NDEVR
API Documentation

A core widget that allows the user to click one of many button types. More...

Inheritance diagram for Button:
[legend]
Collaboration diagram for Button:
[legend]

Public Types

enum  ButtonState {
  e_large , e_medium , e_medium_centered , e_small ,
  e_circular , e_circular_small , e_push_button , e_none
}
 Defines the visual size and style of the button. More...

Public Member Functions

 Button (ButtonState state, QWidget *parent=nullptr)
 Constructs a Button with a specified visual state.
 Button (const std::function< void(Button *)> &on_click, QWidget *parent=nullptr)
 Constructs a Button with a click callback.
 Button (const TranslatedString &name, const std::function< void(Button *)> &on_click, QWidget *parent=nullptr)
 Constructs a Button with a title and click callback.
 Button (const TranslatedString &name, const StringView &icon, const std::function< void(Button *)> &on_click, QWidget *parent=nullptr)
 Constructs a Button with a title, icon, and click callback.
 Button (const TranslatedString &name, const StringView &icon, TooltipType tooltip, const std::function< void(Button *)> &on_click, QWidget *parent=nullptr)
 Constructs a Button with a title, icon, tooltip type, and click callback.
 Button (const TranslatedString &name, const StringView &icon=StringView(), QWidget *parent=nullptr)
 Constructs a Button with a title and optional icon.
 Button (QWidget *parent=nullptr)
 Constructs a Button with an optional parent widget.
 ~Button ()
 Destroys the Button and releases resources.
ButtonState buttonState () const
 Returns the current visual state of the button.
void clearBackgroundColor ()
 Clears any custom background color, reverting to the theme default.
void copyButtonFrom (Button *button)
 Copies all visual properties and settings from another Button.
void enterEvent (ButtonEnterEvent *e) override
 Handles the mouse enter event.
bool event (QEvent *e) override
 Processes a generic event, handling theme and style changes.
bool eventFilter (QObject *watched, QEvent *event) override
 Filters events for watched objects, used for push button event forwarding.
const StringiconName () const
 Returns the current icon resource name.
void leaveEvent (QEvent *e) override
 Handles the mouse leave event.
QMenu * menu () const
 Returns the dropdown menu attached to this button, if any.
QSize minimumSizeHint () const override
 Returns the minimum recommended size for the button.
void paintEvent (QPaintEvent *event) override
 Handles the paint event, rendering the button with its current style and state.
bool requestButtonState (ButtonState state)
 Requests that the button adopt the specified state, returning whether it was accepted.
void requestFixedState (bool fixed_state)
 Requests that the button maintain a fixed state, preventing automatic state changes.
int scaledIconSize () const
 Returns the icon size after applying the current size multiplier.
void setAlignment (Qt::Alignment m_alignment)
 Sets the text alignment within the button.
void setAutoDefault (bool is_auto_default)
 Sets whether the button is an auto-default button in dialogs.
void setBackgroundColor (const RGBColor &color, bool update_foreground=true)
 Sets a custom background color for the button.
void setBackgroundOpacity (fltp04 background_opacity)
 Sets the opacity of the button background (0.0 = transparent, 1.0 = opaque).
void setBold (bool is_bold)
 Sets whether the button text is rendered in bold.
void setButtonDialog (ButtonDialog *dialog)
 Associates a ButtonDialog with this button for toggle-controlled dialog visibility.
void setButtonState (ButtonState state)
 Sets the visual state/style of the button.
void setCheckable (bool checkable)
 Sets whether the button supports a checked/unchecked toggle state.
void setChecked (bool checked)
 Sets the checked state of the button.
void setCheckedIconName (const StringView &icon)
 Sets an alternate icon displayed when the button is checked.
void setClickCooldown (const TimeSpan &span)
 Sets the minimum time between successive click events.
void setDefault (bool is_default)
 Sets whether the button is the default button in dialogs.
void setDisabledToolTip (const TranslatedString &tooltip)
 Sets the tooltip shown when the button is disabled.
void setFlat (bool is_flat)
 Sets whether the button has a flat (borderless) appearance.
