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

A Button that toggles between on and off. In desktop mode this looks like a checkbox and in touch mode has a distinct look and feel. More...

#include <Toggle.h>

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

Public Member Functions

QSize minimumSizeHint () const override
 
float offset () const
 
void setOffset (float o)
 
QSize sizeHint () const override
 
 Toggle (const std::function< void(Button *)> &on_click)
 
 Toggle (const TranslatedString &name, const std::function< void(Button *)> &on_click)
 
 Toggle (const TranslatedString &name, const String &icon, const std::function< void(Button *)> &on_click)
 
 Toggle (const TranslatedString &name, const String &icon, Resource< bool > &on_click)
 
 Toggle (QWidget *parent=nullptr)
 
 ~Toggle ()
 
- Public Member Functions inherited from Button
 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 ()
 

Protected Slots

void onChecked (bool checked)
 
- Protected Slots inherited from Button
void onButtonClickSlot ()
 
void onButtonPressSlot ()
 
void onButtonReleaseSlot ()
 

Protected Member Functions

void mouseReleaseEvent (QMouseEvent *) override
 
void paintEvent (QPaintEvent *) override
 
void setupToggle ()
 
int sliderHeight () const
 
QRect sliderRect () const
 
int sliderWidth () const
 
int spacing () const
 
- Protected Member Functions inherited from Button
void mousePressEvent (QMouseEvent *) override
 
void mouseReleaseEvent (QMouseEvent *) override
 

Properties

float offset
 

Additional Inherited Members

- Public Types inherited from Button
enum  ButtonState {
  e_large , e_medium , e_medium_centered , e_small ,
  e_circular , e_circular_small , e_push_button , e_none
}
 
- Static Public Attributes inherited from Button
static String s_default_sound
 
- Protected Attributes inherited from Button
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
 

Detailed Description

A Button that toggles between on and off. In desktop mode this looks like a checkbox and in touch mode has a distinct look and feel.


Constructor & Destructor Documentation

◆ Toggle() [1/5]

Toggle ( QWidget * parent = nullptr)

◆ Toggle() [2/5]

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

◆ Toggle() [3/5]

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

◆ Toggle() [4/5]

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

◆ Toggle() [5/5]

Toggle ( const TranslatedString & name,
const String & icon,
Resource< bool > & on_click )

◆ ~Toggle()

~Toggle ( )

Member Function Documentation

◆ minimumSizeHint()

QSize minimumSizeHint ( ) const
override

◆ mouseReleaseEvent()

void mouseReleaseEvent ( QMouseEvent * )
overrideprotected

◆ offset()

float offset ( ) const
inline

◆ onChecked

void onChecked ( bool checked)
protectedslot

◆ paintEvent()

void paintEvent ( QPaintEvent * )
overrideprotected

◆ setOffset()

void setOffset ( float o)
inline

◆ setupToggle()

void setupToggle ( )
protected

◆ sizeHint()

QSize sizeHint ( ) const
override

◆ sliderHeight()

int sliderHeight ( ) const
protected

◆ sliderRect()

QRect sliderRect ( ) const
protected

◆ sliderWidth()

int sliderWidth ( ) const
protected

◆ spacing()

int spacing ( ) const
protected

Property Documentation

◆ offset

float offset
readwrite

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