|
Wavelength
Privacy-focused, cross-platform, and open-source communication application
|
A custom QPushButton styled as a tab button with an animated underline effect. More...
#include <tab_button.h>
Public Member Functions | |
| void | SetActive (bool active) |
| Sets the active state of the tab button. An active button displays a full, static underline. An inactive button shows the animated underline on hover. This also affects the underline color. Triggers a repaint. | |
| void | SetUnderlineOffset (double offset) |
| Sets the value of the underline animation offset. Triggers a repaint of the button. Used by the QPropertyAnimation. | |
| TabButton (const QString &text, QWidget *parent=nullptr) | |
| Constructs a TabButton. Initializes the button as flat, checkable, sets the cursor, and applies the specific stylesheet for tab button appearance (colors, font, padding, etc.). | |
| double | UnderlineOffset () const |
| Gets the current value of the underline animation offset. | |
Protected Member Functions | |
| void | enterEvent (QEvent *event) override |
| Overridden enter event handler. Starts the animation to show the underline if the button is inactive. | |
| void | leaveEvent (QEvent *event) override |
| Overridden leave event handler. Starts the animation to hide the underline if the button is inactive. | |
| void | paintEvent (QPaintEvent *event) override |
| Overridden paint event handler. Draws the custom underline effect. Calls the base class paintEvent first. Then, draws either a full static underline (if active) or an animated, partial underline (if inactive and underline_offset_ > 0) below the button text. The underline color also depends on the active state. | |
Properties | |
| double | underlineOffset |
| Property controlling the animation state of the underline effect on hover (0.0 to 5.0). When the button is inactive, this property animates from 0.0 to 5.0 on enter, and back to 0.0 on leave. The paintEvent uses this value (and its sine) to draw the partial, moving underline. | |
Private Attributes | |
| bool | is_active_ |
| Flag indicating if the tab button is currently considered active (displays full underline). | |
| double | underline_offset_ |
| Current animation offset for the underline effect (0.0 to 5.0). | |
A custom QPushButton styled as a tab button with an animated underline effect.
This button is designed for use in tab bars. It features a flat appearance, specific cyberpunk-themed styling (colors, font) via stylesheet, and is checkable. An underline effect is drawn below the button text. The underline is fully visible when the button is active (SetActive(true) or checked) and animates smoothly on mouse hover (enter/leave events) when inactive, controlled by the underlineOffset property.
|
explicit |
Constructs a TabButton. Initializes the button as flat, checkable, sets the cursor, and applies the specific stylesheet for tab button appearance (colors, font, padding, etc.).
| text | The text to display on the tab button. |
| parent | Optional parent widget. |
|
overrideprotected |
Overridden enter event handler. Starts the animation to show the underline if the button is inactive.
| event | The enter event. |
|
overrideprotected |
Overridden leave event handler. Starts the animation to hide the underline if the button is inactive.
| event | The leave event. |
|
overrideprotected |
Overridden paint event handler. Draws the custom underline effect. Calls the base class paintEvent first. Then, draws either a full static underline (if active) or an animated, partial underline (if inactive and underline_offset_ > 0) below the button text. The underline color also depends on the active state.
| event | The paint event. |
| void TabButton::SetActive | ( | bool | active | ) |
Sets the active state of the tab button. An active button displays a full, static underline. An inactive button shows the animated underline on hover. This also affects the underline color. Triggers a repaint.
| active | True to set the button as active, false otherwise. |
| void TabButton::SetUnderlineOffset | ( | double | offset | ) |
Sets the value of the underline animation offset. Triggers a repaint of the button. Used by the QPropertyAnimation.
| offset | The desired underline offset value. |
|
inline |
Gets the current value of the underline animation offset.
|
private |
Flag indicating if the tab button is currently considered active (displays full underline).
|
private |
Current animation offset for the underline effect (0.0 to 5.0).
|
readwrite |
Property controlling the animation state of the underline effect on hover (0.0 to 5.0). When the button is inactive, this property animates from 0.0 to 5.0 on enter, and back to 0.0 on leave. The paintEvent uses this value (and its sine) to draw the partial, moving underline.