summaryrefslogtreecommitdiff
path: root/noncore/styles/liquid/liquid.cpp
Unidiff
Diffstat (limited to 'noncore/styles/liquid/liquid.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/styles/liquid/liquid.cpp129
1 files changed, 68 insertions, 61 deletions
diff --git a/noncore/styles/liquid/liquid.cpp b/noncore/styles/liquid/liquid.cpp
index 51814e7..77cf198 100644
--- a/noncore/styles/liquid/liquid.cpp
+++ b/noncore/styles/liquid/liquid.cpp
@@ -1,27 +1,27 @@
1/*- 1/*-
2 * Copyright (C)QPL 2001 Daniel M. Duley. All rights reserved. 2 * Copyright (C)QPL 2001 Daniel M. Duley. All rights reserved.
3 */ 3 */
4 4
5// 5//
6// (c) 2002 Robert 'sandman' Griebl 6// (c) 2002 Robert 'sandman' Griebl
7// 7//
8 8
9 9
10#ifndef INCLUDE_MENUITEM_DEF 10#ifndef INCLUDE_MENUITEM_DEF
11#define INCLUDE_MENUITEM_DEF 11#define INCLUDE_MENUITEM_DEF
12#endif 12#endif
13 13
14#include "liquid.h" 14#include "liquid.h"
15#include "effects.h" 15#include "effects.h"
16#include "htmlmasks.h" 16#include "htmlmasks.h"
17#include "embeddata.h" 17#include "embeddata.h"
18 18
19/* OPIE */ 19/* OPIE */
20#include <opie2/odebug.h> 20#include <opie2/odebug.h>
21#include <qpe/config.h> 21#include <qpe/config.h>
22using namespace Opie::Core; 22using namespace Opie::Core;
23 23
24/* QT */ 24/* QT */
25#include <qmenudata.h> 25#include <qmenudata.h>
26#include <qapplication.h> 26#include <qapplication.h>
27#include <qpalette.h> 27#include <qpalette.h>
@@ -90,25 +90,25 @@ void TransMenuHandler::reloadSettings()
90 90
91 Config config ( "qpe" ); 91 Config config ( "qpe" );
92 config. setGroup ( "Liquid-Style" ); 92 config. setGroup ( "Liquid-Style" );
93 93
94 type = config. readNumEntry("Type", TransStippleBg); 94 type = config. readNumEntry("Type", TransStippleBg);
95 color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name())); 95 color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name()));
96 fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name())); 96 fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name()));
97 opacity = config. readNumEntry("Opacity", 10); 97 opacity = config. readNumEntry("Opacity", 10);
98 if ( opacity < -20 ) 98 if ( opacity < -20 )
99 opacity = 20; 99 opacity = 20;
100 else if ( opacity > 20 ) 100 else if ( opacity > 20 )
101 opacity = 20; 101 opacity = 20;
102 102
103 shadowText = config. readBoolEntry("ShadowText", true); 103 shadowText = config. readBoolEntry("ShadowText", true);
104} 104}
105 105
106bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev) 106bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev)
107{ 107{
108 QWidget *p = (QWidget *)obj; 108 QWidget *p = (QWidget *)obj;
109 109
110 if(ev->type() == QEvent::Show){ 110 if(ev->type() == QEvent::Show){
111 if(type == TransStippleBg || type == TransStippleBtn || 111 if(type == TransStippleBg || type == TransStippleBtn ||
112 type == Custom){ 112 type == Custom){
113 QApplication::syncX(); 113 QApplication::syncX();
114 QPixmap *pix = new QPixmap; 114 QPixmap *pix = new QPixmap;
@@ -128,61 +128,61 @@ bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev)
128 } 128 }
129 if(type == TransStippleBg){ 129 if(type == TransStippleBg){
130 stripePixmap(*pix, p->colorGroup().background()); 130 stripePixmap(*pix, p->colorGroup().background());
131 } 131 }
132 else if(type == TransStippleBtn){ 132 else if(type == TransStippleBtn){
133 stripePixmap(*pix, p->colorGroup().button()); 133 stripePixmap(*pix, p->colorGroup().button());
134 } 134 }
135 else{ 135 else{
136 QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color); 136 QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color);
137 } 137 }
138 138
139 pixDict.insert(p->winId(), pix); 139 pixDict.insert(p->winId(), pix);
140 140
141 if ( !p->inherits("QPopupMenu")) 141 if ( !p->inherits("QPopupMenu"))
142 p->setBackgroundPixmap(*pix); 142 p->setBackgroundPixmap(*pix);
143 143
144 QObjectList *ol = p-> queryList("QWidget"); 144 QObjectList *ol = p-> queryList("QWidget");
145 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { 145 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) {
146 QWidget *wid = (QWidget *) it.current ( ); 146 QWidget *wid = (QWidget *) it.current ( );
147 147
148 wid-> setBackgroundPixmap(*pix); 148 wid-> setBackgroundPixmap(*pix);
149 wid-> setBackgroundOrigin(QWidget::ParentOrigin); 149 wid-> setBackgroundOrigin(QWidget::ParentOrigin);
150 } 150 }
151 delete ol; 151 delete ol;
152 } 152 }
153 } 153 }
154 else if(ev->type() == QEvent::Hide){ 154 else if(ev->type() == QEvent::Hide){
155 if(type == TransStippleBg || type == TransStippleBtn || 155 if(type == TransStippleBg || type == TransStippleBtn ||
156 type == Custom){ 156 type == Custom){
157// owarn << "Deleting menu pixmap, width " << pixDict.find(p->winId())->width() << "" << oendl; 157// owarn << "Deleting menu pixmap, width " << pixDict.find(p->winId())->width() << "" << oendl;
158 158
159 pixDict.remove(p->winId()); 159 pixDict.remove(p->winId());
160 if ( !p->inherits("QPopupMenu")) 160 if ( !p->inherits("QPopupMenu"))
161 p->setBackgroundMode(QWidget::PaletteBackground); 161 p->setBackgroundMode(QWidget::PaletteBackground);
162 162
163 QObjectList *ol = p-> queryList("QWidget"); 163 QObjectList *ol = p-> queryList("QWidget");
164 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { 164 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) {
165 QWidget *wid = (QWidget *) it.current ( ); 165 QWidget *wid = (QWidget *) it.current ( );
166 166
167 wid-> setBackgroundMode( QWidget::PaletteBackground ); 167 wid-> setBackgroundMode( QWidget::PaletteBackground );
168 } 168 }
169 delete ol; 169 delete ol;
170 } 170 }
171 } 171 }
172 return(false); 172 return(false);
173} 173}
174 174
175 175
176 176
177 177
178LiquidStyle::LiquidStyle() 178LiquidStyle::LiquidStyle()
179 :QWindowsStyle() 179 :QWindowsStyle()
180{ 180{
181 setName ( "LiquidStyle" ); 181 setName ( "LiquidStyle" );
182 182
183 flatTBButtons = false; 183 flatTBButtons = false;
184 currentHeader = 0; 184 currentHeader = 0;
185 185
186 btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true); 186 btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true);
187 btnMaskBmp.setMask(btnMaskBmp); 187 btnMaskBmp.setMask(btnMaskBmp);
188 htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true); 188 htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true);
@@ -490,25 +490,25 @@ void LiquidStyle::drawRoundButton(QPainter *painter, const QColor &c,
490 490
491 491
492 492
493} 493}
494 494
495 495
496QPixmap* LiquidStyle::processEmbedded(const char *label, int h, int s, int v, 496QPixmap* LiquidStyle::processEmbedded(const char *label, int h, int s, int v,
497 bool blend) 497 bool blend)
498{ 498{
499 QImage img(qembed_findImage(label)); 499 QImage img(qembed_findImage(label));
500 img.detach(); 500 img.detach();
501 if(img.isNull()){ // shouldn't happen, been tested 501 if(img.isNull()){ // shouldn't happen, been tested
502 owarn << "Invalid embedded label " << label << "" << oendl; 502 owarn << "Invalid embedded label " << label << "" << oendl;
503 return(NULL); 503 return(NULL);
504 } 504 }
505 if(img.depth() != 32) 505 if(img.depth() != 32)
506 img = img.convertDepth(32); 506 img = img.convertDepth(32);
507 unsigned int *data = (unsigned int *)img.bits(); 507 unsigned int *data = (unsigned int *)img.bits();
508 int total = img.width()*img.height(); 508 int total = img.width()*img.height();
509 int current; 509 int current;
510 QColor c; 510 QColor c;
511 int oldH, oldS, oldV; 511 int oldH, oldS, oldV;
512 int alpha; 512 int alpha;
513 if(v < 235) 513 if(v < 235)
514 v += 20; 514 v += 20;
@@ -590,28 +590,28 @@ QPixmap* LiquidStyle::getPixmap(BitmapData item)
590 case RadioOn: 590 case RadioOn:
591 pixmaps[RadioOn] = processEmbedded("radio_down", btnH, btnS, btnV /*, true*/); 591 pixmaps[RadioOn] = processEmbedded("radio_down", btnH, btnS, btnV /*, true*/);
592 break; 592 break;
593 case RadioOnHover: 593 case RadioOnHover:
594 pixmaps[RadioOnHover] = processEmbedded("radio_down", btnHoverH, btnHoverS, btnHoverV /*, true*/); 594 pixmaps[RadioOnHover] = processEmbedded("radio_down", btnHoverH, btnHoverS, btnHoverV /*, true*/);
595 break; 595 break;
596 596
597 case Tab: 597 case Tab:
598 pixmaps[Tab] = processEmbedded("tab", bH, bS, bV /*, true*/); 598 pixmaps[Tab] = processEmbedded("tab", bH, bS, bV /*, true*/);
599 break; 599 break;
600 case TabDown: 600 case TabDown:
601 pixmaps[TabDown] = processEmbedded("tab", btnH, btnS, btnV /*, true*/); 601 pixmaps[TabDown] = processEmbedded("tab", btnH, btnS, btnV /*, true*/);
602 break; 602 break;
603 case TabFocus: 603 case TabFocus:
604 pixmaps[TabFocus] = processEmbedded("tab", btnHoverH, btnHoverS, btnHoverV /*, true*/); 604 pixmaps[TabFocus] = processEmbedded("tab", btnHoverH, btnHoverS, btnHoverV /*, true*/);
605 break; 605 break;
606 606
607 case CB: 607 case CB:
608 pixmaps[CB] = processEmbedded("checkbox", bH, bS, bV /*, true*/); 608 pixmaps[CB] = processEmbedded("checkbox", bH, bS, bV /*, true*/);
609 break; 609 break;
610 case CBHover: 610 case CBHover:
611 pixmaps[CBHover] = processEmbedded("checkbox", btnHoverH, btnHoverS, btnHoverV /*, true*/); 611 pixmaps[CBHover] = processEmbedded("checkbox", btnHoverH, btnHoverS, btnHoverV /*, true*/);
612 break; 612 break;
613 case CBDown: 613 case CBDown:
614 pixmaps[CBDown] = processEmbedded("checkboxdown", btnH, btnS, btnV /*, true*/); 614 pixmaps[CBDown] = processEmbedded("checkboxdown", btnH, btnS, btnV /*, true*/);
615 break; 615 break;
616 case CBDownHover: 616 case CBDownHover:
617 pixmaps[CBDownHover] = processEmbedded("checkboxdown", btnHoverH, btnHoverS, btnHoverV /*, true*/); 617 pixmaps[CBDownHover] = processEmbedded("checkboxdown", btnHoverH, btnHoverS, btnHoverV /*, true*/);
@@ -792,34 +792,34 @@ void LiquidStyle::polish(QWidget *w)
792 w->setBackgroundMode(QWidget::PaletteBackground); 792 w->setBackgroundMode(QWidget::PaletteBackground);
793 w->setBackgroundOrigin(QWidget::ParentOrigin); 793 w->setBackgroundOrigin(QWidget::ParentOrigin);
794 return; 794 return;
795 } 795 }
796 if(w->inherits("QToolBar")){ 796 if(w->inherits("QToolBar")){
797 w->installEventFilter(this); 797 w->installEventFilter(this);
798 w->setBackgroundMode(QWidget::PaletteBackground); 798 w->setBackgroundMode(QWidget::PaletteBackground);
799 w->setBackgroundOrigin(QWidget::WidgetOrigin); 799 w->setBackgroundOrigin(QWidget::WidgetOrigin);
800 return; 800 return;
801 } 801 }
802 if(w->inherits("QPopupMenu")) 802 if(w->inherits("QPopupMenu"))
803 w->setBackgroundMode(QWidget::NoBackground); 803 w->setBackgroundMode(QWidget::NoBackground);
804 else if(w-> testWFlags(Qt::WType_Popup) && 804 else if(w-> testWFlags(Qt::WType_Popup) &&
805 !w->inherits("QListBox") && 805 !w->inherits("QListBox") &&
806 ( qstrcmp ( w-> name(), "automatic what's this? widget" ) != 0 )) { 806 ( qstrcmp ( w-> name(), "automatic what's this? widget" ) != 0 )) {
807 w->installEventFilter(menuHandler); 807 w->installEventFilter(menuHandler);
808 } 808 }
809 809
810 if(w->isTopLevel()){ 810 if(w->isTopLevel()){
811 return; 811 return;
812 } 812 }
813 813
814 if(w->inherits("QRadioButton") || w->inherits("QCheckBox") || w->inherits("QProgressBar")) { 814 if(w->inherits("QRadioButton") || w->inherits("QCheckBox") || w->inherits("QProgressBar")) {
815 w->installEventFilter(this); 815 w->installEventFilter(this);
816 } 816 }
817 817
818 if(w->inherits("QButton") || w-> inherits("QComboBox")){ 818 if(w->inherits("QButton") || w-> inherits("QComboBox")){
819 w-> setBackgroundMode ( QWidget::PaletteBackground ); 819 w-> setBackgroundMode ( QWidget::PaletteBackground );
820 w->setBackgroundOrigin ( QWidget::ParentOrigin); 820 w->setBackgroundOrigin ( QWidget::ParentOrigin);
821 } 821 }
822 822
823 bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 || 823 bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 ||
824 qstrcmp(w->name(), "qt_clipped_viewport") == 0; 824 qstrcmp(w->name(), "qt_clipped_viewport") == 0;
825 bool isViewportChild = w->parent() && 825 bool isViewportChild = w->parent() &&
@@ -856,57 +856,57 @@ void LiquidStyle::polish(QWidget *w)
856 } 856 }
857 w-> installEventFilter ( this ); 857 w-> installEventFilter ( this );
858 } 858 }
859 if(w-> inherits("QToolBarSeparator")&&w->parent()->inherits("QToolBar")) { 859 if(w-> inherits("QToolBarSeparator")&&w->parent()->inherits("QToolBar")) {
860 ((QFrame *) w)-> setFrameShape ( QFrame::NoFrame ); 860 ((QFrame *) w)-> setFrameShape ( QFrame::NoFrame );
861 } 861 }
862 if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){ 862 if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){
863 return; 863 return;
864 } 864 }
865 865
866 if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())-> 866 if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())->
867 palette().active().brush(QColorGroup::Background).pixmap()){ 867 palette().active().brush(QColorGroup::Background).pixmap()){
868 owarn << "No parent pixmap for child widget " << w->className() << "" << oendl; 868 owarn << "No parent pixmap for child widget " << w->className() << "" << oendl;
869 return; 869 return;
870 } 870 }
871 if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) && 871 if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) &&
872 !( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) { 872 !( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) {
873 if(w->backgroundMode() == QWidget::PaletteBackground || 873 if(w->backgroundMode() == QWidget::PaletteBackground ||
874 w->backgroundMode() == QWidget::PaletteButton){ 874 w->backgroundMode() == QWidget::PaletteButton){
875 w->setBackgroundMode(w->parentWidget()->backgroundMode( )/*QWidget::X11ParentRelative*/); 875 w->setBackgroundMode(w->parentWidget()->backgroundMode( )/*QWidget::X11ParentRelative*/);
876 w->setBackgroundOrigin(QWidget::ParentOrigin); 876 w->setBackgroundOrigin(QWidget::ParentOrigin);
877 // w->setBackgroundMode(QWidget::NoBackground); 877 // w->setBackgroundMode(QWidget::NoBackground);
878 } 878 }
879 } 879 }
880 if ( !w-> inherits("QFrame") || (((QFrame*) w)-> frameShape () == QFrame::NoFrame )) 880 if ( !w-> inherits("QFrame") || (((QFrame*) w)-> frameShape () == QFrame::NoFrame ))
881 w-> setBackgroundOrigin ( QWidget::ParentOrigin ); 881 w-> setBackgroundOrigin ( QWidget::ParentOrigin );
882 else if ( w-> inherits("QFrame") ) 882 else if ( w-> inherits("QFrame") )
883 w->setBackgroundOrigin ( QWidget::WidgetOrigin ); 883 w->setBackgroundOrigin ( QWidget::WidgetOrigin );
884 884
885 if ( w->parentWidget()->inherits ( "QWidgetStack" )) { 885 if ( w->parentWidget()->inherits ( "QWidgetStack" )) {
886 w->setBackgroundOrigin ( QWidget::WidgetOrigin ); 886 w->setBackgroundOrigin ( QWidget::WidgetOrigin );
887 } 887 }
888} 888}
889 889
890void LiquidStyle::unPolish(QWidget *w) 890void LiquidStyle::unPolish(QWidget *w)
891{ 891{
892 if(w->inherits("QMenuBar")){ 892 if(w->inherits("QMenuBar")){
893 ((QFrame *)w)->setLineWidth(1); 893 ((QFrame *)w)->setLineWidth(1);
894 w->setBackgroundMode(QWidget::PaletteBackground); 894 w->setBackgroundMode(QWidget::PaletteBackground);
895 return; 895 return;
896 } 896 }
897 897
898 if(w->inherits("QPopupMenu")) 898 if(w->inherits("QPopupMenu"))
899 w->setBackgroundMode(QWidget::PaletteButton); 899 w->setBackgroundMode(QWidget::PaletteButton);
900 else if(w-> testWFlags(Qt::WType_Popup) && 900 else if(w-> testWFlags(Qt::WType_Popup) &&
901 !w->inherits("QListBox") && 901 !w->inherits("QListBox") &&
902 ( qstrcmp ( w-> name(), "automatic what's this? widget" ) != 0 )) { 902 ( qstrcmp ( w-> name(), "automatic what's this? widget" ) != 0 )) {
903 w->removeEventFilter(menuHandler); 903 w->removeEventFilter(menuHandler);
904 } 904 }
905 905
906 if(w->isTopLevel()) 906 if(w->isTopLevel())
907 return; 907 return;
908 908
909 // for viewport children, don't just check for NoBackground.... 909 // for viewport children, don't just check for NoBackground....
910 bool isViewportChild = w->parent() && 910 bool isViewportChild = w->parent() &&
911 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || 911 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) ||
912 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); 912 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0));
@@ -950,63 +950,63 @@ void LiquidStyle::unPolish(QWidget *w)
950} 950}
951 951
952void LiquidStyle::polish(QApplication *app) 952void LiquidStyle::polish(QApplication *app)
953{ 953{
954 954
955 QWindowsStyle::polish(app); 955 QWindowsStyle::polish(app);
956 menuAni = app->isEffectEnabled(UI_AnimateMenu); 956 menuAni = app->isEffectEnabled(UI_AnimateMenu);
957 menuFade = app->isEffectEnabled(UI_FadeMenu); 957 menuFade = app->isEffectEnabled(UI_FadeMenu);
958 if(menuAni) 958 if(menuAni)
959 app->setEffectEnabled(UI_AnimateMenu, false); 959 app->setEffectEnabled(UI_AnimateMenu, false);
960 if(menuFade) 960 if(menuFade)
961 app->setEffectEnabled(UI_FadeMenu, false); 961 app->setEffectEnabled(UI_FadeMenu, false);
962 962
963 qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &LiquidStyle::drawMenuBarItem); 963 qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &LiquidStyle::drawMenuBarItem);
964 964
965 Config config ( "qpe" ); 965 Config config ( "qpe" );
966 config. setGroup ( "Liquid-Style" ); 966 config. setGroup ( "Liquid-Style" );
967 967
968 // if ( config. readBoolEntry ( "WinDecoration", true )) 968// if ( config. readBoolEntry ( "WinDecoration", true ))
969 // QApplication::qwsSetDecoration ( new LiquidDecoration ( )); 969 // QApplication::qwsSetDecoration ( new LiquidDecoration ( ));
970 970
971 flatTBButtons = config. readBoolEntry ( "FlatToolButtons", false ); 971 flatTBButtons = config. readBoolEntry ( "FlatToolButtons", false );
972} 972}
973 973
974void LiquidStyle::unPolish(QApplication *app) 974void LiquidStyle::unPolish(QApplication *app)
975{ 975{
976 QWindowsStyle::unPolish(app); 976 QWindowsStyle::unPolish(app);
977 app->setEffectEnabled(UI_AnimateMenu, menuAni); 977 app->setEffectEnabled(UI_AnimateMenu, menuAni);
978 app->setEffectEnabled(UI_FadeMenu, menuFade); 978 app->setEffectEnabled(UI_FadeMenu, menuFade);
979 979
980 qt_set_draw_menu_bar_impl ( 0 ); 980 qt_set_draw_menu_bar_impl ( 0 );
981 981
982// QApplication::qwsSetDecoration ( new QPEDecoration ( )); 982// QApplication::qwsSetDecoration ( new QPEDecoration ( ));
983} 983}
984 984
985 985
986/* !! HACK !! Beware 986/* !! HACK !! Beware
987 * 987 *
988 * TT forgot to make the QProgressBar widget styleable in Qt 2.x 988 * TT forgot to make the QProgressBar widget styleable in Qt 2.x
989 * So the only way to customize the drawing, is to intercept the 989 * So the only way to customize the drawing, is to intercept the
990 * paint event - since we have to use protected functions, we need 990 * paint event - since we have to use protected functions, we need
991 * to derive a "hack" class from QProgressBar and do the painting 991 * to derive a "hack" class from QProgressBar and do the painting
992 * in there. 992 * in there.
993 * 993 *
994 * - sandman 994 * - sandman
995 */ 995 */
996 996
997class HackProgressBar : public QProgressBar { 997class HackProgressBar : public QProgressBar {
998public: 998public:
999 HackProgressBar ( ); 999 HackProgressBar ( );
1000 1000
1001 void paint ( QPaintEvent *event, const QColorGroup &g, QPixmap *pix ) 1001 void paint ( QPaintEvent *event, const QColorGroup &g, QPixmap *pix )
1002 { 1002 {
1003 QPainter p( this ); 1003 QPainter p( this );
1004 1004
1005 if ( !contentsRect().contains( event->rect() ) ) { 1005 if ( !contentsRect().contains( event->rect() ) ) {
1006 p.save(); 1006 p.save();
1007 p.setClipRegion( event->region().intersect(frameRect()) ); 1007 p.setClipRegion( event->region().intersect(frameRect()) );
1008 drawFrame( &p); 1008 drawFrame( &p);
1009 p.restore(); 1009 p.restore();
1010 } 1010 }
1011 if ( event->rect().intersects( contentsRect() )) { 1011 if ( event->rect().intersects( contentsRect() )) {
1012 p.setClipRegion( event->region().intersect( contentsRect() ) ); 1012 p.setClipRegion( event->region().intersect( contentsRect() ) );
@@ -1022,48 +1022,48 @@ public:
1022 total = 1; 1022 total = 1;
1023 int bw = w * prog / total; 1023 int bw = w * prog / total;
1024 if ( bw > w ) 1024 if ( bw > w )
1025 bw = w; 1025 bw = w;
1026 1026
1027 p.setPen(g.button().dark(130)); 1027 p.setPen(g.button().dark(130));
1028 p.drawRect(x, y, bw, h); 1028 p.drawRect(x, y, bw, h);
1029 p.setPen(g.button().light(120)); 1029 p.setPen(g.button().light(120));
1030 p.drawRect(x+1, y+1, bw-2, h-2); 1030 p.drawRect(x+1, y+1, bw-2, h-2);
1031 1031
1032 if(bw >= 4 && h >= 4 && pix) 1032 if(bw >= 4 && h >= 4 && pix)
1033 p.drawTiledPixmap(x+2, y+2, bw-4, h-4, *pix); 1033 p.drawTiledPixmap(x+2, y+2, bw-4, h-4, *pix);
1034 1034
1035 if ( progress ( )>= 0 && totalSteps ( ) > 0 ) { 1035 if ( progress ( )>= 0 && totalSteps ( ) > 0 ) {
1036 QString pstr; 1036 QString pstr;
1037 pstr. sprintf ( "%d%%", 100 * progress()/totalSteps ()); 1037 pstr. sprintf ( "%d%%", 100 * progress()/totalSteps ());
1038 p. setPen ( g.text());//g.highlightedText ( )); 1038 p. setPen ( g.text());//g.highlightedText ( ));
1039 p. drawText (x,y,w-1,h-1,AlignCenter,pstr); 1039 p. drawText (x,y,w-1,h-1,AlignCenter,pstr);
1040 } 1040 }
1041 } 1041 }
1042 } 1042 }
1043}; 1043};
1044 1044
1045 1045
1046/* 1046/*
1047 * The same for QToolButton: 1047 * The same for QToolButton:
1048 * TT hardcoded the drawing of the focus rect ... 1048 * TT hardcoded the drawing of the focus rect ...
1049 * 1049 *
1050 * - sandman 1050 * - sandman
1051 */ 1051 */
1052 1052
1053 1053
1054class HackToolButton : public QToolButton { 1054class HackToolButton : public QToolButton {
1055public: 1055public:
1056 HackToolButton ( ); 1056 HackToolButton ( );
1057 1057
1058 void paint ( QPaintEvent *ev ) 1058 void paint ( QPaintEvent *ev )
1059 { 1059 {
1060 erase ( ev-> region ( )); 1060 erase ( ev-> region ( ));
1061 QPainter p ( this ); 1061 QPainter p ( this );
1062 style ( ). drawToolButton ( this, &p ); 1062 style ( ). drawToolButton ( this, &p );
1063 drawButtonLabel ( &p ); 1063 drawButtonLabel ( &p );
1064 } 1064 }
1065}; 1065};
1066 1066
1067/* 1067/*
1068 * This is a fun method ;-) Here's an overview. KToolBar grabs resize to 1068 * This is a fun method ;-) Here's an overview. KToolBar grabs resize to
1069 * force everything to erase and repaint on resize. This is going away, I'm 1069 * force everything to erase and repaint on resize. This is going away, I'm
@@ -1089,25 +1089,25 @@ bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev)
1089 QObjectListIt it(*tbChildList); 1089 QObjectListIt it(*tbChildList);
1090 QObject *child; 1090 QObject *child;
1091 while((child = it.current()) != NULL){ 1091 while((child = it.current()) != NULL){
1092 ++it; 1092 ++it;
1093 if(child->isWidgetType()) 1093 if(child->isWidgetType())
1094 ((QWidget *)child)->repaint(true); 1094 ((QWidget *)child)->repaint(true);
1095 } 1095 }
1096 1096
1097 } 1097 }
1098 } 1098 }
1099 else if(obj->inherits("QToolButton")){ 1099 else if(obj->inherits("QToolButton")){
1100 QToolButton *btn = (QToolButton *)obj; 1100 QToolButton *btn = (QToolButton *)obj;
1101 if(ev->type() == QEvent::FocusIn ){ // && !btn-> autoRaise () 1101 if(ev->type() == QEvent::FocusIn ){ // && !btn-> autoRaise ()
1102 if(btn->isEnabled()){ 1102 if(btn->isEnabled()){
1103 highlightWidget = btn; 1103 highlightWidget = btn;
1104 btn->repaint(false); 1104 btn->repaint(false);
1105 } 1105 }
1106 } 1106 }
1107 else if(ev->type() == QEvent::FocusOut ){ 1107 else if(ev->type() == QEvent::FocusOut ){
1108 if(btn == highlightWidget){ 1108 if(btn == highlightWidget){
1109 highlightWidget = NULL; 1109 highlightWidget = NULL;
1110 btn->repaint(false); 1110 btn->repaint(false);
1111 } 1111 }
1112 } 1112 }
1113 else if(ev->type() == QEvent::Paint) { 1113 else if(ev->type() == QEvent::Paint) {
@@ -1129,25 +1129,25 @@ bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev)
1129 : indicatorSize(); 1129 : indicatorSize();
1130 1130
1131/* 1131/*
1132 if(btn->hasFocus()){ 1132 if(btn->hasFocus()){
1133 QRect r = QRect(0, 0, btn->width(), btn->height()); 1133 QRect r = QRect(0, 0, btn->width(), btn->height());
1134 p.setPen(btn->colorGroup().button().dark(140)); 1134 p.setPen(btn->colorGroup().button().dark(140));
1135 p.drawLine(r.x()+1, r.y(), r.right()-1, r.y()); 1135 p.drawLine(r.x()+1, r.y(), r.right()-1, r.y());
1136 p.drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); 1136 p.drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1);
1137 p.drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); 1137 p.drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1);
1138 p.drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); 1138 p.drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom());
1139 } 1139 }
1140*/ 1140*/
1141 int x = 0; 1141 int x = 0;
1142 int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; 1142 int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2;
1143 if(isRadio) 1143 if(isRadio)
1144 drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), 1144 drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(),
1145 btn->colorGroup(), btn->isOn(), 1145 btn->colorGroup(), btn->isOn(),
1146 btn->isDown(), btn->isEnabled()); 1146 btn->isDown(), btn->isEnabled());
1147 else 1147 else
1148 drawIndicator(&p, x, y, sz.width(), sz.height(), 1148 drawIndicator(&p, x, y, sz.width(), sz.height(),
1149 btn->colorGroup(), btn->state(), btn->isDown(), 1149 btn->colorGroup(), btn->state(), btn->isDown(),
1150 btn->isEnabled()); 1150 btn->isEnabled());
1151 x = sz.width() + 6; 1151 x = sz.width() + 6;
1152 y = 0; 1152 y = 0;
1153 drawItem(&p, sz.width()+6+1, 0, btn->width()-(sz.width()+6+1), 1153 drawItem(&p, sz.width()+6+1, 0, btn->width()-(sz.width()+6+1),
@@ -1184,37 +1184,37 @@ bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev)
1184 } 1184 }
1185 if(headerHoverID != -1){ 1185 if(headerHoverID != -1){
1186 hw->repaint(hw->sectionPos(headerHoverID), 0, 1186 hw->repaint(hw->sectionPos(headerHoverID), 0,
1187 hw->sectionSize(headerHoverID), hw->height()); 1187 hw->sectionSize(headerHoverID), hw->height());
1188 } 1188 }
1189 } 1189 }
1190 } 1190 }
1191 } 1191 }
1192 else if (obj-> inherits( "QProgressBar" )) { 1192 else if (obj-> inherits( "QProgressBar" )) {
1193 if ( ev->type() == QEvent::Paint ) { 1193 if ( ev->type() == QEvent::Paint ) {
1194 HackProgressBar *p = (HackProgressBar *) obj; 1194 HackProgressBar *p = (HackProgressBar *) obj;
1195 const QColorGroup &g = p-> colorGroup ( ); 1195 const QColorGroup &g = p-> colorGroup ( );
1196 1196
1197 QPixmap *pix = bevelFillDict.find(g.button().dark(120).rgb()); 1197 QPixmap *pix = bevelFillDict.find(g.button().dark(120).rgb());
1198 if(!pix){ 1198 if(!pix){
1199 int h, s, v; 1199 int h, s, v;
1200 g.button().dark(120).hsv(&h, &s, &v); 1200 g.button().dark(120).hsv(&h, &s, &v);
1201 pix = new QPixmap(*bevelFillPix); 1201 pix = new QPixmap(*bevelFillPix);
1202 adjustHSV(*pix, h, s, v); 1202 adjustHSV(*pix, h, s, v);
1203 bevelFillDict.insert(g.button().dark(120).rgb(), pix); 1203 bevelFillDict.insert(g.button().dark(120).rgb(), pix);
1204 } 1204 }
1205 p-> paint ((QPaintEvent *) ev, g, pix ); 1205 p-> paint ((QPaintEvent *) ev, g, pix );
1206 return true; 1206 return true;
1207 } 1207 }
1208 } 1208 }
1209 return false ; 1209 return false ;
1210} 1210}
1211 1211
1212void LiquidStyle::drawButton(QPainter *p, int x, int y, int w, int h, 1212void LiquidStyle::drawButton(QPainter *p, int x, int y, int w, int h,
1213 const QColorGroup &g, bool sunken, 1213 const QColorGroup &g, bool sunken,
1214 const QBrush *) 1214 const QBrush *)
1215{ 1215{
1216 drawRoundButton(p, sunken ? g.background() : g.button(), g.background(), 1216 drawRoundButton(p, sunken ? g.background() : g.button(), g.background(),
1217 x, y, w, h); 1217 x, y, w, h);
1218} 1218}
1219 1219
1220void LiquidStyle::drawToolButton(QPainter *p, int x, int y, int w, int h, 1220void LiquidStyle::drawToolButton(QPainter *p, int x, int y, int w, int h,
@@ -1294,33 +1294,37 @@ void LiquidStyle::drawPushButtonLabel(QPushButton *btn, QPainter *p)
1294 bool act = btn->isOn() || btn->isDown(); 1294 bool act = btn->isOn() || btn->isDown();
1295 if(act){ 1295 if(act){
1296 ++x1, ++y1; 1296 ++x1, ++y1;
1297 } 1297 }
1298 1298
1299 // Draw iconset first, if any 1299 // Draw iconset first, if any
1300 if ( btn->iconSet() && !btn->iconSet()->isNull() ) 1300 if ( btn->iconSet() && !btn->iconSet()->isNull() )
1301 { 1301 {
1302 QIconSet::Mode mode = btn->isEnabled() 1302 QIconSet::Mode mode = btn->isEnabled()
1303 ? QIconSet::Normal : QIconSet::Disabled; 1303 ? QIconSet::Normal : QIconSet::Disabled;
1304 if ( mode == QIconSet::Normal && btn->hasFocus() ) 1304 if ( mode == QIconSet::Normal && btn->hasFocus() )
1305 mode = QIconSet::Active; 1305 mode = QIconSet::Active;
1306 QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small, mode ); 1306 QPixmap pixmap;
1307 if ( mode == QIconSet::Disabled )
1308 pixmap = btn->iconSet()->pixmap( QIconSet::Automatic, mode );
1309 else
1310 pixmap = btn->iconSet()->pixmap();
1307 int pixw = pixmap.width(); 1311 int pixw = pixmap.width();
1308 int pixh = pixmap.height(); 1312 int pixh = pixmap.height();
1309 1313
1310 p->drawPixmap( x1+6, y1+h/2-pixh/2, pixmap ); 1314 p->drawPixmap( x1+6, y1+h/2-pixh/2, pixmap );
1311 x1 += pixw + 8; 1315 x1 += pixw + 8;
1312 w -= pixw + 8; 1316 w -= pixw + 8;
1313 } 1317 }
1314 1318
1315 if(act){ 1319 if(act){
1316 QFont font = btn->font(); 1320 QFont font = btn->font();
1317 font.setBold(true); 1321 font.setBold(true);
1318 p->setFont(font); 1322 p->setFont(font);
1319 QColor shadow(btn->colorGroup().button().dark(130)); 1323 QColor shadow(btn->colorGroup().button().dark(130));
1320 drawItem( p, x1+1, y1+1, w, h, 1324 drawItem( p, x1+1, y1+1, w, h,
1321 AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), 1325 AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(),
1322 btn->pixmap(), btn->text(), -1, 1326 btn->pixmap(), btn->text(), -1,
1323 &shadow); 1327 &shadow);
1324 1328
1325 drawItem( p, x1, y1, w, h, 1329 drawItem( p, x1, y1, w, h,
1326 AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), 1330 AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(),
@@ -1396,37 +1400,37 @@ QRect LiquidStyle::buttonRect(int x, int y, int w, int h)
1396} 1400}
1397 1401
1398void LiquidStyle::drawComboButton(QPainter *painter, int x, int y, int w, int h, 1402void LiquidStyle::drawComboButton(QPainter *painter, int x, int y, int w, int h,
1399 const QColorGroup &g, bool sunken, 1403 const QColorGroup &g, bool sunken,
1400 bool edit, bool, const QBrush *) 1404 bool edit, bool, const QBrush *)
1401{ 1405{
1402 bool isActive = false; 1406 bool isActive = false;
1403 if (( painter->device()->devType() == QInternal::Widget ) && 1407 if (( painter->device()->devType() == QInternal::Widget ) &&
1404 ( 1408 (
1405 ( qApp-> focusWidget ( ) == painter-> device ( )) || 1409 ( qApp-> focusWidget ( ) == painter-> device ( )) ||
1406 ( 1410 (
1407 edit && 1411 edit &&
1408 ((QWidget *) painter-> device ( ))-> inherits ( "QComboBox" ) && 1412 ((QWidget *) painter-> device ( ))-> inherits ( "QComboBox" ) &&
1409 ( qApp-> focusWidget ( ) == ((QComboBox *) painter->device())->lineEdit ( ) || 1413 ( qApp-> focusWidget ( ) == ((QComboBox *) painter->device())->lineEdit ( ) ||
1410 qApp-> focusWidget ( ) == ((QComboBox *) painter->device())->listBox ( )) 1414 qApp-> focusWidget ( ) == ((QComboBox *) painter->device())->listBox ( ))
1411 ) 1415 )
1412 ) 1416 )
1413 ) { 1417 ) {
1414 isActive = true; 1418 isActive = true;
1415 } 1419 }
1416 1420
1417 bool isMasked = false; 1421 bool isMasked = false;
1418 if(painter->device()->devType() == QInternal::Widget) 1422 if(painter->device()->devType() == QInternal::Widget)
1419 isMasked = ((QWidget*)painter->device())->autoMask(); 1423 isMasked = ((QWidget*)painter->device())->autoMask();
1420 // TODO: Do custom code, don't just call drawRoundButton into a pixmap 1424 // TODO: Do custom code, don't just call drawRoundButton into a pixmap
1421 QPixmap tmpPix(w, h); 1425 QPixmap tmpPix(w, h);
1422 QPainter p(&tmpPix); 1426 QPainter p(&tmpPix);
1423 1427
1424 drawRoundButton(&p, g.button(), g.background(), 0, 0, w, h, false, 1428 drawRoundButton(&p, g.button(), g.background(), 0, 0, w, h, false,
1425 sunken, false, isMasked); 1429 sunken, false, isMasked);
1426 if(!isActive){ 1430 if(!isActive){
1427 p.setClipRect(0, 0, w-17, h); 1431 p.setClipRect(0, 0, w-17, h);
1428 drawRoundButton(&p, g.background(), g.background(), 0, 0, w, h, false, 1432 drawRoundButton(&p, g.background(), g.background(), 0, 0, w, h, false,
1429 sunken, false, isMasked); 1433 sunken, false, isMasked);
1430 } 1434 }
1431 p.end(); 1435 p.end();
1432 int x2 = x+w-1; 1436 int x2 = x+w-1;
@@ -1469,25 +1473,25 @@ void LiquidStyle::drawComboButtonMask(QPainter *p, int x, int y, int w, int h)
1469 drawButtonMask(p, x, y, w, h); 1473 drawButtonMask(p, x, y, w, h);
1470} 1474}
1471 1475
1472QRect LiquidStyle::comboButtonRect(int x, int y, int w, int h) 1476QRect LiquidStyle::comboButtonRect(int x, int y, int w, int h)
1473{ 1477{
1474 //return(QRect(x+3, y+3, w - (h / 3) - 13, h-6)); 1478 //return(QRect(x+3, y+3, w - (h / 3) - 13, h-6));
1475 return(QRect(x+9, y+3, w - (h / 3) - 20, h-6)); 1479 return(QRect(x+9, y+3, w - (h / 3) - 20, h-6));
1476} 1480}
1477 1481
1478QRect LiquidStyle::comboButtonFocusRect(int /*x*/, int /*y*/, int /*w*/, int /*h*/) 1482QRect LiquidStyle::comboButtonFocusRect(int /*x*/, int /*y*/, int /*w*/, int /*h*/)
1479{ 1483{
1480 return QRect ( ); 1484 return QRect ( );
1481 1485
1482// return(QRect(x+5, y+3, w-(h/3)-13, h-5)); 1486// return(QRect(x+5, y+3, w-(h/3)-13, h-5));
1483} 1487}
1484 1488
1485void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb, 1489void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb,
1486 int sliderStart, uint controls, 1490 int sliderStart, uint controls,
1487 uint activeControl) 1491 uint activeControl)
1488{ 1492{
1489 int sliderMin, sliderMax, sliderLength, buttonDim; 1493 int sliderMin, sliderMax, sliderLength, buttonDim;
1490 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); 1494 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
1491 1495
1492 if (sliderStart > sliderMax) 1496 if (sliderStart > sliderMax)
1493 sliderStart = sliderMax; 1497 sliderStart = sliderMax;
@@ -1624,40 +1628,40 @@ void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb,
1624 painter.setPen(g.mid()); 1628 painter.setPen(g.mid());
1625 painter.drawPoint(bgR.x(), bgR.y()+1); 1629 painter.drawPoint(bgR.x(), bgR.y()+1);
1626 painter.drawPoint(bgR.x(), bgR.bottom()-1); 1630 painter.drawPoint(bgR.x(), bgR.bottom()-1);
1627 painter.drawPoint(bgR.right()-1, bgR.y()+1); 1631 painter.drawPoint(bgR.right()-1, bgR.y()+1);
1628 painter.drawPoint(bgR.right()-1, bgR.bottom()-1); 1632 painter.drawPoint(bgR.right()-1, bgR.bottom()-1);
1629 } 1633 }
1630 if(controls & Slider){ 1634 if(controls & Slider){
1631 if(sliderR.width() >= 16){ 1635 if(sliderR.width() >= 16){
1632 painter.drawPixmap(sliderR.x(), sliderR.y()+1, 1636 painter.drawPixmap(sliderR.x(), sliderR.y()+1,
1633 *getPixmap(HSBSliderTop)); 1637 *getPixmap(HSBSliderTop));
1634 painter.drawTiledPixmap(sliderR.x()+8, sliderR.y()+1, sliderR.width()-16, 1638 painter.drawTiledPixmap(sliderR.x()+8, sliderR.y()+1, sliderR.width()-16,
1635 13, *getPixmap(HSBSliderMid)); 1639 13, *getPixmap(HSBSliderMid));
1636 painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, 1640 painter.drawPixmap(sliderR.right()-8, sliderR.y()+1,
1637 *getPixmap(HSBSliderBtm)); 1641 *getPixmap(HSBSliderBtm));
1638 } 1642 }
1639 else if(sliderR.width() >= 8){ 1643 else if(sliderR.width() >= 8){
1640 int m = sliderR.width()/2; 1644 int m = sliderR.width()/2;
1641 painter.drawPixmap(sliderR.x(), sliderR.y()+1, 1645 painter.drawPixmap(sliderR.x(), sliderR.y()+1,
1642 *getPixmap(HSBSliderTop), 0, 0, m, 13); 1646 *getPixmap(HSBSliderTop), 0, 0, m, 13);
1643 painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, 1647 painter.drawPixmap(sliderR.right()-8, sliderR.y()+1,
1644 *getPixmap(HSBSliderBtm), 8-m, 0, m, 13); 1648 *getPixmap(HSBSliderBtm), 8-m, 0, m, 13);
1645 } 1649 }
1646 else{ 1650 else{
1647 painter.setPen(g.button().dark(210)); 1651 painter.setPen(g.button().dark(210));
1648 drawRoundRect(&painter, sliderR.x(), sliderR.y()+1, 1652 drawRoundRect(&painter, sliderR.x(), sliderR.y()+1,
1649 sliderR.width(), 13); 1653 sliderR.width(), 13);
1650 painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+2, 1654 painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+2,
1651 sliderR.width()-2, 11, 1655 sliderR.width()-2, 11,
1652 *getPixmap(HSBSliderMid), 0, 1); 1656 *getPixmap(HSBSliderMid), 0, 1);
1653 } 1657 }
1654 } 1658 }
1655 painter.setPen(g.mid()); 1659 painter.setPen(g.mid());
1656 painter.drawLine(bgR.x(), bgR.y(), bgR.right(), bgR.y()); 1660 painter.drawLine(bgR.x(), bgR.y(), bgR.right(), bgR.y());
1657 painter.drawLine(bgR.x(), bgR.bottom(), bgR.right(), bgR.bottom()); 1661 painter.drawLine(bgR.x(), bgR.bottom(), bgR.right(), bgR.bottom());
1658 if(brokenApp && (controls & Slider)){ 1662 if(brokenApp && (controls & Slider)){
1659 painter.setPen(g.background()); 1663 painter.setPen(g.background());
1660 painter.drawLine(bgR.x(), bgR.bottom()-1, bgR.right(), 1664 painter.drawLine(bgR.x(), bgR.bottom()-1, bgR.right(),
1661 bgR.bottom()-1); 1665 bgR.bottom()-1);
1662 } 1666 }
1663 painter.end(); 1667 painter.end();
@@ -1967,48 +1971,48 @@ void LiquidStyle::drawArrow(QPainter *p, Qt::ArrowType type, bool on, int x,
1967 default: 1971 default:
1968 a.setPoints(QCOORDARRLEN(r_arrow), r_arrow); 1972 a.setPoints(QCOORDARRLEN(r_arrow), r_arrow);
1969 break; 1973 break;
1970 } 1974 }
1971 1975
1972 a.translate(x, y); 1976 a.translate(x, y);
1973 p->drawLineSegments(a); 1977 p->drawLineSegments(a);
1974} 1978}
1975 1979
1976 1980
1977void LiquidStyle::drawMenuBarItem(QPainter *p, int x, int y, int w, int h, 1981void LiquidStyle::drawMenuBarItem(QPainter *p, int x, int y, int w, int h,
1978 QMenuItem *mi, QColorGroup &g, bool /*enabled*/, bool active ) 1982 QMenuItem *mi, QColorGroup &g, bool /*enabled*/, bool active )
1979 { 1983{
1980 if(active){ 1984 if(active){
1981 x -= 2; // Bug in Qt/E 1985 x -= 2; // Bug in Qt/E
1982 y -= 2; 1986 y -= 2;
1983 w += 2; 1987 w += 2;
1984 h += 2; 1988 h += 2;
1985 } 1989 }
1986 1990
1987 QWidget *parent = (QWidget *)p->device(); 1991 QWidget *parent = (QWidget *)p->device();
1988 p->setBrushOrigin(parent->pos()); 1992 p->setBrushOrigin(parent->pos());
1989 parent->erase(x, y, w, h); 1993 parent->erase(x, y, w, h);
1990 1994
1991 if(menuHandler->useShadowText()){ 1995 if(menuHandler->useShadowText()){
1992 QColor shadow; 1996 QColor shadow;
1993 if(p->device() && p->device()->devType() == QInternal::Widget && 1997 if(p->device() && p->device()->devType() == QInternal::Widget &&
1994 ((QWidget *)p->device())->inherits("QMenuBar")){ 1998 ((QWidget *)p->device())->inherits("QMenuBar")){
1995 shadow = ((QMenuBar*)p->device())->isTopLevel() ? g.button().dark(130) : 1999 shadow = ((QMenuBar*)p->device())->isTopLevel() ? g.button().dark(130) :
1996 g.background().dark(130); 2000 g.background().dark(130);
1997 } 2001 }
1998 else 2002 else
1999 shadow = g.background().dark(130); 2003 shadow = g.background().dark(130);
2000 2004
2001 QPixmap *dummy = 0; 2005 QPixmap *dummy = 0;
2002 2006
2003 if ( mi-> pixmap ( ) && !mi-> pixmap ( )-> isNull ( )) { 2007 if ( mi-> pixmap ( ) && !mi-> pixmap ( )-> isNull ( )) {
2004 dummy = new QPixmap ( mi-> pixmap ( )-> size ( )); 2008 dummy = new QPixmap ( mi-> pixmap ( )-> size ( ));
2005 QBitmap dummy_mask ( dummy-> size ( )); 2009 QBitmap dummy_mask ( dummy-> size ( ));
2006 dummy_mask. fill ( color1 ); 2010 dummy_mask. fill ( color1 );
2007 dummy-> setMask ( dummy_mask ); 2011 dummy-> setMask ( dummy_mask );
2008 } 2012 }
2009 2013
2010 if(active){ 2014 if(active){
2011 drawClearBevel(p, x+1, y+1, w-1, h-1, g.button(), g.background()); 2015 drawClearBevel(p, x+1, y+1, w-1, h-1, g.button(), g.background());
2012 QApplication::style().drawItem(p, x+1, y+1, w, h, 2016 QApplication::style().drawItem(p, x+1, y+1, w, h,
2013 AlignCenter|ShowPrefix|DontClip|SingleLine, 2017 AlignCenter|ShowPrefix|DontClip|SingleLine,
2014 g, mi->isEnabled(), dummy, mi->text(), 2018 g, mi->isEnabled(), dummy, mi->text(),
@@ -2146,25 +2150,29 @@ static const int windowsRightBorder = 12;
2146 c = menuHandler->bgColor(); 2150 c = menuHandler->bgColor();
2147 } 2151 }
2148 p->setPen(c.dark(140)); 2152 p->setPen(c.dark(140));
2149 p->drawLine(x, y, x+w, y ); 2153 p->drawLine(x, y, x+w, y );
2150 p->setPen(c.light(115)); 2154 p->setPen(c.light(115));
2151 p->drawLine(x, y+1, x+w, y+1 ); 2155 p->drawLine(x, y+1, x+w, y+1 );
2152 return; 2156 return;
2153 } 2157 }
2154 if(mi->iconSet()) { 2158 if(mi->iconSet()) {
2155 QIconSet::Mode mode = dis? QIconSet::Disabled : QIconSet::Normal; 2159 QIconSet::Mode mode = dis? QIconSet::Disabled : QIconSet::Normal;
2156 if (!dis) 2160 if (!dis)
2157 mode = QIconSet::Active; 2161 mode = QIconSet::Active;
2158 QPixmap pixmap = mi->iconSet()->pixmap(QIconSet::Small, mode); 2162 QPixmap pixmap;
2163 if ( mode == QIconSet::Disabled )
2164 pixmap = mi->iconSet()->pixmap( QIconSet::Automatic, mode );
2165 else
2166 pixmap = mi->iconSet()->pixmap();
2159 int pixw = pixmap.width(); 2167 int pixw = pixmap.width();
2160 int pixh = pixmap.height(); 2168 int pixh = pixmap.height();
2161 QRect cr(x, y, checkcol, h); 2169 QRect cr(x, y, checkcol, h);
2162 QRect pmr(0, 0, pixw, pixh); 2170 QRect pmr(0, 0, pixw, pixh);
2163 pmr.moveCenter( cr.center() ); 2171 pmr.moveCenter( cr.center() );
2164 p->setPen(itemg.highlightedText()); 2172 p->setPen(itemg.highlightedText());
2165 p->drawPixmap(pmr.topLeft(), pixmap ); 2173 p->drawPixmap(pmr.topLeft(), pixmap );
2166 2174
2167 } 2175 }
2168 else if(checkable) { 2176 else if(checkable) {
2169 int mw = checkcol + motifItemFrame; 2177 int mw = checkcol + motifItemFrame;
2170 int mh = h - 2*motifItemFrame; 2178 int mh = h - 2*motifItemFrame;
@@ -2227,26 +2235,25 @@ static const int windowsRightBorder = 12;
2227 2235
2228int LiquidStyle::popupMenuItemHeight(bool /*checkable*/, QMenuItem *mi, 2236int LiquidStyle::popupMenuItemHeight(bool /*checkable*/, QMenuItem *mi,
2229 const QFontMetrics &fm) 2237 const QFontMetrics &fm)
2230{ 2238{
2231 if (mi->isSeparator()) 2239 if (mi->isSeparator())
2232 return 2; 2240 return 2;
2233 2241
2234 int h = 0; 2242 int h = 0;
2235 if (mi->pixmap()) 2243 if (mi->pixmap())
2236 h = mi->pixmap()->height(); 2244 h = mi->pixmap()->height();
2237 2245
2238 if (mi->iconSet()) 2246 if (mi->iconSet())
2239 h = QMAX(mi->iconSet()-> 2247 h = QMAX(mi->iconSet()->pixmap().height(), h);
2240 pixmap(QIconSet::Small, QIconSet::Normal).height(), h);
2241 2248
2242 h = QMAX(fm.height() + 4, h); 2249 h = QMAX(fm.height() + 4, h);
2243 2250
2244 // we want a minimum size of 18 2251 // we want a minimum size of 18
2245 h = QMAX(h, 18); 2252 h = QMAX(h, 18);
2246 2253
2247 return h; 2254 return h;
2248} 2255}
2249 2256
2250 2257
2251void LiquidStyle::drawFocusRect(QPainter *p, const QRect &r, 2258void LiquidStyle::drawFocusRect(QPainter *p, const QRect &r,
2252 const QColorGroup &g, const QColor *c, 2259 const QColorGroup &g, const QColor *c,
@@ -2421,25 +2428,25 @@ void LiquidStyle::drawPanel(QPainter *p, int x, int y, int w, int h,
2421 else if(lineWidth != 2 || !sunken) 2428 else if(lineWidth != 2 || !sunken)
2422 QWindowsStyle::drawPanel(p, x, y, w, h, g, sunken, lineWidth, fill); 2429 QWindowsStyle::drawPanel(p, x, y, w, h, g, sunken, lineWidth, fill);
2423 else{ 2430 else{
2424 QPen oldPen = p->pen(); 2431 QPen oldPen = p->pen();
2425 int x2 = x+w-1; 2432 int x2 = x+w-1;
2426 int y2 = y+h-1; 2433 int y2 = y+h-1;
2427 p->setPen(g.light()); 2434 p->setPen(g.light());
2428 p->drawLine(x, y2, x2, y2); 2435 p->drawLine(x, y2, x2, y2);
2429 p->drawLine(x2, y, x2, y2); 2436 p->drawLine(x2, y, x2, y2);
2430 p->setPen(g.mid()); 2437 p->setPen(g.mid());
2431 p->drawLine(x, y, x2, y); 2438 p->drawLine(x, y, x2, y);
2432 p->drawLine(x, y, x, y2); 2439 p->drawLine(x, y, x, y2);
2433 2440
2434 p->setPen(g.midlight()); 2441 p->setPen(g.midlight());
2435 p->drawLine(x+1, y2-1, x2-1, y2-1); 2442 p->drawLine(x+1, y2-1, x2-1, y2-1);
2436 p->drawLine(x2-1, y+1, x2-1, y2-1); 2443 p->drawLine(x2-1, y+1, x2-1, y2-1);
2437 p->setPen(g.dark()); 2444 p->setPen(g.dark());
2438 p->drawLine(x+1, y+1, x2-1, y+1); 2445 p->drawLine(x+1, y+1, x2-1, y+1);
2439 p->drawLine(x+1, y+1, x+1, y2-1); 2446 p->drawLine(x+1, y+1, x+1, y2-1);
2440 p->setPen(oldPen); 2447 p->setPen(oldPen);
2441 if(fill){ 2448 if(fill){
2442 // I believe here we are only supposed to fill if there is a 2449 // I believe here we are only supposed to fill if there is a
2443 // specified fill brush... 2450 // specified fill brush...
2444 p->fillRect(x+2, y+2, w-4, h-4, *fill); 2451 p->fillRect(x+2, y+2, w-4, h-4, *fill);
2445 } 2452 }
@@ -2479,46 +2486,46 @@ void LiquidStyle::adjustHSV(QPixmap &pix, int h, int s, int v)
2479} 2486}
2480 2487
2481void LiquidStyle::intensity(QPixmap &pix, float percent) 2488void LiquidStyle::intensity(QPixmap &pix, float percent)
2482{ 2489{
2483 QImage image = pix.convertToImage(); 2490 QImage image = pix.convertToImage();
2484 int i, tmp, r, g, b; 2491 int i, tmp, r, g, b;
2485 int segColors = image.depth() > 8 ? 256 : image.numColors(); 2492 int segColors = image.depth() > 8 ? 256 : image.numColors();
2486 unsigned char *segTbl = new unsigned char[segColors]; 2493 unsigned char *segTbl = new unsigned char[segColors];
2487 int pixels = image.depth() > 8 ? image.width()*image.height() : 2494 int pixels = image.depth() > 8 ? image.width()*image.height() :
2488 image.numColors(); 2495 image.numColors();
2489 unsigned int *data = image.depth() > 8 ? (unsigned int *)image.bits() : 2496 unsigned int *data = image.depth() > 8 ? (unsigned int *)image.bits() :
2490 (unsigned int *)image.colorTable(); 2497 (unsigned int *)image.colorTable();
2491 2498
2492 bool brighten = (percent >= 0); 2499 bool brighten = (percent >= 0);
2493 if(percent < 0) 2500 if(percent < 0)
2494 percent = -percent; 2501 percent = -percent;
2495 2502
2496 if(brighten){ // keep overflow check out of loops 2503 if(brighten){ // keep overflow check out of loops
2497 for(i=0; i < segColors; ++i){ 2504 for(i=0; i < segColors; ++i){
2498 tmp = (int)(i*percent); 2505 tmp = (int)(i*percent);
2499 if(tmp > 255) 2506 if(tmp > 255)
2500 tmp = 255; 2507 tmp = 255;
2501 segTbl[i] = tmp; 2508 segTbl[i] = tmp;
2502 } 2509 }
2503 } 2510 }
2504 else{ 2511 else{
2505 for(i=0; i < segColors; ++i){ 2512 for(i=0; i < segColors; ++i){
2506 tmp = (int)(i*percent); 2513 tmp = (int)(i*percent);
2507 if(tmp < 0) 2514 if(tmp < 0)
2508 tmp = 0; 2515 tmp = 0;
2509 segTbl[i] = tmp; 2516 segTbl[i] = tmp;
2510 } 2517 }
2511 } 2518 }
2512 2519
2513 if(brighten){ // same here 2520 if(brighten){ // same here
2514 for(i=0; i < pixels; ++i){ 2521 for(i=0; i < pixels; ++i){
2515 r = qRed(data[i]); 2522 r = qRed(data[i]);
2516 g = qGreen(data[i]); 2523 g = qGreen(data[i]);
2517 b = qBlue(data[i]); 2524 b = qBlue(data[i]);
2518 r = r + segTbl[r] > 255 ? 255 : r + segTbl[r]; 2525 r = r + segTbl[r] > 255 ? 255 : r + segTbl[r];
2519 g = g + segTbl[g] > 255 ? 255 : g + segTbl[g]; 2526 g = g + segTbl[g] > 255 ? 255 : g + segTbl[g];
2520 b = b + segTbl[b] > 255 ? 255 : b + segTbl[b]; 2527 b = b + segTbl[b] > 255 ? 255 : b + segTbl[b];
2521 data[i] = qRgb(r, g, b); 2528 data[i] = qRgb(r, g, b);
2522 } 2529 }
2523 } 2530 }
2524 else{ 2531 else{