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... | |
| QtxResourceMgr * | resourceMgr () 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 | |
| QtxResourceMgr * | myResourceMgr |
| 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 AppData * | myAppData = 0 |
| Application style data. More... | |
SALOME style model.
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.
|
private |
|
private |
|
private |
|
private |
Color palette instance enumeration.
| Style_Model::Style_Model | ( | ) |
|
virtual |
Destructor.
| bool Style_Model::antialiasing | ( | ) | const |
Get anti-aliasing flag value.
true if widgets borders should be antialiased References myAntiAliasing.
| QFont Style_Model::applicationFont | ( | ) | const |
Get application font.
References myFont.
| QColor Style_Model::color | ( | ColorRole | role, |
| QPalette::ColorGroup | cg = QPalette::Active |
||
| ) | const |
Get palette color value.
| role | color role |
| cg | color group |
References myColors.
| void Style_Model::fromApplication | ( | bool | reset = false | ) |
Initialize model from the current application style.
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()
| reset | if true model is also initializes preoperties from the application |
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() |
||
| ) |
Initialize model from the resources.
This function can be used to retrieve SALOME style properties from the resource file(s). Note, that paremeters resMgr and resSection are stored by the model to be used later with save() method.
| resMgr | resources manager |
| resSection | resources section name; if empty (default), "Theme" section is used instead |
References AlternateBase, AutoRaiseEffect, Base, QtxResourceMgr::booleanValue(), BorderBottom, BorderTop, BrightText, Button, ButtonRadius, ButtonText, Checked, Dark, EditRadius, FieldDark, FieldLight, FrameRadius, fromApplication(), GridLine, Header, Highlight, HighlightBorder, HighlightedText, HighlightEffect, HighlightWidget, Horizontal, Inclined, QtxResourceMgr::integerValue(), Light, Lines, Link, LinkVisited, Mid, Midlight, myResourceMgr, myResourceSection, NoEffect, NoLines, Pointer, ProgressBar, readColorValue(), resourceMgr(), resourceSection(), setAntialiasing(), setApplicationFont(), setAutoPalette(), setHandleDelta(), setLinesTransparency(), setLinesType(), setSliderSize(), setSplitHandleLength(), setWidgetEffect(), setWidgetRounding(), Shadow, Slider, SliderRadius, TabBorderBottom, TabBorderTop, Text, ToolTipBase, ToolTipText, Vertical, Window, and WindowText.
| int Style_Model::handleDelta | ( | Qt::Orientation | o | ) | const |
Get handle spacing value.
| o | handle spacing direction |
References myHandleDelta.
|
private |
Initialize model with the default values.
References AlternateBase, Base, BorderBottom, BorderTop, BrightText, Button, ButtonRadius, ButtonText, Checked, Dark, EditRadius, FieldDark, FieldLight, FrameRadius, GridLine, Header, Highlight, HighlightBorder, HighlightedText, HighlightWidget, Horizontal, Light, Lines, Link, LinkVisited, Mid, Midlight, mixColors(), myAntiAliasing, myAutoPalette, myFont, myHandleDelta, myLinesTransparency, myLinesType, mySliderSize, mySplitHandleLength, myWidgetEffect, myWidgetRounding, NoEffect, NoLines, Pointer, ProgressBar, setColor(), Shadow, Slider, SliderRadius, TabBorderBottom, TabBorderTop, Text, ToolTipBase, ToolTipText, Vertical, Window, and WindowText.
| bool Style_Model::isAutoPalette | ( | ) | const |
Returns 'auto-calculating color values' flag.
References myAutoPalette.
| int Style_Model::linesTransparency | ( | ) | const |
Get lines transparency value.
References myLinesTransparency.
| Style_Model::LineType Style_Model::linesType | ( | ) | const |
Get lines type.
References myLinesType.
|
private |
Read palette color values from resources manager.
| role | color role |
| prefix | palette color value resource name prefix |
References resourceMgr(), resourceSection(), and setColor().
| QtxResourceMgr * Style_Model::resourceMgr | ( | ) | const |
Get resource manager used by this SALOME style model.
References myResourceMgr.
| QString Style_Model::resourceSection | ( | ) | const |
Get resources section name.
If section name is empty, default "Theme" is returned
References myResourceSection.
| void Style_Model::restore | ( | ) |
Restore original style, palette and font to the application.
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.
References myAppData, Style_Model::AppData::myFont, Style_Model::AppData::myPalette, and Style_Model::AppData::myStyle.
| void Style_Model::save | ( | QtxResourceMgr * | resMgr = 0, |
| const QString & | resSection = QString() |
||
| ) |
Save SALOME stype properties to the resource file.
If paremeters resMgr and resSection are not specified, default ones (those passed to the fromResources() function) are used instead.
| resMgr | resources manager |
| resSection | resources section name |
References AlternateBase, antialiasing(), applicationFont(), Base, BorderBottom, BorderTop, BrightText, Button, ButtonRadius, ButtonText, Checked, Dark, EditRadius, FieldDark, FieldLight, FrameRadius, GridLine, handleDelta(), Header, Highlight, HighlightBorder, HighlightedText, HighlightWidget, Horizontal, isAutoPalette(), Light, Lines, linesTransparency(), linesType(), Link, LinkVisited, Mid, Midlight, Pointer, ProgressBar, resourceMgr(), resourceSection(), QtxResourceMgr::setValue(), Shadow, Slider, SliderRadius, sliderSize(), splitHandleLength(), TabBorderBottom, TabBorderTop, Text, ToolTipBase, ToolTipText, Vertical, widgetEffect(), widgetRounding(), Window, WindowText, and writeColorValue().
| void Style_Model::setAntialiasing | ( | bool | value | ) |
Set anti-aliasing flag value.
| value | if true, widgets borders should be antialiased |
References myAntiAliasing.
| void Style_Model::setApplicationFont | ( | const QFont & | font | ) |
Set application font.
| font | new application font |
References myFont.
| void Style_Model::setAutoPalette | ( | bool | on | ) |
Set/clear 'auto-calculating color values' flag.
| on | new value of 'auto-calculating color values' flag |
References myAutoPalette.
| void Style_Model::setColor | ( | Style_Model::ColorRole | role, |
| const QColor & | active, | ||
| const QColor & | inactive = QColor(), |
||
| const QColor & | disabled = QColor() |
||
| ) |
Set palette color value.
If inactive and/or disabled colors are not specified, they are automatically calculated from active color.
| role | color role |
| active | a color to be used with active color group (QPalette::Active) |
| inactive | a color to be used with inactive color group (QPalette::Inactive) |
| disabled | a color to be used with disabled color group (QPalette::Disabled) |
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 | ||
| ) |
| void Style_Model::setHandleDelta | ( | Qt::Orientation | o, |
| int | value | ||
| ) |
Set handle spacing value.
| o | handle spacing direction |
| value | new handle spacing value |
References myHandleDelta.
| void Style_Model::setLinesTransparency | ( | int | transparency | ) |
Set lines transparency value.
| transparency | new lines transparency |
References myLinesTransparency.
| void Style_Model::setLinesType | ( | LineType | lt | ) |
Set lines type.
| lt | new lines type |
References myLinesType.
| void Style_Model::setSliderSize | ( | int | value | ) |
Set slider handle extra size.
| value | new slider handle extra size |
References mySliderSize.
| void Style_Model::setSplitHandleLength | ( | int | value | ) |
Set splitted handle length.
| value | new splitter handle length |
References mySplitHandleLength.
| void Style_Model::setWidgetEffect | ( | WidgetEffect | we | ) |
| void Style_Model::setWidgetRounding | ( | WidgetRounding | wr, |
| double | value | ||
| ) |
Set widget corners rounding radius value.
| wr | widget type |
| value | new widget corners rounding |
References myWidgetRounding.
| int Style_Model::sliderSize | ( | ) | const |
Get slider handle extra size.
References mySliderSize.
| int Style_Model::splitHandleLength | ( | ) | const |
Get splitter handle length.
References mySplitHandleLength.
| void Style_Model::update | ( | ) |
Reload SALOME style properties from the resources file(s).
References fromResources(), resourceMgr(), and resourceSection().
| Style_Model::WidgetEffect Style_Model::widgetEffect | ( | ) | const |
Get widget effect.
References myWidgetEffect.
| double Style_Model::widgetRounding | ( | Style_Model::WidgetRounding | wr | ) | const |
Get widget corners rounding radius value.
| wr | widget type |
References myWidgetRounding.
|
private |
Write palette color values to resources manager.
| role | color role |
| prefix | palette color value resource name prefix |
| resMgr | resource manager |
| resSection | resource section name |
References color(), and QtxResourceMgr::setValue().
|
private |
|
staticprivate |
Application style data.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |