Group emoji and dialogs with namespaces

This commit is contained in:
Konstantinos Sideris 2017-11-30 20:02:46 +02:00
parent 32c8340577
commit eae069ad93
31 changed files with 200 additions and 179 deletions

View file

@ -141,17 +141,17 @@ endif()
# #
set(SRC_FILES set(SRC_FILES
# Dialogs # Dialogs
src/dialogs/ImageOverlayDialog.cc src/dialogs/ImageOverlay.cc
src/dialogs/JoinRoomDialog.cc src/dialogs/JoinRoom.cc
src/dialogs/LeaveRoomDialog.cc src/dialogs/LeaveRoom.cc
src/dialogs/LogoutDialog.cc src/dialogs/Logout.cc
# Emoji # Emoji
src/emoji/EmojiCategory.cc src/emoji/Category.cc
src/emoji/EmojiItemDelegate.cc src/emoji/ItemDelegate.cc
src/emoji/EmojiPanel.cc src/emoji/Panel.cc
src/emoji/EmojiPickButton.cc src/emoji/PickButton.cc
src/emoji/EmojiProvider.cc src/emoji/Provider.cc
# Timeline # Timeline
src/timeline/TimelineViewManager.cc src/timeline/TimelineViewManager.cc
@ -245,17 +245,16 @@ include_directories(${LMDB_INCLUDE_DIR})
qt5_wrap_cpp(MOC_HEADERS qt5_wrap_cpp(MOC_HEADERS
# Dialogs # Dialogs
include/dialogs/ImageOverlayDialog.h include/dialogs/ImageOverlay.h
include/dialogs/JoinRoomDialog.h include/dialogs/JoinRoom.h
include/dialogs/LeaveRoomDialog.h include/dialogs/LeaveRoom.h
include/dialogs/LogoutDialog.h include/dialogs/Logout.h
# Emoji # Emoji
include/emoji/EmojiCategory.h include/emoji/Category.h
include/emoji/EmojiItemDelegate.h include/emoji/ItemDelegate.h
include/emoji/EmojiPanel.h include/emoji/Panel.h
include/emoji/EmojiPickButton.h include/emoji/PickButton.h
include/emoji/EmojiProvider.h
# Timeline # Timeline
include/timeline/TimelineItem.h include/timeline/TimelineItem.h

View file

@ -24,7 +24,8 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QWidget> #include <QWidget>
class JoinRoomDialog; #include "dialogs/LeaveRoom.h"
class LeaveRoomDialog; class LeaveRoomDialog;
class MatrixClient; class MatrixClient;
class OverlayModal; class OverlayModal;
@ -82,10 +83,9 @@ private:
QPushButton *joinRoomButton_; QPushButton *joinRoomButton_;
OverlayModal *joinRoomModal_; OverlayModal *joinRoomModal_;
JoinRoomDialog *joinRoomDialog_;
QSharedPointer<OverlayModal> leaveRoomModal_; QSharedPointer<OverlayModal> leaveRoomModal_;
QSharedPointer<LeaveRoomDialog> leaveRoomDialog_; QSharedPointer<dialogs::LeaveRoom> leaveRoomDialog_;
QMap<QString, QSharedPointer<RoomInfoListItem>> rooms_; QMap<QString, QSharedPointer<RoomInfoListItem>> rooms_;

View file

@ -28,7 +28,7 @@
#include "Image.h" #include "Image.h"
#include "LoadingIndicator.h" #include "LoadingIndicator.h"
#include "emoji/EmojiPickButton.h" #include "emoji/PickButton.h"
namespace msgs = matrix::events::messages; namespace msgs = matrix::events::messages;
@ -107,5 +107,5 @@ private:
FlatButton *sendFileBtn_; FlatButton *sendFileBtn_;
FlatButton *sendMessageBtn_; FlatButton *sendMessageBtn_;
EmojiPickButton *emojiBtn_; emoji::PickButton *emojiBtn_;
}; };

View file

@ -26,10 +26,11 @@
#include <QSharedPointer> #include <QSharedPointer>
#include <QVBoxLayout> #include <QVBoxLayout>
#include "dialogs/LeaveRoom.h"
class Avatar; class Avatar;
class FlatButton; class FlatButton;
class Label; class Label;
class LeaveRoomDialog;
class Menu; class Menu;
class OverlayModal; class OverlayModal;
class RoomSettings; class RoomSettings;
@ -79,7 +80,7 @@ private:
FlatButton *settingsBtn_; FlatButton *settingsBtn_;
QSharedPointer<OverlayModal> leaveRoomModal_; QSharedPointer<OverlayModal> leaveRoomModal_;
QSharedPointer<LeaveRoomDialog> leaveRoomDialog_; QSharedPointer<dialogs::LeaveRoom> leaveRoomDialog_;
Avatar *avatar_; Avatar *avatar_;

View file

@ -20,9 +20,10 @@
#include <QLabel> #include <QLabel>
#include <QLayout> #include <QLayout>
#include "dialogs/Logout.h"
class Avatar; class Avatar;
class FlatButton; class FlatButton;
class LogoutDialog;
class OverlayModal; class OverlayModal;
class UserInfoWidget : public QWidget class UserInfoWidget : public QWidget
@ -68,7 +69,7 @@ private:
QImage avatar_image_; QImage avatar_image_;
QSharedPointer<OverlayModal> logoutModal_; QSharedPointer<OverlayModal> logoutModal_;
QSharedPointer<LogoutDialog> logoutDialog_; QSharedPointer<dialogs::Logout> logoutDialog_;
int logoutButtonSize_; int logoutButtonSize_;
}; };

