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 | |||
@@ -1,16 +1,19 @@ | |||
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 | // | ||
6 | // (c) 2002 Robert 'sandman' Griebl | ||
7 | // | ||
5 | 8 | ||
6 | 9 | ||
7 | #ifndef INCLUDE_MENUITEM_DEF | 10 | #ifndef INCLUDE_MENUITEM_DEF |
8 | #define INCLUDE_MENUITEM_DEF | 11 | #define INCLUDE_MENUITEM_DEF |
9 | #endif | 12 | #endif |
10 | 13 | ||
11 | #include <qmenudata.h> | 14 | #include <qmenudata.h> |
12 | #include "liquid.h" | 15 | #include "liquid.h" |
13 | //#include "liquiddeco.h" | 16 | //#include "liquiddeco.h" |
14 | #include <qapplication.h> | 17 | #include <qapplication.h> |
15 | #include <qpe/config.h> | 18 | #include <qpe/config.h> |
16 | #include "effects.h" | 19 | #include "effects.h" |
@@ -22,24 +25,25 @@ | |||
22 | #include <qimage.h> | 25 | #include <qimage.h> |
23 | #include <qtimer.h> | 26 | #include <qtimer.h> |
24 | #include <qpixmapcache.h> | 27 | #include <qpixmapcache.h> |
25 | #include <qradiobutton.h> | 28 | #include <qradiobutton.h> |
26 | #include <qcombobox.h> | 29 | #include <qcombobox.h> |
27 | #include <qdrawutil.h> | 30 | #include <qdrawutil.h> |
28 | #include <qwidgetlist.h> | 31 | #include <qwidgetlist.h> |
29 | #include <qtoolbutton.h> | 32 | #include <qtoolbutton.h> |
30 | #include <qheader.h> | 33 | #include <qheader.h> |
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 | ||
37 | #include "htmlmasks.h" | 41 | #include "htmlmasks.h" |
38 | #include "embeddata.h" | 42 | #include "embeddata.h" |
39 | 43 | ||
40 | typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, | 44 | typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, |
41 | QColorGroup &, bool, bool); | 45 | QColorGroup &, bool, bool); |
42 | 46 | ||
43 | QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl); | 47 | QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl); |
44 | 48 | ||
45 | void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color) | 49 | void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color) |
@@ -153,47 +157,51 @@ bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev) | |||
153 | for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { | 157 | for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { |
154 | QWidget *wid = (QWidget *) it.current ( ); | 158 | QWidget *wid = (QWidget *) it.current ( ); |
155 | 159 | ||
156 | wid-> setBackgroundMode( QWidget::PaletteBackground ); | 160 | wid-> setBackgroundMode( QWidget::PaletteBackground ); |
157 | } | 161 | } |
158 | delete ol; | 162 | delete ol; |
159 | } | 163 | } |
160 | } | 164 | } |
161 | return(false); | 165 | return(false); |
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); |
173 | btnMaskBmp.setMask(btnMaskBmp); | 185 | btnMaskBmp.setMask(btnMaskBmp); |
174 | htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true); | 186 | htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true); |
175 | htmlBtnMaskBmp.setMask(htmlBtnMaskBmp); | 187 | htmlBtnMaskBmp.setMask(htmlBtnMaskBmp); |
176 | headerHoverID = -1; | 188 | headerHoverID = -1; |
177 | highlightWidget = NULL; | 189 | highlightWidget = NULL; |
178 | setButtonDefaultIndicatorWidth(0); | 190 | setButtonDefaultIndicatorWidth(0); |
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; |
191 | btnBlendPix->convertFromImage(qembed_findImage("buttonborder")); | 199 | btnBlendPix->convertFromImage(qembed_findImage("buttonborder")); |
192 | bevelFillPix = new QPixmap; | 200 | bevelFillPix = new QPixmap; |
193 | bevelFillPix->convertFromImage(qembed_findImage("clear_fill_large")); | 201 | bevelFillPix->convertFromImage(qembed_findImage("clear_fill_large")); |
194 | smallBevelFillPix = new QPixmap; | 202 | smallBevelFillPix = new QPixmap; |
195 | smallBevelFillPix->convertFromImage(qembed_findImage("clear_fill_small")); | 203 | smallBevelFillPix->convertFromImage(qembed_findImage("clear_fill_small")); |
196 | // new stuff | 204 | // new stuff |
197 | vsbSliderFillPix = menuPix = NULL; | 205 | vsbSliderFillPix = menuPix = NULL; |
198 | menuHandler = new TransMenuHandler(this); | 206 | menuHandler = new TransMenuHandler(this); |
199 | setScrollBarExtent(15, 15); | 207 | setScrollBarExtent(15, 15); |
@@ -535,204 +543,180 @@ QPixmap* LiquidStyle::getPixmap(BitmapData item) | |||
535 | { | 543 | { |
536 | 544 | ||
537 | if(pixmaps[item]) | 545 | if(pixmaps[item]) |
538 | return(pixmaps[item]); | 546 | return(pixmaps[item]); |
539 | 547 | ||
540 | switch(item){ | 548 | switch(item){ |
541 | case HTMLBtnBorder: | 549 | case HTMLBtnBorder: |
542 | pixmaps[HTMLBtnBorder] = processEmbedded("htmlbtnborder", btnH, btnS, btnV); | 550 | pixmaps[HTMLBtnBorder] = processEmbedded("htmlbtnborder", btnH, btnS, btnV); |
543 | break; | 551 | break; |
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: |
675 | pixmaps[HSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV); | 671 | pixmaps[HSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV); |
676 | *pixmaps[HSBSliderMidBg] = pixmaps[HSBSliderMidBg]->xForm(rMatrix); | 672 | *pixmaps[HSBSliderMidBg] = pixmaps[HSBSliderMidBg]->xForm(rMatrix); |
677 | break; | 673 | break; |
678 | default: | 674 | default: |
679 | break; | 675 | break; |
680 | } | 676 | } |
681 | return(pixmaps[item]); | 677 | return(pixmaps[item]); |
682 | } | 678 | } |
683 | 679 | ||
684 | void LiquidStyle::polish(QPalette &appPal) | 680 | void LiquidStyle::polish(QPalette &appPal) |
685 | { | 681 | { |
686 | int i; | 682 | int i; |
687 | for(i=0; i < BITMAP_ITEMS; ++i){ | 683 | for(i=0; i < BITMAP_ITEMS; ++i){ |
688 | if(pixmaps[i]){ | 684 | if(pixmaps[i]){ |
689 | delete pixmaps[i]; | 685 | delete pixmaps[i]; |
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(); |
707 | bevelFillDict.clear(); | 692 | bevelFillDict.clear(); |
708 | smallBevelFillDict.clear(); | 693 | smallBevelFillDict.clear(); |
709 | 694 | ||
710 | Config config ( "qpe" ); | 695 | Config config ( "qpe" ); |
711 | config. setGroup ( "Liquid-Style" ); | 696 | config. setGroup ( "Liquid-Style" ); |
712 | int contrast = config. readNumEntry ( "StippleContrast", 5 ); | 697 | int contrast = config. readNumEntry ( "StippleContrast", 5 ); |
713 | if ( contrast < 0 ) | 698 | if ( contrast < 0 ) |
714 | contrast = 0; | 699 | contrast = 0; |
715 | else if ( contrast > 10 ) | 700 | else if ( contrast > 10 ) |
716 | contrast = 10; | 701 | contrast = 10; |
717 | 702 | ||
718 | // QPalette pal = QApplication::palette(); | 703 | // QPalette pal = QApplication::palette(); |
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); |
730 | } | 714 | } |
731 | c.hsv(&btnH, &btnS, &btnV); | 715 | c.hsv(&btnH, &btnS, &btnV); |
732 | c.light(120).hsv(&btnHoverH, &btnHoverS, &btnHoverV); | 716 | c.light(120).hsv(&btnHoverH, &btnHoverS, &btnHoverV); |
733 | 717 | ||
734 | // menu pixmap | 718 | // menu pixmap |
735 | if(!menuPix){ | 719 | if(!menuPix){ |
736 | menuPix = new QPixmap; | 720 | menuPix = new QPixmap; |
737 | menuPix->resize(64, 64); | 721 | menuPix->resize(64, 64); |
738 | } | 722 | } |
@@ -749,91 +733,66 @@ void LiquidStyle::polish(QPalette &appPal) | |||
749 | menuBrush.setPixmap(*menuPix); | 733 | menuBrush.setPixmap(*menuPix); |
750 | 734 | ||
751 | // pager brush | 735 | // pager brush |
752 | c = c.dark(120); | 736 | c = c.dark(120); |
753 | QPixmap *pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) | 737 | QPixmap *pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) |
754 | if(!pix){ | 738 | if(!pix){ |
755 | int h, s, v; | 739 | int h, s, v; |
756 | c.hsv(&h, &s, &v); | 740 | c.hsv(&h, &s, &v); |
757 | pix = new QPixmap(*smallBevelFillPix); | 741 | pix = new QPixmap(*smallBevelFillPix); |
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 ;-) |
766 | if(!pix){ | 750 | if(!pix){ |
767 | int h, s, v; | 751 | int h, s, v; |
768 | c.hsv(&h, &s, &v); | 752 | c.hsv(&h, &s, &v); |
769 | pix = new QPixmap(*smallBevelFillPix); | 753 | pix = new QPixmap(*smallBevelFillPix); |
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 | ||
781 | // FIXME? | 767 | // FIXME? |
782 | if(vsbSliderFillPix) | 768 | if(vsbSliderFillPix) |
783 | delete vsbSliderFillPix; | 769 | delete vsbSliderFillPix; |
784 | vsbSliderFillPix = new QPixmap(bevelFillPix->xForm(rMatrix)); | 770 | vsbSliderFillPix = new QPixmap(bevelFillPix->xForm(rMatrix)); |
785 | adjustHSV(*vsbSliderFillPix, bH, bS, bV); | 771 | adjustHSV(*vsbSliderFillPix, bH, bS, bV); |
786 | 772 | ||
787 | // background brush | 773 | // background brush |
788 | QPixmap wallPaper(32, 32); | 774 | QPixmap wallPaper(32, 32); |
789 | wallPaper.fill(c.rgb()); | 775 | wallPaper.fill(c.rgb()); |
790 | painter.begin(&wallPaper); | 776 | painter.begin(&wallPaper); |
791 | for(i=0; i < 32; i+=4){ | 777 | for(i=0; i < 32; i+=4){ |
792 | painter.setPen(c.dark(100 + contrast)); | 778 | painter.setPen(c.dark(100 + contrast)); |
793 | painter.drawLine(0, i, 32, i); | 779 | painter.drawLine(0, i, 32, i); |
794 | painter.setPen(c.dark(100 + 3 * contrast / 5 ) ); | 780 | painter.setPen(c.dark(100 + 3 * contrast / 5 ) ); |
795 | painter.drawLine(0, i+1, 32, i+1); | 781 | painter.drawLine(0, i+1, 32, i+1); |
796 | }; | 782 | }; |
797 | painter.end(); | 783 | painter.end(); |
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) |
831 | { | 790 | { |
832 | if(w->inherits("QMenuBar")){ | 791 | if(w->inherits("QMenuBar")){ |
833 | //((QFrame*)w)->setLineWidth(0); | 792 | //((QFrame*)w)->setLineWidth(0); |
834 | w->setBackgroundMode(QWidget::PaletteBackground); | 793 | w->setBackgroundMode(QWidget::PaletteBackground); |
835 | w->setBackgroundOrigin(QWidget::ParentOrigin); | 794 | w->setBackgroundOrigin(QWidget::ParentOrigin); |
836 | return; | 795 | return; |
837 | } | 796 | } |
838 | if(w->inherits("QToolBar")){ | 797 | if(w->inherits("QToolBar")){ |
839 | w->installEventFilter(this); | 798 | w->installEventFilter(this); |
@@ -844,38 +803,28 @@ void LiquidStyle::polish(QWidget *w) | |||
844 | if(w->inherits("QPopupMenu")) | 803 | if(w->inherits("QPopupMenu")) |
845 | w->setBackgroundMode(QWidget::NoBackground); | 804 | w->setBackgroundMode(QWidget::NoBackground); |
846 | else if(w-> testWFlags(Qt::WType_Popup) && | 805 | else if(w-> testWFlags(Qt::WType_Popup) && |
847 | !w->inherits("QListBox") && | 806 | !w->inherits("QListBox") && |
848 | ( qstrcmp ( w-> name(), "automatic what's this? widget" ) != 0 )) { | 807 | ( qstrcmp ( w-> name(), "automatic what's this? widget" ) != 0 )) { |
849 | w->installEventFilter(menuHandler); | 808 | w->installEventFilter(menuHandler); |
850 | } | 809 | } |
851 | 810 | ||
852 | if(w->isTopLevel()){ | 811 | if(w->isTopLevel()){ |
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); |
873 | } | 822 | } |
874 | 823 | ||
875 | bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 || | 824 | bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 || |
876 | qstrcmp(w->name(), "qt_clipped_viewport") == 0; | 825 | qstrcmp(w->name(), "qt_clipped_viewport") == 0; |
877 | bool isViewportChild = w->parent() && | 826 | bool isViewportChild = w->parent() && |
878 | ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || | 827 | ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || |
879 | (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); | 828 | (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); |
880 | 829 | ||
881 | if(isViewport && w->parent() && qstrcmp(w->parent()->name(), "proxyview") == 0){ | 830 | if(isViewport && w->parent() && qstrcmp(w->parent()->name(), "proxyview") == 0){ |
@@ -891,28 +840,31 @@ void LiquidStyle::polish(QWidget *w) | |||
891 | w->setAutoMask(true); | 840 | w->setAutoMask(true); |
892 | w->setBackgroundMode(QWidget::NoBackground); | 841 | w->setBackgroundMode(QWidget::NoBackground); |
893 | } | 842 | } |
894 | } | 843 | } |
895 | } | 844 | } |
896 | return; | 845 | return; |
897 | } | 846 | } |
898 | } | 847 | } |
899 | if(w->inherits("QHeader")){ | 848 | if(w->inherits("QHeader")){ |
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 ); |
910 | } | 862 | } |
911 | if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){ | 863 | if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){ |
912 | return; | 864 | return; |
913 | } | 865 | } |
914 | 866 | ||
915 | if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())-> | 867 | if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())-> |
916 | palette().active().brush(QColorGroup::Background).pixmap()){ | 868 | palette().active().brush(QColorGroup::Background).pixmap()){ |
917 | qWarning("No parent pixmap for child widget %s", w->className()); | 869 | qWarning("No parent pixmap for child widget %s", w->className()); |
918 | return; | 870 | return; |
@@ -962,43 +914,40 @@ void LiquidStyle::unPolish(QWidget *w) | |||
962 | 914 | ||
963 | w->unsetPalette(); | 915 | w->unsetPalette(); |
964 | if(w->backgroundMode() == QWidget::X11ParentRelative || isViewportChild){ | 916 | if(w->backgroundMode() == QWidget::X11ParentRelative || isViewportChild){ |
965 | if(w->inherits("QPushButton")) | 917 | if(w->inherits("QPushButton")) |
966 | w->setBackgroundMode(QWidget::PaletteButton); | 918 | w->setBackgroundMode(QWidget::PaletteButton); |
967 | else | 919 | else |
968 | w->setBackgroundMode(QWidget::PaletteBackground); | 920 | w->setBackgroundMode(QWidget::PaletteBackground); |
969 | } | 921 | } |
970 | 922 | ||
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); |
996 | return; | 945 | return; |
997 | } | 946 | } |
998 | if(w->inherits("QHeader")){ | 947 | if(w->inherits("QHeader")){ |
999 | w->setMouseTracking(false); | 948 | w->setMouseTracking(false); |
1000 | w->removeEventFilter(this); | 949 | w->removeEventFilter(this); |
1001 | } | 950 | } |
1002 | } | 951 | } |
1003 | 952 | ||
1004 | void LiquidStyle::polish(QApplication *app) | 953 | void LiquidStyle::polish(QApplication *app) |
@@ -1086,24 +1035,44 @@ public: | |||
1086 | 1035 | ||
1087 | if ( progress ( )>= 0 && totalSteps ( ) > 0 ) { | 1036 | if ( progress ( )>= 0 && totalSteps ( ) > 0 ) { |
1088 | QString pstr; | 1037 | QString pstr; |
1089 | pstr. sprintf ( "%d%%", 100 * progress()/totalSteps ()); | 1038 | pstr. sprintf ( "%d%%", 100 * progress()/totalSteps ()); |
1090 | p. setPen ( g.text());//g.highlightedText ( )); | 1039 | p. setPen ( g.text());//g.highlightedText ( )); |
1091 | p. drawText (x,y,w-1,h-1,AlignCenter,pstr); | 1040 | p. drawText (x,y,w-1,h-1,AlignCenter,pstr); |
1092 | } | 1041 | } |
1093 | } | 1042 | } |
1094 | } | 1043 | } |
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 |
1101 | * force everything to erase and repaint on resize. This is going away, I'm | 1070 | * force everything to erase and repaint on resize. This is going away, I'm |
1102 | * trying to get shaped widgets to work right without masking. QPushButton, | 1071 | * trying to get shaped widgets to work right without masking. QPushButton, |
1103 | * QComboBox, and Panel applet handles capture mouse enter and leaves in order | 1072 | * QComboBox, and Panel applet handles capture mouse enter and leaves in order |
1104 | * to set the highlightwidget and repaint for mouse hovers. CheckBoxes and | 1073 | * to set the highlightwidget and repaint for mouse hovers. CheckBoxes and |
1105 | * RadioButtons need to do this differently. Qt buffers these in pixmaps and | 1074 | * RadioButtons need to do this differently. Qt buffers these in pixmaps and |
1106 | * caches them in QPixmapCache, which is bad for doing things like hover | 1075 | * caches them in QPixmapCache, which is bad for doing things like hover |
1107 | * because the style methods aren't called in paintEvents if everything | 1076 | * because the style methods aren't called in paintEvents if everything |
1108 | * is cached. We use our own Paint event handler instead. Taskbuttons and | 1077 | * is cached. We use our own Paint event handler instead. Taskbuttons and |
1109 | * pager buttons draw into a pixmap buffer, so we handle those with palette | 1078 | * pager buttons draw into a pixmap buffer, so we handle those with palette |
@@ -1119,165 +1088,89 @@ bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) | |||
1119 | if(ev->type() == QEvent::Resize){ | 1088 | if(ev->type() == QEvent::Resize){ |
1120 | const QObjectList *tbChildList = obj->children(); | 1089 | const QObjectList *tbChildList = obj->children(); |
1121 | QObjectListIt it(*tbChildList); | 1090 | QObjectListIt it(*tbChildList); |
1122 | QObject *child; | 1091 | QObject *child; |
1123 | while((child = it.current()) != NULL){ | 1092 | while((child = it.current()) != NULL){ |
1124 | ++it; | 1093 | ++it; |
1125 | if(child->isWidgetType()) | 1094 | if(child->isWidgetType()) |
1126 | ((QWidget *)child)->repaint(true); | 1095 | ((QWidget *)child)->repaint(true); |
1127 | } | 1096 | } |
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")){ |
1203 | QButton *btn = (QButton *)obj; | 1124 | QButton *btn = (QButton *)obj; |
1204 | bool isRadio = obj->inherits("QRadioButton"); | 1125 | bool isRadio = obj->inherits("QRadioButton"); |
1205 | if(ev->type() == QEvent::Paint){ | 1126 | if(ev->type() == QEvent::Paint){ |
1206 | //if(btn->autoMask()) | 1127 | //if(btn->autoMask()) |
1207 | btn->erase(); | 1128 | btn->erase(); |
1208 | QPainter p; | 1129 | QPainter p; |
1209 | p.begin(btn); | 1130 | p.begin(btn); |
1210 | QFontMetrics fm = btn->fontMetrics(); | 1131 | QFontMetrics fm = btn->fontMetrics(); |
1211 | QSize lsz = fm.size(ShowPrefix, btn->text()); | 1132 | QSize lsz = fm.size(ShowPrefix, btn->text()); |
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)); |
1218 | p.drawLine(r.x()+1, r.y(), r.right()-1, r.y()); | 1140 | p.drawLine(r.x()+1, r.y(), r.right()-1, r.y()); |
1219 | p.drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); | 1141 | p.drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); |
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(), |
1227 | btn->colorGroup(), btn->isOn(), | 1150 | btn->colorGroup(), btn->isOn(), |
1228 | btn->isDown(), btn->isEnabled()); | 1151 | btn->isDown(), btn->isEnabled()); |
1229 | else | 1152 | else |
1230 | drawIndicator(&p, x, y, sz.width(), sz.height(), | 1153 | drawIndicator(&p, x, y, sz.width(), sz.height(), |
1231 | btn->colorGroup(), btn->state(), btn->isDown(), | 1154 | btn->colorGroup(), btn->state(), btn->isDown(), |
1232 | btn->isEnabled()); | 1155 | btn->isEnabled()); |
1233 | x = sz.width() + 6; | 1156 | x = sz.width() + 6; |
1234 | y = 0; | 1157 | y = 0; |
1235 | drawItem(&p, sz.width()+6+1, 0, btn->width()-(sz.width()+6+1), | 1158 | drawItem(&p, sz.width()+6+1, 0, btn->width()-(sz.width()+6+1), |
1236 | btn->height(), AlignLeft|AlignVCenter|ShowPrefix, | 1159 | btn->height(), AlignLeft|AlignVCenter|ShowPrefix, |
1237 | btn->colorGroup(), btn->isEnabled(), | 1160 | btn->colorGroup(), btn->isEnabled(), |
1238 | btn->pixmap(), btn->text()); | 1161 | btn->pixmap(), btn->text()); |
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; |
1275 | if(ev->type() == QEvent::Enter){ | 1168 | if(ev->type() == QEvent::Enter){ |
1276 | currentHeader = hw; | 1169 | currentHeader = hw; |
1277 | headerHoverID = -1; | 1170 | headerHoverID = -1; |
1278 | } | 1171 | } |
1279 | else if(ev->type() == QEvent::Leave){ | 1172 | else if(ev->type() == QEvent::Leave){ |
1280 | currentHeader = NULL; | 1173 | currentHeader = NULL; |
1281 | if(headerHoverID != -1){ | 1174 | if(headerHoverID != -1){ |
1282 | hw->repaint(hw->sectionPos(headerHoverID), 0, | 1175 | hw->repaint(hw->sectionPos(headerHoverID), 0, |
1283 | hw->sectionSize(headerHoverID), hw->height()); | 1176 | hw->sectionSize(headerHoverID), hw->height()); |
@@ -1344,26 +1237,29 @@ void LiquidStyle::drawToolButton(QPainter *p, int x, int y, int w, int h, | |||
1344 | 1237 | ||
1345 | // fill | 1238 | // fill |
1346 | QPixmap *pix = bevelFillDict.find(c.rgb()); | 1239 | QPixmap *pix = bevelFillDict.find(c.rgb()); |
1347 | if(!pix){ | 1240 | if(!pix){ |
1348 | int h, s, v; | 1241 | int h, s, v; |
1349 | c.hsv(&h, &s, &v); | 1242 | c.hsv(&h, &s, &v); |
1350 | pix = new QPixmap(*bevelFillPix); | 1243 | pix = new QPixmap(*bevelFillPix); |
1351 | adjustHSV(*pix, h, s, v); | 1244 | adjustHSV(*pix, h, s, v); |
1352 | bevelFillDict.insert(c.rgb(), pix); | 1245 | bevelFillDict.insert(c.rgb(), pix); |
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()); |
1361 | } | 1257 | } |
1362 | } | 1258 | } |
1363 | 1259 | ||
1364 | void LiquidStyle::drawPushButton(QPushButton *btn, QPainter *p) | 1260 | void LiquidStyle::drawPushButton(QPushButton *btn, QPainter *p) |
1365 | { | 1261 | { |
1366 | QRect r = btn->rect(); | 1262 | QRect r = btn->rect(); |
1367 | bool sunken = btn->isOn() || btn->isDown(); | 1263 | bool sunken = btn->isOn() || btn->isDown(); |
1368 | QColorGroup g = btn->colorGroup(); | 1264 | QColorGroup g = btn->colorGroup(); |
1369 | 1265 | ||
@@ -1502,35 +1398,48 @@ void LiquidStyle::drawBevelButton(QPainter *p, int x, int y, int w, int h, | |||
1502 | g.background()); | 1398 | g.background()); |
1503 | } | 1399 | } |
1504 | 1400 | ||
1505 | QRect LiquidStyle::buttonRect(int x, int y, int w, int h) | 1401 | QRect LiquidStyle::buttonRect(int x, int y, int w, int h) |
1506 | { | 1402 | { |
1507 | return(QRect(x+5, y+5, w-10, h-10)); | 1403 | return(QRect(x+5, y+5, w-10, h-10)); |
1508 | } | 1404 | } |
1509 | 1405 | ||
1510 | void LiquidStyle::drawComboButton(QPainter *painter, int x, int y, int w, int h, | 1406 | 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(); |
1518 | // TODO: Do custom code, don't just call drawRoundButton into a pixmap | 1427 | // TODO: Do custom code, don't just call drawRoundButton into a pixmap |
1519 | QPixmap tmpPix(w, h); | 1428 | QPixmap tmpPix(w, h); |
1520 | QPainter p(&tmpPix); | 1429 | QPainter p(&tmpPix); |
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); |
1528 | } | 1437 | } |
1529 | p.end(); | 1438 | p.end(); |
1530 | int x2 = x+w-1; | 1439 | int x2 = x+w-1; |
1531 | int y2 = y+h-1; | 1440 | int y2 = y+h-1; |
1532 | int bx2 = btnMaskBmp.width()-1; | 1441 | int bx2 = btnMaskBmp.width()-1; |
1533 | int by2 = btnMaskBmp.height()-1; | 1442 | int by2 = btnMaskBmp.height()-1; |
1534 | QBitmap btnMask(w, h); | 1443 | QBitmap btnMask(w, h); |
1535 | QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp; | 1444 | QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp; |
1536 | p.begin(&btnMask); | 1445 | p.begin(&btnMask); |
@@ -1564,34 +1473,35 @@ void LiquidStyle::drawComboButton(QPainter *painter, int x, int y, int w, int h, | |||
1564 | 1473 | ||
1565 | void LiquidStyle::drawComboButtonMask(QPainter *p, int x, int y, int w, int h) | 1474 | void LiquidStyle::drawComboButtonMask(QPainter *p, int x, int y, int w, int h) |
1566 | { | 1475 | { |
1567 | drawButtonMask(p, x, y, w, h); | 1476 | drawButtonMask(p, x, y, w, h); |
1568 | } | 1477 | } |
1569 | 1478 | ||
1570 | QRect LiquidStyle::comboButtonRect(int x, int y, int w, int h) | 1479 | QRect LiquidStyle::comboButtonRect(int x, int y, int w, int h) |
1571 | { | 1480 | { |
1572 | //return(QRect(x+3, y+3, w - (h / 3) - 13, h-6)); | 1481 | //return(QRect(x+3, y+3, w - (h / 3) - 13, h-6)); |
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 | ||
1589 | if (sliderStart > sliderMax) | 1499 | if (sliderStart > sliderMax) |
1590 | sliderStart = sliderMax; | 1500 | sliderStart = sliderMax; |
1591 | 1501 | ||
1592 | bool horiz = sb->orientation() == QScrollBar::Horizontal; | 1502 | bool horiz = sb->orientation() == QScrollBar::Horizontal; |
1593 | QColorGroup g = sb->colorGroup(); | 1503 | QColorGroup g = sb->colorGroup(); |
1594 | QRect addB, subHC, subB; | 1504 | QRect addB, subHC, subB; |
1595 | QRect addPageR, subPageR, sliderR; | 1505 | QRect addPageR, subPageR, sliderR; |
1596 | int addX, addY, subX, subY; | 1506 | int addX, addY, subX, subY; |
1597 | int len = horiz ? sb->width() : sb->height(); | 1507 | int len = horiz ? sb->width() : sb->height(); |
@@ -1662,51 +1572,40 @@ void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb, | |||
1662 | painter.drawTiledPixmap(bgR.x()+1, bgR.y(), 13, bgR.height(), | 1572 | painter.drawTiledPixmap(bgR.x()+1, bgR.y(), 13, bgR.height(), |
1663 | *getPixmap(VSBSliderMidBg)); | 1573 | *getPixmap(VSBSliderMidBg)); |
1664 | painter.setPen(g.background().dark(210)); | 1574 | painter.setPen(g.background().dark(210)); |
1665 | painter.drawRect(bgR.x()+1, bgR.y(), 13, bgR.height()-1); | 1575 | painter.drawRect(bgR.x()+1, bgR.y(), 13, bgR.height()-1); |
1666 | painter.setPen(g.mid()); | 1576 | painter.setPen(g.mid()); |
1667 | painter.drawPoint(bgR.x()+1, bgR.y()); | 1577 | painter.drawPoint(bgR.x()+1, bgR.y()); |
1668 | painter.drawPoint(bgR.x()+13, bgR.y()); | 1578 | painter.drawPoint(bgR.x()+13, bgR.y()); |
1669 | painter.drawPoint(bgR.x()+1, bgR.bottom()-1); | 1579 | painter.drawPoint(bgR.x()+1, bgR.bottom()-1); |
1670 | painter.drawPoint(bgR.x()+13, bgR.bottom()-1); | 1580 | painter.drawPoint(bgR.x()+13, bgR.bottom()-1); |
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)); |
1696 | drawRoundRect(&painter, sliderR.x()+1, sliderR.y(), | 1596 | drawRoundRect(&painter, sliderR.x()+1, sliderR.y(), |
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 | } |
1704 | painter.setPen(g.mid()); | 1603 | painter.setPen(g.mid()); |
1705 | painter.drawLine(bgR.x(), bgR.y(), bgR.x(), bgR.bottom()); | 1604 | painter.drawLine(bgR.x(), bgR.y(), bgR.x(), bgR.bottom()); |
1706 | painter.drawLine(bgR.right(), bgR.y(), bgR.right(), bgR.bottom()); | 1605 | painter.drawLine(bgR.right(), bgR.y(), bgR.right(), bgR.bottom()); |
1707 | if(brokenApp && (controls & Slider)){ | 1606 | if(brokenApp && (controls & Slider)){ |
1708 | painter.setPen(g.background()); | 1607 | painter.setPen(g.background()); |
1709 | painter.drawLine(bgR.right()-1, bgR.y(), bgR.right()-1, | 1608 | painter.drawLine(bgR.right()-1, bgR.y(), bgR.right()-1, |
1710 | bgR.bottom()); | 1609 | bgR.bottom()); |
1711 | } | 1610 | } |
1712 | painter.end(); | 1611 | painter.end(); |
@@ -1729,49 +1628,43 @@ void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb, | |||
1729 | *getPixmap(HSBSliderMidBg)); | 1628 | *getPixmap(HSBSliderMidBg)); |
1730 | painter.setPen(g.background().dark(210)); | 1629 | painter.setPen(g.background().dark(210)); |
1731 | painter.drawRect(bgR.x(), bgR.y()+1, bgR.width()-1, 13); | 1630 | painter.drawRect(bgR.x(), bgR.y()+1, bgR.width()-1, 13); |
1732 | painter.setPen(g.mid()); | 1631 | painter.setPen(g.mid()); |
1733 | painter.drawPoint(bgR.x(), bgR.y()+1); | 1632 | painter.drawPoint(bgR.x(), bgR.y()+1); |
1734 | painter.drawPoint(bgR.x(), bgR.bottom()-1); | 1633 | painter.drawPoint(bgR.x(), bgR.bottom()-1); |
1735 | painter.drawPoint(bgR.right()-1, bgR.y()+1); | 1634 | painter.drawPoint(bgR.right()-1, bgR.y()+1); |
1736 | painter.drawPoint(bgR.right()-1, bgR.bottom()-1); | 1635 | painter.drawPoint(bgR.right()-1, bgR.bottom()-1); |
1737 | } | 1636 | } |
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{ |
1760 | painter.setPen(g.button().dark(210)); | 1654 | painter.setPen(g.button().dark(210)); |
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 | } |
1769 | painter.setPen(g.mid()); | 1662 | painter.setPen(g.mid()); |
1770 | painter.drawLine(bgR.x(), bgR.y(), bgR.right(), bgR.y()); | 1663 | painter.drawLine(bgR.x(), bgR.y(), bgR.right(), bgR.y()); |
1771 | painter.drawLine(bgR.x(), bgR.bottom(), bgR.right(), bgR.bottom()); | 1664 | painter.drawLine(bgR.x(), bgR.bottom(), bgR.right(), bgR.bottom()); |
1772 | if(brokenApp && (controls & Slider)){ | 1665 | if(brokenApp && (controls & Slider)){ |
1773 | painter.setPen(g.background()); | 1666 | painter.setPen(g.background()); |
1774 | painter.drawLine(bgR.x(), bgR.bottom()-1, bgR.right(), | 1667 | painter.drawLine(bgR.x(), bgR.bottom()-1, bgR.right(), |
1775 | bgR.bottom()-1); | 1668 | bgR.bottom()-1); |
1776 | } | 1669 | } |
1777 | painter.end(); | 1670 | painter.end(); |
@@ -1932,99 +1825,99 @@ QStyle::ScrollControl LiquidStyle::scrollBarPointOver(const QScrollBar *sb, | |||
1932 | #define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) | 1825 | #define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) |
1933 | 1826 | ||
1934 | 1827 | ||
1935 | QSize LiquidStyle::exclusiveIndicatorSize() const | 1828 | QSize LiquidStyle::exclusiveIndicatorSize() const |
1936 | { | 1829 | { |
1937 | return(QSize(16, 16)); | 1830 | return(QSize(16, 16)); |
1938 | } | 1831 | } |
1939 | 1832 | ||
1940 | void LiquidStyle::drawExclusiveIndicator(QPainter *p, int x, int y, int /*w*/, | 1833 | 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 | } |
1968 | 1861 | ||
1969 | void LiquidStyle::drawExclusiveIndicatorMask(QPainter *p, int x, int y, int w, | 1862 | void LiquidStyle::drawExclusiveIndicatorMask(QPainter *p, int x, int y, int w, |
1970 | int h, bool) | 1863 | int h, bool) |
1971 | { | 1864 | { |
1972 | p->fillRect(x, y, w, h, Qt::color0); | 1865 | p->fillRect(x, y, w, h, Qt::color0); |
1973 | p->setPen(Qt::color1); | 1866 | p->setPen(Qt::color1); |
1974 | p->drawPixmap(x, y, *getPixmap(RadioOn)->mask()); | 1867 | p->drawPixmap(x, y, *getPixmap(RadioOn)->mask()); |
1975 | } | 1868 | } |
1976 | 1869 | ||
1977 | 1870 | ||
1978 | QSize LiquidStyle::indicatorSize() const | 1871 | QSize LiquidStyle::indicatorSize() const |
1979 | { | 1872 | { |
1980 | return(QSize(20, 22)); | 1873 | return(QSize(20, 22)); |
1981 | } | 1874 | } |
1982 | 1875 | ||
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){ |
2005 | p->setPen(Qt::black); | 1898 | p->setPen(Qt::black); |
2006 | p->drawPixmap(3, 3, xBmp); | 1899 | p->drawPixmap(3, 3, xBmp); |
2007 | } | 1900 | } |
2008 | else{ | 1901 | else{ |
2009 | p->setPen(g.dark()); | 1902 | p->setPen(g.dark()); |
2010 | p->drawRect(x+2, y+2, w-4, h-4); | 1903 | p->drawRect(x+2, y+2, w-4, h-4); |
2011 | p->setPen(Qt::black); | 1904 | p->setPen(Qt::black); |
2012 | p->drawLine(x+3, (y+h)/2-2, x+w-4, (y+h)/2-2); | 1905 | p->drawLine(x+3, (y+h)/2-2, x+w-4, (y+h)/2-2); |
2013 | p->drawLine(x+3, (y+h)/2, x+w-4, (y+h)/2); | 1906 | p->drawLine(x+3, (y+h)/2, x+w-4, (y+h)/2); |
2014 | p->drawLine(x+3, (y+h)/2+2, x+w-4, (y+h)/2+2); | 1907 | p->drawLine(x+3, (y+h)/2+2, x+w-4, (y+h)/2+2); |
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 | ||
2022 | void LiquidStyle::drawIndicatorMask(QPainter *p, int x, int y, int /*w*/, int /*h*/, | 1915 | void LiquidStyle::drawIndicatorMask(QPainter *p, int x, int y, int /*w*/, int /*h*/, |
2023 | int /*state*/) | 1916 | int /*state*/) |
2024 | { | 1917 | { |
2025 | // needed for some reason by KHtml, even tho it's all filled ;P | 1918 | // needed for some reason by KHtml, even tho it's all filled ;P |
2026 | p->drawPixmap(x, y, *getPixmap(HTMLCB)->mask()); | 1919 | p->drawPixmap(x, y, *getPixmap(HTMLCB)->mask()); |
2027 | 1920 | ||
2028 | } | 1921 | } |
2029 | 1922 | ||
2030 | void LiquidStyle::drawSlider(QPainter *p, int x, int y, int w, int h, | 1923 | void LiquidStyle::drawSlider(QPainter *p, int x, int y, int w, int h, |
@@ -2351,25 +2244,25 @@ int LiquidStyle::popupMenuItemHeight(bool /*checkable*/, QMenuItem *mi, | |||
2351 | return h; | 2244 | return h; |
2352 | } | 2245 | } |
2353 | 2246 | ||
2354 | 2247 | ||
2355 | void LiquidStyle::drawFocusRect(QPainter *p, const QRect &r, | 2248 | void LiquidStyle::drawFocusRect(QPainter *p, const QRect &r, |
2356 | const QColorGroup &g, const QColor *c, | 2249 | const QColorGroup &g, const QColor *c, |
2357 | bool atBorder) | 2250 | bool atBorder) |
2358 | { | 2251 | { |
2359 | // are we painting a widget? | 2252 | // are we painting a widget? |
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{ |
2367 | QWindowsStyle::drawFocusRect(p, r, g, c, atBorder); | 2260 | QWindowsStyle::drawFocusRect(p, r, g, c, atBorder); |
2368 | } | 2261 | } |
2369 | } | 2262 | } |
2370 | else | 2263 | else |
2371 | QWindowsStyle::drawFocusRect(p, r, g, c, atBorder); | 2264 | QWindowsStyle::drawFocusRect(p, r, g, c, atBorder); |
2372 | 2265 | ||
2373 | } | 2266 | } |
2374 | 2267 | ||
2375 | void LiquidStyle::polishPopupMenu(QPopupMenu *mnu) | 2268 | void LiquidStyle::polishPopupMenu(QPopupMenu *mnu) |
@@ -2704,118 +2597,14 @@ void LiquidStyle::drawSliderGrooveMask (QPainter * p, int x, int y, int w, | |||
2704 | p->fillRect(x, y+1, w, 4, Qt::color1); | 2597 | p->fillRect(x, y+1, w, 4, Qt::color1); |
2705 | p->drawLine(x+1, y+5, x2-1, y+5); | 2598 | p->drawLine(x+1, y+5, x2-1, y+5); |
2706 | } | 2599 | } |
2707 | else{ | 2600 | else{ |
2708 | int y2 = y+h-1; | 2601 | int y2 = y+h-1; |
2709 | x+=2; | 2602 | x+=2; |
2710 | p->drawLine(x, y+1, x, y2-1); | 2603 | p->drawLine(x, y+1, x, y2-1); |
2711 | p->fillRect(x+1, y, 4, h, Qt::color1); | 2604 | p->fillRect(x+1, y, 4, h, Qt::color1); |
2712 | p->drawLine(x+5, y+1, x+5, y2-1); | 2605 | p->drawLine(x+5, y+1, x+5, y2-1); |
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: */ |