SALOME style model. More...
#include <Style_Model.h>
Data Structures | |
| 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. | |
| virtual | ~Style_Model () |
| Destructor. | |
| void | fromApplication (bool=false) |
| Initialize model from the current application style. | |
| void | fromResources (QtxResourceMgr *, const QString &=QString()) |
| Initialize model from the resources. | |
| void | save (QtxResourceMgr *=0, const QString &=QString()) |
| Save SALOME stype properties to the resource file. | |
| void | update () |
| Reload SALOME style properties from the resources file(s). | |
| void | restore () |
| Restore original style, palette and font to the application. | |
| QtxResourceMgr * | resourceMgr () const |
| Get resource manager used by this SALOME style model. | |
| QString | resourceSection () const |
| Get resources section name. | |
| QColor | color (ColorRole, QPalette::ColorGroup=QPalette::Active) const |
| Get palette color value. | |
| void | setColor (ColorRole, const QColor &, const QColor &=QColor(), const QColor &=QColor()) |
| Set palette color value. | |
| void | setColor (ColorRole, QPalette::ColorGroup, const QColor &) |
| Set palette color value. | |
| bool | isAutoPalette () const |
| Returns 'auto-calculating color values' flag. | |
| void | setAutoPalette (bool) |
| Set/clear 'auto-calculating color values' flag. | |
| LineType | linesType () const |
| Get lines type. | |
| void | setLinesType (LineType) |
| Set lines type. | |
| int | linesTransparency () const |
| Get lines transparency value. | |
| void | setLinesTransparency (int) |
| Set lines transparency value. | |
| QFont | applicationFont () const |
| Get application font. | |
| void | setApplicationFont (const QFont &) |
| Set application font. | |
| double | widgetRounding (WidgetRounding) const |
| Get widget corners rounding radius value. | |
| void | setWidgetRounding (WidgetRounding, double) |
| Set widget corners rounding radius value. | |
| bool | antialiasing () const |
| Get anti-aliasing flag value. | |
| void | setAntialiasing (bool) |
| Set anti-aliasing flag value. | |
| WidgetEffect | widgetEffect () const |
| Get widget effect. | |
| void | setWidgetEffect (WidgetEffect) |
| Set widget effect. | |
| int | handleDelta (Qt::Orientation) const |
| Get handle spacing value. | |
| void | setHandleDelta (Qt::Orientation, int) |
| Set handle spacing value. | |
| int | splitHandleLength () const |
| Get splitter handle length. | |
| void | setSplitHandleLength (int) |
| Set splitted handle length. | |
| int | sliderSize () const |
| Get slider handle extra size. | |
| void | setSliderSize (int) |
| Set slider handle extra size. | |
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. | |
| void | readColorValue (ColorRole, const QString &) |
| Read palette color values from resources manager. | |
| void | writeColorValue (ColorRole, const QString &, QtxResourceMgr *, const QString &) const |
| Write palette color values to resources manager. | |
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. | |
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.
typedef QMap<ColorRole, QColor> Style_Model.ColorMap [private] |
typedef QMap<QPalette::ColorGroup, ColorMap> Style_Model.ColorGroupMap [private] |
typedef QMap<WidgetRounding, double> Style_Model.RoundMap [private] |
typedef QMap<Qt::Orientation, int> Style_Model.DeltaMap [private] |
| 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. |
| Style_Model::Style_Model | ( | ) |
Create new SALOME style model with default properties.
References initDefaults().
| Style_Model::~Style_Model | ( | ) | [virtual] |
| 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()
| 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() |
||
| ) |
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.
| void Style_Model::save | ( | QtxResourceMgr * | resMgr = 0, |
| const QString & | resSection = QString() |
||
| ) |
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::update | ( | ) |
References fromResources(), resourceMgr(), and resourceSection().
| 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.
References myAppData, Style_Model.AppData.myFont, Style_Model.AppData.myPalette, and Style_Model.AppData.myStyle.
| QtxResourceMgr * Style_Model::resourceMgr | ( | ) | const |
References myResourceMgr.
| QString Style_Model::resourceSection | ( | ) | const |
If section name is empty, default "Theme" is returned
References myResourceSection.
| QColor Style_Model::color | ( | ColorRole | role, |
| QPalette::ColorGroup | cg = QPalette::Active |
||
| ) | const |
| role | color role |
| cg | color group |
References test_table.c, and myColors.
| 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.
| 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, 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.
| role | color role |
| cg | color group |
| c | color which should be used to draw the corresponding part of the application |
References test_table.c, and myColors.
| bool Style_Model::isAutoPalette | ( | ) | const |
| void Style_Model::setAutoPalette | ( | bool | on | ) |
| on | new value of 'auto-calculating color values' flag |
References myAutoPalette.
| Style_Model::LineType Style_Model::linesType | ( | ) | const |
| void Style_Model::setLinesType | ( | LineType | lt | ) |
| int Style_Model::linesTransparency | ( | ) | const |
References myLinesTransparency.
| void Style_Model::setLinesTransparency | ( | int | transparency | ) |
| transparency | new lines transparency |
References myLinesTransparency.
| QFont Style_Model::applicationFont | ( | ) | const |
| void Style_Model::setApplicationFont | ( | const QFont & | font | ) |
| double Style_Model::widgetRounding | ( | Style_Model::WidgetRounding | wr | ) | const |
| wr | widget type |
References myWidgetRounding.
| void Style_Model::setWidgetRounding | ( | WidgetRounding | wr, |
| double | value | ||
| ) |
| wr | widget type |
| value | new widget corners rounding |
References myWidgetRounding.
| bool Style_Model::antialiasing | ( | ) | const |
true if widgets borders should be antialiased References myAntiAliasing.
| void Style_Model::setAntialiasing | ( | bool | value | ) |
| value | if true, widgets borders should be antialiased |
References myAntiAliasing.
| Style_Model::WidgetEffect Style_Model::widgetEffect | ( | ) | const |
| void Style_Model::setWidgetEffect | ( | WidgetEffect | we | ) |
| int Style_Model::handleDelta | ( | Qt::Orientation | o | ) | const |
| o | handle spacing direction |
References myHandleDelta.
| void Style_Model::setHandleDelta | ( | Qt::Orientation | o, |
| int | value | ||
| ) |
| o | handle spacing direction |
| value | new handle spacing value |
References myHandleDelta.
| int Style_Model::splitHandleLength | ( | ) | const |
References mySplitHandleLength.
| void Style_Model::setSplitHandleLength | ( | int | value | ) |
| value | new splitter handle length |
References mySplitHandleLength.
| int Style_Model::sliderSize | ( | ) | const |
| void Style_Model::setSliderSize | ( | int | value | ) |
| void Style_Model::initDefaults | ( | ) | [private] |
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.
| void Style_Model::readColorValue | ( | ColorRole | role, |
| const QString & | prefix | ||
| ) | [private] |
| role | color role |
| prefix | palette color value resource name prefix |
References resourceMgr(), resourceSection(), and setColor().
| void Style_Model::writeColorValue | ( | ColorRole | role, |
| const QString & | prefix, | ||
| QtxResourceMgr * | resMgr, | ||
| const QString & | resSection | ||
| ) | const [private] |
| role | color role |
| prefix | palette color value resource name prefix |
| resMgr | resource manager |
| resSection | resource section name |
References color(), and QtxResourceMgr.setValue().
QtxResourceMgr* Style_Model.myResourceMgr [private] |
QString Style_Model.myResourceSection [private] |
ColorGroupMap Style_Model.myColors [private] |
bool Style_Model.myAutoPalette [private] |
RoundMap Style_Model.myWidgetRounding [private] |
DeltaMap Style_Model.myHandleDelta [private] |
QFont Style_Model.myFont [private] |
LineType Style_Model.myLinesType [private] |
WidgetEffect Style_Model.myWidgetEffect [private] |
bool Style_Model.myAntiAliasing [private] |
int Style_Model.myLinesTransparency [private] |
int Style_Model.mySplitHandleLength [private] |
int Style_Model.mySliderSize [private] |
Style_Model::AppData * Style_Model::myAppData = 0 [static, private] |