Wavelength
Privacy-focused, cross-platform, and open-source communication application
Loading...
Searching...
No Matches
tab_button.h
Go to the documentation of this file.
1#ifndef TAB_BUTTON_H
2#define TAB_BUTTON_H
3
4#include <QPushButton>
5
15class TabButton final : public QPushButton {
16 Q_OBJECT
23
24public:
32 explicit TabButton(const QString &text, QWidget *parent = nullptr);
33
38 double UnderlineOffset() const { return underline_offset_; }
39
45 void SetUnderlineOffset(double offset);
46
54 void SetActive(bool active);
55
56protected:
61 void enterEvent(QEvent *event) override;
62
67 void leaveEvent(QEvent *event) override;
68
76 void paintEvent(QPaintEvent *event) override;
77
78private:
83};
84
85
86#endif //TAB_BUTTON_H
void leaveEvent(QEvent *event) override
Overridden leave event handler. Starts the animation to hide the underline if the button is inactive.
Definition tab_button.cpp:55
TabButton(const QString &text, QWidget *parent=nullptr)
Constructs a TabButton. Initializes the button as flat, checkable, sets the cursor,...
Definition tab_button.cpp:7
double underlineOffset
Property controlling the animation state of the underline effect on hover (0.0 to 5....
Definition tab_button.h:22
double underline_offset_
Current animation offset for the underline effect (0.0 to 5.0).
Definition tab_button.h:80
void SetActive(bool active)
Sets the active state of the tab button. An active button displays a full, static underline....
Definition tab_button.cpp:38
bool is_active_
Flag indicating if the tab button is currently considered active (displays full underline).
Definition tab_button.h:82
void paintEvent(QPaintEvent *event) override
Overridden paint event handler. Draws the custom underline effect. Calls the base class paintEvent fi...
Definition tab_button.cpp:67
double UnderlineOffset() const
Gets the current value of the underline animation offset.
Definition tab_button.h:38
void enterEvent(QEvent *event) override
Overridden enter event handler. Starts the animation to show the underline if the button is inactive.
Definition tab_button.cpp:43
void SetUnderlineOffset(double offset)
Sets the value of the underline animation offset. Triggers a repaint of the button....
Definition tab_button.cpp:33