NDEVR
API Documentation
NDEVRProxyStyle

Responsible for setting up the core style of the application including size of various widgets and colors. More...

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

Public Member Functions

 NDEVRProxyStyle ()
 Constructs the proxy style with default settings.
 NDEVRProxyStyle (const File &ini_file)
 Constructs the proxy style and loads settings from an INI file.
 NDEVRProxyStyle (QStyle *style)
 Constructs the proxy style wrapping an existing QStyle.
fltp08 baseTextScale () const
 Returns the base text scaling factor.
fltp08 desktopFontScale ()
 Returns the desktop font scaling factor.
RGBColor disabledColor (NDEVRLightingTheme theme) const
 Returns the disabled-state color for a given theme.
void drawArrow (Qt::ArrowType type, QPainter *painter, const QStyleOption *option, const QRect &rect, const QColor &color) const
 Draws an arrow indicator in the given direction.
void drawComplexControl (ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget=nullptr) const override
 Draws a complex control such as a scroll bar or slider.
void drawControl (ControlElement element, const QStyleOption *opt, QPainter *painter, const QWidget *widget) const override
 Draws a control element such as a button or label.
virtual void drawItemPixmap (QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const override
 Draws a pixmap within a styled context.
void drawItemText (QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole=QPalette::NoRole) const override
 Draws text within a styled context.
virtual void drawPrimitive (PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const override
 Draws a primitive style element with custom NDEVR rendering.
TimeSpan fadeInAnimationTime () const
 Returns the duration of fade-in animations.
TimeSpan fadeOutAnimationTime () const
 Returns the duration of fade-out animations.
virtual void getINI (INIFactory &factory) override
 Serializes or deserializes theme settings through an INI factory.
QPalette interpolatedThemePalette (NDEVRLightingTheme start, NDEVRLightingTheme end, fltp04 percent) const
 Returns a palette that interpolates between two themes.
bool isGlobalStyle () const
 Checks whether this instance is the global singleton style.
QRect itemPixmapRect (const QRect &r, int flags, const QPixmap &pixmap) const override
 Returns the bounding rectangle for an item pixmap.
QRect itemTextRect (const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const override
 Returns the bounding rectangle for item text.
void lightingThemeChangedSignal (NDEVRLightingTheme theme)
 Emitted when the lighting theme changes.
NDEVRLightingTheme oldTheme () const
 Returns the theme that was active before the most recent theme change.
TimeSpan paletteAnimationTime () const
 Returns the duration of palette transition animations.
int pixelMetric (PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const override
 Returns a pixel metric value scaled for the current UI settings.
void polish (QWidget *widget) override
 Polishes a widget by applying NDEVR-specific style adjustments.
TimeSpan resizeAnimationTime () const
 Returns the duration of widget resize animations.
void setLightingTheme (NDEVRLightingTheme theme, bool force_update=false, bool save_settings=true)
 Sets the active lighting theme immediately.
void setLightingThemeAnimated (NDEVRLightingTheme start, NDEVRLightingTheme end, fltp04 percent)
 Sets the lighting theme with an animated transition at a specific percentage.
void setLightingThemeAnimated (NDEVRLightingTheme theme)
 Sets the lighting theme with an animated transition from the current theme.
void setToDefaultColors ()
 Resets all theme colors to their default values.
void setToDefaultSizes ()
 Resets all UI size metrics to their default values.
void setUseRoundedButtons (bool use_rounded_buttons)
 Enables or disables rounded button rendering.
QSize sizeFromContents (ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const override
 Computes the size for a widget given its contents type.
QIcon standardIcon (StandardPixmap standardIcon, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const override
 Returns the standard icon for a given pixmap type.
virtual QPalette standardPalette () const override
 Returns the standard palette for the current theme.
int styleHint (StyleHint stylehint, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr, QStyleHintReturn *returnData=nullptr) const override
 Returns a style hint value for the given hint type.
QRect subControlRect (ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const override
 Returns the sub-control rectangle for a complex control.
QRect subElementRect (SubElement element, const QStyleOption *option, const QWidget *widget) const override
 Returns the sub-element rectangle for a given element type.
NDEVRLightingTheme theme () const
 Returns the currently active lighting theme.
QPalette themePalette (NDEVRLightingTheme theme) const
 Returns the palette for a specific lighting theme.
fltp04 themeTransitionPercent ()
 Returns the current theme transition animation percentage.
void updateIconOverrideTheme ()
 Updates the icon theme override to match the current lighting theme.
void updateResolutionPixelMetric ()
 Recalculates the resolution-dependent pixel metric based on the current display.
void updateUIFromStyle ()
 Refreshes the entire UI to reflect current style settings.
bool usingRoundedButtons () const
 Checks whether rounded buttons are currently enabled.
Public Member Functions inherited from INIInterface
 INIInterface ()
 Constructs an INIInterface with no default INI file.
 INIInterface (const File &default_ini)
 Constructs an INIInterface with the specified default INI file.
virtual ~INIInterface ()
 Virtual destructor for safe polymorphic cleanup.
virtual void finishReadingINI (INIFactory &)
 Called after reading an INI file.
virtual void prepareForINI (INIFactory &)
 Called before reading or writing an INI file.
virtual bool readINIOptions ()
 Reads INI options from the default INI file.
virtual bool readINIOptions (File &ini_file)
 Reads INI options from the specified INI file.
virtual bool saveINIOptions (bool multithead=false)
 Saves INI options to the default INI file.
virtual bool saveINIOptions (File &ini_file, bool multithead=false)
 Saves INI options to the specified INI file.
void setDefaultINIFile (const File &file)
 Sets the default INI file path used for reading and writing options.
virtual void writeToLog (const StringView &title, LogPtr log, uint01 log_level=2U)
 Writes the current INI options to the specified log with a title.
virtual void writeToLog (LogPtr log, uint01 log_level=2U)
 Writes the current INI options to the specified log.

Static Public Member Functions

static StringView ColorThemeIcon (NDEVRLightingTheme theme)
 Returns the icon name associated with a given lighting theme.
static NDEVRProxyStyleGlobalStyle ()
 Returns the singleton global style instance.
static QFont OriginalFont ()
 Returns the original application font before any scaling is applied.

Protected Member Functions

fltp08 baseUIScale () const
 Returns the base UI scaling factor.
void drawRoundedButtonBackground (const QStyleOption *opt, QPainter *p, int radius=Constant< int >::Max) const
 Draws a rounded button background.
void init ()
 Initializes the proxy style with default values and system metrics.
void saveSettings ()
 Persists the current style settings to storage.
void updateFontScale ()
 Recalculates the font scale based on current settings.

Protected Attributes

fltp08 m_desktop_text_scale
 Text scale factor for desktop mode.
fltp08 m_desktop_ui_scale
 UI scale factor for desktop mode.
QStyle * m_native_theme
 The platform native style used as a fallback.
NDEVRLightingTheme m_old_theme
 The previously active theme before the last change.
fltp08 m_resolution_pixel_metric
 A DPI-aware pixel metric for the current display.
NDEVRLightingTheme m_theme
 The currently active lighting theme.
fltp04 m_theme_transition_percent
 Current animation progress during theme transitions.
fltp08 m_touch_text_scale_horz
 Horizontal text scale factor for touch mode.
fltp08 m_touch_text_scale_vert
 Vertical text scale factor for touch mode.
fltp08 m_touch_ui_scale_horz
 Horizontal UI scale factor for touch mode.
fltp08 m_touch_ui_scale_vert
 Vertical UI scale factor for touch mode.
bool m_touch_use_rounded_buttons
 Whether rounded button rendering is enabled in touch mode.
RGBColor theme_colors [NDEVRLightingTheme::e_num_of_themes][QPalette::NColorRoles]
 Per-theme color table indexed by theme and palette role.
Protected Attributes inherited from INIInterface
File m_default_ini
 The default file path used for reading and writing INI options.

Static Protected Attributes

static NDEVRProxyStyles_global_style
 The singleton global style instance.

Detailed Description

Responsible for setting up the core style of the application including size of various widgets and colors.


Some themes are inherited from the OS, some from Qt's fusion style, and some are defined and drawn directly.

Definition at line 94 of file NDEVRTheme.h.

Constructor & Destructor Documentation

◆ NDEVRProxyStyle() [1/2]

NDEVRProxyStyle::NDEVRProxyStyle ( const File & ini_file)

Constructs the proxy style and loads settings from an INI file.

Parameters
[in]ini_fileThe INI file containing theme settings.

◆ NDEVRProxyStyle() [2/2]

NDEVRProxyStyle::NDEVRProxyStyle ( QStyle * style)

Constructs the proxy style wrapping an existing QStyle.

Parameters
[in]styleThe base QStyle to proxy.

References NDEVRProxyStyle().

Member Function Documentation

◆ baseTextScale()

fltp08 NDEVRProxyStyle::baseTextScale ( ) const

Returns the base text scaling factor.

Returns
The text scale as a double-precision value.

◆ baseUIScale()

fltp08 NDEVRProxyStyle::baseUIScale ( ) const
protected

Returns the base UI scaling factor.

Returns
The UI scale as a double-precision value.

◆ ColorThemeIcon()

StringView NDEVRProxyStyle::ColorThemeIcon ( NDEVRLightingTheme theme)
static

Returns the icon name associated with a given lighting theme.

Parameters
[in]themeThe lighting theme.
Returns
A StringView containing the icon name.

References theme().

◆ desktopFontScale()

fltp08 NDEVRProxyStyle::desktopFontScale ( )

Returns the desktop font scaling factor.

Returns
The font scale as a double-precision value.

◆ disabledColor()

RGBColor NDEVRProxyStyle::disabledColor ( NDEVRLightingTheme theme) const

Returns the disabled-state color for a given theme.

Parameters
[in]themeThe lighting theme to query.
Returns
The RGBColor used for disabled elements.

References theme().

◆ drawArrow()

void NDEVRProxyStyle::drawArrow ( Qt::ArrowType type,
QPainter * painter,
const QStyleOption * option,
const QRect & rect,
const QColor & color ) const

Draws an arrow indicator in the given direction.

Parameters
[in]typeThe arrow direction.
[in]painterThe painter to draw with.
[in]optionThe style options.
[in]rectThe bounding rectangle for the arrow.
[in]colorThe color of the arrow.

◆ drawComplexControl()

void NDEVRProxyStyle::drawComplexControl ( ComplexControl control,
const QStyleOptionComplex * option,
QPainter * painter,
const QWidget * widget = nullptr ) const
override

Draws a complex control such as a scroll bar or slider.

Parameters
[in]controlThe complex control type.
[in]optionThe style options for the complex control.
[in]painterThe painter to draw with.
[in]widgetOptional widget context.

◆ drawControl()

void NDEVRProxyStyle::drawControl ( ControlElement element,
const QStyleOption * opt,
QPainter * painter,
const QWidget * widget ) const
override

Draws a control element such as a button or label.

Parameters
[in]elementThe control element type.
[in]optThe style options.
[in]painterThe painter to draw with.
[in]widgetOptional widget context.

◆ drawItemPixmap()

virtual void NDEVRProxyStyle::drawItemPixmap ( QPainter * painter,
const QRect & rect,
int alignment,
const QPixmap & pixmap ) const
overridevirtual

Draws a pixmap within a styled context.

Parameters
[in]painterThe painter to draw with.
[in]rectThe bounding rectangle.
[in]alignmentThe alignment flags for the pixmap.
[in]pixmapThe pixmap to draw.

◆ drawItemText()

void NDEVRProxyStyle::drawItemText ( QPainter * painter,
const QRect & rect,
int flags,
const QPalette & pal,
bool enabled,
const QString & text,
QPalette::ColorRole textRole = QPalette::NoRole ) const
override

Draws text within a styled context.

Parameters
[in]painterThe painter to draw with.
[in]rectThe bounding rectangle for the text.
[in]flagsText alignment and formatting flags.
[in]palThe palette to use for text colors.
[in]enabledWhether the text should appear enabled.
[in]textThe text string to draw.
[in]textRoleThe palette color role for the text.

◆ drawPrimitive()

virtual void NDEVRProxyStyle::drawPrimitive ( PrimitiveElement pe,
const QStyleOption * opt,
QPainter * p,
const QWidget * w = nullptr ) const
overridevirtual

Draws a primitive style element with custom NDEVR rendering.

Parameters
[in]peThe primitive element to draw.
[in]optThe style options for the element.
[in]pThe painter to draw with.
[in]wOptional widget context.

◆ drawRoundedButtonBackground()

void NDEVRProxyStyle::drawRoundedButtonBackground ( const QStyleOption * opt,
QPainter * p,
int radius = Constant< int >::Max ) const
protected

Draws a rounded button background.

Parameters
[in]optThe style options for the button.
[in]pThe painter to draw with.
[in]radiusThe corner radius, defaults to maximum for fully rounded.

◆ fadeInAnimationTime()

TimeSpan NDEVRProxyStyle::fadeInAnimationTime ( ) const

Returns the duration of fade-in animations.

Returns
The animation duration as a TimeSpan.

◆ fadeOutAnimationTime()

TimeSpan NDEVRProxyStyle::fadeOutAnimationTime ( ) const

Returns the duration of fade-out animations.

Returns
The animation duration as a TimeSpan.

◆ getINI()

virtual void NDEVRProxyStyle::getINI ( INIFactory & factory)
overridevirtual

Serializes or deserializes theme settings through an INI factory.

Parameters
[in]factoryThe INI factory for reading or writing settings.

Implements INIInterface.

◆ GlobalStyle()

NDEVRProxyStyle * NDEVRProxyStyle::GlobalStyle ( )
static

Returns the singleton global style instance.

Returns
A pointer to the global NDEVRProxyStyle.

References NDEVRProxyStyle().

◆ interpolatedThemePalette()

QPalette NDEVRProxyStyle::interpolatedThemePalette ( NDEVRLightingTheme start,
NDEVRLightingTheme end,
fltp04 percent ) const

Returns a palette that interpolates between two themes.

Parameters
[in]startThe starting theme.
[in]endThe ending theme.
[in]percentThe interpolation percentage from 0.0 to 1.0.
Returns
The interpolated QPalette.

◆ isGlobalStyle()

bool NDEVRProxyStyle::isGlobalStyle ( ) const

Checks whether this instance is the global singleton style.

Returns
True if this is the global style.

◆ itemPixmapRect()

QRect NDEVRProxyStyle::itemPixmapRect ( const QRect & r,
int flags,
const QPixmap & pixmap ) const
override

Returns the bounding rectangle for an item pixmap.

Parameters
[in]rThe reference rectangle.
[in]flagsAlignment flags.
[in]pixmapThe pixmap to position.
Returns
The bounding rectangle for the pixmap.

◆ itemTextRect()

QRect NDEVRProxyStyle::itemTextRect ( const QFontMetrics & fm,
const QRect & r,
int flags,
bool enabled,
const QString & text ) const
override

Returns the bounding rectangle for item text.

Parameters
[in]fmThe font metrics to use.
[in]rThe reference rectangle.
[in]flagsText alignment and formatting flags.
[in]enabledWhether the item is enabled.
[in]textThe text to measure.
Returns
The bounding rectangle for the text.

◆ lightingThemeChangedSignal()

void NDEVRProxyStyle::lightingThemeChangedSignal ( NDEVRLightingTheme theme)

Emitted when the lighting theme changes.

Parameters
[in]themeThe new lighting theme.

References theme().

◆ oldTheme()

NDEVRLightingTheme NDEVRProxyStyle::oldTheme ( ) const

Returns the theme that was active before the most recent theme change.

Returns
The previous NDEVRLightingTheme.

◆ OriginalFont()

QFont NDEVRProxyStyle::OriginalFont ( )
static

Returns the original application font before any scaling is applied.

Returns
The original QFont.

◆ paletteAnimationTime()

TimeSpan NDEVRProxyStyle::paletteAnimationTime ( ) const

Returns the duration of palette transition animations.

Returns
The animation duration as a TimeSpan.

◆ pixelMetric()

int NDEVRProxyStyle::pixelMetric ( PixelMetric metric,
const QStyleOption * option = nullptr,
const QWidget * widget = nullptr ) const
override

Returns a pixel metric value scaled for the current UI settings.

Parameters
[in]metricThe pixel metric to query.
[in]optionOptional style option context.
[in]widgetOptional widget context.
Returns
The computed pixel metric value.

◆ polish()

void NDEVRProxyStyle::polish ( QWidget * widget)
override

Polishes a widget by applying NDEVR-specific style adjustments.

Parameters
[in]widgetThe widget to polish.

◆ resizeAnimationTime()

TimeSpan NDEVRProxyStyle::resizeAnimationTime ( ) const

Returns the duration of widget resize animations.

Returns
The animation duration as a TimeSpan.

◆ setLightingTheme()

void NDEVRProxyStyle::setLightingTheme ( NDEVRLightingTheme theme,
bool force_update = false,
bool save_settings = true )

Sets the active lighting theme immediately.

Parameters
[in]themeThe lighting theme to apply.
[in]force_updateIf true, forces a full UI refresh even if the theme has not changed.
[in]save_settingsIf true, persists the theme setting.

References theme().

◆ setLightingThemeAnimated() [1/2]

void NDEVRProxyStyle::setLightingThemeAnimated ( NDEVRLightingTheme start,
NDEVRLightingTheme end,
fltp04 percent )

Sets the lighting theme with an animated transition at a specific percentage.

Parameters
[in]startThe starting theme.
[in]endThe ending theme.
[in]percentThe interpolation percentage from 0.0 to 1.0.

◆ setLightingThemeAnimated() [2/2]

void NDEVRProxyStyle::setLightingThemeAnimated ( NDEVRLightingTheme theme)

Sets the lighting theme with an animated transition from the current theme.

Parameters
[in]themeThe target lighting theme.

References theme().

◆ setUseRoundedButtons()

void NDEVRProxyStyle::setUseRoundedButtons ( bool use_rounded_buttons)

Enables or disables rounded button rendering.

Parameters
[in]use_rounded_buttonsTrue to use rounded buttons, false for rectangular.

◆ sizeFromContents()

QSize NDEVRProxyStyle::sizeFromContents ( ContentsType type,
const QStyleOption * option,
const QSize & size,
const QWidget * widget ) const
override

Computes the size for a widget given its contents type.

Parameters
[in]typeThe contents type.
[in]optionThe style options.
[in]sizeThe proposed content size.
[in]widgetOptional widget context.
Returns
The computed size for the widget.

◆ standardIcon()

QIcon NDEVRProxyStyle::standardIcon ( StandardPixmap standardIcon,
const QStyleOption * option = nullptr,
const QWidget * widget = nullptr ) const
override

Returns the standard icon for a given pixmap type.

Parameters
[in]standardIconThe standard pixmap identifier.
[in]optionOptional style options.
[in]widgetOptional widget context.
Returns
The QIcon for the requested standard pixmap.

References standardIcon().

Referenced by standardIcon().

◆ standardPalette()

virtual QPalette NDEVRProxyStyle::standardPalette ( ) const
overridevirtual

Returns the standard palette for the current theme.

Returns
The QPalette representing the standard color scheme.

◆ styleHint()

int NDEVRProxyStyle::styleHint ( StyleHint stylehint,
const QStyleOption * opt = nullptr,
const QWidget * widget = nullptr,
QStyleHintReturn * returnData = nullptr ) const
override

Returns a style hint value for the given hint type.

Parameters
[in]stylehintThe style hint to query.
[in]optOptional style options.
[in]widgetOptional widget context.
[in]returnDataOptional return data for complex hints.
Returns
The integer style hint value.

◆ subControlRect()

QRect NDEVRProxyStyle::subControlRect ( ComplexControl cc,
const QStyleOptionComplex * opt,
SubControl sc,
const QWidget * widget ) const
override

Returns the sub-control rectangle for a complex control.

Parameters
[in]ccThe complex control type.
[in]optThe style options for the complex control.
[in]scThe sub-control to query.
[in]widgetOptional widget context.
Returns
The computed rectangle for the sub-control.

◆ subElementRect()

QRect NDEVRProxyStyle::subElementRect ( SubElement element,
const QStyleOption * option,
const QWidget * widget ) const
override

Returns the sub-element rectangle for a given element type.

Parameters
[in]elementThe sub-element type.
[in]optionThe style options.
[in]widgetOptional widget context.
Returns
The computed rectangle for the sub-element.

◆ theme()

NDEVRLightingTheme NDEVRProxyStyle::theme ( ) const
inline

Returns the currently active lighting theme.

Returns
The current NDEVRLightingTheme.

Definition at line 330 of file NDEVRTheme.h.

References m_theme.

Referenced by ColorThemeIcon(), disabledColor(), lightingThemeChangedSignal(), setLightingTheme(), setLightingThemeAnimated(), and themePalette().

◆ themePalette()

QPalette NDEVRProxyStyle::themePalette ( NDEVRLightingTheme theme) const

Returns the palette for a specific lighting theme.

Parameters
[in]themeThe lighting theme to retrieve the palette for.
Returns
The QPalette for the specified theme.

References theme().

◆ themeTransitionPercent()

fltp04 NDEVRProxyStyle::themeTransitionPercent ( )

Returns the current theme transition animation percentage.

Returns
The transition percentage from 0.0 to 1.0.

◆ usingRoundedButtons()

bool NDEVRProxyStyle::usingRoundedButtons ( ) const

Checks whether rounded buttons are currently enabled.

Returns
True if using rounded buttons.

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