From 41aac1448adbe608b90ef3b9d2d8692bd1cf3454 Mon Sep 17 00:00:00 2001 From: pajlada Date: Sun, 3 Aug 2025 14:25:35 +0200 Subject: [PATCH] chore: make split header menu button drawn (#6372) --- CHANGELOG.md | 2 +- resources/buttons/menuDark.png | Bin 90 -> 0 bytes resources/buttons/menuLight.png | Bin 328 -> 0 bytes src/widgets/buttons/DrawnButton.cpp | 40 ++++++++++++++++++++++++++++ src/widgets/buttons/DrawnButton.hpp | 3 +++ src/widgets/splits/SplitHeader.cpp | 18 +++++++------ src/widgets/splits/SplitHeader.hpp | 2 +- 7 files changed, 55 insertions(+), 10 deletions(-) delete mode 100644 resources/buttons/menuDark.png delete mode 100644 resources/buttons/menuLight.png diff --git a/CHANGELOG.md b/CHANGELOG.md index 67602d9a..6973322d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -81,7 +81,7 @@ - Dev: Simplified string literals to be a re-export of Qt functions. (#6175) - Dev: Fixed incorrect lua generation of static methods for typescript plugins. (#6190, #6223) - Dev: Merged top/bottom and left/right notebook layouts. (#6215) -- Dev: Refactored `Button` and friends. (#6102, #6255, #6266, #6302, #6268, #6334, #6371) +- Dev: Refactored `Button` and friends. (#6102, #6255, #6266, #6302, #6268, #6334, #6371, #6372) - Dev: Made "add split" button (part of the split header) a natively rendered button. (#6349) - Dev: Made Settings & Account button on Linux/macOS SVGs. (#6267) - Dev: Some more setting widget refactors. (#6317) diff --git a/resources/buttons/menuDark.png b/resources/buttons/menuDark.png deleted file mode 100644 index bca55f26249f09914c0c913f1199d031a1588d9a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 90 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE0wix1Z>k4Uik>cxAr-fhC0Lu~{^>bP0l+XkKtF{NS%G}c0*}aI z1_s$C5N2EyKV>pdP_o1|q9iy!t)x7$D3zfgF*C13FE6!3!9>qM&&cqjLgrMUqNAQJ zjv*25ThBUXF*^#dIR5>A`Ss)vK`l0!(Owtheme->messages.textColors.regular; } break; + + case Symbol::Kebab: { + o.padding = 2; + o.thickness = 2; + + if (this->theme->isLightTheme()) + { + // TODO: This should use its own theme color (e.g. theme->button->regular) + o.foreground = QColor("#424242"); + } + else + { + // TODO: This should use its own theme color (e.g. theme->button->regular) + o.foreground = QColor("#c0c0c0"); + } + o.foregroundHover = this->theme->messages.textColors.regular; + } + break; } this->invalidateContent(); @@ -104,6 +122,28 @@ void DrawnButton::paintContent(QPainter &painter) painter.drawLine(horizontal); } break; + + case Symbol::Kebab: { + QPen pen; + pen.setColor(fg); + pen.setWidth(thickness); + painter.setPen(pen); + + QRect centerBox; + centerBox.setSize({thickness, thickness}); + centerBox.moveCenter(rect().center()); + + painter.fillRect(centerBox, fg); + + // NOTE: Technically a misuse of padding + auto bottomBox = centerBox.translated(0, thickness + padding); + painter.fillRect(bottomBox, fg); + + // NOTE: Technically a misuse of padding + auto topBox = centerBox.translated(0, -(thickness + padding)); + painter.fillRect(topBox, fg); + } + break; } } diff --git a/src/widgets/buttons/DrawnButton.hpp b/src/widgets/buttons/DrawnButton.hpp index 6a83b28f..417a2e9e 100644 --- a/src/widgets/buttons/DrawnButton.hpp +++ b/src/widgets/buttons/DrawnButton.hpp @@ -21,6 +21,9 @@ public: /// Padding: 2px /// Thickness: 1px Plus, + + /// kebab menu (3 dots underneath eachother) + Kebab, }; struct Options { diff --git a/src/widgets/splits/SplitHeader.cpp b/src/widgets/splits/SplitHeader.cpp index f20d9841..e75571d1 100644 --- a/src/widgets/splits/SplitHeader.cpp +++ b/src/widgets/splits/SplitHeader.cpp @@ -296,6 +296,15 @@ void SplitHeader::initializeLayout() }, this); + this->dropdownButton_ = + new DrawnButton(DrawnButton::Symbol::Kebab, {}, this); + + /// XXX: this never gets disconnected + QObject::connect(this->dropdownButton_, &Button::leftMousePress, this, + [this] { + this->dropdownButton_->setMenu(this->createMainMenu()); + }); + auto *layout = makeLayout({ // space makeWidget([](auto w) { @@ -362,12 +371,7 @@ void SplitHeader::initializeLayout() }); }), // dropdown - this->dropdownButton_ = makeWidget([&](auto w) { - /// XXX: this never gets disconnected - QObject::connect(w, &Button::leftMousePress, this, [this] { - this->dropdownButton_->setMenu(this->createMainMenu()); - }); - }), + this->dropdownButton_, // add split this->addButton_, }); @@ -1085,12 +1089,10 @@ void SplitHeader::themeChangedEvent() if (this->theme->isLightTheme()) { this->chattersButton_->setPixmap(getResources().buttons.chattersDark); - this->dropdownButton_->setPixmap(getResources().buttons.menuDark); } else { this->chattersButton_->setPixmap(getResources().buttons.chattersLight); - this->dropdownButton_->setPixmap(getResources().buttons.menuLight); } this->update(); diff --git a/src/widgets/splits/SplitHeader.hpp b/src/widgets/splits/SplitHeader.hpp index da3ffab6..e0e7b9c6 100644 --- a/src/widgets/splits/SplitHeader.hpp +++ b/src/widgets/splits/SplitHeader.hpp @@ -76,7 +76,7 @@ private: std::chrono::steady_clock::time_point lastReloadedSubEmotes_; // ui - PixmapButton *dropdownButton_{}; + DrawnButton *dropdownButton_{}; Label *titleLabel_{}; LabelButton *modeButton_{};