void setFocusOnPress (bool focus_on_press)
 Sets whether the button should receive focus when pressed.
void setFontMultiplier (fltp04 font_multiplier)
 Sets a multiplier for the button's font size.
void setForErrorOrSuccess (bool is_error, bool is_success)
 Sets the button's visual state to indicate an error or success condition.
void setFunction (const std::function< void(Button *)> &on_click)
 Sets the callback function invoked when the button is clicked.
void setHoverFunction (const std::function< void(Button *, bool hovering)> &on_hover)
 Sets a callback function invoked when the mouse enters or leaves the button.
void setHoverIconName (const StringView &icon)
 Sets an alternate icon displayed when the button is hovered.
void setHoverIconSizeMultiplier (fltp04 icon_size_multiplier)
 Sets a multiplier for the icon size when the button is hovered.
void setIcon (const QIcon &icon)
 Sets the icon directly from a QIcon object.
void setIconColor (const RGBColor &color)
 Sets a custom color for the button icon.
void setIconName (const StringView &icon)
 Sets the icon by resource name, triggering an icon update.
void setIconSize (int size)
 Sets the icon size in pixels, overriding automatic scaling.
void setIconSizeMultiplier (fltp04 icon_size_multiplier)
 Sets a multiplier for the default icon size.
void setIgnoreClicks (bool ignore_clicks)
 Sets whether click events should be ignored.
void setLogOutput (bool log_output)
 Enables or disables logging of button click events.
void setMargin (uint04 margin)
 Sets the margin around the button content in pixels.
void setMenu (QMenu *menu)
 Sets a dropdown QMenu to display when the button is clicked.
void setMenuDialog (QWidget *widget)
 Sets a widget to be shown as a popup menu when the button is clicked.
void setPressFunction (const std::function< void(Button *, bool hovering)> &on_press)
 Sets a callback function invoked when the button is pressed or released.
void setProgressPercent (fltp04 progress)
 Sets a progress percentage to display as an overlay on the button.
void setSound (const StringView &sound)
 Sets the sound played when the button is clicked.
void setText (const QString &text)
 Sets the display text of the button (Qt override).
void setTitle (const TranslatedString &title)
 Sets the display title of the button.
void setToolTip (const QString &tip)
 Sets the tooltip text from a QString.
void setToolTip (const TranslatedString &enabled_tooltip, const TranslatedString &disabled_tooltip)
 Sets separate tooltips for the enabled and disabled states.
void setToolTip (const TranslatedString &tooltip)
 Sets the tooltip text from a TranslatedString.
void setToolTip (TooltipType type)
 Sets the tooltip from a predefined tooltip type.
void setup (ApplicationOption< bool > &checked_var)
 Sets up the button as a checkable toggle bound to an ApplicationOption<bool>.
void setup (const TranslatedString &name, const StringView &icon, ApplicationOption< bool > &checked_var)
 Sets up the button with a name, icon, and ApplicationOption<bool> binding.
void setup (const TranslatedString &name, const StringView &icon, const std::function< void(Button *)> &on_click)
 Sets up the button with a name, icon, and click callback.
void setup (const TranslatedString &name, const StringView &icon, Resource< bool > &checked_var)
 Sets up the button as a checkable toggle bound to a bool Resource.
void setup (const TranslatedString &name, const StringView &icon, TooltipType tooltip, const std::function< void(Button *)> &on_click)
 Sets up the button with a name, icon, tooltip type, and click callback.
void setup (GenericOption &checked_var)
 Sets up the button from a GenericOption, using its name, icon, and value.
void showPopupMenu (QWidget *widget, bool is_popup=true)
 Shows a popup menu widget anchored to this button.
void showToolTip () const
 Programmatically shows the button's tooltip at the button's position.
QSize sizeHint () const override
 Returns the recommended size for the button.
int styleDefaultIconSize () const
 Returns the default icon size as determined by the current style.
const TranslatedStringtitle () const
 Returns the translated title of the button.
void virtualMouseEvent (QEvent::Type event)
 Simulates a mouse event of the given type on the button.

Static Public Attributes