View file

@ -21,11 +21,13 @@
#include <QMouseEvent> #include <QMouseEvent>
#include <QPixmap> #include <QPixmap>
class ImageOverlayDialog : public QWidget namespace dialogs {
class ImageOverlay : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
ImageOverlayDialog(QPixmap image, QWidget *parent = nullptr); ImageOverlay(QPixmap image, QWidget *parent = nullptr);
protected: protected:
void mousePressEvent(QMouseEvent *event) override; void mousePressEvent(QMouseEvent *event) override;
@ -44,3 +46,4 @@ private:
QRect close_button_; QRect close_button_;
QRect screen_; QRect screen_;
}; };
} // dialogs

View file

@ -5,11 +5,13 @@
class FlatButton; class FlatButton;
class JoinRoomDialog : public QFrame namespace dialogs {
class JoinRoom : public QFrame
{ {
Q_OBJECT Q_OBJECT
public: public:
JoinRoomDialog(QWidget *parent = nullptr); JoinRoom(QWidget *parent = nullptr);
signals: signals:
void closing(bool isJoining, QString roomAlias); void closing(bool isJoining, QString roomAlias);
@ -20,3 +22,5 @@ private:
QLineEdit *roomAliasEdit_; QLineEdit *roomAliasEdit_;
}; };
} // dialogs

View file

@ -4,11 +4,13 @@
class FlatButton; class FlatButton;
class LeaveRoomDialog : public QFrame namespace dialogs {
class LeaveRoom : public QFrame
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit LeaveRoomDialog(QWidget *parent = nullptr); explicit LeaveRoom(QWidget *parent = nullptr);
protected: protected:
void paintEvent(QPaintEvent *event) override; void paintEvent(QPaintEvent *event) override;
@ -20,3 +22,4 @@ private:
FlatButton *confirmBtn_; FlatButton *confirmBtn_;
FlatButton *cancelBtn_; FlatButton *cancelBtn_;
}; };
} // dialogs

View file

@ -21,11 +21,13 @@
class FlatButton; class FlatButton;
class LogoutDialog : public QFrame namespace dialogs {
class Logout : public QFrame
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit LogoutDialog(QWidget *parent = nullptr); explicit Logout(QWidget *parent = nullptr);
protected: protected:
void paintEvent(QPaintEvent *event) override; void paintEvent(QPaintEvent *event) override;
@ -37,3 +39,4 @@ private:
FlatButton *confirmBtn_; FlatButton *confirmBtn_;
FlatButton *cancelBtn_; FlatButton *cancelBtn_;
}; };
} // dialogs

View file

@ -22,17 +22,17 @@
#include <QListView> #include <QListView>
#include <QStandardItemModel> #include <QStandardItemModel>
#include "EmojiItemDelegate.h" #include "ItemDelegate.h"
class EmojiProvider; namespace emoji {
class EmojiCategory : public QWidget class Category : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
EmojiCategory(QString category, QList<Emoji> emoji, QWidget *parent = nullptr); Category(QString category, QList<Emoji> emoji, QWidget *parent = nullptr);
~EmojiCategory(); ~Category();
signals: signals:
void emojiSelected(const QString &emoji); void emojiSelected(const QString &emoji);
@ -52,8 +52,9 @@ private:
QStandardItemModel *itemModel_; QStandardItemModel *itemModel_;
QListView *emojiListView_; QListView *emojiListView_;
Emoji *data_; emoji::Emoji *data_;
EmojiItemDelegate *delegate_; emoji::ItemDelegate *delegate_;
QLabel *category_; QLabel *category_;
}; };
} // namespace emoji

