From eae069ad93a6822e8cb96522708115793c01c5d7 Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Thu, 30 Nov 2017 20:02:46 +0200 Subject: [PATCH] Group emoji and dialogs with namespaces --- CMakeLists.txt | 35 +++++----- include/RoomList.h | 6 +- include/TextInputWidget.h | 4 +- include/TopRoomBar.h | 5 +- include/UserInfoWidget.h | 5 +- .../{ImageOverlayDialog.h => ImageOverlay.h} | 7 +- .../dialogs/{JoinRoomDialog.h => JoinRoom.h} | 8 ++- .../{LeaveRoomDialog.h => LeaveRoom.h} | 7 +- include/dialogs/{LogoutDialog.h => Logout.h} | 7 +- include/emoji/{EmojiCategory.h => Category.h} | 15 +++-- .../{EmojiItemDelegate.h => ItemDelegate.h} | 11 ++-- include/emoji/{EmojiPanel.h => Panel.h} | 15 +++-- .../emoji/{EmojiPickButton.h => PickButton.h} | 11 ++-- include/emoji/{EmojiProvider.h => Provider.h} | 5 +- resources/styles/nheko-dark.qss | 14 ++-- resources/styles/nheko.qss | 30 +++------ resources/styles/system.qss | 8 +-- src/RoomList.cc | 7 +- src/TextInputWidget.cc | 2 +- src/TopRoomBar.cc | 4 +- src/UserInfoWidget.cc | 4 +- ...{ImageOverlayDialog.cc => ImageOverlay.cc} | 12 ++-- .../{JoinRoomDialog.cc => JoinRoom.cc} | 6 +- .../{LeaveRoomDialog.cc => LeaveRoom.cc} | 8 ++- src/dialogs/{LogoutDialog.cc => Logout.cc} | 8 ++- src/emoji/{EmojiCategory.cc => Category.cc} | 14 ++-- .../{EmojiItemDelegate.cc => ItemDelegate.cc} | 14 ++-- src/emoji/{EmojiPanel.cc => Panel.cc} | 66 +++++++++---------- .../{EmojiPickButton.cc => PickButton.cc} | 17 ++--- src/emoji/{EmojiProvider.cc => Provider.cc} | 20 +++--- src/timeline/widgets/ImageItem.cc | 4 +- 31 files changed, 200 insertions(+), 179 deletions(-) rename include/dialogs/{ImageOverlayDialog.h => ImageOverlay.h} (89%) rename include/dialogs/{JoinRoomDialog.h => JoinRoom.h} (71%) rename include/dialogs/{LeaveRoomDialog.h => LeaveRoom.h} (69%) rename include/dialogs/{LogoutDialog.h => Logout.h} (89%) rename include/emoji/{EmojiCategory.h => Category.h} (82%) rename include/emoji/{EmojiItemDelegate.h => ItemDelegate.h} (84%) rename include/emoji/{EmojiPanel.h => Panel.h} (83%) rename include/emoji/{EmojiPickButton.h => PickButton.h} (86%) rename include/emoji/{EmojiProvider.h => Provider.h} (95%) rename src/dialogs/{ImageOverlayDialog.cc => ImageOverlay.cc} (93%) rename src/dialogs/{JoinRoomDialog.cc => JoinRoom.cc} (93%) rename src/dialogs/{LeaveRoomDialog.cc => LeaveRoom.cc} (91%) rename src/dialogs/{LogoutDialog.cc => Logout.cc} (94%) rename src/emoji/{EmojiCategory.cc => Category.cc} (89%) rename src/emoji/{EmojiItemDelegate.cc => ItemDelegate.cc} (78%) rename src/emoji/{EmojiPanel.cc => Panel.cc} (75%) rename src/emoji/{EmojiPickButton.cc => PickButton.cc} (79%) rename src/emoji/{EmojiProvider.cc => Provider.cc} (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b13def9..c2d9ff58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,17 +141,17 @@ endif() # set(SRC_FILES # Dialogs - src/dialogs/ImageOverlayDialog.cc - src/dialogs/JoinRoomDialog.cc - src/dialogs/LeaveRoomDialog.cc - src/dialogs/LogoutDialog.cc + src/dialogs/ImageOverlay.cc + src/dialogs/JoinRoom.cc + src/dialogs/LeaveRoom.cc + src/dialogs/Logout.cc # Emoji - src/emoji/EmojiCategory.cc - src/emoji/EmojiItemDelegate.cc - src/emoji/EmojiPanel.cc - src/emoji/EmojiPickButton.cc - src/emoji/EmojiProvider.cc + src/emoji/Category.cc + src/emoji/ItemDelegate.cc + src/emoji/Panel.cc + src/emoji/PickButton.cc + src/emoji/Provider.cc # Timeline src/timeline/TimelineViewManager.cc @@ -245,17 +245,16 @@ include_directories(${LMDB_INCLUDE_DIR}) qt5_wrap_cpp(MOC_HEADERS # Dialogs - include/dialogs/ImageOverlayDialog.h - include/dialogs/JoinRoomDialog.h - include/dialogs/LeaveRoomDialog.h - include/dialogs/LogoutDialog.h + include/dialogs/ImageOverlay.h + include/dialogs/JoinRoom.h + include/dialogs/LeaveRoom.h + include/dialogs/Logout.h # Emoji - include/emoji/EmojiCategory.h - include/emoji/EmojiItemDelegate.h - include/emoji/EmojiPanel.h - include/emoji/EmojiPickButton.h - include/emoji/EmojiProvider.h + include/emoji/Category.h + include/emoji/ItemDelegate.h + include/emoji/Panel.h + include/emoji/PickButton.h # Timeline include/timeline/TimelineItem.h diff --git a/include/RoomList.h b/include/RoomList.h index aa7c919c..f75f7ba4 100644 --- a/include/RoomList.h +++ b/include/RoomList.h @@ -24,7 +24,8 @@ #include #include -class JoinRoomDialog; +#include "dialogs/LeaveRoom.h" + class LeaveRoomDialog; class MatrixClient; class OverlayModal; @@ -82,10 +83,9 @@ private: QPushButton *joinRoomButton_; OverlayModal *joinRoomModal_; - JoinRoomDialog *joinRoomDialog_; QSharedPointer leaveRoomModal_; - QSharedPointer leaveRoomDialog_; + QSharedPointer leaveRoomDialog_; QMap> rooms_; diff --git a/include/TextInputWidget.h b/include/TextInputWidget.h index ede7b18a..3c338fe3 100644 --- a/include/TextInputWidget.h +++ b/include/TextInputWidget.h @@ -28,7 +28,7 @@ #include "Image.h" #include "LoadingIndicator.h" -#include "emoji/EmojiPickButton.h" +#include "emoji/PickButton.h" namespace msgs = matrix::events::messages; @@ -107,5 +107,5 @@ private: FlatButton *sendFileBtn_; FlatButton *sendMessageBtn_; - EmojiPickButton *emojiBtn_; + emoji::PickButton *emojiBtn_; }; diff --git a/include/TopRoomBar.h b/include/TopRoomBar.h index 2f65428d..7bd10356 100644 --- a/include/TopRoomBar.h +++ b/include/TopRoomBar.h @@ -26,10 +26,11 @@ #include #include +#include "dialogs/LeaveRoom.h" + class Avatar; class FlatButton; class Label; -class LeaveRoomDialog; class Menu; class OverlayModal; class RoomSettings; @@ -79,7 +80,7 @@ private: FlatButton *settingsBtn_; QSharedPointer leaveRoomModal_; - QSharedPointer leaveRoomDialog_; + QSharedPointer leaveRoomDialog_; Avatar *avatar_; diff --git a/include/UserInfoWidget.h b/include/UserInfoWidget.h index 2acfedb8..3c20380f 100644 --- a/include/UserInfoWidget.h +++ b/include/UserInfoWidget.h @@ -20,9 +20,10 @@ #include #include +#include "dialogs/Logout.h" + class Avatar; class FlatButton; -class LogoutDialog; class OverlayModal; class UserInfoWidget : public QWidget @@ -68,7 +69,7 @@ private: QImage avatar_image_; QSharedPointer logoutModal_; - QSharedPointer logoutDialog_; + QSharedPointer logoutDialog_; int logoutButtonSize_; }; diff --git a/include/dialogs/ImageOverlayDialog.h b/include/dialogs/ImageOverlay.h similarity index 89% rename from include/dialogs/ImageOverlayDialog.h rename to include/dialogs/ImageOverlay.h index 5159c665..682999ef 100644 --- a/include/dialogs/ImageOverlayDialog.h +++ b/include/dialogs/ImageOverlay.h @@ -21,11 +21,13 @@ #include #include -class ImageOverlayDialog : public QWidget +namespace dialogs { + +class ImageOverlay : public QWidget { Q_OBJECT public: - ImageOverlayDialog(QPixmap image, QWidget *parent = nullptr); + ImageOverlay(QPixmap image, QWidget *parent = nullptr); protected: void mousePressEvent(QMouseEvent *event) override; @@ -44,3 +46,4 @@ private: QRect close_button_; QRect screen_; }; +} // dialogs diff --git a/include/dialogs/JoinRoomDialog.h b/include/dialogs/JoinRoom.h similarity index 71% rename from include/dialogs/JoinRoomDialog.h rename to include/dialogs/JoinRoom.h index 84184733..dbc06bdf 100644 --- a/include/dialogs/JoinRoomDialog.h +++ b/include/dialogs/JoinRoom.h @@ -5,11 +5,13 @@ class FlatButton; -class JoinRoomDialog : public QFrame +namespace dialogs { + +class JoinRoom : public QFrame { Q_OBJECT public: - JoinRoomDialog(QWidget *parent = nullptr); + JoinRoom(QWidget *parent = nullptr); signals: void closing(bool isJoining, QString roomAlias); @@ -20,3 +22,5 @@ private: QLineEdit *roomAliasEdit_; }; + +} // dialogs diff --git a/include/dialogs/LeaveRoomDialog.h b/include/dialogs/LeaveRoom.h similarity index 69% rename from include/dialogs/LeaveRoomDialog.h rename to include/dialogs/LeaveRoom.h index eab022f7..98e4938d 100644 --- a/include/dialogs/LeaveRoomDialog.h +++ b/include/dialogs/LeaveRoom.h @@ -4,11 +4,13 @@ class FlatButton; -class LeaveRoomDialog : public QFrame +namespace dialogs { + +class LeaveRoom : public QFrame { Q_OBJECT public: - explicit LeaveRoomDialog(QWidget *parent = nullptr); + explicit LeaveRoom(QWidget *parent = nullptr); protected: void paintEvent(QPaintEvent *event) override; @@ -20,3 +22,4 @@ private: FlatButton *confirmBtn_; FlatButton *cancelBtn_; }; +} // dialogs diff --git a/include/dialogs/LogoutDialog.h b/include/dialogs/Logout.h similarity index 89% rename from include/dialogs/LogoutDialog.h rename to include/dialogs/Logout.h index a1a5ee4f..cfefb970 100644 --- a/include/dialogs/LogoutDialog.h +++ b/include/dialogs/Logout.h @@ -21,11 +21,13 @@ class FlatButton; -class LogoutDialog : public QFrame +namespace dialogs { + +class Logout : public QFrame { Q_OBJECT public: - explicit LogoutDialog(QWidget *parent = nullptr); + explicit Logout(QWidget *parent = nullptr); protected: void paintEvent(QPaintEvent *event) override; @@ -37,3 +39,4 @@ private: FlatButton *confirmBtn_; FlatButton *cancelBtn_; }; +} // dialogs diff --git a/include/emoji/EmojiCategory.h b/include/emoji/Category.h similarity index 82% rename from include/emoji/EmojiCategory.h rename to include/emoji/Category.h index be0110f2..0310a4f3 100644 --- a/include/emoji/EmojiCategory.h +++ b/include/emoji/Category.h @@ -22,17 +22,17 @@ #include #include -#include "EmojiItemDelegate.h" +#include "ItemDelegate.h" -class EmojiProvider; +namespace emoji { -class EmojiCategory : public QWidget +class Category : public QWidget { Q_OBJECT public: - EmojiCategory(QString category, QList emoji, QWidget *parent = nullptr); - ~EmojiCategory(); + Category(QString category, QList emoji, QWidget *parent = nullptr); + ~Category(); signals: void emojiSelected(const QString &emoji); @@ -52,8 +52,9 @@ private: QStandardItemModel *itemModel_; QListView *emojiListView_; - Emoji *data_; - EmojiItemDelegate *delegate_; + emoji::Emoji *data_; + emoji::ItemDelegate *delegate_; QLabel *category_; }; +} // namespace emoji diff --git a/include/emoji/EmojiItemDelegate.h b/include/emoji/ItemDelegate.h similarity index 84% rename from include/emoji/EmojiItemDelegate.h rename to include/emoji/ItemDelegate.h index 15d61f49..e0456308 100644 --- a/include/emoji/EmojiItemDelegate.h +++ b/include/emoji/ItemDelegate.h @@ -21,15 +21,17 @@ #include #include -#include "EmojiProvider.h" +#include "Provider.h" -class EmojiItemDelegate : public QStyledItemDelegate +namespace emoji { + +class ItemDelegate : public QStyledItemDelegate { Q_OBJECT public: - explicit EmojiItemDelegate(QObject *parent = nullptr); - ~EmojiItemDelegate(); + explicit ItemDelegate(QObject *parent = nullptr); + ~ItemDelegate(); void paint(QPainter *painter, const QStyleOptionViewItem &option, @@ -38,3 +40,4 @@ public: private: Emoji *data_; }; +} // namespace emoji diff --git a/include/emoji/EmojiPanel.h b/include/emoji/Panel.h similarity index 83% rename from include/emoji/EmojiPanel.h rename to include/emoji/Panel.h index 9eecc8e0..523a855e 100644 --- a/include/emoji/EmojiPanel.h +++ b/include/emoji/Panel.h @@ -19,16 +19,18 @@ #include -#include "EmojiProvider.h" +#include "Provider.h" -class EmojiCategory; +namespace emoji { -class EmojiPanel : public QWidget +class Category; + +class Panel : public QWidget { Q_OBJECT public: - EmojiPanel(QWidget *parent = nullptr); + Panel(QWidget *parent = nullptr); signals: void mouseLeft(); @@ -39,9 +41,9 @@ protected: void paintEvent(QPaintEvent *event); private: - void showEmojiCategory(const EmojiCategory *category); + void showCategory(const Category *category); - EmojiProvider emoji_provider_; + Provider emoji_provider_; QScrollArea *scrollArea_; @@ -53,3 +55,4 @@ private: int categoryIconSize_; }; +} // namespace emoji diff --git a/include/emoji/EmojiPickButton.h b/include/emoji/PickButton.h similarity index 86% rename from include/emoji/EmojiPickButton.h rename to include/emoji/PickButton.h index 8ef9be9e..d0026828 100644 --- a/include/emoji/EmojiPickButton.h +++ b/include/emoji/PickButton.h @@ -22,13 +22,15 @@ #include "FlatButton.h" -class EmojiPanel; +namespace emoji { -class EmojiPickButton : public FlatButton +class Panel; + +class PickButton : public FlatButton { Q_OBJECT public: - explicit EmojiPickButton(QWidget *parent = nullptr); + explicit PickButton(QWidget *parent = nullptr); signals: void emojiSelected(const QString &emoji); @@ -44,5 +46,6 @@ private: // Horizontal distance from panel's bottom right corner. int horizontal_distance_ = 70; - QSharedPointer panel_; + QSharedPointer panel_; }; +} // namespace emoji diff --git a/include/emoji/EmojiProvider.h b/include/emoji/Provider.h similarity index 95% rename from include/emoji/EmojiProvider.h rename to include/emoji/Provider.h index 847157fd..8754dabc 100644 --- a/include/emoji/EmojiProvider.h +++ b/include/emoji/Provider.h @@ -19,6 +19,8 @@ #include +namespace emoji { + struct Emoji { // Unicode code. @@ -27,7 +29,7 @@ struct Emoji QString shortname; }; -class EmojiProvider +class Provider { public: static const QList people; @@ -39,3 +41,4 @@ public: static const QList symbols; static const QList flags; }; +} // namespace emoji diff --git a/resources/styles/nheko-dark.qss b/resources/styles/nheko-dark.qss index 1a32ced3..0182d7a3 100644 --- a/resources/styles/nheko-dark.qss +++ b/resources/styles/nheko-dark.qss @@ -71,8 +71,8 @@ Avatar { color: #f2f2f2; } -LogoutDialog, -LeaveRoomDialog { +dialogs--Logout, +dialogs--LeaveRoom { background-color: #383c4a; color: #caccd1; } @@ -84,14 +84,14 @@ RegisterPage { color: #caccd1; } -EmojiPanel, -EmojiPanel > * { - background-color: #383c4a; +emoji--Panel, +emoji--Panel > * { + background-color: #313440; color: #caccd1; } -EmojiCategory, -EmojiCategory > * { +emoji--Category, +emoji--Category > * { background-color: #383c4a; color: #caccd1; } diff --git a/resources/styles/nheko.qss b/resources/styles/nheko.qss index 3e889530..4251b4a5 100644 --- a/resources/styles/nheko.qss +++ b/resources/styles/nheko.qss @@ -73,39 +73,27 @@ Avatar { color: #555459; } -LogoutDialog { - background-color: white; - color: #333; -} - -LeaveRoomDialog { - background-color: white; - color: #333; -} - -WelcomePage { - background-color: white; - color: #333; -} - -LoginPage { +dialogs--Logout, +dialogs--LeaveRoom { background-color: white; color: #333; } +WelcomePage, +LoginPage, RegisterPage { background-color: white; color: #333; } -EmojiPanel, -EmojiPanel > * { - background-color: white; +emoji--Panel, +emoji--Panel > * { + background-color: #eee; color: #333; } -EmojiCategory, -EmojiCategory > * { +emoji--Category, +emoji--Category > * { background-color: white; color: #ccc; } diff --git a/resources/styles/system.qss b/resources/styles/system.qss index bce0f059..4cd1bbfe 100644 --- a/resources/styles/system.qss +++ b/resources/styles/system.qss @@ -64,13 +64,13 @@ UserInfoWidget > * { background-color: palette(window); } -EmojiCategory, -EmojiCategory > * { +emoji--Category, +emoji--Category > * { background-color: palette(window); } -EmojiPanel, -EmojiPanel > * { +emoji--Panel, +emoji--Panel > * { background-color: palette(window); } diff --git a/src/RoomList.cc b/src/RoomList.cc index 6b8867f3..23c0c5a7 100644 --- a/src/RoomList.cc +++ b/src/RoomList.cc @@ -18,9 +18,6 @@ #include #include -#include "dialogs/JoinRoomDialog.h" -#include "dialogs/LeaveRoomDialog.h" - #include "MainWindow.h" #include "MatrixClient.h" #include "OverlayModal.h" @@ -159,10 +156,10 @@ void RoomList::openLeaveRoomDialog(const QString &room_id) { if (leaveRoomDialog_.isNull()) { - leaveRoomDialog_ = QSharedPointer(new LeaveRoomDialog(this)); + leaveRoomDialog_ = QSharedPointer(new dialogs::LeaveRoom(this)); connect(leaveRoomDialog_.data(), - &LeaveRoomDialog::closing, + &dialogs::LeaveRoom::closing, this, [=](bool leaving) { closeLeaveRoomDialog(leaving, room_id); }); } diff --git a/src/TextInputWidget.cc b/src/TextInputWidget.cc index c4d01357..2f6c435a 100644 --- a/src/TextInputWidget.cc +++ b/src/TextInputWidget.cc @@ -211,7 +211,7 @@ TextInputWidget::TextInputWidget(QWidget *parent) sendMessageBtn_->setIcon(send_message_icon); sendMessageBtn_->setIconSize(QSize(24, 24)); - emojiBtn_ = new EmojiPickButton(this); + emojiBtn_ = new emoji::PickButton(this); QIcon emoji_icon; emoji_icon.addFile(":/icons/icons/ui/smile.png"); diff --git a/src/TopRoomBar.cc b/src/TopRoomBar.cc index 3418e6f1..51a3af68 100644 --- a/src/TopRoomBar.cc +++ b/src/TopRoomBar.cc @@ -27,8 +27,6 @@ #include "RoomSettings.h" #include "TopRoomBar.h" -#include "dialogs/LeaveRoomDialog.h" - TopRoomBar::TopRoomBar(QWidget *parent) : QWidget(parent) , buttonSize_{32} @@ -94,7 +92,7 @@ TopRoomBar::TopRoomBar(QWidget *parent) connect(leaveRoom_, &QAction::triggered, this, [=]() { if (leaveRoomDialog_.isNull()) { leaveRoomDialog_ = - QSharedPointer(new LeaveRoomDialog(this)); + QSharedPointer(new dialogs::LeaveRoom(this)); connect(leaveRoomDialog_.data(), SIGNAL(closing(bool)), diff --git a/src/UserInfoWidget.cc b/src/UserInfoWidget.cc index 98977bb3..fe0c2b56 100644 --- a/src/UserInfoWidget.cc +++ b/src/UserInfoWidget.cc @@ -24,8 +24,6 @@ #include "OverlayModal.h" #include "UserInfoWidget.h" -#include "dialogs/LogoutDialog.h" - UserInfoWidget::UserInfoWidget(QWidget *parent) : QWidget(parent) , display_name_("User") @@ -94,7 +92,7 @@ UserInfoWidget::UserInfoWidget(QWidget *parent) // Show the confirmation dialog. connect(logoutButton_, &QPushButton::clicked, this, [=]() { if (logoutDialog_.isNull()) { - logoutDialog_ = QSharedPointer(new LogoutDialog(this)); + logoutDialog_ = QSharedPointer(new dialogs::Logout(this)); connect(logoutDialog_.data(), SIGNAL(closing(bool)), this, diff --git a/src/dialogs/ImageOverlayDialog.cc b/src/dialogs/ImageOverlay.cc similarity index 93% rename from src/dialogs/ImageOverlayDialog.cc rename to src/dialogs/ImageOverlay.cc index ad87d144..1e30b3ff 100644 --- a/src/dialogs/ImageOverlayDialog.cc +++ b/src/dialogs/ImageOverlay.cc @@ -19,9 +19,11 @@ #include #include -#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} , originalImage_{image} { @@ -47,7 +49,7 @@ ImageOverlayDialog::ImageOverlayDialog(QPixmap image, QWidget *parent) // TODO: Move this into Utils void -ImageOverlayDialog::scaleImage(int max_width, int max_height) +ImageOverlay::scaleImage(int max_width, int max_height) { if (originalImage_.isNull()) return; @@ -73,7 +75,7 @@ ImageOverlayDialog::scaleImage(int max_width, int max_height) } void -ImageOverlayDialog::paintEvent(QPaintEvent *event) +ImageOverlay::paintEvent(QPaintEvent *event) { Q_UNUSED(event); @@ -117,7 +119,7 @@ ImageOverlayDialog::paintEvent(QPaintEvent *event) } void -ImageOverlayDialog::mousePressEvent(QMouseEvent *event) +ImageOverlay::mousePressEvent(QMouseEvent *event) { if (event->button() != Qt::LeftButton) return; diff --git a/src/dialogs/JoinRoomDialog.cc b/src/dialogs/JoinRoom.cc similarity index 93% rename from src/dialogs/JoinRoomDialog.cc rename to src/dialogs/JoinRoom.cc index 2cee7ef6..5b874011 100644 --- a/src/dialogs/JoinRoomDialog.cc +++ b/src/dialogs/JoinRoom.cc @@ -5,9 +5,11 @@ #include "FlatButton.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) { setMaximumSize(400, 400); diff --git a/src/dialogs/LeaveRoomDialog.cc b/src/dialogs/LeaveRoom.cc similarity index 91% rename from src/dialogs/LeaveRoomDialog.cc rename to src/dialogs/LeaveRoom.cc index b0d1679f..6a8447d4 100644 --- a/src/dialogs/LeaveRoomDialog.cc +++ b/src/dialogs/LeaveRoom.cc @@ -6,9 +6,11 @@ #include "FlatButton.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) { setMaximumSize(400, 400); @@ -45,7 +47,7 @@ LeaveRoomDialog::LeaveRoomDialog(QWidget *parent) } void -LeaveRoomDialog::paintEvent(QPaintEvent *) +LeaveRoom::paintEvent(QPaintEvent *) { QStyleOption opt; opt.init(this); diff --git a/src/dialogs/LogoutDialog.cc b/src/dialogs/Logout.cc similarity index 94% rename from src/dialogs/LogoutDialog.cc rename to src/dialogs/Logout.cc index 73e09745..f4752b0a 100644 --- a/src/dialogs/LogoutDialog.cc +++ b/src/dialogs/Logout.cc @@ -24,9 +24,11 @@ #include "FlatButton.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) { setMaximumSize(400, 400); @@ -63,7 +65,7 @@ LogoutDialog::LogoutDialog(QWidget *parent) } void -LogoutDialog::paintEvent(QPaintEvent *) +Logout::paintEvent(QPaintEvent *) { QStyleOption opt; opt.init(this); diff --git a/src/emoji/EmojiCategory.cc b/src/emoji/Category.cc similarity index 89% rename from src/emoji/EmojiCategory.cc rename to 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, QWidget *parent) +using namespace emoji; + +Category::Category(QString category, QList emoji, QWidget *parent) : QWidget(parent) { mainLayout_ = new QVBoxLayout(this); @@ -33,7 +35,7 @@ EmojiCategory::EmojiCategory(QString category, QList 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, 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 similarity index 78% rename from src/emoji/EmojiItemDelegate.cc rename to src/emoji/ItemDelegate.cc index 547d3b4c..2cc838e3 100644 --- a/src/emoji/EmojiItemDelegate.cc +++ b/src/emoji/ItemDelegate.cc @@ -18,20 +18,22 @@ #include #include -#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 similarity index 75% rename from src/emoji/EmojiPanel.cc rename to 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 similarity index 79% rename from src/emoji/EmojiPickButton.cc rename to 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 . */ -#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(new EmojiPanel(this)); - connect( - panel_.data(), &EmojiPanel::emojiSelected, this, &EmojiPickButton::emojiSelected); + panel_ = QSharedPointer(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 similarity index 99% rename from src/emoji/EmojiProvider.cc rename to src/emoji/Provider.cc index 838c0340..23f99c05 100644 --- a/src/emoji/EmojiProvider.cc +++ b/src/emoji/Provider.cc @@ -17,9 +17,11 @@ #include -#include "emoji/EmojiProvider.h" +#include "emoji/Provider.h" -const QList EmojiProvider::people = { +using namespace emoji; + +const QList 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 EmojiProvider::people = { Emoji{QString::fromUtf8("\xf0\x9f\x92\xbc"), ":briefcase:"}, }; -const QList EmojiProvider::nature = { +const QList 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 EmojiProvider::nature = { Emoji{QString::fromUtf8("\xf0\x9f\x8e\x8d"), ":bamboo:"}, }; -const QList EmojiProvider::food = { +const QList 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 EmojiProvider::food = { Emoji{QString::fromUtf8("\xf0\x9f\xa5\x84"), ":spoon:"}, }; -const QList EmojiProvider::activity = { +const QList 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 EmojiProvider::activity = { Emoji{QString::fromUtf8("\xf0\x9f\x8f\xb9"), ":bow_and_arrow:"}, }; -const QList EmojiProvider::travel = { +const QList 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 EmojiProvider::travel = { Emoji{QString::fromUtf8("\xf0\x9f\x8f\x81"), ":checkered_flag:"}, }; -const QList EmojiProvider::objects = { +const QList 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 EmojiProvider::objects = { Emoji{QString::fromUtf8("\xf0\x9f\x8f\xb3\xf0\x9f\x8c\x88"), ":rainbow_flag:"}, }; -const QList EmojiProvider::symbols = { +const QList 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 EmojiProvider::symbols = { Emoji{QString::fromUtf8("\xf0\x9f\x94\xb5"), ":blue_circle:"}, }; -const QList EmojiProvider::flags = { +const QList 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:"}, diff --git a/src/timeline/widgets/ImageItem.cc b/src/timeline/widgets/ImageItem.cc index 106fc79b..c8cf8e23 100644 --- a/src/timeline/widgets/ImageItem.cc +++ b/src/timeline/widgets/ImageItem.cc @@ -22,7 +22,7 @@ #include #include -#include "dialogs/ImageOverlayDialog.h" +#include "dialogs/ImageOverlay.h" #include "timeline/widgets/ImageItem.h" namespace events = matrix::events; @@ -165,7 +165,7 @@ ImageItem::mousePressEvent(QMouseEvent *event) if (QRect(0, height_ - bottom_height_, width_, bottom_height_).contains(point)) { openUrl(); } else { - auto image_dialog = new ImageOverlayDialog(image_, this); + auto image_dialog = new dialogs::ImageOverlay(image_, this); image_dialog->show(); } }