-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 | |||
@@ -21,25 +21,25 @@ | |||
21 | #include <qobjectlist.h> | 21 | #include <qobjectlist.h> |
22 | #include <qimage.h> | 22 | #include <qimage.h> |
23 | #include <qtimer.h> | 23 | #include <qtimer.h> |
24 | #include <qpixmapcache.h> | 24 | #include <qpixmapcache.h> |
25 | #include <qradiobutton.h> | 25 | #include <qradiobutton.h> |
26 | #include <qcombobox.h> | 26 | #include <qcombobox.h> |
27 | #include <qdrawutil.h> | 27 | #include <qdrawutil.h> |
28 | #include <qwidgetlist.h> | 28 | #include <qwidgetlist.h> |
29 | #include <qtoolbutton.h> | 29 | #include <qtoolbutton.h> |
30 | #include <qheader.h> | 30 | #include <qheader.h> |
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> |
36 | 36 | ||
37 | #include "htmlmasks.h" | 37 | #include "htmlmasks.h" |
38 | #include "embeddata.h" | 38 | #include "embeddata.h" |
39 | 39 | ||
40 | typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, | 40 | typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, |
41 | QColorGroup &, bool, bool); | 41 | QColorGroup &, bool, bool); |
42 | 42 | ||
43 | QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl); | 43 | QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl); |
44 | 44 | ||
45 | void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color) | 45 | void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color) |
@@ -844,28 +844,25 @@ void LiquidStyle::polish(QWidget *w) | |||
844 | return; | 844 | return; |
845 | } | 845 | } |
846 | if(w->inherits("QPopupMenu")) | 846 | if(w->inherits("QPopupMenu")) |
847 | w->setBackgroundMode(QWidget::NoBackground); | 847 | w->setBackgroundMode(QWidget::NoBackground); |
848 | else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) { | 848 | else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) { |
849 | w->installEventFilter(menuHandler); | 849 | w->installEventFilter(menuHandler); |
850 | } | 850 | } |
851 | 851 | ||
852 | if(w->isTopLevel()){ | 852 | if(w->isTopLevel()){ |
853 | return; | 853 | return; |
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")) { |
862 | w->installEventFilter(this); | 859 | w->installEventFilter(this); |
863 | } | 860 | } |
864 | if(w->inherits("QLineEdit")){ | 861 | if(w->inherits("QLineEdit")){ |
865 | QPalette pal = w->palette(); | 862 | QPalette pal = w->palette(); |
866 | pal.setBrush(QColorGroup::Base, baseBrush); | 863 | pal.setBrush(QColorGroup::Base, baseBrush); |
867 | w->setPalette(pal); | 864 | w->setPalette(pal); |
868 | } | 865 | } |
869 | if(w->inherits("QPushButton")){ | 866 | if(w->inherits("QPushButton")){ |
870 | applyCustomAttributes((QPushButton *)w); | 867 | applyCustomAttributes((QPushButton *)w); |
871 | w->installEventFilter(this); | 868 | w->installEventFilter(this); |
@@ -1026,24 +1023,86 @@ void LiquidStyle::polish(QApplication *app) | |||
1026 | 1023 | ||
1027 | void LiquidStyle::unPolish(QApplication *app) | 1024 | void LiquidStyle::unPolish(QApplication *app) |
1028 | { | 1025 | { |
1029 | QWindowsStyle::unPolish(app); | 1026 | QWindowsStyle::unPolish(app); |
1030 | app->setEffectEnabled(UI_AnimateMenu, menuAni); | 1027 | app->setEffectEnabled(UI_AnimateMenu, menuAni); |
1031 | app->setEffectEnabled(UI_FadeMenu, menuFade); | 1028 | app->setEffectEnabled(UI_FadeMenu, menuFade); |
1032 | 1029 | ||
1033 | qt_set_draw_menu_bar_impl ( 0 ); | 1030 | qt_set_draw_menu_bar_impl ( 0 ); |
1034 | 1031 | ||
1035 | // QApplication::qwsSetDecoration ( new QPEDecoration ( )); | 1032 | // QApplication::qwsSetDecoration ( new QPEDecoration ( )); |
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 |
1040 | * force everything to erase and repaint on resize. This is going away, I'm | 1099 | * force everything to erase and repaint on resize. This is going away, I'm |
1041 | * trying to get shaped widgets to work right without masking. QPushButton, | 1100 | * trying to get shaped widgets to work right without masking. QPushButton, |
1042 | * QComboBox, and Panel applet handles capture mouse enter and leaves in order | 1101 | * QComboBox, and Panel applet handles capture mouse enter and leaves in order |
1043 | * to set the highlightwidget and repaint for mouse hovers. CheckBoxes and | 1102 | * to set the highlightwidget and repaint for mouse hovers. CheckBoxes and |
1044 | * RadioButtons need to do this differently. Qt buffers these in pixmaps and | 1103 | * RadioButtons need to do this differently. Qt buffers these in pixmaps and |
1045 | * caches them in QPixmapCache, which is bad for doing things like hover | 1104 | * caches them in QPixmapCache, which is bad for doing things like hover |
1046 | * because the style methods aren't called in paintEvents if everything | 1105 | * because the style methods aren't called in paintEvents if everything |
1047 | * is cached. We use our own Paint event handler instead. Taskbuttons and | 1106 | * is cached. We use our own Paint event handler instead. Taskbuttons and |
1048 | * pager buttons draw into a pixmap buffer, so we handle those with palette | 1107 | * pager buttons draw into a pixmap buffer, so we handle those with palette |
1049 | * modifications. For QHeader, different header items are actually one widget | 1108 | * modifications. For QHeader, different header items are actually one widget |
@@ -1231,25 +1290,42 @@ bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) | |||
1231 | // reset old header | 1290 | // reset old header |
1232 | if(oldHeader != -1){ | 1291 | if(oldHeader != -1){ |
1233 | hw->repaint(hw->sectionPos(oldHeader), 0, | 1292 | hw->repaint(hw->sectionPos(oldHeader), 0, |
1234 | hw->sectionSize(oldHeader), hw->height()); | 1293 | hw->sectionSize(oldHeader), hw->height()); |
1235 | } | 1294 | } |
1236 | if(headerHoverID != -1){ | 1295 | if(headerHoverID != -1){ |
1237 | hw->repaint(hw->sectionPos(headerHoverID), 0, | 1296 | hw->repaint(hw->sectionPos(headerHoverID), 0, |
1238 | hw->sectionSize(headerHoverID), hw->height()); | 1297 | hw->sectionSize(headerHoverID), hw->height()); |
1239 | } | 1298 | } |
1240 | } | 1299 | } |
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 | ||
1246 | void LiquidStyle::drawButton(QPainter *p, int x, int y, int w, int h, | 1322 | void LiquidStyle::drawButton(QPainter *p, int x, int y, int w, int h, |
1247 | const QColorGroup &g, bool sunken, | 1323 | const QColorGroup &g, bool sunken, |
1248 | const QBrush *) | 1324 | const QBrush *) |
1249 | { | 1325 | { |
1250 | drawRoundButton(p, sunken ? g.background() : g.button(), g.background(), | 1326 | drawRoundButton(p, sunken ? g.background() : g.button(), g.background(), |
1251 | x, y, w, h); | 1327 | x, y, w, h); |
1252 | } | 1328 | } |
1253 | 1329 | ||
1254 | void LiquidStyle::drawToolButton(QPainter *p, int x, int y, int w, int h, | 1330 | void LiquidStyle::drawToolButton(QPainter *p, int x, int y, int w, int h, |
1255 | const QColorGroup &g, bool sunken, | 1331 | const QColorGroup &g, bool sunken, |