1 // Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : Style_Model.cxx
21 // Author : Vadim SANDLER, Open CASCADE S.A.S (vadim.sandler@opencascade.com)
23 #include "Style_Model.h"
24 #include "Style_Salome.h"
26 #include <QtxResourceMgr.h>
28 #include <QApplication>
34 \brief Mix two colors to get color with averaged red, green, blue and alpha-channel values
37 \param c2 second color
38 \return averaged color
40 static QColor mixColors( const QColor& c1, const QColor& c2 )
42 return QColor( (c1.red() + c2.red() ) / 2,
43 (c1.green() + c2.green() ) / 2,
44 (c1.blue() + c2.blue() ) / 2,
45 (c1.alpha() + c2.alpha() ) / 2 );
50 \brief SALOME style model
52 Style model class stores properties of the SALOME style, like palette colors,
53 widget roundings etc. It allows reading these properties from the resource file
54 and write them back to resource file.
56 SALOME_Style class provides an access to the global style model (which is applied
57 to the application). To get access to the global SALOME style model, use static
58 Style_Model::model() function.
60 \sa Style_Salome class
64 \brief Application style data
67 Style_Model::AppData* Style_Model::myAppData = 0;
72 Create new SALOME style model with default properties.
74 Style_Model::Style_Model()
77 initDefaults(); // init from default values
83 Style_Model::~Style_Model()
88 \brief Initialize model from the current application style
90 This function is useful when it is necessary to set/remove SALOME style
91 dynamically. Function fromApplication() saves current application properties
92 (style, palette, font) which can be later restored with the restore() function.
94 The simplest way it can be done is using static functions of Style_Salome class:
95 Style_Salome::apply(), Style_Salome::restore()
97 \param reset if \c true model is also initializes preoperties from the application
98 \sa restore(), fromResources()
99 \sa Style_Salome class
101 void Style_Model::fromApplication( bool reset )
105 if ( !QApplication::instance() ) // application object is not created yet
108 if ( !myAppData ) // if not yes initialized from the application init myAppData
109 myAppData = new AppData;
111 // store original application's style, palette, etc
112 if ( !Style_Salome::isActive() ) {
113 myAppData->myStyle = QApplication::style();
114 myAppData->myPalette = QApplication::palette();
115 myAppData->myFont = QApplication::font();
118 // initialize style properties from the application
120 if ( !reset ) return;
123 myFont = myAppData->myFont;
125 for ( int i = (int)QPalette::Active; i <= (int)QPalette::Inactive; i++ ) {
126 for ( int j = (int)Style_Model::WindowText; j < (int)Style_Model::NColorRoles; j++ ) {
127 myColors[ (QPalette::ColorGroup)i ][ (Style_Model::ColorRole)j ] =
128 myAppData->myPalette.color( (QPalette::ColorGroup)i, (QPalette::ColorRole)j );
132 QColor dark = myAppData->myPalette.color( QPalette::Dark );
133 setColor( BorderTop, dark.lighter() );
134 setColor( BorderBottom, dark.darker() );
135 setColor( TabBorderTop, dark.lighter().lighter() );
136 setColor( TabBorderBottom, dark.darker().darker() );
137 setColor( FieldLight, myAppData->myPalette.color( QPalette::Light ) );
138 setColor( FieldDark, myAppData->myPalette.color( QPalette::Mid ).light( 125 ) );
139 setColor( ProgressBar, myAppData->myPalette.color( QPalette::Highlight ) );
140 setColor( Pointer, myAppData->myPalette.color( QPalette::WindowText ) );
141 setColor( Checked, myAppData->myPalette.color( QPalette::Base ) );
142 setColor( GridLine, myAppData->myPalette.color( QPalette::Mid ) );
143 setColor( Header, myAppData->myPalette.color( QPalette::Button ) );
144 setColor( Slider, myAppData->myPalette.color( QPalette::Button ) );
145 setColor( HighlightWidget, myAppData->myPalette.color( QPalette::Button ) );
146 setColor( HighlightBorder, myAppData->myPalette.color( QPalette::Button ) );
147 setColor( Lines, myAppData->myPalette.color( QPalette::Mid ) );
151 \brief Initialize model from the resources
153 This function can be used to retrieve SALOME style properties from the resource file(s).
154 Note, that paremeters \a resMgr and \a resSection are stored by the model to be used
155 later with save() method.
157 \param resMgr resources manager
158 \param resSection resources section name; if empty (default), "Theme" section is used instead
159 \sa fromApplication(), save(), update()
161 void Style_Model::fromResources( QtxResourceMgr* resMgr, const QString& resSection )
163 // init from application
164 fromApplication( false );
166 myResourceMgr = resMgr;
167 myResourceSection = resSection;
169 // init from resource manager
170 if ( !resourceMgr() )
173 QString section = resourceSection();
177 readColorValue( Button, "button" );
179 readColorValue( WindowText, "window-text" );
181 readColorValue( Light, "light" );
183 readColorValue( Dark, "dark" );
185 readColorValue( Mid, "mid" );
187 readColorValue( Text, "text" );
189 readColorValue( BrightText, "bright-text" );
191 readColorValue( ButtonText, "button-text" );
193 readColorValue( Base, "base" );
195 readColorValue( Window, "window" );
197 readColorValue( AlternateBase, "alternate-base" );
199 readColorValue( Midlight, "midlight" );
201 readColorValue( Shadow, "shadow" );
203 readColorValue( Highlight, "highlight" );
205 readColorValue( HighlightedText, "highlight-text" );
207 readColorValue( Link, "link" );
209 readColorValue( LinkVisited, "link-visited" );
211 readColorValue( ToolTipBase, "tooltip-base" );
213 readColorValue( ToolTipText, "tooltip-text" );
215 readColorValue( BorderTop, "border-top" );
217 readColorValue( BorderBottom, "border-bottom" );
219 readColorValue( TabBorderTop, "tab-border-top" );
221 readColorValue( TabBorderBottom, "tab-border-bottom" );
223 readColorValue( FieldLight, "field-light" );
225 readColorValue( FieldDark, "field-dark" );
227 readColorValue( ProgressBar, "progress-bar" );
229 readColorValue( Pointer, "pointer" );
231 readColorValue( Checked, "checked" );
233 readColorValue( GridLine, "grid-line" );
235 readColorValue( Header, "header" );
237 readColorValue( Slider, "slider" );
239 readColorValue( HighlightWidget, "highlight-widget" );
241 readColorValue( HighlightBorder, "highlight-border" );
243 readColorValue( Lines, "lines" );
244 // auto-palette flag (internal)
245 if ( resourceMgr()->hasValue( section, "auto-palette" ) ) {
246 setAutoPalette( resourceMgr()->booleanValue( section, "auto-palette" ) );
249 if ( resourceMgr()->hasValue( section, "lines-type" ) ) {
250 int ltype = resourceMgr()->integerValue( section, "lines-type" );
251 if ( ltype >= NoLines && ltype <= Inclined )
252 setLinesType( (LineType)ltype );
254 // lines transparency
255 if ( resourceMgr()->hasValue( section, "lines-transparency" ) ) {
256 int ltransp = resourceMgr()->integerValue( section, "lines-transparency" );
257 if ( ltransp >= 0 && ltransp <= 100 )
258 setLinesTransparency( ltransp );
261 if ( resourceMgr()->hasValue( section, "application-font" ) ) {
262 setApplicationFont( resourceMgr()->fontValue( section, "application-font" ) );
265 if ( resourceMgr()->hasValue( section, "button-rad" ) ) {
266 setWidgetRounding( ButtonRadius, resourceMgr()->doubleValue( section, "button-rad" ) );
268 if ( resourceMgr()->hasValue( section, "edit-rad" ) ) {
269 setWidgetRounding( EditRadius, resourceMgr()->doubleValue( section, "edit-rad" ) );
271 if ( resourceMgr()->hasValue( section, "frame-rad" ) ) {
272 setWidgetRounding( FrameRadius, resourceMgr()->doubleValue( section, "frame-rad" ) );
274 if ( resourceMgr()->hasValue( section, "slider-rad" ) ) {
275 setWidgetRounding( SliderRadius, resourceMgr()->doubleValue( section, "slider-rad" ) );
278 if ( resourceMgr()->hasValue( section, "widget-effect" ) ) {
279 int effect = resourceMgr()->integerValue( section, "widget-effect" );
280 if ( effect >= NoEffect && effect <= AutoRaiseEffect )
281 setWidgetEffect( (WidgetEffect)effect );
283 else if ( resourceMgr()->hasValue( section, "is-highlight-widget" ) ||
284 resourceMgr()->hasValue( section, "is-raising-widget" ) ) {
285 bool highlight = resourceMgr()->booleanValue( section, "is-highlight-widget", false );
286 bool autoraise = resourceMgr()->booleanValue( section, "is-highlight-widget", false );
288 setWidgetEffect( HighlightEffect );
289 else if ( autoraise )
290 setWidgetEffect( AutoRaiseEffect );
292 if ( resourceMgr()->hasValue( section, "all-antialized" ) ) {
293 setAntialiasing( resourceMgr()->booleanValue( section, "all-antialized" ) );
296 if ( resourceMgr()->hasValue( section, "hor-hadle-delta" ) ) {
297 setHandleDelta( Qt::Horizontal, resourceMgr()->integerValue( section, "hor-hadle-delta" ) );
299 if ( resourceMgr()->hasValue( section, "ver-hadle-delta" ) ) {
300 setHandleDelta( Qt::Vertical, resourceMgr()->integerValue( section, "vsr-hadle-delta" ) );
302 if ( resourceMgr()->hasValue( section, "slider-size" ) ) {
303 setSliderSize( resourceMgr()->integerValue( section, "slider-size" ) );
305 else if ( resourceMgr()->hasValue( section, "slider-increase" ) ) {
306 setSliderSize( resourceMgr()->integerValue( section, "slider-increase" ) );
308 if ( resourceMgr()->hasValue( section, "split-handle-len" ) ) {
309 setSplitHandleLength( resourceMgr()->integerValue( section, "split-handle-len" ) );
314 \brief Save SALOME stype properties to the resource file.
316 If paremeters \a resMgr and \a resSection are not specified, default ones
317 (those passed to the fromResources() function) are used instead.
319 \param resMgr resources manager
320 \param resSection resources section name
321 \sa fromResources(), update()
323 void Style_Model::save( QtxResourceMgr* resMgr, const QString& resSection )
326 resMgr = resourceMgr();
330 QString section = resSection.isEmpty() ? resourceSection() : resSection;
334 writeColorValue( Button, "button", resMgr, section );
336 writeColorValue( WindowText, "window-text", resMgr, section );
338 writeColorValue( Light, "light", resMgr, section );
340 writeColorValue( Dark, "dark", resMgr, section );
342 writeColorValue( Mid, "mid", resMgr, section );
344 writeColorValue( Text, "text", resMgr, section );
346 writeColorValue( BrightText, "bright-text", resMgr, section );
348 writeColorValue( ButtonText, "button-text", resMgr, section );
350 writeColorValue( Base, "base", resMgr, section );
352 writeColorValue( Window, "window", resMgr, section );
354 writeColorValue( AlternateBase, "alternate-base", resMgr, section );
356 writeColorValue( Midlight, "midlight", resMgr, section );
358 writeColorValue( Shadow, "shadow", resMgr, section );
360 writeColorValue( Highlight, "highlight", resMgr, section );
362 writeColorValue( HighlightedText, "highlight-text", resMgr, section );
364 writeColorValue( Link, "link", resMgr, section );
366 writeColorValue( LinkVisited, "link-visited", resMgr, section );
368 writeColorValue( ToolTipBase, "tooltip-base", resMgr, section );
370 writeColorValue( ToolTipText, "tooltip-text", resMgr, section );
372 writeColorValue( BorderTop, "border-top", resMgr, section );
374 writeColorValue( BorderBottom, "border-bottom", resMgr, section );
376 writeColorValue( TabBorderTop, "tab-border-top", resMgr, section );
378 writeColorValue( TabBorderBottom, "tab-border-bottom", resMgr, section );
380 writeColorValue( FieldLight, "field-light", resMgr, section );
382 writeColorValue( FieldDark, "field-dark", resMgr, section );
384 writeColorValue( ProgressBar, "progress-bar", resMgr, section );
386 writeColorValue( Pointer, "pointer", resMgr, section );
388 writeColorValue( Checked, "checked", resMgr, section );
390 writeColorValue( GridLine, "grid-line", resMgr, section );
392 writeColorValue( Header, "header", resMgr, section );
394 writeColorValue( Slider, "slider", resMgr, section );
396 writeColorValue( HighlightWidget, "highlight-widget", resMgr, section );
398 writeColorValue( HighlightBorder, "highlight-border", resMgr, section );
400 writeColorValue( Lines, "lines", resMgr, section );
401 // auto-palette flag (internal)
402 resMgr->setValue( section, "auto-palette", isAutoPalette() );
405 resMgr->setValue( section, "lines-type", (int)linesType() );
406 // lines transparency
407 resMgr->setValue( section, "lines-transparency", linesTransparency() );
409 resMgr->setValue( section, "application-font", applicationFont() );
411 resMgr->setValue( section, "button-rad", widgetRounding( ButtonRadius ) );
412 resMgr->setValue( section, "edit-rad", widgetRounding( EditRadius ) );
413 resMgr->setValue( section, "frame-rad", widgetRounding( FrameRadius ) );
414 resMgr->setValue( section, "slider-rad", widgetRounding( SliderRadius ) );
415 resMgr->setValue( section, "all-antialized", antialiasing() );
417 resMgr->setValue( section, "widget-effect", (int)widgetEffect() );
419 resMgr->setValue( section, "hor-hadle-delta", handleDelta( Qt::Horizontal ) );
420 resMgr->setValue( section, "vsr-hadle-delta", handleDelta( Qt::Vertical ) );
421 resMgr->setValue( section, "slider-size", sliderSize() );
422 resMgr->setValue( section, "split-handle-len", splitHandleLength() );
426 \brief Reload SALOME style properties from the resources file(s).
427 \sa fromResources(), save()
429 void Style_Model::update()
431 fromResources( resourceMgr(), resourceSection() );
435 \brief Restore original style, palette and font to the application
437 This function should be used in conjunction with fromApplication() method.
438 Sets initial style, color palette and font to the application.
439 If SALOME style model has not been initialized from the application,
440 this function does nothing.
442 \sa fromApplication()
444 void Style_Model::restore()
446 if ( !QApplication::instance() ) // application object is not created yet
448 if ( !myAppData ) // not initialized from the application yet
451 QApplication::setStyle( myAppData->myStyle );
452 QApplication::setPalette( myAppData->myPalette );
453 QApplication::setFont( myAppData->myFont );
457 \brief Get resource manager used by this SALOME style model.
459 \return pointer to the resource manager passed previously to the fromResources() method
460 \sa initFromResources(), resourceSection()
462 QtxResourceMgr* Style_Model::resourceMgr() const
464 return myResourceMgr;
468 \brief Get resources section name
470 If section name is empty, default "Theme" is returned
472 \return resource section name passed previously to the fromResources() method
473 \sa initFromResources(), resourceMgr()
475 QString Style_Model::resourceSection() const
477 return !myResourceSection.isEmpty() ? myResourceSection : "Theme";
481 \brief Get palette color value
482 \param role color role
483 \param cg color group
484 \return a color which should be used to draw the corresponding part of the application
487 QColor Style_Model::color( ColorRole role, QPalette::ColorGroup cg ) const
489 QColor c = myColors[ cg ][ role ];
490 if ( !c.isValid() ) c = myColors[ QPalette::Active ][ role ];
495 \brief Set palette color value
497 If \a inactive and/or \a disabled colors are not specified, they are automatically
498 calculated from \a active color.
500 \param role color role
501 \param active a color to be used with active color group (QPalette::Active)
502 \param inactive a color to be used with inactive color group (QPalette::Inactive)
503 \param disabled a color to be used with disabled color group (QPalette::Disabled)
506 void Style_Model::setColor( Style_Model::ColorRole role, const QColor& active,
507 const QColor& inactive, const QColor& disabled )
509 QColor ac = active, ic = inactive, dc = disabled;
511 if ( !ic.isValid() ) {
514 if ( !dc.isValid() ) {
519 dc = color( Button ).darker();
522 dc = color( Button );
525 dc = mixColors( color( Base, QPalette::Inactive ), color( Button, QPalette::Inactive ) );
528 dc = mixColors( color( Light, QPalette::Inactive ), color( Button, QPalette::Inactive ) );
536 setColor( role, QPalette::Active, ac );
537 setColor( role, QPalette::Inactive, ic );
538 setColor( role, QPalette::Disabled, dc );
542 \brief Set palette color value
544 If \a inactive and/or \a disabled colors are not specified, they are automatically
545 calculated from \a active color.
547 \param role color role
548 \param cg color group
549 \param c color which should be used to draw the corresponding part of the application
552 void Style_Model::setColor( Style_Model::ColorRole role, QPalette::ColorGroup cg, const QColor& c )
554 myColors[ cg ][ role ] = c;
558 \brief Returns 'auto-calculating color values' flag
559 \return 'auto-calculating color values' flag
563 bool Style_Model::isAutoPalette() const
565 return myAutoPalette;
569 \brief Set/clear 'auto-calculating color values' flag
570 \param on new value of 'auto-calculating color values' flag
574 void Style_Model::setAutoPalette( bool on )
580 \brief Get lines type
581 \return current lines type
582 \sa setLinesType(), linesTransparency()
584 Style_Model::LineType Style_Model::linesType() const
590 \brief Set lines type
591 \param lt new lines type
592 \sa linesType(), linesTransparency()
594 void Style_Model::setLinesType( LineType lt )
600 \brief Get lines transparency value
601 \return current lines transparency
602 \sa setLinesTransparency(), linesType()
604 int Style_Model::linesTransparency() const
606 return myLinesTransparency;
610 \brief Set lines transparency value
611 \param transparency new lines transparency
612 \sa linesTransparency(), linesType()
614 void Style_Model::setLinesTransparency( int transparency )
616 myLinesTransparency = transparency;
620 \brief Get application font
621 \return current application font
622 \sa setApplicationFont()
624 QFont Style_Model::applicationFont() const
630 \brief Set application font
631 \param font new application font
632 \sa applicationFont()
634 void Style_Model::setApplicationFont( const QFont& font )
640 \brief Get widget corners rounding radius value
641 \param wr widget type
642 \return current widget corners rounding
643 \sa setWidgetRounding(), antialiasing()
645 double Style_Model::widgetRounding( Style_Model::WidgetRounding wr ) const
647 return myWidgetRounding[ wr ];
651 \brief Set widget corners rounding radius value
652 \param wr widget type
653 \param value new widget corners rounding
654 \sa widgetRounding(), antialiasing()
656 void Style_Model::setWidgetRounding( WidgetRounding wr, double value )
658 myWidgetRounding[ wr ] = value;
662 \brief Get anti-aliasing flag value
663 \return \c true if widgets borders should be antialiased
664 \sa setAntialiasing(), widgetRounding()
666 bool Style_Model::antialiasing() const
668 return myAntiAliasing;
672 \brief Set anti-aliasing flag value
673 \param value if \c true, widgets borders should be antialiased
674 \sa antialiasing(), widgetRounding()
676 void Style_Model::setAntialiasing( bool value )
678 myAntiAliasing = value;
682 \brief Get widget effect
683 \return current widget effect
684 \sa setWidgetEffect()
686 Style_Model::WidgetEffect Style_Model::widgetEffect() const
688 return myWidgetEffect;
692 \brief Set widget effect
693 \param we new widget effect
696 void Style_Model::setWidgetEffect( WidgetEffect we )
702 \brief Get handle spacing value
703 \param o handle spacing direction
704 \return current handle spacing value
707 int Style_Model::handleDelta( Qt::Orientation o ) const
709 return myHandleDelta[ o ];
713 \brief Set handle spacing value
714 \param o handle spacing direction
715 \param value new handle spacing value
718 void Style_Model::setHandleDelta( Qt::Orientation o, int value )
720 myHandleDelta[ o ] = value;
724 \brief Get splitter handle length
725 \return current splitter handle length
726 \sa setSplitHandleLength()
728 int Style_Model::splitHandleLength() const
730 return mySplitHandleLength;
734 \brief Set splitted handle length
735 \param value new splitter handle length
736 \sa splitHandleLength()
738 void Style_Model::setSplitHandleLength( int value )
740 mySplitHandleLength = value;
744 \brief Get slider handle extra size
745 \return current slider handle extra size
748 int Style_Model::sliderSize() const
754 \brief Set slider handle extra size
755 \param value new slider handle extra size
758 void Style_Model::setSliderSize( int value )
760 mySliderSize = value;
764 \brief Initialize model with the default values
766 void Style_Model::initDefaults()
768 // default application font
769 myFont.fromString( "Sans Serif,9,-1,5,50,0,0,0,0,0" );
771 // default palette colors
772 myAutoPalette = false;
773 QColor btn = QColor( "#e6e7e6" );
774 QColor fg = QColor( "#000000" );
775 QColor bg = QColor( "#ffffff" );
776 setColor( Button, btn ); // = (230, 231, 230)
777 setColor( WindowText, fg ); // = ( 0, 0, 0)
778 setColor( Light, bg ); // = (255, 255, 255)
779 setColor( Dark, btn.darker() ); // = (115, 115, 115) // btn.darker( 130 ) = (177, 178, 177)
780 setColor( Mid, btn.darker( 150 ) ); // = (153, 154, 153)
781 setColor( Text, fg ); // = ( 0, 0, 0)
782 setColor( BrightText, bg ); // = (255, 255, 255) // fg = ( 0, 0, 0)
783 setColor( ButtonText, fg ); // = ( 0, 0, 0)
784 setColor( Base, bg ); // = (255, 255, 255)
785 setColor( Window, btn ); // = (230, 231, 230)
786 setColor( AlternateBase, mixColors( bg, btn ) ); // = (242, 243, 242)
787 setColor( Midlight, mixColors( bg, btn ) ); // = (242, 243, 242)
788 setColor( Shadow, fg ); // = ( 0, 0, 0)
789 setColor( Highlight, "#000080" ); // = ( 0, 0, 128) // ( 33, 68, 156 )
790 setColor( HighlightedText, bg ); // = (255, 255, 255)
791 setColor( Link, "#0000ff" ); // = ( 0, 0, 255)
792 setColor( LinkVisited, "#ff00ff" ); // = (255, 0, 255)
793 setColor( ToolTipBase, "#ffffdc" ); // = (255, 255, 220) // ( 230, 231, 230 )
794 setColor( ToolTipText, fg ); // = ( 0, 0, 0)
795 setColor( BorderTop, "#adadad" ); // = (173, 173, 173) // ( 255, 255, 255 )
796 setColor( BorderBottom, "#393939" ); // = ( 57, 57, 57) // ( 88, 89, 88 )
797 setColor( TabBorderTop, "#ffffff" ); // = (255, 255, 255)
798 setColor( TabBorderBottom, "#0e0e0e" ); // = ( 14, 14, 14) // ( 44, 44, 44 )
799 setColor( FieldLight, "#ffffff" ); // = (255, 255, 255)
800 setColor( FieldDark, "#c0c1c0" ); // = (192, 193, 192) // ( 240, 241, 240 )
801 setColor( ProgressBar, "#000080" ); // = ( 0, 0, 128) // ( 33, 68, 156 )
802 setColor( Pointer, "#000000" ); // = ( 0, 0, 0)
803 setColor( Checked, "#ffffff" ); // = (255, 255, 255)
804 setColor( GridLine, "#999a99" ); // = (153, 154, 153) // ( 192, 192, 192 )
805 setColor( Header, "#e6e7e6" ); // = (230, 231, 230)
806 setColor( Slider, "#e6e7e6" ); // = (230, 231, 230)
807 setColor( HighlightWidget, "#e6e7e6" ); // = (230, 231, 230)
808 setColor( HighlightBorder, "#e6e7e6" ); // = (230, 231, 230)
809 setColor( Lines, "#999a99" ); // = (153, 154, 153) // ( 192, 193, 192 )
812 myLinesType = NoLines;
813 myWidgetEffect = NoEffect;
814 myAntiAliasing = false;
815 myLinesTransparency = 0;
816 myWidgetRounding[ EditRadius ] = 0.0;
817 myWidgetRounding[ ButtonRadius ] = 0.0;
818 myWidgetRounding[ FrameRadius ] = 0.0;
819 myWidgetRounding[ SliderRadius ] = 0.0;
820 myHandleDelta[ Qt::Horizontal ] = 3;
821 myHandleDelta[ Qt::Vertical ] = 3;
822 mySplitHandleLength = 20;
827 \brief Read palette color values from resources manager
828 \param role color role
829 \param prefix palette color value resource name prefix
830 \sa writeColorValue()
832 void Style_Model::readColorValue( ColorRole role, const QString& prefix )
834 if ( !resourceMgr() ) return;
836 QString section = resourceSection();
837 QString active = QString( "%1-color" ).arg( prefix );
838 QString inactive = QString( "%1-color-inactive" ).arg( prefix );
839 QString disabled = QString( "%1-color-disabled" ).arg( prefix );
841 if ( resourceMgr()->hasValue( section, active ) )
842 setColor( role, resourceMgr()->colorValue( section, active ) );
843 if ( resourceMgr()->hasValue( section, inactive ) )
844 setColor( role, QPalette::Inactive, resourceMgr()->colorValue( section, inactive ) );
845 if ( resourceMgr()->hasValue( section, disabled ) )
846 setColor( role, QPalette::Disabled, resourceMgr()->colorValue( section, disabled ) );
850 \brief Write palette color values to resources manager
851 \param role color role
852 \param prefix palette color value resource name prefix
853 \param resMgr resource manager
854 \param resSection resource section name
857 void Style_Model::writeColorValue( ColorRole role, const QString& prefix,
858 QtxResourceMgr* resMgr, const QString& resSection ) const
860 QString active = QString( "%1-color" ).arg( prefix );
861 QString inactive = QString( "%1-color-inactive" ).arg( prefix );
862 QString disabled = QString( "%1-color-disabled" ).arg( prefix );
864 resMgr->setValue( resSection, active, color( role, QPalette::Active ) );
865 resMgr->setValue( resSection, inactive, color( role, QPalette::Inactive ) );
866 resMgr->setValue( resSection, disabled, color( role, QPalette::Disabled ) );