summary refs log tree commit diff
path: root/src/emoji
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2017-11-30 20:02:46 +0200
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2017-11-30 20:02:46 +0200
commiteae069ad93a6822e8cb96522708115793c01c5d7 (patch)
treee44b67a82110051f90ce8555a3520f62456be02b /src/emoji
parentCreate directories for related files (diff)
downloadnheko-eae069ad93a6822e8cb96522708115793c01c5d7.tar.xz
Group emoji and dialogs with namespaces
Diffstat (limited to 'src/emoji')
-rw-r--r--src/emoji/Category.cc (renamed from src/emoji/EmojiCategory.cc)14
-rw-r--r--src/emoji/ItemDelegate.cc (renamed from src/emoji/EmojiItemDelegate.cc)14
-rw-r--r--src/emoji/Panel.cc (renamed from src/emoji/EmojiPanel.cc)66
-rw-r--r--src/emoji/PickButton.cc (renamed from src/emoji/EmojiPickButton.cc)17
-rw-r--r--src/emoji/Provider.cc (renamed from src/emoji/EmojiProvider.cc)20
5 files changed, 68 insertions, 63 deletions
diff --git a/src/emoji/EmojiCategory.cc b/src/emoji/Category.cc

index 42f09409..6b925ce9 100644 --- a/src/emoji/EmojiCategory.cc +++ b/src/emoji/Category.cc
@@ -21,9 +21,11 @@ #include "Config.h" -#include "emoji/EmojiCategory.h" +#include "emoji/Category.h" -EmojiCategory::EmojiCategory(QString category, QList<Emoji> emoji, QWidget *parent) +using namespace emoji; + +Category::Category(QString category, QList<Emoji> emoji, QWidget *parent) : QWidget(parent) { mainLayout_ = new QVBoxLayout(this); @@ -33,7 +35,7 @@ EmojiCategory::EmojiCategory(QString category, QList<Emoji> emoji, QWidget *pare emojiListView_ = new QListView(); itemModel_ = new QStandardItemModel(this); - delegate_ = new EmojiItemDelegate(this); + delegate_ = new ItemDelegate(this); data_ = new Emoji; emojiListView_->setItemDelegate(delegate_); @@ -75,11 +77,11 @@ EmojiCategory::EmojiCategory(QString category, QList<Emoji> emoji, QWidget *pare mainLayout_->addWidget(category_); mainLayout_->addWidget(emojiListView_); - connect(emojiListView_, &QListView::clicked, this, &EmojiCategory::clickIndex); + connect(emojiListView_, &QListView::clicked, this, &Category::clickIndex); } void -EmojiCategory::paintEvent(QPaintEvent *) +Category::paintEvent(QPaintEvent *) { QStyleOption opt; opt.init(this); @@ -87,4 +89,4 @@ EmojiCategory::paintEvent(QPaintEvent *) style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); } -EmojiCategory::~EmojiCategory() {} +Category::~Category() {} diff --git a/src/emoji/EmojiItemDelegate.cc b/src/emoji/ItemDelegate.cc
index 547d3b4c..2cc838e3 100644 --- a/src/emoji/EmojiItemDelegate.cc +++ b/src/emoji/ItemDelegate.cc
@@ -18,20 +18,22 @@ #include <QDebug> #include <QPainter> -#include "emoji/EmojiItemDelegate.h" +#include "emoji/ItemDelegate.h" -EmojiItemDelegate::EmojiItemDelegate(QObject *parent) +using namespace emoji; + +ItemDelegate::ItemDelegate(QObject *parent) : QStyledItemDelegate(parent) { data_ = new Emoji; } -EmojiItemDelegate::~EmojiItemDelegate() { delete data_; } +ItemDelegate::~ItemDelegate() { delete data_; } void -EmojiItemDelegate::paint(QPainter *painter, - const QStyleOptionViewItem &option, - const QModelIndex &index) const +ItemDelegate::paint(QPainter *painter, + const QStyleOptionViewItem &option, + const QModelIndex &index) const { Q_UNUSED(index); diff --git a/src/emoji/EmojiPanel.cc b/src/emoji/Panel.cc
index 9df6f193..0b99eb81 100644 --- a/src/emoji/EmojiPanel.cc +++ b/src/emoji/Panel.cc
@@ -22,10 +22,12 @@ #include "DropShadow.h" #include "FlatButton.h" -#include "emoji/EmojiCategory.h" -#include "emoji/EmojiPanel.h" +#include "emoji/Category.h" +#include "emoji/Panel.h" -EmojiPanel::EmojiPanel(QWidget *parent) +using namespace emoji; + +Panel::Panel(QWidget *parent) : QWidget(parent) , shadowMargin_{2} , width_{370} @@ -53,9 +55,6 @@ EmojiPanel::EmojiPanel(QWidget *parent) contentLayout->setSpacing(0); auto emojiCategories = new QFrame(mainWidget); - emojiCategories->setStyleSheet( - QString("background-color: %1") - .arg(palette().color(QPalette::Window).darker(110).name())); auto categoriesLayout = new QHBoxLayout(emojiCategories); categoriesLayout->setSpacing(0); @@ -124,79 +123,78 @@ EmojiPanel::EmojiPanel(QWidget *parent) scrollArea_->setWidget(scrollWidget); auto peopleEmoji = - new EmojiCategory(tr("Smileys & People"), emoji_provider_.people, scrollWidget); + new Category(tr("Smileys & People"), emoji_provider_.people, scrollWidget); scrollLayout->addWidget(peopleEmoji); auto natureEmoji = - new EmojiCategory(tr("Animals & Nature"), emoji_provider_.nature, scrollWidget); + new Category(tr("Animals & Nature"), emoji_provider_.nature, scrollWidget); scrollLayout->addWidget(natureEmoji); - auto foodEmoji = new EmojiCategory(tr("Food & Drink"), emoji_provider_.food, scrollWidget); + auto foodEmoji = new Category(tr("Food & Drink"), emoji_provider_.food, scrollWidget); scrollLayout->addWidget(foodEmoji); - auto activityEmoji = - new EmojiCategory(tr("Activity"), emoji_provider_.activity, scrollWidget); + auto activityEmoji = new Category(tr("Activity"), emoji_provider_.activity, scrollWidget); scrollLayout->addWidget(activityEmoji); auto travelEmoji = - new EmojiCategory(tr("Travel & Places"), emoji_provider_.travel, scrollWidget); + new Category(tr("Travel & Places"), emoji_provider_.travel, scrollWidget); scrollLayout->addWidget(travelEmoji); - auto objectsEmoji = new EmojiCategory(tr("Objects"), emoji_provider_.objects, scrollWidget); + auto objectsEmoji = new Category(tr("Objects"), emoji_provider_.objects, scrollWidget); scrollLayout->addWidget(objectsEmoji); - auto symbolsEmoji = new EmojiCategory(tr("Symbols"), emoji_provider_.symbols, scrollWidget); + auto symbolsEmoji = new Category(tr("Symbols"), emoji_provider_.symbols, scrollWidget); scrollLayout->addWidget(symbolsEmoji); - auto flagsEmoji = new EmojiCategory(tr("Flags"), emoji_provider_.flags, scrollWidget); + auto flagsEmoji = new Category(tr("Flags"), emoji_provider_.flags, scrollWidget); scrollLayout->addWidget(flagsEmoji); contentLayout->addWidget(scrollArea_); contentLayout->addWidget(emojiCategories); - connect(peopleEmoji, &EmojiCategory::emojiSelected, this, &EmojiPanel::emojiSelected); + connect(peopleEmoji, &Category::emojiSelected, this, &Panel::emojiSelected); connect(peopleCategory, &QPushButton::clicked, [this, peopleEmoji]() { - this->showEmojiCategory(peopleEmoji); + this->showCategory(peopleEmoji); }); - connect(natureEmoji, &EmojiCategory::emojiSelected, this, &EmojiPanel::emojiSelected); + connect(natureEmoji, &Category::emojiSelected, this, &Panel::emojiSelected); connect(natureCategory_, &QPushButton::clicked, [this, natureEmoji]() { - this->showEmojiCategory(natureEmoji); + this->showCategory(natureEmoji); }); - connect(foodEmoji, &EmojiCategory::emojiSelected, this, &EmojiPanel::emojiSelected); + connect(foodEmoji, &Category::emojiSelected, this, &Panel::emojiSelected); connect(foodCategory_, &QPushButton::clicked, [this, foodEmoji]() { - this->showEmojiCategory(foodEmoji); + this->showCategory(foodEmoji); }); - connect(activityEmoji, &EmojiCategory::emojiSelected, this, &EmojiPanel::emojiSelected); + connect(activityEmoji, &Category::emojiSelected, this, &Panel::emojiSelected); connect(activityCategory, &QPushButton::clicked, [this, activityEmoji]() { - this->showEmojiCategory(activityEmoji); + this->showCategory(activityEmoji); }); - connect(travelEmoji, &EmojiCategory::emojiSelected, this, &EmojiPanel::emojiSelected); + connect(travelEmoji, &Category::emojiSelected, this, &Panel::emojiSelected); connect(travelCategory, &QPushButton::clicked, [this, travelEmoji]() { - this->showEmojiCategory(travelEmoji); + this->showCategory(travelEmoji); }); - connect(objectsEmoji, &EmojiCategory::emojiSelected, this, &EmojiPanel::emojiSelected); + connect(objectsEmoji, &Category::emojiSelected, this, &Panel::emojiSelected); connect(objectsCategory, &QPushButton::clicked, [this, objectsEmoji]() { - this->showEmojiCategory(objectsEmoji); + this->showCategory(objectsEmoji); }); - connect(symbolsEmoji, &EmojiCategory::emojiSelected, this, &EmojiPanel::emojiSelected); + connect(symbolsEmoji, &Category::emojiSelected, this, &Panel::emojiSelected); connect(symbolsCategory, &QPushButton::clicked, [this, symbolsEmoji]() { - this->showEmojiCategory(symbolsEmoji); + this->showCategory(symbolsEmoji); }); - connect(flagsEmoji, &EmojiCategory::emojiSelected, this, &EmojiPanel::emojiSelected); + connect(flagsEmoji, &Category::emojiSelected, this, &Panel::emojiSelected); connect(flagsCategory, &QPushButton::clicked, [this, flagsEmoji]() { - this->showEmojiCategory(flagsEmoji); + this->showCategory(flagsEmoji); }); } void -EmojiPanel::showEmojiCategory(const EmojiCategory *category) +Panel::showCategory(const Category *category) { auto posToGo = category->mapToParent(QPoint()).y(); auto current = scrollArea_->verticalScrollBar()->value(); @@ -217,13 +215,13 @@ EmojiPanel::showEmojiCategory(const EmojiCategory *category) } void -EmojiPanel::leaveEvent(QEvent *) +Panel::leaveEvent(QEvent *) { hide(); } void -EmojiPanel::paintEvent(QPaintEvent *event) +Panel::paintEvent(QPaintEvent *event) { Q_UNUSED(event); diff --git a/src/emoji/EmojiPickButton.cc b/src/emoji/PickButton.cc
index 44955a8c..ca3b3017 100644 --- a/src/emoji/EmojiPickButton.cc +++ b/src/emoji/PickButton.cc
@@ -15,23 +15,24 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "emoji/EmojiPickButton.h" -#include "emoji/EmojiPanel.h" +#include "emoji/PickButton.h" +#include "emoji/Panel.h" -EmojiPickButton::EmojiPickButton(QWidget *parent) +using namespace emoji; + +PickButton::PickButton(QWidget *parent) : FlatButton(parent) , panel_{nullptr} {} void -EmojiPickButton::enterEvent(QEvent *e) +PickButton::enterEvent(QEvent *e) { Q_UNUSED(e); if (panel_.isNull()) { - panel_ = QSharedPointer<EmojiPanel>(new EmojiPanel(this)); - connect( - panel_.data(), &EmojiPanel::emojiSelected, this, &EmojiPickButton::emojiSelected); + panel_ = QSharedPointer<Panel>(new Panel(this)); + connect(panel_.data(), &Panel::emojiSelected, this, &PickButton::emojiSelected); } QPoint pos(rect().x(), rect().y()); @@ -47,7 +48,7 @@ EmojiPickButton::enterEvent(QEvent *e) } void -EmojiPickButton::leaveEvent(QEvent *e) +PickButton::leaveEvent(QEvent *e) { Q_UNUSED(e); diff --git a/src/emoji/EmojiProvider.cc b/src/emoji/Provider.cc
index 838c0340..23f99c05 100644 --- a/src/emoji/EmojiProvider.cc +++ b/src/emoji/Provider.cc
@@ -17,9 +17,11 @@ #include <QByteArray> -#include "emoji/EmojiProvider.h" +#include "emoji/Provider.h" -const QList<Emoji> EmojiProvider::people = { +using namespace emoji; + +const QList<Emoji> Provider::people = { Emoji{QString::fromUtf8("\xf0\x9f\x98\x80"), ":grinning:"}, Emoji{QString::fromUtf8("\xf0\x9f\x98\x81"), ":grin:"}, Emoji{QString::fromUtf8("\xf0\x9f\x98\x82"), ":joy:"}, @@ -229,7 +231,7 @@ const QList<Emoji> EmojiProvider::people = { Emoji{QString::fromUtf8("\xf0\x9f\x92\xbc"), ":briefcase:"}, }; -const QList<Emoji> EmojiProvider::nature = { +const QList<Emoji> Provider::nature = { Emoji{QString::fromUtf8("\xf0\x9f\x99\x88"), ":see_no_evil:"}, Emoji{QString::fromUtf8("\xf0\x9f\x99\x89"), ":hear_no_evil:"}, Emoji{QString::fromUtf8("\xf0\x9f\x99\x8a"), ":speak_no_evil:"}, @@ -392,7 +394,7 @@ const QList<Emoji> EmojiProvider::nature = { Emoji{QString::fromUtf8("\xf0\x9f\x8e\x8d"), ":bamboo:"}, }; -const QList<Emoji> EmojiProvider::food = { +const QList<Emoji> Provider::food = { Emoji{QString::fromUtf8("\xf0\x9f\x8d\x87"), ":grapes:"}, Emoji{QString::fromUtf8("\xf0\x9f\x8d\x88"), ":melon:"}, Emoji{QString::fromUtf8("\xf0\x9f\x8d\x89"), ":watermelon:"}, @@ -480,7 +482,7 @@ const QList<Emoji> EmojiProvider::food = { Emoji{QString::fromUtf8("\xf0\x9f\xa5\x84"), ":spoon:"}, }; -const QList<Emoji> EmojiProvider::activity = { +const QList<Emoji> Provider::activity = { Emoji{QString::fromUtf8("\xf0\x9f\x91\xbe"), ":space_invader:"}, Emoji{QString::fromUtf8("\xf0\x9f\x95\xb4"), ":levitate:"}, Emoji{QString::fromUtf8("\xf0\x9f\xa4\xba"), ":fencer:"}, @@ -622,7 +624,7 @@ const QList<Emoji> EmojiProvider::activity = { Emoji{QString::fromUtf8("\xf0\x9f\x8f\xb9"), ":bow_and_arrow:"}, }; -const QList<Emoji> EmojiProvider::travel = { +const QList<Emoji> Provider::travel = { Emoji{QString::fromUtf8("\xf0\x9f\x8f\x8e"), ":race_car:"}, Emoji{QString::fromUtf8("\xf0\x9f\x8f\x8d"), ":motorcycle:"}, Emoji{QString::fromUtf8("\xf0\x9f\x97\xbe"), ":japan:"}, @@ -743,7 +745,7 @@ const QList<Emoji> EmojiProvider::travel = { Emoji{QString::fromUtf8("\xf0\x9f\x8f\x81"), ":checkered_flag:"}, }; -const QList<Emoji> EmojiProvider::objects = { +const QList<Emoji> Provider::objects = { Emoji{QString::fromUtf8("\xe2\x98\xa0"), ":skull_crossbones:"}, Emoji{QString::fromUtf8("\xf0\x9f\x92\x8c"), ":love_letter:"}, Emoji{QString::fromUtf8("\xf0\x9f\x92\xa3"), ":bomb:"}, @@ -926,7 +928,7 @@ const QList<Emoji> EmojiProvider::objects = { Emoji{QString::fromUtf8("\xf0\x9f\x8f\xb3\xf0\x9f\x8c\x88"), ":rainbow_flag:"}, }; -const QList<Emoji> EmojiProvider::symbols = { +const QList<Emoji> Provider::symbols = { Emoji{QString::fromUtf8("\xf0\x9f\x91\x81\xf0\x9f\x97\xa8"), ":eye_in_speech_bubble:"}, Emoji{QString::fromUtf8("\xf0\x9f\x92\x98"), ":cupid:"}, Emoji{QString::fromUtf8("\xe2\x9d\xa4"), ":heart:"}, @@ -1204,7 +1206,7 @@ const QList<Emoji> EmojiProvider::symbols = { Emoji{QString::fromUtf8("\xf0\x9f\x94\xb5"), ":blue_circle:"}, }; -const QList<Emoji> EmojiProvider::flags = { +const QList<Emoji> Provider::flags = { Emoji{QString::fromUtf8("\xf0\x9f\x87\xa6\xf0\x9f\x87\xa8"), ":flag_ac:"}, Emoji{QString::fromUtf8("\xf0\x9f\x87\xa6\xf0\x9f\x87\xa9"), ":flag_ad:"}, Emoji{QString::fromUtf8("\xf0\x9f\x87\xa6\xf0\x9f\x87\xaa"), ":flag_ae:"},