Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Style_Model Class Reference

SALOME style model. More...

#include <Style_Model.h>

Classes

struct  AppData
 

Public Types

enum  ColorRole {
  WindowText = QPalette::WindowText, Button = QPalette::Button, Light = QPalette::Light, Midlight = QPalette::Midlight,
  Dark = QPalette::Dark, Mid = QPalette::Mid, Text = QPalette::Text, BrightText = QPalette::BrightText,
  ButtonText = QPalette::ButtonText, Base = QPalette::Base, Window = QPalette::Window, Shadow = QPalette::Shadow,
  Highlight = QPalette::Highlight, HighlightedText = QPalette::HighlightedText, Link = QPalette::Link, LinkVisited = QPalette::LinkVisited,
  AlternateBase = QPalette::AlternateBase, NoRole = QPalette::NoRole, ToolTipBase = QPalette::ToolTipBase, ToolTipText = QPalette::ToolTipText,
  NColorRoles = QPalette::NColorRoles, BorderTop = NColorRoles, BorderBottom, TabBorderTop,
  TabBorderBottom, FieldLight, FieldDark, Slider,
  Lines, HighlightWidget, HighlightBorder, Header,
  ProgressBar, Pointer, Checked, GridLine,
  LastColor
}
 Color palette instance enumeration. More...
 
enum  LineType { NoLines, Horizontal, Inclined }
 Lines type. More...
 
enum  WidgetRounding { ButtonRadius, EditRadius, FrameRadius, SliderRadius }
 
enum  WidgetEffect { NoEffect, HighlightEffect, AutoRaiseEffect }
 Widget effect. More...
 

Public Member Functions

 Style_Model ()
 Constructor. More...
 
virtual ~Style_Model ()
 Destructor. More...
 
void fromApplication (bool=false)
 Initialize model from the current application style. More...
 
void fromResources (QtxResourceMgr *, const QString &=QString())
 Initialize model from the resources. More...
 
void save (QtxResourceMgr *=0, const QString &=QString())
 Save SALOME stype properties to the resource file. More...
 
void update ()
 Reload SALOME style properties from the resources file(s). More...
 
void restore ()
 Restore original style, palette and font to the application. More...
 
QtxResourceMgrresourceMgr () const
 Get resource manager used by this SALOME style model. More...
 
QString resourceSection () const
 Get resources section name. More...
 
QColor color (ColorRole, QPalette::ColorGroup=QPalette::Active) const
 Get palette color value. More...
 
void setColor (ColorRole, const QColor &, const QColor &=QColor(), const QColor &=QColor())
 Set palette color value. More...
 
void setColor (ColorRole, QPalette::ColorGroup, const QColor &)
 Set palette color value. More...
 
bool isAutoPalette () const
 Returns 'auto-calculating color values' flag. More...
 
void setAutoPalette (bool)
 Set/clear 'auto-calculating color values' flag. More...
 
LineType linesType () const
 Get lines type. More...
 
void setLinesType (LineType)
 Set lines type. More...
 
int linesTransparency () const
 Get lines transparency value. More...
 
void setLinesTransparency (int)
 Set lines transparency value. More...
 
QFont applicationFont () const
 Get application font. More...
 
void setApplicationFont (const QFont &)
 Set application font. More...
 
double widgetRounding (WidgetRounding) const
 Get widget corners rounding radius value. More...
 
void setWidgetRounding (WidgetRounding, double)
 Set widget corners rounding radius value. More...
 
bool antialiasing () const
 Get anti-aliasing flag value. More...
 
void setAntialiasing (bool)
 Set anti-aliasing flag value. More...
 
WidgetEffect widgetEffect () const
 Get widget effect. More...
 
void setWidgetEffect (WidgetEffect)
 Set widget effect. More...
 
int handleDelta (Qt::Orientation) const
 Get handle spacing value. More...
 
void setHandleDelta (Qt::Orientation, int)
 Set handle spacing value. More...
 
int splitHandleLength () const
 Get splitter handle length. More...
 
void setSplitHandleLength (int)
 Set splitted handle length. More...
 
int sliderSize () const
 Get slider handle extra size. More...
 