static String s_default_sound
 The default sound played by all buttons on click.

Protected Member Functions

void mousePressEvent (QMouseEvent *) override
 Handles the mouse press event.
void mouseReleaseEvent (QMouseEvent *) override
 Handles the mouse release event for click detection.
void onButtonClickSlot ()
 Slot invoked when the button is clicked, executing the click callback.
void onButtonPressSlot ()
 Slot invoked when the button is pressed down.
void onButtonReleaseSlot ()
 Slot invoked when the button is released.

Protected Attributes

Qt::Alignment m_alignment
 Text alignment within the button.
fltp04 m_background_opacity = 1.0f
 Opacity of the button background.
String m_checked_icon
 Icon resource name displayed when checked.
TimeSpan m_click_cooldown = TimeSpan(0.1)
 Minimum duration between successive clicks.
String m_current_icon
 The currently displayed icon resource name.
ButtonDialogm_dialog = nullptr
 Associated ButtonDialog for toggle-controlled visibility.
TranslatedString m_disabled_tooltip
 Tooltip shown when the button is disabled.
TranslatedString m_enabled_tooltip
 Tooltip shown when the button is enabled.
bool m_fixed_state_requested = false
 Whether the button state has been locked.
bool m_focus_on_press = true
 Whether the button receives focus when pressed.
fltp04 m_font_multiplier = 1.0f
 Multiplier applied to the default font size.
bool m_has_custom_background_color = false
 Whether a custom background color has been set.
String m_hover_icon
 Icon resource name displayed on hover.
fltp04 m_hover_icon_size_multiplier = Constant<fltp04>::Invalid
 Icon size multiplier when hovered, or Invalid for default.
String m_icon
 The requested icon resource name.
RGBColor m_icon_color
 Custom icon color override.
fltp04 m_icon_size_multiplier = 1.0f
 Multiplier applied to the default icon size.
QTResourceListenerm_icon_theme_listener = nullptr
 Listener for icon theme changes.
bool m_ignore_clicks = false
 Whether to ignore click events.
bool m_is_auto_default_button = false
 Whether this is an auto-default button in a dialog.
bool m_is_bold = false
 Whether the button text is bold.
bool m_is_default_button = false
 Whether this is the default button in a dialog.
Time m_last_click_time = Time(0)
 Timestamp of the most recent click event.
bool m_log_output = true
 Whether click events are logged.
uint04 m_margin = Constant<uint04>::Invalid
 Custom margin around button content, or Invalid for default.
QPointer< QWidget > m_menu_dialog = nullptr
 Widget shown as a popup menu on click.
std::function< void(Button *)> m_on_click = nullptr
 Callback invoked on button click.
std::function< void(Button *, bool hovering)> m_on_hover = nullptr
 Callback invoked on hover state change.
std::function< void(Button *, bool pressing)> m_on_press = nullptr
 Callback invoked on press state change.
fltp04 m_progress = Constant<fltp04>::Invalid
 Progress overlay value (0.0-1.0), or Invalid to hide.
QPushButton * m_push_button = nullptr
 Internal QPushButton used for push button state rendering.
String m_sound
 Sound resource name played on click.
ButtonState m_state = ButtonState::e_large
 The current visual state/style of the button.
TranslatedString m_title
 The display title of the button.

Detailed Description

A core widget that allows the user to click one of many button types.


Perhaps the most commonly used widget in any graphical user interface. Push (click) a button to command the computer to perform some action, or to answer a question.

See also
Toggle, ColorChooserButton, ButtonDialog

Definition at line 67 of file Button.h.

Member Enumeration Documentation

◆ ButtonState

Defines the visual size and style of the button.

Enumerator
e_large 

Large button with icon and text below.

e_medium 

Medium button with icon and text beside it.

e_medium_centered 

Medium button with centered icon and text.

e_small 

Small button with icon only.

e_circular 

Circular button.

e_circular_small 

Small circular button.

e_push_button 

Standard push button style.

e_none 

No specific style applied.

Definition at line 75 of file Button.h.

Constructor & Destructor Documentation

