summaryrefslogtreecommitdiff
path: root/noncore/styles/theme/othemestyle.cpp
Unidiff
Diffstat (limited to 'noncore/styles/theme/othemestyle.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/styles/theme/othemestyle.cpp53
1 files changed, 28 insertions, 25 deletions
diff --git a/noncore/styles/theme/othemestyle.cpp b/noncore/styles/theme/othemestyle.cpp
index 98e7253..106d206 100644
--- a/noncore/styles/theme/othemestyle.cpp
+++ b/noncore/styles/theme/othemestyle.cpp
@@ -37,20 +37,20 @@ QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl);
37 37
38 38
39/* !! HACK !! Beware 39/* !! HACK !! Beware
40 * 40 *
41 * TT forgot to make the QProgressBar widget styleable in Qt 2.x 41 * TT forgot to make the QProgressBar widget styleable in Qt 2.x
42 * So the only way to customize the drawing, is to intercept the 42 * So the only way to customize the drawing, is to intercept the
43 * paint event - since we have to use protected functions, we need 43 * paint event - since we have to use protected functions, we need
44 * to derive a "hack" class from QProgressBar and do the painting 44 * to derive a "hack" class from QProgressBar and do the painting
45 * in there. 45 * in there.
46 * 46 *
47 * - sandman 47 * - sandman
48 */ 48 */
49 49
50class HackProgressBar : public QProgressBar { 50class HackProgressBar : public QProgressBar {
51public: 51public:
52 HackProgressBar ( ); 52 HackProgressBar ( );
53 53
54 void paint ( QPaintEvent *event, OThemeStyle *style ) 54 void paint ( QPaintEvent *event, OThemeStyle *style )
55 { 55 {
56 QPainter p( this ); 56 QPainter p( this );
@@ -75,9 +75,9 @@ public:
75 total = 1; 75 total = 1;
76 int perc = prog * 100 / total; 76 int perc = prog * 100 / total;
77 77
78 style-> drawProgressBar ( &p, x, y, w, h, colorGroup ( ), perc ); 78 style-> drawProgressBar ( &p, x, y, w, h, colorGroup ( ), perc );
79 79
80 if ( progress ( ) >= 0 && totalSteps ( ) > 0 ) { 80 if ( progress ( ) >= 0 && totalSteps ( ) > 0 ) {
81 QString pstr; 81 QString pstr;
82 pstr. sprintf ( "%d%%", 100 * progress()/totalSteps ()); 82 pstr. sprintf ( "%d%%", 100 * progress()/totalSteps ());
83 p. setPen ( colorGroup().text());//g.highlightedText ( )); 83 p. setPen ( colorGroup().text());//g.highlightedText ( ));
@@ -109,13 +109,13 @@ void OThemeStyle::polish( QApplication * /*app*/ )
109void OThemeStyle::polish( QPalette &p ) 109void OThemeStyle::polish( QPalette &p )
110{ 110{
111 oldPalette = p; 111 oldPalette = p;
112 112
113 QColor bg = oldPalette. color ( QPalette::Normal, QColorGroup::Background ); 113 QColor bg = oldPalette. color ( QPalette::Normal, QColorGroup::Background );
114 114
115 if ( bgcolor. isValid ( )) 115 if ( bgcolor. isValid ( ))
116 bg = bgcolor; 116 bg = bgcolor;
117 117
118 if ( isColor ( Background )) 118 if ( isColor ( Background ))
119 bg = colorGroup ( oldPalette. active ( ), Background )-> background ( ); 119 bg = colorGroup ( oldPalette. active ( ), Background )-> background ( );
120 120
121 p = QPalette ( bg, bg ); 121 p = QPalette ( bg, bg );
@@ -124,18 +124,18 @@ void OThemeStyle::polish( QPalette &p )
124 p. setBrush ( QColorGroup::Background, QBrush ( bg, *uncached ( Background ))); 124 p. setBrush ( QColorGroup::Background, QBrush ( bg, *uncached ( Background )));
125 125
126 if ( fgcolor. isValid ( )) { 126 if ( fgcolor. isValid ( )) {
127 p. setColor ( QColorGroup::Foreground, fgcolor ); 127 p. setColor ( QColorGroup::Foreground, fgcolor );
128 p. setColor ( QColorGroup::ButtonText, fgcolor ); 128 p. setColor ( QColorGroup::ButtonText, fgcolor );
129 } 129 }
130 if ( selfgcolor. isValid ( )) 130 if ( selfgcolor. isValid ( ))
131 p. setColor ( QColorGroup::HighlightedText, selfgcolor ); 131 p. setColor ( QColorGroup::HighlightedText, selfgcolor );
132 if ( selbgcolor. isValid ( )) 132 if ( selbgcolor. isValid ( ))
133 p. setColor ( QColorGroup::Highlight, selbgcolor ); 133 p. setColor ( QColorGroup::Highlight, selbgcolor );
134 if ( winfgcolor. isValid ( )) 134 if ( winfgcolor. isValid ( ))
135 p. setColor ( QColorGroup::Text, winfgcolor ); 135 p. setColor ( QColorGroup::Text, winfgcolor );
136 if ( winbgcolor. isValid ( )) 136 if ( winbgcolor. isValid ( ))
137 p. setColor ( QColorGroup::Base, winbgcolor ); 137 p. setColor ( QColorGroup::Base, winbgcolor );
138 138
139} 139}
140 140
141 141
@@ -1183,7 +1183,7 @@ void OThemeStyle::drawPushButtonLabel( QPushButton *btn, QPainter *p )
1183 ? QIconSet::Normal : QIconSet::Disabled; 1183 ? QIconSet::Normal : QIconSet::Disabled;
1184 if ( mode == QIconSet::Normal && btn->hasFocus() ) 1184 if ( mode == QIconSet::Normal && btn->hasFocus() )
1185 mode = QIconSet::Active; 1185 mode = QIconSet::Active;
1186 QPixmap pixmap = btn->iconSet() ->pixmap( QIconSet::Small, mode ); 1186 QPixmap pixmap = btn->iconSet() ->pixmap( QIconSet::Automatic, mode );
1187 int pixw = pixmap.width(); 1187 int pixw = pixmap.width();
1188 int pixh = pixmap.height(); 1188 int pixh = pixmap.height();
1189 1189
@@ -1246,8 +1246,7 @@ int OThemeStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem *mi,
1246 h = h2 > h ? h2 : h; 1246 h = h2 > h ? h2 : h;
1247 } 1247 }
1248 if ( mi->iconSet() ) { 1248 if ( mi->iconSet() ) {
1249 h2 = mi->iconSet() -> 1249 h2 = mi->iconSet() ->pixmap().height() + offset;
1250 pixmap( QIconSet::Small, QIconSet::Normal ).height() + offset;
1251 h = h2 > h ? h2 : h; 1250 h = h2 > h ? h2 : h;
1252 } 1251 }
1253 h2 = fm.height() + offset; 1252 h2 = fm.height() + offset;
@@ -1325,7 +1324,11 @@ void OThemeStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw,
1325 QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal; 1324 QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal;
1326 if ( act && !dis ) 1325 if ( act && !dis )
1327 mode = QIconSet::Active; 1326 mode = QIconSet::Active;
1328 QPixmap pixmap = mi->iconSet() ->pixmap( QIconSet::Small, mode ); 1327 QPixmap pixmap;
1328 if ( mode == QIconSet::Disabled )
1329 pixmap = mi->iconSet()->pixmap( QIconSet::Automatic, mode );
1330 else
1331 pixmap = mi->iconSet()->pixmap();
1329 int pixw = pixmap.width(); 1332 int pixw = pixmap.width();
1330 int pixh = pixmap.height(); 1333 int pixh = pixmap.height();
1331 QRect cr( x, y, checkcol, h ); 1334 QRect cr( x, y, checkcol, h );
@@ -1434,11 +1437,11 @@ void OThemeStyle::drawKMenuBar( QPainter *p, int x, int y, int w, int h,
1434#endif 1437#endif
1435 1438
1436void OThemeStyle::drawMenuBarItem( QPainter *p, int x, int y, int w, int h, 1439void OThemeStyle::drawMenuBarItem( QPainter *p, int x, int y, int w, int h,
1437 QMenuItem *mi, const QColorGroup &g, 1440 QMenuItem *mi, const QColorGroup &g,
1438 bool /*enabled*/, bool active ) 1441 bool /*enabled*/, bool active )
1439{ 1442{
1440 if(active){ 1443 if(active){
1441 x -= 2; // Bug in Qt/E 1444 x -= 2; // Bug in Qt/E
1442 y -= 2; 1445 y -= 2;
1443 w += 2; 1446 w += 2;
1444 h += 2; 1447 h += 2;
@@ -1464,11 +1467,11 @@ void OThemeStyle::drawProgressBar ( QPainter *p, int x, int y, int w, int h, con
1464 bg.setColor( cg->color( QColorGroup::Background ) ); 1467 bg.setColor( cg->color( QColorGroup::Background ) );
1465 if ( isPixmap( ProgressBg ) ) 1468 if ( isPixmap( ProgressBg ) )
1466 bg.setPixmap( *uncached( ProgressBg ) ); 1469 bg.setPixmap( *uncached( ProgressBg ) );
1467 1470
1468 int pw = w * percent / 100; 1471 int pw = w * percent / 100;
1469 1472
1470 p-> fillRect ( x + pw, y, w - pw, h, bg ); // ### TODO 1473 p-> fillRect ( x + pw, y, w - pw, h, bg ); // ### TODO
1471 1474
1472 drawBaseButton( p, x, y, pw, h, *cg, false, false, ProgressBar ); 1475 drawBaseButton( p, x, y, pw, h, *cg, false, false, ProgressBar );
1473} 1476}
1474 1477