void setSliderSize (int)
 Set slider handle extra size. More...
 

Private Types

typedef QMap< ColorRole, QColor > ColorMap
 
typedef QMap
< QPalette::ColorGroup,
ColorMap
ColorGroupMap
 
typedef QMap< WidgetRounding,
double > 
RoundMap
 
typedef QMap< Qt::Orientation,
int > 
DeltaMap
 

Private Member Functions

void initDefaults ()
 Initialize model with the default values. More...
 
void readColorValue (ColorRole, const QString &)
 Read palette color values from resources manager. More...
 
void writeColorValue (ColorRole, const QString &, QtxResourceMgr *, const QString &) const
 Write palette color values to resources manager. More...
 

Private Attributes

QtxResourceMgrmyResourceMgr
 
QString myResourceSection
 
ColorGroupMap myColors
 
bool myAutoPalette
 
RoundMap myWidgetRounding
 
DeltaMap myHandleDelta
 
QFont myFont
 
LineType myLinesType
 
WidgetEffect myWidgetEffect
 
bool myAntiAliasing
 
int myLinesTransparency
 
int mySplitHandleLength
 
int mySliderSize
 

Static Private Attributes

static AppDatamyAppData = 0
 Application style data. More...
 

Detailed Description

Style model class stores properties of the SALOME style, like palette colors, widget roundings etc. It allows reading these properties from the resource file and write them back to resource file.

SALOME_Style class provides an access to the global style model (which is applied to the application). To get access to the global SALOME style model, use static Style_Model::model() function.

See Also
Style_Salome class

Member Typedef Documentation

typedef QMap<QPalette::ColorGroup, ColorMap> Style_Model::ColorGroupMap
private
typedef QMap<ColorRole, QColor> Style_Model::ColorMap
private
typedef QMap<Qt::Orientation, int> Style_Model::DeltaMap
private
typedef QMap<WidgetRounding, double> Style_Model::RoundMap
private

Member Enumeration Documentation

Enumerator
WindowText 

A general foreground color.

Button 

The general button background color.

Light 

Usually lighter than Button color.

Midlight 

Usually between Button and Light.

Dark 

Usually darker than Button.

Mid 

Usualliy between Button and Dark.

Text 

The foreground color used with Base.

BrightText 

A text color that is very different from WindowText, and contrasts well with e.g. Dark.

ButtonText 

A foreground color used with the Button color.

Base 

Used mostly as the background color for text entry widgets.

Window 

A general background color.

Shadow 

Usually a very dark palette color.

Highlight 

A color to indicate a selected item or the current item.

HighlightedText 

A text color that contrasts with Highlight.

Link 

A text color used for unvisited hyperlinks.

LinkVisited 

A text color used for already visited hyperlinks.

AlternateBase 

Used as the alternate background color in views with alternating row colors.

NoRole 

No role; this special role is often used to indicate that a role has not been assigned.

ToolTipBase 

Used as the background color for QToolTip and QWhatsThis.

ToolTipText 

Used as the foreground color for QToolTip and QWhatsThis.

NColorRoles 

Used to indicate last standard palette color.

BorderTop 

Used to draw top-left borders of the widgets.

BorderBottom 

Used to draw bottom-right borders of the widgets.

TabBorderTop 

Used to draw top-left borders of the tab panels.

TabBorderBottom 

Used to draw bottom-right borders of the tab panels.

FieldLight 

Light component of the text entry widgets.

FieldDark 

Dark component of the text entry widgets.

Slider 

Used to draw sliders.

Lines 

Used to draw lines throughout all the widgets.

HighlightWidget 

Used to draw widget background when widget is hovered.

HighlightBorder 

Used to draw widget borders when widget is hovered.

Header 

Used to draw header of tab panels.

ProgressBar 

Main progress bar color.

Pointer 

Used to draw different widgets indicators like spin box arrows etc.

Checked 

Check box indicator color.

GridLine 

Used to draw table widgets grid.

LastColor 

Points to the last color; no specific meaning.

Enumerator
NoLines 

Do not draw lines.

Horizontal 

Draw horozontal lines.

Inclined 

Draw inclined lines.

