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 bca55f26..00000000 Binary files a/resources/buttons/menuDark.png and /dev/null differ diff --git a/resources/buttons/menuLight.png b/resources/buttons/menuLight.png deleted file mode 100644 index 42bdfb3e..00000000 Binary files a/resources/buttons/menuLight.png and /dev/null differ diff --git a/src/widgets/buttons/DrawnButton.cpp b/src/widgets/buttons/DrawnButton.cpp index 51634a4c..3e28149e 100644 --- a/src/widgets/buttons/DrawnButton.cpp +++ b/src/widgets/buttons/DrawnButton.cpp @@ -42,6 +42,24 @@ void DrawnButton::themeChangedEvent() o.foregroundHover = this->theme->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_{};