API Documentation
Loading...
Searching...
No Matches
Button Class Reference

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

#include <Button.h>

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
}
 

Public Member Functions

 Button (ButtonState state, QWidget *parent=nullptr)
 
 Button (const std::function< void(Button *)> &on_click, QWidget *parent=nullptr)
 
 Button (const TranslatedString &name, const std::function< void(Button *)> &on_click, QWidget *parent=nullptr)
 
 Button (const TranslatedString &name, const String &icon, const std::function< void(Button *)> &on_click, QWidget *parent=nullptr)
 
 Button (const TranslatedString &name, const String &icon, TooltipType tooltip, const std::function< void(Button *)> &on_click, QWidget *parent=nullptr)
 
 Button (const TranslatedString &name, const String &icon="", QWidget *parent=nullptr)
 
 Button (QWidget *parent=nullptr)
 
ButtonState buttonState () const
 
void clearBackgroundColor ()
 
void copyButtonFrom (Button *button)
 
void enterEvent (ButtonEnterEvent *e) override
 
bool event (QEvent *e) override
 
bool eventFilter (QObject *watched, QEvent *event) override
 
const StringiconName () const
 
void leaveEvent (QEvent *e) override
 
QMenu * menu () const
 
QSize minimumSizeHint () const override
 
void paintEvent (QPaintEvent *event) override
 
bool requestButtonState (ButtonState state)
 
void requestFixedState (bool fixed_state)
 
int scaledIconSize () const
 
void setAlignment (Qt::Alignment m_alignment)
 
void setAutoDefault (bool is_auto_default)
 
void setBackgroundColor (const RGBColor &color, bool update_foreground=true)
 
void setBackgroundOpacity (fltp04 background_opacity)
 
void setBold (bool is_bold)
 
void setButtonDialog (ButtonDialog *dialog)
 
void setButtonState (ButtonState state)
 
void setCheckable (bool checkable)
 
void setChecked (bool checked)
 
void setCheckedIconName (const String &icon)
 
void setClickCooldown (const TimeSpan &span)
 
void setDefault (bool is_default)
 
void setDisabledToolTip (const TranslatedString &tooltip)
 
void setFlat (bool is_flat)
 
void setFocusOnPress (bool focus_on_press)
 
void setFontMultiplier (fltp04 font_multiplier)
 
void setFunction (const std::function< void(Button *)> &on_click)
 
void setHoverFunction (const std::function< void(Button *, bool hovering)> &on_hover)
 
void setHoverIconName (const String &icon)
 
void setHoverIconSizeMultiplier (fltp04 icon_size_multiplier)
 
void setIcon (const QIcon &icon)
 
void setIconColor (const RGBColor &color)
 
void setIconName (const String &icon)
 
void setIconSize (int size)
 
void setIconSizeMultiplier (fltp04 icon_size_multiplier)
 
void setIgnoreClicks (bool ignore_clicks)
 
void setMargin (uint04 margin)
 
void setMenu (QMenu *menu)
 
void setMenuDialog (QWidget *widget)
 
void setPressFunction (const std::function< void(Button *, bool hovering)> &on_press)
 
void setProgressPercent (fltp04 progress)
 
void setSound (const String &sound)
 
void setText (const QString &text)
 
void setTitle (const TranslatedString &title)
 
void setToolTip (const QString &tip)
 
void setToolTip (const TranslatedString &enabled_tooltip, const TranslatedString &disabled_tooltip)
 
void setToolTip (const TranslatedString &tooltip)
 
void setToolTip (TooltipType type)
 
void setup (ApplicationOption< bool > &checked_var)
 
void setup (const TranslatedString &name, const String &icon, ApplicationOption< bool > &checked_var)
 
void setup (const TranslatedString &name, const String &icon, const std::function< void(Button *)> &on_click)
 
void setup (const TranslatedString &name, const String &icon, Resource< bool > &checked_var)
 
void setup (const TranslatedString &name, const String &icon, TooltipType tooltip, const std::function< void(Button *)> &on_click)
 
void setup (GenericOption &checked_var)
 
void showPopupMenu (QWidget *widget, bool is_popup=true)
 
QSize sizeHint () const override
 
int styleDefaultIconSize () const
 
const TranslatedStringtitle () const
 
void virtualMouseEvent (QEvent::Type event)
 
 ~Button ()
 

Static Public Attributes

static String s_default_sound
 

Protected Slots

void onButtonClickSlot ()
 
void onButtonPressSlot ()
 
void onButtonReleaseSlot ()
 

Protected Member Functions

void mousePressEvent (QMouseEvent *) override
 
void mouseReleaseEvent (QMouseEvent *) override
 

Protected Attributes

Qt::Alignment m_alignment
 
fltp04 m_background_opacity = 1.0f
 
String m_checked_icon
 
TimeSpan m_click_cooldown = TimeSpan(0.1)
 
String m_current_icon
 
ButtonDialogm_dialog = nullptr
 
