Diffstat (limited to 'noncore/styles/liquid/liquid.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/styles/liquid/liquid.cpp | 567 |
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 | |||
@@ -2,6 +2,9 @@ | |||
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 | // | ||
6 | // (c) 2002 Robert 'sandman' Griebl | ||
7 | // | ||
5 | 8 | ||
6 | 9 | ||
7 | #ifndef INCLUDE_MENUITEM_DEF | 10 | #ifndef INCLUDE_MENUITEM_DEF |
@@ -31,6 +34,7 @@ | |||
31 | #include <unistd.h> | 34 | #include <unistd.h> |
32 | #include <qmenubar.h> | 35 | #include <qmenubar.h> |
33 | #include <qprogressbar.h> | 36 | #include <qprogressbar.h> |
37 | #include <qlineedit.h> | ||
34 | 38 | ||
35 | #include <stdio.h> | 39 | #include <stdio.h> |
36 | 40 | ||
@@ -162,11 +166,19 @@ bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev) | |||
162 | } | 166 | } |
163 | 167 | ||
164 | 168 | ||
169 | static 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 | |||
165 | LiquidStyle::LiquidStyle() | 176 | LiquidStyle::LiquidStyle() |
166 | :QWindowsStyle() | 177 | :QWindowsStyle() |
167 | { | 178 | { |
168 | setName ( "LiquidStyle" ); | 179 | setName ( "LiquidStyle" ); |
169 | 180 | ||
181 | oldqte = ( qt_version ( ) < 234 ); | ||
170 | flatTBButtons = false; | 182 | flatTBButtons = false; |
171 | 183 | ||
172 | btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true); | 184 | btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true); |
@@ -179,12 +191,8 @@ LiquidStyle::LiquidStyle() | |||
179 | btnDict.setAutoDelete(true); | 191 | btnDict.setAutoDelete(true); |
180 | bevelFillDict.setAutoDelete(true); | 192 | bevelFillDict.setAutoDelete(true); |
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; |
189 | btnBorderPix->convertFromImage(qembed_findImage("buttonfill")); | 197 | btnBorderPix->convertFromImage(qembed_findImage("buttonfill")); |
190 | btnBlendPix = new QPixmap; | 198 | btnBlendPix = new QPixmap; |
@@ -544,131 +552,119 @@ QPixmap* LiquidStyle::getPixmap(BitmapData item) | |||
544 | case HTMLBtnBorderDown: | 552 | case HTMLBtnBorderDown: |
545 | pixmaps[HTMLBtnBorderDown] = processEmbedded("htmlbtnborder", btnHoverH, btnHoverS, btnHoverV); | 553 | pixmaps[HTMLBtnBorderDown] = processEmbedded("htmlbtnborder", btnHoverH, btnHoverS, btnHoverV); |
546 | break; | 554 | break; |
555 | |||
547 | case HTMLCB: | 556 | case HTMLCB: |
548 | pixmaps[HTMLCB] = processEmbedded("htmlcheckbox", bH, bS, bV); | 557 | pixmaps[HTMLCB] = processEmbedded("htmlcheckbox", bH, bS, bV); |
549 | break; | 558 | break; |
559 | case HTMLCBHover: | ||
560 | pixmaps[HTMLCBHover] = processEmbedded("htmlcheckbox", btnHoverH, btnHoverS, btnHoverV); | ||
561 | break; | ||
550 | case HTMLCBDown: | 562 | case HTMLCBDown: |
551 | pixmaps[HTMLCBDown] = processEmbedded("htmlcheckboxdown", btnH, btnS, btnV); | 563 | pixmaps[HTMLCBDown] = processEmbedded("htmlcheckboxdown", btnH, btnS, btnV); |
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); |
669 | break; | 665 | break; |
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); |
673 | break; | 669 | break; |
674 | case HSBSliderMidBg: | 670 | case HSBSliderMidBg: |
@@ -690,17 +686,6 @@ void LiquidStyle::polish(QPalette &appPal) | |||
690 | pixmaps[i] = NULL; | 686 | pixmaps[i] = NULL; |
691 | } | 687 | } |
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; |
705 | btnDict.clear(); | 690 | btnDict.clear(); |
706 | btnBorderDict.clear(); | 691 | btnBorderDict.clear(); |
@@ -719,11 +704,10 @@ void LiquidStyle::polish(QPalette &appPal) | |||
719 | 704 | ||
720 | // button color stuff | 705 | // button color stuff |
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 |
728 | QBrush btnBrush(QColor(200, 202, 228)); | 712 | QBrush btnBrush(QColor(200, 202, 228)); |
729 | appPal.setBrush(QColorGroup::Button, btnBrush); | 713 | appPal.setBrush(QColorGroup::Button, btnBrush); |
@@ -758,8 +742,8 @@ void LiquidStyle::polish(QPalette &appPal) | |||
758 | adjustHSV(*pix, h, s, v); | 742 | adjustHSV(*pix, h, s, v); |
759 | smallBevelFillDict.insert(c.rgb(), pix); | 743 | smallBevelFillDict.insert(c.rgb(), pix); |
760 | } | 744 | } |
761 | pagerHoverBrush.setColor(c); | 745 | // pagerHoverBrush.setColor(c); |
762 | pagerHoverBrush.setPixmap(*pix); | 746 | // pagerHoverBrush.setPixmap(*pix); |
763 | 747 | ||
764 | c = c.dark(120); | 748 | c = c.dark(120); |
765 | pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) | 749 | pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) |
@@ -770,11 +754,13 @@ void LiquidStyle::polish(QPalette &appPal) | |||
770 | adjustHSV(*pix, h, s, v); | 754 | adjustHSV(*pix, h, s, v); |
771 | smallBevelFillDict.insert(c.rgb(), pix); | 755 | smallBevelFillDict.insert(c.rgb(), pix); |
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); |
779 | c.light(120).hsv(&bHoverH, &bHoverS, &bHoverV); | 765 | c.light(120).hsv(&bHoverH, &bHoverS, &bHoverV); |
780 | 766 | ||
@@ -798,33 +784,6 @@ void LiquidStyle::polish(QPalette &appPal) | |||
798 | bgBrush.setColor(c); | 784 | bgBrush.setColor(c); |
799 | bgBrush.setPixmap(wallPaper); | 785 | bgBrush.setPixmap(wallPaper); |
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 | } |
829 | 788 | ||
830 | void LiquidStyle::polish(QWidget *w) | 789 | void LiquidStyle::polish(QWidget *w) |
@@ -853,20 +812,10 @@ void LiquidStyle::polish(QWidget *w) | |||
853 | return; | 812 | return; |
854 | } | 813 | } |
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")){ |
871 | w-> setBackgroundMode ( QWidget::PaletteBackground ); | 820 | w-> setBackgroundMode ( QWidget::PaletteBackground ); |
872 | w->setBackgroundOrigin ( QWidget::ParentOrigin); | 821 | w->setBackgroundOrigin ( QWidget::ParentOrigin); |
@@ -900,10 +849,13 @@ void LiquidStyle::polish(QWidget *w) | |||
900 | w->setMouseTracking(true); | 849 | w->setMouseTracking(true); |
901 | w->installEventFilter(this); | 850 | w->installEventFilter(this); |
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 | } |
908 | if(w-> inherits("QToolBarSeparator")&&w->parent()->inherits("QToolBar")) { | 860 | if(w-> inherits("QToolBarSeparator")&&w->parent()->inherits("QToolBar")) { |
909 | ((QFrame *) w)-> setFrameShape ( QFrame::NoFrame ); | 861 | ((QFrame *) w)-> setFrameShape ( QFrame::NoFrame ); |
@@ -971,25 +923,22 @@ void LiquidStyle::unPolish(QWidget *w) | |||
971 | if(isViewportChild) | 923 | if(isViewportChild) |
972 | w->setAutoMask(false); | 924 | w->setAutoMask(false); |
973 | 925 | ||
974 | if(w->inherits("QPushButton")){ | ||
975 | unapplyCustomAttributes((QPushButton *)w); | ||
976 | w->removeEventFilter(this); | ||
977 | } | ||
978 | /* | 926 | /* |
979 | if(w->inherits("QPushButton") || w-> inherits("QComboBox")){ | 927 | if(w->inherits("QPushButton") || w-> inherits("QComboBox")){ |
980 | w-> setBackgroundMode ( PaletteBackground ); | 928 | w-> setBackgroundMode ( PaletteBackground ); |
981 | } | 929 | } |
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 | } |
988 | if(w->inherits("QButton") || w->inherits("QComboBox")){ | 934 | if(w->inherits("QButton") || w->inherits("QComboBox")){ |
989 | if(w->parent() && w->parent()->inherits("KHTMLPart")){ | 935 | if(w->parent() && w->parent()->inherits("KHTMLPart")){ |
990 | w->setAutoMask(false); | 936 | w->setAutoMask(false); |
991 | } | 937 | } |
992 | } | 938 | } |
939 | if(w-> inherits("QToolButton")) { | ||
940 | w-> removeEventFilter ( this ); | ||
941 | } | ||
993 | if(w->inherits("QToolBar")){ | 942 | if(w->inherits("QToolBar")){ |
994 | w->removeEventFilter(this); | 943 | w->removeEventFilter(this); |
995 | w->setBackgroundMode(QWidget::PaletteBackground); | 944 | w->setBackgroundMode(QWidget::PaletteBackground); |
@@ -1095,6 +1044,26 @@ public: | |||
1095 | }; | 1044 | }; |
1096 | 1045 | ||
1097 | 1046 | ||
1047 | /* | ||
1048 | * The same for QToolButton: | ||
1049 | * TT hardcoded the drawing of the focus rect ... | ||
1050 | * | ||
1051 | * - sandman | ||
1052 | */ | ||
1053 | |||
1054 | |||
1055 | class HackToolButton : public QToolButton { | ||
1056 | public: | ||
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 | ||
1099 | /* | 1068 | /* |
1100 | * This is a fun method ;-) Here's an overview. KToolBar grabs resize to | 1069 | * This is a fun method ;-) Here's an overview. KToolBar grabs resize to |
@@ -1128,75 +1097,27 @@ bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) | |||
1128 | 1097 | ||
1129 | } | 1098 | } |
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()){ |
1150 | highlightWidget = btn; | 1104 | highlightWidget = btn; |
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){ |
1157 | highlightWidget = NULL; | 1112 | highlightWidget = NULL; |
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 | } |
1201 | } | 1122 | } |
1202 | else if(obj->inherits("QRadioButton") || obj->inherits("QCheckBox")){ | 1123 | else if(obj->inherits("QRadioButton") || obj->inherits("QCheckBox")){ |
@@ -1212,6 +1133,7 @@ bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) | |||
1212 | QSize sz = isRadio ? exclusiveIndicatorSize() | 1133 | QSize sz = isRadio ? exclusiveIndicatorSize() |
1213 | : indicatorSize(); | 1134 | : indicatorSize(); |
1214 | 1135 | ||
1136 | /* | ||
1215 | if(btn->hasFocus()){ | 1137 | if(btn->hasFocus()){ |
1216 | QRect r = QRect(0, 0, btn->width(), btn->height()); | 1138 | QRect r = QRect(0, 0, btn->width(), btn->height()); |
1217 | p.setPen(btn->colorGroup().button().dark(140)); | 1139 | p.setPen(btn->colorGroup().button().dark(140)); |
@@ -1220,7 +1142,8 @@ bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) | |||
1220 | p.drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); | 1142 | p.drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); |
1221 | p.drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); | 1143 | p.drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); |
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; |
1225 | if(isRadio) | 1148 | if(isRadio) |
1226 | drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), | 1149 | drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), |
@@ -1239,36 +1162,6 @@ bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) | |||
1239 | p.end(); | 1162 | p.end(); |
1240 | return(true); | 1163 | return(true); |
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 | } |
1273 | else if(obj->inherits("QHeader")){ | 1166 | else if(obj->inherits("QHeader")){ |
1274 | QHeader *hw = (QHeader *)obj; | 1167 | QHeader *hw = (QHeader *)obj; |
@@ -1353,8 +1246,11 @@ void LiquidStyle::drawToolButton(QPainter *p, int x, int y, int w, int h, | |||
1353 | } | 1246 | } |
1354 | 1247 | ||
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() : |
1359 | highlightWidget == p->device() ? g.button().light(110) : | 1255 | highlightWidget == p->device() ? g.button().light(110) : |
1360 | g.background(), g.background()); | 1256 | g.background(), g.background()); |
@@ -1511,7 +1407,20 @@ void LiquidStyle::drawComboButton(QPainter *painter, int x, int y, int w, int h, | |||
1511 | const QColorGroup &g, bool sunken, | 1407 | const QColorGroup &g, bool sunken, |
1512 | bool edit, bool, const QBrush *) | 1408 | bool edit, bool, const QBrush *) |
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; |
1516 | if(painter->device()->devType() == QInternal::Widget) | 1425 | if(painter->device()->devType() == QInternal::Widget) |
1517 | isMasked = ((QWidget*)painter->device())->autoMask(); | 1426 | isMasked = ((QWidget*)painter->device())->autoMask(); |
@@ -1521,7 +1430,7 @@ void LiquidStyle::drawComboButton(QPainter *painter, int x, int y, int w, int h, | |||
1521 | 1430 | ||
1522 | drawRoundButton(&p, g.button(), g.background(), 0, 0, w, h, false, | 1431 | drawRoundButton(&p, g.button(), g.background(), 0, 0, w, h, false, |
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); |
1526 | drawRoundButton(&p, g.background(), g.background(), 0, 0, w, h, false, | 1435 | drawRoundButton(&p, g.background(), g.background(), 0, 0, w, h, false, |
1527 | sunken, false, isMasked); | 1436 | sunken, false, isMasked); |
@@ -1573,16 +1482,17 @@ QRect LiquidStyle::comboButtonRect(int x, int y, int w, int h) | |||
1573 | return(QRect(x+9, y+3, w - (h / 3) - 20, h-6)); | 1482 | return(QRect(x+9, y+3, w - (h / 3) - 20, h-6)); |
1574 | } | 1483 | } |
1575 | 1484 | ||
1576 | QRect LiquidStyle::comboButtonFocusRect(int x, int y, int w, int h) | 1485 | QRect 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 | } |
1580 | 1491 | ||
1581 | void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb, | 1492 | void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb, |
1582 | int sliderStart, uint controls, | 1493 | int sliderStart, uint controls, |
1583 | uint activeControl) | 1494 | uint activeControl) |
1584 | { | 1495 | { |
1585 | bool isHover = highlightWidget == p->device(); | ||
1586 | int sliderMin, sliderMax, sliderLength, buttonDim; | 1496 | int sliderMin, sliderMax, sliderLength, buttonDim; |
1587 | scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); | 1497 | scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); |
1588 | 1498 | ||
@@ -1671,25 +1581,15 @@ void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb, | |||
1671 | } | 1581 | } |
1672 | if(controls & Slider){ | 1582 | if(controls & Slider){ |
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 | } |
1685 | else if(sliderR.height() >= 8){ | 1589 | else if(sliderR.height() >= 8){ |
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 | } |
1694 | else{ | 1594 | else{ |
1695 | painter.setPen(g.button().dark(210)); | 1595 | painter.setPen(g.button().dark(210)); |
@@ -1697,7 +1597,6 @@ void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb, | |||
1697 | 13, sliderR.height()); | 1597 | 13, sliderR.height()); |
1698 | painter.drawTiledPixmap(sliderR.x()+2, sliderR.y()+1, | 1598 | painter.drawTiledPixmap(sliderR.x()+2, sliderR.y()+1, |
1699 | 11, sliderR.height()-2, | 1599 | 11, sliderR.height()-2, |
1700 | isHover ? *getPixmap(VSBSliderMidHover) : | ||
1701 | *getPixmap(VSBSliderMid), 1, 0); | 1600 | *getPixmap(VSBSliderMid), 1, 0); |
1702 | } | 1601 | } |
1703 | } | 1602 | } |
@@ -1738,22 +1637,17 @@ void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb, | |||
1738 | if(controls & Slider){ | 1637 | if(controls & Slider){ |
1739 | if(sliderR.width() >= 16){ | 1638 | if(sliderR.width() >= 16){ |
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)); |
1749 | } | 1645 | } |
1750 | else if(sliderR.width() >= 8){ | 1646 | else if(sliderR.width() >= 8){ |
1751 | int m = sliderR.width()/2; | 1647 | int m = sliderR.width()/2; |
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); |
1758 | } | 1652 | } |
1759 | else{ | 1653 | else{ |
@@ -1761,8 +1655,7 @@ void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb, | |||
1761 | drawRoundRect(&painter, sliderR.x(), sliderR.y()+1, | 1655 | drawRoundRect(&painter, sliderR.x(), sliderR.y()+1, |
1762 | sliderR.width(), 13); | 1656 | sliderR.width(), 13); |
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); |
1767 | } | 1660 | } |
1768 | } | 1661 | } |
@@ -1941,27 +1834,27 @@ void LiquidStyle::drawExclusiveIndicator(QPainter *p, int x, int y, int /*w*/, | |||
1941 | int /*h*/, const QColorGroup &/*g*/, bool on, | 1834 | int /*h*/, const QColorGroup &/*g*/, bool on, |
1942 | bool down, bool) | 1835 | bool down, bool) |
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 |
1946 | && ((QWidget*)p->device())->autoMask(); | 1839 | && ((QWidget*)p->device())->autoMask(); |
1947 | 1840 | ||
1948 | if(isMasked){ | 1841 | if(isMasked){ |
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)); |
1952 | } | 1845 | } |
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)); |
1956 | 1849 | ||
1957 | } | 1850 | } |
1958 | else{ | 1851 | else{ |
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)); |
1962 | } | 1855 | } |
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)); |
1966 | } | 1859 | } |
1967 | } | 1860 | } |
@@ -1983,22 +1876,22 @@ QSize LiquidStyle::indicatorSize() const | |||
1983 | void LiquidStyle::drawIndicator(QPainter *p, int x, int y, int /*w*/, int /*h*/, | 1876 | void LiquidStyle::drawIndicator(QPainter *p, int x, int y, int /*w*/, int /*h*/, |
1984 | const QColorGroup &/*g*/, int state, bool /*down*/, bool) | 1877 | const QColorGroup &/*g*/, int state, bool /*down*/, bool) |
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 |
1988 | && ((QWidget*)p->device())->autoMask(); | 1881 | && ((QWidget*)p->device())->autoMask(); |
1989 | if(isMasked){ | 1882 | if(isMasked){ |
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)); |
1993 | } | 1886 | } |
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)); |
1997 | 1890 | ||
1998 | } | 1891 | } |
1999 | else{ | 1892 | else{ |
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)); |
2003 | /* Todo - tristate | 1896 | /* Todo - tristate |
2004 | if(state == QButton::On){ | 1897 | if(state == QButton::On){ |
@@ -2015,7 +1908,7 @@ void LiquidStyle::drawIndicator(QPainter *p, int x, int y, int /*w*/, int /*h*/, | |||
2015 | }*/ | 1908 | }*/ |
2016 | } | 1909 | } |
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 | } |
2020 | } | 1913 | } |
2021 | 1914 | ||
@@ -2360,7 +2253,7 @@ void LiquidStyle::drawFocusRect(QPainter *p, const QRect &r, | |||
2360 | if(p->device()->devType() == QInternal::Widget){ | 2253 | if(p->device()->devType() == QInternal::Widget){ |
2361 | // if so does it use a special focus rectangle? | 2254 | // if so does it use a special focus rectangle? |
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; |
2365 | } | 2258 | } |
2366 | else{ | 2259 | else{ |
@@ -2713,109 +2606,5 @@ void LiquidStyle::drawSliderGrooveMask (QPainter * p, int x, int y, int w, | |||
2713 | } | 2606 | } |
2714 | } | 2607 | } |
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 | |||
2719 | void 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 | |||
2767 | void 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 | |||
2795 | void 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 | ||
2821 | /* vim: set noet sw=8 ts=8: */ | 2610 | /* vim: set noet sw=8 ts=8: */ |