◆ Button() [1/7]

◆ Button() [2/7]

Button::Button ( ButtonState state,
QWidget * parent = nullptr )

Constructs a Button with a specified visual state.

Parameters
[in]stateThe initial button state/style.
[in]parentThe parent widget.

◆ Button() [3/7]

Button::Button ( const TranslatedString & name,
const StringView & icon = StringView(),
QWidget * parent = nullptr )

Constructs a Button with a title and optional icon.

Parameters
[in]nameThe display title of the button.
[in]iconThe icon resource name.
[in]parentThe parent widget.

◆ Button() [4/7]

Button::Button ( const std::function< void(Button *)> & on_click,
QWidget * parent = nullptr )

Constructs a Button with a click callback.

Parameters
[in]on_clickThe function to call when clicked.
[in]parentThe parent widget.

References Button().

◆ Button() [5/7]

Button::Button ( const TranslatedString & name,
const std::function< void(Button *)> & on_click,
QWidget * parent = nullptr )

Constructs a Button with a title and click callback.

Parameters
[in]nameThe display title of the button.
[in]on_clickThe function to call when clicked.
[in]parentThe parent widget.

References Button().

◆ Button() [6/7]

Button::Button ( const TranslatedString & name,
const StringView & icon,
const std::function< void(Button *)> & on_click,
QWidget * parent = nullptr )

Constructs a Button with a title, icon, and click callback.

Parameters
[in]nameThe display title of the button.
[in]iconThe icon resource name.
[in]on_clickThe function to call when clicked.
[in]parentThe parent widget.

References Button().

◆ Button() [7/7]

Button::Button ( const TranslatedString & name,
const StringView & icon,
TooltipType tooltip,
const std::function< void(Button *)> & on_click,
QWidget * parent = nullptr )

Constructs a Button with a title, icon, tooltip type, and click callback.

Parameters
[in]nameThe display title of the button.
[in]iconThe icon resource name.
[in]tooltipThe tooltip type to display.
[in]on_clickThe function to call when clicked.
[in]parentThe parent widget.

References Button().

Member Function Documentation

◆ buttonState()

ButtonState Button::buttonState ( ) const
inline

Returns the current visual state of the button.

Returns
The current ButtonState.

Definition at line 255 of file Button.h.

References m_state.

◆ copyButtonFrom()

void Button::copyButtonFrom ( Button * button)

Copies all visual properties and settings from another Button.

Parameters
[in]buttonThe button to copy from.

References Button().

◆ enterEvent()

void Button::enterEvent ( ButtonEnterEvent * e)
override

Handles the mouse enter event.

Parameters
[in]eThe enter event.

◆ event()

bool Button::event ( QEvent * e)
override

Processes a generic event, handling theme and style changes.

Parameters
[in]eThe event to process.
Returns
True if the event was handled.

Referenced by eventFilter(), paintEvent(), and virtualMouseEvent().

◆ eventFilter()

bool Button::eventFilter ( QObject * watched,
QEvent * event )
override

Filters events for watched objects, used for push button event forwarding.

Parameters
[in]watchedThe object being watched.
[in]eventThe event to filter.
Returns
True if the event was consumed.

References event().

◆ iconName()

const String & Button::iconName ( ) const

Returns the current icon resource name.

Returns
A const reference to the icon name string.

◆ leaveEvent()

void Button::leaveEvent ( QEvent * e)
override

Handles the mouse leave event.

Parameters
[in]eThe leave event.

◆ menu()

QMenu * Button::menu ( ) const

Returns the dropdown menu attached to this button, if any.

Returns
A pointer to the QMenu, or nullptr if none is set.

Referenced by setMenu().

◆ minimumSizeHint()

QSize Button::minimumSizeHint ( ) const
override

Returns the minimum recommended size for the button.

Returns
The minimum size hint.

◆ paintEvent()

void Button::paintEvent ( QPaintEvent * event)
override

Handles the paint event, rendering the button with its current style and state.

Parameters
[in]eventThe paint event.

References event().

◆ requestButtonState()

bool Button::requestButtonState ( ButtonState state)