TranslatedString m_disabled_tooltip
 
TranslatedString m_enabled_tooltip
 
bool m_fixed_state_requested = false
 
bool m_focus_on_press = true
 
fltp04 m_font_multiplier = 1.0f
 
bool m_has_custom_background_color = false
 
String m_hover_icon
 
fltp04 m_hover_icon_size_multiplier = Constant<fltp04>::Invalid
 
String m_icon
 
RGBColor m_icon_color
 
fltp04 m_icon_size_multiplier = 1.0f
 
QTResourceListenerm_icon_theme_listener = nullptr
 
bool m_ignore_clicks = false
 
bool m_is_auto_default_button = false
 
bool m_is_bold = false
 
bool m_is_default_button = false
 
Time m_last_click_time = Time(0)
 
uint04 m_margin = Constant<uint04>::Invalid
 
QPointer< QWidget > m_menu_dialog = nullptr
 
std::function< void(Button *)> m_on_click = nullptr
 
std::function< void(Button *, bool hovering)> m_on_hover = nullptr
 
std::function< void(Button *, bool pressing)> m_on_press = nullptr
 
fltp04 m_progress = Constant<fltp04>::Invalid
 
QPushButton * m_push_button = nullptr
 
String m_sound
 
ButtonState m_state = ButtonState::e_large
 
TranslatedString m_title
 

Friends

class HoverButtonIconWatch
 

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.

Member Enumeration Documentation

◆ ButtonState

Enumerator
e_large 
e_medium 
e_medium_centered 
e_small 
e_circular 
e_circular_small 
e_push_button 
e_none 

Constructor & Destructor Documentation

◆ Button() [1/7]

Button ( QWidget * parent = nullptr)

◆ Button() [2/7]

Button ( ButtonState state,
QWidget * parent = nullptr )

◆ Button() [3/7]

Button ( const TranslatedString & name,
const String & icon = "",
QWidget * parent = nullptr )

◆ Button() [4/7]

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

◆ Button() [5/7]

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

◆ Button() [6/7]

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

◆ Button() [7/7]

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

◆ ~Button()

~Button ( )

Member Function Documentation

◆ buttonState()

ButtonState buttonState ( ) const
inline

◆ clearBackgroundColor()

void clearBackgroundColor ( )

◆ copyButtonFrom()

void copyButtonFrom ( Button * button)

◆ enterEvent()

void enterEvent ( ButtonEnterEvent * e)
override

◆ event()

bool event ( QEvent * e)
override

◆ eventFilter()

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

◆ iconName()

const String & iconName ( ) const

◆ leaveEvent()

void leaveEvent ( QEvent * e)
override

◆ menu()

QMenu * menu ( ) const

◆ minimumSizeHint()

QSize minimumSizeHint ( ) const
override

◆ mousePressEvent()

void mousePressEvent ( QMouseEvent * )
overrideprotected

◆ mouseReleaseEvent()

void mouseReleaseEvent ( QMouseEvent * )
overrideprotected

◆ onButtonClickSlot

void onButtonClickSlot ( )
protectedslot

◆ onButtonPressSlot

void onButtonPressSlot ( )
protectedslot

◆ onButtonReleaseSlot

void onButtonReleaseSlot ( )
protectedslot

◆ paintEvent()

void paintEvent ( QPaintEvent * event)
override

◆ requestButtonState()

bool requestButtonState ( ButtonState state)

◆ requestFixedState()

void requestFixedState ( bool fixed_state)

◆ scaledIconSize()

int scaledIconSize ( ) const

◆ setAlignment()

void setAlignment ( Qt::Alignment m_alignment)

◆ setAutoDefault()

void setAutoDefault ( bool is_auto_default)

◆ setBackgroundColor()

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

◆ setBackgroundOpacity()

void setBackgroundOpacity ( fltp04 background_opacity)

◆ setBold()

void setBold ( bool is_bold)

◆ setButtonDialog()

void setButtonDialog ( ButtonDialog * dialog)

◆ setButtonState()

void setButtonState ( ButtonState state)

◆ setCheckable()

void setCheckable ( bool checkable)

◆ setChecked()

void setChecked ( bool checked)

◆ setCheckedIconName()

void setCheckedIconName ( const String & icon)

◆ setClickCooldown()

void setClickCooldown ( const TimeSpan & span)

◆ setDefault()

void setDefault ( bool is_default)

◆ setDisabledToolTip()

void setDisabledToolTip ( const TranslatedString & tooltip)

◆ setFlat()

void setFlat ( bool is_flat)

◆ setFocusOnPress()

void setFocusOnPress ( bool focus_on_press)

◆ setFontMultiplier()

void setFontMultiplier ( fltp04 font_multiplier)

◆ setFunction()

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

◆ setHoverFunction()

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

◆ setHoverIconName()

void setHoverIconName ( const String & icon)

◆ setHoverIconSizeMultiplier()

