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.cpp567
1 files changed, 178 insertions, 389 deletions
diff --git a/noncore/styles/liquid/liquid.cpp b/noncore/styles/liquid/liquid.cpp
index 6812d16..ba732aa 100644
--- a/noncore/styles/liquid/liquid.cpp
+++ b/noncore/styles/liquid/liquid.cpp
@@ -4,2 +4,5 @@
4 4
5//
6// (c) 2002 Robert 'sandman' Griebl
7//
5 8
@@ -33,2 +36,3 @@
33#include <qprogressbar.h> 36#include <qprogressbar.h>
37#include <qlineedit.h>
34 38
@@ -164,2 +168,9 @@ bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev)
164 168
169static int qt_version ( )
170{
171 const char *qver = qVersion ( );
172 return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' );
173}
174
175
165LiquidStyle::LiquidStyle() 176LiquidStyle::LiquidStyle()
@@ -169,2 +180,3 @@ LiquidStyle::LiquidStyle()
169 180
181 oldqte = ( qt_version ( ) < 234 );
170 flatTBButtons = false; 182 flatTBButtons = false;
@@ -181,8 +193,4 @@ LiquidStyle::LiquidStyle()
181 smallBevelFillDict.setAutoDelete(true); 193 smallBevelFillDict.setAutoDelete(true);
182 customBtnColorList.setAutoDelete(true);
183 customBtnIconList.setAutoDelete(true);
184 customBtnLabelList.setAutoDelete(true);
185 194
186 rMatrix.rotate(270.0); 195 rMatrix.rotate(270.0);
187 highcolor = QPixmap::defaultDepth() > 8;
188 btnBorderPix = new QPixmap; 196 btnBorderPix = new QPixmap;
@@ -546,2 +554,3 @@ QPixmap* LiquidStyle::getPixmap(BitmapData item)
546 break; 554 break;
555
547 case HTMLCB: 556 case HTMLCB:
@@ -549,2 +558,5 @@ QPixmap* LiquidStyle::getPixmap(BitmapData item)
549 break; 558 break;
559 case HTMLCBHover:
560 pixmaps[HTMLCBHover] = processEmbedded("htmlcheckbox", btnHoverH, btnHoverS, btnHoverV);
561 break;
550 case HTMLCBDown: 562 case HTMLCBDown:
@@ -552,117 +564,101 @@ QPixmap* LiquidStyle::getPixmap(BitmapData item)
552 break; 564 break;
553 case HTMLCBHover:
554 pixmaps[HTMLCBHover] = processEmbedded("htmlcheckbox", btnH, btnS, btnV);
555 break;
556 case HTMLCBDownHover: 565 case HTMLCBDownHover:
557 pixmaps[HTMLCBDownHover] = processEmbedded("htmlcheckboxdown", 566 pixmaps[HTMLCBDownHover] = processEmbedded("htmlcheckboxdown", btnHoverH, btnHoverS, btnHoverV);
558 btnHoverH, btnHoverS,
559 btnHoverV);
560 break; 567 break;
568
561 case HTMLRadio: 569 case HTMLRadio:
562 pixmaps[HTMLRadio] = processEmbedded("htmlradio", bH, bS, bV); 570 pixmaps[HTMLRadio] = processEmbedded("htmlradio", bH, bS, bV);
571 break;
572 case HTMLRadioHover:
573 pixmaps[HTMLRadioHover] = processEmbedded("htmlradio", btnHoverH, btnHoverS, btnHoverV);
574 break;
563 case HTMLRadioDown: 575 case HTMLRadioDown:
564 pixmaps[HTMLRadioDown] = processEmbedded("htmlradiodown", btnH, btnS, btnV); 576 pixmaps[HTMLRadioDown] = processEmbedded("htmlradiodown", btnH, btnS, btnV);
565 case HTMLRadioHover: 577 break;
566 pixmaps[HTMLRadioHover] = processEmbedded("htmlradio", btnH, btnS, btnV);
567 case HTMLRadioDownHover: 578 case HTMLRadioDownHover:
568 pixmaps[HTMLRadioDownHover] = processEmbedded("htmlradiodown", 579 pixmaps[HTMLRadioDownHover] = processEmbedded("htmlradiodown", btnHoverH, btnHoverS, btnHoverV);
569 btnHoverH, btnHoverS, 580 break;
570 btnHoverV); 581
571 case RadioOn: 582 case RadioOff:
572 pixmaps[RadioOn] = processEmbedded("radio_down", btnH, btnS, btnV, true); 583 pixmaps[RadioOff] = processEmbedded("radio", bH, bS, bV /*, true*/);
584 break;
585 case RadioOffHover:
586 pixmaps[RadioOffHover] = processEmbedded("radio", btnHoverH, btnHoverS, btnHoverV /*, true*/);
587 break;
588 case RadioOn:
589 pixmaps[RadioOn] = processEmbedded("radio_down", btnH, btnS, btnV /*, true*/);
573 break; 590 break;
574 case RadioOnHover: 591 case RadioOnHover:
575 pixmaps[RadioOnHover] = processEmbedded("radio_down", btnHoverH, btnHoverS, 592 pixmaps[RadioOnHover] = processEmbedded("radio_down", btnHoverH, btnHoverS, btnHoverV /*, true*/);
576 btnHoverV, true);
577 break; 593 break;
578 case RadioOffHover: 594
579 pixmaps[RadioOffHover] = processEmbedded("radio", btnH, btnS, btnV, true); 595 case Tab:
596 pixmaps[Tab] = processEmbedded("tab", bH, bS, bV /*, true*/);
580 break; 597 break;
581 case TabDown: 598 case TabDown:
582 pixmaps[TabDown] = processEmbedded("tab", btnH, btnS, btnV, true); 599 pixmaps[TabDown] = processEmbedded("tab", btnH, btnS, btnV /*, true*/);
583 break; 600 break;
584 case TabFocus: 601 case TabFocus:
585 pixmaps[TabFocus] = processEmbedded("tab", btnHoverH, btnHoverS, 602 pixmaps[TabFocus] = processEmbedded("tab", btnHoverH, btnHoverS, btnHoverV /*, true*/);
586 btnHoverS, true); 603 break;
604
605 case CB:
606 pixmaps[CB] = processEmbedded("checkbox", bH, bS, bV /*, true*/);
607 break;
608 case CBHover:
609 pixmaps[CBHover] = processEmbedded("checkbox", btnHoverH, btnHoverS, btnHoverV /*, true*/);
587 break; 610 break;
588 case CBDown: 611 case CBDown:
589 pixmaps[CBDown] = processEmbedded("checkboxdown", btnH, btnS, btnV, true); 612 pixmaps[CBDown] = processEmbedded("checkboxdown", btnH, btnS, btnV /*, true*/);
590 break; 613 break;
591 case CBDownHover: 614 case CBDownHover:
592 pixmaps[CBDownHover] = processEmbedded("checkboxdown", btnHoverH, 615 pixmaps[CBDownHover] = processEmbedded("checkboxdown", btnHoverH, btnHoverS, btnHoverV /*, true*/);
593 btnHoverS, btnHoverV, true);
594 break;
595 case CBHover:
596 pixmaps[CBHover] = processEmbedded("checkbox", btnH, btnS, btnV, true);
597 break; 616 break;
598 case HSlider: 617
599 pixmaps[HSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true); 618 case VSlider:
600 break; 619 pixmaps[VSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true );
601 case VSlider:
602 pixmaps[VSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true);
603 *pixmaps[VSlider] = pixmaps[VSlider]->xForm(rMatrix); 620 *pixmaps[VSlider] = pixmaps[VSlider]->xForm(rMatrix);
604 break; 621 break;
605 case RadioOff:
606 pixmaps[RadioOff] = processEmbedded("radio", bH, bS, bV, true);
607 break;
608 case Tab:
609 pixmaps[Tab] = processEmbedded("tab", bH, bS, bV, true);
610 break;
611 case CB:
612 pixmaps[CB] = processEmbedded("checkbox", bH, bS, bV, true);
613 break;
614 case VSBSliderTop: 622 case VSBSliderTop:
615 pixmaps[VSBSliderTop] = processEmbedded("sbslider_top", btnH, btnS, btnV, true); 623 case VSBSliderTopHover:
624 pixmaps[item] = processEmbedded("sbslider_top", btnH, btnS, btnV /*, true*/);
616 break; 625 break;
617 case VSBSliderBtm: 626 case VSBSliderBtm:
618 pixmaps[VSBSliderBtm] = processEmbedded("sbslider_btm", btnH, btnS, btnV, true); 627 case VSBSliderBtmHover:
628 pixmaps[item] = processEmbedded("sbslider_btm", btnH, btnS, btnV /*, true*/);
619 break; 629 break;
620 case VSBSliderMid: 630 case VSBSliderMid:
621 pixmaps[VSBSliderMid] = processEmbedded("sbslider_mid", btnH, btnS, btnV); 631 case VSBSliderMidHover:
632 pixmaps[item] = processEmbedded("sbslider_mid", btnH, btnS, btnV);
622 break; 633 break;
623 case VSBSliderTopHover: 634 case VSBSliderTopBg:
624 pixmaps[VSBSliderTopHover] = processEmbedded("sbslider_top", btnHoverH, btnHoverS, btnHoverV, true); 635 pixmaps[VSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV /*, true*/);
625 break; 636 break;
626 case VSBSliderBtmHover: 637 case VSBSliderBtmBg:
627 pixmaps[VSBSliderBtmHover] = processEmbedded("sbslider_btm", btnHoverH, btnHoverS, btnHoverV, true); 638 pixmaps[VSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV /*, true*/);
628 break; 639 break;
629 case VSBSliderMidHover: 640 case VSBSliderMidBg:
630 pixmaps[VSBSliderMidHover] = processEmbedded("sbslider_mid", btnHoverH, btnHoverS, btnHoverV); 641 pixmaps[VSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV);
631 break; 642 break;
632 643
633 case HSBSliderTop: 644 case HSlider:
634 pixmaps[HSBSliderTop] = processEmbedded("sbslider_top", btnH, btnS, btnV, true); 645 pixmaps[HSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV /*, true*/);
635 *pixmaps[HSBSliderTop] = pixmaps[HSBSliderTop]->xForm(rMatrix);
636 break;
637 case HSBSliderBtm:
638 pixmaps[HSBSliderBtm] = processEmbedded("sbslider_btm", btnH, btnS, btnV, true);
639 *pixmaps[HSBSliderBtm] = pixmaps[HSBSliderBtm]->xForm(rMatrix);
640 break;
641 case HSBSliderMid:
642 pixmaps[HSBSliderMid] = processEmbedded("sbslider_mid", btnH, btnS, btnV);
643 *pixmaps[HSBSliderMid] = pixmaps[HSBSliderMid]->xForm(rMatrix);
644 break; 646 break;
647 case HSBSliderTop:
645 case HSBSliderTopHover: 648 case HSBSliderTopHover:
646 pixmaps[HSBSliderTopHover] = processEmbedded("sbslider_top", btnHoverH, btnHoverS, btnHoverV, true); 649 pixmaps[item] = processEmbedded("sbslider_top", btnH, btnS, btnV, true );
647 *pixmaps[HSBSliderTopHover] = pixmaps[HSBSliderTopHover]->xForm(rMatrix); 650 *pixmaps[item] = pixmaps[item]->xForm(rMatrix);
648 break; 651 break;
652 case HSBSliderBtm:
649 case HSBSliderBtmHover: 653 case HSBSliderBtmHover:
650 pixmaps[HSBSliderBtmHover] = processEmbedded("sbslider_btm", btnHoverH, btnHoverS, btnHoverV, true); 654 pixmaps[item] = processEmbedded("sbslider_btm", btnH, btnS, btnV, true );
651 *pixmaps[HSBSliderBtmHover] = pixmaps[HSBSliderBtmHover]->xForm(rMatrix); 655 *pixmaps[item] = pixmaps[item]->xForm(rMatrix);
652 break; 656 break;
657 case HSBSliderMid:
653 case HSBSliderMidHover: 658 case HSBSliderMidHover:
654 pixmaps[HSBSliderMidHover] = processEmbedded("sbslider_mid", btnHoverH, btnHoverS, btnHoverV); 659 pixmaps[item] = processEmbedded("sbslider_mid", btnH, btnS, btnV);
655 *pixmaps[HSBSliderMidHover] = pixmaps[HSBSliderMidHover]->xForm(rMatrix); 660 *pixmaps[item] = pixmaps[item]->xForm(rMatrix);
656 break;
657 case VSBSliderTopBg:
658 pixmaps[VSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true);
659 break;
660 case VSBSliderBtmBg:
661 pixmaps[VSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true);
662 break;
663 case VSBSliderMidBg:
664 pixmaps[VSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV);
665 break; 661 break;
666 case HSBSliderTopBg: 662 case HSBSliderTopBg:
667 pixmaps[HSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true); 663 pixmaps[HSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true );
668 *pixmaps[HSBSliderTopBg] = pixmaps[HSBSliderTopBg]->xForm(rMatrix); 664 *pixmaps[HSBSliderTopBg] = pixmaps[HSBSliderTopBg]->xForm(rMatrix);
@@ -670,3 +666,3 @@ QPixmap* LiquidStyle::getPixmap(BitmapData item)
670 case HSBSliderBtmBg: 666 case HSBSliderBtmBg:
671 pixmaps[HSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true); 667 pixmaps[HSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true );
672 *pixmaps[HSBSliderBtmBg] = pixmaps[HSBSliderBtmBg]->xForm(rMatrix); 668 *pixmaps[HSBSliderBtmBg] = pixmaps[HSBSliderBtmBg]->xForm(rMatrix);
@@ -692,13 +688,2 @@ void LiquidStyle::polish(QPalette &appPal)
692 } 688 }
693 QWidgetList *list = QApplication::allWidgets();
694 QWidgetListIt it( *list );
695 QWidget *w;
696 while ((w=it.current()) != 0 ){
697 ++it;
698 if(w->inherits("QPushButton")){
699 unapplyCustomAttributes((QPushButton *)w);
700 }
701 }
702
703 loadCustomButtons();
704 lowLightVal = 100 + (2* /*KGlobalSettings::contrast()*/ 3 +4)*10; 689 lowLightVal = 100 + (2* /*KGlobalSettings::contrast()*/ 3 +4)*10;
@@ -721,7 +706,6 @@ void LiquidStyle::polish(QPalette &appPal)
721 config. setGroup ( "Appearance" ); 706 config. setGroup ( "Appearance" );
722 QColor c = // QColor ( config. readEntry("Button", ( Qt::lightGray ). name ( ))); 707 QColor c = oldqte ? QColor ( config. readEntry("Button", ( Qt::lightGray ). name ( )))
723 appPal. color ( QPalette::Active, QColorGroup::Button ); 708 : appPal. color ( QPalette::Active, QColorGroup::Button );
724 if ( c == appPal. color ( QPalette::Active, QColorGroup::Background ) 709 if ( c == ( oldqte ? QColor ( config. readEntry ( "background", ( Qt::lightGray ). name ( )))
725 //QColor ( config. readEntry ( "background", ( Qt::lightGray ). name ( ))) 710 : appPal. color ( QPalette::Active, QColorGroup::Background ))) {
726 ) {
727 // force button color to be different from background 711 // force button color to be different from background
@@ -760,4 +744,4 @@ void LiquidStyle::polish(QPalette &appPal)
760 } 744 }
761 pagerHoverBrush.setColor(c); 745// pagerHoverBrush.setColor(c);
762 pagerHoverBrush.setPixmap(*pix); 746// pagerHoverBrush.setPixmap(*pix);
763 747
@@ -772,7 +756,9 @@ void LiquidStyle::polish(QPalette &appPal)
772 } 756 }
773 pagerBrush.setColor(c); 757// pagerBrush.setColor(c);
774 pagerBrush.setPixmap(*pix); 758// pagerBrush.setPixmap(*pix);
775 759
776 // background color stuff 760 // background color stuff
777 c = /*QColor ( config. readEntry ( "Background", ( Qt::lightGray ).name ( )));*/ appPal. color ( QPalette::Active, QColorGroup::Background ); 761 c = oldqte ? QColor ( config. readEntry ( "Background", ( Qt::lightGray ).name ( )))
762 : appPal. color ( QPalette::Active, QColorGroup::Background );
763
778 c.hsv(&bH, &bS, &bV); 764 c.hsv(&bH, &bS, &bV);
@@ -800,29 +786,2 @@ void LiquidStyle::polish(QPalette &appPal)
800 appPal.setBrush(QColorGroup::Background, bgBrush); 786 appPal.setBrush(QColorGroup::Background, bgBrush);
801
802 // lineedits
803 c = /*QColor ( config. readEntry("Base", ( Qt::white). name ( )));*/ appPal. color ( QPalette::Active, QColorGroup::Base );
804 QPixmap basePix;
805 basePix.resize(32, 32);
806 basePix.fill(c.rgb());
807 painter.begin(&basePix);
808 painter.setPen(c.dark(105));
809 for(i=0; i < 32; i+=4){
810 painter.drawLine(0, i, 32, i);
811 painter.drawLine(0, i+1, 32, i+1);
812 };
813 painter.end();
814 baseBrush.setColor(c);
815 baseBrush.setPixmap(basePix);
816 it.toFirst();
817 while ((w=it.current()) != 0 ){
818 ++it;
819 if(w->inherits("QLineEdit")){
820 QPalette pal = w->palette();
821 pal.setBrush(QColorGroup::Base, baseBrush);
822 w->setPalette(pal);
823 }
824 else if(w->inherits("QPushButton")){
825 applyCustomAttributes((QPushButton *)w);
826 }
827 }
828} 787}
@@ -855,16 +814,6 @@ void LiquidStyle::polish(QWidget *w)
855 814
856 if(w->inherits("QComboBox") || w->inherits("QProgressBar") || 815 if(w->inherits("QRadioButton") || w->inherits("QCheckBox") || w->inherits("QProgressBar")) {
857 w->inherits("QLineEdit") || w->inherits("QRadioButton") ||
858 w->inherits("QCheckBox") || w->inherits("QScrollBar")) {
859 w->installEventFilter(this);
860 }
861 if(w->inherits("QLineEdit")){
862 QPalette pal = w->palette();
863 pal.setBrush(QColorGroup::Base, baseBrush);
864 w->setPalette(pal);
865 }
866 if(w->inherits("QPushButton")){
867 applyCustomAttributes((QPushButton *)w);
868 w->installEventFilter(this); 816 w->installEventFilter(this);
869 } 817 }
818
870 if(w->inherits("QButton") || w-> inherits("QComboBox")){ 819 if(w->inherits("QButton") || w-> inherits("QComboBox")){
@@ -902,6 +851,9 @@ void LiquidStyle::polish(QWidget *w)
902 } 851 }
903 if(w-> inherits("QToolButton")&&w->parent()->inherits("QToolBar")) { 852 if(w-> inherits("QToolButton")) {
904 ((QToolButton*)w)->setAutoRaise (flatTBButtons); 853 if (w->parent()->inherits("QToolBar")) {
905 if ( flatTBButtons ) 854 ((QToolButton*)w)->setAutoRaise (flatTBButtons);
906 w->setBackgroundOrigin(QWidget::ParentOrigin); 855 if ( flatTBButtons )
856 w->setBackgroundOrigin(QWidget::ParentOrigin);
857 }
858 w-> installEventFilter ( this );
907 } 859 }
@@ -973,6 +925,2 @@ void LiquidStyle::unPolish(QWidget *w)
973 925
974 if(w->inherits("QPushButton")){
975 unapplyCustomAttributes((QPushButton *)w);
976 w->removeEventFilter(this);
977 }
978/* 926/*
@@ -982,6 +930,4 @@ void LiquidStyle::unPolish(QWidget *w)
982*/ 930*/
983 if(w->inherits("QComboBox") || 931 if( w->inherits("QRadioButton") || w->inherits("QCheckBox") || w->inherits("QProgressBar")) {
984 w->inherits("QLineEdit") || w->inherits("QRadioButton") || 932 w->removeEventFilter(this);
985 w->inherits("QCheckBox") || w->inherits("QScrollBar")) {
986 w->removeEventFilter(this);
987 } 933 }
@@ -992,2 +938,5 @@ void LiquidStyle::unPolish(QWidget *w)
992 } 938 }
939 if(w-> inherits("QToolButton")) {
940 w-> removeEventFilter ( this );
941 }
993 if(w->inherits("QToolBar")){ 942 if(w->inherits("QToolBar")){
@@ -1097,2 +1046,22 @@ public:
1097 1046
1047/*
1048 * The same for QToolButton:
1049 * TT hardcoded the drawing of the focus rect ...
1050 *
1051 * - sandman
1052 */
1053
1054
1055class HackToolButton : public QToolButton {
1056public:
1057 HackToolButton ( );
1058
1059 void paint ( QPaintEvent *ev )
1060 {
1061 erase ( ev-> region ( ));
1062 QPainter p ( this );
1063 style ( ). drawToolButton ( this, &p );
1064 drawButtonLabel ( &p );
1065 }
1066};
1098 1067
@@ -1130,20 +1099,5 @@ bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev)
1130 } 1099 }
1131 else if(obj->inherits("QPushButton") || obj->inherits("QComboBox")){
1132 QWidget *btn = (QWidget *)obj;
1133 if(ev->type() == QEvent::Enter){
1134 if(btn->isEnabled()){
1135 highlightWidget = btn;
1136 btn->repaint(false);
1137 }
1138 }
1139 else if(ev->type() == QEvent::Leave){
1140 if(btn == highlightWidget){
1141 highlightWidget = NULL;
1142 btn->repaint(false);
1143 }
1144 }
1145 }
1146 else if(obj->inherits("QToolButton")){ 1100 else if(obj->inherits("QToolButton")){
1147 QToolButton *btn = (QToolButton *)btn; 1101 QToolButton *btn = (QToolButton *)obj;
1148 if(!btn->autoRaise()){ 1102 if(ev->type() == QEvent::FocusIn ){ // && !btn-> autoRaise ()
1149 if(btn->isEnabled()){ 1103 if(btn->isEnabled()){
@@ -1151,6 +1105,7 @@ bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev)
1151 btn->repaint(false); 1105 btn->repaint(false);
1106
1107 qDebug ( "TB FOCUS IN [%p]", btn );
1152 } 1108 }
1153 } 1109 }
1154 else if(ev->type() == QEvent::Leave){ 1110 else if(ev->type() == QEvent::FocusOut ){
1155 QWidget *btn = (QWidget *)obj;
1156 if(btn == highlightWidget){ 1111 if(btn == highlightWidget){
@@ -1158,43 +1113,9 @@ bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev)
1158 btn->repaint(false); 1113 btn->repaint(false);
1114
1115 qDebug ( "TB FOCUS OUT [%p]", btn );
1159 } 1116 }
1160 } 1117 }
1161 else 1118 else if(ev->type() == QEvent::Paint) {
1162 highlightWidget = NULL; 1119 (( HackToolButton *) btn )-> paint ((QPaintEvent *) ev );
1163 } 1120 return true;
1164 else if(obj->inherits("QScrollBar")){
1165 QScrollBar *sb = (QScrollBar *)obj;
1166 if(ev->type() == QEvent::Enter){
1167 if(sb->isEnabled()){
1168 highlightWidget = sb;
1169 sb->repaint(false);
1170 }
1171 }
1172 else if(ev->type() == QEvent::Leave){
1173 if(sb == highlightWidget && !sb->draggingSlider()){
1174 highlightWidget = NULL;
1175 sb->repaint(false);
1176 }
1177 }
1178 else if(ev->type() == QEvent::MouseButtonRelease){
1179 QMouseEvent *me = (QMouseEvent *)ev;
1180 if(sb == highlightWidget && !sb->rect().contains(me->pos())){
1181 highlightWidget = NULL;
1182 sb->repaint(false);
1183 }
1184 }
1185 }
1186 else if(obj->inherits("QLineEdit")){
1187 if(obj->parent() && obj->parent()->inherits("QComboBox")){
1188 QWidget *btn = (QComboBox *)obj->parent();
1189 if(ev->type() == QEvent::Enter){
1190 if (btn->isEnabled()){
1191 highlightWidget = btn;
1192 btn->repaint(false);
1193 }
1194 }
1195 else if(ev->type() == QEvent::Leave){
1196 if (btn == highlightWidget)
1197 highlightWidget = NULL;
1198 btn->repaint(false);
1199 }
1200 } 1121 }
@@ -1214,2 +1135,3 @@ bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev)
1214 1135
1136/*
1215 if(btn->hasFocus()){ 1137 if(btn->hasFocus()){
@@ -1222,3 +1144,4 @@ bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev)
1222 } 1144 }
1223 int x = 0; 1145*/
1146 int x = 0;
1224 int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; 1147 int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2;
@@ -1241,32 +1164,2 @@ bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev)
1241 } 1164 }
1242 // for hover, just redraw the indicator (not the text)
1243 else if((ev->type() == QEvent::Enter && btn->isEnabled()) ||
1244 (ev->type() == QEvent::Leave && btn == highlightWidget)){
1245 QButton *btn = (QButton *)obj;
1246 bool isRadio = obj->inherits("QRadioButton");
1247
1248 if(ev->type() == QEvent::Enter)
1249 highlightWidget = btn;
1250 else
1251 highlightWidget = NULL;
1252 QFontMetrics fm = btn->fontMetrics();
1253 QSize lsz = fm.size(ShowPrefix, btn->text());
1254 QSize sz = isRadio ? exclusiveIndicatorSize()
1255 : indicatorSize();
1256 int x = 0;
1257 int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2;
1258 //if(btn->autoMask())
1259 // btn->erase(x+1, y+1, sz.width()-2, sz.height()-2);
1260 QPainter p;
1261 p.begin(btn);
1262 if(isRadio)
1263 drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(),
1264 btn->colorGroup(), btn->isOn(),
1265 btn->isDown(), btn->isEnabled());
1266 else
1267 drawIndicator(&p, x, y, sz.width(), sz.height(),
1268 btn->colorGroup(), btn->state(), btn->isDown(),
1269 btn->isEnabled());
1270 p.end();
1271 }
1272 } 1165 }
@@ -1355,4 +1248,7 @@ void LiquidStyle::drawToolButton(QPainter *p, int x, int y, int w, int h,
1355 p->drawTiledPixmap(x+2, y+2, w-4, h-4, *pix); 1248 p->drawTiledPixmap(x+2, y+2, w-4, h-4, *pix);
1249 qDebug ( "DRAW TOOLBUTTON IN PIXMAP" );
1356 } 1250 }
1357 else{ 1251 else{
1252 qDebug ( "DRAW TOOLBUTTON sunken=%d/high=%p/device=%p", sunken, highlightWidget,p->device() );
1253
1358 drawClearBevel(p, x, y, w, h, sunken ? g.button() : 1254 drawClearBevel(p, x, y, w, h, sunken ? g.button() :
@@ -1513,3 +1409,16 @@ void LiquidStyle::drawComboButton(QPainter *painter, int x, int y, int w, int h,
1513{ 1409{
1514 bool isHover = highlightWidget == painter->device(); 1410 bool isActive = false;
1411 if (( painter->device()->devType() == QInternal::Widget ) &&
1412 (
1413 ( qApp-> focusWidget ( ) == painter-> device ( )) ||
1414 (
1415 edit &&
1416 ((QWidget *) painter-> device ( ))-> inherits ( "QComboBox" ) &&
1417 ( qApp-> focusWidget ( ) == ((QComboBox *) painter->device())->lineEdit ( ))
1418 )
1419 )
1420 ) {
1421 isActive = true;
1422 }
1423
1515 bool isMasked = false; 1424 bool isMasked = false;
@@ -1523,3 +1432,3 @@ void LiquidStyle::drawComboButton(QPainter *painter, int x, int y, int w, int h,
1523 sunken, false, isMasked); 1432 sunken, false, isMasked);
1524 if(!isHover){ 1433 if(!isActive){
1525 p.setClipRect(0, 0, w-17, h); 1434 p.setClipRect(0, 0, w-17, h);
@@ -1575,5 +1484,7 @@ QRect LiquidStyle::comboButtonRect(int x, int y, int w, int h)
1575 1484
1576QRect LiquidStyle::comboButtonFocusRect(int x, int y, int w, int h) 1485QRect LiquidStyle::comboButtonFocusRect(int /*x*/, int /*y*/, int /*w*/, int /*h*/)
1577{ 1486{
1578 return(QRect(x+5, y+3, w-(h/3)-13, h-5)); 1487 return QRect ( );
1488
1489// return(QRect(x+5, y+3, w-(h/3)-13, h-5));
1579} 1490}
@@ -1584,3 +1495,2 @@ void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb,
1584{ 1495{
1585 bool isHover = highlightWidget == p->device();
1586 int sliderMin, sliderMax, sliderLength, buttonDim; 1496 int sliderMin, sliderMax, sliderLength, buttonDim;
@@ -1673,12 +1583,6 @@ void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb,
1673 if(sliderR.height() >= 16){ 1583 if(sliderR.height() >= 16){
1674 painter.drawPixmap(sliderR.x()+1, sliderR.y(), 1584 painter.drawPixmap(sliderR.x()+1, sliderR.y(), *getPixmap(VSBSliderTop));
1675 isHover ? *getPixmap(VSBSliderTopHover):
1676 *getPixmap(VSBSliderTop));
1677 painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+8, 13, 1585 painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+8, 13,
1678 sliderR.height()-16, isHover ? 1586 sliderR.height()-16, *getPixmap(VSBSliderMid));
1679 *getPixmap(VSBSliderMidHover) : 1587 painter.drawPixmap(sliderR.x()+1, sliderR.bottom()-8, *getPixmap(VSBSliderBtm));
1680 *getPixmap(VSBSliderMid));
1681 painter.drawPixmap(sliderR.x()+1, sliderR.bottom()-8,
1682 isHover ? *getPixmap(VSBSliderBtmHover) :
1683 *getPixmap(VSBSliderBtm));
1684 } 1588 }
@@ -1686,8 +1590,4 @@ void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb,
1686 int m = sliderR.height()/2; 1590 int m = sliderR.height()/2;
1687 painter.drawPixmap(sliderR.x()+1, sliderR.y(), 1591 painter.drawPixmap(sliderR.x()+1, sliderR.y(), *getPixmap(VSBSliderTop), 0, 0, 13, m);
1688 isHover ? *getPixmap(VSBSliderTopHover): 1592 painter.drawPixmap(sliderR.x()+1, sliderR.y()+m, *getPixmap(VSBSliderBtm), 0, 8-m, 13, m);
1689 *getPixmap(VSBSliderTop), 0, 0, 13, m);
1690 painter.drawPixmap(sliderR.x()+1, sliderR.y()+m,
1691 isHover ? *getPixmap(VSBSliderBtmHover):
1692 *getPixmap(VSBSliderBtm), 0, 8-m, 13, m);
1693 } 1593 }
@@ -1699,3 +1599,2 @@ void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb,
1699 11, sliderR.height()-2, 1599 11, sliderR.height()-2,
1700 isHover ? *getPixmap(VSBSliderMidHover) :
1701 *getPixmap(VSBSliderMid), 1, 0); 1600 *getPixmap(VSBSliderMid), 1, 0);
@@ -1740,9 +1639,6 @@ void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb,
1740 painter.drawPixmap(sliderR.x(), sliderR.y()+1, 1639 painter.drawPixmap(sliderR.x(), sliderR.y()+1,
1741 isHover ? *getPixmap(HSBSliderTopHover) :
1742 *getPixmap(HSBSliderTop)); 1640 *getPixmap(HSBSliderTop));
1743 painter.drawTiledPixmap(sliderR.x()+8, sliderR.y()+1, sliderR.width()-16, 1641 painter.drawTiledPixmap(sliderR.x()+8, sliderR.y()+1, sliderR.width()-16,
1744 13, isHover ? *getPixmap(HSBSliderMidHover) : 1642 13, *getPixmap(HSBSliderMid));
1745 *getPixmap(HSBSliderMid)); 1643 painter.drawPixmap(sliderR.right()-8, sliderR.y()+1,
1746 painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, isHover ?
1747 *getPixmap(HSBSliderBtmHover) :
1748 *getPixmap(HSBSliderBtm)); 1644 *getPixmap(HSBSliderBtm));
@@ -1752,6 +1648,4 @@ void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb,
1752 painter.drawPixmap(sliderR.x(), sliderR.y()+1, 1648 painter.drawPixmap(sliderR.x(), sliderR.y()+1,
1753 isHover ? *getPixmap(HSBSliderTopHover) :
1754 *getPixmap(HSBSliderTop), 0, 0, m, 13); 1649 *getPixmap(HSBSliderTop), 0, 0, m, 13);
1755 painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, isHover ? 1650 painter.drawPixmap(sliderR.right()-8, sliderR.y()+1,
1756 *getPixmap(HSBSliderBtmHover) :
1757 *getPixmap(HSBSliderBtm), 8-m, 0, m, 13); 1651 *getPixmap(HSBSliderBtm), 8-m, 0, m, 13);
@@ -1763,4 +1657,3 @@ void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb,
1763 painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+2, 1657 painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+2,
1764 sliderR.width()-2, 11, isHover ? 1658 sliderR.width()-2, 11,
1765 *getPixmap(HSBSliderMidHover) :
1766 *getPixmap(HSBSliderMid), 0, 1); 1659 *getPixmap(HSBSliderMid), 0, 1);
@@ -1943,3 +1836,3 @@ void LiquidStyle::drawExclusiveIndicator(QPainter *p, int x, int y, int /*w*/,
1943{ 1836{
1944 bool isHover = highlightWidget == p->device(); 1837 bool isActive = ( p->device()->devType() == QInternal::Widget ) && ( qApp-> focusWidget ( ) == p-> device ( ));
1945 bool isMasked = p->device() && p->device()->devType() == QInternal::Widget 1838 bool isMasked = p->device() && p->device()->devType() == QInternal::Widget
@@ -1949,3 +1842,3 @@ void LiquidStyle::drawExclusiveIndicator(QPainter *p, int x, int y, int /*w*/,
1949 if(on || down){ 1842 if(on || down){
1950 p->drawPixmap(x, y, isHover ? *getPixmap(HTMLRadioDownHover) : 1843 p->drawPixmap(x, y, isActive ? *getPixmap(HTMLRadioDownHover) :
1951 *getPixmap(HTMLRadioDown)); 1844 *getPixmap(HTMLRadioDown));
@@ -1953,3 +1846,3 @@ void LiquidStyle::drawExclusiveIndicator(QPainter *p, int x, int y, int /*w*/,
1953 else 1846 else
1954 p->drawPixmap(x, y, isHover ? *getPixmap(HTMLRadioHover) : 1847 p->drawPixmap(x, y, isActive ? *getPixmap(HTMLRadioHover) :
1955 *getPixmap(HTMLRadio)); 1848 *getPixmap(HTMLRadio));
@@ -1959,3 +1852,3 @@ void LiquidStyle::drawExclusiveIndicator(QPainter *p, int x, int y, int /*w*/,
1959 if(on || down){ 1852 if(on || down){
1960 p->drawPixmap(x, y, isHover ? *getPixmap(RadioOnHover) : 1853 p->drawPixmap(x, y, isActive ? *getPixmap(RadioOnHover) :
1961 *getPixmap(RadioOn)); 1854 *getPixmap(RadioOn));
@@ -1963,3 +1856,3 @@ void LiquidStyle::drawExclusiveIndicator(QPainter *p, int x, int y, int /*w*/,
1963 else 1856 else
1964 p->drawPixmap(x, y, isHover ? *getPixmap(RadioOffHover) : 1857 p->drawPixmap(x, y, isActive ? *getPixmap(RadioOffHover) :
1965 *getPixmap(RadioOff)); 1858 *getPixmap(RadioOff));
@@ -1985,3 +1878,3 @@ void LiquidStyle::drawIndicator(QPainter *p, int x, int y, int /*w*/, int /*h*/,
1985{ 1878{
1986 bool isHover = highlightWidget == p->device(); 1879 bool isActive = ( p->device()->devType() == QInternal::Widget ) && ( qApp-> focusWidget ( ) == p-> device ( ));
1987 bool isMasked = p->device() && p->device()->devType() == QInternal::Widget 1880 bool isMasked = p->device() && p->device()->devType() == QInternal::Widget
@@ -1990,3 +1883,3 @@ void LiquidStyle::drawIndicator(QPainter *p, int x, int y, int /*w*/, int /*h*/,
1990 if(state != QButton::Off){ 1883 if(state != QButton::Off){
1991 p->drawPixmap(x, y, isHover ? *getPixmap(HTMLCBDownHover) : 1884 p->drawPixmap(x, y, isActive ? *getPixmap(HTMLCBDownHover) :
1992 *getPixmap(HTMLCBDown)); 1885 *getPixmap(HTMLCBDown));
@@ -1994,3 +1887,3 @@ void LiquidStyle::drawIndicator(QPainter *p, int x, int y, int /*w*/, int /*h*/,
1994 else 1887 else
1995 p->drawPixmap(x, y, isHover ? *getPixmap(HTMLCBHover) : 1888 p->drawPixmap(x, y, isActive ? *getPixmap(HTMLCBHover) :
1996 *getPixmap(HTMLCB)); 1889 *getPixmap(HTMLCB));
@@ -2000,3 +1893,3 @@ void LiquidStyle::drawIndicator(QPainter *p, int x, int y, int /*w*/, int /*h*/,
2000 if(state != QButton::Off){ 1893 if(state != QButton::Off){
2001 p->drawPixmap(x, y, isHover ? *getPixmap(CBDownHover) : 1894 p->drawPixmap(x, y, isActive ? *getPixmap(CBDownHover) :
2002 *getPixmap(CBDown)); 1895 *getPixmap(CBDown));
@@ -2017,3 +1910,3 @@ void LiquidStyle::drawIndicator(QPainter *p, int x, int y, int /*w*/, int /*h*/,
2017 else 1910 else
2018 p->drawPixmap(x, y, isHover ? *getPixmap(CBHover) : *getPixmap(CB)); 1911 p->drawPixmap(x, y, isActive ? *getPixmap(CBHover) : *getPixmap(CB));
2019 } 1912 }
@@ -2362,3 +2255,3 @@ void LiquidStyle::drawFocusRect(QPainter *p, const QRect &r,
2362 QWidget *w = (QWidget *)p->device(); 2255 QWidget *w = (QWidget *)p->device();
2363 if(w->inherits("QPushButton") || w->inherits("QSlider")){ 2256 if(w->inherits("QPushButton") || w->inherits("QSlider") || w->inherits("QComboBox") || w->inherits("QToolButton" )){
2364 return; 2257 return;
@@ -2715,106 +2608,2 @@ void LiquidStyle::drawSliderGrooveMask (QPainter * p, int x, int y, int w,
2715 2608
2716// I'm debating if to use QValueList or QList here. I like QValueList better,
2717// but QList handles pointers which is good for a lot of empty icons...
2718
2719void LiquidStyle::loadCustomButtons()
2720{
2721 return; // TODO
2722 customBtnColorList.clear();
2723 customBtnIconList.clear();
2724 customBtnLabelList.clear();
2725
2726// KConfig *config = KGlobal::config();
2727// QString oldGrp = config->group();
2728// config->setGroup("MosfetButtons");
2729
2730 QStrList iconList, colorList; //temp, we store QPixmaps and QColors
2731 iconList.setAutoDelete(true);
2732 colorList.setAutoDelete(true);
2733// config->readListEntry("Labels", customBtnLabelList);
2734// config->readListEntry("Icons", iconList);
2735// config->readListEntry("Colors", colorList);
2736
2737 const char *labelStr = customBtnLabelList.first();
2738 const char *colorStr = colorList.first();
2739 const char *iconStr = iconList.first();
2740
2741// KIconLoader *ldr = KGlobal::iconLoader();
2742 while(labelStr != NULL){
2743 QColor *c = new QColor;
2744 c->setNamedColor(QString(colorStr));
2745 customBtnColorList.append(c);
2746
2747 QString tmpStr(iconStr);
2748 if(!tmpStr.isEmpty()){
2749 QPixmap *pixmap =
2750 new QPixmap();//ldr->loadIcon(tmpStr, KIcon::Small));
2751 if(pixmap->isNull()){
2752 delete pixmap;
2753 customBtnIconList.append(NULL);
2754 }
2755 else
2756 customBtnIconList.append(pixmap);
2757 }
2758 else
2759 customBtnIconList.append(NULL);
2760
2761 labelStr = customBtnLabelList.next();
2762 colorStr = colorList.next();
2763 iconStr = iconList.next();
2764 }
2765}
2766
2767void LiquidStyle::applyCustomAttributes(QPushButton *btn)
2768{
2769 return; // TODO
2770 QString str = btn->text();
2771 if(str.isEmpty())
2772 return;
2773 while(str.contains('&') != 0)
2774 str = str.remove(str.find('&'), 1);
2775
2776 const char *s;
2777 int idx = 0;
2778 for(s = customBtnLabelList.first(); s != NULL;
2779 ++idx, s = customBtnLabelList.next()){
2780 if(qstricmp(s, str.latin1()) == 0){
2781 QPalette pal = btn->palette();
2782 pal.setColor(QColorGroup::Button,
2783 *customBtnColorList.at(idx));
2784 btn->setPalette(pal);
2785 /*
2786 if(customBtnIconList.at(idx) != NULL){
2787 QPixmap *pix = customBtnIconList.at(idx);
2788 btn->setIconSet(QIconSet(*pix));
2789 }*/
2790 break;
2791 }
2792 }
2793}
2794
2795void LiquidStyle::unapplyCustomAttributes(QPushButton *btn)
2796{
2797 return; // TODO
2798 QString str = btn->text();
2799 if(str.isEmpty())
2800 return;
2801 while(str.contains('&') != 0)
2802 str = str.remove(str.find('&'), 1);
2803
2804 const char *s;
2805 for(s = customBtnLabelList.first(); s != NULL; s = customBtnLabelList.next()){
2806 if(qstricmp(s, str.latin1()) == 0){
2807 btn->setPalette(QApplication::palette());
2808 btn->setIconSet(QIconSet());
2809 break;
2810 }
2811 }
2812}
2813
2814// #include "liquid.moc"
2815
2816
2817
2818
2819
2820 2609