View file

@ -21,15 +21,17 @@
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QStyledItemDelegate> #include <QStyledItemDelegate>
#include "EmojiProvider.h" #include "Provider.h"
class EmojiItemDelegate : public QStyledItemDelegate namespace emoji {
class ItemDelegate : public QStyledItemDelegate
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit EmojiItemDelegate(QObject *parent = nullptr); explicit ItemDelegate(QObject *parent = nullptr);
~EmojiItemDelegate(); ~ItemDelegate();
void paint(QPainter *painter, void paint(QPainter *painter,
const QStyleOptionViewItem &option, const QStyleOptionViewItem &option,
@ -38,3 +40,4 @@ public:
private: private:
Emoji *data_; Emoji *data_;
}; };
} // namespace emoji

View file

@ -19,16 +19,18 @@
#include <QScrollArea> #include <QScrollArea>
#include "EmojiProvider.h" #include "Provider.h"
class EmojiCategory; namespace emoji {
class EmojiPanel : public QWidget class Category;
class Panel : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
EmojiPanel(QWidget *parent = nullptr); Panel(QWidget *parent = nullptr);
signals: signals:
void mouseLeft(); void mouseLeft();
@ -39,9 +41,9 @@ protected:
void paintEvent(QPaintEvent *event); void paintEvent(QPaintEvent *event);
private: private:
void showEmojiCategory(const EmojiCategory *category); void showCategory(const Category *category);
EmojiProvider emoji_provider_; Provider emoji_provider_;
QScrollArea *scrollArea_; QScrollArea *scrollArea_;
@ -53,3 +55,4 @@ private:
int categoryIconSize_; int categoryIconSize_;
}; };
} // namespace emoji

View file

@ -22,13 +22,15 @@
#include "FlatButton.h" #include "FlatButton.h"
class EmojiPanel; namespace emoji {
class EmojiPickButton : public FlatButton class Panel;
class PickButton : public FlatButton
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit EmojiPickButton(QWidget *parent = nullptr); explicit PickButton(QWidget *parent = nullptr);
signals: signals:
void emojiSelected(const QString &emoji); void emojiSelected(const QString &emoji);
@ -44,5 +46,6 @@ private:
// Horizontal distance from panel's bottom right corner. // Horizontal distance from panel's bottom right corner.
int horizontal_distance_ = 70; int horizontal_distance_ = 70;
QSharedPointer<EmojiPanel> panel_; QSharedPointer<Panel> panel_;
}; };
} // namespace emoji

View file

@ -19,6 +19,8 @@
#include <QList> #include <QList>
namespace emoji {
struct Emoji struct Emoji
{ {
// Unicode code. // Unicode code.
@ -27,7 +29,7 @@ struct Emoji
QString shortname; QString shortname;
}; };
class EmojiProvider class Provider
{ {
public: public:
static const QList<Emoji> people; static const QList<Emoji> people;
@ -39,3 +41,4 @@ public:
static const QList<Emoji> symbols; static const QList<Emoji> symbols;
static const QList<Emoji> flags; static const QList<Emoji> flags;
}; };
} // namespace emoji

View file

@ -71,8 +71,8 @@ Avatar {
color: #f2f2f2; color: #f2f2f2;
} }
LogoutDialog, dialogs--Logout,
LeaveRoomDialog { dialogs--LeaveRoom {
background-color: #383c4a; background-color: #383c4a;
color: #caccd1; color: #caccd1;
} }
@ -84,14 +84,14 @@ RegisterPage {
color: #caccd1; color: #caccd1;
} }
EmojiPanel, emoji--Panel,
EmojiPanel > * { emoji--Panel > * {
background-color: #383c4a; background-color: #313440;
color: #caccd1; color: #caccd1;
} }
EmojiCategory, emoji--Category,
EmojiCategory > * { emoji--Category > * {
background-color: #383c4a; background-color: #383c4a;
color: #caccd1; color: #caccd1;
} }