Requests that the button adopt the specified state, returning whether it was accepted.

Parameters
[in]stateThe requested button state.
Returns
True if the state was accepted.

◆ requestFixedState()

void Button::requestFixedState ( bool fixed_state)

Requests that the button maintain a fixed state, preventing automatic state changes.

Parameters
[in]fixed_stateWhether to lock the current state.

◆ scaledIconSize()

int Button::scaledIconSize ( ) const

Returns the icon size after applying the current size multiplier.

Returns
The scaled icon size in pixels.

◆ setAlignment()

void Button::setAlignment ( Qt::Alignment m_alignment)

Sets the text alignment within the button.

Parameters
[in]m_alignmentThe alignment flags.

References m_alignment.

◆ setAutoDefault()

void Button::setAutoDefault ( bool is_auto_default)

Sets whether the button is an auto-default button in dialogs.

Parameters
[in]is_auto_defaultWhether the button is auto-default.

◆ setBackgroundColor()

void Button::setBackgroundColor ( const RGBColor & color,
bool update_foreground = true )

Sets a custom background color for the button.

Parameters
[in]colorThe background color.
[in]update_foregroundWhether to automatically adjust the foreground color for contrast.

◆ setBackgroundOpacity()

void Button::setBackgroundOpacity ( fltp04 background_opacity)

Sets the opacity of the button background (0.0 = transparent, 1.0 = opaque).

Parameters
[in]background_opacityThe background opacity value.

◆ setBold()

void Button::setBold ( bool is_bold)

Sets whether the button text is rendered in bold.

Parameters
[in]is_boldWhether text should be bold.

◆ setButtonDialog()

void Button::setButtonDialog ( ButtonDialog * dialog)

Associates a ButtonDialog with this button for toggle-controlled dialog visibility.

Parameters
[in]dialogThe ButtonDialog to associate.

◆ setButtonState()

void Button::setButtonState ( ButtonState state)

Sets the visual state/style of the button.

Parameters
[in]stateThe button state to apply.

Referenced by ProgressWidgetDemo::OptionsButton().

◆ setCheckable()

void Button::setCheckable ( bool checkable)

Sets whether the button supports a checked/unchecked toggle state.

Parameters
[in]checkableWhether the button is checkable.

◆ setChecked()

void Button::setChecked ( bool checked)

Sets the checked state of the button.

Parameters
[in]checkedWhether the button is checked.

Referenced by DesignObjectToggleWidget::onObjectUpdatedSlot().

◆ setCheckedIconName()

void Button::setCheckedIconName ( const StringView & icon)

Sets an alternate icon displayed when the button is checked.

Parameters
[in]iconThe checked-state icon resource name.

◆ setClickCooldown()

void Button::setClickCooldown ( const TimeSpan & span)

Sets the minimum time between successive click events.

Parameters
[in]spanThe cooldown duration between clicks.

◆ setDefault()

void Button::setDefault ( bool is_default)

Sets whether the button is the default button in dialogs.

Parameters
[in]is_defaultWhether the button is the default.

◆ setDisabledToolTip()

void Button::setDisabledToolTip ( const TranslatedString & tooltip)

Sets the tooltip shown when the button is disabled.

Parameters
[in]tooltipThe disabled-state tooltip text.

◆ setFlat()

void Button::setFlat ( bool is_flat)

Sets whether the button has a flat (borderless) appearance.

Parameters
[in]is_flatWhether the button should be flat.

◆ setFocusOnPress()

void Button::setFocusOnPress ( bool focus_on_press)

Sets whether the button should receive focus when pressed.

Parameters
[in]focus_on_pressWhether to focus on press.

◆ setFontMultiplier()

void Button::setFontMultiplier ( fltp04 font_multiplier)

Sets a multiplier for the button's font size.

Parameters
[in]font_multiplierThe font size multiplier (1.0 = default).

◆ setForErrorOrSuccess()

void Button::setForErrorOrSuccess ( bool is_error,
bool is_success )

Sets the button's visual state to indicate an error or success condition.

Parameters
[in]is_errorWhether the button should display as an error.
[in]is_successWhether the button should display as a success.