Enumerator
NoEffect 

Do not use widget effects.

HighlightEffect 

Highlight widget when it is hovered.

AutoRaiseEffect 

Raise widget when it is hovered.

Enumerator
ButtonRadius 

Buttons rounding.

EditRadius 

Text entry widgets rounding.

FrameRadius 

Frames rounding.

SliderRadius 

Sliders rounding.

Constructor & Destructor Documentation

Style_Model::Style_Model ( )

Create new SALOME style model with default properties.

References initDefaults().

Style_Model::~Style_Model ( )
virtual

Member Function Documentation

bool Style_Model::antialiasing ( ) const
Returns
true if widgets borders should be antialiased
See Also
setAntialiasing(), widgetRounding()

References myAntiAliasing.

QFont Style_Model::applicationFont ( ) const
Returns
current application font
See Also
setApplicationFont()

References myFont.

QColor Style_Model::color ( ColorRole  role,
QPalette::ColorGroup  cg = QPalette::Active 
) const
Parameters
rolecolor role
cgcolor group
Returns
a color which should be used to draw the corresponding part of the application
See Also
setColor()

References myColors.

void Style_Model::fromApplication ( bool  reset = false)

This function is useful when it is necessary to set/remove SALOME style dynamically. Function fromApplication() saves current application properties (style, palette, font) which can be later restored with the restore() function.

The simplest way it can be done is using static functions of Style_Salome class: Style_Salome::apply(), Style_Salome::restore()

Parameters
resetif true model is also initializes preoperties from the application
See Also
restore(), fromResources()
Style_Salome class

References BorderBottom, BorderTop, Checked, FieldDark, FieldLight, GridLine, Header, HighlightBorder, HighlightWidget, initDefaults(), Style_Salome::isActive(), Lines, myAppData, myColors, myFont, Style_Model::AppData::myFont, Style_Model::AppData::myPalette, Style_Model::AppData::myStyle, NColorRoles, Pointer, ProgressBar, setColor(), Slider, TabBorderBottom, TabBorderTop, and WindowText.

void Style_Model::fromResources ( QtxResourceMgr resMgr,
const QString &  resSection = QString() 
)
int Style_Model::handleDelta ( Qt::Orientation  o) const
Parameters
ohandle spacing direction
Returns
current handle spacing value
See Also
setHandleDelta()

References myHandleDelta.

bool Style_Model::isAutoPalette ( ) const
Returns
'auto-calculating color values' flag
See Also
setAutoPalette()

References myAutoPalette.

int Style_Model::linesTransparency ( ) const
Returns
current lines transparency
See Also
setLinesTransparency(), linesType()

References myLinesTransparency.

Style_Model::LineType Style_Model::linesType ( ) const
Returns
current lines type
See Also
setLinesType(), linesTransparency()

References myLinesType.

void Style_Model::readColorValue ( ColorRole  role,
const QString &  prefix 
)
private
Parameters
rolecolor role
prefixpalette color value resource name prefix
See Also
writeColorValue()

References resourceMgr(), resourceSection(), and setColor().

QtxResourceMgr * Style_Model::resourceMgr ( ) const
Returns
pointer to the resource manager passed previously to the fromResources() method
See Also
initFromResources(), resourceSection()

References myResourceMgr.

QString Style_Model::resourceSection ( ) const

If section name is empty, default "Theme" is returned

Returns
resource section name passed previously to the fromResources() method
See Also
initFromResources(), resourceMgr()

References myResourceSection.

void Style_Model::restore ( )

This function should be used in conjunction with fromApplication() method. Sets initial style, color palette and font to the application. If SALOME style model has not been initialized from the application, this function does nothing.

See Also
fromApplication()

References myAppData, Style_Model::AppData::myFont, Style_Model::AppData::myPalette, and Style_Model::AppData::myStyle.

void Style_Model::setAntialiasing ( bool  value)
Parameters
valueif true, widgets borders should be antialiased
See Also
antialiasing(), widgetRounding()

References myAntiAliasing.

void Style_Model::setApplicationFont ( const QFont &  font)
Parameters
fontnew application font
See Also
applicationFont()

References myFont.

