summary refs log tree commit diff
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2017-11-22 21:03:53 +0200
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2017-11-22 21:03:53 +0200
commit56d8be5a27f12a575c7e28ad3aaa263eb3c507b5 (patch)
tree28a09fae02a9b6c2b240e56f25fff88c44036c72
parentFix minor stylistic issues on the nheko theme (diff)
downloadnheko-56d8be5a27f12a575c7e28ad3aaa263eb3c507b5.tar.xz
Fix emoji picker's theme
-rw-r--r--include/EmojiCategory.h3
-rw-r--r--include/EmojiPanel.h9
-rw-r--r--resources/styles/nheko.qss12
-rw-r--r--src/EmojiCategory.cc21
-rw-r--r--src/EmojiPanel.cc57
-rw-r--r--src/EmojiPickButton.cc3
6 files changed, 42 insertions, 63 deletions
diff --git a/include/EmojiCategory.h b/include/EmojiCategory.h
index 06099f3d..0eb4aeb1 100644
--- a/include/EmojiCategory.h
+++ b/include/EmojiCategory.h
@@ -37,6 +37,9 @@ public:
 signals:
         void emojiSelected(const QString &emoji);
 
+protected:
+	void paintEvent(QPaintEvent *event) override;
+
 private slots:
         void clickIndex(const QModelIndex &index)
         {
diff --git a/include/EmojiPanel.h b/include/EmojiPanel.h
index 211d916b..9eecc8e0 100644
--- a/include/EmojiPanel.h
+++ b/include/EmojiPanel.h
@@ -17,8 +17,6 @@
 
 #pragma once
 
-#include <QGraphicsOpacityEffect>
-#include <QPropertyAnimation>
 #include <QScrollArea>
 
 #include "EmojiProvider.h"
@@ -32,9 +30,6 @@ class EmojiPanel : public QWidget
 public:
         EmojiPanel(QWidget *parent = nullptr);
 
-        void fadeOut();
-        void fadeIn();
-
 signals:
         void mouseLeft();
         void emojiSelected(const QString &emoji);
@@ -46,9 +41,6 @@ protected:
 private:
         void showEmojiCategory(const EmojiCategory *category);
 
-        QPropertyAnimation *animation_;
-        QGraphicsOpacityEffect *opacity_;
-
         EmojiProvider emoji_provider_;
 
         QScrollArea *scrollArea_;
@@ -59,6 +51,5 @@ private:
         int width_;
         int height_;
 
-        int animationDuration_;
         int categoryIconSize_;
 };
diff --git a/resources/styles/nheko.qss b/resources/styles/nheko.qss
index 76ff7b5e..a84d247f 100644
--- a/resources/styles/nheko.qss
+++ b/resources/styles/nheko.qss
@@ -77,3 +77,15 @@ RegisterPage {
     background-color: white;
     color: #333;
 }
+
+EmojiPanel,
+EmojiPanel > * {
+    background-color: white;
+    color: #333;
+}
+
+EmojiCategory,
+EmojiCategory > * {
+    background-color: white;
+    color: #ccc;
+}
diff --git a/src/EmojiCategory.cc b/src/EmojiCategory.cc
index 8546b807..a8851a89 100644
--- a/src/EmojiCategory.cc
+++ b/src/EmojiCategory.cc
@@ -16,6 +16,8 @@
  */
 
 #include <QScrollBar>
+#include <QStyleOption>
+#include <QPainter>
 
 #include "Config.h"
 #include "EmojiCategory.h"
