mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 04:28:49 +03:00
Merge pull request #418 from LorenDB/fixEmojiCategories
Fix emoji categories
This commit is contained in:
commit
a5cd283423
5 changed files with 42 additions and 48 deletions
|
@ -126,7 +126,7 @@ Popup {
|
||||||
interval: 350 // tweak as needed?
|
interval: 350 // tweak as needed?
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
emojiPopup.model.filter = emojiSearch.text;
|
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
|
// TODO: Would like to get 'simple' icons for the categories
|
||||||
ListElement {
|
ListElement {
|
||||||
image: ":/icons/icons/emoji-categories/people.png"
|
image: ":/icons/icons/emoji-categories/people.png"
|
||||||
category: EmojiCategory.People
|
category: Emoji.Category.People
|
||||||
}
|
}
|
||||||
|
|
||||||
ListElement {
|
ListElement {
|
||||||
image: ":/icons/icons/emoji-categories/nature.png"
|
image: ":/icons/icons/emoji-categories/nature.png"
|
||||||
category: EmojiCategory.Nature
|
category: Emoji.Category.Nature
|
||||||
}
|
}
|
||||||
|
|
||||||
ListElement {
|
ListElement {
|
||||||
image: ":/icons/icons/emoji-categories/foods.png"
|
image: ":/icons/icons/emoji-categories/foods.png"
|
||||||
category: EmojiCategory.Food
|
category: Emoji.Category.Food
|
||||||
}
|
}
|
||||||
|
|
||||||
ListElement {
|
ListElement {
|
||||||
image: ":/icons/icons/emoji-categories/activity.png"
|
image: ":/icons/icons/emoji-categories/activity.png"
|
||||||
category: EmojiCategory.Activity
|
category: Emoji.Category.Activity
|
||||||
}
|
}
|
||||||
|
|
||||||
ListElement {
|
ListElement {
|
||||||
image: ":/icons/icons/emoji-categories/travel.png"
|
image: ":/icons/icons/emoji-categories/travel.png"
|
||||||
category: EmojiCategory.Travel
|
category: Emoji.Category.Travel
|
||||||
}
|
}
|
||||||
|
|
||||||
ListElement {
|
ListElement {
|
||||||
image: ":/icons/icons/emoji-categories/objects.png"
|
image: ":/icons/icons/emoji-categories/objects.png"
|
||||||
category: EmojiCategory.Objects
|
category: Emoji.Category.Objects
|
||||||
}
|
}
|
||||||
|
|
||||||
ListElement {
|
ListElement {
|
||||||
image: ":/icons/icons/emoji-categories/symbols.png"
|
image: ":/icons/icons/emoji-categories/symbols.png"
|
||||||
category: EmojiCategory.Symbols
|
category: Emoji.Category.Symbols
|
||||||
}
|
}
|
||||||
|
|
||||||
ListElement {
|
ListElement {
|
||||||
image: ":/icons/icons/emoji-categories/flags.png"
|
image: ":/icons/icons/emoji-categories/flags.png"
|
||||||
category: EmojiCategory.Flags
|
category: Emoji.Category.Flags
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -224,21 +224,21 @@ Popup {
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
ToolTip.text: {
|
ToolTip.text: {
|
||||||
switch (model.category) {
|
switch (model.category) {
|
||||||
case EmojiCategory.People:
|
case Emoji.Category.People:
|
||||||
return qsTr('People');
|
return qsTr('People');
|
||||||
case EmojiCategory.Nature:
|
case Emoji.Category.Nature:
|
||||||
return qsTr('Nature');
|
return qsTr('Nature');
|
||||||
case EmojiCategory.Food:
|
case Emoji.Category.Food:
|
||||||
return qsTr('Food');
|
return qsTr('Food');
|
||||||
case EmojiCategory.Activity:
|
case Emoji.Category.Activity:
|
||||||
return qsTr('Activity');
|
return qsTr('Activity');
|
||||||
case EmojiCategory.Travel:
|
case Emoji.Category.Travel:
|
||||||
return qsTr('Travel');
|
return qsTr('Travel');
|
||||||
case EmojiCategory.Objects:
|
case Emoji.Category.Objects:
|
||||||
return qsTr('Objects');
|
return qsTr('Objects');
|
||||||
case EmojiCategory.Symbols:
|
case Emoji.Category.Symbols:
|
||||||
return qsTr('Symbols');
|
return qsTr('Symbols');
|
||||||
case EmojiCategory.Flags:
|
case Emoji.Category.Flags:
|
||||||
return qsTr('Flags');
|
return qsTr('Flags');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -295,7 +295,7 @@ Popup {
|
||||||
ToolTip.visible: hovered
|
ToolTip.visible: hovered
|
||||||
onClicked: {
|
onClicked: {
|
||||||
// clear any filters
|
// clear any filters
|
||||||
emojiPopup.model.category = EmojiCategory.Search;
|
emojiPopup.model.category = Emoji.Category.Search;
|
||||||
gridView.positionViewAtBeginning();
|
gridView.positionViewAtBeginning();
|
||||||
emojiSearch.forceActiveFocus();
|
emojiSearch.forceActiveFocus();
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,14 +63,14 @@ EmojiProxyModel::EmojiProxyModel(QObject *parent)
|
||||||
|
|
||||||
EmojiProxyModel::~EmojiProxyModel() {}
|
EmojiProxyModel::~EmojiProxyModel() {}
|
||||||
|
|
||||||
EmojiCategory
|
Emoji::Category
|
||||||
EmojiProxyModel::category() const
|
EmojiProxyModel::category() const
|
||||||
{
|
{
|
||||||
return category_;
|
return category_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
EmojiProxyModel::setCategory(EmojiCategory cat)
|
EmojiProxyModel::setCategory(Emoji::Category cat)
|
||||||
{
|
{
|
||||||
if (category_ == cat) {
|
if (category_ == cat) {
|
||||||
return;
|
return;
|
||||||
|
@ -106,7 +106,7 @@ EmojiProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent
|
||||||
const Emoji emoji = index.data(static_cast<int>(EmojiModel::Roles::Emoji)).value<Emoji>();
|
const Emoji emoji = index.data(static_cast<int>(EmojiModel::Roles::Emoji)).value<Emoji>();
|
||||||
|
|
||||||
// TODO: Add favorites / recently used
|
// TODO: Add favorites / recently used
|
||||||
if (category_ != EmojiCategory::Search) {
|
if (category_ != Emoji::Category::Search) {
|
||||||
return emoji.category == category_;
|
return emoji.category == category_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,15 +36,15 @@ class EmojiProxyModel : public QSortFilterProxyModel
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(
|
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)
|
Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit EmojiProxyModel(QObject *parent = nullptr);
|
explicit EmojiProxyModel(QObject *parent = nullptr);
|
||||||
~EmojiProxyModel() override;
|
~EmojiProxyModel() override;
|
||||||
|
|
||||||
EmojiCategory category() const;
|
Emoji::Category category() const;
|
||||||
void setCategory(EmojiCategory cat);
|
void setCategory(Emoji::Category cat);
|
||||||
|
|
||||||
QString filter() const;
|
QString filter() const;
|
||||||
void setFilter(const QString &filter);
|
void setFilter(const QString &filter);
|
||||||
|
@ -57,7 +57,7 @@ protected:
|
||||||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EmojiCategory category_ = EmojiCategory::Search;
|
Emoji::Category category_ = Emoji::Category::Search;
|
||||||
emoji::Provider emoji_provider_;
|
emoji::Provider emoji_provider_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -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"
|
#include "emoji/Provider.h"
|
||||||
|
|
||||||
using namespace emoji;
|
using namespace emoji;
|
||||||
|
|
|
@ -26,32 +26,32 @@
|
||||||
namespace emoji {
|
namespace emoji {
|
||||||
Q_NAMESPACE
|
Q_NAMESPACE
|
||||||
|
|
||||||
enum class EmojiCategory
|
|
||||||
{
|
|
||||||
People,
|
|
||||||
Nature,
|
|
||||||
Food,
|
|
||||||
Activity,
|
|
||||||
Travel,
|
|
||||||
Objects,
|
|
||||||
Symbols,
|
|
||||||
Flags,
|
|
||||||
Search
|
|
||||||
};
|
|
||||||
Q_ENUM_NS(EmojiCategory)
|
|
||||||
|
|
||||||
struct Emoji
|
struct Emoji
|
||||||
{
|
{
|
||||||
Q_GADGET
|
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 &unicode MEMBER unicode)
|
||||||
Q_PROPERTY(const QString &shortName MEMBER shortName)
|
Q_PROPERTY(const QString &shortName MEMBER shortName)
|
||||||
Q_PROPERTY(emoji::EmojiCategory category MEMBER category)
|
Q_PROPERTY(emoji::Emoji::Category category MEMBER category)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString unicode;
|
QString unicode;
|
||||||
QString shortName;
|
QString shortName;
|
||||||
EmojiCategory category;
|
Category category;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Provider
|
class Provider
|
||||||
|
|
Loading…
Reference in a new issue