From bc7cf9ef39d82da70af62e1433d5de2e2a7d45f7 Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Fri, 22 Jan 2021 20:07:23 -0500 Subject: [PATCH 1/3] Get category switching working --- resources/qml/emoji/EmojiPicker.qml | 36 ++++++++++++++--------------- src/emoji/EmojiModel.cpp | 6 ++--- src/emoji/EmojiModel.h | 10 ++++---- src/emoji/Provider.h | 31 +++++++++++++------------ 4 files changed, 42 insertions(+), 41 deletions(-) diff --git a/resources/qml/emoji/EmojiPicker.qml b/resources/qml/emoji/EmojiPicker.qml index e0e1ceaf..7c75e010 100644 --- a/resources/qml/emoji/EmojiPicker.qml +++ b/resources/qml/emoji/EmojiPicker.qml @@ -126,7 +126,7 @@ Popup { interval: 350 // tweak as needed? onTriggered: { emojiPopup.model.filter = emojiSearch.text; - emojiPopup.model.category = EmojiCategory.Search; + emojiPopup.model.category = Emoji.Category.Search; } } @@ -178,42 +178,42 @@ Popup { // TODO: Would like to get 'simple' icons for the categories ListElement { image: ":/icons/icons/emoji-categories/people.png" - category: EmojiCategory.People + category: Emoji.Category.People } ListElement { image: ":/icons/icons/emoji-categories/nature.png" - category: EmojiCategory.Nature + category: Emoji.Category.Nature } ListElement { image: ":/icons/icons/emoji-categories/foods.png" - category: EmojiCategory.Food + category: Emoji.Category.Food } ListElement { image: ":/icons/icons/emoji-categories/activity.png" - category: EmojiCategory.Activity + category: Emoji.Category.Activity } ListElement { image: ":/icons/icons/emoji-categories/travel.png" - category: EmojiCategory.Travel + category: Emoji.Category.Travel } ListElement { image: ":/icons/icons/emoji-categories/objects.png" - category: EmojiCategory.Objects + category: Emoji.Category.Objects } ListElement { image: ":/icons/icons/emoji-categories/symbols.png" - category: EmojiCategory.Symbols + category: Emoji.Category.Symbols } ListElement { image: ":/icons/icons/emoji-categories/flags.png" - category: EmojiCategory.Flags + category: Emoji.Category.Flags } } @@ -224,21 +224,21 @@ Popup { hoverEnabled: true ToolTip.text: { switch (model.category) { - case EmojiCategory.People: + case Emoji.Category.People: return qsTr('People'); - case EmojiCategory.Nature: + case Emoji.Category.Nature: return qsTr('Nature'); - case EmojiCategory.Food: + case Emoji.Category.Food: return qsTr('Food'); - case EmojiCategory.Activity: + case Emoji.Category.Activity: return qsTr('Activity'); - case EmojiCategory.Travel: + case Emoji.Category.Travel: return qsTr('Travel'); - case EmojiCategory.Objects: + case Emoji.Category.Objects: return qsTr('Objects'); - case EmojiCategory.Symbols: + case Emoji.Category.Symbols: return qsTr('Symbols'); - case EmojiCategory.Flags: + case Emoji.Category.Flags: return qsTr('Flags'); } } @@ -295,7 +295,7 @@ Popup { ToolTip.visible: hovered onClicked: { // clear any filters - emojiPopup.model.category = EmojiCategory.Search; + emojiPopup.model.category = Emoji.Category.Search; gridView.positionViewAtBeginning(); emojiSearch.forceActiveFocus(); } diff --git a/src/emoji/EmojiModel.cpp b/src/emoji/EmojiModel.cpp index 85c2dd34..f207c740 100644 --- a/src/emoji/EmojiModel.cpp +++ b/src/emoji/EmojiModel.cpp @@ -63,14 +63,14 @@ EmojiProxyModel::EmojiProxyModel(QObject *parent) EmojiProxyModel::~EmojiProxyModel() {} -EmojiCategory +Emoji::Category EmojiProxyModel::category() const { return category_; } void -EmojiProxyModel::setCategory(EmojiCategory cat) +EmojiProxyModel::setCategory(Emoji::Category cat) { if (category_ == cat) { return; @@ -106,7 +106,7 @@ EmojiProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent const Emoji emoji = index.data(static_cast(EmojiModel::Roles::Emoji)).value(); // TODO: Add favorites / recently used - if (category_ != EmojiCategory::Search) { + if (category_ != Emoji::Category::Search) { return emoji.category == category_; } diff --git a/src/emoji/EmojiModel.h b/src/emoji/EmojiModel.h index 88bacdee..938db46d 100644 --- a/src/emoji/EmojiModel.h +++ b/src/emoji/EmojiModel.h @@ -36,15 +36,15 @@ class EmojiProxyModel : public QSortFilterProxyModel Q_OBJECT Q_PROPERTY( - emoji::EmojiCategory category READ category WRITE setCategory NOTIFY categoryChanged) + emoji::Emoji::Category category READ category WRITE setCategory NOTIFY categoryChanged) Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged) public: explicit EmojiProxyModel(QObject *parent = nullptr); ~EmojiProxyModel() override; - EmojiCategory category() const; - void setCategory(EmojiCategory cat); + Emoji::Category category() const; + void setCategory(Emoji::Category cat); QString filter() const; void setFilter(const QString &filter); @@ -57,7 +57,7 @@ protected: bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; private: - EmojiCategory category_ = EmojiCategory::Search; + Emoji::Category category_ = Emoji::Category::Search; emoji::Provider emoji_provider_; }; -} \ No newline at end of file +} diff --git a/src/emoji/Provider.h b/src/emoji/Provider.h index ad03eb26..9b2234ba 100644 --- a/src/emoji/Provider.h +++ b/src/emoji/Provider.h @@ -26,32 +26,33 @@ namespace emoji { Q_NAMESPACE -enum class EmojiCategory -{ - People, - Nature, - Food, - Activity, - Travel, - Objects, - Symbols, - Flags, - Search -}; -Q_ENUM_NS(EmojiCategory) struct Emoji { Q_GADGET +public: + enum class Category + { + People, + Nature, + Food, + Activity, + Travel, + Objects, + Symbols, + Flags, + Search + }; + Q_ENUM(Category) Q_PROPERTY(const QString &unicode MEMBER unicode) Q_PROPERTY(const QString &shortName MEMBER shortName) - Q_PROPERTY(emoji::EmojiCategory category MEMBER category) + Q_PROPERTY(emoji::Emoji::Category category MEMBER category) public: QString unicode; QString shortName; - EmojiCategory category; + Category category; }; class Provider From 7629e9b786bbb5838fcddab5ac4fe82ed483e633 Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Fri, 22 Jan 2021 20:50:03 -0500 Subject: [PATCH 2/3] Use new enum structure in emoji generation script --- src/emoji/Provider.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/emoji/Provider.cpp b/src/emoji/Provider.cpp index eff57c9f..42adc271 100644 --- a/src/emoji/Provider.cpp +++ b/src/emoji/Provider.cpp @@ -1,9 +1,3 @@ -/* - This file contains a single definition of all of the emoji from Provider.cpp. - It is being split out into a separate code file to alleviate compilation issues - in some versions of clang. -*/ - #include "emoji/Provider.h" using namespace emoji; From e57dc5ea83f4cbab62f49e2b828ea2d82922cddb Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Fri, 22 Jan 2021 21:16:24 -0500 Subject: [PATCH 3/3] Make lint --- src/emoji/Provider.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/emoji/Provider.h b/src/emoji/Provider.h index 9b2234ba..068162f4 100644 --- a/src/emoji/Provider.h +++ b/src/emoji/Provider.h @@ -26,7 +26,6 @@ namespace emoji { Q_NAMESPACE - struct Emoji { Q_GADGET