@@ -25,6 +27,7 @@ EmojiCategory::EmojiCategory(QString category, QList<Emoji> emoji, QWidget *pare
 {
         mainLayout_ = new QVBoxLayout(this);
         mainLayout_->setMargin(0);
+        mainLayout_->setSpacing(0);
 
         emojiListView_ = new QListView();
         itemModel_     = new QStandardItemModel(this);
@@ -33,7 +36,6 @@ EmojiCategory::EmojiCategory(QString category, QList<Emoji> emoji, QWidget *pare
         data_     = new Emoji;
 
         emojiListView_->setItemDelegate(delegate_);
-        emojiListView_->setSpacing(5);
         emojiListView_->setModel(itemModel_);
         emojiListView_->setViewMode(QListView::IconMode);
         emojiListView_->setFlow(QListView::LeftToRight);
@@ -67,16 +69,21 @@ EmojiCategory::EmojiCategory(QString category, QList<Emoji> emoji, QWidget *pare
 
         category_ = new QLabel(category, this);
         category_->setFont(font);
-        category_->setStyleSheet("color: #ccc; margin: 20px 0px 15px 8px;");
+	category_->setStyleSheet("margin: 20px 0 20px 8px;");
 
-        auto labelLayout_ = new QHBoxLayout();
-        labelLayout_->addWidget(category_);
-        labelLayout_->addStretch(1);
-
-        mainLayout_->addLayout(labelLayout_);
+        mainLayout_->addWidget(category_);
         mainLayout_->addWidget(emojiListView_);
 
         connect(emojiListView_, &QListView::clicked, this, &EmojiCategory::clickIndex);
 }
 
+void
+EmojiCategory::paintEvent(QPaintEvent *)
+{
+        QStyleOption opt;
+        opt.init(this);
+        QPainter p(this);
+        style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
+}
+
 EmojiCategory::~EmojiCategory() {}
diff --git a/src/EmojiPanel.cc b/src/EmojiPanel.cc
index 82eb8afc..ce342007 100644
--- a/src/EmojiPanel.cc
+++ b/src/EmojiPanel.cc
@@ -29,14 +29,11 @@ EmojiPanel::EmojiPanel(QWidget *parent)
   , shadowMargin_{2}
   , width_{370}
   , height_{350}
-  , animationDuration_{100}
   , categoryIconSize_{20}
 {
         setStyleSheet("QWidget {border: none;}"
-                      "QScrollBar:vertical { width: 8px; margin: 0px 2px 0 2px; }"
-                      "QScrollBar::handle:vertical { min-height: 20px; }"
-                      "QScrollBar::add-line:vertical { border: none; background: none; }"
-                      "QScrollBar::sub-line:vertical { border: none; background: none; }");
+                      "QScrollBar:vertical { width: 0px; margin: 0px; }"
+                      "QScrollBar::handle:vertical { min-height: 30px; }");
 
         setAttribute(Qt::WA_TranslucentBackground, true);
         setAttribute(Qt::WA_ShowWithoutActivating, true);
@@ -48,16 +45,18 @@ EmojiPanel::EmojiPanel(QWidget *parent)
         auto topLayout = new QVBoxLayout(this);
         topLayout->addWidget(mainWidget);
         topLayout->setMargin(shadowMargin_);
+        topLayout->setSpacing(0);
 
         auto contentLayout = new QVBoxLayout(mainWidget);
         contentLayout->setMargin(0);
+        contentLayout->setSpacing(0);
 
         auto emojiCategories = new QFrame(mainWidget);
-        // emojiCategories->setStyleSheet("background-color: #f2f2f2");
+        emojiCategories->setStyleSheet("background-color: #f2f2f2");
 
         auto categoriesLayout = new QHBoxLayout(emojiCategories);
-        categoriesLayout->setSpacing(6);
-        categoriesLayout->setMargin(5);
+        categoriesLayout->setSpacing(0);
+        categoriesLayout->setMargin(0);
 
         QIcon icon;
 
@@ -126,6 +125,7 @@ EmojiPanel::EmojiPanel(QWidget *parent)
         auto scrollLayout = new QVBoxLayout(scrollWidget);
 
         scrollLayout->setMargin(0);
+        scrollLayout->setSpacing(0);
         scrollArea_->setWidget(scrollWidget);
 
         auto peopleEmoji =
@@ -156,20 +156,9 @@ EmojiPanel::EmojiPanel(QWidget *parent)
         auto flagsEmoji = new EmojiCategory(tr("Flags"), emoji_provider_.flags, scrollWidget);
         scrollLayout->addWidget(flagsEmoji);
 
-        contentLayout->addStretch(1);
         contentLayout->addWidget(scrollArea_);
         contentLayout->addWidget(emojiCategories);
 
-        opacity_ = new QGraphicsOpacityEffect(this);
-        opacity_->setOpacity(1.0);
-
-        setGraphicsEffect(opacity_);
-
-        animation_ = new QPropertyAnimation(opacity_, "opacity", this);
-        animation_->setDuration(animationDuration_);
-        animation_->setStartValue(1);
-        animation_->setEndValue(0);
-
         connect(peopleEmoji, &EmojiCategory::emojiSelected, this, &EmojiPanel::emojiSelected);
         connect(peopleCategory, &QPushButton::clicked, [this, peopleEmoji]() {
                 this->showEmojiCategory(peopleEmoji);
@@ -209,11 +198,6 @@ EmojiPanel::EmojiPanel(QWidget *parent)
         connect(flagsCategory, &QPushButton::clicked, [this, flagsEmoji]() {
                 this->showEmojiCategory(flagsEmoji);
         });
-
-        connect(animation_, &QAbstractAnimation::finished, [this]() {
-                if (animation_->direction() == QAbstractAnimation::Forward)
-                        this->hide();
-        });
 }
 
 void
@@ -238,11 +222,9 @@ EmojiPanel::showEmojiCategory(const EmojiCategory *category)
 }
 
 void
-EmojiPanel::leaveEvent(QEvent *event)
+EmojiPanel::leaveEvent(QEvent *)
 {
-        Q_UNUSED(event);
-
-        fadeOut();
+        hide();
 }
 
 void
@@ -253,6 +235,8 @@ EmojiPanel::paintEvent(QPaintEvent *event)
         QStyleOption opt;
         opt.init(this);
         QPainter p(this);
+        style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
+
         DropShadow::draw(p,
                          shadowMargin_,
                          4.0,
@@ -263,21 +247,4 @@ EmojiPanel::paintEvent(QPaintEvent *event)
                          0.6,
                          width(),
                          height());
-
-        style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
-        // QWidget::paintEvent(event);
-}
-
-void
-EmojiPanel::fadeOut()
-{
-        animation_->setDirection(QAbstractAnimation::Forward);
-        animation_->start();
-}
-
-void
-EmojiPanel::fadeIn()
-{
-        animation_->setDirection(QAbstractAnimation::Backward);
-        animation_->start();
 }
diff --git a/src/EmojiPickButton.cc b/src/EmojiPickButton.cc
index 06aa3db9..a4f83c46 100644
--- a/src/EmojiPickButton.cc
+++ b/src/EmojiPickButton.cc
@@ -43,7 +43,6 @@ EmojiPickButton::enterEvent(QEvent *e)
         auto y = pos.y() - panel_size.height() - vertical_distance_;
 
         panel_->move(x, y);
-        panel_->fadeIn();
         panel_->show();
 }
 
@@ -62,5 +61,5 @@ EmojiPickButton::leaveEvent(QEvent *e)
         if (panel_geometry.contains(pos))
                 return;
 
-        panel_->fadeOut();
+        panel_->hide();
 }