summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/EmojiCategory.cc21
-rw-r--r--src/EmojiPanel.cc57
-rw-r--r--src/EmojiPickButton.cc3
3 files changed, 27 insertions, 54 deletions
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();
 }