View file

@ -73,39 +73,27 @@ Avatar {
color: #555459; color: #555459;
} }
LogoutDialog { dialogs--Logout,
background-color: white; dialogs--LeaveRoom {
color: #333;
}
LeaveRoomDialog {
background-color: white;
color: #333;
}
WelcomePage {
background-color: white;
color: #333;
}
LoginPage {
background-color: white; background-color: white;
color: #333; color: #333;
} }
WelcomePage,
LoginPage,
RegisterPage { RegisterPage {
background-color: white; background-color: white;
color: #333; color: #333;
} }
EmojiPanel, emoji--Panel,
EmojiPanel > * { emoji--Panel > * {
background-color: white; background-color: #eee;
color: #333; color: #333;
} }
EmojiCategory, emoji--Category,
EmojiCategory > * { emoji--Category > * {
background-color: white; background-color: white;
color: #ccc; color: #ccc;
} }

View file

@ -64,13 +64,13 @@ UserInfoWidget > * {
background-color: palette(window); background-color: palette(window);
} }
EmojiCategory, emoji--Category,
EmojiCategory > * { emoji--Category > * {
background-color: palette(window); background-color: palette(window);
} }
EmojiPanel, emoji--Panel,
EmojiPanel > * { emoji--Panel > * {
background-color: palette(window); background-color: palette(window);
} }

View file

