Class SBGUIPushButton#
QPushButton subclass that can display an animated GIF overlay (e.g., a busy spinner) on top of the button's icon while a "busy" state is active. More...
#include <SBGUIPushButton.hpp>
Inherits the following classes: QPushButton, QPushButton
Public Functions#
| Type | Name |
|---|---|
| SBGUIPushButton (QWidget * parent=nullptr) Constructs a SBGUIPushButton with an optional parent widget. |
|
| bool | dimBaseIconWhileBusy () const Returns whether the shade is drawn. |
| bool | isBusy () const Returns whether overlay is shown. |
| QPoint | overlayOffset () const Returns the overlay offset. |
| qreal | overlayScale () const Returns the overlay scale. |
| void | setBusy (bool on) Enable or disable the busy overlay. |
| void | setDimBaseIconWhileBusy (bool on) If true, draws a subtle shade over the base icon while busy. |
| bool | setOverlayGif (const QString & path) Load a GIF (from file path or Qt resource) to use as the busy overlay. |
| void | setOverlayMovie (QMovie * movie) Provide an already-constructed QMovie as the overlay. |
| void | setOverlayOffset (const QPoint & px) Optional pixel offset to nudge the overlay relative to the icon rect. |
| void | setOverlayScale (qreal s) Scale overlay relative to the base icon rectangle. |
| ~SBGUIPushButton () override |
Protected Functions#
| Type | Name |
|---|---|
| void | paintEvent (QPaintEvent * e) override Paints the standard QPushButton then, if busy, draws the animated overlay centered on the button's icon rectangle. |
Detailed Description#
Usage: auto* btn = new SBGUIPushButton(parent); btn->setIcon(QIcon(":/icons/download.svg")); btn->setOverlayGif(":/spinners/spinner.gif"); btn->setBusy(true); // starts animation overlay
Notes: * The overlay scales relative to the button's iconSize(). * Optionally dims the base icon while busy to provide visual feedback. * A fallback repaint timer is used in case the QMovie doesn't emit frameChanged.
Public Functions Documentation#
function SBGUIPushButton#
Constructs a SBGUIPushButton with an optional parent widget.
Creates a new button instance. The button is initially not busy and has default overlay settings.
Parameters:
parentThe parent widget for this button, or nullptr.
function dimBaseIconWhileBusy#
Returns whether the shade is drawn.
function isBusy#
Returns whether overlay is shown.
function overlayOffset#
Returns the overlay offset.
function overlayScale#
Returns the overlay scale.
function setBusy#
Enable or disable the busy overlay.
Starts/stops the movie and triggers repaints.
Parameters:
ontrueto enable the busy overlay,falseto disable it.
function setDimBaseIconWhileBusy#
If true, draws a subtle shade over the base icon while busy.
Enable or disable drawing a subtle shade over the base icon while busy.
Parameters:
onTrue to draw the shade,falseto disable it.
function setOverlayGif#
Load a GIF (from file path or Qt resource) to use as the busy overlay.
Ownership: the created QMovie is parented to this button.
Parameters:
pathFile path or qrc path to a GIF.
Returns:
true on success, false if the movie is invalid.
function setOverlayMovie#
Provide an already-constructed QMovie as the overlay.
Provide an already‑constructed QMovie as the overlay.
Ownership is transferred to this button (parent is set to this).
Parameters:
movieQMovie to use (may benullptrto clear).
function setOverlayOffset#
Optional pixel offset to nudge the overlay relative to the icon rect.
Set an optional pixel offset to nudge the overlay relative to the icon rect.
Parameters:
pxPixel offset to apply.
function setOverlayScale#
Scale overlay relative to the base icon rectangle.
1.0 = same size, 0.8 = 80%, etc. Clamped to [0.2, 2.0].
Parameters:
sDesired overlay scale factor.
function ~SBGUIPushButton#
Protected Functions Documentation#
function paintEvent#
Paints the standard QPushButton then, if busy, draws the animated overlay centered on the button's icon rectangle.
Paint the standard QPushButton and, if busy, draw the animated overlay centered on the button's icon rectangle.
Parameters:
eThe paint event describing the area to be repainted.