void Style_Model::setAutoPalette ( bool  on)
Parameters
onnew value of 'auto-calculating color values' flag
See Also
isAutoPalette()

References myAutoPalette.

void Style_Model::setColor ( Style_Model::ColorRole  role,
const QColor &  active,
const QColor &  inactive = QColor(),
const QColor &  disabled = QColor() 
)

If inactive and/or disabled colors are not specified, they are automatically calculated from active color.

Parameters
rolecolor role
activea color to be used with active color group (QPalette::Active)
inactivea color to be used with inactive color group (QPalette::Inactive)
disableda color to be used with disabled color group (QPalette::Disabled)
See Also
color()

References AlternateBase, Base, Button, ButtonText, color(), Light, Midlight, mixColors(), Text, and WindowText.

void Style_Model::setColor ( Style_Model::ColorRole  role,
QPalette::ColorGroup  cg,
const QColor &  c 
)

If inactive and/or disabled colors are not specified, they are automatically calculated from active color.

Parameters
rolecolor role
cgcolor group
ccolor which should be used to draw the corresponding part of the application
See Also
color()

References myColors.

void Style_Model::setHandleDelta ( Qt::Orientation  o,
int  value 
)
Parameters
ohandle spacing direction
valuenew handle spacing value
See Also
handleDelta()

References myHandleDelta.

void Style_Model::setLinesTransparency ( int  transparency)
Parameters
transparencynew lines transparency
See Also
linesTransparency(), linesType()

References myLinesTransparency.

void Style_Model::setLinesType ( LineType  lt)
Parameters
ltnew lines type
See Also
linesType(), linesTransparency()

References myLinesType.

void Style_Model::setSliderSize ( int  value)
Parameters
valuenew slider handle extra size
See Also
sliderSize()

References mySliderSize.

void Style_Model::setSplitHandleLength ( int  value)
Parameters
valuenew splitter handle length
See Also
splitHandleLength()

References mySplitHandleLength.

void Style_Model::setWidgetEffect ( WidgetEffect  we)
Parameters
wenew widget effect
See Also
widgetEffect()

References myWidgetEffect.

void Style_Model::setWidgetRounding ( WidgetRounding  wr,
double  value 
)
Parameters
wrwidget type
valuenew widget corners rounding
See Also
widgetRounding(), antialiasing()

References myWidgetRounding.

int Style_Model::sliderSize ( ) const
Returns
current slider handle extra size
See Also
setSliderSize()

References mySliderSize.

int Style_Model::splitHandleLength ( ) const
Returns
current splitter handle length
See Also
setSplitHandleLength()

References mySplitHandleLength.

void Style_Model::update ( )
Style_Model::WidgetEffect Style_Model::widgetEffect ( ) const
Returns
current widget effect
See Also
setWidgetEffect()

References myWidgetEffect.

double Style_Model::widgetRounding ( Style_Model::WidgetRounding  wr) const
Parameters
wrwidget type
Returns
current widget corners rounding
See Also
setWidgetRounding(), antialiasing()

References myWidgetRounding.

void Style_Model::writeColorValue ( ColorRole  role,
const QString &  prefix,
QtxResourceMgr resMgr,
const QString &  resSection 
) const
private
Parameters
rolecolor role
prefixpalette color value resource name prefix
resMgrresource manager
resSectionresource section name
See Also
readColorValue()

References color(), and QtxResourceMgr::setValue().

Member Data Documentation

bool Style_Model::myAntiAliasing
private
Style_Model::AppData * Style_Model::myAppData = 0
staticprivate
bool Style_Model::myAutoPalette
private
ColorGroupMap Style_Model::myColors
private
QFont Style_Model::myFont
private
DeltaMap Style_Model::myHandleDelta
private
int Style_Model::myLinesTransparency
private
LineType Style_Model::myLinesType
private
QtxResourceMgr* Style_Model::myResourceMgr
private
QString Style_Model::myResourceSection
private
int Style_Model::mySliderSize
private
int Style_Model::mySplitHandleLength
private
WidgetEffect Style_Model::myWidgetEffect
private
RoundMap Style_Model::myWidgetRounding
private

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