refactor: buttons and friends (#6102)

This commit is contained in:
nerix
2025-05-25 11:17:06 +02:00
committed by GitHub
parent deed1061b5
commit 84c0b39fde
49 changed files with 1083 additions and 691 deletions
+19 -5
View File
@@ -16,10 +16,11 @@ typedef struct tagMSG MSG;
namespace chatterino {
class Button;
class EffectLabel;
class LabelButton;
class PixmapButton;
class TitleBarButton;
class TitleBarButtons;
enum class TitleBarButtonStyle;
enum class TitleBarButtonStyle : std::uint8_t;
class BaseWindow : public BaseWidget
{
@@ -52,9 +53,20 @@ public:
QWidget *getLayoutContainer();
bool hasCustomWindowFrame() const;
TitleBarButton *addTitleBarButton(const TitleBarButtonStyle &style,
std::function<void()> onClicked);
EffectLabel *addTitleBarLabel(std::function<void()> onClicked);
template <typename T>
T *addTitleBarButton(std::function<void()> onClicked, auto &&...args)
{
auto *button = new T(std::forward<decltype(args)>(args)...);
button->setScaleIndependentSize(30, 30);
this->appendTitlebarButton(button);
QObject::connect(button, &T::leftClicked, this, std::move(onClicked));
return button;
}
LabelButton *addTitleBarLabel(std::function<void()> onClicked);
void moveTo(QPoint point, widgets::BoundsChecking mode);
@@ -169,6 +181,8 @@ private:
bool handleNCHITTEST(MSG *msg, long *result);
#endif
void appendTitlebarButton(Button *button);
bool enableCustomFrame_;
bool frameless_;
bool shown_ = false;