diff --git a/CMakeLists.txt b/CMakeLists.txt index abc2f8b..4b541df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,120 +1,120 @@ cmake_minimum_required(VERSION 3.5) -set(PIM_VERSION "5.11.41") +set(PIM_VERSION "5.11.42") project(KPimTextEdit VERSION ${PIM_VERSION}) # ECM setup set(KF5_MIN_VERSION "5.58.0") find_package(ECM ${KF5_MIN_VERSION} CONFIG REQUIRED) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) if (POLICY CMP0053) cmake_policy(SET CMP0053 NEW) endif() include(GenerateExportHeader) include(ECMGenerateHeaders) include(ECMGeneratePriFile) include(ECMSetupVersion) include(FeatureSummary) include(KDEInstallDirs) include(KDECMakeSettings) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(ECMAddTests) include(ECMQtDeclareLoggingCategory) set(KPIMTEXTEDIT_LIB_VERSION ${PIM_VERSION}) ecm_setup_version(PROJECT VARIABLE_PREFIX KPIMTEXTEDIT VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kpimtextedit_version.h" PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5PimTextEditConfigVersion.cmake" SOVERSION 5 ) set(QT_REQUIRED_VERSION "5.10.0") find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED COMPONENTS Widgets) find_package(Grantlee5 "5.1" CONFIG REQUIRED) set_package_properties(Grantlee5 PROPERTIES DESCRIPTION "A plug-in based String Template system for Qt" URL "http://github.com/steveire/grantlee" PURPOSE "Required for the RichText composer" TYPE REQUIRED ) find_package(KF5DesignerPlugin ${KF5_MIN_VERSION} CONFIG) set_package_properties(KF5DesignerPlugin PROPERTIES DESCRIPTION "KF5 designer plugin" TYPE OPTIONAL) ########### Find packages ########### find_package(KF5Codecs ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Config ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5ConfigWidgets ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5CoreAddons ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Emoticons ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5I18n ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5IconThemes ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5KIO ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Sonnet ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5SyntaxHighlighting ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5WidgetsAddons ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5XmlGui ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5DesignerPlugin ${KF5_MIN_VERSION} CONFIG) set_package_properties(KF5DesignerPlugin PROPERTIES DESCRIPTION "KF5 designer plugin" TYPE OPTIONAL) add_definitions(-DTRANSLATION_DOMAIN=\"libkpimtextedit\") add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x060000) add_definitions(-DQT_NO_FOREACH) find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED COMPONENTS TextToSpeech) if(BUILD_TESTING) find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED COMPONENTS Test) add_definitions(-DBUILD_TESTING) endif() ########### Targets ########### add_subdirectory(src) if(BUILD_TESTING) find_package(KF5TextWidgets ${KF5_MIN_VERSION} CONFIG REQUIRED) add_subdirectory(autotests) add_subdirectory(tests) endif() ########### CMake Config Files ########### set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5PimTextEdit") configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/KF5PimTextEditConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/KF5PimTextEditConfig.cmake" INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KF5PimTextEditConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/KF5PimTextEditConfigVersion.cmake" DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) install(EXPORT KF5PimTextEditTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5PimTextEditTargets.cmake NAMESPACE KF5:: ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kpimtextedit_version.h DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5} COMPONENT Devel ) install( FILES kpimtextedit.categories DESTINATION ${KDE_INSTALL_CONFDIR} ) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/src/emoticon/emoticonlistwidgetselector.cpp b/src/emoticon/emoticonlistwidgetselector.cpp index 5468604..e4848b7 100644 --- a/src/emoticon/emoticonlistwidgetselector.cpp +++ b/src/emoticon/emoticonlistwidgetselector.cpp @@ -1,143 +1,87 @@ /* Copyright (c) 2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "emoticonlistwidgetselector.h" -#include -#include #include "kpimtextedit_debug.h" -// Use a static for this as calls to the KEmoticons constructor are expensive. -Q_GLOBAL_STATIC(KEmoticons, sEmoticons) using namespace KPIMTextEdit; EmoticonTextEditItem::EmoticonTextEditItem(const QString &emoticonText, QListWidget *parent) : QListWidgetItem(parent) { mText = emoticonText; setText(mText); } -EmoticonTextEditItem::EmoticonTextEditItem(const QString &emoticonText, const QString &pixmapPath, QListWidget *parent) - : QListWidgetItem(parent) -{ - mText = emoticonText; - mPixmapPath = pixmapPath; - QPixmap p(mPixmapPath); - // Some of the custom icons are rather large - // so lets limit them to a maximum size for this display panel - // - - //TODO need to fix hdpi support here. - if (p.width() > 32 || p.height() > 32) { - p = p.scaled(QSize(32, 32), Qt::KeepAspectRatio); - } - - setIcon(p); - setToolTip(mText); -} QString EmoticonTextEditItem::text() const { return mText; } QString EmoticonTextEditItem::pixmapPath() const { return mPixmapPath; } EmoticonListWidgetSelector::EmoticonListWidgetSelector(QWidget *parent) : QListWidget(parent) { setViewMode(QListView::IconMode); setSelectionMode(QAbstractItemView::SingleSelection); setMouseTracking(true); setDragEnabled(false); connect(this, &EmoticonListWidgetSelector::itemEntered, this, &EmoticonListWidgetSelector::slotMouseOverItem); connect(this, &EmoticonListWidgetSelector::itemClicked, this, &EmoticonListWidgetSelector::slotEmoticonClicked); setIconSize(QSize(32, 32)); QFont f; f.setPointSize(22); f.setFamily(QStringLiteral("NotoColorEmoji")); setFont(f); } EmoticonListWidgetSelector::~EmoticonListWidgetSelector() { } void EmoticonListWidgetSelector::slotMouseOverItem(QListWidgetItem *item) { item->setSelected(true); if (!hasFocus()) { setFocus(); } } -void EmoticonListWidgetSelector::loadEmotionsFromTheme() -{ - static QString cachedEmoticonsThemeName; - if (cachedEmoticonsThemeName.isEmpty()) { - cachedEmoticonsThemeName = KEmoticons::currentThemeName(); - } - const QHash list - = sEmoticons->theme(cachedEmoticonsThemeName).emoticonsMap(); - - if (list.isEmpty()) { - qCWarning(KPIMTEXTEDIT_LOG) << "It seems that there is a problem with emoticon support in KDE"; - } else { - //Keep in sync with linklocator.cpp - QStringList exclude; - exclude << QStringLiteral("(c)") << QStringLiteral("(C)") << QStringLiteral(">:-(") << QStringLiteral(">:(") << QStringLiteral("(B)") << QStringLiteral("(b)") << QStringLiteral("(P)") - << QStringLiteral("(p)"); - exclude << QStringLiteral("(O)") << QStringLiteral("(o)") << QStringLiteral("(D)") << QStringLiteral("(d)") << QStringLiteral("(E)") << QStringLiteral("(e)") << QStringLiteral("(K)") - << QStringLiteral("(k)"); - exclude << QStringLiteral("(I)") << QStringLiteral("(i)") << QStringLiteral("(L)") << QStringLiteral("(l)") << QStringLiteral("(8)") << QStringLiteral("(T)") << QStringLiteral("(t)") - << QStringLiteral("(G)"); - exclude << QStringLiteral("(g)") << QStringLiteral("(F)") << QStringLiteral("(f)") << QStringLiteral("(H)"); - exclude << QStringLiteral("8)") << QStringLiteral("(N)") << QStringLiteral("(n)") << QStringLiteral("(Y)") << QStringLiteral("(y)") << QStringLiteral("(U)") << QStringLiteral("(u)") - << QStringLiteral("(W)") << QStringLiteral("(w)"); - - const QHash::const_iterator end = list.constEnd(); - for (QHash::const_iterator it = list.constBegin(); it != end; ++it) { - const QString str = it.value().first(); - if (!exclude.contains(str)) { - new EmoticonTextEditItem(str, it.key(), this); - } - } - } -} - void EmoticonListWidgetSelector::setEmoticons(const QList &lst) { for (uint emoji : lst) { const QString str = QString::fromUcs4(&emoji, 1); new KPIMTextEdit::EmoticonTextEditItem(str, this); } } void EmoticonListWidgetSelector::slotEmoticonClicked(QListWidgetItem *item) { if (!item) { return; } EmoticonTextEditItem *itemEmoticon = static_cast(item); Q_EMIT itemSelected(itemEmoticon->text()); } diff --git a/src/emoticon/emoticonlistwidgetselector.h b/src/emoticon/emoticonlistwidgetselector.h index 35e7c5b..a8c3cc2 100644 --- a/src/emoticon/emoticonlistwidgetselector.h +++ b/src/emoticon/emoticonlistwidgetselector.h @@ -1,58 +1,56 @@ /* Copyright (c) 2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef EMOTICONLISTWIDGETSELECTOR_H #define EMOTICONLISTWIDGETSELECTOR_H #include #include "kpimtextedit_private_export.h" namespace KPIMTextEdit { class KPIMTEXTEDIT_TESTS_EXPORT EmoticonTextEditItem : public QListWidgetItem { public: - explicit EmoticonTextEditItem(const QString &emoticonText, const QString &pixmapPath, QListWidget *parent); explicit EmoticonTextEditItem(const QString &emoticonText, QListWidget *parent); QString text() const; QString pixmapPath() const; private: QString mText; QString mPixmapPath; }; class KPIMTEXTEDIT_TESTS_EXPORT EmoticonListWidgetSelector : public QListWidget { Q_OBJECT public: explicit EmoticonListWidgetSelector(QWidget *parent = nullptr); ~EmoticonListWidgetSelector(); void setEmoticons(const QList &lst); - void loadEmotionsFromTheme(); Q_SIGNALS: void itemSelected(const QString &); private: void slotMouseOverItem(QListWidgetItem *item); void slotEmoticonClicked(QListWidgetItem *item); }; } #endif // EMOTICONLISTWIDGETSELECTOR_H diff --git a/src/emoticon/emoticontexteditaction.cpp b/src/emoticon/emoticontexteditaction.cpp index e44312c..f0e582e 100644 --- a/src/emoticon/emoticontexteditaction.cpp +++ b/src/emoticon/emoticontexteditaction.cpp @@ -1,72 +1,68 @@ /* Copyright (c) 2012-2019 Montel Laurent based on code from kopete This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "emoticontexteditaction.h" #include "emoticontexteditselector.h" #include #include #include #include using namespace KPIMTextEdit; class EmoticonTextEditAction::EmoticonTextEditActionPrivate { public: EmoticonTextEditActionPrivate() { emoticonMenu = new QMenu(); selector = new EmoticonTextEditSelector(emoticonMenu); QWidgetAction *action = new QWidgetAction(emoticonMenu); action->setDefaultWidget(selector); emoticonMenu->addAction(action); connect(emoticonMenu, &QMenu::aboutToShow, selector, &EmoticonTextEditSelector::loadEmoticons); } ~EmoticonTextEditActionPrivate() { delete emoticonMenu; } QMenu *emoticonMenu = nullptr; EmoticonTextEditSelector *selector = nullptr; }; EmoticonTextEditAction::EmoticonTextEditAction(QObject *parent) : KActionMenu(i18n("Add Smiley"), parent) , d(new EmoticonTextEditActionPrivate()) { delete menu(); setMenu(d->emoticonMenu); setIcon(QIcon::fromTheme(QStringLiteral("face-smile"))); setDelayed(false); connect(d->selector, &EmoticonTextEditSelector::itemSelected, this, &EmoticonTextEditAction::emoticonActivated); } EmoticonTextEditAction::~EmoticonTextEditAction() { delete d; } -void EmoticonTextEditAction::setEmojiPlainText(bool b) -{ - d->selector->setEmojiPlainText(b); -} diff --git a/src/emoticon/emoticontexteditaction.h b/src/emoticon/emoticontexteditaction.h index 72d4923..c10f4d0 100644 --- a/src/emoticon/emoticontexteditaction.h +++ b/src/emoticon/emoticontexteditaction.h @@ -1,47 +1,45 @@ /* Copyright (c) 2012-2019 Montel Laurent based on code from kopete This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KPIMTEXTEDIT_EMOTICONTEXTEDITACTION_H #define KPIMTEXTEDIT_EMOTICONTEXTEDITACTION_H #include "kpimtextedit_export.h" #include namespace KPIMTextEdit { class EmoticonTextEditAction : public KActionMenu { Q_OBJECT public: explicit EmoticonTextEditAction(QObject *parent); ~EmoticonTextEditAction(); - void setEmojiPlainText(bool b); - Q_SIGNALS: void emoticonActivated(const QString &); private: class EmoticonTextEditActionPrivate; EmoticonTextEditActionPrivate *const d; }; } #endif /* KPIMTEXTEDIT_EMOTICONTEXTEDITACTION_H */ diff --git a/src/emoticon/emoticontexteditselector.cpp b/src/emoticon/emoticontexteditselector.cpp index ce540d7..9609156 100644 --- a/src/emoticon/emoticontexteditselector.cpp +++ b/src/emoticon/emoticontexteditselector.cpp @@ -1,72 +1,64 @@ /* Copyright (c) 2012-2019 Montel Laurent based on code from kopete This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "emoticontexteditselector.h" #include "emoticonunicodetab.h" #include "textutils.h" #include #include #include #include #include using namespace KPIMTextEdit; EmoticonTextEditSelector::EmoticonTextEditSelector(QWidget *parent) : QWidget(parent) { QHBoxLayout *lay = new QHBoxLayout(this); lay->setSpacing(0); lay->setContentsMargins(0, 0, 0, 0); mUnicodeTab = new EmoticonUnicodeTab(this); lay->addWidget(mUnicodeTab); connect(mUnicodeTab, &EmoticonUnicodeTab::itemSelected, this, &EmoticonTextEditSelector::slotItemSelected); } EmoticonTextEditSelector::~EmoticonTextEditSelector() { } void EmoticonTextEditSelector::slotItemSelected(const QString &str) { Q_EMIT itemSelected(str); if (isVisible() && parentWidget() && parentWidget()->inherits("QMenu")) { parentWidget()->close(); } } void EmoticonTextEditSelector::loadEmoticons() { if (mUnicodeTab->count() == 0) { mUnicodeTab->loadEmoticons(); } } -bool EmoticonTextEditSelector::emojiPlainText() const -{ - return mUnicodeTab->emojiPlainText(); -} -void EmoticonTextEditSelector::setEmojiPlainText(bool emojiPlainText) -{ - mUnicodeTab->setEmojiPlainText(emojiPlainText); -} diff --git a/src/emoticon/emoticontexteditselector.h b/src/emoticon/emoticontexteditselector.h index 596abee..099e2da 100644 --- a/src/emoticon/emoticontexteditselector.h +++ b/src/emoticon/emoticontexteditselector.h @@ -1,51 +1,48 @@ /* Copyright (c) 2012-2019 Montel Laurent based on code from kopete This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KPIMTEXTEDIT_EMOTICONTEXTEDITSELECTOR_H #define KPIMTEXTEDIT_EMOTICONTEXTEDITSELECTOR_H #include #include namespace KPIMTextEdit { class EmoticonListWidgetSelector; class EmoticonUnicodeTab; class EmoticonTextEditSelector : public QWidget { Q_OBJECT public: explicit EmoticonTextEditSelector(QWidget *parent = nullptr); ~EmoticonTextEditSelector(); - Q_REQUIRED_RESULT bool emojiPlainText() const; - void setEmojiPlainText(bool emojiPlainText); - public Q_SLOTS: void loadEmoticons(); Q_SIGNALS: void itemSelected(const QString &); private: void slotItemSelected(const QString &str); EmoticonUnicodeTab *mUnicodeTab = nullptr; }; } #endif /* KPIMTEXTEDIT_EMOTICONTEXTEDITSELECTOR_H */ diff --git a/src/emoticon/emoticonunicodetab.cpp b/src/emoticon/emoticonunicodetab.cpp index b1b0430..2bb6683 100644 --- a/src/emoticon/emoticonunicodetab.cpp +++ b/src/emoticon/emoticonunicodetab.cpp @@ -1,105 +1,81 @@ /* Copyright (c) 2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "emoticonunicodetab.h" #include "emoticonlistwidgetselector.h" #include "textutils.h" #include using namespace KPIMTextEdit; EmoticonUnicodeTab::EmoticonUnicodeTab(QWidget *parent) : QTabWidget(parent) { setTabBarAutoHide(true); loadEmoticons(); QFont f; f.setPointSize(22); f.setFamily(QStringLiteral("NotoColorEmoji")); setFont(f); } EmoticonUnicodeTab::~EmoticonUnicodeTab() { } void EmoticonUnicodeTab::loadEmoticons() { - if (mEmojiPlainText) { - createPlainTextEmoticonTab(i18n("Faces"), TextUtils::unicodeFacesEmoji()); - createPlainTextEmoticonTab(i18n("Animals"), TextUtils::unicodeAnimalsEmoji()); - createPlainTextEmoticonTab(i18n("Emotions"), TextUtils::unicodeEmotionEmoji()); - createPlainTextEmoticonTab(i18n("Body"), TextUtils::unicodeBodyEmoji()); - createPlainTextEmoticonTab(i18n("Transports"), TextUtils::unicodeTransportEmoji()); - createPlainTextEmoticonTab(i18n("Events"), TextUtils::unicodeEventEmoji()); - createPlainTextEmoticonTab(i18n("Flags"), TextUtils::unicodeFlagsEmoji()); - createPlainTextEmoticonTab(i18n("Weather"), TextUtils::unicodeWeatherEmoji()); - createPlainTextEmoticonTab(i18n("Foods"), TextUtils::unicodeFoodEmoji()); - createPlainTextEmoticonTab(i18n("Sports"), TextUtils::unicodeSportEmoji()); - createPlainTextEmoticonTab(i18n("Time"), TextUtils::unicodeTimeEmoji()); - createPlainTextEmoticonTab(i18n("Game"), TextUtils::unicodeGameEmoji()); - createPlainTextEmoticonTab(i18n("Clothing"), TextUtils::unicodeClothingEmoji()); - createPlainTextEmoticonTab(i18n("Music"), TextUtils::unicodeSoundMusicEmoji()); - createPlainTextEmoticonTab(i18n("Computer"), TextUtils::unicodeComputerEmoji()); - createPlainTextEmoticonTab(i18n("Symbols"), TextUtils::unicodeSymbolsEmoji()); - createPlainTextEmoticonTab(i18n("Face"), TextUtils::unicodeFaceEmoji()); - createPlainTextEmoticonTab(i18n("Fantasy"), TextUtils::unicodeFantasyEmoji()); - createPlainTextEmoticonTab(i18n("Plant"), TextUtils::unicodePlantEmoji()); - createPlainTextEmoticonTab(i18n("Travel"), TextUtils::unicodeTravelEmoji()); - createPlainTextEmoticonTab(i18n("Book"), TextUtils::unicodeBookPaperEmoji()); - createPlainTextEmoticonTab(i18n("Book Tools"), TextUtils::unicodeBookToolsEmoji()); - createPlainTextEmoticonTab(i18n("Science"), TextUtils::unicodeScienceEmoji()); - } else { - createHtmlEmoticonTab(); - } -} - -void EmoticonUnicodeTab::createHtmlEmoticonTab() -{ - EmoticonListWidgetSelector *selector = new EmoticonListWidgetSelector(this); - selector->loadEmotionsFromTheme(); - addTab(selector, QString()); - connect(selector, &KPIMTextEdit::EmoticonListWidgetSelector::itemSelected, this, &EmoticonUnicodeTab::itemSelected); + createPlainTextEmoticonTab(i18n("Faces"), TextUtils::unicodeFacesEmoji()); + createPlainTextEmoticonTab(i18n("Animals"), TextUtils::unicodeAnimalsEmoji()); + createPlainTextEmoticonTab(i18n("Emotions"), TextUtils::unicodeEmotionEmoji()); + createPlainTextEmoticonTab(i18n("Body"), TextUtils::unicodeBodyEmoji()); + createPlainTextEmoticonTab(i18n("Transports"), TextUtils::unicodeTransportEmoji()); + createPlainTextEmoticonTab(i18n("Events"), TextUtils::unicodeEventEmoji()); + createPlainTextEmoticonTab(i18n("Flags"), TextUtils::unicodeFlagsEmoji()); + createPlainTextEmoticonTab(i18n("Weather"), TextUtils::unicodeWeatherEmoji()); + createPlainTextEmoticonTab(i18n("Foods"), TextUtils::unicodeFoodEmoji()); + createPlainTextEmoticonTab(i18n("Sports"), TextUtils::unicodeSportEmoji()); + createPlainTextEmoticonTab(i18n("Time"), TextUtils::unicodeTimeEmoji()); + createPlainTextEmoticonTab(i18n("Game"), TextUtils::unicodeGameEmoji()); + createPlainTextEmoticonTab(i18n("Clothing"), TextUtils::unicodeClothingEmoji()); + createPlainTextEmoticonTab(i18n("Music"), TextUtils::unicodeSoundMusicEmoji()); + createPlainTextEmoticonTab(i18n("Computer"), TextUtils::unicodeComputerEmoji()); + createPlainTextEmoticonTab(i18n("Symbols"), TextUtils::unicodeSymbolsEmoji()); + createPlainTextEmoticonTab(i18n("Face"), TextUtils::unicodeFaceEmoji()); + createPlainTextEmoticonTab(i18n("Fantasy"), TextUtils::unicodeFantasyEmoji()); + createPlainTextEmoticonTab(i18n("Plant"), TextUtils::unicodePlantEmoji()); + createPlainTextEmoticonTab(i18n("Travel"), TextUtils::unicodeTravelEmoji()); + createPlainTextEmoticonTab(i18n("Book"), TextUtils::unicodeBookPaperEmoji()); + createPlainTextEmoticonTab(i18n("Book Tools"), TextUtils::unicodeBookToolsEmoji()); + createPlainTextEmoticonTab(i18n("Science"), TextUtils::unicodeScienceEmoji()); } void EmoticonUnicodeTab::createPlainTextEmoticonTab(const QString &str, const QList &emoticons) { if (!emoticons.isEmpty()) { EmoticonListWidgetSelector *selector = new EmoticonListWidgetSelector(this); connect(selector, &KPIMTextEdit::EmoticonListWidgetSelector::itemSelected, this, &EmoticonUnicodeTab::itemSelected); selector->setEmoticons(emoticons); const QString strTab = QString::fromUcs4(&emoticons.at(0), 1); const int index = addTab(selector, strTab); if (!str.isEmpty()) { setTabToolTip(index, str); } } } -bool EmoticonUnicodeTab::emojiPlainText() const -{ - return mEmojiPlainText; -} - -void EmoticonUnicodeTab::setEmojiPlainText(bool emojiPlainText) -{ - if (mEmojiPlainText != emojiPlainText) { - mEmojiPlainText = emojiPlainText; - clear(); - } -} diff --git a/src/emoticon/emoticonunicodetab.h b/src/emoticon/emoticonunicodetab.h index 7cd3652..e0a5c87 100644 --- a/src/emoticon/emoticonunicodetab.h +++ b/src/emoticon/emoticonunicodetab.h @@ -1,50 +1,45 @@ /* Copyright (c) 2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef EMOTICONUNICODETAB_H #define EMOTICONUNICODETAB_H #include #include "kpimtextedit_export.h" namespace KPIMTextEdit { class KPIMTEXTEDIT_EXPORT EmoticonUnicodeTab : public QTabWidget { Q_OBJECT public: explicit EmoticonUnicodeTab(QWidget *parent = nullptr); ~EmoticonUnicodeTab(); - Q_REQUIRED_RESULT bool emojiPlainText() const; - void setEmojiPlainText(bool emojiPlainText); - void loadEmoticons(); Q_SIGNALS: void itemSelected(const QString &); private: void createPlainTextEmoticonTab(const QString &str, const QList &emoticons); - void createHtmlEmoticonTab(); - bool mEmojiPlainText = true; }; } #endif // EMOTICONUNICODETAB_H