Diffstat (limited to 'noncore/styles/liquid/liquid.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/styles/liquid/liquid.cpp | 88 |
1 files changed, 82 insertions, 6 deletions
diff --git a/noncore/styles/liquid/liquid.cpp b/noncore/styles/liquid/liquid.cpp index 259f6af..4013981 100644 --- a/noncore/styles/liquid/liquid.cpp +++ b/noncore/styles/liquid/liquid.cpp | |||
@@ -31,5 +31,5 @@ | |||
31 | #include <unistd.h> | 31 | #include <unistd.h> |
32 | #include <qmenubar.h> | 32 | #include <qmenubar.h> |
33 | 33 | #include <qprogressbar.h> | |
34 | 34 | ||
35 | #include <stdio.h> | 35 | #include <stdio.h> |
@@ -854,8 +854,5 @@ void LiquidStyle::polish(QWidget *w) | |||
854 | } | 854 | } |
855 | 855 | ||
856 | 856 | if(w->inherits("QComboBox") || w->inherits("QProgressBar") || | |
857 | |||
858 | |||
859 | if(w->inherits("QComboBox") || | ||
860 | w->inherits("QLineEdit") || w->inherits("QRadioButton") || | 857 | w->inherits("QLineEdit") || w->inherits("QRadioButton") || |
861 | w->inherits("QCheckBox") || w->inherits("QScrollBar")) { | 858 | w->inherits("QCheckBox") || w->inherits("QScrollBar")) { |
@@ -1036,4 +1033,66 @@ void LiquidStyle::unPolish(QApplication *app) | |||
1036 | } | 1033 | } |
1037 | 1034 | ||
1035 | |||
1036 | /* !! HACK !! Beware | ||
1037 | * | ||
1038 | * TT forgot to make the QProgressBar widget styleable in Qt 2.x | ||
1039 | * So the only way to customize the drawing, is to intercept the | ||
1040 | * paint event - since we have to use protected functions, we need | ||
1041 | * to derive a "hack" class from QProgressBar and do the painting | ||
1042 | * in there. | ||
1043 | * | ||
1044 | * - sandman | ||
1045 | */ | ||
1046 | |||
1047 | class HackProgressBar : public QProgressBar { | ||
1048 | public: | ||
1049 | HackProgressBar ( ); | ||
1050 | |||
1051 | void paint ( QPaintEvent *event, const QColorGroup &g, QPixmap *pix ) | ||
1052 | { | ||
1053 | QPainter p( this ); | ||
1054 | |||
1055 | if ( !contentsRect().contains( event->rect() ) ) { | ||
1056 | p.save(); | ||
1057 | p.setClipRegion( event->region().intersect(frameRect()) ); | ||
1058 | drawFrame( &p); | ||
1059 | p.restore(); | ||
1060 | } | ||
1061 | if ( event->rect().intersects( contentsRect() )) { | ||
1062 | p.setClipRegion( event->region().intersect( contentsRect() ) ); | ||
1063 | |||
1064 | int x, y, w, h; | ||
1065 | contentsRect ( ). rect ( &x, &y, &w, &h ); | ||
1066 | |||
1067 | int prog = progress ( ); | ||
1068 | int total = totalSteps ( ); | ||
1069 | if ( prog < 0 ) | ||
1070 | prog = 0; | ||
1071 | if ( total <= 0 ) | ||
1072 | total = 1; | ||
1073 | int bw = w * prog / total; | ||
1074 | if ( bw > w ) | ||
1075 | bw = w; | ||
1076 | |||
1077 | p.setPen(g.button().dark(130)); | ||
1078 | p.drawRect(x, y, bw, h); | ||
1079 | p.setPen(g.button().light(120)); | ||
1080 | p.drawRect(x+1, y+1, bw-2, h-2); | ||
1081 | |||
1082 | if(bw >= 4 && h >= 4 && pix) | ||
1083 | p.drawTiledPixmap(x+2, y+2, bw-4, h-4, *pix); | ||
1084 | |||
1085 | if ( progress ( )>= 0 && totalSteps ( ) > 0 ) { | ||
1086 | QString pstr; | ||
1087 | pstr. sprintf ( "%d%%", 100 * progress()/totalSteps ()); | ||
1088 | p. setPen ( g.text());//g.highlightedText ( )); | ||
1089 | p. drawText (x,y,w-1,h-1,AlignCenter,pstr); | ||
1090 | } | ||
1091 | } | ||
1092 | } | ||
1093 | }; | ||
1094 | |||
1095 | |||
1096 | |||
1038 | /* | 1097 | /* |
1039 | * This is a fun method ;-) Here's an overview. KToolBar grabs resize to | 1098 | * This is a fun method ;-) Here's an overview. KToolBar grabs resize to |
@@ -1241,5 +1300,22 @@ bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) | |||
1241 | } | 1300 | } |
1242 | } | 1301 | } |
1243 | return(false); | 1302 | else if (obj-> inherits( "QProgressBar" )) { |
1303 | if ( ev->type() == QEvent::Paint ) { | ||
1304 | HackProgressBar *p = (HackProgressBar *) obj; | ||
1305 | const QColorGroup &g = p-> colorGroup ( ); | ||
1306 | |||
1307 | QPixmap *pix = bevelFillDict.find(g.button().dark(120).rgb()); | ||
1308 | if(!pix){ | ||
1309 | int h, s, v; | ||
1310 | g.button().dark(120).hsv(&h, &s, &v); | ||
1311 | pix = new QPixmap(*bevelFillPix); | ||
1312 | adjustHSV(*pix, h, s, v); | ||
1313 | bevelFillDict.insert(g.button().dark(120).rgb(), pix); | ||
1314 | } | ||
1315 | p-> paint ((QPaintEvent *) ev, g, pix ); | ||
1316 | return true; | ||
1317 | } | ||
1318 | } | ||
1319 | return false ; | ||
1244 | } | 1320 | } |
1245 | 1321 | ||