From 4fd8eccecec1dea7f7c7095d11e15fc0c2474b9f Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Tue, 24 Apr 2018 16:03:50 +0300 Subject: [PATCH] Adjust completion menu to fit its contents --- include/SuggestionsPopup.hpp | 3 +++ resources/styles/nheko-dark.qss | 4 ++++ resources/styles/nheko.qss | 4 ++++ resources/styles/system.qss | 4 ++++ src/SuggestionsPopup.cpp | 10 ++++++++++ 5 files changed, 25 insertions(+) diff --git a/include/SuggestionsPopup.hpp b/include/SuggestionsPopup.hpp index 64a86d7a..32964cb3 100644 --- a/include/SuggestionsPopup.hpp +++ b/include/SuggestionsPopup.hpp @@ -64,6 +64,9 @@ public slots: //! Set hovering to the item in the given layout position. void setHovering(int pos); +protected: + void paintEvent(QPaintEvent *event) override; + signals: void itemSelected(const QString &user); diff --git a/resources/styles/nheko-dark.qss b/resources/styles/nheko-dark.qss index 61643710..ff18b338 100644 --- a/resources/styles/nheko-dark.qss +++ b/resources/styles/nheko-dark.qss @@ -22,6 +22,10 @@ QuickSwitcher { background-color: #202228; } +SuggestionsPopup { + background-color: #202228; +} + PopupItem { background-color: #202228; qproperty-hoverColor: rgba(45, 49, 57, 120); diff --git a/resources/styles/nheko.qss b/resources/styles/nheko.qss index c7d57252..e0b3ad55 100644 --- a/resources/styles/nheko.qss +++ b/resources/styles/nheko.qss @@ -22,6 +22,10 @@ QuickSwitcher { background-color: white; } +SuggestionsPopup { + background-color: white; +} + PopupItem { background-color: white; qproperty-hoverColor: rgba(192, 193, 195, 120); diff --git a/resources/styles/system.qss b/resources/styles/system.qss index 5ebc4dd6..17302a1d 100644 --- a/resources/styles/system.qss +++ b/resources/styles/system.qss @@ -25,6 +25,10 @@ QuickSwitcher { background-color: palette(window); } +SuggestionsPopup { + background-color: palette(window); +} + PopupItem { background-color: palette(window); qproperty-hoverColor: rgba(192, 193, 195, 120); diff --git a/src/SuggestionsPopup.cpp b/src/SuggestionsPopup.cpp index e7011fcb..49495e71 100644 --- a/src/SuggestionsPopup.cpp +++ b/src/SuggestionsPopup.cpp @@ -106,6 +106,7 @@ SuggestionsPopup::addUsers(const QVector &users) } resetSelection(); + adjustSize(); resize(geometry().width(), 40 * users.size()); } @@ -171,3 +172,12 @@ SuggestionsPopup::selectHoveredSuggestion() resetSelection(); } + +void +SuggestionsPopup::paintEvent(QPaintEvent *) +{ + QStyleOption opt; + opt.init(this); + QPainter p(this); + style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); +}