summaryrefslogtreecommitdiff
authorsandman <sandman>2002-10-06 20:54:49 (UTC)
committer sandman <sandman>2002-10-06 20:54:49 (UTC)
commite334186122e512a57bd27026014f01f501db93fc (patch) (unidiff)
tree218c24647dbf6ce15fda1d1ef987ab70e6964570
parente28318681d10236fe06cc478d329b4d000c2a48a (diff)
downloadopie-e334186122e512a57bd27026014f01f501db93fc.zip
opie-e334186122e512a57bd27026014f01f501db93fc.tar.gz
opie-e334186122e512a57bd27026014f01f501db93fc.tar.bz2
QProgressBar widget are now also painted in liquid style -- this is only
possible by intercepting the paint events, since TT forgot to make this widget styleable.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/styles/liquid/liquid.cpp88
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
@@ -1,129 +1,129 @@
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 6
7#ifndef INCLUDE_MENUITEM_DEF 7#ifndef INCLUDE_MENUITEM_DEF
8#define INCLUDE_MENUITEM_DEF 8#define INCLUDE_MENUITEM_DEF
9#endif 9#endif
10 10
11#include <qmenudata.h> 11#include <qmenudata.h>
12#include "liquid.h" 12#include "liquid.h"
13//#include "liquiddeco.h" 13//#include "liquiddeco.h"
14#include <qapplication.h> 14#include <qapplication.h>
15#include <qpe/config.h> 15#include <qpe/config.h>
16#include "effects.h" 16#include "effects.h"
17#include <qpalette.h> 17#include <qpalette.h>
18#include <qbitmap.h> 18#include <qbitmap.h>
19#include <qtabbar.h> 19#include <qtabbar.h>
20#include <qpopupmenu.h> 20#include <qpopupmenu.h>
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
40typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, 40typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *,
41 QColorGroup &, bool, bool); 41 QColorGroup &, bool, bool);
42 42
43QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl); 43QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl);
44 44
45void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color) 45void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color)
46{ 46{
47 QImage img(pix.convertToImage()); 47 QImage img(pix.convertToImage());
48 QImageEffect::fade(img, 0.9, color); 48 QImageEffect::fade(img, 0.9, color);
49 int x, y; 49 int x, y;
50 int r, g, b; 50 int r, g, b;
51 for(y=0; y < img.height(); y+=3){ 51 for(y=0; y < img.height(); y+=3){
52 unsigned int *data = (unsigned int *) img.scanLine(y); 52 unsigned int *data = (unsigned int *) img.scanLine(y);
53 for(x=0; x < img.width(); ++x){ 53 for(x=0; x < img.width(); ++x){
54 r = qRed(data[x]); 54 r = qRed(data[x]);
55 g = qGreen(data[x]); 55 g = qGreen(data[x]);
56 b = qBlue(data[x]); 56 b = qBlue(data[x]);
57 if(r-10) 57 if(r-10)
58 r-=10; 58 r-=10;
59 if(g-10) 59 if(g-10)
60 g-=10; 60 g-=10;
61 if(b-10) 61 if(b-10)
62 b-=10; 62 b-=10;
63 data[x] = qRgb(r, g, b); 63 data[x] = qRgb(r, g, b);
64 } 64 }
65 } 65 }
66 pix.convertFromImage(img); 66 pix.convertFromImage(img);
67} 67}
68 68
69TransMenuHandler::TransMenuHandler(QObject *parent) 69TransMenuHandler::TransMenuHandler(QObject *parent)
70 : QObject(parent) 70 : QObject(parent)
71{ 71{
72 pixDict.setAutoDelete(true); 72 pixDict.setAutoDelete(true);
73 reloadSettings(); 73 reloadSettings();
74} 74}
75 75
76void TransMenuHandler::reloadSettings() 76void TransMenuHandler::reloadSettings()
77{ 77{
78 pixDict.clear(); 78 pixDict.clear();
79 79
80 Config config ( "qpe" ); 80 Config config ( "qpe" );
81 config. setGroup ( "Liquid-Style" ); 81 config. setGroup ( "Liquid-Style" );
82 82
83 type = config. readNumEntry("Type", TransStippleBg); 83 type = config. readNumEntry("Type", TransStippleBg);
84 color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name())); 84 color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name()));
85 fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name())); 85 fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name()));
86 opacity = config. readNumEntry("Opacity", 10); 86 opacity = config. readNumEntry("Opacity", 10);
87 if ( opacity < -20 ) 87 if ( opacity < -20 )
88 opacity = 20; 88 opacity = 20;
89 else if ( opacity > 20 ) 89 else if ( opacity > 20 )
90 opacity = 20; 90 opacity = 20;
91 91
92 shadowText = config. readBoolEntry("ShadowText", true); 92 shadowText = config. readBoolEntry("ShadowText", true);
93} 93}
94 94
95bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev) 95bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev)
96{ 96{
97 QWidget *p = (QWidget *)obj; 97 QWidget *p = (QWidget *)obj;
98 98
99 if(ev->type() == QEvent::Show){ 99 if(ev->type() == QEvent::Show){
100 if(type == TransStippleBg || type == TransStippleBtn || 100 if(type == TransStippleBg || type == TransStippleBtn ||
101 type == Custom){ 101 type == Custom){
102 QApplication::syncX(); 102 QApplication::syncX();
103 QPixmap *pix = new QPixmap; 103 QPixmap *pix = new QPixmap;
104 if(p->testWFlags(Qt::WType_Popup)){ 104 if(p->testWFlags(Qt::WType_Popup)){
105 QRect r(p->x(), p->y(), p->width(), p->height()); 105 QRect r(p->x(), p->y(), p->width(), p->height());
106 QRect deskR = QApplication::desktop()->rect(); 106 QRect deskR = QApplication::desktop()->rect();
107 if(r.right() > deskR.right() || r.bottom() > deskR.bottom()){ 107 if(r.right() > deskR.right() || r.bottom() > deskR.bottom()){
108 r.setBottom(deskR.bottom()); 108 r.setBottom(deskR.bottom());
109 r.setRight(deskR.right()); 109 r.setRight(deskR.right());
110 } 110 }
111 *pix = QPixmap::grabWindow(QApplication::desktop()-> winId(), r.x(), r.y(), 111 *pix = QPixmap::grabWindow(QApplication::desktop()-> winId(), r.x(), r.y(),
112 r.width(), r.height()); 112 r.width(), r.height());
113 } 113 }
114 else{ // tear off menu 114 else{ // tear off menu
115 pix->resize(p->width(), p->height()); 115 pix->resize(p->width(), p->height());
116 pix->fill(Qt::black.rgb()); 116 pix->fill(Qt::black.rgb());
117 } 117 }
118 if(type == TransStippleBg){ 118 if(type == TransStippleBg){
119 stripePixmap(*pix, p->colorGroup().background()); 119 stripePixmap(*pix, p->colorGroup().background());
120 } 120 }
121 else if(type == TransStippleBtn){ 121 else if(type == TransStippleBtn){
122 stripePixmap(*pix, p->colorGroup().button()); 122 stripePixmap(*pix, p->colorGroup().button());
123 } 123 }
124 else{ 124 else{
125 QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color); 125 QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color);
126 } 126 }
127 127
128 pixDict.insert(p->winId(), pix); 128 pixDict.insert(p->winId(), pix);
129 129
@@ -760,374 +760,433 @@ void LiquidStyle::polish(QPalette &appPal)
760 adjustHSV(*pix, h, s, v); 760 adjustHSV(*pix, h, s, v);
761 smallBevelFillDict.insert(c.rgb(), pix); 761 smallBevelFillDict.insert(c.rgb(), pix);
762 } 762 }
763 pagerHoverBrush.setColor(c); 763 pagerHoverBrush.setColor(c);
764 pagerHoverBrush.setPixmap(*pix); 764 pagerHoverBrush.setPixmap(*pix);
765 765
766 c = c.dark(120); 766 c = c.dark(120);
767 pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) 767 pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-)
768 if(!pix){ 768 if(!pix){
769 int h, s, v; 769 int h, s, v;
770 c.hsv(&h, &s, &v); 770 c.hsv(&h, &s, &v);
771 pix = new QPixmap(*smallBevelFillPix); 771 pix = new QPixmap(*smallBevelFillPix);
772 adjustHSV(*pix, h, s, v); 772 adjustHSV(*pix, h, s, v);
773 smallBevelFillDict.insert(c.rgb(), pix); 773 smallBevelFillDict.insert(c.rgb(), pix);
774 } 774 }
775 pagerBrush.setColor(c); 775 pagerBrush.setColor(c);
776 pagerBrush.setPixmap(*pix); 776 pagerBrush.setPixmap(*pix);
777 777
778 // background color stuff 778 // background color stuff
779 c = /*QColor ( config. readEntry ( "Background", ( Qt::lightGray ).name ( )));*/ appPal. color ( QPalette::Active, QColorGroup::Background ); 779 c = /*QColor ( config. readEntry ( "Background", ( Qt::lightGray ).name ( )));*/ appPal. color ( QPalette::Active, QColorGroup::Background );
780 c.hsv(&bH, &bS, &bV); 780 c.hsv(&bH, &bS, &bV);
781 c.light(120).hsv(&bHoverH, &bHoverS, &bHoverV); 781 c.light(120).hsv(&bHoverH, &bHoverS, &bHoverV);
782 782
783 // FIXME? 783 // FIXME?
784 if(vsbSliderFillPix) 784 if(vsbSliderFillPix)
785 delete vsbSliderFillPix; 785 delete vsbSliderFillPix;
786 vsbSliderFillPix = new QPixmap(bevelFillPix->xForm(rMatrix)); 786 vsbSliderFillPix = new QPixmap(bevelFillPix->xForm(rMatrix));
787 adjustHSV(*vsbSliderFillPix, bH, bS, bV); 787 adjustHSV(*vsbSliderFillPix, bH, bS, bV);
788 788
789 // background brush 789 // background brush
790 QPixmap wallPaper(32, 32); 790 QPixmap wallPaper(32, 32);
791 wallPaper.fill(c.rgb()); 791 wallPaper.fill(c.rgb());
792 painter.begin(&wallPaper); 792 painter.begin(&wallPaper);
793 for(i=0; i < 32; i+=4){ 793 for(i=0; i < 32; i+=4){
794 painter.setPen(c.dark(100 + contrast)); 794 painter.setPen(c.dark(100 + contrast));
795 painter.drawLine(0, i, 32, i); 795 painter.drawLine(0, i, 32, i);
796 painter.setPen(c.dark(100 + 3 * contrast / 5 ) ); 796 painter.setPen(c.dark(100 + 3 * contrast / 5 ) );
797 painter.drawLine(0, i+1, 32, i+1); 797 painter.drawLine(0, i+1, 32, i+1);
798 }; 798 };
799 painter.end(); 799 painter.end();
800 bgBrush.setColor(c); 800 bgBrush.setColor(c);
801 bgBrush.setPixmap(wallPaper); 801 bgBrush.setPixmap(wallPaper);
802 appPal.setBrush(QColorGroup::Background, bgBrush); 802 appPal.setBrush(QColorGroup::Background, bgBrush);
803 803
804 // lineedits 804 // lineedits
805 c = /*QColor ( config. readEntry("Base", ( Qt::white). name ( )));*/ appPal. color ( QPalette::Active, QColorGroup::Base ); 805 c = /*QColor ( config. readEntry("Base", ( Qt::white). name ( )));*/ appPal. color ( QPalette::Active, QColorGroup::Base );
806 QPixmap basePix; 806 QPixmap basePix;
807 basePix.resize(32, 32); 807 basePix.resize(32, 32);
808 basePix.fill(c.rgb()); 808 basePix.fill(c.rgb());
809 painter.begin(&basePix); 809 painter.begin(&basePix);
810 painter.setPen(c.dark(105)); 810 painter.setPen(c.dark(105));
811 for(i=0; i < 32; i+=4){ 811 for(i=0; i < 32; i+=4){
812 painter.drawLine(0, i, 32, i); 812 painter.drawLine(0, i, 32, i);
813 painter.drawLine(0, i+1, 32, i+1); 813 painter.drawLine(0, i+1, 32, i+1);
814 }; 814 };
815 painter.end(); 815 painter.end();
816 baseBrush.setColor(c); 816 baseBrush.setColor(c);
817 baseBrush.setPixmap(basePix); 817 baseBrush.setPixmap(basePix);
818 it.toFirst(); 818 it.toFirst();
819 while ((w=it.current()) != 0 ){ 819 while ((w=it.current()) != 0 ){
820 ++it; 820 ++it;
821 if(w->inherits("QLineEdit")){ 821 if(w->inherits("QLineEdit")){
822 QPalette pal = w->palette(); 822 QPalette pal = w->palette();
823 pal.setBrush(QColorGroup::Base, baseBrush); 823 pal.setBrush(QColorGroup::Base, baseBrush);
824 w->setPalette(pal); 824 w->setPalette(pal);
825 } 825 }
826 else if(w->inherits("QPushButton")){ 826 else if(w->inherits("QPushButton")){
827 applyCustomAttributes((QPushButton *)w); 827 applyCustomAttributes((QPushButton *)w);
828 } 828 }
829 } 829 }
830} 830}
831 831
832void LiquidStyle::polish(QWidget *w) 832void LiquidStyle::polish(QWidget *w)
833{ 833{
834 if(w->inherits("QMenuBar")){ 834 if(w->inherits("QMenuBar")){
835 //((QFrame*)w)->setLineWidth(0); 835 //((QFrame*)w)->setLineWidth(0);
836 w->setBackgroundMode(QWidget::PaletteBackground); 836 w->setBackgroundMode(QWidget::PaletteBackground);
837 w->setBackgroundOrigin(QWidget::ParentOrigin); 837 w->setBackgroundOrigin(QWidget::ParentOrigin);
838 return; 838 return;
839 } 839 }
840 if(w->inherits("QToolBar")){ 840 if(w->inherits("QToolBar")){
841 w->installEventFilter(this); 841 w->installEventFilter(this);
842 w->setBackgroundMode(QWidget::PaletteBackground); 842 w->setBackgroundMode(QWidget::PaletteBackground);
843 w->setBackgroundOrigin(QWidget::WidgetOrigin); 843 w->setBackgroundOrigin(QWidget::WidgetOrigin);
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);
872 } 869 }
873 if(w->inherits("QButton") || w-> inherits("QComboBox")){ 870 if(w->inherits("QButton") || w-> inherits("QComboBox")){
874 w-> setBackgroundMode ( QWidget::PaletteBackground ); 871 w-> setBackgroundMode ( QWidget::PaletteBackground );
875 w->setBackgroundOrigin ( QWidget::ParentOrigin); 872 w->setBackgroundOrigin ( QWidget::ParentOrigin);
876 } 873 }
877 874
878 bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 || 875 bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 ||
879 qstrcmp(w->name(), "qt_clipped_viewport") == 0; 876 qstrcmp(w->name(), "qt_clipped_viewport") == 0;
880 bool isViewportChild = w->parent() && 877 bool isViewportChild = w->parent() &&
881 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || 878 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) ||
882 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); 879 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0));
883 880
884 if(isViewport && w->parent() && qstrcmp(w->parent()->name(), "proxyview") == 0){ 881 if(isViewport && w->parent() && qstrcmp(w->parent()->name(), "proxyview") == 0){
885 w->setBackgroundMode(QWidget::X11ParentRelative); 882 w->setBackgroundMode(QWidget::X11ParentRelative);
886 return; 883 return;
887 } 884 }
888 if(isViewportChild){ 885 if(isViewportChild){
889 if(w->inherits("QButton") || w->inherits("QComboBox")){ 886 if(w->inherits("QButton") || w->inherits("QComboBox")){
890 if(w->parent()){ // heh, only way to test for KHTML children ;-) 887 if(w->parent()){ // heh, only way to test for KHTML children ;-)
891 if(w->parent()->parent()){ 888 if(w->parent()->parent()){
892 if(w->parent()->parent()->parent() && 889 if(w->parent()->parent()->parent() &&
893 w->parent()->parent()->parent()->inherits("KHTMLView")){ 890 w->parent()->parent()->parent()->inherits("KHTMLView")){
894 w->setAutoMask(true); 891 w->setAutoMask(true);
895 w->setBackgroundMode(QWidget::NoBackground); 892 w->setBackgroundMode(QWidget::NoBackground);
896 } 893 }
897 } 894 }
898 } 895 }
899 return; 896 return;
900 } 897 }
901 } 898 }
902 if(w->inherits("QHeader")){ 899 if(w->inherits("QHeader")){
903 w->setMouseTracking(true); 900 w->setMouseTracking(true);
904 w->installEventFilter(this); 901 w->installEventFilter(this);
905 } 902 }
906 if(w-> inherits("QToolButton")&&w->parent()->inherits("QToolBar")) { 903 if(w-> inherits("QToolButton")&&w->parent()->inherits("QToolBar")) {
907 ((QToolButton*)w)->setAutoRaise (flatTBButtons); 904 ((QToolButton*)w)->setAutoRaise (flatTBButtons);
908 if ( flatTBButtons ) 905 if ( flatTBButtons )
909 w->setBackgroundOrigin(QWidget::ParentOrigin); 906 w->setBackgroundOrigin(QWidget::ParentOrigin);
910 } 907 }
911 if(w-> inherits("QToolBarSeparator")&&w->parent()->inherits("QToolBar")) { 908 if(w-> inherits("QToolBarSeparator")&&w->parent()->inherits("QToolBar")) {
912 ((QFrame *) w)-> setFrameShape ( QFrame::NoFrame ); 909 ((QFrame *) w)-> setFrameShape ( QFrame::NoFrame );
913 } 910 }
914 if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){ 911 if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){
915 return; 912 return;
916 } 913 }
917 914
918 if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())-> 915 if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())->
919 palette().active().brush(QColorGroup::Background).pixmap()){ 916 palette().active().brush(QColorGroup::Background).pixmap()){
920 qWarning("No parent pixmap for child widget %s", w->className()); 917 qWarning("No parent pixmap for child widget %s", w->className());
921 return; 918 return;
922 } 919 }
923 if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) && 920 if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) &&
924 !( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) { 921 !( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) {
925 if(w->backgroundMode() == QWidget::PaletteBackground || 922 if(w->backgroundMode() == QWidget::PaletteBackground ||
926 w->backgroundMode() == QWidget::PaletteButton){ 923 w->backgroundMode() == QWidget::PaletteButton){
927 w->setBackgroundMode(w->parentWidget()->backgroundMode( )/*QWidget::X11ParentRelative*/); 924 w->setBackgroundMode(w->parentWidget()->backgroundMode( )/*QWidget::X11ParentRelative*/);
928 w->setBackgroundOrigin(QWidget::ParentOrigin); 925 w->setBackgroundOrigin(QWidget::ParentOrigin);
929 // w->setBackgroundMode(QWidget::NoBackground); 926 // w->setBackgroundMode(QWidget::NoBackground);
930 } 927 }
931 } 928 }
932 if ( !w-> inherits("QFrame") || (((QFrame*) w)-> frameShape () == QFrame::NoFrame )) 929 if ( !w-> inherits("QFrame") || (((QFrame*) w)-> frameShape () == QFrame::NoFrame ))
933 w-> setBackgroundOrigin ( QWidget::ParentOrigin ); 930 w-> setBackgroundOrigin ( QWidget::ParentOrigin );
934 else if ( w-> inherits("QFrame") ) 931 else if ( w-> inherits("QFrame") )
935 w->setBackgroundOrigin ( QWidget::WidgetOrigin ); 932 w->setBackgroundOrigin ( QWidget::WidgetOrigin );
936 933
937 if ( w->parentWidget()->inherits ( "QWidgetStack" )) { 934 if ( w->parentWidget()->inherits ( "QWidgetStack" )) {
938 w->setBackgroundOrigin ( QWidget::WidgetOrigin ); 935 w->setBackgroundOrigin ( QWidget::WidgetOrigin );
939 } 936 }
940} 937}
941 938
942void LiquidStyle::unPolish(QWidget *w) 939void LiquidStyle::unPolish(QWidget *w)
943{ 940{
944 if(w->inherits("QMenuBar")){ 941 if(w->inherits("QMenuBar")){
945 ((QFrame *)w)->setLineWidth(1); 942 ((QFrame *)w)->setLineWidth(1);
946 w->setBackgroundMode(QWidget::PaletteBackground); 943 w->setBackgroundMode(QWidget::PaletteBackground);
947 return; 944 return;
948 } 945 }
949 946
950 if(w->inherits("QPopupMenu")) 947 if(w->inherits("QPopupMenu"))
951 w->setBackgroundMode(QWidget::PaletteButton); 948 w->setBackgroundMode(QWidget::PaletteButton);
952 else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) { 949 else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) {
953 w->removeEventFilter(menuHandler); 950 w->removeEventFilter(menuHandler);
954 } 951 }
955 952
956 if(w->isTopLevel()) 953 if(w->isTopLevel())
957 return; 954 return;
958 955
959 // for viewport children, don't just check for NoBackground.... 956 // for viewport children, don't just check for NoBackground....
960 bool isViewportChild = w->parent() && 957 bool isViewportChild = w->parent() &&
961 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || 958 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) ||
962 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); 959 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0));
963 960
964 w->unsetPalette(); 961 w->unsetPalette();
965 if(w->backgroundMode() == QWidget::X11ParentRelative || isViewportChild){ 962 if(w->backgroundMode() == QWidget::X11ParentRelative || isViewportChild){
966 if(w->inherits("QPushButton")) 963 if(w->inherits("QPushButton"))
967 w->setBackgroundMode(QWidget::PaletteButton); 964 w->setBackgroundMode(QWidget::PaletteButton);
968 else 965 else
969 w->setBackgroundMode(QWidget::PaletteBackground); 966 w->setBackgroundMode(QWidget::PaletteBackground);
970 } 967 }
971 968
972 if(isViewportChild) 969 if(isViewportChild)
973 w->setAutoMask(false); 970 w->setAutoMask(false);
974 971
975 if(w->inherits("QPushButton")){ 972 if(w->inherits("QPushButton")){
976 unapplyCustomAttributes((QPushButton *)w); 973 unapplyCustomAttributes((QPushButton *)w);
977 w->removeEventFilter(this); 974 w->removeEventFilter(this);
978 } 975 }
979/* 976/*
980 if(w->inherits("QPushButton") || w-> inherits("QComboBox")){ 977 if(w->inherits("QPushButton") || w-> inherits("QComboBox")){
981 w-> setBackgroundMode ( PaletteBackground ); 978 w-> setBackgroundMode ( PaletteBackground );
982 } 979 }
983*/ 980*/
984 if(w->inherits("QComboBox") || 981 if(w->inherits("QComboBox") ||
985 w->inherits("QLineEdit") || w->inherits("QRadioButton") || 982 w->inherits("QLineEdit") || w->inherits("QRadioButton") ||
986 w->inherits("QCheckBox") || w->inherits("QScrollBar")) { 983 w->inherits("QCheckBox") || w->inherits("QScrollBar")) {
987 w->removeEventFilter(this); 984 w->removeEventFilter(this);
988 } 985 }
989 if(w->inherits("QButton") || w->inherits("QComboBox")){ 986 if(w->inherits("QButton") || w->inherits("QComboBox")){
990 if(w->parent() && w->parent()->inherits("KHTMLPart")){ 987 if(w->parent() && w->parent()->inherits("KHTMLPart")){
991 w->setAutoMask(false); 988 w->setAutoMask(false);
992 } 989 }
993 } 990 }
994 if(w->inherits("QToolBar")){ 991 if(w->inherits("QToolBar")){
995 w->removeEventFilter(this); 992 w->removeEventFilter(this);
996 w->setBackgroundMode(QWidget::PaletteBackground); 993 w->setBackgroundMode(QWidget::PaletteBackground);
997 return; 994 return;
998 } 995 }
999 if(w->inherits("QHeader")){ 996 if(w->inherits("QHeader")){
1000 w->setMouseTracking(false); 997 w->setMouseTracking(false);
1001 w->removeEventFilter(this); 998 w->removeEventFilter(this);
1002 } 999 }
1003} 1000}
1004 1001
1005void LiquidStyle::polish(QApplication *app) 1002void LiquidStyle::polish(QApplication *app)
1006{ 1003{
1007 1004
1008 QWindowsStyle::polish(app); 1005 QWindowsStyle::polish(app);
1009 menuAni = app->isEffectEnabled(UI_AnimateMenu); 1006 menuAni = app->isEffectEnabled(UI_AnimateMenu);
1010 menuFade = app->isEffectEnabled(UI_FadeMenu); 1007 menuFade = app->isEffectEnabled(UI_FadeMenu);
1011 if(menuAni) 1008 if(menuAni)
1012 app->setEffectEnabled(UI_AnimateMenu, false); 1009 app->setEffectEnabled(UI_AnimateMenu, false);
1013 if(menuFade) 1010 if(menuFade)
1014 app->setEffectEnabled(UI_FadeMenu, false); 1011 app->setEffectEnabled(UI_FadeMenu, false);
1015 1012
1016 qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &LiquidStyle::drawMenuBarItem); 1013 qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &LiquidStyle::drawMenuBarItem);
1017 1014
1018 Config config ( "qpe" ); 1015 Config config ( "qpe" );
1019 config. setGroup ( "Liquid-Style" ); 1016 config. setGroup ( "Liquid-Style" );
1020 1017
1021 // if ( config. readBoolEntry ( "WinDecoration", true )) 1018 // if ( config. readBoolEntry ( "WinDecoration", true ))
1022 // QApplication::qwsSetDecoration ( new LiquidDecoration ( )); 1019 // QApplication::qwsSetDecoration ( new LiquidDecoration ( ));
1023 1020
1024 flatTBButtons = config. readBoolEntry ( "FlatToolButtons", false ); 1021 flatTBButtons = config. readBoolEntry ( "FlatToolButtons", false );
1025} 1022}
1026 1023
1027void LiquidStyle::unPolish(QApplication *app) 1024void 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
1047class HackProgressBar : public QProgressBar {
1048public:
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
1050 * that draws multiple items, so we need to check which ID is hightlighted 1109 * that draws multiple items, so we need to check which ID is hightlighted
1051 * and draw it. Finally, we also check enter and leave events for QLineEdit, 1110 * and draw it. Finally, we also check enter and leave events for QLineEdit,
1052 * since if it's inside a combobox we want to highlight the combobox during 1111 * since if it's inside a combobox we want to highlight the combobox during
1053 * hovering in the edit. 1112 * hovering in the edit.
1054 */ 1113 */
1055bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) 1114bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev)
1056{ 1115{
1057 if(obj->inherits("QToolBar")){ 1116 if(obj->inherits("QToolBar")){
1058 if(ev->type() == QEvent::Resize){ 1117 if(ev->type() == QEvent::Resize){
1059 const QObjectList *tbChildList = obj->children(); 1118 const QObjectList *tbChildList = obj->children();
1060 QObjectListIt it(*tbChildList); 1119 QObjectListIt it(*tbChildList);
1061 QObject *child; 1120 QObject *child;
1062 while((child = it.current()) != NULL){ 1121 while((child = it.current()) != NULL){
1063 ++it; 1122 ++it;
1064 if(child->isWidgetType()) 1123 if(child->isWidgetType())
1065 ((QWidget *)child)->repaint(true); 1124 ((QWidget *)child)->repaint(true);
1066 } 1125 }
1067 1126
1068 } 1127 }
1069 } 1128 }
1070 else if(obj->inherits("QPushButton") || obj->inherits("QComboBox")){ 1129 else if(obj->inherits("QPushButton") || obj->inherits("QComboBox")){
1071 QWidget *btn = (QWidget *)obj; 1130 QWidget *btn = (QWidget *)obj;
1072 if(ev->type() == QEvent::Enter){ 1131 if(ev->type() == QEvent::Enter){
1073 if(btn->isEnabled()){ 1132 if(btn->isEnabled()){
1074 highlightWidget = btn; 1133 highlightWidget = btn;
1075 btn->repaint(false); 1134 btn->repaint(false);
1076 } 1135 }
1077 } 1136 }
1078 else if(ev->type() == QEvent::Leave){ 1137 else if(ev->type() == QEvent::Leave){
1079 if(btn == highlightWidget){ 1138 if(btn == highlightWidget){
1080 highlightWidget = NULL; 1139 highlightWidget = NULL;
1081 btn->repaint(false); 1140 btn->repaint(false);
1082 } 1141 }
1083 } 1142 }
1084 } 1143 }
1085 else if(obj->inherits("QToolButton")){ 1144 else if(obj->inherits("QToolButton")){
1086 QToolButton *btn = (QToolButton *)btn; 1145 QToolButton *btn = (QToolButton *)btn;
1087 if(!btn->autoRaise()){ 1146 if(!btn->autoRaise()){
1088 if(btn->isEnabled()){ 1147 if(btn->isEnabled()){
1089 highlightWidget = btn; 1148 highlightWidget = btn;
1090 btn->repaint(false); 1149 btn->repaint(false);
1091 } 1150 }
1092 } 1151 }
1093 else if(ev->type() == QEvent::Leave){ 1152 else if(ev->type() == QEvent::Leave){
1094 QWidget *btn = (QWidget *)obj; 1153 QWidget *btn = (QWidget *)obj;
1095 if(btn == highlightWidget){ 1154 if(btn == highlightWidget){
1096 highlightWidget = NULL; 1155 highlightWidget = NULL;
1097 btn->repaint(false); 1156 btn->repaint(false);
1098 } 1157 }
1099 } 1158 }
1100 else 1159 else
1101 highlightWidget = NULL; 1160 highlightWidget = NULL;
1102 } 1161 }
1103 else if(obj->inherits("QScrollBar")){ 1162 else if(obj->inherits("QScrollBar")){
1104 QScrollBar *sb = (QScrollBar *)obj; 1163 QScrollBar *sb = (QScrollBar *)obj;
1105 if(ev->type() == QEvent::Enter){ 1164 if(ev->type() == QEvent::Enter){
1106 if(sb->isEnabled()){ 1165 if(sb->isEnabled()){
1107 highlightWidget = sb; 1166 highlightWidget = sb;
1108 sb->repaint(false); 1167 sb->repaint(false);
1109 } 1168 }
1110 } 1169 }
1111 else if(ev->type() == QEvent::Leave){ 1170 else if(ev->type() == QEvent::Leave){
1112 if(sb == highlightWidget && !sb->draggingSlider()){ 1171 if(sb == highlightWidget && !sb->draggingSlider()){
1113 highlightWidget = NULL; 1172 highlightWidget = NULL;
1114 sb->repaint(false); 1173 sb->repaint(false);
1115 } 1174 }
1116 } 1175 }
1117 else if(ev->type() == QEvent::MouseButtonRelease){ 1176 else if(ev->type() == QEvent::MouseButtonRelease){
1118 QMouseEvent *me = (QMouseEvent *)ev; 1177 QMouseEvent *me = (QMouseEvent *)ev;
1119 if(sb == highlightWidget && !sb->rect().contains(me->pos())){ 1178 if(sb == highlightWidget && !sb->rect().contains(me->pos())){
1120 highlightWidget = NULL; 1179 highlightWidget = NULL;
1121 sb->repaint(false); 1180 sb->repaint(false);
1122 } 1181 }
1123 } 1182 }
1124 } 1183 }
1125 else if(obj->inherits("QLineEdit")){ 1184 else if(obj->inherits("QLineEdit")){
1126 if(obj->parent() && obj->parent()->inherits("QComboBox")){ 1185 if(obj->parent() && obj->parent()->inherits("QComboBox")){
1127 QWidget *btn = (QComboBox *)obj->parent(); 1186 QWidget *btn = (QComboBox *)obj->parent();
1128 if(ev->type() == QEvent::Enter){ 1187 if(ev->type() == QEvent::Enter){
1129 if (btn->isEnabled()){ 1188 if (btn->isEnabled()){
1130 highlightWidget = btn; 1189 highlightWidget = btn;
1131 btn->repaint(false); 1190 btn->repaint(false);
1132 } 1191 }
1133 } 1192 }
@@ -1147,193 +1206,210 @@ bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev)
1147 QPainter p; 1206 QPainter p;
1148 p.begin(btn); 1207 p.begin(btn);
1149 QFontMetrics fm = btn->fontMetrics(); 1208 QFontMetrics fm = btn->fontMetrics();
1150 QSize lsz = fm.size(ShowPrefix, btn->text()); 1209 QSize lsz = fm.size(ShowPrefix, btn->text());
1151 QSize sz = isRadio ? exclusiveIndicatorSize() 1210 QSize sz = isRadio ? exclusiveIndicatorSize()
1152 : indicatorSize(); 1211 : indicatorSize();
1153 1212
1154 if(btn->hasFocus()){ 1213 if(btn->hasFocus()){
1155 QRect r = QRect(0, 0, btn->width(), btn->height()); 1214 QRect r = QRect(0, 0, btn->width(), btn->height());
1156 p.setPen(btn->colorGroup().button().dark(140)); 1215 p.setPen(btn->colorGroup().button().dark(140));
1157 p.drawLine(r.x()+1, r.y(), r.right()-1, r.y()); 1216 p.drawLine(r.x()+1, r.y(), r.right()-1, r.y());
1158 p.drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); 1217 p.drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1);
1159 p.drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); 1218 p.drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1);
1160 p.drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); 1219 p.drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom());
1161 } 1220 }
1162 int x = 0; 1221 int x = 0;
1163 int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; 1222 int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2;
1164 if(isRadio) 1223 if(isRadio)
1165 drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), 1224 drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(),
1166 btn->colorGroup(), btn->isOn(), 1225 btn->colorGroup(), btn->isOn(),
1167 btn->isDown(), btn->isEnabled()); 1226 btn->isDown(), btn->isEnabled());
1168 else 1227 else
1169 drawIndicator(&p, x, y, sz.width(), sz.height(), 1228 drawIndicator(&p, x, y, sz.width(), sz.height(),
1170 btn->colorGroup(), btn->state(), btn->isDown(), 1229 btn->colorGroup(), btn->state(), btn->isDown(),
1171 btn->isEnabled()); 1230 btn->isEnabled());
1172 x = sz.width() + 6; 1231 x = sz.width() + 6;
1173 y = 0; 1232 y = 0;
1174 drawItem(&p, sz.width()+6+1, 0, btn->width()-(sz.width()+6+1), 1233 drawItem(&p, sz.width()+6+1, 0, btn->width()-(sz.width()+6+1),
1175 btn->height(), AlignLeft|AlignVCenter|ShowPrefix, 1234 btn->height(), AlignLeft|AlignVCenter|ShowPrefix,
1176 btn->colorGroup(), btn->isEnabled(), 1235 btn->colorGroup(), btn->isEnabled(),
1177 btn->pixmap(), btn->text()); 1236 btn->pixmap(), btn->text());
1178 p.end(); 1237 p.end();
1179 return(true); 1238 return(true);
1180 } 1239 }
1181 // for hover, just redraw the indicator (not the text) 1240 // for hover, just redraw the indicator (not the text)
1182 else if((ev->type() == QEvent::Enter && btn->isEnabled()) || 1241 else if((ev->type() == QEvent::Enter && btn->isEnabled()) ||
1183 (ev->type() == QEvent::Leave && btn == highlightWidget)){ 1242 (ev->type() == QEvent::Leave && btn == highlightWidget)){
1184 QButton *btn = (QButton *)obj; 1243 QButton *btn = (QButton *)obj;
1185 bool isRadio = obj->inherits("QRadioButton"); 1244 bool isRadio = obj->inherits("QRadioButton");
1186 1245
1187 if(ev->type() == QEvent::Enter) 1246 if(ev->type() == QEvent::Enter)
1188 highlightWidget = btn; 1247 highlightWidget = btn;
1189 else 1248 else
1190 highlightWidget = NULL; 1249 highlightWidget = NULL;
1191 QFontMetrics fm = btn->fontMetrics(); 1250 QFontMetrics fm = btn->fontMetrics();
1192 QSize lsz = fm.size(ShowPrefix, btn->text()); 1251 QSize lsz = fm.size(ShowPrefix, btn->text());
1193 QSize sz = isRadio ? exclusiveIndicatorSize() 1252 QSize sz = isRadio ? exclusiveIndicatorSize()
1194 : indicatorSize(); 1253 : indicatorSize();
1195 int x = 0; 1254 int x = 0;
1196 int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; 1255 int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2;
1197 //if(btn->autoMask()) 1256 //if(btn->autoMask())
1198 // btn->erase(x+1, y+1, sz.width()-2, sz.height()-2); 1257 // btn->erase(x+1, y+1, sz.width()-2, sz.height()-2);
1199 QPainter p; 1258 QPainter p;
1200 p.begin(btn); 1259 p.begin(btn);
1201 if(isRadio) 1260 if(isRadio)
1202 drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), 1261 drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(),
1203 btn->colorGroup(), btn->isOn(), 1262 btn->colorGroup(), btn->isOn(),
1204 btn->isDown(), btn->isEnabled()); 1263 btn->isDown(), btn->isEnabled());
1205 else 1264 else
1206 drawIndicator(&p, x, y, sz.width(), sz.height(), 1265 drawIndicator(&p, x, y, sz.width(), sz.height(),
1207 btn->colorGroup(), btn->state(), btn->isDown(), 1266 btn->colorGroup(), btn->state(), btn->isDown(),
1208 btn->isEnabled()); 1267 btn->isEnabled());
1209 p.end(); 1268 p.end();
1210 } 1269 }
1211 } 1270 }
1212 else if(obj->inherits("QHeader")){ 1271 else if(obj->inherits("QHeader")){
1213 QHeader *hw = (QHeader *)obj; 1272 QHeader *hw = (QHeader *)obj;
1214 if(ev->type() == QEvent::Enter){ 1273 if(ev->type() == QEvent::Enter){
1215 currentHeader = hw; 1274 currentHeader = hw;
1216 headerHoverID = -1; 1275 headerHoverID = -1;
1217 } 1276 }
1218 else if(ev->type() == QEvent::Leave){ 1277 else if(ev->type() == QEvent::Leave){
1219 currentHeader = NULL; 1278 currentHeader = NULL;
1220 if(headerHoverID != -1){ 1279 if(headerHoverID != -1){
1221 hw->repaint(hw->sectionPos(headerHoverID), 0, 1280 hw->repaint(hw->sectionPos(headerHoverID), 0,
1222 hw->sectionSize(headerHoverID), hw->height()); 1281 hw->sectionSize(headerHoverID), hw->height());
1223 } 1282 }
1224 headerHoverID = -1; 1283 headerHoverID = -1;
1225 } 1284 }
1226 else if(ev->type() == QEvent::MouseMove){ 1285 else if(ev->type() == QEvent::MouseMove){
1227 QMouseEvent *me = (QMouseEvent *)ev; 1286 QMouseEvent *me = (QMouseEvent *)ev;
1228 int oldHeader = headerHoverID; 1287 int oldHeader = headerHoverID;
1229 headerHoverID = hw->sectionAt(me->x()); 1288 headerHoverID = hw->sectionAt(me->x());
1230 if(oldHeader != headerHoverID){ 1289 if(oldHeader != headerHoverID){
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
1246void LiquidStyle::drawButton(QPainter *p, int x, int y, int w, int h, 1322void 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
1254void LiquidStyle::drawToolButton(QPainter *p, int x, int y, int w, int h, 1330void LiquidStyle::drawToolButton(QPainter *p, int x, int y, int w, int h,
1255 const QColorGroup &g, bool sunken, 1331 const QColorGroup &g, bool sunken,
1256 const QBrush *) 1332 const QBrush *)
1257{ 1333{
1258 if(p->device()->devType() != QInternal::Widget){ 1334 if(p->device()->devType() != QInternal::Widget){
1259 // drawing into a temp pixmap, don't use mask 1335 // drawing into a temp pixmap, don't use mask
1260 QColor c = sunken ? g.button() : g.background(); 1336 QColor c = sunken ? g.button() : g.background();
1261 p->setPen(c.dark(130)); 1337 p->setPen(c.dark(130));
1262 p->drawRect(x, y, w, h); 1338 p->drawRect(x, y, w, h);
1263 p->setPen(c.light(105)); 1339 p->setPen(c.light(105));
1264 p->drawRect(x+1, y+1, w-2, h-2); 1340 p->drawRect(x+1, y+1, w-2, h-2);
1265 1341
1266 1342
1267 // fill 1343 // fill
1268 QPixmap *pix = bevelFillDict.find(c.rgb()); 1344 QPixmap *pix = bevelFillDict.find(c.rgb());
1269 if(!pix){ 1345 if(!pix){
1270 int h, s, v; 1346 int h, s, v;
1271 c.hsv(&h, &s, &v); 1347 c.hsv(&h, &s, &v);
1272 pix = new QPixmap(*bevelFillPix); 1348 pix = new QPixmap(*bevelFillPix);
1273 adjustHSV(*pix, h, s, v); 1349 adjustHSV(*pix, h, s, v);
1274 bevelFillDict.insert(c.rgb(), pix); 1350 bevelFillDict.insert(c.rgb(), pix);
1275 } 1351 }
1276 1352
1277 p->drawTiledPixmap(x+2, y+2, w-4, h-4, *pix); 1353 p->drawTiledPixmap(x+2, y+2, w-4, h-4, *pix);
1278 } 1354 }
1279 else{ 1355 else{
1280 drawClearBevel(p, x, y, w, h, sunken ? g.button() : 1356 drawClearBevel(p, x, y, w, h, sunken ? g.button() :
1281 highlightWidget == p->device() ? g.button().light(110) : 1357 highlightWidget == p->device() ? g.button().light(110) :
1282 g.background(), g.background()); 1358 g.background(), g.background());
1283 } 1359 }
1284} 1360}
1285 1361
1286void LiquidStyle::drawPushButton(QPushButton *btn, QPainter *p) 1362void LiquidStyle::drawPushButton(QPushButton *btn, QPainter *p)
1287{ 1363{
1288 QRect r = btn->rect(); 1364 QRect r = btn->rect();
1289 bool sunken = btn->isOn() || btn->isDown(); 1365 bool sunken = btn->isOn() || btn->isDown();
1290 QColorGroup g = btn->colorGroup(); 1366 QColorGroup g = btn->colorGroup();
1291 1367
1292 1368
1293 //int dw = buttonDefaultIndicatorWidth(); 1369 //int dw = buttonDefaultIndicatorWidth();
1294 if(btn->hasFocus() || btn->isDefault()){ 1370 if(btn->hasFocus() || btn->isDefault()){
1295 QColor c = btn->hasFocus() ? g.button().light(110) : g.background(); 1371 QColor c = btn->hasFocus() ? g.button().light(110) : g.background();
1296 QPixmap *pix = bevelFillDict.find(c.rgb()); 1372 QPixmap *pix = bevelFillDict.find(c.rgb());
1297 if(!pix){ 1373 if(!pix){
1298 int h, s, v; 1374 int h, s, v;
1299 c.hsv(&h, &s, &v); 1375 c.hsv(&h, &s, &v);
1300 pix = new QPixmap(*bevelFillPix); 1376 pix = new QPixmap(*bevelFillPix);
1301 adjustHSV(*pix, h, s, v); 1377 adjustHSV(*pix, h, s, v);
1302 bevelFillDict.insert(c.rgb(), pix); 1378 bevelFillDict.insert(c.rgb(), pix);
1303 } 1379 }
1304 p->setPen(c.dark(150)); 1380 p->setPen(c.dark(150));
1305 p->drawLine(r.x()+1, r.y(), r.right()-1, r.y()); 1381 p->drawLine(r.x()+1, r.y(), r.right()-1, r.y());
1306 p->drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); 1382 p->drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1);
1307 p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); 1383 p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1);
1308 p->drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); 1384 p->drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom());
1309 p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix); 1385 p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix);
1310 } 1386 }
1311 1387
1312 QColor newColor = btn == highlightWidget || sunken ? 1388 QColor newColor = btn == highlightWidget || sunken ?
1313 g.button().light(120) : g.button(); 1389 g.button().light(120) : g.button();
1314 1390
1315 drawRoundButton(p, newColor, g.background(), 1391 drawRoundButton(p, newColor, g.background(),
1316 r.x(), r.y(), r.width(), r.height(), !btn->autoMask(), 1392 r.x(), r.y(), r.width(), r.height(), !btn->autoMask(),
1317 sunken, btn->isDefault() || btn->autoDefault() || btn->hasFocus(), 1393 sunken, btn->isDefault() || btn->autoDefault() || btn->hasFocus(),
1318 btn->autoMask()); 1394 btn->autoMask());
1319} 1395}
1320 1396
1321void LiquidStyle::drawPushButtonLabel(QPushButton *btn, QPainter *p) 1397void LiquidStyle::drawPushButtonLabel(QPushButton *btn, QPainter *p)
1322{ 1398{
1323 int x1, y1, x2, y2, w, h; 1399 int x1, y1, x2, y2, w, h;
1324 btn->rect().coords(&x1, &y1, &x2, &y2); 1400 btn->rect().coords(&x1, &y1, &x2, &y2);
1325 w = btn->width(); 1401 w = btn->width();
1326 h = btn->height(); 1402 h = btn->height();
1327 1403
1328 bool act = btn->isOn() || btn->isDown(); 1404 bool act = btn->isOn() || btn->isDown();
1329 if(act){ 1405 if(act){
1330 ++x1, ++y1; 1406 ++x1, ++y1;
1331 } 1407 }
1332 1408
1333 // Draw iconset first, if any 1409 // Draw iconset first, if any
1334 if ( btn->iconSet() && !btn->iconSet()->isNull() ) 1410 if ( btn->iconSet() && !btn->iconSet()->isNull() )
1335 { 1411 {
1336 QIconSet::Mode mode = btn->isEnabled() 1412 QIconSet::Mode mode = btn->isEnabled()
1337 ? QIconSet::Normal : QIconSet::Disabled; 1413 ? QIconSet::Normal : QIconSet::Disabled;
1338 if ( mode == QIconSet::Normal && btn->hasFocus() ) 1414 if ( mode == QIconSet::Normal && btn->hasFocus() )
1339 mode = QIconSet::Active; 1415 mode = QIconSet::Active;