◆ setFunction()

void Button::setFunction ( const std::function< void(Button *)> & on_click)
inline

Sets the callback function invoked when the button is clicked.

Parameters
[in]on_clickThe click callback function.

Definition at line 260 of file Button.h.

References Button(), and m_on_click.

Referenced by DesignObjectToggleWidget::DesignObjectToggleWidget().

◆ setHoverFunction()

void Button::setHoverFunction ( const std::function< void(Button *, bool hovering)> & on_hover)
inline

Sets a callback function invoked when the mouse enters or leaves the button.

Parameters
[in]on_hoverThe hover callback, receiving the button and hover state.

Definition at line 265 of file Button.h.

References Button(), and m_on_hover.

◆ setHoverIconName()

void Button::setHoverIconName ( const StringView & icon)

Sets an alternate icon displayed when the button is hovered.

Parameters
[in]iconThe hover icon resource name.

◆ setHoverIconSizeMultiplier()

void Button::setHoverIconSizeMultiplier ( fltp04 icon_size_multiplier)

Sets a multiplier for the icon size when the button is hovered.

Parameters
[in]icon_size_multiplierThe hover icon size multiplier.

◆ setIcon()

void Button::setIcon ( const QIcon & icon)

Sets the icon directly from a QIcon object.

Parameters
[in]iconThe QIcon to display.

◆ setIconColor()

void Button::setIconColor ( const RGBColor & color)

Sets a custom color for the button icon.

Parameters
[in]colorThe icon color.

◆ setIconName()

void Button::setIconName ( const StringView & icon)

Sets the icon by resource name, triggering an icon update.

Parameters
[in]iconThe icon resource name.

◆ setIconSize()

void Button::setIconSize ( int size)

Sets the icon size in pixels, overriding automatic scaling.

Parameters
[in]sizeThe icon size in pixels.

◆ setIconSizeMultiplier()

void Button::setIconSizeMultiplier ( fltp04 icon_size_multiplier)

Sets a multiplier for the default icon size.

Parameters
[in]icon_size_multiplierThe multiplier value (1.0 = default).

◆ setIgnoreClicks()

void Button::setIgnoreClicks ( bool ignore_clicks)
inline

Sets whether click events should be ignored.

Parameters
[in]ignore_clicksWhether to ignore clicks.

Definition at line 378 of file Button.h.

References m_ignore_clicks.

◆ setLogOutput()

void Button::setLogOutput ( bool log_output)

Enables or disables logging of button click events.

Parameters
[in]log_outputWhether to log clicks.

◆ setMargin()

void Button::setMargin ( uint04 margin)

Sets the margin around the button content in pixels.

Parameters
[in]marginThe margin size.

◆ setMenu()

void Button::setMenu ( QMenu * menu)

Sets a dropdown QMenu to display when the button is clicked.

Parameters
[in]menuThe menu to attach.

References menu().

◆ setMenuDialog()

void Button::setMenuDialog ( QWidget * widget)

Sets a widget to be shown as a popup menu when the button is clicked.

Parameters
[in]widgetThe menu dialog widget.

◆ setPressFunction()

void Button::setPressFunction ( const std::function< void(Button *, bool hovering)> & on_press)
inline

Sets a callback function invoked when the button is pressed or released.

Parameters
[in]on_pressThe press callback, receiving the button and press state.

Definition at line 270 of file Button.h.

References Button(), and m_on_press.

◆ setProgressPercent()

void Button::setProgressPercent ( fltp04 progress)

Sets a progress percentage to display as an overlay on the button.

Parameters
[in]progressThe progress value from 0.0 to 1.0, or Invalid to hide.

◆ setSound()

void Button::setSound ( const StringView & sound)

Sets the sound played when the button is clicked.

Parameters
[in]soundThe sound resource name.

◆ setText()

void Button::setText ( const QString & text)

Sets the display text of the button (Qt override).

Parameters
[in]textThe text to display.

◆ setTitle()

void Button::setTitle ( const TranslatedString & title)

Sets the display title of the button.