void setHoverIconSizeMultiplier ( fltp04 icon_size_multiplier)

◆ setIcon()

void setIcon ( const QIcon & icon)

◆ setIconColor()

void setIconColor ( const RGBColor & color)

◆ setIconName()

void setIconName ( const String & icon)

◆ setIconSize()

void setIconSize ( int size)

◆ setIconSizeMultiplier()

void setIconSizeMultiplier ( fltp04 icon_size_multiplier)

◆ setIgnoreClicks()

void setIgnoreClicks ( bool ignore_clicks)
inline

◆ setMargin()

void setMargin ( uint04 margin)

◆ setMenu()

void setMenu ( QMenu * menu)

◆ setMenuDialog()

void setMenuDialog ( QWidget * widget)

◆ setPressFunction()

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

◆ setProgressPercent()

void setProgressPercent ( fltp04 progress)

◆ setSound()

void setSound ( const String & sound)

◆ setText()

void setText ( const QString & text)

◆ setTitle()

void setTitle ( const TranslatedString & title)

◆ setToolTip() [1/4]

void setToolTip ( const QString & tip)

◆ setToolTip() [2/4]

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

◆ setToolTip() [3/4]

void setToolTip ( const TranslatedString & tooltip)

◆ setToolTip() [4/4]

void setToolTip ( TooltipType type)

◆ setup() [1/6]

void setup ( ApplicationOption< bool > & checked_var)

◆ setup() [2/6]

void setup ( const TranslatedString & name,
const String & icon,
ApplicationOption< bool > & checked_var )

◆ setup() [3/6]

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

◆ setup() [4/6]

void setup ( const TranslatedString & name,
const String & icon,
Resource< bool > & checked_var )

◆ setup() [5/6]

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

◆ setup() [6/6]

void setup ( GenericOption & checked_var)

◆ showPopupMenu()

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

◆ sizeHint()

QSize sizeHint ( ) const
override

◆ styleDefaultIconSize()

int styleDefaultIconSize ( ) const

◆ title()

const TranslatedString & title ( ) const

◆ virtualMouseEvent()

void virtualMouseEvent ( QEvent::Type event)

Friends And Related Symbol Documentation

◆ HoverButtonIconWatch

friend class HoverButtonIconWatch
friend

Member Data Documentation

◆ m_alignment

Qt::Alignment m_alignment
protected

◆ m_background_opacity

fltp04 m_background_opacity = 1.0f
protected

◆ m_checked_icon

String m_checked_icon
protected

◆ m_click_cooldown

TimeSpan m_click_cooldown = TimeSpan(0.1)
protected

◆ m_current_icon

String m_current_icon
protected

◆ m_dialog

ButtonDialog* m_dialog = nullptr
protected

◆ m_disabled_tooltip

TranslatedString m_disabled_tooltip
protected

◆ m_enabled_tooltip

TranslatedString m_enabled_tooltip
protected

◆ m_fixed_state_requested

bool m_fixed_state_requested = false
protected

◆ m_focus_on_press

bool m_focus_on_press = true
protected

◆ m_font_multiplier

fltp04 m_font_multiplier = 1.0f
protected

◆ m_has_custom_background_color

bool m_has_custom_background_color = false
protected

◆ m_hover_icon

String m_hover_icon
protected

◆ m_hover_icon_size_multiplier

fltp04 m_hover_icon_size_multiplier = Constant<fltp04>::Invalid
protected

◆ m_icon

String m_icon
protected

◆ m_icon_color

RGBColor m_icon_color
protected

◆ m_icon_size_multiplier

fltp04 m_icon_size_multiplier = 1.0f
protected

◆ m_icon_theme_listener

QTResourceListener* m_icon_theme_listener = nullptr
protected

◆ m_ignore_clicks

bool m_ignore_clicks = false
protected

◆ m_is_auto_default_button

bool m_is_auto_default_button = false
protected

◆ m_is_bold

bool m_is_bold = false
protected

◆ m_is_default_button

bool m_is_default_button = false
protected

◆ m_last_click_time

Time m_last_click_time = Time(0)
protected

◆ m_margin

uint04 m_margin = Constant<uint04>::Invalid
protected

◆ m_menu_dialog

QPointer<QWidget> m_menu_dialog = nullptr
protected

◆ m_on_click

std::function<void(Button*)> m_on_click = nullptr
protected

◆ m_on_hover

std::function<void(Button*, bool hovering)> m_on_hover = nullptr
protected

◆ m_on_press

std::function<void(Button*, bool pressing)> m_on_press = nullptr
protected

◆ m_progress

fltp04 m_progress = Constant<fltp04>::Invalid
protected

◆ m_push_button

QPushButton* m_push_button = nullptr
protected

◆ m_sound

String m_sound
protected

◆ m_state

ButtonState m_state = ButtonState::e_large
protected

◆ m_title

TranslatedString m_title
protected

◆ s_default_sound

String s_default_sound
static

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