@ -18,9 +18,6 @@
#include <QDebug> #include <QDebug>
#include <QObject> #include <QObject>
#include "dialogs/JoinRoomDialog.h"
#include "dialogs/LeaveRoomDialog.h"
#include "MainWindow.h" #include "MainWindow.h"
#include "MatrixClient.h" #include "MatrixClient.h"
#include "OverlayModal.h" #include "OverlayModal.h"
@ -159,10 +156,10 @@ void
RoomList::openLeaveRoomDialog(const QString &room_id) RoomList::openLeaveRoomDialog(const QString &room_id)
{ {
if (leaveRoomDialog_.isNull()) { if (leaveRoomDialog_.isNull()) {
leaveRoomDialog_ = QSharedPointer<LeaveRoomDialog>(new LeaveRoomDialog(this)); leaveRoomDialog_ = QSharedPointer<dialogs::LeaveRoom>(new dialogs::LeaveRoom(this));
connect(leaveRoomDialog_.data(), connect(leaveRoomDialog_.data(),
&LeaveRoomDialog::closing, &dialogs::LeaveRoom::closing,
this, this,
[=](bool leaving) { closeLeaveRoomDialog(leaving, room_id); }); [=](bool leaving) { closeLeaveRoomDialog(leaving, room_id); });
} }

View file

@ -211,7 +211,7 @@ TextInputWidget::TextInputWidget(QWidget *parent)
sendMessageBtn_->setIcon(send_message_icon); sendMessageBtn_->setIcon(send_message_icon);
sendMessageBtn_->setIconSize(QSize(24, 24)); sendMessageBtn_->setIconSize(QSize(24, 24));
emojiBtn_ = new EmojiPickButton(this); emojiBtn_ = new emoji::PickButton(this);
QIcon emoji_icon; QIcon emoji_icon;
emoji_icon.addFile(":/icons/icons/ui/smile.png"); emoji_icon.addFile(":/icons/icons/ui/smile.png");

View file

@ -27,8 +27,6 @@
#include "RoomSettings.h" #include "RoomSettings.h"
#include "TopRoomBar.h" #include "TopRoomBar.h"
#include "dialogs/LeaveRoomDialog.h"
TopRoomBar::TopRoomBar(QWidget *parent) TopRoomBar::TopRoomBar(QWidget *parent)
: QWidget(parent) : QWidget(parent)
, buttonSize_{32} , buttonSize_{32}
@ -94,7 +92,7 @@ TopRoomBar::TopRoomBar(QWidget *parent)
connect(leaveRoom_, &QAction::triggered, this, [=]() { connect(leaveRoom_, &QAction::triggered, this, [=]() {
if (leaveRoomDialog_.isNull()) { if (leaveRoomDialog_.isNull()) {
leaveRoomDialog_ = leaveRoomDialog_ =
QSharedPointer<LeaveRoomDialog>(new LeaveRoomDialog(this)); QSharedPointer<dialogs::LeaveRoom>(new dialogs::LeaveRoom(this));
connect(leaveRoomDialog_.data(), connect(leaveRoomDialog_.data(),
SIGNAL(closing(bool)), SIGNAL(closing(bool)),

View file

@ -24,8 +24,6 @@
#include "OverlayModal.h" #include "OverlayModal.h"
#include "UserInfoWidget.h" #include "UserInfoWidget.h"
#include "dialogs/LogoutDialog.h"
UserInfoWidget::UserInfoWidget(QWidget *parent) UserInfoWidget::UserInfoWidget(QWidget *parent)
: QWidget(parent) : QWidget(parent)
, display_name_("User") , display_name_("User")
@ -94,7 +92,7 @@ UserInfoWidget::UserInfoWidget(QWidget *parent)
// Show the confirmation dialog. // Show the confirmation dialog.
connect(logoutButton_, &QPushButton::clicked, this, [=]() { connect(logoutButton_, &QPushButton::clicked, this, [=]() {
if (logoutDialog_.isNull()) { if (logoutDialog_.isNull()) {
logoutDialog_ = QSharedPointer<LogoutDialog>(new LogoutDialog(this)); logoutDialog_ = QSharedPointer<dialogs::Logout>(new dialogs::Logout(this));
connect(logoutDialog_.data(), connect(logoutDialog_.data(),
SIGNAL(closing(bool)), SIGNAL(closing(bool)),
this, this,

View file

@ -19,9 +19,11 @@
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QPainter> #include <QPainter>
#include "dialogs/ImageOverlayDialog.h" #include "dialogs/ImageOverlay.h"
ImageOverlayDialog::ImageOverlayDialog(QPixmap image, QWidget *parent) using namespace dialogs;
ImageOverlay::ImageOverlay(QPixmap image, QWidget *parent)
: QWidget{parent} : QWidget{parent}
, originalImage_{image} , originalImage_{image}
{ {
@ -47,7 +49,7 @@ ImageOverlayDialog::ImageOverlayDialog(QPixmap image, QWidget *parent)
// TODO: Move this into Utils // TODO: Move this into Utils
void void
ImageOverlayDialog::scaleImage(int max_width, int max_height) ImageOverlay::scaleImage(int max_width, int max_height)
{ {
if (originalImage_.isNull()) if (originalImage_.isNull())
return; return;
@ -73,7 +75,7 @@ ImageOverlayDialog::scaleImage(int max_width, int max_height)
} }
void void
ImageOverlayDialog::paintEvent(QPaintEvent *event) ImageOverlay::paintEvent(QPaintEvent *event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
@ -117,7 +119,7 @@ ImageOverlayDialog::paintEvent(QPaintEvent *event)
} }
void void
ImageOverlayDialog::mousePressEvent(QMouseEvent *event) ImageOverlay::mousePressEvent(QMouseEvent *event)
{ {
if (event->button() != Qt::LeftButton) if (event->button() != Qt::LeftButton)
return; return;

View file

@ -5,9 +5,11 @@
#include "FlatButton.h" #include "FlatButton.h"
#include "Theme.h" #include "Theme.h"
#include "dialogs/JoinRoomDialog.h" #include "dialogs/JoinRoom.h"
JoinRoomDialog::JoinRoomDialog(QWidget *parent) using namespace dialogs;
JoinRoom::JoinRoom(QWidget *parent)
: QFrame(parent) : QFrame(parent)
{ {
setMaximumSize(400, 400); setMaximumSize(400, 400);

View file

@ -6,9 +6,11 @@
#include "FlatButton.h" #include "FlatButton.h"
#include "Theme.h" #include "Theme.h"
#include "dialogs/LeaveRoomDialog.h" #include "dialogs/LeaveRoom.h"
LeaveRoomDialog::LeaveRoomDialog(QWidget *parent) using namespace dialogs;
LeaveRoom::LeaveRoom(QWidget *parent)
: QFrame(parent) : QFrame(parent)
{ {
setMaximumSize(400, 400); setMaximumSize(400, 400);
@ -45,7 +47,7 @@ LeaveRoomDialog::LeaveRoomDialog(QWidget *parent)
} }
void void
LeaveRoomDialog::paintEvent(QPaintEvent *) LeaveRoom::paintEvent(QPaintEvent *)
{ {
QStyleOption opt; QStyleOption opt;
opt.init(this); opt.init(this);

View file

@ -24,9 +24,11 @@
#include "FlatButton.h" #include "FlatButton.h"
#include "Theme.h" #include "Theme.h"
#include "dialogs/LogoutDialog.h" #include "dialogs/Logout.h"
LogoutDialog::LogoutDialog(QWidget *parent) using namespace dialogs;
Logout::Logout(QWidget *parent)
: QFrame(parent) : QFrame(parent)
{ {
setMaximumSize(400, 400); setMaximumSize(400, 400);
@ -63,7 +65,7 @@ LogoutDialog::LogoutDialog(QWidget *parent)
} }
void void
LogoutDialog::paintEvent(QPaintEvent *) Logout::paintEvent(QPaintEvent *)
{ {
QStyleOption opt; QStyleOption opt;
opt.init(this); opt.init(this);

View file

@ -21,9 +21,11 @@
#include "Config.h" #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) : QWidget(parent)
{ {
mainLayout_ = new QVBoxLayout(this); mainLayout_ = new QVBoxLayout(this);
@ -33,7 +35,7 @@ EmojiCategory::EmojiCategory(QString category, QList<Emoji> emoji, QWidget *pare
emojiListView_ = new QListView(); emojiListView_ = new QListView();
itemModel_ = new QStandardItemModel(this); itemModel_ = new QStandardItemModel(this);
delegate_ = new EmojiItemDelegate(this); delegate_ = new ItemDelegate(this);
data_ = new Emoji; data_ = new Emoji;
emojiListView_->setItemDelegate(delegate_); emojiListView_->setItemDelegate(delegate_);
@ -75,11 +77,11 @@ EmojiCategory::EmojiCategory(QString category, QList<Emoji> emoji, QWidget *pare
mainLayout_->addWidget(category_); mainLayout_->addWidget(category_);
mainLayout_->addWidget(emojiListView_); mainLayout_->addWidget(emojiListView_);
connect(emojiListView_, &QListView::clicked, this, &EmojiCategory::clickIndex); connect(emojiListView_, &QListView::clicked, this, &Category::clickIndex);
} }
void void
EmojiCategory::paintEvent(QPaintEvent *) Category::paintEvent(QPaintEvent *)
{ {
QStyleOption opt; QStyleOption opt;
opt.init(this); opt.init(this);
@ -87,4 +89,4 @@ EmojiCategory::paintEvent(QPaintEvent *)
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
} }
EmojiCategory::~EmojiCategory() {} Category::~Category() {}

View file

@ -18,20 +18,22 @@
#include <QDebug> #include <QDebug>
#include <QPainter> #include <QPainter>
#include "emoji/EmojiItemDelegate.h" #include "emoji/ItemDelegate.h"
EmojiItemDelegate::EmojiItemDelegate(QObject *parent) using namespace emoji;
ItemDelegate::ItemDelegate(QObject *parent)
: QStyledItemDelegate(parent) : QStyledItemDelegate(parent)
{ {
data_ = new Emoji; data_ = new Emoji;
} }
EmojiItemDelegate::~EmojiItemDelegate() { delete data_; } ItemDelegate::~ItemDelegate() { delete data_; }
void void
EmojiItemDelegate::paint(QPainter *painter, ItemDelegate::paint(QPainter *painter,
const QStyleOptionViewItem &option, const QStyleOptionViewItem &option,
const QModelIndex &index) const const QModelIndex &index) const
{ {
Q_UNUSED(index); Q_UNUSED(index);

View file

@ -22,10 +22,12 @@
#include "DropShadow.h" #include "DropShadow.h"
#include "FlatButton.h" #include "FlatButton.h"
#include "emoji/EmojiCategory.h" #include "emoji/Category.h"
#include "emoji/EmojiPanel.h" #include "emoji/Panel.h"
EmojiPanel::EmojiPanel(QWidget *parent) using namespace emoji;
Panel::Panel(QWidget *parent)
: QWidget(parent) : QWidget(parent)
, shadowMargin_{2} , shadowMargin_{2}
, width_{370} , width_{370}
@ -53,9 +55,6 @@ EmojiPanel::EmojiPanel(QWidget *parent)
contentLayout->setSpacing(0); contentLayout->setSpacing(0);
auto emojiCategories = new QFrame(mainWidget); auto emojiCategories = new QFrame(mainWidget);
emojiCategories->setStyleSheet(
QString("background-color: %1")
.arg(palette().color(QPalette::Window).darker(110).name()));
auto categoriesLayout = new QHBoxLayout(emojiCategories); auto categoriesLayout = new QHBoxLayout(emojiCategories);
categoriesLayout->setSpacing(0); categoriesLayout->setSpacing(0);
@ -124,79 +123,78 @@ EmojiPanel::EmojiPanel(QWidget *parent)
scrollArea_->setWidget(scrollWidget); scrollArea_->setWidget(scrollWidget);
auto peopleEmoji = auto peopleEmoji =
new EmojiCategory(tr("Smileys & People"), emoji_provider_.people, scrollWidget); new Category(tr("Smileys & People"), emoji_provider_.people, scrollWidget);
scrollLayout->addWidget(peopleEmoji); scrollLayout->addWidget(peopleEmoji);
auto natureEmoji = auto natureEmoji =
new EmojiCategory(tr("Animals & Nature"), emoji_provider_.nature, scrollWidget); new Category(tr("Animals & Nature"), emoji_provider_.nature, scrollWidget);
scrollLayout->addWidget(natureEmoji); 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); scrollLayout->addWidget(foodEmoji);
auto activityEmoji = auto activityEmoji = new Category(tr("Activity"), emoji_provider_.activity, scrollWidget);
new EmojiCategory(tr("Activity"), emoji_provider_.activity, scrollWidget);
scrollLayout->addWidget(activityEmoji); scrollLayout->addWidget(activityEmoji);
auto travelEmoji = auto travelEmoji =
new EmojiCategory(tr("Travel & Places"), emoji_provider_.travel, scrollWidget); new Category(tr("Travel & Places"), emoji_provider_.travel, scrollWidget);
scrollLayout->addWidget(travelEmoji); 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); 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); 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); scrollLayout->addWidget(flagsEmoji);
contentLayout->addWidget(scrollArea_); contentLayout->addWidget(scrollArea_);
contentLayout->addWidget(emojiCategories); contentLayout->addWidget(emojiCategories);
connect(peopleEmoji, &EmojiCategory::emojiSelected, this, &EmojiPanel::emojiSelected); connect(peopleEmoji, &Category::emojiSelected, this, &Panel::emojiSelected);
connect(peopleCategory, &QPushButton::clicked, [this, peopleEmoji]() { 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]() { 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]() { 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]() { 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]() { 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]() { 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]() { 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]() { connect(flagsCategory, &QPushButton::clicked, [this, flagsEmoji]() {
this->showEmojiCategory(flagsEmoji); this->showCategory(flagsEmoji);
}); });
} }
void void
EmojiPanel::showEmojiCategory(const EmojiCategory *category) Panel::showCategory(const Category *category)
{ {
auto posToGo = category->mapToParent(QPoint()).y(); auto posToGo = category->mapToParent(QPoint()).y();
auto current = scrollArea_->verticalScrollBar()->value(); auto current = scrollArea_->verticalScrollBar()->value();
@ -217,13 +215,13 @@ EmojiPanel::showEmojiCategory(const EmojiCategory *category)
} }
void void
EmojiPanel::leaveEvent(QEvent *) Panel::leaveEvent(QEvent *)
{ {
hide(); hide();
} }
void void
EmojiPanel::paintEvent(QPaintEvent *event) Panel::paintEvent(QPaintEvent *event)
{ {
Q_UNUSED(event); Q_UNUSED(event);

View file

@ -15,23 +15,24 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "emoji/EmojiPickButton.h" #include "emoji/PickButton.h"
#include "emoji/EmojiPanel.h" #include "emoji/Panel.h"
EmojiPickButton::EmojiPickButton(QWidget *parent) using namespace emoji;
PickButton::PickButton(QWidget *parent)
: FlatButton(parent) : FlatButton(parent)
, panel_{nullptr} , panel_{nullptr}
{} {}
void void
EmojiPickButton::enterEvent(QEvent *e) PickButton::enterEvent(QEvent *e)
{ {
Q_UNUSED(e); Q_UNUSED(e);
if (panel_.isNull()) { if (panel_.isNull()) {
panel_ = QSharedPointer<EmojiPanel>(new EmojiPanel(this)); panel_ = QSharedPointer<Panel>(new Panel(this));
connect( connect(panel_.data(), &Panel::emojiSelected, this, &PickButton::emojiSelected);
panel_.data(), &EmojiPanel::emojiSelected, this, &EmojiPickButton::emojiSelected);
} }
QPoint pos(rect().x(), rect().y()); QPoint pos(rect().x(), rect().y());
@ -47,7 +48,7 @@ EmojiPickButton::enterEvent(QEvent *e)
} }
void void
EmojiPickButton::leaveEvent(QEvent *e) PickButton::leaveEvent(QEvent *e)
{ {
Q_UNUSED(e); Q_UNUSED(e);

View file

@ -17,9 +17,11 @@
#include <QByteArray> #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\x80"), ":grinning:"},
Emoji{QString::fromUtf8("\xf0\x9f\x98\x81"), ":grin:"}, Emoji{QString::fromUtf8("\xf0\x9f\x98\x81"), ":grin:"},
Emoji{QString::fromUtf8("\xf0\x9f\x98\x82"), ":joy:"}, 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:"}, 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\x88"), ":see_no_evil:"},
Emoji{QString::fromUtf8("\xf0\x9f\x99\x89"), ":hear_no_evil:"}, Emoji{QString::fromUtf8("\xf0\x9f\x99\x89"), ":hear_no_evil:"},
Emoji{QString::fromUtf8("\xf0\x9f\x99\x8a"), ":speak_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:"}, 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\x87"), ":grapes:"},
Emoji{QString::fromUtf8("\xf0\x9f\x8d\x88"), ":melon:"}, Emoji{QString::fromUtf8("\xf0\x9f\x8d\x88"), ":melon:"},
Emoji{QString::fromUtf8("\xf0\x9f\x8d\x89"), ":watermelon:"}, 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:"}, 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\x91\xbe"), ":space_invader:"},
Emoji{QString::fromUtf8("\xf0\x9f\x95\xb4"), ":levitate:"}, Emoji{QString::fromUtf8("\xf0\x9f\x95\xb4"), ":levitate:"},
Emoji{QString::fromUtf8("\xf0\x9f\xa4\xba"), ":fencer:"}, 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:"}, 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\x8e"), ":race_car:"},
Emoji{QString::fromUtf8("\xf0\x9f\x8f\x8d"), ":motorcycle:"}, Emoji{QString::fromUtf8("\xf0\x9f\x8f\x8d"), ":motorcycle:"},
Emoji{QString::fromUtf8("\xf0\x9f\x97\xbe"), ":japan:"}, 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:"}, 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("\xe2\x98\xa0"), ":skull_crossbones:"},
Emoji{QString::fromUtf8("\xf0\x9f\x92\x8c"), ":love_letter:"}, Emoji{QString::fromUtf8("\xf0\x9f\x92\x8c"), ":love_letter:"},
Emoji{QString::fromUtf8("\xf0\x9f\x92\xa3"), ":bomb:"}, 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:"}, 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\x91\x81\xf0\x9f\x97\xa8"), ":eye_in_speech_bubble:"},
Emoji{QString::fromUtf8("\xf0\x9f\x92\x98"), ":cupid:"}, Emoji{QString::fromUtf8("\xf0\x9f\x92\x98"), ":cupid:"},
Emoji{QString::fromUtf8("\xe2\x9d\xa4"), ":heart:"}, 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:"}, 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\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\xa9"), ":flag_ad:"},
Emoji{QString::fromUtf8("\xf0\x9f\x87\xa6\xf0\x9f\x87\xaa"), ":flag_ae:"}, Emoji{QString::fromUtf8("\xf0\x9f\x87\xa6\xf0\x9f\x87\xaa"), ":flag_ae:"},

View file

@ -22,7 +22,7 @@
#include <QPainter> #include <QPainter>
#include <QPixmap> #include <QPixmap>
#include "dialogs/ImageOverlayDialog.h" #include "dialogs/ImageOverlay.h"
#include "timeline/widgets/ImageItem.h" #include "timeline/widgets/ImageItem.h"
namespace events = matrix::events; namespace events = matrix::events;
@ -165,7 +165,7 @@ ImageItem::mousePressEvent(QMouseEvent *event)
if (QRect(0, height_ - bottom_height_, width_, bottom_height_).contains(point)) { if (QRect(0, height_ - bottom_height_, width_, bottom_height_).contains(point)) {
openUrl(); openUrl();
} else { } else {
auto image_dialog = new ImageOverlayDialog(image_, this); auto image_dialog = new dialogs::ImageOverlay(image_, this);
image_dialog->show(); image_dialog->show();
} }
} }