Parameters
[in]titleThe translated title text.

References title().

Referenced by GoogleEarthApplicationManager::createLauncherButton(), and DesignObjectToggleWidget::setNDPO().

◆ setToolTip() [1/4]

void Button::setToolTip ( const QString & tip)

Sets the tooltip text from a QString.

Parameters
[in]tipThe tooltip text.

◆ setToolTip() [2/4]

void Button::setToolTip ( const TranslatedString & enabled_tooltip,
const TranslatedString & disabled_tooltip )

Sets separate tooltips for the enabled and disabled states.

Parameters
[in]enabled_tooltipThe tooltip shown when the button is enabled.
[in]disabled_tooltipThe tooltip shown when the button is disabled.

◆ setToolTip() [3/4]

void Button::setToolTip ( const TranslatedString & tooltip)

Sets the tooltip text from a TranslatedString.

Parameters
[in]tooltipThe translated tooltip text.

◆ setToolTip() [4/4]

void Button::setToolTip ( TooltipType type)

Sets the tooltip from a predefined tooltip type.

Parameters
[in]typeThe tooltip type.

◆ setup() [1/6]

void Button::setup ( ApplicationOption< bool > & checked_var)

Sets up the button as a checkable toggle bound to an ApplicationOption<bool>.

Parameters
[in]checked_varThe application option to bind to.

◆ setup() [2/6]

void Button::setup ( const TranslatedString & name,
const StringView & icon,
ApplicationOption< bool > & checked_var )

Sets up the button with a name, icon, and ApplicationOption<bool> binding.

Parameters
[in]nameThe display title.
[in]iconThe icon resource name.
[in]checked_varThe application option to bind to.

◆ setup() [3/6]

void Button::setup ( const TranslatedString & name,
const StringView & icon,
const std::function< void(Button *)> & on_click )

Sets up the button with a name, icon, and click callback.

Parameters
[in]nameThe display title.
[in]iconThe icon resource name.
[in]on_clickThe function to call when clicked.

References Button().

Referenced by onButtonReleaseSlot().

◆ setup() [4/6]

void Button::setup ( const TranslatedString & name,
const StringView & icon,
Resource< bool > & checked_var )

Sets up the button as a checkable toggle bound to a bool Resource.

Parameters
[in]nameThe display title.
[in]iconThe icon resource name.
[in]checked_varThe bool resource to bind the checked state to.

◆ setup() [5/6]

void Button::setup ( const TranslatedString & name,
const StringView & icon,
TooltipType tooltip,
const std::function< void(Button *)> & on_click )

Sets up the button with a name, icon, tooltip type, and click callback.

Parameters
[in]nameThe display title.
[in]iconThe icon resource name.
[in]tooltipThe tooltip type.
[in]on_clickThe function to call when clicked.

References Button().

◆ setup() [6/6]

void Button::setup ( GenericOption & checked_var)

Sets up the button from a GenericOption, using its name, icon, and value.

Parameters
[in]checked_varThe generic option to bind to.

◆ showPopupMenu()

void Button::showPopupMenu ( QWidget * widget,
bool is_popup = true )

Shows a popup menu widget anchored to this button.

Parameters
[in]widgetThe widget to display as a popup.
[in]is_popupWhether to show the widget as a popup dialog.

◆ sizeHint()

QSize Button::sizeHint ( ) const
override

Returns the recommended size for the button.

Returns
The preferred size hint.

◆ styleDefaultIconSize()

int Button::styleDefaultIconSize ( ) const

Returns the default icon size as determined by the current style.

Returns
The default icon size in pixels.

◆ title()

const TranslatedString & Button::title ( ) const

Returns the translated title of the button.

Returns
A const reference to the button title.

Referenced by ColorChooserButton::ColorChooserButton(), setTitle(), and DesignObjectToggleWidget::setupForMetadata().

◆ virtualMouseEvent()

void Button::virtualMouseEvent ( QEvent::Type event)

Simulates a mouse event of the given type on the button.

Parameters
[in]eventThe mouse event type to simulate.

References event().


The documentation for this class was generated from the following file: