~ubuntu-branches/ubuntu/precise/kde-style-qtcurve/precise

« back to all changes in this revision

Viewing changes to style/qtcurve.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Thomas, Jonathan Thomas, Harald Sitter
  • Date: 2009-06-10 17:01:24 UTC
  • mfrom: (1.1.15 upstream)
  • Revision ID: james.westby@ubuntu.com-20090610170124-7w346g248vofffxk
Tags: 0.64.2-0ubuntu1
[ Jonathan Thomas ]
* New upstream release (LP: #385707)
* Use kde.mk from pkg-kde-tools
* Remove unnecessary build-dep on cmake, build-dep on the earliest version
  of kdelibs5-dev to depend on cmake

[ Harald Sitter ]
* Bump standards version to 3.8.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include "macmenu.h"
32
32
#endif
33
33
 
34
 
#if defined KDE4_FOUND && !defined QTC_NO_KDE4_LINKING
35
 
#define QTC_USE_KDE4
36
 
 
37
34
// TODO! REMOVE THIS WHEN KDE'S ICON SETTINGS ACTUALLY WORK!!!
38
35
#define QTC_FIX_DISABLED_ICONS
39
36
 
40
 
#endif
41
 
 
42
 
#ifdef QTC_USE_KDE4
 
37
#define QTC_MO_ARROW_X(MO, COL) (MO_GLOW==opts.coloredMouseOver && state&State_Enabled && MO ? itsMouseOverCols[QT_STD_BORDER] : COL)
 
38
#define QTC_MO_ARROW(COL)       QTC_MO_ARROW_X(state&State_MouseOver, COL)
 
39
 
 
40
static bool useQt3Settings()
 
41
{
 
42
    static const char *full = getenv("KDE_FULL_SESSION");
 
43
    static const char *vers = full ? getenv("KDE_SESSION_VERSION") : 0;
 
44
    static bool       use   = full && (!vers || atoi(vers)<4);
 
45
 
 
46
    return use;
 
47
}
 
48
 
 
49
#ifndef QTC_QT_ONLY
43
50
#include <KDE/KApplication>
44
51
#include <KDE/KAboutData>
45
52
#include <KDE/KGlobalSettings>
49
56
#include <KDE/KIcon>
50
57
#include <KDE/KComponentData>
51
58
#include <KDE/KTabWidget>
52
 
                           
53
 
static void applyKdeSettings(bool pal)
54
 
{
55
 
    if(pal)
56
 
        QApplication::setPalette(KGlobalSettings::createApplicationPalette());
57
 
    else
58
 
    {
59
 
        QApplication::setFont(KGlobalSettings::generalFont());
60
 
        QApplication::setFont(KGlobalSettings::menuFont(), "QMenuBar");
61
 
        QApplication::setFont(KGlobalSettings::menuFont(), "QMenu");
62
 
        QApplication::setFont(KGlobalSettings::menuFont(), "KPopupTitle");
63
 
// Don't set toolbar font - messes things up with Arora...
64
 
//         QApplication::setFont(KGlobalSettings::toolBarFont(), "QToolBar");
65
 
    }
66
 
}
 
59
#include <KDE/KColorScheme>
 
60
#include <KDE/KStandardDirs>
67
61
 
68
62
static KComponentData *theKComponentData=0;
69
63
static int            theInstanceCount=0;
70
64
 
71
 
static void checkKComponentData()
72
 
{
73
 
    if(!theKComponentData && !KGlobal::hasMainComponent())
74
 
    {
75
 
        //printf("Creating KComponentData\n");
76
 
 
77
 
        QString name(QApplication::applicationName());
78
 
 
79
 
        if(name.isEmpty())
80
 
            name=qAppName();
81
 
 
82
 
        if(name.isEmpty())
83
 
            name="QtApp";
84
 
 
85
 
        QByteArray utf8=name.toUtf8();
86
 
        theKComponentData=new KComponentData(KAboutData(utf8, utf8, ki18n(utf8), "0.1"));
87
 
// Dont call these here, as if we get called at app start, things seem to go wrong...
88
 
//         applyKdeSettings(true);
89
 
//         applyKdeSettings(false);
90
 
    }
91
 
}
92
 
 
93
 
#if defined QTC_USE_KDE4 && !defined QTC_DISABLE_KDEFILEDIALOG_CALLS && !KDE_IS_VERSION(4, 1, 0)
 
65
#if !defined QTC_DISABLE_KDEFILEDIALOG_CALLS && !KDE_IS_VERSION(4, 1, 0)
94
66
// KDE4.1 does this functionality for us!
95
67
#include <KDE/KFileDialog>
96
68
#include <KDE/KDirSelectDialog>
158
130
 
159
131
static QString getExistingDirectory(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options)
160
132
{
161
 
    checkKComponentData();
162
 
 
163
133
    KUrl url(KDirSelectDialog::selectDirectory(KUrl(dir), true, parent, caption));
164
134
 
165
135
    if(url.isLocalFile())
171
141
static QString getOpenFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter,
172
142
                               QFileDialog::Options)
173
143
{
174
 
    checkKComponentData();
175
 
 
176
144
    KFileDialog dlg(KUrl(dir), qt2KdeFilter(filter), parent);
177
145
 
178
146
    dlg.setOperationMode(KFileDialog::Opening);
191
159
static QStringList getOpenFileNames(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
192
160
                                    QString *selectedFilter, QFileDialog::Options)
193
161
{
194
 
    checkKComponentData();
195
 
 
196
162
    KFileDialog dlg(KUrl(dir), qt2KdeFilter(filter), parent);
197
163
 
198
164
    dlg.setOperationMode(KFileDialog::Opening);
211
177
static QString getSaveFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter,
212
178
                               QFileDialog::Options)
213
179
{
214
 
    checkKComponentData();
215
 
 
216
180
    KFileDialog dlg(KUrl(dir), qt2KdeFilter(filter), parent);
217
181
 
218
182
    dlg.setOperationMode(KFileDialog::Saving);
259
223
}
260
224
 
261
225
#endif
262
 
 
263
 
#endif // QTC_USE_KDE4
264
 
 
265
 
#ifdef QTC_FIX_DISABLED_ICONS
 
226
#endif
 
227
 
 
228
#if defined QTC_FIX_DISABLED_ICONS && !defined QTC_QT_ONLY
266
229
#include <KDE/KIconEffect>
267
230
QPixmap getIconPixmap(const QIcon &icon, const QSize &size, QIcon::Mode mode, QIcon::State)
268
231
{
345
308
#define QTC_STATE_REVERSE     (QStyle::StateFlag)0x10000000
346
309
#define QTC_STATE_MENU        (QStyle::StateFlag)0x20000000
347
310
#define QTC_STATE_KWIN_BUTTON (QStyle::StateFlag)0x40000000
348
 
#ifdef QTC_DONT_COLOUR_MOUSEOVER_TBAR_BUTTONS
349
311
#define QTC_STATE_TBAR_BUTTON (QStyle::StateFlag)0x80000000
350
 
#endif
351
312
 
352
313
#define M_PI 3.14159265358979323846
353
314
 
443
404
 
444
405
static bool isInQAbstractItemView(const QObject *w)
445
406
{
446
 
    int level=4;
 
407
    int level=8;
447
408
 
448
409
    while(w && --level>0)
449
410
    {
474
435
 
475
436
    // KHTML:  widget -> QWidget       -> QWidget    -> KHTMLView
476
437
    const QObject *w=widget && widget->parent() && widget->parent()->parent()
477
 
                        ? widget->parent()->parent()->parent() : NULL;
 
438
                        ? widget->parent()->parent()->parent() : 0L;
478
439
 
479
440
    return (w && isA(w, "KHTMLView")) || (widget && isInQAbstractItemView(widget->parentWidget()));
480
441
}
481
442
 
482
 
static QColor getLowerEtchCol(const QWidget *widget)
483
 
{
484
 
    QColor col(Qt::white);
485
 
 
486
 
    if(widget && widget->parentWidget() && !theNoEtchWidgets.contains(widget))
487
 
    {
488
 
        col=widget->parentWidget()->palette().color(widget->parentWidget()->backgroundRole());
489
 
        shade(col, &col, 1.06);
490
 
    }
491
 
    else
492
 
        col.setAlphaF(0.0);
493
 
 
494
 
    return col;
495
 
}
496
 
 
497
443
static QWidget * scrollViewFrame(QWidget *widget)
498
444
{
499
445
    QWidget *w=widget;
522
468
 
523
469
#define QTC_SB_SUB2 ((QStyle::SubControl)(QStyle::SC_ScrollBarGroove << 1))
524
470
 
525
 
static QString readEnvPath(const char *env)
526
 
{
527
 
   QByteArray path=getenv(env);
528
 
 
529
 
   return path.isEmpty() ? QString::null : QFile::decodeName(path);
530
 
}
531
 
 
532
471
static QString kdeHome()
533
472
{
534
 
    QString env(readEnvPath(getuid() ? "KDEHOME" : "KDEROOTHOME"));
 
473
#if defined QTC_QT_ONLY
 
474
    static QString kdeHomePath;
 
475
    if (kdeHomePath.isEmpty())
 
476
    {
 
477
        kdeHomePath = QString::fromLocal8Bit(qgetenv("KDEHOME"));
 
478
        if (kdeHomePath.isEmpty())
 
479
        {
 
480
            QDir    homeDir(QDir::homePath());
 
481
            QString kdeConfDir(QLatin1String("/.kde"));
 
482
            if (!useQt3Settings() && homeDir.exists(QLatin1String(".kde4")))
 
483
                kdeConfDir = QLatin1String("/.kde4");
 
484
            kdeHomePath = QDir::homePath() + kdeConfDir;
 
485
        }
 
486
    }
 
487
    return kdeHomePath;
535
488
 
536
 
    return env.isEmpty() ? QDir::homePath()+"/.kde" : env;
 
489
#else
 
490
    return KGlobal::dirs()->localkdedir();
 
491
#endif
537
492
}
538
493
 
539
 
static void getStyles(const QString &dir, const char *sub, QStringList &styles)
 
494
static void getStyles(const QString &dir, const char *sub, QSet<QString> &styles)
540
495
{
541
496
    QDir d(dir+sub);
542
497
 
556
511
            QString style((*it).left((*it).lastIndexOf(QTC_THEME_SUFFIX)));
557
512
 
558
513
            if(!styles.contains(style))
559
 
                styles.append(style);
 
514
                styles.insert(style);
560
515
        }
561
516
    }
562
517
}
563
518
 
564
 
static void getStyles(const QString &dir, QStringList &styles)
 
519
static void getStyles(const QString &dir, QSet<QString> &styles)
565
520
{
566
521
    getStyles(dir, QTC_THEME_DIR, styles);
567
522
    getStyles(dir, QTC_THEME_DIR4, styles);
592
547
 
593
548
    QStringList keys() const
594
549
    {
595
 
        QStringList list;
596
 
        list << "QtCurve";
597
 
 
598
 
        getStyles(kdeHome(), list);
599
 
        getStyles(KDE_PREFIX(3), list);
600
 
        getStyles(KDE_PREFIX(4), list);
601
 
 
602
 
        return list;
 
550
        QSet<QString> styles;
 
551
        styles.insert("QtCurve");
 
552
 
 
553
        getStyles(kdeHome(), styles);
 
554
        getStyles(KDE_PREFIX(3), styles);
 
555
        getStyles(KDE_PREFIX(4), styles);
 
556
 
 
557
        return styles.toList();
603
558
    }
604
559
 
605
560
    QStyle * create(const QString &key)
695
650
    p->setRenderHint(QPainter::Antialiasing, false);
696
651
}
697
652
 
698
 
inline QColor midColor(const QColor &a, const QColor &b, double factor=1.0)
699
 
{
700
 
    return QColor((a.red()+limit(b.red()*factor))>>1, 
701
 
                  (a.green()+limit(b.green()*factor))>>1, 
702
 
                  (a.blue()+limit(b.blue()*factor))>>1);
703
 
}
704
 
 
705
 
inline QColor tint(const QColor &a, const QColor &b, double factor=0.2)
706
 
{
707
 
    return QColor((int)((a.red()+(factor*b.red()))/(1+factor)),
708
 
                  (int)((a.green()+(factor*b.green()))/(1+factor)),
709
 
                  (int)((a.blue()+(factor*b.blue()))/(1+factor)));
710
 
}
711
 
 
712
 
static QColor shade(const QColor &a, float k)
713
 
{
714
 
    QColor mod;
715
 
 
716
 
    shade(a, &mod, k);
717
 
    return mod;
718
 
}
719
 
 
720
653
static bool isHoriz(const QStyleOption *option, EWidget w)
721
654
{
722
655
    return WIDGET_BUTTON(w) || option->state&QStyle::State_Horizontal;
771
704
           (((qulonglong)1)<<37);
772
705
}
773
706
 
774
 
#ifndef QTC_USE_KDE4
775
 
static void setRgb(QColor *col, const QStringList &rgb)
776
 
{
777
 
    if(3==rgb.size())
778
 
        *col=QColor(rgb[0].toInt(), rgb[1].toInt(), rgb[2].toInt());
779
 
}
780
 
#endif
781
 
 
782
707
static void parseWindowLine(const QString &line, QList<int> &data)
783
708
{
784
709
    int len(line.length());
811
736
        }
812
737
}
813
738
 
814
 
static bool useQt3Settings()
815
 
{
816
 
    static const char *full = getenv("KDE_FULL_SESSION");
817
 
    static const char *vers = full ? getenv("KDE_SESSION_VERSION") : 0;
818
 
    static bool       use   = full && (!vers || atoi(vers)<4);
819
 
 
820
 
    return use;
821
 
}
822
 
 
823
739
static const QPushButton * getButton(const QWidget *w, const QPainter *p)
824
740
{
825
741
    const QWidget *widget=w ? w : (p && p->device() ? dynamic_cast<const QWidget *>(p->device()) : 0L);
832
748
}
833
749
 
834
750
QtCurveStyle::QtCurveStyle(const QString &name)
835
 
            : itsSliderCols(NULL),
836
 
              itsDefBtnCols(NULL),
837
 
              itsMouseOverCols(NULL),
838
 
              itsSidebarButtonsCols(NULL),
839
 
              itsActiveMdiColors(NULL),
840
 
              itsMdiColors(NULL),
 
751
            : itsSliderCols(0L),
 
752
              itsDefBtnCols(0L),
 
753
              itsMouseOverCols(0L),
 
754
              itsComboBtnCols(0L),
 
755
              itsSidebarButtonsCols(0L),
 
756
              itsActiveMdiColors(0L),
 
757
              itsMdiColors(0L),
841
758
              itsPixmapCache(150000),
842
759
              itsActive(true),
843
 
              itsSbWidget(NULL),
 
760
              itsSbWidget(0L),
844
761
              itsProgressBarAnimateTimer(0),
845
762
              itsAnimateStep(0),
846
763
              itsPos(-1, -1),
847
 
              itsHoverWidget(NULL),
 
764
              itsHoverWidget(0L),
848
765
              itsQtVersion(VER_UNKNOWN)
849
766
{
850
 
#ifdef QTC_USE_KDE4
 
767
#if !defined QTC_QT_ONLY
851
768
    theInstanceCount++;
 
769
 
 
770
    if(!theKComponentData && !KGlobal::hasMainComponent())
 
771
    {
 
772
        //printf("Creating KComponentData\n");
 
773
 
 
774
        QString name(QApplication::applicationName());
 
775
 
 
776
        if(name.isEmpty())
 
777
            name=qAppName();
 
778
 
 
779
        if(name.isEmpty())
 
780
            name="QtApp";
 
781
 
 
782
        //QByteArray utf8=name.toUtf8();
 
783
        //theKComponentData=new KComponentData(KAboutData(utf8, utf8, ki18n(utf8), "0.1"));
 
784
        theKComponentData=new KComponentData(name.toLatin1(), name.toLatin1(), KComponentData::SkipMainComponentRegistration);
 
785
    }
 
786
 
852
787
#if !defined QTC_DISABLE_KDEFILEDIALOG_CALLS && !KDE_IS_VERSION(4, 1, 0)
853
788
    setFileDialogs();
854
789
#endif
855
 
    QTimer::singleShot(0, this, SLOT(setupKde4()));
856
790
    QDBusConnection::sessionBus().connect(QString(), "/KGlobalSettings", "org.kde.KGlobalSettings",
857
791
                                          "notifyChange", this, SLOT(kdeGlobalSettingsChange(int, int)));
858
792
#endif
876
810
    if(opts.contrast<0 || opts.contrast>10)
877
811
        opts.contrast=7;
878
812
 
879
 
    shadeColors(QApplication::palette().color(QPalette::Active, QPalette::Highlight), itsMenuitemCols);
 
813
    shadeColors(QApplication::palette().color(QPalette::Active, QPalette::Highlight), itsHighlightCols);
880
814
    shadeColors(QApplication::palette().color(QPalette::Active, QPalette::Background), itsBackgroundCols);
881
815
    shadeColors(QApplication::palette().color(QPalette::Active, QPalette::Button), itsButtonCols);
882
816
 
883
 
    if(SHADE_SELECTED==opts.shadeSliders)
884
 
        itsSliderCols=itsMenuitemCols;
885
 
    else if(SHADE_NONE!=opts.shadeSliders)
886
 
    {
887
 
        itsSliderCols=new QColor [TOTAL_SHADES+1];
888
 
        shadeColors(SHADE_BLEND_SELECTED==opts.shadeSliders
889
 
                        ? midColor(itsMenuitemCols[ORIGINAL_SHADE],
890
 
                                   itsButtonCols[ORIGINAL_SHADE])
891
 
                        : opts.customSlidersColor,
892
 
                    itsSliderCols);
893
 
    }
894
 
 
895
 
    if(IND_TINT==opts.defBtnIndicator)
896
 
    {
897
 
        itsDefBtnCols=new QColor [TOTAL_SHADES+1];
898
 
        shadeColors(tint(itsButtonCols[ORIGINAL_SHADE],
899
 
                         itsMenuitemCols[ORIGINAL_SHADE]), itsDefBtnCols);
900
 
    }
901
 
    else/* if(IND_COLORED==opts.defBtnIndicator)*/
902
 
    {
903
 
        if(SHADE_BLEND_SELECTED==opts.shadeSliders)
904
 
            itsDefBtnCols=itsSliderCols;
905
 
        else
906
 
        {
 
817
    // Set defaults for Hover and Focus, these will be changed when KDE4 palette is applied...
 
818
    shadeColors(QApplication::palette().color(QPalette::Active, QPalette::Highlight), itsFocusCols);
 
819
    if(opts.coloredMouseOver)
 
820
    {
 
821
        itsMouseOverCols=new QColor [TOTAL_SHADES+1];
 
822
        shadeColors(QApplication::palette().color(QPalette::Active, QPalette::Highlight), itsMouseOverCols);
 
823
    }
 
824
 
 
825
    switch(opts.shadeSliders)
 
826
    {
 
827
        default:
 
828
        case SHADE_DARKEN:
 
829
        case SHADE_NONE:
 
830
            break;
 
831
        case SHADE_SELECTED:
 
832
            itsSliderCols=itsHighlightCols;
 
833
            break;
 
834
        case SHADE_BLEND_SELECTED:
 
835
        case SHADE_CUSTOM:
 
836
            if(!itsSliderCols)
 
837
                itsSliderCols=new QColor [TOTAL_SHADES+1];
 
838
            shadeColors(SHADE_BLEND_SELECTED==opts.shadeSliders
 
839
                            ? midColor(itsHighlightCols[ORIGINAL_SHADE],
 
840
                                       itsButtonCols[ORIGINAL_SHADE])
 
841
                            : opts.customSlidersColor,
 
842
                        itsSliderCols);
 
843
    }
 
844
 
 
845
    switch(opts.defBtnIndicator)
 
846
    {
 
847
        case IND_GLOW:
 
848
            itsDefBtnCols=itsFocusCols;
 
849
            break;
 
850
        case IND_TINT:
907
851
            itsDefBtnCols=new QColor [TOTAL_SHADES+1];
908
 
            shadeColors(midColor(itsMenuitemCols[ORIGINAL_SHADE],
909
 
                                 itsButtonCols[ORIGINAL_SHADE]), itsDefBtnCols);
910
 
        }
911
 
    }
912
 
 
913
 
    if(opts.coloredMouseOver || IND_CORNER==opts.defBtnIndicator || IND_GLOW==opts.defBtnIndicator)
914
 
        if(itsDefBtnCols && IND_TINT!=opts.defBtnIndicator)
915
 
            itsMouseOverCols=itsDefBtnCols;
916
 
        else
917
 
        {
918
 
            itsMouseOverCols=new QColor [TOTAL_SHADES+1];
919
 
            shadeColors(midColor(itsMenuitemCols[ORIGINAL_SHADE],
920
 
                                 itsButtonCols[ORIGINAL_SHADE]), itsMouseOverCols);
921
 
        }
922
 
 
 
852
            shadeColors(tint(itsButtonCols[ORIGINAL_SHADE],
 
853
                            itsHighlightCols[ORIGINAL_SHADE], QTC_DEF_BNT_TINT), itsDefBtnCols);
 
854
            break;
 
855
        default:
 
856
            break;
 
857
        case IND_COLORED:
 
858
            if(SHADE_BLEND_SELECTED==opts.shadeSliders)
 
859
                itsDefBtnCols=itsSliderCols;
 
860
            else
 
861
            {
 
862
                itsDefBtnCols=new QColor [TOTAL_SHADES+1];
 
863
                shadeColors(midColor(itsHighlightCols[ORIGINAL_SHADE],
 
864
                                    itsButtonCols[ORIGINAL_SHADE]), itsDefBtnCols);
 
865
            }
 
866
    }
 
867
 
 
868
    switch(opts.comboBtn)
 
869
    {
 
870
        default:
 
871
        case SHADE_DARKEN:
 
872
        case SHADE_NONE:
 
873
            break;
 
874
        case SHADE_SELECTED:
 
875
            itsComboBtnCols=itsHighlightCols;
 
876
            break;
 
877
        case SHADE_BLEND_SELECTED:
 
878
            if(opts.shadeSliders==SHADE_BLEND_SELECTED)
 
879
            {
 
880
                itsComboBtnCols=itsSliderCols;
 
881
                break;
 
882
            }
 
883
        case SHADE_CUSTOM:
 
884
            if(opts.shadeSliders==SHADE_CUSTOM && opts.customSlidersColor==opts.customComboBtnColor)
 
885
            {
 
886
                itsComboBtnCols=itsSliderCols;
 
887
                break;
 
888
            }
 
889
            if(!itsComboBtnCols)
 
890
                itsComboBtnCols=new QColor [TOTAL_SHADES+1];
 
891
            shadeColors(SHADE_BLEND_SELECTED==opts.comboBtn
 
892
                            ? midColor(itsHighlightCols[ORIGINAL_SHADE],
 
893
                                       itsButtonCols[ORIGINAL_SHADE])
 
894
                            : opts.customComboBtnColor,
 
895
                        itsComboBtnCols);
 
896
    }
 
897
    
923
898
    setMenuColors(QApplication::palette().color(QPalette::Active, QPalette::Background));
924
899
 
925
900
    if(USE_LIGHTER_POPUP_MENU)
938
913
        case SHADE_CUSTOM:
939
914
            itsCheckRadioCol=opts.customCheckRadioColor;
940
915
    }
 
916
 
 
917
    if(opts.titlebarButtons&QTC_TITLEBAR_BUTTON_COLOR && NUM_TITLEBAR_BUTTONS==opts.titlebarButtonColors.size())
 
918
        for(int i=0; i<NUM_TITLEBAR_BUTTONS; ++i)
 
919
        {
 
920
            QColor *cols=new QColor [TOTAL_SHADES+1];
 
921
            shadeColors(opts.titlebarButtonColors[(ETitleBarButtons)i], cols);
 
922
            itsTitleBarButtonsCols[i]=cols;
 
923
        }
 
924
    else
 
925
        opts.titlebarButtons&=~QTC_TITLEBAR_BUTTON_COLOR;
 
926
 
 
927
#if !defined QTC_QT_ONLY
 
928
    setupKde4();
 
929
#endif
941
930
}
942
931
 
943
932
QtCurveStyle::~QtCurveStyle()
944
933
{
945
 
#ifdef QTC_USE_KDE4
 
934
#if !defined QTC_QT_ONLY
946
935
    if(0==--theInstanceCount && theKComponentData)
947
936
    {
948
937
        delete theKComponentData;
957
946
       itsSidebarButtonsCols!=itsSliderCols &&
958
947
       itsSidebarButtonsCols!=itsDefBtnCols)
959
948
        delete [] itsSidebarButtonsCols;
960
 
    if(itsActiveMdiColors && itsActiveMdiColors!=itsMenuitemCols)
 
949
    if(itsActiveMdiColors && itsActiveMdiColors!=itsHighlightCols)
961
950
        delete [] itsActiveMdiColors;
962
951
    if(itsMdiColors && itsMdiColors!=itsBackgroundCols)
963
952
        delete [] itsMdiColors;
964
953
    if(itsMouseOverCols && itsMouseOverCols!=itsDefBtnCols &&
965
954
       itsMouseOverCols!=itsSliderCols)
966
955
        delete [] itsMouseOverCols;
967
 
    if(itsDefBtnCols && itsDefBtnCols!=itsSliderCols)
 
956
    if(itsDefBtnCols && itsDefBtnCols!=itsSliderCols && itsDefBtnCols!=itsFocusCols)
968
957
        delete [] itsDefBtnCols;
969
 
    if(itsSliderCols && itsSliderCols!=itsMenuitemCols)
 
958
    if(itsSliderCols && itsSliderCols!=itsHighlightCols)
970
959
        delete [] itsSliderCols;
 
960
    if(itsComboBtnCols && itsComboBtnCols!=itsHighlightCols && itsComboBtnCols!=itsSliderCols)
 
961
        delete [] itsComboBtnCols;
 
962
 
 
963
    if(opts.titlebarButtons&QTC_TITLEBAR_BUTTON_COLOR)
 
964
        for(int i=0; i<NUM_TITLEBAR_BUTTONS; ++i)
 
965
            delete [] itsTitleBarButtonsCols[i];
971
966
}
972
967
 
973
968
static QString getFile(const QString &f)
1007
1002
            theThemedApp=APP_SYSTEMSETTINGS;
1008
1003
        else if("plasma"==appName)
1009
1004
            theThemedApp=APP_PLASMA;
1010
 
        else if("krunner"==appName || "krunner_lock"==appName)
 
1005
        else if("krunner"==appName || "krunner_lock"==appName || "kscreenlocker"==appName)
1011
1006
            theThemedApp=APP_KRUNNER;
1012
1007
        else if("konqueror"==appName)
1013
1008
            theThemedApp=APP_KONQUEROR;
1040
1035
    }
1041
1036
 
1042
1037
    bool newMenu(newContrast ||
1043
 
                 itsMenuitemCols[ORIGINAL_SHADE]!=palette.color(QPalette::Active, QPalette::Highlight)),
 
1038
                 itsHighlightCols[ORIGINAL_SHADE]!=palette.color(QPalette::Active, QPalette::Highlight)),
1044
1039
         newGray(newContrast ||
1045
1040
                 itsBackgroundCols[ORIGINAL_SHADE]!=palette.color(QPalette::Active, QPalette::Background)),
1046
1041
         newButton(newContrast ||
1047
1042
                   itsButtonCols[ORIGINAL_SHADE]!=palette.color(QPalette::Active, QPalette::Button)),
1048
 
         newSlider(itsSliderCols && (itsMenuitemCols!=itsSliderCols) /*&& SHADE_BLEND_SELECTED==opts.shadeSliders*/ &&
 
1043
         newSlider(itsSliderCols && itsHighlightCols!=itsSliderCols && SHADE_BLEND_SELECTED==opts.shadeSliders &&
1049
1044
                   (newContrast || newButton || newMenu)),
1050
1045
         newDefBtn(itsDefBtnCols && /*( (IND_COLORED==opts.defBtnIndicator &&*/
1051
1046
                                       SHADE_BLEND_SELECTED!=opts.shadeSliders/*) ||*/ // If so, def btn == slider!
1052
1047
                                      /*(IND_TINT==opts.defBtnIndicator) )*/ &&
1053
1048
                   (newContrast || newButton || newMenu)),
1054
 
         newMouseOver(itsMouseOverCols && itsMouseOverCols!=itsDefBtnCols &&
1055
 
                      itsMouseOverCols!=itsSliderCols &&
 
1049
         newMouseOver(itsMouseOverCols &&
 
1050
                     (newContrast || newButton || newMenu)),
 
1051
         newComboBtn(itsComboBtnCols && itsHighlightCols!=itsComboBtnCols && itsSliderCols!=itsComboBtnCols &&
 
1052
                     SHADE_BLEND_SELECTED==opts.comboBtn &&
1056
1053
                     (newContrast || newButton || newMenu));
1057
1054
 
1058
1055
    if(newGray)
1062
1059
        shadeColors(palette.color(QPalette::Active, QPalette::Button), itsButtonCols);
1063
1060
 
1064
1061
    if(newMenu)
1065
 
        shadeColors(palette.color(QPalette::Active, QPalette::Highlight), itsMenuitemCols);
 
1062
        shadeColors(palette.color(QPalette::Active, QPalette::Highlight), itsHighlightCols);
 
1063
 
 
1064
// Dont set these here, they will be updated in setDecorationColors()...
 
1065
//     shadeColors(QApplication::palette().color(QPalette::Active, QPalette::Highlight), itsFocusCols);
 
1066
//     if(opts.coloredMouseOver)
 
1067
//         shadeColors(QApplication::palette().color(QPalette::Active, QPalette::Highlight), itsMouseOverCols);
1066
1068
 
1067
1069
    setMenuColors(palette.color(QPalette::Active, QPalette::Background));
1068
1070
 
1069
1071
    if(newSlider)
1070
 
        shadeColors(midColor(itsMenuitemCols[ORIGINAL_SHADE],
 
1072
        shadeColors(midColor(itsHighlightCols[ORIGINAL_SHADE],
1071
1073
                    itsButtonCols[ORIGINAL_SHADE]), itsSliderCols);
1072
1074
 
 
1075
    if(newComboBtn)
 
1076
        shadeColors(midColor(itsHighlightCols[ORIGINAL_SHADE],
 
1077
                    itsButtonCols[ORIGINAL_SHADE]), itsComboBtnCols);
 
1078
 
1073
1079
    if(newDefBtn)
1074
1080
        if(IND_TINT==opts.defBtnIndicator)
1075
1081
            shadeColors(tint(itsButtonCols[ORIGINAL_SHADE],
1076
 
                        itsMenuitemCols[ORIGINAL_SHADE]), itsDefBtnCols);
1077
 
        else
1078
 
            shadeColors(midColor(itsMenuitemCols[ORIGINAL_SHADE],
 
1082
                        itsHighlightCols[ORIGINAL_SHADE], QTC_DEF_BNT_TINT), itsDefBtnCols);
 
1083
        else if(IND_GLOW!=opts.defBtnIndicator)
 
1084
            shadeColors(midColor(itsHighlightCols[ORIGINAL_SHADE],
1079
1085
                        itsButtonCols[ORIGINAL_SHADE]), itsDefBtnCols);
1080
1086
 
1081
 
    if(newMouseOver)
1082
 
        shadeColors(midColor(itsMenuitemCols[ORIGINAL_SHADE],
1083
 
                    itsButtonCols[ORIGINAL_SHADE]), itsMouseOverCols);
1084
 
 
1085
1087
    if(itsSidebarButtonsCols && SHADE_BLEND_SELECTED!=opts.shadeSliders &&
1086
1088
       IND_COLORED!=opts.defBtnIndicator)
1087
 
        shadeColors(midColor(itsMenuitemCols[ORIGINAL_SHADE],
 
1089
        shadeColors(midColor(itsHighlightCols[ORIGINAL_SHADE],
1088
1090
                   itsButtonCols[ORIGINAL_SHADE]), itsSidebarButtonsCols);
1089
1091
 
1090
1092
    if(USE_LIGHTER_POPUP_MENU && newGray)
1119
1121
        if(i!=QPalette::Highlight && i!=QPalette::HighlightedText)
1120
1122
            palette.setColor(QPalette::Inactive, (QPalette::ColorRole)i, palette.color(QPalette::Active, (QPalette::ColorRole)i));
1121
1123
 
1122
 
    if(opts.inactiveHighlight)
1123
 
    {
1124
 
        palette.setColor(QPalette::Inactive, QPalette::Highlight,
1125
 
                          midColor(palette.color(QPalette::Active, QPalette::Window),
1126
 
                                   palette.color(QPalette::Active, QPalette::Highlight), INACTIVE_HIGHLIGHT_FACTOR));
1127
 
        palette.setColor(QPalette::Inactive, QPalette::HighlightedText, palette.color(QPalette::Active, QPalette::WindowText));
1128
 
    }
 
1124
//     KConfigGroup group(KGlobal::config(), "ColorEffects:Inactive");
 
1125
//     if(group.readEntry("ChangeSelectionColor", group.readEntry("Enable", false)))
 
1126
//     {
 
1127
//         palette.setColor(QPalette::Inactive, QPalette::Highlight,
 
1128
//                           midColor(palette.color(QPalette::Active, QPalette::Window),
 
1129
//                                    palette.color(QPalette::Active, QPalette::Highlight), INACTIVE_HIGHLIGHT_FACTOR));
 
1130
//         palette.setColor(QPalette::Inactive, QPalette::HighlightedText, palette.color(QPalette::Active, QPalette::WindowText));
 
1131
//     }
 
1132
 
 
1133
    // Force this to be re-generated!
 
1134
    opts.customMenuStripeColor=Qt::black;
1129
1135
}
1130
1136
 
1131
1137
void QtCurveStyle::polish(QWidget *widget)
1148
1154
    if (QAbstractItemView *itemView = qobject_cast<QAbstractItemView*>(widget))
1149
1155
        itemView->viewport()->setAttribute(Qt::WA_Hover);
1150
1156
 
 
1157
    if(APP_KONTACT==theThemedApp && qobject_cast<QToolButton *>(widget))
 
1158
        ((QToolButton *)widget)->setAutoRaise(true);
 
1159
 
1151
1160
    if(enableMouseOver &&
1152
1161
       (qobject_cast<QPushButton *>(widget) ||
1153
1162
        qobject_cast<QAbstractButton*>(widget) ||
1205
1214
            widget->installEventFilter(this);
1206
1215
 
1207
1216
        if(opts.customMenuTextColor || SHADE_BLEND_SELECTED==opts.shadeMenubars ||
 
1217
           SHADE_SELECTED==opts.shadeMenubars ||
1208
1218
           (SHADE_CUSTOM==opts.shadeMenubars && TOO_DARK(itsMenubarCols[ORIGINAL_SHADE])))
1209
1219
        {
1210
1220
            QPalette pal(widget->palette());
1299
1309
                    layout->setMargin(0);
1300
1310
            }
1301
1311
 
1302
 
            QWidget *p=NULL;
 
1312
            QWidget *p=0L;
1303
1313
 
1304
1314
            if(opts.gtkComboMenus && widget->parentWidget() && (p=widget->parentWidget()->parentWidget()) &&
1305
1315
               qobject_cast<QComboBox *>(p) && !((QComboBox *)(p))->isEditable())
1395
1405
            widget->removeEventFilter(this);
1396
1406
 
1397
1407
        if(opts.customMenuTextColor || SHADE_BLEND_SELECTED==opts.shadeMenubars ||
 
1408
           SHADE_SELECTED==opts.shadeMenubars ||
1398
1409
           (SHADE_CUSTOM==opts.shadeMenubars &&TOO_DARK(itsMenubarCols[ORIGINAL_SHADE])))
1399
1410
            widget->setPalette(QApplication::palette());
1400
1411
    }
1666
1677
            {
1667
1678
                itsPos.setX(-1);
1668
1679
                itsPos.setY(-1);
1669
 
                itsHoverWidget=NULL;
 
1680
                itsHoverWidget=0L;
1670
1681
            }
1671
1682
 
1672
1683
            // The Destroy event is sent from ~QWidget, which happens after
1705
1716
                itsHoverWidget=(QWidget *)object;
1706
1717
 
1707
1718
                if(itsHoverWidget && !itsHoverWidget->isEnabled())
1708
 
                    itsHoverWidget=NULL;
 
1719
                    itsHoverWidget=0L;
1709
1720
            }
1710
1721
            break;
1711
1722
        case QEvent::Leave:
1713
1724
            {
1714
1725
                itsPos.setX(-1);
1715
1726
                itsPos.setY(-1);
1716
 
                itsHoverWidget=NULL;
 
1727
                itsHoverWidget=0L;
1717
1728
                ((QWidget *)object)->repaint();
1718
1729
            }
1719
1730
            break;
1798
1809
    switch(metric)
1799
1810
    {
1800
1811
#if QT_VERSION >= 0x040500
 
1812
        case PM_SubMenuOverlap:
 
1813
            return -2;
1801
1814
        case PM_ScrollView_ScrollBarSpacing:
1802
1815
#else
1803
1816
        case PM_TextCursorWidth+3:
1804
1817
#endif
1805
1818
            return 3;
 
1819
        case PM_MenuPanelWidth:
 
1820
            return opts.popupBorder ? pixelMetric(PM_DefaultFrameWidth, option, widget) : 0;
 
1821
        case PM_SizeGripSize:
 
1822
            return SIZE_GRIP_SIZE;
1806
1823
        case PM_TabBarScrollButtonWidth:
1807
1824
            return 18;
1808
1825
        case PM_HeaderMargin:
1865
1882
        case PM_ButtonDefaultIndicator:
1866
1883
            return 0;
1867
1884
        case PM_DefaultFrameWidth:
1868
 
//             if (widget && widget->inherits("QComboBoxPrivateContainer"))
1869
 
//                 return 1;
 
1885
            if (!opts.popupBorder && widget && widget->inherits("QComboBoxPrivateContainer"))
 
1886
                return 0;
1870
1887
 
1871
1888
            if (widget && widget->parentWidget() &&
1872
1889
                ::qobject_cast<const QFrame *>(widget) &&
1898
1915
            return QTC_DO_EFFECT
1899
1916
                        ? QTC_RADIO_SIZE+2 : QTC_RADIO_SIZE;
1900
1917
        case PM_TabBarTabOverlap:
1901
 
            return 1;
 
1918
            return TAB_MO_GLOW==opts.tabMouseOver ? 0 : 1;
1902
1919
        case PM_ProgressBarChunkWidth:
1903
1920
            return 4;
1904
1921
//         case PM_DockWindowSeparatorExtent:
1962
1979
                case ALIGN_RIGHT:
1963
1980
                    return Qt::AlignRight;
1964
1981
            }
 
1982
        case QtC_TitleBarButtons:
 
1983
            return opts.titlebarButtons;
 
1984
        case QtC_TitleBarIcon:
 
1985
            return opts.titlebarIcon;
 
1986
        case QtC_TitleBarIconColor:
 
1987
            return buttonColors(option)[ORIGINAL_SHADE].rgb();
1965
1988
// The following is a somewhat hackyish fix for konqueror's show close button on tab setting...
1966
1989
// ...its hackish in the way that I'm assuming when KTabBar is positioning the close button and it
1967
1990
// asks for these options, it only passes in a QStyleOption  not a QStyleOptionTab
1985
2008
{
1986
2009
    switch (hint)
1987
2010
    {
 
2011
        case SH_RubberBand_Mask:
 
2012
        {
 
2013
            const QStyleOptionRubberBand *opt = qstyleoption_cast<const QStyleOptionRubberBand *>(option);
 
2014
            if (!opt)
 
2015
                return true;
 
2016
            if (QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(returnData)) 
 
2017
            {
 
2018
                mask->region = option->rect;
 
2019
                mask->region -= option->rect.adjusted(1,1,-1,-1);
 
2020
            }
 
2021
            return true;
 
2022
        }
 
2023
        case SH_Menu_SubMenuPopupDelay:
 
2024
            return opts.menuDelay;
 
2025
        case SH_ToolButton_PopupDelay:
 
2026
            return 250;
 
2027
        case SH_Menu_AllowActiveAndDisabled:
 
2028
            return false;
1988
2029
        case SH_ComboBox_PopupFrameStyle:
1989
2030
            return QFrame::StyledPanel|QFrame::Plain;
1990
2031
        case SH_TabBar_Alignment:
2013
2054
                mask->region -= QRect(r.right(), r.top() + 1, 1, 1);
2014
2055
 
2015
2056
                const QStyleOptionTitleBar *titleBar = qstyleoption_cast<const QStyleOptionTitleBar *>(option);
2016
 
                if (titleBar && (titleBar->titleBarState & Qt::WindowMinimized))
 
2057
                if (titleBar && (titleBar->titleBarState&Qt::WindowMinimized))
2017
2058
                {
2018
2059
                    mask->region -= QRect(r.left(), r.bottom(), 2, 1);
2019
2060
                    mask->region -= QRect(r.right() - 1, r.bottom(), 2, 1);
2094
2135
        case SH_FormLayoutWrapPolicy:
2095
2136
            return QFormLayout::DontWrapRows;
2096
2137
#endif
2097
 
#ifdef QTC_USE_KDE4
 
2138
#if !defined QTC_QT_ONLY
2098
2139
        case SH_DialogButtonBox_ButtonsHaveIcons:
2099
 
            checkKComponentData();
2100
2140
            return KGlobalSettings::showIconsOnPushButtons();
2101
2141
        case SH_ItemView_ActivateItemOnSingleClick:
2102
 
            checkKComponentData();
2103
2142
            return KGlobalSettings::singleClick();
2104
2143
#endif
2105
2144
        case SH_MenuBar_AltKeyNavigation:
2106
2145
            return false;
2107
2146
        default:
 
2147
#if !defined QTC_QT_ONLY
2108
2148
            // Tell the calling app that we can handle certain custom widgets...
2109
2149
            if(hint>=SH_CustomBase && widget)
2110
2150
                if("CE_CapacityBar"==widget->objectName())
2111
2151
                    return CE_QtC_KCapacityBar;
 
2152
#endif
2112
2153
            return QTC_BASE_STYLE::styleHint(hint, option, widget, returnData);
2113
2154
   }
2114
2155
}
2115
2156
 
2116
2157
QPalette QtCurveStyle::standardPalette() const
2117
2158
{
2118
 
#ifdef QTC_USE_KDE4
 
2159
#if defined QTC_QT_ONLY
 
2160
    return QTC_BASE_STYLE::standardPalette();
 
2161
#else
2119
2162
    return KGlobalSettings::createApplicationPalette(KSharedConfig::openConfig(KGlobal::mainComponent()));
2120
 
#else
2121
 
    return QCommonStyle::standardPalette();
2122
2163
#endif
2123
2164
}
2124
2165
 
2125
2166
QPixmap QtCurveStyle::standardPixmap(StandardPixmap pix, const QStyleOption *option, const QWidget *widget) const
2126
2167
{
2127
 
#ifdef QTC_USE_KDE4
2128
 
    checkKComponentData();
 
2168
#if !defined QTC_QT_ONLY
2129
2169
    bool fd(widget && qobject_cast<const QFileDialog *>(widget));
2130
2170
 
2131
2171
    switch(pix)
2267
2307
 
2268
2308
QIcon QtCurveStyle::standardIconImplementation(StandardPixmap pix, const QStyleOption *option, const QWidget *widget) const
2269
2309
{
2270
 
#ifdef QTC_USE_KDE4
2271
 
    checkKComponentData();
 
2310
#if !defined QTC_QT_ONLY
2272
2311
    switch(pix)
2273
2312
    {
2274
2313
//         case SP_TitleBarMenuButton:
2512
2551
            if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option))
2513
2552
                drawArrow(painter, r,
2514
2553
                          header->sortIndicator & QStyleOptionHeader::SortUp ? PE_IndicatorArrowUp : PE_IndicatorArrowDown, 
2515
 
                          option->palette.buttonText().color());
 
2554
                          QTC_MO_ARROW(option->palette.buttonText().color()));
2516
2555
            break;
2517
2556
        case PE_IndicatorArrowUp:
2518
2557
        case PE_IndicatorArrowDown:
2520
2559
        case PE_IndicatorArrowRight:
2521
2560
            if(state&(State_Sunken|State_On))
2522
2561
                r.adjust(1, 1, 1, 1);
2523
 
            drawArrow(painter, r, element, palette.text().color());
 
2562
            drawArrow(painter, r, element, QTC_MO_ARROW(palette.text().color()));
2524
2563
            break;
2525
2564
        case PE_IndicatorSpinMinus:
2526
2565
        case PE_IndicatorSpinPlus:
2531
2570
            const QColor *use(buttonColors(option));
2532
2571
            bool         down(PE_IndicatorSpinDown==element || PE_IndicatorSpinMinus==element);
2533
2572
 
2534
 
            drawLightBevel(painter, sr, option, widget, down
2535
 
                                                  ? reverse
2536
 
                                                        ? ROUNDED_BOTTOMLEFT
2537
 
                                                        : ROUNDED_BOTTOMRIGHT
2538
 
                                                    : reverse
2539
 
                                                        ? ROUNDED_TOPLEFT
2540
 
                                                        : ROUNDED_TOPRIGHT,
2541
 
                           getFill(option, use), use, true, WIDGET_SPIN);
 
2573
            if(!opts.unifySpinBtns || state&State_Sunken)
 
2574
                drawLightBevel(painter, sr, option, widget, down
 
2575
                                                    ? reverse
 
2576
                                                            ? ROUNDED_BOTTOMLEFT
 
2577
                                                            : ROUNDED_BOTTOMRIGHT
 
2578
                                                        : reverse
 
2579
                                                            ? ROUNDED_TOPLEFT
 
2580
                                                            : ROUNDED_TOPRIGHT,
 
2581
                               getFill(option, use), use, true, WIDGET_SPIN);
2542
2582
 
2543
2583
            if(PE_IndicatorSpinUp==element || PE_IndicatorSpinDown==element)
2544
2584
            {
2548
2588
                    sr.adjust(1, 1, 1, 1);
2549
2589
 
2550
2590
                drawArrow(painter, sr, PE_IndicatorSpinUp==element ? PE_IndicatorArrowUp : PE_IndicatorArrowDown,
2551
 
                          option->palette.buttonText().color(), true);
 
2591
                          QTC_MO_ARROW(option->palette.buttonText().color()), true);
2552
2592
            }
2553
2593
            else
2554
2594
            {
2562
2602
                if(state&State_Sunken)
2563
2603
                    c+=QPoint(1, 1);
2564
2604
 
2565
 
                painter->setPen(palette.buttonText().color());
 
2605
                painter->setPen(MO_GLOW==opts.coloredMouseOver && state&State_MouseOver && state&State_Enabled
 
2606
                                 ? itsMouseOverCols[QT_STD_BORDER] : palette.buttonText().color());
2566
2607
                painter->drawLine(c.x()-l, c.y(), c.x()+l, c.y());
2567
2608
                if(!down)
2568
2609
                    painter->drawLine(c.x(), c.y()-l, c.x(), c.y()+l);
2624
2665
            break;
2625
2666
        case PE_Frame:
2626
2667
            if(widget && widget->parent() && widget->parent()->inherits("KTitleWidget"))
2627
 
                drawFadedLine(painter, QRect(r.x(), (r.y()+r.height())-2, r.width(), 1),
2628
 
                              backgroundColors(option)[QT_STD_BORDER], reverse, !reverse, true);
 
2668
                break;
2629
2669
            else if(widget && widget->parent() && qobject_cast<const QComboBox *>(widget->parent()))
2630
2670
            {
2631
2671
                if(opts.gtkComboMenus && !((QComboBox *)(widget->parent()))->isEditable())
2664
2704
                    {
2665
2705
                        const QStyleOptionFrame *fo = qstyleoption_cast<const QStyleOptionFrame *>(option);
2666
2706
 
 
2707
                        // For some reason, in KPackageKit, the KTextBrower when polished is not in the scrollview,
 
2708
                        // but is when painted. So check here if it should not be etched.
 
2709
                        // Also, see not in getLowerEtchCol()
 
2710
                        if(QTC_DO_EFFECT && widget && widget->parentWidget() && !theNoEtchWidgets.contains(widget) &&
 
2711
                           isInQAbstractItemView(widget->parentWidget()))
 
2712
                            theNoEtchWidgets.insert(widget);
 
2713
 
 
2714
                        // If we are set to have sunken scrollviews, then the frame width is set to 3.
 
2715
                        // ...but it we are a scrollview within a scrollview, then we dont draw sunken, therefore
 
2716
                        // need to draw inner border...
 
2717
                        bool doEtch=QTC_DO_EFFECT,
 
2718
                             noEtchW=doEtch && theNoEtchWidgets.contains(widget);
 
2719
                        if(doEtch && noEtchW)
 
2720
                        {
 
2721
                            painter->setPen(palette.brush(QPalette::Base).color());
 
2722
                            drawRect(painter, r.adjusted(2, 2, -2, -2));
 
2723
                        }
 
2724
        
2667
2725
                        if(!opts.highlightScrollViews && fo)
2668
2726
                        {
2669
2727
                            QStyleOptionFrame opt(*fo);
2670
2728
                            opt.state&=~State_HasFocus;
2671
 
                            drawEntryField(painter, r, widget, &opt, ROUNDED_ALL, false, QTC_DO_EFFECT, WIDGET_SCROLLVIEW);
 
2729
                            drawEntryField(painter, r, widget, &opt, ROUNDED_ALL, false,
 
2730
                                           doEtch && !noEtchW, WIDGET_SCROLLVIEW);
2672
2731
                        }
2673
2732
                        else
2674
 
                            drawEntryField(painter, r, widget, option, ROUNDED_ALL, false, QTC_DO_EFFECT, WIDGET_SCROLLVIEW);
 
2733
                            drawEntryField(painter, r, widget, option, ROUNDED_ALL, false,
 
2734
                                           doEtch && !noEtchW, WIDGET_SCROLLVIEW);
2675
2735
                    }
2676
2736
                }
2677
2737
                else
2680
2740
 
2681
2741
                    if (fo && fo->lineWidth>0)
2682
2742
                    {
 
2743
                        bool         kwinTab(APP_KWIN==theThemedApp &&  widget && !widget->parentWidget() &&
 
2744
                                             0==strcmp(widget->metaObject()->className(), "KWin::TabBox"));
2683
2745
                        QStyleOption opt(*option);
2684
2746
 
2685
2747
                        painter->save();
2686
2748
 
 
2749
                        if(kwinTab)
 
2750
                            r.adjust(-1, -1, 1, 1);
 
2751
 
2687
2752
                        if(!opts.highlightScrollViews)
2688
2753
                            opt.state&=~State_HasFocus;
2689
2754
 
2690
2755
                        drawBorder(painter, r, &opt,
2691
 
                                   opts.round && (APP_KMIX==theThemedApp || APP_KRUNNER==theThemedApp) && widget && widget->parentWidget() &&
2692
 
                                   qobject_cast<const QFrame *>(widget) && 
2693
 
                                        ( (APP_KMIX==theThemedApp && 0==strcmp(widget->parentWidget()->metaObject()->className(), "ViewDockAreaPopup")) ||
2694
 
                                          (APP_KRUNNER==theThemedApp && 0==strcmp(widget->parentWidget()->metaObject()->className(), "PasswordDlg")))
 
2756
                                   opts.round &&
 
2757
                                    ( (APP_KMIX==theThemedApp &&  widget && widget->parentWidget() && qobject_cast<const QFrame *>(widget) &&
 
2758
                                       0==strcmp(widget->parentWidget()->metaObject()->className(), "ViewDockAreaPopup")) ||
 
2759
                                      (APP_KRUNNER==theThemedApp &&  widget && widget->parentWidget() && qobject_cast<const QFrame *>(widget) &&
 
2760
                                       0==strcmp(widget->parentWidget()->metaObject()->className(), "PasswordDlg")) ||
 
2761
                                      kwinTab)
2695
2762
                                   ? ROUND_NONE : ROUNDED_ALL, backgroundColors(option),
2696
2763
                                   sv ? WIDGET_SCROLLVIEW : WIDGET_FRAME, state&State_Sunken || state&State_HasFocus
2697
2764
                                                          ? BORDER_SUNKEN
2903
2970
            if( ((state&State_Enabled) || !(state&State_AutoRaise)) &&
2904
2971
               (!widget || !dwt || (state&State_MouseOver)) )
2905
2972
            {
2906
 
#ifdef QTC_DONT_COLOUR_MOUSEOVER_TBAR_BUTTONS
2907
2973
                QStyleOption opt(*option);
2908
2974
 
2909
2975
                if(dwt)
2910
2976
                    opt.state|=QTC_STATE_TBAR_BUTTON;
2911
2977
                drawPrimitive(PE_PanelButtonCommand, &opt, painter, widget);
2912
 
#else
2913
 
                drawPrimitive(PE_PanelButtonCommand, option, painter, widget);
2914
 
#endif
2915
2978
            }
2916
2979
            break;
2917
2980
        }
2934
2997
                    QRect r2(r.adjusted(1, 1, -1, (QTC_DO_EFFECT ? -2 : -1)));
2935
2998
                    painter->save();
2936
2999
                    painter->setClipPath(buildPath(r2, WIDGET_ENTRY, ROUNDED_ALL,
2937
 
                                                   getRadius(opts.round, r2.width(), r2.height(), WIDGET_ENTRY,
 
3000
                                                   getRadius(&opts, r2.width(), r2.height(), WIDGET_ENTRY,
2938
3001
                                                   RADIUS_INTERNAL)),
2939
3002
                                         Qt::IntersectClip);
2940
3003
                    painter->fillRect(r2, palette.brush(QPalette::Base));
3028
3091
                                 && QTC_DO_EFFECT),
3029
3092
                          glow(doEtch && MO_GLOW==opts.coloredMouseOver && mo);
3030
3093
            QRect         rect(doEtch ? r.adjusted(1, 1, -1, -1) : r);
3031
 
            const QColor *bc(sunken ? NULL : borderColors(option, NULL)),
 
3094
            const QColor *bc(sunken ? 0L : borderColors(option, 0L)),
3032
3095
                         *btn(buttonColors(option)),
3033
3096
                         *use(bc ? bc : btn);
3034
3097
            const QColor &bgnd(opts.crButton
3042
3105
            EAppearance  app=opts.crButton ? opts.appearance : APPEARANCE_INVERTED;
3043
3106
            bool         drawSunken=opts.crButton ? sunken : false,
3044
3107
                         lightBorder=QTC_DRAW_LIGHT_BORDER(drawSunken, wid, app),
3045
 
                         draw3d=!lightBorder && QTC_DRAW_3D_BORDER(drawSunken, app),
3046
 
                         drawLight=opts.crButton && !drawSunken && (lightBorder || draw3d);
 
3108
                         draw3dFull=!lightBorder && QTC_DRAW_3D_FULL_BORDER(drawSunken, app),
 
3109
                         draw3d=draw3dFull || (!lightBorder && QTC_DRAW_3D_BORDER(drawSunken, app)),
 
3110
                         drawLight=opts.crButton && !drawSunken && (lightBorder || draw3d),
 
3111
                         drawDark=drawLight && draw3dFull && !lightBorder;
3047
3112
 
3048
3113
            painter->save();
3049
3114
            if(IS_FLAT(opts.appearance))
3071
3136
                {
3072
3137
                    painter->drawLine(rect.x()+1, rect.y()+1, rect.x()+1, rect.y()+rect.height()-2);
3073
3138
                    painter->drawLine(rect.x()+1, rect.y()+1, rect.x()+rect.width()-2, rect.y()+1);
 
3139
 
 
3140
                    if(drawDark)
 
3141
                    {
 
3142
                        painter->setPen(btn[2]);
 
3143
                        painter->drawLine(rect.x()+rect.width()-2, rect.y()+1,
 
3144
                                          rect.x()+rect.width()-2, rect.y()+rect.height()-2);
 
3145
                        painter->drawLine(rect.x()+1, rect.y()+rect.height()-2,
 
3146
                                          rect.x()+rect.width()-2, rect.y()+rect.height()-2);
 
3147
                    }
3074
3148
                }
3075
3149
            }
3076
3150
 
3138
3212
            EAppearance app=opts.crButton ? opts.appearance : APPEARANCE_INVERTED;
3139
3213
            bool        drawSunken=opts.crButton ? sunken : false,
3140
3214
                        lightBorder=QTC_DRAW_LIGHT_BORDER(drawSunken, wid, app),
3141
 
                        draw3d=!lightBorder && QTC_DRAW_3D_BORDER(drawSunken, app),
 
3215
                        draw3d=!lightBorder &&
 
3216
                               (QTC_DRAW_3D_BORDER(drawSunken, app) || QTC_DRAW_3D_FULL_BORDER(drawSunken, app)),
3142
3217
                        drawLight=opts.crButton && !drawSunken && (lightBorder || draw3d),
3143
3218
                        doneShadow=false;
3144
3219
 
3145
3220
            clipRegion.setPoints(8,  x+1,  y+8,   x+1,  y+4,   x+4, y+1,    x+8, y+1,
3146
3221
                                     x+12, y+4,   x+12, y+8,   x+8, y+12,   x+4, y+12);
3147
3222
 
3148
 
            const QColor *bc(sunken ? NULL : borderColors(option, NULL)),
 
3223
            const QColor *bc(sunken ? 0L : borderColors(option, 0L)),
3149
3224
                         *btn(buttonColors(option)),
3150
3225
                         *use(bc ? bc : btn);
3151
3226
            const QColor &bgnd(opts.crButton
3189
3264
 
3190
3265
            painter->setClipping(false);
3191
3266
 
3192
 
            if(!doneShadow && doEtch && glow)
 
3267
            if(!doneShadow && doEtch && (glow || EFFECT_ETCH==opts.buttonEffect || sunken))
3193
3268
            {
3194
 
                QColor topCol(glow ? itsMouseOverCols[QTC_GLOW_MO] : Qt::black),
3195
 
                       botCol(getLowerEtchCol(widget));
 
3269
                QColor topCol(glow ? itsMouseOverCols[QTC_GLOW_MO] : Qt::black);
3196
3270
 
3197
3271
                if(!glow)
3198
 
                {
3199
3272
                    topCol.setAlphaF(QTC_ETCH_RADIO_TOP_ALPHA);
3200
 
                    botCol=getLowerEtchCol(widget);
3201
 
                }
3202
3273
 
3203
3274
                painter->setRenderHint(QPainter::Antialiasing, true);
3204
3275
                painter->setBrush(Qt::NoBrush);
3205
3276
                painter->setPen(topCol);
3206
3277
                painter->drawArc(QRectF(r.x()+0.5, r.y()+0.5, QTC_RADIO_SIZE+1, QTC_RADIO_SIZE+1), 45*16, 180*16);
3207
3278
                if(!glow)
3208
 
                    painter->setPen(botCol);
 
3279
                    painter->setPen(getLowerEtchCol(widget));
3209
3280
                painter->drawArc(QRectF(r.x()+0.5, r.y()+0.5, QTC_RADIO_SIZE+1, QTC_RADIO_SIZE+1), 225*16, 180*16);
3210
3281
                painter->setRenderHint(QPainter::Antialiasing, false);
3211
3282
            }
3262
3333
                                         (widget && widget->parent() &&
3263
3334
                                            ((dynamic_cast<const QAbstractScrollArea*>(widget->parent())) ||
3264
3335
                                              widget->parent()->inherits("Q3ScrollView"))));
3265
 
                    const QColor *use(view && state&State_Selected
3266
 
                                        ? 0L : (FOCUS_BACKGROUND==opts.focus ?  backgroundColors(option) : itsMenuitemCols));
3267
 
 
3268
3336
                    painter->save();
3269
3337
                    QColor c(view && state&State_Selected
3270
3338
                                  ? palette.highlightedText().color()
3271
 
                                  : use[FOCUS_BACKGROUND!=opts.focus && state&State_Selected ? 3 : QT_FOCUS]);
 
3339
                                  : itsFocusCols[QT_FOCUS(state&State_Selected)]);
3272
3340
 
3273
3341
                    if(FOCUS_LINE==opts.focus)
3274
 
                        drawFadedLine(painter, QRect(r2.x(), r2.y()+r2.height()-(view ? 3 : 1), r2.width(), 1),
3275
 
                                      c, true, true, true);
 
3342
                        if(!(state&State_Horizontal) && widget && qobject_cast<const QTabBar *>(widget))
 
3343
                            drawFadedLine(painter, QRect(r2.x()+r2.width()-1, r2.y(), 1, r2.height()),
 
3344
                                          c, true, true, false);
 
3345
                        else
 
3346
                            drawFadedLine(painter, QRect(r2.x(), r2.y()+r2.height()-(view ? 3 : 1), r2.width(), 1),
 
3347
                                          c, true, true, true);
3276
3348
                    else
3277
3349
                    {
3278
3350
                        painter->setPen(c);
3285
3357
                        {
3286
3358
                            painter->setRenderHint(QPainter::Antialiasing, true);
3287
3359
                            painter->drawPath(buildPath(r2, WIDGET_SELECTION, ROUNDED_ALL,
3288
 
                                                        getRadius(opts.round, r2.width(), r2.height(), WIDGET_OTHER,
 
3360
                                                        getRadius(&opts, r2.width(), r2.height(), WIDGET_OTHER,
3289
3361
                                                                  QTC_FULL_FOCUS ? RADIUS_EXTERNAL : RADIUS_SELECTION)));
3290
3362
                        }
3291
3363
                        else
3351
3423
//             painter->fillRect(doEtch ? r.adjusted(2, 2, -2, -2) : r.adjusted(1, 1, -1, -1), palette.background().color());
3352
3424
//             painter->setRenderHint(QPainter::Antialiasing, false);
3353
3425
 
3354
 
            drawLightBevel(painter, r, &opt, widget, ROUNDED_ALL, getFill(&opt, use), use,
 
3426
            bool coloredDef=isDefault && state&State_Enabled && IND_COLORED==opts.defBtnIndicator;
 
3427
            
 
3428
            drawLightBevel(painter, r, &opt, widget, ROUNDED_ALL,
 
3429
                           coloredDef ? itsDefBtnCols[QTC_MO_DEF_BTN]
 
3430
                                      : getFill(&opt, use, false,
 
3431
                                                isDefault && state&State_Enabled && IND_DARKEN==opts.defBtnIndicator),
 
3432
                           coloredDef ? itsDefBtnCols : use,
3355
3433
                           true, isKWin
3356
3434
                                    ? WIDGET_MDI_WINDOW_BUTTON
3357
3435
                                    : isOnListView
3358
3436
                                        ? WIDGET_NO_ETCH_BTN
3359
 
                                        : isDefault && state&State_Enabled  && IND_COLORED!=opts.defBtnIndicator
 
3437
                                        : isDefault && state&State_Enabled
3360
3438
                                            ? WIDGET_DEF_BUTTON
3361
 
                                            : WIDGET_STD_BUTTON);
 
3439
                                            : state&QTC_STATE_TBAR_BUTTON
 
3440
                                                ? WIDGET_TOOLBAR_BUTTON
 
3441
                                                : WIDGET_STD_BUTTON);
3362
3442
 
3363
3443
            if (isDefault && state&State_Enabled)
3364
3444
                switch(opts.defBtnIndicator)
3370
3450
                                     etchOffset(doEtch ? 1 : 0);
3371
3451
                        double       xd(r.x()+0.5),
3372
3452
                                     yd(r.y()+0.5);
 
3453
                        const QColor *cols(itsFocusCols ? itsFocusCols : itsHighlightCols);
3373
3454
 
3374
3455
                        path.moveTo(xd+offset+etchOffset, yd+offset+etchOffset);
3375
3456
                        path.lineTo(xd+offset+6+etchOffset, yd+offset+etchOffset);
3376
3457
                        path.lineTo(xd+offset+etchOffset, yd+offset+6+etchOffset);
3377
3458
                        path.lineTo(xd+offset+etchOffset, yd+offset+etchOffset);
3378
 
                        painter->setBrush(itsMouseOverCols[isDown ? 0 : 4]);
3379
 
                        painter->setPen(itsMouseOverCols[isDown ? 0 : 4]);
 
3459
                        painter->setBrush(cols[isDown ? 0 : 4]);
 
3460
                        painter->setPen(cols[isDown ? 0 : 4]);
3380
3461
                        painter->setRenderHint(QPainter::Antialiasing, true);
3381
3462
                        painter->drawPath(path);
3382
3463
                        painter->setRenderHint(QPainter::Antialiasing, false);
3384
3465
                    }
3385
3466
                    case IND_COLORED:
3386
3467
                    {
3387
 
                        const QColor *cols=itsMouseOverCols && opt.state&State_MouseOver ? itsMouseOverCols : itsDefBtnCols;
3388
 
                        QRegion      outer(r);
3389
 
                        QRect        r2(r);
3390
 
 
3391
 
                        if(doEtch)
3392
 
                            r2.adjust(1, 1, -1, -1);
3393
 
 
3394
 
                        r2.adjust(COLORED_BORDER_SIZE, COLORED_BORDER_SIZE, -COLORED_BORDER_SIZE,
3395
 
                                    -COLORED_BORDER_SIZE);
3396
 
 
3397
 
                        QRegion inner(r2);
3398
 
 
3399
 
                        painter->setClipRegion(outer.subtract(inner));
3400
 
 
3401
 
                        drawLightBevel(painter, r, option, widget, ROUNDED_ALL, cols[QTC_MO_DEF_BTN],
3402
 
                                       cols, true, WIDGET_DEF_BUTTON);
3403
 
 
3404
 
                        painter->setClipping(false);
 
3468
                        int   offset=COLORED_BORDER_SIZE+(doEtch ? 1 : 0);
 
3469
                        QRect r2(r.adjusted(offset, offset, -offset, -offset));
 
3470
 
 
3471
                        drawBevelGradient(getFill(&opt, use), painter, r2, true,
 
3472
                                          state &(State_On | State_Sunken),
 
3473
                                          opts.appearance, WIDGET_STD_BUTTON);
3405
3474
                    }
3406
3475
                    default:
3407
3476
                        break;
3413
3482
            break;
3414
3483
        case PE_FrameWindow:
3415
3484
        {
 
3485
            ERound oldRound=opts.round;
 
3486
            if(state&QtCStateKWinNotFull && state&QtC_StateKWin)
 
3487
                opts.round=ROUND_NONE;
 
3488
 
3416
3489
            const QColor *borderCols(opts.colorTitlebarOnly
3417
3490
                                        ? backgroundColors(palette.color(QPalette::Active, QPalette::Window))
3418
3491
                                        : theThemedApp==APP_KWIN
3442
3515
                mask += QRegion(x+w-5, y+1, 2, h-2);
3443
3516
                painter->setClipRegion(mask);
3444
3517
            }
3445
 
                
3446
 
            drawBorder(painter, r, &opt, ROUNDED_BOTTOM, borderCols, WIDGET_MDI_WINDOW, BORDER_RAISED);
 
3518
 
 
3519
            drawBorder(painter, r, &opt, ROUNDED_BOTTOM, borderCols, WIDGET_MDI_WINDOW, opts.titlebarBorder ? BORDER_RAISED : BORDER_FLAT);
 
3520
            opts.round=oldRound;
3447
3521
 
3448
3522
            if(roundKWinFull)
3449
3523
            {
3450
3524
                bool   kwinHighlight(state&QtC_StateKWinHighlight);
3451
 
                QColor col(kwinHighlight ? itsMenuitemCols[0] : buttonColors(option)[QT_STD_BORDER]);
 
3525
                QColor col(opts.colorTitlebarOnly
 
3526
                            ? backgroundColors(option)[QT_STD_BORDER]
 
3527
                            : kwinHighlight ? itsFocusCols[0] : buttonColors(option)[QT_STD_BORDER]);
3452
3528
 
3453
3529
                painter->setPen(col);
3454
3530
 
3485
3561
 
3486
3562
            if(opts.round && widget && ::qobject_cast<const QTabWidget *>(widget))
3487
3563
            {
3488
 
#ifdef QTC_USE_KDE4
 
3564
#if !defined QTC_QT_ONLY
3489
3565
                const KTabWidget *ktw=::qobject_cast<const KTabWidget *>(widget);
3490
3566
#endif
3491
3567
                const QTabWidget *tw((const QTabWidget *)widget);
3492
3568
 
3493
3569
                if(0==tw->currentIndex() && tw->count()>0
3494
 
#ifdef QTC_USE_KDE4
3495
 
                      && (!ktw || !ktw->isTabBarHidden())
 
3570
#if !defined QTC_QT_ONLY
 
3571
                    && (!ktw || !ktw->isTabBarHidden())
3496
3572
#endif
3497
3573
                  )
3498
3574
                    if(const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(option))
3603
3679
 
3604
3680
                QRect inner(border.adjusted(1, 1, -1, -1));
3605
3681
                painter->save();
3606
 
                if(QTC_FULLLY_ROUNDED && r.width()>QTC_MIN_ROUND_FULL_SIZE && r.height()>QTC_MIN_ROUND_FULL_SIZE)
3607
 
                {
3608
 
                    double radius=getRadius(opts.round, border.width(), border.height(), WIDGET_OTHER, RADIUS_SELECTION);
3609
 
                    painter->setClipRect(r);
3610
 
                    painter->setClipPath(buildPath(border.adjusted(0, 0, 0,
3611
 
                                                                   radius>QTC_EXTRA_ETCH_RADIUS ? -1 : 0),
3612
 
                                                   WIDGET_OTHER, round, radius), Qt::IntersectClip);
3613
 
                }
3614
 
                else
3615
 
                    painter->setClipRect(inner.intersect(r));
 
3682
                painter->setRenderHint(QPainter::Antialiasing, true);
 
3683
                painter->setClipRect(r);
 
3684
                painter->setClipPath(buildPath(border, WIDGET_OTHER, round,
 
3685
                                               getRadius(&opts, border.width(), border.height(), WIDGET_OTHER, RADIUS_SELECTION),
 
3686
                                               0, -0.5), Qt::IntersectClip);
 
3687
 
3616
3688
                drawBevelGradient(color, painter, inner, true, false, opts.selectionAppearance, WIDGET_SELECTION);
3617
 
 
3618
 
                painter->setRenderHint(QPainter::Antialiasing, true);
3619
3689
                painter->setBrush(Qt::NoBrush);
3620
3690
                painter->setPen(color);
3621
3691
                painter->setClipRect(r);
3622
3692
                painter->drawPath(buildPath(border, WIDGET_SELECTION, round,
3623
 
                                            getRadius(opts.round, r.width(), r.height(), WIDGET_OTHER, RADIUS_SELECTION)));
3624
 
                painter->setClipping(false);
 
3693
                                            getRadius(&opts, r.width(), r.height(), WIDGET_OTHER, RADIUS_SELECTION)));
3625
3694
                painter->restore();
3626
3695
            }
3627
3696
 
3739
3808
        case CE_RubberBand: // Rubber band used in such things as iconview.
3740
3809
        {
3741
3810
            painter->save();
3742
 
            QColor c(itsMenuitemCols[ORIGINAL_SHADE]);
 
3811
            QColor c(itsHighlightCols[ORIGINAL_SHADE]);
 
3812
            double radius=QTC_ROUNDED ? getRadius(&opts, r.width(), r.height(), WIDGET_RUBBER_BAND, RADIUS_SELECTION) : 0.0;
3743
3813
 
 
3814
            painter->setClipRegion(r);
 
3815
            r.adjust(0, 0, -1, -1);
3744
3816
            painter->setPen(c);
3745
 
            c.setAlpha(50);
3746
 
            painter->setBrush(c);
3747
 
            if(QTC_ROUNDED)
 
3817
            if(r.width()>0 && r.height()>0)
3748
3818
            {
3749
 
                painter->setRenderHint(QPainter::Antialiasing, true);
3750
 
                painter->drawPath(buildPath(r, WIDGET_SELECTION, ROUNDED_ALL,
3751
 
                                            getRadius(opts.round, r.width(), r.height(), WIDGET_OTHER, RADIUS_SELECTION)));
 
3819
                c.setAlpha(50);
 
3820
                painter->setBrush(c);
 
3821
                if(radius>0.0 && r.width()>(2*radius) && r.height()>(2*radius))
 
3822
                {
 
3823
                    painter->setRenderHint(QPainter::Antialiasing, true);
 
3824
                    painter->drawPath(buildPath(r, WIDGET_RUBBER_BAND, ROUNDED_ALL, radius));
 
3825
                }
 
3826
                else
 
3827
                    drawRect(painter, r);
3752
3828
            }
3753
 
            else
3754
 
                drawRect(painter, r);
3755
3829
            painter->restore();
3756
3830
            break;
3757
3831
        }
3783
3857
        }
3784
3858
        case CE_SizeGrip:
3785
3859
        {
3786
 
            painter->save();
3787
 
            painter->setRenderHint(QPainter::Antialiasing, true);
3788
 
            int x, y, w, h;
3789
 
            r.getRect(&x, &y, &w, &h);
3790
 
 
3791
 
            if (h > w)
3792
 
                painter->translate(0, h - w);
3793
 
            else
3794
 
                painter->translate(w - h, 0);
3795
 
 
3796
 
            int sw(qMin(h, w)),
3797
 
                sx(x),
3798
 
                sy(y),
3799
 
                s(sw / 4),
3800
 
                dark(4); // QT_BORDER(state&State_Enabled));
3801
 
 
 
3860
            QPolygon   triangle(3);
3802
3861
            Qt::Corner corner;
 
3862
            int        size=SIZE_GRIP_SIZE-2;
 
3863
 
3803
3864
            if (const QStyleOptionSizeGrip *sgrp = qstyleoption_cast<const QStyleOptionSizeGrip *>(option))
3804
3865
                corner = sgrp->corner;
3805
3866
            else if (Qt::RightToLeft==option->direction)
3810
3871
            switch(corner)
3811
3872
            {
3812
3873
                case Qt::BottomLeftCorner:
3813
 
                    sx = x + sw;
3814
 
                    for (int i = 0; i < 4; ++i)
3815
 
                    {
3816
 
//                         painter->setPen(QPen(itsBackgroundCols[0], 1));
3817
 
//                         painter->drawLine(x, sy - 1 , sx + 1, sw);
3818
 
                        painter->setPen(QPen(itsBackgroundCols[dark], 1));
3819
 
                        painter->drawLine(x, sy, sx, sw);
3820
 
                        sx -= s;
3821
 
                        sy += s;
3822
 
                    }
 
3874
                    triangle.putPoints(0, 3, 0,0, size,size, 0,size);
 
3875
                    triangle.translate(r.x(), r.y()+(r.height()-(SIZE_GRIP_SIZE-1)));
3823
3876
                    break;
3824
3877
                case Qt::BottomRightCorner:
3825
 
                    for (int i = 0; i < 4; ++i)
3826
 
                    {
3827
 
//                         painter->setPen(QPen(itsBackgroundCols[0], 1));
3828
 
//                         painter->drawLine(sx - 1, sw, sw, sy - 1);
3829
 
                        painter->setPen(QPen(itsBackgroundCols[dark], 1));
3830
 
                        painter->drawLine(sx, sw, sw, sy);
3831
 
                        sx += s;
3832
 
                        sy += s;
3833
 
                    }
 
3878
                    triangle.putPoints(0, 3, size,0, size,size, 0,size);
 
3879
                    triangle.translate(r.x()+(r.width()-(SIZE_GRIP_SIZE-1)), r.y()+(r.height()-(SIZE_GRIP_SIZE-1)));
3834
3880
                    break;
3835
3881
                case Qt::TopRightCorner:
3836
 
                    sy = y + sw;
3837
 
                    for (int i = 0; i < 4; ++i)
3838
 
                    {
3839
 
//                         painter->setPen(QPen(itsBackgroundCols[0], 1));
3840
 
//                         painter->drawLine(sx - 1, y, sw, sy + 1);
3841
 
                        painter->setPen(QPen(itsBackgroundCols[dark], 1));
3842
 
                        painter->drawLine(sx, y, sw, sy);
3843
 
                        sx += s;
3844
 
                        sy -= s;
3845
 
                    }
 
3882
                    triangle.putPoints(0, 3, 0,0, size,0, size,size);
 
3883
                    triangle.translate(r.x()+(r.width()-(SIZE_GRIP_SIZE-1)), r.y());
3846
3884
                    break;
3847
3885
                case Qt::TopLeftCorner:
3848
 
                    for (int i = 0; i < 4; ++i)
3849
 
                    {
3850
 
//                         painter->setPen(QPen(itsBackgroundCols[0], 1));
3851
 
//                         painter->drawLine(x, sy - 1, sx - 1, y);
3852
 
                        painter->setPen(QPen(itsBackgroundCols[dark], 1));
3853
 
                        painter->drawLine(x, sy, sx, y);
3854
 
                        sx += s;
3855
 
                        sy += s;
3856
 
                    }
 
3886
                    triangle.putPoints(0, 3, 0,0, size,0, 0,size);
 
3887
                    triangle.translate(r.x(), r.y());
3857
3888
            }
3858
 
            painter->setRenderHint(QPainter::Antialiasing, false);
 
3889
            painter->save();
 
3890
            painter->setPen(itsBackgroundCols[2]);
 
3891
            painter->setBrush(itsBackgroundCols[2]);
 
3892
            painter->drawPolygon(triangle);
3859
3893
            painter->restore();
3860
3894
            break;
3861
3895
        }
3985
4019
        case CE_HeaderEmptyArea:
3986
4020
        {
3987
4021
            const QStyleOptionHeader *ho = qstyleoption_cast<const QStyleOptionHeader *>(option);
3988
 
            bool horiz(ho ? Qt::Horizontal==ho->orientation : state&State_Horizontal);
3989
 
            QStyleOption opt(*option);
 
4022
            bool                     horiz(ho ? Qt::Horizontal==ho->orientation : state&State_Horizontal);
 
4023
            QStyleOption             opt(*option);
 
4024
            const QColor             *use(opts.lvButton ? buttonColors(option) : backgroundColors(option));
3990
4025
 
3991
4026
            opt.state&=~State_MouseOver;
3992
4027
            painter->save();
3993
4028
 
3994
 
            drawBevelGradient(getFill(&opt, itsBackgroundCols), painter, r, horiz,
 
4029
            drawBevelGradient(getFill(&opt, use), painter, r, horiz,
3995
4030
                              false, opts.lvAppearance, WIDGET_LISTVIEW_HEADER);
3996
4031
 
3997
4032
            painter->setRenderHint(QPainter::Antialiasing, true);
3998
4033
            if(APPEARANCE_RAISED==opts.lvAppearance)
3999
4034
            {
4000
 
                painter->setPen(itsBackgroundCols[4]);
 
4035
                painter->setPen(use[4]);
4001
4036
                if(horiz)
4002
4037
                    drawAaLine(painter, r.x(), r.y()+r.height()-2, r.x()+r.width()-1, r.y()+r.height()-2);
4003
4038
                else
4004
4039
                    drawAaLine(painter, r.x()+r.width()-2, r.y(), r.x()+r.width()-2, r.y()+r.height()-1);
4005
4040
            }
4006
4041
 
4007
 
            painter->setPen(itsBackgroundCols[QT_STD_BORDER]);
 
4042
            painter->setPen(use[QT_STD_BORDER]);
4008
4043
            if(horiz)
4009
4044
                drawAaLine(painter, r.x(), r.y()+r.height()-1, r.x()+r.width()-1, r.y()+r.height()-1);
4010
4045
            else
4017
4052
        case CE_HeaderSection:
4018
4053
            if (const QStyleOptionHeader *ho = qstyleoption_cast<const QStyleOptionHeader *>(option))
4019
4054
            {
 
4055
                const QColor *use(opts.lvButton ? buttonColors(option) : backgroundColors(option));
 
4056
 
4020
4057
                painter->save();
4021
4058
 
4022
4059
                if(state & (State_Raised | State_Sunken))
4032
4069
                    if(-1==ho->section && !(state&State_Enabled) && widget && widget->isEnabled())
4033
4070
                        opt.state|=State_Enabled;
4034
4071
 
4035
 
                    drawBevelGradient(getFill(&opt, itsBackgroundCols), painter, r,
 
4072
                    drawBevelGradient(getFill(&opt, use), painter, r,
4036
4073
                                        Qt::Horizontal==ho->orientation,
4037
4074
                                        sunken, opts.lvAppearance, WIDGET_LISTVIEW_HEADER);
4038
4075
 
4039
4076
                    painter->setRenderHint(QPainter::Antialiasing, true);
4040
4077
                    if(APPEARANCE_RAISED==opts.lvAppearance)
4041
4078
                    {
4042
 
                        painter->setPen(itsBackgroundCols[4]);
 
4079
                        painter->setPen(use[4]);
4043
4080
                        if(Qt::Horizontal==ho->orientation)
4044
4081
                            drawAaLine(painter, r.x(), r.y()+r.height()-2, r.x()+r.width()-1, r.y()+r.height()-2);
4045
4082
                        else
4046
4083
                            drawAaLine(painter, r.x()+r.width()-2, r.y(), r.x()+r.width()-2, r.y()+r.height()-1);
4047
4084
                    }
4048
4085
 
4049
 
                    const QColor *border(borderColors(&opt, NULL));
4050
 
 
4051
4086
                    if(Qt::Horizontal==ho->orientation)
4052
4087
                    {
4053
 
                        if(border)
4054
 
                        {
4055
 
                            painter->setPen(border[ORIGINAL_SHADE]);
4056
 
                            drawAaLine(painter, r.x(), r.y()+r.height()-2, r.x()+r.width()-1,
4057
 
                                      r.y()+r.height()-2);
4058
 
                            painter->setPen(border[QT_STD_BORDER]);
4059
 
                        }
4060
 
                        else
4061
 
                            painter->setPen(itsBackgroundCols[QT_STD_BORDER]);
 
4088
                        painter->setPen(use[QT_STD_BORDER]);
4062
4089
                        drawAaLine(painter, r.x(), r.y()+r.height()-1, r.x()+r.width()-1, r.y()+r.height()-1);
 
4090
                        if(itsMouseOverCols && opts.coloredMouseOver && state&State_MouseOver && state&State_Enabled)
 
4091
                            drawHighlight(painter, QRect(r.x(), r.y()+r.height()-2, r.width(), 2), true, true);
4063
4092
 
4064
4093
                        if(q3Header ||
4065
4094
                           (QStyleOptionHeader::End!=ho->position && QStyleOptionHeader::OnlyOneSection!=ho->position))
4066
4095
                        {
4067
4096
                            drawFadedLine(painter, QRect(r.x()+r.width()-2, r.y()+5, 1, r.height()-10),
4068
 
                                          itsBackgroundCols[QT_STD_BORDER], true, true, false);
 
4097
                                          use[QT_STD_BORDER], true, true, false);
4069
4098
                            drawFadedLine(painter, QRect(r.x()+r.width()-1, r.y()+5, 1, r.height()-10),
4070
 
                                          itsBackgroundCols[0], true, true, false);
 
4099
                                          use[0], true, true, false);
4071
4100
                        }
4072
4101
                    }
4073
4102
                    else
4074
4103
                    {
4075
 
                        if(border)
4076
 
                        {
4077
 
                            painter->setPen(border[ORIGINAL_SHADE]);
4078
 
                            drawAaLine(painter, r.x()+r.width()-2, r.y(), r.x()+r.width()-2, r.y()+r.height()-1);
4079
 
                            painter->setPen(border[QT_STD_BORDER]);
4080
 
                        }
4081
 
                        else
4082
 
                            painter->setPen(itsBackgroundCols[QT_STD_BORDER]);
 
4104
                        painter->setPen(use[QT_STD_BORDER]);
4083
4105
                        drawAaLine(painter, r.x()+r.width()-1, r.y(), r.x()+r.width()-1, r.y()+r.height()-1);
4084
4106
 
4085
4107
                        if(q3Header ||
4086
4108
                           (QStyleOptionHeader::End!=ho->position && QStyleOptionHeader::OnlyOneSection!=ho->position))
4087
4109
                        {
4088
 
                            painter->setPen(itsBackgroundCols[QT_STD_BORDER]);
 
4110
                            painter->setPen(use[QT_STD_BORDER]);
4089
4111
                            drawAaLine(painter, r.x()+5, r.y()+r.height()-2, r.x()+r.width()-6,
4090
4112
                                      r.y()+r.height()-2);
4091
 
                            painter->setPen(itsBackgroundCols[0]);
 
4113
                            painter->setPen(use[0]);
4092
4114
                            drawAaLine(painter, r.x()+5, r.y()+r.height()-1, r.x()+r.width()-6,
4093
4115
                                      r.y()+r.height()-1);
4094
4116
                        }
 
4117
                        if(itsMouseOverCols && opts.coloredMouseOver && state&State_MouseOver && state&State_Enabled)
 
4118
                            drawHighlight(painter, QRect(r.x(), r.y()+r.height()-3, r.width(), 2), true, true);
4095
4119
                    }
4096
4120
                    painter->setRenderHint(QPainter::Antialiasing, false);
4097
4121
                }
4098
4122
                else
4099
 
                    painter->fillRect(r, getFill(option, itsBackgroundCols));
 
4123
                    painter->fillRect(r, getFill(option, use));
4100
4124
                painter->restore();
4101
4125
            }
4102
4126
            break;
4152
4176
            }
4153
4177
 
4154
4178
            painter->setClipPath(buildPath(r, WIDGET_PBAR_TROUGH, ROUNDED_ALL,
4155
 
                                 getRadius(opts.round, r.width(), r.height(), WIDGET_PBAR_TROUGH, RADIUS_EXTERNAL)));
 
4179
                                 getRadius(&opts, r.width(), r.height(), WIDGET_PBAR_TROUGH, RADIUS_EXTERNAL)));
4156
4180
            drawBevelGradient(col, painter, r.adjusted(1, 1, -1, -1), horiz,
4157
4181
                              false, opts.progressGrooveAppearance, WIDGET_PBAR_TROUGH);
4158
4182
            painter->setClipping(false);
4359
4383
                if(active)
4360
4384
                    drawMenuItem(painter, r, option, true, down && opts.roundMbTopOnly ? ROUNDED_TOP : ROUNDED_ALL,
4361
4385
                                 opts.useHighlightForMenu && (opts.colorMenubarMouseOver || down)
4362
 
                                    ? itsMenuitemCols : itsBackgroundCols);
 
4386
                                    ? itsHighlightCols : itsBackgroundCols);
4363
4387
 
4364
4388
                if (!pix.isNull())
4365
4389
                    drawItemPixmap(painter, mbi->rect, alignment, pix);
4435
4459
                     checked(menuItem->checked),
4436
4460
                     enabled(state&State_Enabled);
4437
4461
 
4438
 
                if(!(selected && enabled) || APPEARANCE_FADE==opts.menuitemAppearance)
4439
 
                {
4440
 
/*
4441
 
                    painter->fillRect(menuItem->rect, USE_LIGHTER_POPUP_MENU ? itsLighterPopupMenuBgndCol
4442
 
                                                                             : itsBackgroundCols[ORIGINAL_SHADE]);
4443
 
*/
4444
 
                    if(opts.menuStripe && !comboMenu)
4445
 
                        drawBevelGradient(menuStripeCol(), painter,
4446
 
                                          QRect(reverse ? r.right()-stripeWidth : r.x(), r.y(), stripeWidth,
4447
 
                                                r.height()), false,
4448
 
                                          false, opts.menuStripeAppearance, WIDGET_OTHER);
4449
 
                }
 
4462
                if(opts.menuStripe && !comboMenu)
 
4463
                    drawBevelGradient(menuStripeCol(), painter,
 
4464
                                        QRect(reverse ? r.right()-stripeWidth : r.x(), r.y(), stripeWidth,
 
4465
                                            r.height()), false,
 
4466
                                        false, opts.menuStripeAppearance, WIDGET_OTHER);
4450
4467
 
4451
4468
                if (selected && enabled)
4452
4469
                    drawMenuItem(painter, r.adjusted(0, 0, -1, 0), option, false, ROUNDED_ALL,
4453
 
                                 opts.useHighlightForMenu ? itsMenuitemCols : itsBackgroundCols);
 
4470
                                 opts.useHighlightForMenu ? itsHighlightCols : itsBackgroundCols);
4454
4471
 
4455
4472
                if(comboMenu)
4456
4473
                {
4491
4508
                            else if (checked)
4492
4509
                            {
4493
4510
                                int          iconSize(qMax(menuItem->maxIconWidth, 20));
4494
 
                                QRect        sunkenRect(r.left() + 1, r.top() + (r.height() - iconSize) / 2 + 1,
 
4511
                                QRect        sunkenRect(r.left() + 1, r.top() + (r.height() - iconSize) / 2,
4495
4512
                                                        iconSize, iconSize);
4496
4513
                                QStyleOption opt(*option);
4497
4514
 
4498
4515
                                sunkenRect = visualRect(menuItem->direction, menuItem->rect, sunkenRect);
4499
4516
                                opt.state = menuItem->state;
4500
 
                                opt.state|=State_Raised;
 
4517
                                opt.state|=State_Raised|State_Horizontal;
4501
4518
                                if (checked)
4502
4519
                                    opt.state |= State_On;
4503
4520
                                drawLightBevel(painter, sunkenRect, &opt, widget, ROUNDED_ALL, getFill(&opt, itsButtonCols), itsButtonCols);
4653
4670
                             ((btn->rect.height() - mbi)/2),
4654
4671
                             mbi - 6, mbi);
4655
4672
 
4656
 
                    drawArrow(painter, ar, PE_IndicatorArrowDown, option->palette.buttonText().color());
 
4673
                    if(option->state &(State_On | State_Sunken))
 
4674
                        ar.adjust(1, 1, 1, 1);
 
4675
                            
 
4676
                    drawArrow(painter, ar, PE_IndicatorArrowDown, QTC_MO_ARROW(option->palette.buttonText().color()));
4657
4677
                }
4658
4678
            }
4659
4679
            break;
4677
4697
                    QPixmap      pixmap(getIconPixmap(button->icon, button->iconSize, mode, state));
4678
4698
                    int          labelWidth(pixmap.width()),
4679
4699
                                 labelHeight(pixmap.height()),
4680
 
                                 iconSpacing (4),//### 4 is currently hardcoded in QPushButton::sizeHint()
4681
 
                                 textWidth(button->fontMetrics.boundingRect(option->rect, tf, button->text).width());
 
4700
                                 iconSpacing (4);//### 4 is currently hardcoded in QPushButton::sizeHint()
4682
4701
 
4683
4702
                    if (!button->text.isEmpty())
4684
 
                        labelWidth += (textWidth + iconSpacing);
 
4703
                        labelWidth += (button->fontMetrics.boundingRect(option->rect, tf, button->text).width() + iconSpacing);
4685
4704
 
4686
4705
                    QRect iconRect(r.x() + (r.width() - labelWidth) / 2,
4687
 
                                r.y() + (r.height() - labelHeight) / 2,
4688
 
                                pixmap.width(), pixmap.height());
 
4706
                                   r.y() + (r.height() - labelHeight) / 2,
 
4707
                                   pixmap.width(), pixmap.height());
4689
4708
 
4690
4709
                    iconRect = visualRect(button->direction, r, iconRect);
4691
4710
 
4733
4752
 
4734
4753
                        if(option->state &(State_On | State_Sunken))
4735
4754
                            ar.adjust(1, 1, 1, 1);
4736
 
                        drawArrow(painter, ar, PE_IndicatorArrowDown, option->palette.buttonText().color());
 
4755
                        drawArrow(painter, ar, PE_IndicatorArrowDown, QTC_MO_ARROW(option->palette.buttonText().color()));
4737
4756
                    }
4738
4757
 
4739
4758
//                     QRect              ir(button->rect);
4940
4959
                    QStyleOptionFocusRect fropt;
4941
4960
                    fropt.QStyleOption::operator=(*tab);
4942
4961
                    fropt.rect.setRect(x1 + 1 + constOffset, tabV2.rect.y() + constOffset,
4943
 
                                    x2 - x1 - 2*constOffset, tabV2.rect.height() - 2*constOffset);
 
4962
                                       x2 - x1 - 2*constOffset, tabV2.rect.height() - 2*constOffset);
 
4963
 
 
4964
                    fropt.state|=State_Horizontal;
 
4965
                    if(TAB_MO_BOTTOM==opts.tabMouseOver && FOCUS_LINE==opts.focus)
 
4966
                        switch(tabV2.shape)
 
4967
                        {
 
4968
                            case QTabBar::RoundedNorth:
 
4969
                            case QTabBar::TriangularNorth:
 
4970
                                fropt.rect.adjust(0, 0, 0, 1);
 
4971
                                break;
 
4972
                            case QTabBar::RoundedEast:
 
4973
                            case QTabBar::TriangularEast:
 
4974
                                fropt.rect.adjust(-2, 0, -(fropt.rect.width()+1), 0);
 
4975
                                fropt.state&=~State_Horizontal;
 
4976
                                break;
 
4977
                            case QTabBar::RoundedSouth:
 
4978
                            case QTabBar::TriangularSouth:
 
4979
                                fropt.rect.adjust(0, 0, 0, 1);
 
4980
                                break;
 
4981
                            case QTabBar::RoundedWest:
 
4982
                            case QTabBar::TriangularWest:
 
4983
                                fropt.rect.adjust(0, 0, 2, 0);
 
4984
                                fropt.state&=~State_Horizontal;
 
4985
                            default:
 
4986
                                break;
 
4987
                        }
 
4988
 
4944
4989
                    drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
4945
4990
                }
4946
4991
            }
4980
5025
                    break;
4981
5026
                }
4982
5027
#endif
4983
 
 
 
5028
#if QT_VERSION >= 0x040500
 
5029
                QStyleOptionTabV3 tabV3(*tab);
 
5030
#endif
4984
5031
                QRect r2(r);
4985
5032
                bool rtlHorTabs(Qt::RightToLeft==tab->direction && horiz),
4986
5033
                     onlyTab(QStyleOptionTab::OnlyOneTab==tab->position),
4992
5039
                                  QStyleOptionTab::End : QStyleOptionTab::Beginning)) || onlyTab);
4993
5040
                int  tabBarAlignment(styleHint(SH_TabBar_Alignment, tab, widget)),
4994
5041
                     tabOverlap(onlyTab ? 0 : pixelMetric(PM_TabBarTabOverlap, option, widget)),
4995
 
                     moOffset(ROUNDED_NONE==opts.round ? 1 : opts.round);
 
5042
                     moOffset(ROUNDED_NONE==opts.round || TAB_MO_TOP!=opts.tabMouseOver ? 1 : opts.round),
 
5043
                     highlightOffset(opts.highlightTab && opts.round>ROUND_SLIGHT ? 2 : 1),
 
5044
                     highlightBorder(opts.round>ROUND_FULL ? 4 : 3),
 
5045
                     sizeAdjust(!selected && TAB_MO_GLOW==opts.tabMouseOver ? 1 : 0);
4996
5046
                bool leftAligned((!rtlHorTabs && Qt::AlignLeft==tabBarAlignment) ||
4997
5047
                                 (rtlHorTabs && Qt::AlignRight==tabBarAlignment)),
4998
5048
                     rightAligned((!rtlHorTabs && Qt::AlignRight==tabBarAlignment) ||
4999
5049
                                   (rtlHorTabs && Qt::AlignLeft==tabBarAlignment)),
5000
 
                     fixLeft(!onlyBase && !leftCornerWidget && leftAligned && firstTab),
5001
 
                     fixRight(!onlyBase && !rightCornerWidget && rightAligned && lastTab),
5002
 
                     mouseOver(state&State_Enabled && state&State_MouseOver);
 
5050
                     fixLeft(!onlyBase && !leftCornerWidget && leftAligned && firstTab
 
5051
#if QT_VERSION >= 0x040500
 
5052
                             && !tabV3.documentMode
 
5053
#endif
 
5054
                            ),
 
5055
                     fixRight(!onlyBase && !rightCornerWidget && rightAligned && lastTab
 
5056
#if QT_VERSION >= 0x040500
 
5057
                             && !tabV3.documentMode
 
5058
#endif
 
5059
                             ),
 
5060
                     mouseOver(state&State_Enabled && state&State_MouseOver),
 
5061
                     glowMo(!selected && mouseOver && opts.coloredMouseOver && TAB_MO_GLOW==opts.tabMouseOver);
5003
5062
                const QColor *use(backgroundColors(option));
5004
5063
                const QColor &fill(getTabFill(selected, mouseOver, use));
5005
 
                double radius=getRadius(opts.round, r.width(), r.height(), WIDGET_TAB_TOP, RADIUS_EXTERNAL);
 
5064
                double radius=getRadius(&opts, r.width(), r.height(), WIDGET_TAB_TOP, RADIUS_EXTERNAL);
5006
5065
 
5007
5066
                painter->save();
5008
5067
                switch(tab->shape)
5010
5069
                    case QTabBar::RoundedNorth:
5011
5070
                    case QTabBar::TriangularNorth:
5012
5071
                    {
5013
 
                        int round=selected || onlyTab
 
5072
                        int round=selected || onlyTab || TAB_MO_GLOW==opts.tabMouseOver || opts.roundAllTabs
5014
5073
                                        ? ROUNDED_TOP
5015
5074
                                        : firstTab
5016
5075
                                            ? ROUNDED_TOPLEFT
5023
5082
                        if(!firstTab)
5024
5083
                            r.adjust(-tabOverlap, 0, 0, 0);
5025
5084
                        painter->setClipPath(buildPath(r.adjusted(0, 0, 0, 4), WIDGET_TAB_TOP, round, radius));
5026
 
                        fillTab(painter, r.adjusted(1, 1, -1, 0), option, fill, true, WIDGET_TAB_TOP);
 
5085
                        fillTab(painter, r.adjusted(1+sizeAdjust, 1, -(1+sizeAdjust), 0), option, fill, true, WIDGET_TAB_TOP);
5027
5086
                        painter->setClipping(false);
5028
5087
                        // This clipping helps with plasma's tabs and nvidia
5029
5088
                        if(selected)
5030
5089
                            painter->setClipRect(r2.adjusted(-1, 0, 1, -1));
5031
 
                        drawBorder(painter, r.adjusted(0, 0, 0, 4), option, round, NULL, WIDGET_TAB_TOP,
5032
 
                                   selected && !opts.colorSelTab ? BORDER_RAISED : BORDER_FLAT, false);
 
5090
                        drawBorder(painter, r.adjusted(sizeAdjust, 0, -sizeAdjust, 4), option, round, glowMo ? itsMouseOverCols : 0L, WIDGET_TAB_TOP,
 
5091
                                   selected ? BORDER_RAISED : BORDER_FLAT, false);
 
5092
                        if(glowMo)
 
5093
                            drawGlow(painter, r.adjusted(0, -1, 0, 5), WIDGET_TAB_TOP);
5033
5094
 
5034
5095
                        if(selected)
5035
5096
                        {
5058
5119
                        {
5059
5120
                            if(opts.highlightTab)
5060
5121
                            {
 
5122
                                QColor col(itsHighlightCols[0]);
5061
5123
                                painter->setRenderHint(QPainter::Antialiasing, true);
5062
 
                                painter->setPen(itsMenuitemCols[0]);
5063
 
                                drawAaLine(painter, r.left()+1, r.top()+1, r.right()-1, r.top()+1);
5064
 
                                painter->setPen(midColor(fill, itsMenuitemCols[0], IS_FLAT(opts.activeTabAppearance) ? 1.0 : 1.2));
 
5124
                                painter->setPen(col);
 
5125
                                drawAaLine(painter, r.left()+highlightOffset, r.top()+1, r.right()-highlightOffset, r.top()+1);
 
5126
                                col.setAlphaF(0.5);
 
5127
                                painter->setPen(col);
5065
5128
                                drawAaLine(painter, r.left()+1, r.top()+2, r.right()-1, r.top()+2);
5066
5129
                                painter->setRenderHint(QPainter::Antialiasing, false);
 
5130
                                painter->setClipRect(QRect(r.x(), r.y(), r.width(), highlightBorder));
 
5131
                                drawBorder(painter, r, option, ROUNDED_ALL, itsHighlightCols, WIDGET_TAB_TOP, BORDER_FLAT, false, 3);
 
5132
                            }
5067
5133
 
5068
 
                                painter->setClipRect(QRect(r.x(), r.y(), r.width(), 3));
5069
 
                                drawBorder(painter, r, option, ROUNDED_ALL, itsMenuitemCols, WIDGET_TAB_TOP, BORDER_FLAT, false, 3);
5070
 
                            }
5071
 
                        }
5072
 
                        else if(mouseOver && opts.coloredMouseOver)
5073
 
                        {
5074
 
                            painter->setRenderHint(QPainter::Antialiasing, true);
5075
 
                            painter->setPen(itsMouseOverCols[ORIGINAL_SHADE]);
5076
 
                            drawAaLine(painter, r.x()+(firstTab ? moOffset : 1), r.y()+1,
5077
 
                                              r.x()+r.width()-((lastTab ? moOffset : 0)+1), r.y()+1);
5078
 
                            painter->setPen(itsMouseOverCols[QT_STD_BORDER]);
5079
 
                            drawAaLine(painter, r.x()+(firstTab ? moOffset : 1), r.y(),
5080
 
                                              r.x()+r.width()-((lastTab ? moOffset : 0)+1), r.y());
5081
 
                            painter->setRenderHint(QPainter::Antialiasing, false);
5082
 
                        }
 
5134
                            if(opts.colorSelTab)
 
5135
                                colorTab(painter, r, true, WIDGET_TAB_TOP, round);
 
5136
                        }
 
5137
                        else if(mouseOver && opts.coloredMouseOver && TAB_MO_GLOW!=opts.tabMouseOver)
 
5138
                            drawHighlight(painter, QRect(r.x()+(firstTab ? moOffset : 1),
 
5139
                                                         r.y()+(TAB_MO_TOP==opts.tabMouseOver ? 0 : r.height()-1),
 
5140
                                                         r.width()-(firstTab || lastTab ? moOffset : 1), 2),
 
5141
                                          true, TAB_MO_TOP==opts.tabMouseOver);
5083
5142
                        break;
5084
5143
                    }
5085
5144
                    case QTabBar::RoundedSouth:
5086
5145
                    case QTabBar::TriangularSouth:
5087
5146
                    {
5088
 
                        int round=selected || onlyTab
 
5147
                        int round=selected || onlyTab || TAB_MO_GLOW==opts.tabMouseOver || opts.roundAllTabs
5089
5148
                                        ? ROUNDED_BOTTOM
5090
5149
                                        : firstTab
5091
5150
                                            ? ROUNDED_BOTTOMLEFT
5098
5157
                            r.adjust(-tabOverlap, 0, 0, 0);
5099
5158
 
5100
5159
                        painter->setClipPath(buildPath(r.adjusted(0, -4, 0, 0), WIDGET_TAB_BOT, round, radius));
5101
 
                        fillTab(painter, r.adjusted(1, 0, -1, -1), option, fill, true, WIDGET_TAB_BOT);
 
5160
                        fillTab(painter, r.adjusted(1+sizeAdjust, 0, -(1+sizeAdjust), -1), option, fill, true, WIDGET_TAB_BOT);
5102
5161
                        painter->setClipping(false);
5103
 
                        drawBorder(painter, r.adjusted(0, -4, 0, 0), option, round, NULL, WIDGET_TAB_BOT,
5104
 
                                   selected && !opts.colorSelTab ? BORDER_RAISED : BORDER_FLAT, false);
 
5162
                        drawBorder(painter, r.adjusted(sizeAdjust, -4, -sizeAdjust, 0), option, round, glowMo ? itsMouseOverCols : 0L, WIDGET_TAB_BOT,
 
5163
                                   selected ? BORDER_RAISED : BORDER_FLAT, false);
 
5164
                        if(glowMo)
 
5165
                            drawGlow(painter, r.adjusted(0, -5, 0, 1), WIDGET_TAB_BOT);
5105
5166
 
5106
5167
                        if(selected)
5107
5168
                        {
5108
5169
                            painter->setPen(use[QT_FRAME_DARK_SHADOW]);
5109
5170
                            if(!fixLeft)
5110
 
                                painter->drawPoint(r2.left()-1, r2.top());
 
5171
                                painter->drawPoint(r2.left()-(TAB_MO_GLOW==opts.tabMouseOver ? 0 : 1), r2.top());
5111
5172
                            if(!fixRight)
5112
 
                                painter->drawLine(r2.right()-1, r2.top(), r2.right(), r2.top());
 
5173
                                painter->drawLine(r2.right()-(TAB_MO_GLOW==opts.tabMouseOver ? 0 : 1), r2.top(), r2.right(), r2.top());
5113
5174
                        }
5114
5175
                        else
5115
5176
                        {
5125
5186
                        {
5126
5187
                            if(opts.highlightTab)
5127
5188
                            {
 
5189
                                QColor col(itsHighlightCols[0]);
5128
5190
                                painter->setRenderHint(QPainter::Antialiasing, true);
5129
 
                                painter->setPen(itsMenuitemCols[0]);
5130
 
                                drawAaLine(painter, r.left()+1, r.bottom()-1, r.right()-1, r.bottom()-1);
5131
 
                                painter->setPen(midColor(fill, itsMenuitemCols[0]));
 
5191
                                painter->setPen(col);
 
5192
                                drawAaLine(painter, r.left()+highlightOffset, r.bottom()-1, r.right()-highlightOffset, r.bottom()-1);
 
5193
                                col.setAlphaF(0.5);
 
5194
                                painter->setPen(col);
5132
5195
                                drawAaLine(painter, r.left()+1, r.bottom()-2, r.right()-1, r.bottom()-2);
5133
5196
                                painter->setRenderHint(QPainter::Antialiasing, false);
 
5197
                                painter->setClipRect(QRect(r.x(), r.y()+r.height()-highlightBorder, r.width(), r.y()+r.height()-1));
 
5198
                                drawBorder(painter, r, option, ROUNDED_ALL, itsHighlightCols, WIDGET_TAB_BOT, BORDER_FLAT, false, 3);
 
5199
                            }
5134
5200
 
5135
 
                                painter->setClipRect(QRect(r.x(), r.y()+r.height()-3, r.width(), r.y()+r.height()-1));
5136
 
                                drawBorder(painter, r, option, ROUNDED_ALL, itsMenuitemCols, WIDGET_TAB_BOT, BORDER_FLAT, false, 3);
5137
 
                            }
5138
 
                        }
5139
 
                        else if(mouseOver && opts.coloredMouseOver)
5140
 
                        {
5141
 
                            painter->setRenderHint(QPainter::Antialiasing, true);
5142
 
                            painter->setPen(itsMouseOverCols[ORIGINAL_SHADE]);
5143
 
                            drawAaLine(painter, r.x()+(firstTab ? moOffset : 1), r.bottom()-1,
5144
 
                                              r.x()+r.width()-((lastTab ? moOffset : 0)+1), r.bottom()-1);
5145
 
                            painter->setPen(itsMouseOverCols[QT_STD_BORDER]);
5146
 
                            drawAaLine(painter, r.x()+(firstTab ? moOffset : 1), r.bottom(),
5147
 
                                              r.x()+r.width()-((lastTab ? moOffset : 0)+1), r.bottom());
5148
 
                            painter->setRenderHint(QPainter::Antialiasing, false);
5149
 
                        }
 
5201
                            if(opts.colorSelTab)
 
5202
                                colorTab(painter, r, true, WIDGET_TAB_BOT, round);
 
5203
                        }
 
5204
                        else if(mouseOver && opts.coloredMouseOver && TAB_MO_GLOW!=opts.tabMouseOver)
 
5205
                            drawHighlight(painter, QRect(r.x()+(firstTab ? moOffset : 1),
 
5206
                                                         r.y()+(TAB_MO_TOP==opts.tabMouseOver ? r.height()-2 : -1),
 
5207
                                                         r.width()-(firstTab || lastTab ? moOffset : 1), 2),
 
5208
                                          true, TAB_MO_TOP!=opts.tabMouseOver);
5150
5209
                        break;
5151
5210
                    }
5152
5211
                    case QTabBar::RoundedWest:
5153
5212
                    case QTabBar::TriangularWest:
5154
5213
                    {
5155
 
                        int round=selected || onlyTab
 
5214
                        int round=selected || onlyTab || TAB_MO_GLOW==opts.tabMouseOver || opts.roundAllTabs
5156
5215
                                        ? ROUNDED_LEFT
5157
5216
                                        : firstTab
5158
5217
                                            ? ROUNDED_TOPLEFT
5165
5224
                        if(!firstTab)
5166
5225
                            r.adjust(0, -tabOverlap, 0, 0);
5167
5226
                        painter->setClipPath(buildPath(r.adjusted(0, 0, 4, 0), WIDGET_TAB_TOP, round, radius));
5168
 
                        fillTab(painter, r.adjusted(1, 1, 0, -1), option, fill, false, WIDGET_TAB_TOP);
 
5227
                        fillTab(painter, r.adjusted(1, sizeAdjust, 0, -(1+sizeAdjust)), option, fill, false, WIDGET_TAB_TOP);
5169
5228
                        painter->setClipping(false);
5170
 
                        drawBorder(painter, r.adjusted(0, 0, 4, 0), option, round, NULL, WIDGET_TAB_TOP,
5171
 
                                   selected && !opts.colorSelTab ? BORDER_RAISED : BORDER_FLAT, false);
 
5229
                        drawBorder(painter, r.adjusted(0, sizeAdjust, 4, -sizeAdjust), option, round, glowMo ? itsMouseOverCols : 0L, WIDGET_TAB_TOP,
 
5230
                                   selected ? BORDER_RAISED : BORDER_FLAT, false);
 
5231
                        if(glowMo)
 
5232
                            drawGlow(painter, r.adjusted(-1, 0, 5, 0), WIDGET_TAB_TOP);
5172
5233
 
5173
5234
                        if(selected)
5174
5235
                        {
5175
5236
                            painter->setPen(use[0]);
5176
5237
                            if(!firstTab)
5177
 
                                painter->drawPoint(r2.right(), r2.top()-1);
 
5238
                                painter->drawPoint(r2.right(), r2.top()-(TAB_MO_GLOW==opts.tabMouseOver ? 0 : 1));
5178
5239
                            painter->drawLine(r2.right(), r2.bottom()-1, r2.right(), r2.bottom());
5179
5240
                        }
5180
5241
                        else
5192
5253
                        {
5193
5254
                            if(opts.highlightTab)
5194
5255
                            {
 
5256
                                QColor col(itsHighlightCols[0]);
5195
5257
                                painter->setRenderHint(QPainter::Antialiasing, true);
5196
 
                                painter->setPen(itsMenuitemCols[0]);
5197
 
                                drawAaLine(painter, r.left()+1, r.top()+1, r.left()+1, r.bottom()-1);
5198
 
                                painter->setPen(midColor(fill, itsMenuitemCols[0], IS_FLAT(opts.activeTabAppearance) ? 1.0 : 1.2));
 
5258
                                painter->setPen(col);
 
5259
                                drawAaLine(painter, r.left()+1, r.top()+highlightOffset, r.left()+1, r.bottom()-highlightOffset);
 
5260
                                col.setAlphaF(0.5);
 
5261
                                painter->setPen(col);
5199
5262
                                drawAaLine(painter, r.left()+2, r.top()+1, r.left()+2, r.bottom()-1);
5200
5263
                                painter->setRenderHint(QPainter::Antialiasing, false);
 
5264
                                painter->setClipRect(QRect(r.x(), r.y(), highlightBorder, r.height()));
 
5265
                                drawBorder(painter, r, option, ROUNDED_ALL, itsHighlightCols, WIDGET_TAB_TOP, BORDER_FLAT, false, 3);
 
5266
                            }
5201
5267
 
5202
 
                                painter->setClipRect(QRect(r.x(), r.y(), 3, r.height()));
5203
 
                                drawBorder(painter, r, option, ROUNDED_ALL, itsMenuitemCols, WIDGET_TAB_TOP, BORDER_FLAT, false, 3);
5204
 
                            }
5205
 
                        }
5206
 
                        else if(mouseOver && opts.coloredMouseOver)
5207
 
                        {
5208
 
                            painter->setRenderHint(QPainter::Antialiasing, true);
5209
 
                            painter->setPen(itsMouseOverCols[ORIGINAL_SHADE]);
5210
 
                            drawAaLine(painter, r.x()+1, r.y()+(firstTab ? moOffset : 1),
5211
 
                                              r.x()+1, r.y()+r.height()-((lastTab ? moOffset : 0)+1));
5212
 
                            painter->setPen(itsMouseOverCols[QT_STD_BORDER]);
5213
 
                            drawAaLine(painter, r.x(), r.y()+(firstTab ? moOffset : 1),
5214
 
                                              r.x(), r.y()+r.height()-((lastTab ? moOffset : 0)+1));
5215
 
                            painter->setRenderHint(QPainter::Antialiasing, false);
5216
 
                        }
 
5268
                            if(opts.colorSelTab)
 
5269
                                colorTab(painter, r, false, WIDGET_TAB_TOP, round);
 
5270
                        }
 
5271
                        else if(mouseOver && opts.coloredMouseOver && TAB_MO_GLOW!=opts.tabMouseOver)
 
5272
                            drawHighlight(painter, QRect(r.x()+(TAB_MO_TOP==opts.tabMouseOver ? 0 : r.width()-1),
 
5273
                                                         r.y()+(firstTab ? moOffset : 1),
 
5274
                                                         2, r.height()-(firstTab || lastTab ? moOffset : 1)),
 
5275
                                          false, TAB_MO_TOP==opts.tabMouseOver);
5217
5276
                        break;
5218
5277
                    }
5219
5278
                    case QTabBar::RoundedEast:
5220
5279
                    case QTabBar::TriangularEast:
5221
5280
                    {
5222
 
                        int round=selected || onlyTab
 
5281
                        int round=selected || onlyTab || TAB_MO_GLOW==opts.tabMouseOver || opts.roundAllTabs
5223
5282
                                        ? ROUNDED_RIGHT
5224
5283
                                        : firstTab
5225
5284
                                            ? ROUNDED_TOPRIGHT
5232
5291
                        if(!firstTab)
5233
5292
                            r.adjust(0, -tabOverlap, 0, 0);
5234
5293
                        painter->setClipPath(buildPath(r.adjusted(-4, 0, 0, 0), WIDGET_TAB_BOT, round, radius));
5235
 
                        fillTab(painter, r.adjusted(0, 1, -1, -1), option, fill, false, WIDGET_TAB_BOT);
 
5294
                        fillTab(painter, r.adjusted(0, sizeAdjust, -1, -(1+sizeAdjust)), option, fill, false, WIDGET_TAB_BOT);
5236
5295
                        painter->setClipping(false);
5237
 
                        drawBorder(painter, r.adjusted(-4, 0, 0, 0), option, round, NULL, WIDGET_TAB_BOT,
5238
 
                                   selected && !opts.colorSelTab ? BORDER_RAISED : BORDER_FLAT, false);
 
5296
                        drawBorder(painter, r.adjusted(-4, sizeAdjust, 0, -sizeAdjust), option, round, glowMo ? itsMouseOverCols : 0L, WIDGET_TAB_BOT,
 
5297
                                   selected ? BORDER_RAISED : BORDER_FLAT, false);
 
5298
                        if(glowMo)
 
5299
                            drawGlow(painter, r.adjusted(-5, 0, 1, 0), WIDGET_TAB_BOT);
5239
5300
 
5240
5301
                        if(selected)
5241
5302
                        {
5242
5303
                            painter->setPen(use[QT_FRAME_DARK_SHADOW]);
5243
5304
                            if(!firstTab)
5244
 
                                painter->drawPoint(r2.left(), r2.top()-1);
5245
 
                            painter->drawLine(r2.left(), r2.bottom()-1, r2.left(), r2.bottom());
 
5305
                                painter->drawPoint(r2.left(), r2.top()-(TAB_MO_GLOW==opts.tabMouseOver ? 0 : 1));
 
5306
                            painter->drawLine(r2.left(), r2.bottom()-(TAB_MO_GLOW==opts.tabMouseOver ? 0 : 1), r2.left(), r2.bottom());
5246
5307
                        }
5247
5308
                        else
5248
5309
                        {
5259
5320
                        {
5260
5321
                            if(opts.highlightTab)
5261
5322
                            {
 
5323
                                QColor col(itsHighlightCols[0]);
5262
5324
                                painter->setRenderHint(QPainter::Antialiasing, true);
5263
 
                                painter->setPen(itsMenuitemCols[0]);
5264
 
                                drawAaLine(painter, r.right()-1, r.top()+1, r.right()-1, r.bottom()-1);
5265
 
                                painter->setPen(midColor(fill, itsMenuitemCols[0]));
 
5325
                                painter->setPen(col);
 
5326
                                drawAaLine(painter, r.right()-1, r.top()+highlightOffset, r.right()-1, r.bottom()-highlightOffset);
 
5327
                                col.setAlphaF(0.5);
 
5328
                                painter->setPen(col);
5266
5329
                                drawAaLine(painter, r.right()-2, r.top()+1, r.right()-2, r.bottom()-1);
5267
5330
                                painter->setRenderHint(QPainter::Antialiasing, false);
 
5331
                                painter->setClipRect(QRect(r.x()+r.width()-highlightBorder, r.y(), r.x()+r.width()-1, r.height()));
 
5332
                                drawBorder(painter, r, option, ROUNDED_ALL, itsHighlightCols, WIDGET_TAB_TOP, BORDER_FLAT, false, 3);
 
5333
                            }
5268
5334
 
5269
 
                                painter->setClipRect(QRect(r.x()+r.width()-3, r.y(), r.x()+r.width()-1, r.height()));
5270
 
                                drawBorder(painter, r, option, ROUNDED_ALL, itsMenuitemCols, WIDGET_TAB_TOP, BORDER_FLAT, false, 3);
5271
 
                            }
5272
 
                        }
5273
 
                        else if(mouseOver && opts.coloredMouseOver)
5274
 
                        {
5275
 
                            painter->setRenderHint(QPainter::Antialiasing, true);
5276
 
                            painter->setPen(itsMouseOverCols[ORIGINAL_SHADE]);
5277
 
                            drawAaLine(painter, r.right()-1, r.y()+(firstTab ? moOffset : 1),
5278
 
                                              r.right()-1, r.y()+r.height()-((lastTab ? moOffset : 0)+1));
5279
 
                            painter->setPen(itsMouseOverCols[QT_STD_BORDER]);
5280
 
                            drawAaLine(painter, r.right(), r.y()+(firstTab ? moOffset : 1),
5281
 
                                              r.right(), r.y()+r.height()-((lastTab ? moOffset : 0)+1));
5282
 
                            painter->setRenderHint(QPainter::Antialiasing, false);
5283
 
                        }
 
5335
                            if(opts.colorSelTab)
 
5336
                                colorTab(painter, r, false, WIDGET_TAB_BOT, round);
 
5337
                        }
 
5338
                        else if(mouseOver && opts.coloredMouseOver && TAB_MO_GLOW!=opts.tabMouseOver)
 
5339
                            drawHighlight(painter, QRect(r.x()+(TAB_MO_TOP==opts.tabMouseOver ? r.width()-2 : -1),
 
5340
                                                         r.y()+(firstTab ? moOffset : 1),
 
5341
                                                         2, r.height()-(firstTab || lastTab ? moOffset : 1)),
 
5342
                                          false, TAB_MO_TOP!=opts.tabMouseOver);
5284
5343
                        break;
5285
5344
                    }
5286
5345
                }
5370
5429
            }
5371
5430
 
5372
5431
            painter->save();
5373
 
            if(!widget || !widget->testAttribute(Qt::WA_NoSystemBackground))
 
5432
            if(opts.flatSbarButtons && !IS_FLAT(opts.sbarBgndAppearance) && SCROLLBAR_NONE!=opts.scrollbarType)
 
5433
                drawBevelGradientReal(palette.brush(QPalette::Background).color(), painter, r, state&State_Horizontal, false,
 
5434
                                      opts.sbarBgndAppearance, WIDGET_SB_BGND);
 
5435
            else if(!widget || !widget->testAttribute(Qt::WA_NoSystemBackground))
5374
5436
                painter->fillRect(r, palette.brush(QPalette::Background));
5375
5437
 
5376
5438
            QStyleOption opt(*option);
5393
5455
                drawLightBevel(painter, br, &opt, widget, round, getFill(&opt, use), use, true, WIDGET_SB_BUTTON);
5394
5456
 
5395
5457
            opt.rect = ar;
5396
 
            // The following fixes gwenviews scrollbars...
5397
 
            if(opt.palette.text().color()!=opt.palette.buttonText().color())
 
5458
            
 
5459
            if(opt.palette.text().color()!=opt.palette.buttonText().color()) // The following fixes gwenviews scrollbars...
5398
5460
                opt.palette.setColor(QPalette::Text, opt.palette.buttonText().color());
5399
5461
 
5400
5462
            drawPrimitive(pe, &opt, painter, widget);
5536
5598
                        pm=getIconPixmap(tb->icon, tb->rect.size().boundedTo(iconSize), mode, state);
5537
5599
                        pmSize = tb->icon.actualSize(iconSize, mode);
5538
5600
                        if(pmSize.width()<pm.width())
5539
 
                            pr.setX(pr.x()+((pm.width()-pmSize.width())/2));
 
5601
                            pr.setX(pr.x()+((pm.width()-pmSize.width())));
5540
5602
                        if(pmSize.height()<pm.height())
5541
 
                            pr.setY(pr.y()+((pm.height()-pmSize.height())/2));
 
5603
                            pr.setY(pr.y()+((pm.height()-pmSize.height())));
5542
5604
                    }
5543
5605
 
5544
5606
                    if (Qt::ToolButtonIconOnly!=tb->toolButtonStyle)
5554
5616
                        {
5555
5617
                            pr.setHeight(pmSize.height() + 6);
5556
5618
 
5557
 
                            tr.adjust(0, pr.bottom()-2, 0, 0); // -3);
 
5619
                            tr.adjust(0, pr.bottom()-3, 0, 0); // -3);
5558
5620
                            pr.translate(shiftX, shiftY);
5559
5621
                            if (hasArrow)
5560
5622
                                drawTbArrow(this, tb, pr, painter, widget);
5580
5642
                    else
5581
5643
                    {
5582
5644
                        pr.translate(shiftX, shiftY);
 
5645
 
5583
5646
                        if (hasArrow)
5584
5647
                            drawTbArrow(this, tb, pr, painter, widget);
5585
5648
                        else
 
5649
                        {
 
5650
                            if (tb->features&QStyleOptionToolButton::HasMenu)
 
5651
                                pr.adjust(-LARGE_ARR_WIDTH, 0, 0, 0);
5586
5652
                            drawItemPixmap(painter, pr, Qt::AlignCenter, pm);
 
5653
                        }
5587
5654
                    }
5588
5655
                }
5589
5656
            }
5757
5824
 
5758
5825
                        // For some reason the MenuTitle has a larger border on the left, so adjust the width by 1 pixel
5759
5826
                        // to make this look nicer.
5760
 
                        //drawBorder(painter, r.adjusted(2, 2, -3, -2), option, ROUNDED_ALL, NULL, WIDGET_OTHER, BORDER_SUNKEN);
 
5827
                        //drawBorder(painter, r.adjusted(2, 2, -3, -2), option, ROUNDED_ALL, 0L, WIDGET_OTHER, BORDER_SUNKEN);
5761
5828
                        QStyleOptionToolButton opt(*toolbutton);
5762
5829
                        opt.rect = r.adjusted(2, 2, -3, -2);
5763
5830
                        opt.state=State_Raised|State_Enabled|State_Horizontal;
5783
5850
                else if(bflags&State_AutoRaise)
5784
5851
                    bflags &= ~State_Raised;
5785
5852
 
5786
 
#ifdef QTC_DONT_COLOUR_MOUSEOVER_TBAR_BUTTONS
5787
 
                if(state&State_AutoRaise)
 
5853
                //if(state&State_AutoRaise)
5788
5854
                    bflags|=QTC_STATE_TBAR_BUTTON;
5789
 
#endif
 
5855
 
5790
5856
                State mflags(bflags);
5791
5857
 
5792
5858
#if QT_VERSION >= 0x040500
5793
 
                if (state&State_Sunken && !(toolbutton->activeSubControls & SC_ToolButton))
 
5859
                if (state&State_Sunken && !(toolbutton->activeSubControls&SC_ToolButton))
5794
5860
                    bflags&=~State_Sunken;
5795
5861
#else
5796
5862
                // Try to detect if this is Qt 4.5...
5797
5863
                if(qtVersion()>=VER_45)
5798
 
                {      
5799
 
                    if (state&State_Sunken && !(toolbutton->activeSubControls & SC_ToolButton))
 
5864
                {
 
5865
                    if (state&State_Sunken && !(toolbutton->activeSubControls&SC_ToolButton))
5800
5866
                        bflags&=~State_Sunken;
5801
5867
                }
5802
 
                else if (toolbutton->activeSubControls & SC_ToolButtonMenu && state&State_Enabled)
 
5868
                else if (toolbutton->activeSubControls&SC_ToolButtonMenu && state&State_Enabled)
5803
5869
                    mflags |= State_Sunken;
5804
5870
#endif
5805
5871
 
5807
5873
                QStyleOption tool(0);
5808
5874
                tool.palette = toolbutton->palette;
5809
5875
 
5810
 
                if ( (toolbutton->subControls & SC_ToolButton && (bflags & (State_Sunken | State_On | State_Raised))) ||
5811
 
                     (toolbutton->subControls & SC_ToolButtonMenu && drawMenu))
 
5876
                if ( (toolbutton->subControls&SC_ToolButton && (bflags & (State_Sunken | State_On | State_Raised))) ||
 
5877
                     (toolbutton->subControls&SC_ToolButtonMenu && drawMenu))
5812
5878
                {
5813
 
                    tool.rect = toolbutton->subControls & SC_ToolButtonMenu ? button.united(menuarea) : button;
 
5879
                    tool.rect = toolbutton->subControls&SC_ToolButtonMenu ? button.united(menuarea) : button;
5814
5880
                    tool.state = bflags;
5815
5881
 
5816
5882
                    if(!(bflags&State_Sunken) && (mflags&State_Sunken))
5817
5883
                        tool.state &= ~State_MouseOver;
5818
 
                                 
 
5884
 
5819
5885
                    drawPrimitive(PE_PanelButtonTool, &tool, painter, widget);
5820
5886
                }
5821
5887
 
5822
 
                if (toolbutton->subControls & SC_ToolButtonMenu)
 
5888
                if (toolbutton->subControls&SC_ToolButtonMenu)
5823
5889
                {
5824
5890
                    if(etched)
5825
5891
                        if(reverse)
5842
5908
                                       MO_GLOW==opts.coloredMouseOver ? WIDGET_MENU_BUTTON : WIDGET_NO_ETCH_BTN);
5843
5909
                    }
5844
5910
 
5845
 
                    drawArrow(painter, tool.rect, PE_IndicatorArrowDown, option->palette.buttonText().color());
 
5911
                    if(mflags&State_Sunken)
 
5912
                        tool.rect.adjust(1, 1, 1, 1);
 
5913
                    drawArrow(painter, tool.rect, PE_IndicatorArrowDown, QTC_MO_ARROW(option->palette.buttonText().color()));
5846
5914
                }
5847
5915
/*
5848
5916
                else if (toolbutton->features & QStyleOptionToolButton::HasMenu)
5899
5967
                    if(bflags&State_Sunken)
5900
5968
                        arrow.adjust(1, 1, 1, 1);
5901
5969
 
5902
 
                    drawArrow(painter, arrow, PE_IndicatorArrowDown, option->palette.buttonText().color());
 
5970
                    drawArrow(painter, arrow, PE_IndicatorArrowDown, QTC_MO_ARROW(option->palette.buttonText().color()));
5903
5971
                }
5904
5972
            }
5905
5973
            break;
5921
5989
            if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(option))
5922
5990
            {
5923
5991
                int i;
5924
 
                if (lv->subControls & SC_Q3ListView)
 
5992
                if (lv->subControls&SC_Q3ListView)
5925
5993
                    QCommonStyle::drawComplexControl(control, lv, painter, widget);
5926
5994
                if (lv->subControls & (SC_Q3ListViewBranch | SC_Q3ListViewExpand))
5927
5995
                {
5935
6003
                    QPolygon                   lines;
5936
6004
 
5937
6005
                    painter->save();
5938
 
                    if ((lv->activeSubControls & SC_All) && (lv->subControls & SC_Q3ListViewExpand))
 
6006
                    if ((lv->activeSubControls&SC_All) && (lv->subControls&SC_Q3ListViewExpand))
5939
6007
                    {
5940
6008
                        c = 2;
5941
6009
                        if(opts.lvLines)
6061
6129
                        }
6062
6130
                    }
6063
6131
 
6064
 
                    if (opts.lvLines && (lv->subControls & SC_Q3ListViewBranch))
 
6132
                    if (opts.lvLines && (lv->subControls&SC_Q3ListViewBranch))
6065
6133
                    {
6066
6134
                        painter->setPen(palette.mid().color());
6067
6135
 
6097
6165
                    frame.adjust(reverse ? 0 : 1, 1, reverse ? -1 : 0, -1);
6098
6166
                }
6099
6167
 
 
6168
                if(opts.unifySpinBtns)
 
6169
                {
 
6170
                    QRect btns=up.united(down);
 
6171
                    const QColor *use(buttonColors(option));
 
6172
                    QStyleOption opt(*option);
 
6173
 
 
6174
                    opt.state&=~(State_Sunken|State_MouseOver);
 
6175
                    opt.state|=State_Horizontal;
 
6176
 
 
6177
                    drawLightBevel(painter, btns, &opt, widget, reverse ?  ROUNDED_LEFT : ROUNDED_RIGHT,
 
6178
                                   getFill(&opt, use), use, true, WIDGET_SPIN);
 
6179
 
 
6180
                    if(state&State_MouseOver && state&State_Enabled && !(state&State_Sunken))
 
6181
                    {
 
6182
                        opt.state|=State_MouseOver;
 
6183
                        painter->save();
 
6184
                        painter->setClipRect(upIsActive ? up : down);
 
6185
                        drawLightBevel(painter, btns, &opt, widget, reverse ?  ROUNDED_LEFT : ROUNDED_RIGHT,
 
6186
                                       getFill(&opt, use), use, true, WIDGET_SPIN);
 
6187
                        painter->restore();
 
6188
                    }
 
6189
                    drawFadedLine(painter, down.adjusted(2, 0, -2, 0), use[QT_BORDER(state&State_Enabled)], true, true, true);
 
6190
                }
 
6191
                
6100
6192
                if(up.isValid())
6101
6193
                {
6102
6194
                    QStyleOption opt(*option);
6147
6239
//                 if (groove.isValid())
6148
6240
//                     groove = horizontal ? groove.adjusted(0, 5, 0, -5) : groove.adjusted(5, 0, -5, 0);
6149
6241
 
6150
 
                if ((option->subControls & SC_SliderGroove) && groove.isValid())
 
6242
                if ((option->subControls&SC_SliderGroove) && groove.isValid())
6151
6243
                    drawSliderGroove(painter, groove, handle, slider, widget);
6152
6244
 
6153
 
                if ((option->subControls & SC_SliderHandle) && handle.isValid())
 
6245
                if ((option->subControls&SC_SliderHandle) && handle.isValid())
6154
6246
                {
6155
 
                    drawSliderHandle(painter, handle, slider);
 
6247
                    QStyleOptionSlider s(*slider);
 
6248
                    if(!(s.activeSubControls & QStyle::SC_SliderHandle))
 
6249
                    {
 
6250
                        s.state &= ~QStyle::State_MouseOver;
 
6251
                        s.state &= ~QStyle::State_Sunken;
 
6252
                    }
 
6253
 
 
6254
                    drawSliderHandle(painter, handle, &s);
6156
6255
 
6157
6256
                    if (state&State_HasFocus)
6158
6257
                    {
6169
6268
                    }
6170
6269
                }
6171
6270
 
6172
 
                if (option->subControls & SC_SliderTickmarks)
 
6271
                if (option->subControls&SC_SliderTickmarks)
6173
6272
                {
6174
6273
                    QPen oldPen = painter->pen();
6175
6274
                    painter->setPen(backgroundColors(option)[QT_STD_BORDER]);
6196
6295
                    int v(slider->minimum),
6197
6296
                        len(pixelMetric(PM_SliderLength, slider, widget));
6198
6297
 
6199
 
                    QVarLengthArray<QLine, 32> lines;
6200
 
                    while (v <= slider->maximum)
 
6298
                    while (v <= slider->maximum + 1)
6201
6299
                    {
 
6300
                        if (v == slider->maximum + 1 && interval == 1)
 
6301
                            break;
 
6302
 
6202
6303
                        int pos(sliderPositionFromValue(slider->minimum, slider->maximum,
6203
 
                                                        v, (horizontal
 
6304
                                                        qMin(v, slider->maximum), (horizontal
6204
6305
                                                            ? slider->rect.width()
6205
6306
                                                            : slider->rect.height()) - len,
6206
6307
                                                        slider->upsideDown) + len / 2);
6210
6311
                        if (horizontal)
6211
6312
                        {
6212
6313
                            if (ticksAbove)
6213
 
                                lines.append(QLine(pos, slider->rect.top() + extra,
 
6314
                                painter->drawLine(QLine(pos, slider->rect.top() + extra,
6214
6315
                                                pos, slider->rect.top() + tickSize));
6215
6316
                            if (ticksBelow)
6216
 
                                lines.append(QLine(pos, slider->rect.bottom() - extra,
 
6317
                                painter->drawLine(QLine(pos, slider->rect.bottom() - extra,
6217
6318
                                                pos, slider->rect.bottom() - tickSize));
6218
6319
                        }
6219
6320
                        else
6220
6321
                        {
6221
6322
                            if (ticksAbove)
6222
 
                                lines.append(QLine(slider->rect.left() + extra, pos,
 
6323
                                painter->drawLine(QLine(slider->rect.left() + extra, pos,
6223
6324
                                                slider->rect.left() + tickSize, pos));
6224
6325
                            if (ticksBelow)
6225
 
                                lines.append(QLine(slider->rect.right() - extra, pos,
 
6326
                                painter->drawLine(QLine(slider->rect.right() - extra, pos,
6226
6327
                                                slider->rect.right() - tickSize, pos));
6227
6328
                        }
6228
6329
 
6232
6333
                            break;
6233
6334
                        v = nextInterval;
6234
6335
                    }
6235
 
                    painter->drawLines(lines.constData(), lines.size());
6236
6336
                    painter->setPen(oldPen);
6237
6337
                }
6238
6338
            }
6242
6342
            {
6243
6343
                painter->save();
6244
6344
 
6245
 
                const int    buttonMargin(6);
6246
 
                bool         active(state & State_Active),
 
6345
                bool         active(state&State_Active),
6247
6346
                             kwin(theThemedApp==APP_KWIN || titleBar->titleBarState&QtC_StateKWin),
6248
6347
                             roundKWinFull(QTC_FULLLY_ROUNDED &&
6249
6348
                                            ((APP_KWIN==theThemedApp && !(titleBar->titleBarState&State_Raised)) ||
6250
6349
                                              titleBar->titleBarState&QtC_StateKWin));
6251
 
                const QColor *btnCols(kwin
 
6350
                const QColor *bgndCols(kwin ? buttonColors(option) : getMdiColors(titleBar, active)),
 
6351
                             *btnCols(kwin || opts.titlebarButtons&QTC_TITLEBAR_BUTTON_STD_COLOR
6252
6352
                                        ? buttonColors(option)
6253
 
                                        : getMdiColors(titleBar, active));
 
6353
                                        : getMdiColors(titleBar, active)),
 
6354
                             *titleCols(kwin || !(opts.titlebarButtons&QTC_TITLEBAR_BUTTON_STD_COLOR)
 
6355
                                            ? btnCols : getMdiColors(titleBar, active));
6254
6356
                QColor       textColor(theThemedApp==APP_KWIN
6255
6357
                                        ? option->palette.color(QPalette::WindowText)
6256
 
                                        : active
 
6358
                                        : active || opts.titlebarButtons&QTC_TITLEBAR_BUTTON_HOVER_SYMBOL
6257
6359
                                            ? itsActiveMdiTextColor
6258
6360
                                            : itsMdiTextColor),
6259
6361
                             shadow(shadowColor(textColor));
6269
6371
                if(state&QtC_StateKWinHighlight)
6270
6372
                    opt.state|=QtC_StateKWinHighlight;
6271
6373
 
6272
 
                if(APP_KWIN!=theThemedApp && roundKWinFull) // Set clipping for preview in kcmshell...
6273
 
                {
6274
 
                    int     x(r.x()), y(r.y()), w(r.width()), h(r.height());
6275
 
                    QRegion mask(x+5, y+0, w-10, h);
6276
 
 
6277
 
                    mask += QRegion(x+0, y+5, 1, h-6);
6278
 
                    mask += QRegion(x+1, y+3, 1, h-3);
6279
 
                    mask += QRegion(x+2, y+2, 1, h-2);
6280
 
                    mask += QRegion(x+3, y+1, 2, h-1);
6281
 
 
6282
 
                    mask += QRegion(x+w-1, y+5, 1, h-6);
6283
 
                    mask += QRegion(x+w-2, y+3, 1, h-3);
6284
 
                    mask += QRegion(x+w-3, y+2, 1, h-2);
6285
 
                    mask += QRegion(x+w-5, y+1, 2, h-1);
6286
 
                    painter->setClipRegion(mask);
6287
 
                }
6288
 
 
6289
 
                drawLightBevel(painter, r, &opt, widget,
6290
 
                               titleBar->titleBarState&State_Raised
6291
 
                                ? ROUNDED_NONE
6292
 
                                : titleBar->titleBarState&State_Enabled
6293
 
                                    ? ROUNDED_ALL
6294
 
                                    : ROUNDED_TOP,
6295
 
                               btnCols[ORIGINAL_SHADE], btnCols, true,
6296
 
                               titleBar->titleBarState&Qt::WindowMinimized ? WIDGET_MDI_WINDOW : WIDGET_MDI_WINDOW_TITLE);
6297
 
 
6298
 
                if(roundKWinFull)
6299
 
                {
6300
 
                    bool   kwinHighlight(state&QtC_StateKWinHighlight);
6301
 
                    QColor col(kwinHighlight ? itsMenuitemCols[0] : btnCols[QT_STD_BORDER]);
6302
 
 
6303
 
                    painter->setPen(col);
6304
 
 
6305
 
                    if(kwinHighlight || (state&QtC_StateKWinShadows))
6306
 
                    {
6307
 
                        painter->drawPoint(r.x()+3, r.y()+1);
6308
 
                        painter->drawPoint(r.x()+1, r.y()+3);
6309
 
                        painter->drawPoint(r.x()+r.width()-4, r.y()+1);
6310
 
                        painter->drawPoint(r.x()+r.width()-2, r.y()+3);
6311
 
                        col.setAlphaF(0.5);
6312
 
                        painter->setPen(col);
6313
 
                        painter->drawPoint(r.x()+2, r.y()+2);
6314
 
                        painter->drawPoint(r.x()+4, r.y()+1);
6315
 
                        painter->drawPoint(r.x()+1, r.y()+4);
6316
 
                        painter->drawPoint(r.x()+r.width()-3, r.y()+2);
6317
 
                        painter->drawPoint(r.x()+r.width()-5, r.y()+1);
6318
 
                        painter->drawPoint(r.x()+r.width()-2, r.y()+4);
6319
 
                    }
6320
 
                    else
6321
 
                    {
6322
 
                        painter->drawLine(r.x()+1, r.y()+4, r.x()+1, r.y()+3);
6323
 
                        painter->drawPoint(r.x()+2, r.y()+2);
6324
 
                        painter->drawLine(r.x()+3, r.y()+1, r.x()+4, r.y()+1);
6325
 
                        painter->drawLine(r.x()+r.width()-2, r.y()+4, r.x()+r.width()-2, r.y()+3);
6326
 
                        painter->drawPoint(r.x()+r.width()-3, r.y()+2);
6327
 
                        painter->drawLine(r.x()+r.width()-4, r.y()+1, r.x()+r.width()-5, r.y()+1);
6328
 
                    }
6329
 
                    if(APPEARANCE_SHINY_GLASS!=(active ? opts.titlebarAppearance : opts.inactiveTitlebarAppearance))
 
6374
//                 if(APP_KWIN!=theThemedApp && roundKWinFull) // Set clipping for preview in kcmshell...
 
6375
//                 {
 
6376
//                     int     x(r.x()), y(r.y()), w(r.width()), h(r.height());
 
6377
//                     QRegion mask(x+5, y+0, w-10, h);
 
6378
// 
 
6379
//                     mask += QRegion(x+0, y+5, 1, h-6);
 
6380
//                     mask += QRegion(x+1, y+3, 1, h-3);
 
6381
//                     mask += QRegion(x+2, y+2, 1, h-2);
 
6382
//                     mask += QRegion(x+3, y+1, 2, h-1);
 
6383
// 
 
6384
//                     mask += QRegion(x+w-1, y+5, 1, h-6);
 
6385
//                     mask += QRegion(x+w-2, y+3, 1, h-3);
 
6386
//                     mask += QRegion(x+w-3, y+2, 1, h-2);
 
6387
//                     mask += QRegion(x+w-5, y+1, 2, h-1);
 
6388
//                     painter->setClipRegion(mask);
 
6389
//                 }
 
6390
 
 
6391
                if(state&QtCStateKWinNoBorder)
 
6392
                    drawBevelGradient(titleCols[ORIGINAL_SHADE], painter, r, true, false,
 
6393
                                      widgetApp(WIDGET_MDI_WINDOW, &opts, option->state&State_Active), WIDGET_MDI_WINDOW);
 
6394
                else
 
6395
                {
 
6396
                    drawLightBevel(painter, r, &opt, widget,
 
6397
                                   titleBar->titleBarState&State_Raised
 
6398
                                        ? ROUNDED_NONE
 
6399
                                        : titleBar->titleBarState&State_Enabled
 
6400
                                            ? ROUNDED_ALL
 
6401
                                            : ROUNDED_TOP,
 
6402
                                    titleCols[ORIGINAL_SHADE], titleCols, true,
 
6403
                                    titleBar->titleBarState&Qt::WindowMinimized ? WIDGET_MDI_WINDOW : WIDGET_MDI_WINDOW_TITLE);
 
6404
 
 
6405
                    if(opts.titlebarBorder)
6330
6406
                    {
6331
6407
                        painter->setPen(btnCols[0]);
6332
 
                        painter->drawLine(r.x()+2, r.y()+4, r.x()+2, r.y()+3);
6333
 
                        painter->drawLine(r.x()+3, r.y()+2, r.x()+4, r.y()+2);
6334
 
                        //painter->drawLine(r.x()+r.width()-3, r.y()+4, r.x()+r.width()-3, r.y()+3);
6335
 
                        painter->drawLine(r.x()+r.width()-4, r.y()+2, r.x()+r.width()-5, r.y()+2);
 
6408
                        painter->drawPoint(r.x()+1, r.y()+r.height()-1);
 
6409
                    }
 
6410
 
 
6411
                    if(roundKWinFull)
 
6412
                    {
 
6413
                        bool   kwinHighlight(state&QtC_StateKWinHighlight);
 
6414
                        QColor col(kwinHighlight ? itsFocusCols[0] : btnCols[QT_STD_BORDER]);
 
6415
 
 
6416
                        painter->setPen(col);
 
6417
 
 
6418
                        if(kwinHighlight || (state&QtC_StateKWinShadows))
 
6419
                        {
 
6420
                            painter->drawPoint(r.x()+3, r.y()+1);
 
6421
                            painter->drawPoint(r.x()+1, r.y()+3);
 
6422
                            painter->drawPoint(r.x()+r.width()-4, r.y()+1);
 
6423
                            painter->drawPoint(r.x()+r.width()-2, r.y()+3);
 
6424
    //                         painter->drawPoint(r.x()+r.width()-1, r.y()+6);
 
6425
                            col.setAlphaF(0.5);
 
6426
                            painter->setPen(col);
 
6427
                            painter->drawPoint(r.x()+2, r.y()+2);
 
6428
                            painter->drawPoint(r.x()+4, r.y()+1);
 
6429
                            painter->drawPoint(r.x()+1, r.y()+4);
 
6430
                            painter->drawPoint(r.x()+r.width()-3, r.y()+2);
 
6431
                            painter->drawPoint(r.x()+r.width()-5, r.y()+1);
 
6432
                            painter->drawPoint(r.x()+r.width()-2, r.y()+4);
 
6433
                        }
 
6434
                        else
 
6435
                        {
 
6436
                            painter->drawLine(r.x()+1, r.y()+4, r.x()+1, r.y()+3);
 
6437
                            painter->drawPoint(r.x()+2, r.y()+2);
 
6438
                            painter->drawLine(r.x()+3, r.y()+1, r.x()+4, r.y()+1);
 
6439
                            painter->drawLine(r.x()+r.width()-2, r.y()+4, r.x()+r.width()-2, r.y()+3);
 
6440
                            painter->drawPoint(r.x()+r.width()-3, r.y()+2);
 
6441
                            painter->drawLine(r.x()+r.width()-4, r.y()+1, r.x()+r.width()-5, r.y()+1);
 
6442
                        }
 
6443
                        if(opts.titlebarBorder && (APPEARANCE_SHINY_GLASS!=(active ? opts.titlebarAppearance : opts.inactiveTitlebarAppearance)))
 
6444
                        {
 
6445
                            col=btnCols[0];
 
6446
                            //col.setAlphaF(0.5);
 
6447
                            painter->setPen(col);
 
6448
                            painter->drawLine(r.x()+2, r.y()+4, r.x()+2, r.y()+3);
 
6449
                            painter->drawLine(r.x()+3, r.y()+2, r.x()+4, r.y()+2);
 
6450
                            //painter->drawLine(r.x()+r.width()-3, r.y()+4, r.x()+r.width()-3, r.y()+3);
 
6451
                            painter->drawLine(r.x()+r.width()-4, r.y()+2, r.x()+r.width()-5, r.y()+2);
 
6452
                        }
6336
6453
                    }
6337
6454
                }
6338
6455
 
6342
6459
                    painter->drawLine(r.left()+1, r.bottom(), r.right()-1, r.bottom());
6343
6460
                }
6344
6461
 
 
6462
                bool    showIcon=TITLEBAR_ICON_NEXT_TO_TITLE==opts.titlebarIcon && !titleBar->icon.isNull();
 
6463
                int     iconSize=showIcon ? pixelMetric(QStyle::PM_SmallIconSize) : 0,
 
6464
                        iconX=r.x();
 
6465
                QPixmap pixmap;
 
6466
 
 
6467
                if(showIcon)
 
6468
                    pixmap=getIconPixmap(titleBar->icon, iconSize, titleBar->state);
 
6469
 
6345
6470
                if(!titleBar->text.isEmpty())
6346
6471
                {
 
6472
                    static const int constPad=4;
 
6473
 
6347
6474
                    QFont         font(painter->font());
6348
 
                    Qt::Alignment align((Qt::Alignment)pixelMetric((QStyle::PixelMetric)QtC_TitleAlignment, NULL, NULL));
6349
 
                    QRect         textRect(subControlRect(CC_TitleBar, titleBar, SC_TitleBarLabel, widget));
6350
 
                    QTextOption   textOpt(align|Qt::AlignVCenter);
6351
 
                    bool          alignRealCenter(Qt::AlignHCenter==align);
 
6475
                    Qt::Alignment alignment((Qt::Alignment)pixelMetric((QStyle::PixelMetric)QtC_TitleAlignment, 0L, 0L));
 
6476
                    bool          alignFull(Qt::AlignHCenter==alignment),
 
6477
                                  iconRight((!reverse && alignment&Qt::AlignRight) || (reverse && alignment&Qt::AlignLeft));
 
6478
                    QRect         captionRect(subControlRect(CC_TitleBar, titleBar, SC_TitleBarLabel, widget)),
 
6479
                                  textRect(alignFull
 
6480
                                            ? QRect(r.x(), captionRect.y(), r.width(), captionRect.height())
 
6481
                                            : captionRect);
6352
6482
 
6353
6483
                    font.setBold(true);
6354
6484
                    painter->setFont(font);
 
6485
 
 
6486
                    QFontMetrics fm(painter->fontMetrics());
 
6487
                    QString str(fm.elidedText(titleBar->text, Qt::ElideRight, textRect.width(), QPalette::WindowText));
 
6488
 
 
6489
                    int           textWidth=alignFull || (showIcon && alignment&Qt::AlignHCenter)
 
6490
                                                ? fm.boundingRect(str).width()+(showIcon ? iconSize+constPad : 0) : 0;
 
6491
 
 
6492
                    if(alignFull)
 
6493
                        if(captionRect.left()>((textRect.width()-textWidth)>>1))
 
6494
                        {
 
6495
                            alignment=Qt::AlignVCenter|Qt::AlignLeft;
 
6496
                            textRect=captionRect;
 
6497
                        }
 
6498
                        else if(captionRect.right()<((textRect.width()+textWidth)>>1))
 
6499
                        {
 
6500
                            alignment=Qt::AlignVCenter|Qt::AlignRight;
 
6501
                            textRect=captionRect;
 
6502
                        }
 
6503
 
 
6504
                    if(showIcon)
 
6505
                        if(alignment&Qt::AlignHCenter)
 
6506
                        {
 
6507
                            if(reverse)
 
6508
                            {
 
6509
                                iconX=((textRect.width()-textWidth)/2.0)+0.5+textWidth+iconSize;
 
6510
                                textRect.setX(textRect.x()-(iconSize+constPad));
 
6511
                            }
 
6512
                            else
 
6513
                            {
 
6514
                                iconX=((textRect.width()-textWidth)/2.0)+0.5;
 
6515
                                textRect.setX(iconX+iconSize+constPad);
 
6516
                                alignment=Qt::AlignVCenter|Qt::AlignLeft;
 
6517
                            }
 
6518
                        }
 
6519
                        else if((!reverse && alignment&Qt::AlignLeft) || (reverse && alignment&Qt::AlignRight))
 
6520
                        {
 
6521
                            iconX=textRect.x();
 
6522
                            textRect.setX(textRect.x()+(iconSize+constPad));
 
6523
                        }
 
6524
                        else if((!reverse && alignment&Qt::AlignRight) || (reverse && alignment&Qt::AlignLeft))
 
6525
                        {
 
6526
                            if(iconRight)
 
6527
                            {
 
6528
                                iconX=textRect.x()+textRect.width()-iconSize;
 
6529
                                textRect.setWidth(textRect.width()-(iconSize+constPad));
 
6530
                            }
 
6531
                            else
 
6532
                            {
 
6533
                                iconX=textRect.x()+textRect.width()-textWidth;
 
6534
                                if(iconX<textRect.x())
 
6535
                                    iconX=textRect.x();
 
6536
                            }
 
6537
                        }
 
6538
 
 
6539
                    QTextOption textOpt(alignment|Qt::AlignVCenter);
6355
6540
                    textOpt.setWrapMode(QTextOption::NoWrap);
6356
6541
 
6357
 
                    QString str(painter->fontMetrics().elidedText(titleBar->text, Qt::ElideRight, textRect.width(), QPalette::WindowText));
6358
 
 
6359
 
                    if(alignRealCenter)
6360
 
                    {
6361
 
                        painter->setClipRect(textRect);
6362
 
                        textRect=r;
6363
 
                    }
6364
6542
                    painter->setPen(shadow);
6365
6543
                    painter->drawText(textRect.adjusted(1, 1, 1, 1), str, textOpt);
6366
6544
                    painter->setPen(textColor);
6367
6545
                    painter->drawText(textRect, str, textOpt);
6368
 
                    if(alignRealCenter)
6369
 
                        painter->setClipping(false);
6370
 
                }
6371
 
 
6372
 
                // min button
6373
 
                if ((titleBar->subControls & SC_TitleBarMinButton) && (titleBar->titleBarFlags & Qt::WindowMinimizeButtonHint) &&
6374
 
                    !(titleBar->titleBarState& Qt::WindowMinimized))
6375
 
                {
6376
 
                    QRect rect(subControlRect(CC_TitleBar, titleBar, SC_TitleBarMinButton, widget));
6377
 
 
6378
 
                    if (rect.isValid())
6379
 
                    {
6380
 
                        bool sunken((titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_Sunken));
6381
 
 
6382
 
                        drawMdiButton(painter, rect,
6383
 
                                      (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_MouseOver),
6384
 
                                      sunken, btnCols);
6385
 
                        drawMdiIcon(painter, textColor, shadow, rect, sunken, buttonMargin, SC_TitleBarMinButton);
6386
 
                    }
6387
 
                }
6388
 
                // max button
6389
 
                if ((titleBar->subControls & SC_TitleBarMaxButton) && (titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint) &&
6390
 
                    !(titleBar->titleBarState & Qt::WindowMaximized))
6391
 
                {
6392
 
                    QRect rect(subControlRect(CC_TitleBar, titleBar, SC_TitleBarMaxButton, widget));
6393
 
 
6394
 
                    if (rect.isValid())
6395
 
                    {
6396
 
                        bool sunken((titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_Sunken));
6397
 
 
6398
 
                        drawMdiButton(painter, rect,
6399
 
                                      (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_MouseOver),
6400
 
                                      sunken, btnCols);
6401
 
                        drawMdiIcon(painter, textColor, shadow, rect, sunken, buttonMargin, SC_TitleBarMaxButton);
6402
 
                    }
6403
 
                }
6404
 
 
6405
 
                // close button
6406
 
                if ((titleBar->subControls & SC_TitleBarCloseButton) && (titleBar->titleBarFlags & Qt::WindowSystemMenuHint))
6407
 
                {
6408
 
                    QRect rect(subControlRect(CC_TitleBar, titleBar, SC_TitleBarCloseButton, widget));
6409
 
 
6410
 
                    if (rect.isValid())
6411
 
                    {
6412
 
 
6413
 
                        bool sunken((titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_Sunken)),
6414
 
                             hover((titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_MouseOver));
6415
 
 
6416
 
                        drawMdiButton(painter, rect, hover, sunken, btnCols);
6417
 
                        drawMdiIcon(painter, hover || sunken ? CLOSE_COLOR : textColor, shadow, rect, sunken, buttonMargin, SC_TitleBarCloseButton);
6418
 
                    }
6419
 
                }
6420
 
 
6421
 
                // normalize button
6422
 
                if ((titleBar->subControls & SC_TitleBarNormalButton) &&
6423
 
                    (((titleBar->titleBarFlags & Qt::WindowMinimizeButtonHint) &&
6424
 
                    (titleBar->titleBarState & Qt::WindowMinimized)) ||
6425
 
                    ((titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint) &&
6426
 
                    (titleBar->titleBarState & Qt::WindowMaximized))))
6427
 
                {
6428
 
                    QRect rect(subControlRect(CC_TitleBar, titleBar, SC_TitleBarNormalButton, widget));
6429
 
 
6430
 
                    if (rect.isValid())
6431
 
                    {
6432
 
                        bool sunken((titleBar->activeSubControls & SC_TitleBarNormalButton) && (titleBar->state & State_Sunken));
6433
 
 
6434
 
                        QRect normalButtonIconRect(rect.adjusted(buttonMargin, buttonMargin, -buttonMargin, -buttonMargin));
6435
 
                        drawMdiButton(painter, rect,
6436
 
                                      (titleBar->activeSubControls & SC_TitleBarNormalButton) && (titleBar->state & State_MouseOver),
6437
 
                                      sunken, btnCols);
6438
 
                        drawMdiIcon(painter, textColor, shadow, rect, sunken, buttonMargin, SC_TitleBarNormalButton);
6439
 
                    }
6440
 
                }
6441
 
 
6442
 
                // context help button
6443
 
                if (titleBar->subControls & SC_TitleBarContextHelpButton && (titleBar->titleBarFlags & Qt::WindowContextHelpButtonHint))
6444
 
                {
6445
 
                    QRect rect(subControlRect(CC_TitleBar, titleBar, SC_TitleBarContextHelpButton, widget));
6446
 
 
6447
 
                    if (rect.isValid())
6448
 
                    {
6449
 
                        bool sunken((titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_Sunken));
6450
 
 
6451
 
                        drawMdiButton(painter, rect,
6452
 
                                      (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_MouseOver),
6453
 
                                      sunken, btnCols);
6454
 
 
6455
 
                        QColor blend;
6456
 
                        QImage image(standardPixmap(SP_TitleBarContextHelpButton, option, widget).toImage());
6457
 
                        QColor alpha(textColor);
6458
 
 
6459
 
                        alpha.setAlpha(128);
6460
 
                        image.setColor(1, textColor.rgba());
6461
 
                        image.setColor(2, alpha.rgba());
6462
 
                        painter->setRenderHint(QPainter::SmoothPixmapTransform);
6463
 
                        painter->drawImage(rect.adjusted(4, 4, -4, -4), image);
6464
 
                    }
6465
 
                }
6466
 
 
6467
 
                // shade button
6468
 
                if (titleBar->subControls & SC_TitleBarShadeButton && (titleBar->titleBarFlags & Qt::WindowShadeButtonHint))
6469
 
                {
6470
 
                    QRect rect(subControlRect(CC_TitleBar, titleBar, SC_TitleBarShadeButton, widget));
6471
 
 
6472
 
                    if (rect.isValid())
6473
 
                    {
6474
 
                        bool sunken((titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_Sunken));
6475
 
 
6476
 
                        drawMdiButton(painter, rect,
6477
 
                                      (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_MouseOver),
6478
 
                                      sunken, btnCols);
6479
 
                        drawMdiIcon(painter, textColor, shadow, rect, sunken, buttonMargin, SC_TitleBarShadeButton);
6480
 
                    }
6481
 
                }
6482
 
 
6483
 
                // unshade button
6484
 
                if (titleBar->subControls & SC_TitleBarUnshadeButton && (titleBar->titleBarFlags & Qt::WindowShadeButtonHint))
6485
 
                {
6486
 
                    QRect rect(subControlRect(CC_TitleBar, titleBar, SC_TitleBarUnshadeButton, widget));
6487
 
 
6488
 
                    if (rect.isValid())
6489
 
                    {
6490
 
                        bool sunken((titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_Sunken));
6491
 
 
6492
 
                        drawMdiButton(painter, rect,
6493
 
                                      (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_MouseOver),
6494
 
                                      sunken, btnCols);
6495
 
                        drawMdiIcon(painter, textColor, shadow, rect, sunken, buttonMargin, SC_TitleBarUnshadeButton);
6496
 
                    }
6497
 
                }
6498
 
 
6499
 
                if ((titleBar->subControls & SC_TitleBarSysMenu) && (titleBar->titleBarFlags & Qt::WindowSystemMenuHint))
6500
 
                {
6501
 
                    QRect rect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarSysMenu, widget);
6502
 
                    if (rect.isValid())
6503
 
                    {
6504
 
                        drawMdiButton(painter, rect,
6505
 
                                      (titleBar->activeSubControls & SC_TitleBarSysMenu) && (titleBar->state & State_MouseOver),
6506
 
                                      (titleBar->activeSubControls & SC_TitleBarSysMenu) && (titleBar->state & State_Sunken), btnCols);
6507
 
 
6508
 
                        if (!titleBar->icon.isNull())
6509
 
                            titleBar->icon.paint(painter, rect);
6510
 
                        else
 
6546
                }
 
6547
 
 
6548
                if(showIcon && iconX>=0)
 
6549
                    painter->drawPixmap(iconX, r.y()+((r.height()-iconSize)/2)+1, pixmap);
 
6550
 
 
6551
                if ((titleBar->subControls&SC_TitleBarMinButton) && (titleBar->titleBarFlags&Qt::WindowMinimizeButtonHint) &&
 
6552
                    !(titleBar->titleBarState&Qt::WindowMinimized))
 
6553
                    drawMdiControl(painter, titleBar, SC_TitleBarMinButton, widget, TITLEBAR_MIN, textColor, shadow, btnCols, bgndCols);
 
6554
 
 
6555
                if ((titleBar->subControls&SC_TitleBarMaxButton) && (titleBar->titleBarFlags&Qt::WindowMaximizeButtonHint) &&
 
6556
                    !(titleBar->titleBarState&Qt::WindowMaximized))
 
6557
                    drawMdiControl(painter, titleBar, SC_TitleBarMaxButton, widget, TITLEBAR_MAX, textColor, shadow, btnCols, bgndCols);
 
6558
 
 
6559
                if ((titleBar->subControls&SC_TitleBarCloseButton) && (titleBar->titleBarFlags&Qt::WindowSystemMenuHint))
 
6560
                    drawMdiControl(painter, titleBar, SC_TitleBarCloseButton, widget, TITLEBAR_CLOSE, textColor, shadow, btnCols, bgndCols);
 
6561
 
 
6562
                if ((titleBar->subControls&SC_TitleBarNormalButton) &&
 
6563
                    (((titleBar->titleBarFlags&Qt::WindowMinimizeButtonHint) &&
 
6564
                    (titleBar->titleBarState&Qt::WindowMinimized)) ||
 
6565
                    ((titleBar->titleBarFlags&Qt::WindowMaximizeButtonHint) &&
 
6566
                    (titleBar->titleBarState&Qt::WindowMaximized))))
 
6567
                    drawMdiControl(painter, titleBar, SC_TitleBarNormalButton, widget, TITLEBAR_MAX, textColor, shadow, btnCols, bgndCols);
 
6568
 
 
6569
                if (titleBar->subControls&SC_TitleBarContextHelpButton && (titleBar->titleBarFlags&Qt::WindowContextHelpButtonHint))
 
6570
                    drawMdiControl(painter, titleBar, SC_TitleBarContextHelpButton, widget, TITLEBAR_HELP, textColor, shadow, btnCols, bgndCols);
 
6571
 
 
6572
                if (titleBar->subControls&SC_TitleBarShadeButton && (titleBar->titleBarFlags&Qt::WindowShadeButtonHint))
 
6573
                    drawMdiControl(painter, titleBar, SC_TitleBarShadeButton, widget, TITLEBAR_SHADE, textColor, shadow, btnCols, bgndCols);
 
6574
 
 
6575
                if (titleBar->subControls&SC_TitleBarUnshadeButton && (titleBar->titleBarFlags&Qt::WindowShadeButtonHint))
 
6576
                    drawMdiControl(painter, titleBar, SC_TitleBarUnshadeButton, widget, TITLEBAR_SHADE, textColor, shadow, btnCols, bgndCols);
 
6577
  
 
6578
                if ((titleBar->subControls&SC_TitleBarSysMenu) && (titleBar->titleBarFlags&Qt::WindowSystemMenuHint))
 
6579
                    if(TITLEBAR_ICON_MENU_BUTTON==opts.titlebarIcon)
 
6580
                    {
 
6581
                        QRect rect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarSysMenu, widget);
 
6582
                        if (rect.isValid())
6511
6583
                        {
6512
 
                            QStyleOption tool(0);
6513
 
 
6514
 
                            tool.palette = palette;
6515
 
                            tool.rect = rect;
6516
 
                            painter->save();
6517
 
                            drawItemPixmap(painter, rect, Qt::AlignCenter, standardIcon(SP_TitleBarMenuButton, &tool, widget).pixmap(16, 16));
6518
 
                            painter->restore();
 
6584
                            bool sunken((titleBar->activeSubControls&SC_TitleBarSysMenu) && (titleBar->state&State_Sunken)),
 
6585
                                 hover((titleBar->activeSubControls&SC_TitleBarSysMenu) && (titleBar->state&State_MouseOver));
 
6586
                            int  offset(sunken ? 1 : 0);
 
6587
 
 
6588
                            if(!(opts.titlebarButtons&QTC_TITLEBAR_BUTTON_ROUND))
 
6589
                                drawMdiButton(painter, rect, hover, sunken,
 
6590
                                            coloredMdiButtons(state&State_Active, hover) ? itsTitleBarButtonsCols[TITLEBAR_MENU] : btnCols);
 
6591
 
 
6592
                            if (!titleBar->icon.isNull())
 
6593
                                titleBar->icon.paint(painter, rect.adjusted(offset, offset, offset, offset));
 
6594
                            else
 
6595
                            {
 
6596
                                QStyleOption tool(0);
 
6597
 
 
6598
                                tool.palette = palette;
 
6599
                                tool.rect = rect;
 
6600
                                painter->save();
 
6601
                                drawItemPixmap(painter, rect.adjusted(offset, offset, offset, offset), Qt::AlignCenter, standardIcon(SP_TitleBarMenuButton, &tool, widget).pixmap(16, 16));
 
6602
                                painter->restore();
 
6603
                            }
6519
6604
                        }
6520
6605
                    }
6521
 
                }
 
6606
                    else
 
6607
                        drawMdiControl(painter, titleBar, SC_TitleBarSysMenu, widget, TITLEBAR_MENU, textColor, shadow, btnCols, bgndCols);
6522
6608
                painter->restore();
6523
6609
            }
6524
6610
            break;
6581
6667
 
6582
6668
                painter->save();
6583
6669
 
6584
 
                if(!widget || !widget->testAttribute(Qt::WA_NoSystemBackground))
6585
 
                    painter->fillRect(r, palette.brush(QPalette::Background));
 
6670
                if(opts.flatSbarButtons && !IS_FLAT(opts.sbarBgndAppearance) && SCROLLBAR_NONE!=opts.scrollbarType)
 
6671
                    drawBevelGradientReal(palette.brush(QPalette::Background).color(), painter, r, horiz, false,
 
6672
                                          opts.sbarBgndAppearance, WIDGET_SB_BGND);
 
6673
                else
 
6674
                {
 
6675
                    if(!widget || !widget->testAttribute(Qt::WA_NoSystemBackground))
 
6676
                        painter->fillRect(r, palette.brush(QPalette::Background));
6586
6677
 
6587
 
                if(opts.flatSbarButtons && APP_KRUNNER==theThemedApp)
6588
 
                    painter->fillRect(r, itsBackgroundCols[ORIGINAL_SHADE]);
 
6678
                    if(opts.flatSbarButtons && APP_KRUNNER==theThemedApp)
 
6679
                        painter->fillRect(r, itsBackgroundCols[ORIGINAL_SHADE]);
 
6680
                }
6589
6681
 
6590
6682
                if(noButtons || opts.flatSbarButtons)
6591
6683
                {
6594
6686
                    opt.state=scrollbar->state;
6595
6687
                    opt.state&=~(State_MouseOver|State_Sunken|State_On);
6596
6688
 
6597
 
                    drawLightBevel(painter, opt.rect, &opt, widget,
 
6689
                    if(opts.thinSbarGroove && slider.isValid())
 
6690
                    {
 
6691
                        painter->save();
 
6692
                        painter->setClipRegion(QRegion(opt.rect).subtract(slider));
 
6693
                    }
 
6694
                    drawLightBevel(painter, opts.thinSbarGroove
 
6695
                                                ? horiz
 
6696
                                                    ? opt.rect.adjusted(0, QTC_THIN_SBAR_MOD, 0, -QTC_THIN_SBAR_MOD)
 
6697
                                                    : opt.rect.adjusted(QTC_THIN_SBAR_MOD, 0, -QTC_THIN_SBAR_MOD, 0)
 
6698
                                                : opt.rect, &opt, widget,
6598
6699
    #ifndef QTC_SIMPLE_SCROLLBARS
6599
6700
                                   SCROLLBAR_NONE==opts.scrollbarType || opts.flatSbarButtons ? ROUNDED_ALL :
6600
6701
    #endif
6601
6702
                                   ROUNDED_NONE,
6602
 
                                   itsBackgroundCols[2], itsBackgroundCols, true, WIDGET_TROUGH);
 
6703
                                   itsBackgroundCols[2], itsBackgroundCols, true,
 
6704
                                   opts.thinSbarGroove ? WIDGET_SLIDER_TROUGH : WIDGET_TROUGH);
 
6705
                    if(opts.thinSbarGroove && slider.isValid())
 
6706
                        painter->restore();
6603
6707
                }
6604
6708
                else
6605
6709
                {
6628
6732
                    opt.state=scrollbar->state;
6629
6733
                    if(maxed)
6630
6734
                        opt.state&=~State_Enabled;
6631
 
                    if (!(scrollbar->activeSubControls & SC_ScrollBarSubLine) ||
 
6735
                    if (!(scrollbar->activeSubControls&SC_ScrollBarSubLine) ||
6632
6736
                        (useThreeButtonScrollBar && itsSbWidget && itsSbWidget==widget))
6633
6737
                        opt.state &= ~(State_Sunken | State_MouseOver);
6634
6738
 
6640
6744
                        opt.state=scrollbar->state;
6641
6745
                        if(maxed)
6642
6746
                            opt.state&=~State_Enabled;
6643
 
                        if ((!(scrollbar->activeSubControls & SC_ScrollBarSubLine)) || (itsSbWidget && itsSbWidget!=widget))
 
6747
                        if ((!(scrollbar->activeSubControls&SC_ScrollBarSubLine)) || (itsSbWidget && itsSbWidget!=widget))
6644
6748
                            opt.state &= ~(State_Sunken | State_MouseOver);
6645
6749
 
6646
6750
                        drawControl(CE_ScrollBarSubLine, &opt, painter, widget);
6653
6757
                    opt.state=scrollbar->state;
6654
6758
                    if(maxed)
6655
6759
                        opt.state&=~State_Enabled;
6656
 
                    if (!(scrollbar->activeSubControls & SC_ScrollBarAddLine))
 
6760
                    if (!(scrollbar->activeSubControls&SC_ScrollBarAddLine))
6657
6761
                        opt.state &= ~(State_Sunken | State_MouseOver);
6658
6762
                    drawControl(CE_ScrollBarAddLine, &opt, painter, widget);
6659
6763
                }
6662
6766
                {
6663
6767
                    opt.rect=first;
6664
6768
                    opt.state=scrollbar->state;
6665
 
                    if (!(scrollbar->activeSubControls & SC_ScrollBarFirst))
 
6769
                    if (!(scrollbar->activeSubControls&SC_ScrollBarFirst))
6666
6770
                        opt.state &= ~(State_Sunken | State_MouseOver);
6667
6771
                    drawControl(CE_ScrollBarFirst, &opt, painter, widget);
6668
6772
                }
6671
6775
                {
6672
6776
                    opt.rect=last;
6673
6777
                    opt.state=scrollbar->state;
6674
 
                    if (!(scrollbar->activeSubControls & SC_ScrollBarLast))
 
6778
                    if (!(scrollbar->activeSubControls&SC_ScrollBarLast))
6675
6779
                        opt.state &= ~(State_Sunken | State_MouseOver);
6676
6780
                    drawControl(CE_ScrollBarLast, &opt, painter, widget);
6677
6781
                }
6681
6785
                    // If "SC_ScrollBarSlider" wasn't specified, then we only want to draw the portion
6682
6786
                    // of the slider that overlaps with the trough. So, once again set the clipping
6683
6787
                    // region...
6684
 
                    if(!(option->subControls&SC_ScrollBarSlider))
6685
 
                        painter->setClipRegion(QRegion(s2)+QRegion(a2));
 
6788
 
 
6789
                    // NO! Seeems to mess things up with Arora, su just dsiable all clipping when drawing
 
6790
                    // the slider...
 
6791
                    painter->setClipping(false);
 
6792
//                     if(!(option->subControls&SC_ScrollBarSlider))
 
6793
//                         painter->setClipRegion(QRegion(s2)+QRegion(a2));
6686
6794
#ifdef QTC_INCREASE_SB_SLIDER
6687
 
                    else if(!opts.flatSbarButtons)
 
6795
                    /*else*/ if(!opts.flatSbarButtons)
6688
6796
                    {
6689
6797
                        if(atMax)
6690
6798
                            switch(opts.scrollbarType)
6716
6824
#endif
6717
6825
                    opt.rect=slider;
6718
6826
                    opt.state=scrollbar->state;
6719
 
                    if (!(scrollbar->activeSubControls & SC_ScrollBarSlider))
 
6827
                    if (!(scrollbar->activeSubControls&SC_ScrollBarSlider))
6720
6828
                        opt.state &= ~(State_Sunken | State_MouseOver);
6721
6829
                    drawControl(CE_ScrollBarSlider, &opt, painter, widget);
6722
6830
 
6728
6836
                        drawPrimitive(PE_FrameFocusRect, &opt, painter, widget);
6729
6837
                    }
6730
6838
 
6731
 
                    if(!(option->subControls&SC_ScrollBarSlider))
6732
 
                        painter->setClipping(false);
 
6839
//                     if(!(option->subControls&SC_ScrollBarSlider))
 
6840
//                         painter->setClipping(false);
6733
6841
                }
6734
6842
                painter->restore();
6735
6843
            }
6766
6874
 
6767
6875
                if(/*comboBox->frame &&*/ frame.isValid())
6768
6876
                {
 
6877
                    const QColor *cols=itsComboBtnCols && comboBox->editable && state&State_Enabled ? itsComboBtnCols : use;
 
6878
 
6769
6879
                    QStyleOption frameOpt(*option);
6770
6880
 
6771
 
                    if (comboBox->editable && !(comboBox->activeSubControls & SC_ComboBoxArrow))
 
6881
                    if (comboBox->editable && !(comboBox->activeSubControls&SC_ComboBoxArrow))
6772
6882
                        frameOpt.state &= ~(State_Sunken | State_MouseOver);
6773
6883
 
6774
6884
                    if(!sunken)
6779
6889
 
6780
6890
                    drawLightBevel(painter, frame, &frameOpt, widget,
6781
6891
                                   comboBox->editable ? (reverse ? ROUNDED_LEFT : ROUNDED_RIGHT) : ROUNDED_ALL,
6782
 
                                   getFill(&frameOpt, use), use, true,
6783
 
                                   comboBox->editable ? WIDGET_COMBO_BUTTON : WIDGET_COMBO);
 
6892
                                   getFill(&frameOpt, cols, false,
 
6893
                                           (SHADE_DARKEN==opts.comboBtn || (SHADE_NONE!=opts.comboBtn &&
 
6894
                                                                            !(state&State_Enabled))) &&
 
6895
                                           comboBox->editable),
 
6896
                                   cols, true, comboBox->editable ? WIDGET_COMBO_BUTTON : WIDGET_COMBO);
6784
6897
                }
6785
6898
 
6786
6899
                if(/*controls&SC_ComboBoxArrow && */arrow.isValid())
6787
6900
                {
 
6901
                    bool mouseOver=comboBox->editable && !(comboBox->activeSubControls&SC_ComboBoxArrow)
 
6902
                                    ? false : (state&State_MouseOver ? true : false);
 
6903
 
 
6904
                    if(!comboBox->editable && (SHADE_DARKEN==opts.comboBtn || itsComboBtnCols))
 
6905
                    {
 
6906
                        QStyleOption frameOpt(*option);
 
6907
                        QRect        btn(arrow.x(), frame.y(), arrow.width()+2, frame.height());
 
6908
                        const QColor *cols=SHADE_DARKEN==opts.comboBtn || !(state&State_Enabled) ? use : itsComboBtnCols;
 
6909
                        if(!sunken)
 
6910
                            frameOpt.state|=State_Raised;
 
6911
                        painter->save();
 
6912
                        painter->setClipRect(btn);
 
6913
                        drawLightBevel(painter, opts.comboSplitter
 
6914
                                                    ? btn
 
6915
                                                    : btn.adjusted(reverse ? 0 : -2, 0, reverse ? 2 : 0, 0),
 
6916
                                       &frameOpt, widget, reverse ? ROUNDED_LEFT : ROUNDED_RIGHT,
 
6917
                                       getFill(&frameOpt, cols, false,
 
6918
                                               SHADE_DARKEN==opts.comboBtn || (SHADE_NONE!=opts.comboBtn &&
 
6919
                                                                               !(state&State_Enabled))),
 
6920
                                       cols, true, WIDGET_COMBO);
 
6921
                        painter->restore();
 
6922
                    }
 
6923
                    
6788
6924
                    if(sunken)
6789
6925
                        arrow.adjust(1, 1, 1, 1);
6790
6926
 
6791
6927
                    //if(comboBox->editable || !opts.gtkComboMenus)
6792
 
                        drawArrow(painter, arrow, PE_IndicatorArrowDown, option->palette.buttonText().color());
 
6928
                        drawArrow(painter, arrow, PE_IndicatorArrowDown, QTC_MO_ARROW_X(mouseOver, option->palette.buttonText().color()),
 
6929
                                  false, false);
6793
6930
//                     else
6794
6931
//                     {
6795
6932
//                         int middle=arrow.y()+(arrow.height()>>1);
6814
6951
                        field.adjust(-(2+pad),-2, (2+pad), 2);
6815
6952
                        drawEntryField(painter, field, widget, option, reverse ? ROUNDED_RIGHT : ROUNDED_LEFT, true, false);
6816
6953
                    }
6817
 
                    else if(opts.comboSplitter)
 
6954
                    else if(opts.comboSplitter && !(SHADE_DARKEN==opts.comboBtn || itsComboBtnCols))
6818
6955
                    {
6819
6956
                        drawFadedLine(painter, QRect(reverse ? arrow.right()+1 : arrow.x()-1, arrow.top()+2,
6820
6957
                                                     1, arrow.height()-4),
6870
7007
        if(button && isMultiTabBarTab(button) && button->isChecked())
6871
7008
            textRole=QPalette::HighlightedText;
6872
7009
    }
6873
 
 
6874
7010
    QTC_BASE_STYLE::drawItemText(painter, rect, flags, pal, enabled, text, textRole);
6875
7011
}
6876
7012
 
6933
7069
            break;
6934
7070
        case CT_ToolButton:
6935
7071
        {
6936
 
            newSize = QSize(size.width()+9, size.height()+9);
 
7072
            newSize = QSize(size.width()+8, size.height()+8);
6937
7073
            // -- from kstyle & oxygen --
6938
7074
            // We want to avoid super-skiny buttons, for things like "up" when icons + text
6939
7075
            // For this, we would like to make width >= height.
6945
7081
 
6946
7082
            if (const QStyleOptionToolButton* tbOpt = qstyleoption_cast<const QStyleOptionToolButton*>(option))
6947
7083
            {
6948
 
                if ((!tbOpt->icon.isNull()) && (!tbOpt->text.isEmpty()) && Qt::ToolButtonTextUnderIcon==tbOpt->toolButtonStyle)
 
7084
                if (!tbOpt->icon.isNull() && !tbOpt->text.isEmpty() && Qt::ToolButtonTextUnderIcon==tbOpt->toolButtonStyle)
6949
7085
                    newSize.setHeight(newSize.height()-4);
6950
7086
 
6951
7087
                if (tbOpt->features & QStyleOptionToolButton::MenuButtonPopup)
6952
7088
                    menuAreaWidth = pixelMetric(QStyle::PM_MenuButtonIndicator, option, widget);
6953
7089
                else if (tbOpt->features & QStyleOptionToolButton::HasMenu)
6954
 
                    newSize.setWidth(newSize.width()+6);
 
7090
                    switch(tbOpt->toolButtonStyle)
 
7091
                    {
 
7092
                        case Qt::ToolButtonIconOnly:
 
7093
                            newSize.setWidth(newSize.width()+LARGE_ARR_WIDTH+2);
 
7094
                            break;
 
7095
                        case Qt::ToolButtonTextBesideIcon:
 
7096
                            newSize.setWidth(newSize.width()+3);
 
7097
                            break;
 
7098
                        case Qt::ToolButtonTextOnly:
 
7099
                            newSize.setWidth(newSize.width()+8);
 
7100
                            break;
 
7101
                        case Qt::ToolButtonTextUnderIcon:
 
7102
                            newSize.setWidth(newSize.width()+8);
 
7103
                            break;
 
7104
                    }
6955
7105
            }
6956
7106
 
6957
7107
            newSize.setWidth(newSize.width() - menuAreaWidth);
6979
7129
                int h(newSize.height()-8); // Fix mainly for Qt4.4
6980
7130
 
6981
7131
                if (QStyleOptionMenuItem::Separator==mi->menuItemType)
6982
 
                    h =/* mi->text.isEmpty() ? */(opts.thinnerMenuItems ? 6 : 8)/* : mi->fontMetrics.lineSpacing()*/;
 
7132
                    h = 7;
6983
7133
                else
6984
7134
                {
6985
7135
                    h = qMax(h, mi->fontMetrics.height());
7629
7779
            else
7630
7780
                r.setRect(r.left()+windowMargin+pos, r.top()+windowMargin,
7631
7781
                          controlSize, controlSize);
 
7782
            if(0==(r.height()%2))
 
7783
                r.adjust(0, 0, 1, 1);
7632
7784
            return visualRect(tb->direction, tb->rect, r);
7633
7785
        }
7634
7786
        default:
7641
7793
QStyle::SubControl QtCurveStyle::hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option,
7642
7794
                                                       const QPoint &pos, const QWidget *widget) const
7643
7795
{
7644
 
    itsSbWidget=NULL;
 
7796
    itsSbWidget=0L;
7645
7797
    switch (control)
7646
7798
    {
7647
7799
        case CC_ScrollBar:
7673
7825
    return QTC_BASE_STYLE::hitTestComplexControl(control, option,  pos, widget);
7674
7826
}
7675
7827
 
 
7828
void QtCurveStyle::drawHighlight(QPainter *p, const QRect &r, bool horiz, bool inc) const
 
7829
{
 
7830
    QColor col1(itsMouseOverCols[ORIGINAL_SHADE]);
 
7831
 
 
7832
    col1.setAlphaF(0.5);
 
7833
    drawFadedLine(p, r, inc ? col1 : itsMouseOverCols[ORIGINAL_SHADE], true, true, horiz);
 
7834
    drawFadedLine(p, r.adjusted(horiz ? 0 : 1, horiz ? 1 : 0, 0, 0), inc ? itsMouseOverCols[ORIGINAL_SHADE] : col1, true, true, horiz);
 
7835
}
 
7836
 
7676
7837
void QtCurveStyle::drawFadedLine(QPainter *p, const QRect &r, const QColor &col, bool fadeStart, bool fadeEnd, bool horiz) const
7677
7838
{
7678
7839
    bool            aa(p->testRenderHint(QPainter::Antialiasing));
7779
7940
 
7780
7941
void QtCurveStyle::drawProgressBevelGradient(QPainter *p, const QRect &origRect, const QStyleOption *option, bool horiz, EAppearance bevApp) const
7781
7942
{
7782
 
    const QColor *use=option->state&State_Enabled || ECOLOR_BACKGROUND==opts.progressGrooveColor ? itsMenuitemCols : itsBackgroundCols;
 
7943
    const QColor *use=option->state&State_Enabled || ECOLOR_BACKGROUND==opts.progressGrooveColor ? itsHighlightCols : itsBackgroundCols;
7783
7944
    bool    vertical(!horiz),
7784
7945
            inCache(true);
7785
7946
    QRect   r(0, 0, horiz ? PROGRESS_CHUNK_WIDTH*2 : origRect.width(),
7882
8043
void QtCurveStyle::drawBevelGradient(const QColor &base, QPainter *p, const QRect &origRect,
7883
8044
                                     bool horiz, bool sel, EAppearance bevApp, EWidget w) const
7884
8045
{
 
8046
    if(origRect.width()<1 || origRect.height()<1)
 
8047
        return;
 
8048
 
7885
8049
    if(IS_FLAT(bevApp))
7886
8050
        p->fillRect(origRect, base);
7887
8051
    else
7935
8099
                                         bool horiz, bool sel, EAppearance app, EWidget w) const
7936
8100
{
7937
8101
    bool                             topTab(WIDGET_TAB_TOP==w),
7938
 
                                     botTab(WIDGET_TAB_BOT==w),
7939
 
                                     colorTab(sel && opts.colorSelTab && (topTab || botTab));
 
8102
                                     botTab(WIDGET_TAB_BOT==w);
7940
8103
    const Gradient                   *grad=getGradient(app, &opts);
7941
8104
    QLinearGradient                  g(r.topLeft(), horiz ? r.bottomLeft() : r.topRight());
7942
8105
    GradientStopCont::const_iterator it(grad->stops.begin()),
7951
8114
            col=base;
7952
8115
        else
7953
8116
            shade(base, &col, botTab ? qMax(INVERT_SHADE((*it).val), 0.9) : (*it).val);
7954
 
        if(colorTab && i<numStops-1)
7955
 
            col=tint(col, itsMenuitemCols[0], (1.0-(*it).pos)*QTC_COLOR_SEL_TAB_FACTOR);
7956
8117
        g.setColorAt(botTab ? 1.0-(*it).pos : (*it).pos, col);
7957
8118
    }
7958
8119
    //p->fillRect(r, base);
7971
8132
    QRect        r(rOrig);
7972
8133
    bool         bevelledButton((WIDGET_BUTTON(w) || WIDGET_NO_ETCH_BTN==w || WIDGET_MENU_BUTTON==w) && APPEARANCE_BEVELLED==app),
7973
8134
                 sunken(option->state &(/*State_Down | */State_On | State_Sunken)),
7974
 
                 lightBorder(WIDGET_MDI_WINDOW!=w && WIDGET_MDI_WINDOW_TITLE!=w && QTC_DRAW_LIGHT_BORDER(sunken, w, app)),
7975
 
                 draw3d(!lightBorder && WIDGET_MDI_WINDOW!=w && WIDGET_MDI_WINDOW_TITLE!=w &&
7976
 
                        QTC_DRAW_3D_BORDER(sunken, app)),
 
8135
                 flatMdi(WIDGET_MDI_WINDOW_BUTTON==w &&
 
8136
                         (opts.round==ROUND_MAX || opts.titlebarButtons&QTC_TITLEBAR_BUTTON_ROUND)),
 
8137
                 lightBorder(!flatMdi && WIDGET_MDI_WINDOW!=w && WIDGET_MDI_WINDOW_TITLE!=w && QTC_DRAW_LIGHT_BORDER(sunken, w, app)),
 
8138
                 draw3dfull(!flatMdi && !lightBorder && WIDGET_MDI_WINDOW!=w && WIDGET_MDI_WINDOW_TITLE!=w &&
 
8139
                        QTC_DRAW_3D_FULL_BORDER(sunken, app)),
 
8140
                 draw3d(!flatMdi && (draw3dfull || (
 
8141
                            !lightBorder && WIDGET_MDI_WINDOW!=w && WIDGET_MDI_WINDOW_TITLE!=w &&
 
8142
                            QTC_DRAW_3D_BORDER(sunken, app)))),
7977
8143
                 doColouredMouseOver(!sunken && doBorder && option->state&State_Enabled &&
7978
8144
                                     WIDGET_MDI_WINDOW_BUTTON!=w &&
 
8145
                                     (WIDGET_SPIN!=w || !opts.unifySpinBtns) &&
7979
8146
                                     !(option->state&QTC_STATE_KWIN_BUTTON) &&
7980
8147
#ifdef QTC_DONT_COLOUR_MOUSEOVER_TBAR_BUTTONS
7981
8148
                                     !(option->state&QTC_STATE_TBAR_BUTTON) &&
7986
8153
                 plastikMouseOver(doColouredMouseOver && MO_PLASTIK==opts.coloredMouseOver),
7987
8154
                 colouredMouseOver(doColouredMouseOver && WIDGET_MENU_BUTTON!=w &&
7988
8155
                                       (MO_COLORED==opts.coloredMouseOver ||
7989
 
                                              (MO_GLOW==opts.coloredMouseOver &&
7990
 
                                              ((WIDGET_COMBO!=w && !ETCH_WIDGET(w) && WIDGET_SB_SLIDER!=w) || !QTC_DO_EFFECT)))),
 
8156
                                        MO_COLORED_THICK==opts.coloredMouseOver ||
 
8157
                                              (MO_GLOW==opts.coloredMouseOver && !QTC_DO_EFFECT))),
7991
8158
                 doEtch(doBorder && ETCH_WIDGET(w) && QTC_DO_EFFECT),
7992
8159
                 horiz(isHoriz(option, w));
7993
 
    int          dark(bevelledButton ? 2 : 4),
7994
 
                 c1(sunken ? dark : 0);
7995
8160
    const QColor *cols(custom ? custom : itsBackgroundCols),
7996
8161
                 *border(colouredMouseOver ? borderColors(option, cols) : cols);
7997
8162
 
8000
8165
    if(doEtch)
8001
8166
        r.adjust(1, 1, -1, -1);
8002
8167
 
 
8168
    p->setRenderHint(QPainter::Antialiasing, true);
 
8169
 
8003
8170
    if(r.width()>0 && r.height()>0)
8004
8171
    {
8005
 
        double radius=getRadius(opts.round, r.width(), r.height(), w, RADIUS_INTERNAL);
8006
 
        p->setClipPath(buildPath(r.adjusted(0, 0, radius>QTC_EXTRA_ETCH_RADIUS ? -1 : 0,
8007
 
                                            radius>QTC_EXTRA_ETCH_RADIUS ? -1 : 0), w, round, radius), Qt::IntersectClip);
 
8172
        double radius=getRadius(&opts, r.width(), r.height(), w, RADIUS_INTERNAL),
 
8173
               modW=radius>QTC_EXTRA_ETCH_RADIUS && WIDGET_MDI_WINDOW_BUTTON!=w ? -0.75 : 0,
 
8174
               modH=radius>QTC_EXTRA_ETCH_RADIUS ? -0.75 : 0;
 
8175
 
 
8176
        p->save();
 
8177
        p->setClipPath(buildPath(r, w, round, radius, modW, modH), Qt::IntersectClip);
8008
8178
 
8009
8179
        if(WIDGET_PROGRESSBAR==w && STRIPE_NONE!=opts.stripedProgress)
8010
8180
            drawProgressBevelGradient(p, r.adjusted(1, 1, -1, -1), option, horiz, app);
8011
8181
        else
8012
8182
        {
8013
 
            drawBevelGradient(fill, p, r.adjusted(1, 1, -1, WIDGET_MDI_WINDOW_TITLE==w ? 0 : -1), horiz,
8014
 
                              sunken, app, w);
 
8183
            drawBevelGradient(fill, p, r.adjusted(1, 1, -1,  WIDGET_MDI_WINDOW_TITLE==w ? 0 : -1),
 
8184
                              horiz, sunken, app, w);
8015
8185
 
8016
8186
            if(!sunken)
8017
8187
                if(plastikMouseOver && !sunken)
8044
8214
                             thin(WIDGET_SB_BUTTON==w || WIDGET_SPIN==w || ((horiz ? r.height() : r.width())<16));
8045
8215
 
8046
8216
                        p->setPen(itsMouseOverCols[QTC_MO_PLASTIK_DARK(w)]);
8047
 
                        p->setRenderHint(QPainter::Antialiasing, true);
8048
8217
                        if(horizontal)
8049
8218
                        {
8050
8219
                            drawAaLine(p, r.x()+1, r.y()+1, r.x()+r.width()-2, r.y()+1);
8069
8238
                                drawAaLine(p, r.x()+r.width()-3, r.y()+1, r.x()+r.width()-3, r.y()+r.height()-2);
8070
8239
                            }
8071
8240
                        }
8072
 
                        p->setRenderHint(QPainter::Antialiasing, false);
8073
8241
                    }
8074
8242
                }
8075
8243
        }
8076
 
        p->setClipping(false);
 
8244
        p->restore();
8077
8245
    }
8078
8246
 
8079
 
    p->setRenderHint(QPainter::Antialiasing, true);
8080
8247
    r.adjust(1, 1, -1, -1);
8081
8248
 
8082
8249
    if(plastikMouseOver && !sunken)
8085
8252
                horizontal(WIDGET_SB_SLIDER==w ? !horiz : (horiz && WIDGET_SB_BUTTON!=w)|| (!horiz && WIDGET_SB_BUTTON==w));
8086
8253
        int  len(WIDGET_SB_SLIDER==w ? QTC_SB_SLIDER_MO_LEN(horiz ? r.width() : r.height()) : (thin ? 1 : 2));
8087
8254
 
 
8255
        p->save();
8088
8256
        if(horizontal)
8089
8257
            p->setClipRect(r.x(), r.y()+len, r.width(), r.height()-(len*2));
8090
8258
        else
8094
8262
    if(!colouredMouseOver && lightBorder)
8095
8263
    {
8096
8264
        p->setPen(cols[APPEARANCE_DULL_GLASS==app ? 1 : 0]);
8097
 
        p->drawPath(buildPath(r, w, round, getRadius(opts.round, r.width(), r.height(), w, RADIUS_INTERNAL)));
 
8265
        p->drawPath(buildPath(r, w, round, getRadius(&opts, r.width(), r.height(), w, RADIUS_INTERNAL)));
8098
8266
    }
8099
 
    else if(colouredMouseOver || WIDGET_MDI_WINDOW==w || WIDGET_MDI_WINDOW_TITLE==w ||
 
8267
    else if(colouredMouseOver || (opts.titlebarBorder && (WIDGET_MDI_WINDOW==w || WIDGET_MDI_WINDOW_TITLE==w)) ||
8100
8268
            (draw3d && option->state&State_Raised))
8101
8269
    {
8102
8270
        QPainterPath innerTlPath,
8103
8271
                     innerBrPath;
 
8272
        int          dark(/*bevelledButton ? */2/* : 4*/);
8104
8273
 
8105
8274
        buildSplitPath(r, w, round,
8106
 
                       getRadius(opts.round, r.width(), r.height(), w, RADIUS_INTERNAL),
 
8275
                       getRadius(&opts, r.width(), r.height(), w, RADIUS_INTERNAL),
8107
8276
                       innerTlPath, innerBrPath);
8108
8277
 
8109
 
        p->setPen(border[colouredMouseOver ? QTC_MO_STD_LIGHT(w, sunken) : c1]);
8110
 
        if(colouredMouseOver || bevelledButton || APPEARANCE_RAISED==app)
 
8278
        p->setPen(border[colouredMouseOver ? QTC_MO_STD_LIGHT(w, sunken) : (sunken ? dark : 0)]);
 
8279
        if(colouredMouseOver || bevelledButton || draw3dfull)
8111
8280
        {
8112
8281
            p->drawPath(innerTlPath);
8113
8282
            p->setPen(border[colouredMouseOver ? QTC_MO_STD_DARK(w) : (sunken ? 0 : dark)]);
8122
8291
        }
8123
8292
    }
8124
8293
    if(plastikMouseOver && !sunken)
8125
 
        p->setClipping(false);
 
8294
        p->restore();
8126
8295
    p->setRenderHint(QPainter::Antialiasing, false);
8127
8296
 
8128
8297
    if(doEtch)
8137
8306
    
8138
8307
    if(doBorder)
8139
8308
    {
 
8309
        const QColor *borderCols=(WIDGET_COMBO==w || WIDGET_COMBO_BUTTON==w) && border==itsComboBtnCols
 
8310
                            ? option->state&State_MouseOver && MO_GLOW==opts.coloredMouseOver && !sunken
 
8311
                                ? itsMouseOverCols
 
8312
                                : itsButtonCols
 
8313
                            : cols;
 
8314
 
8140
8315
        r.adjust(-1, -1, 1, 1);
8141
8316
        if(!sunken && option->state&State_Enabled &&
8142
8317
            ( ( ( (doEtch && WIDGET_OTHER!=w && WIDGET_SLIDER_TROUGH!=w) || WIDGET_SB_SLIDER==w || WIDGET_COMBO==w || WIDGET_MENU_BUTTON==w ) &&
8143
8318
                 (MO_GLOW==opts.coloredMouseOver/* || MO_COLORED==opts.colorMenubarMouseOver*/) && option->state&State_MouseOver) ||
8144
8319
               (doEtch && WIDGET_DEF_BUTTON==w && IND_GLOW==opts.defBtnIndicator)))
8145
 
            drawBorder(p, r, option, round, itsMouseOverCols, w);
 
8320
            drawBorder(p, r, option, round,
 
8321
                       WIDGET_DEF_BUTTON==w && IND_GLOW==opts.defBtnIndicator &&
 
8322
                       (!(option->state&State_MouseOver) || !itsMouseOverCols)
 
8323
                            ? itsDefBtnCols : itsMouseOverCols, w);
8146
8324
        else
8147
 
            drawBorder(p, r, option, round, cols, w);
 
8325
            drawBorder(p, r, option, round,
 
8326
                       colouredMouseOver && MO_COLORED_THICK==opts.coloredMouseOver ? itsMouseOverCols : borderCols, w);
8148
8327
    }
8149
8328
        
8150
8329
    p->restore();
8152
8331
 
8153
8332
void QtCurveStyle::drawGlow(QPainter *p, const QRect &r, EWidget w) const
8154
8333
{
8155
 
    p->setBrush(Qt::NoBrush);
8156
 
    p->setRenderHint(QPainter::Antialiasing, true);
8157
 
    p->setPen(itsMouseOverCols[WIDGET_DEF_BUTTON==w && IND_GLOW==opts.defBtnIndicator ? QTC_GLOW_DEFBTN : QTC_GLOW_MO]);
8158
 
    p->drawPath(buildPath(r, w, ROUNDED_ALL, getRadius(opts.round, r.width(), r.height(), w, RADIUS_ETCH)));
8159
 
    p->setRenderHint(QPainter::Antialiasing, false);
 
8334
    if(itsMouseOverCols || itsDefBtnCols)
 
8335
    {
 
8336
        bool   def(WIDGET_DEF_BUTTON==w && IND_GLOW==opts.defBtnIndicator),
 
8337
               defShade=def && (!itsDefBtnCols ||
 
8338
                                (itsMouseOverCols && itsDefBtnCols[ORIGINAL_SHADE]==itsMouseOverCols[ORIGINAL_SHADE]));
 
8339
        QColor col((def && itsDefBtnCols) || !itsMouseOverCols
 
8340
                        ? itsDefBtnCols[QTC_GLOW_DEFBTN] : itsMouseOverCols[QTC_GLOW_MO]);
 
8341
 
 
8342
        col.setAlphaF(QTC_GLOW_ALPHA(defShade));
 
8343
        p->setBrush(Qt::NoBrush);
 
8344
        p->setRenderHint(QPainter::Antialiasing, true);
 
8345
        p->setPen(col);
 
8346
        p->drawPath(buildPath(r, w, ROUNDED_ALL, getRadius(&opts, r.width(), r.height(), w, RADIUS_ETCH)));
 
8347
        p->setRenderHint(QPainter::Antialiasing, false);
 
8348
    }
8160
8349
}
8161
8350
 
8162
8351
void QtCurveStyle::drawEtch(QPainter *p, const QRect &r, const QWidget *widget,  EWidget w, bool raised) const
8165
8354
                 br;
8166
8355
    QColor       col(Qt::black);
8167
8356
 
8168
 
    buildSplitPath(r, w, ROUNDED_ALL, getRadius(opts.round, r.width(), r.height(), w, RADIUS_ETCH), tl, br);
 
8357
    buildSplitPath(r, w, ROUNDED_ALL, getRadius(&opts, r.width(), r.height(), w, RADIUS_ETCH), tl, br);
8169
8358
 
8170
8359
    col.setAlphaF(QTC_ETCH_TOP_ALPHA);
8171
8360
    p->setBrush(Qt::NoBrush);
8175
8364
    if(!raised)
8176
8365
    {
8177
8366
        p->drawPath(tl);
8178
 
        p->setPen(getLowerEtchCol(widget));
 
8367
        if(WIDGET_SLIDER_TROUGH==w && opts.thinSbarGroove && widget && qobject_cast<const QScrollBar *>(widget))
 
8368
        {
 
8369
            QColor col(Qt::white);
 
8370
            col.setAlphaF(0.25);
 
8371
            p->setPen(col);
 
8372
        }
 
8373
        else
 
8374
            p->setPen(getLowerEtchCol(widget));
8179
8375
    }
8180
8376
 
8181
8377
    p->drawPath(br);
8182
8378
    p->setRenderHint(QPainter::Antialiasing, false);
8183
8379
}
8184
8380
 
8185
 
QPainterPath QtCurveStyle::buildPath(const QRect &r, EWidget w, int round, double radius) const
 
8381
QPainterPath QtCurveStyle::buildPath(const QRect &r, EWidget w, int round, double radius, double wmod, double hmod) const
8186
8382
{
8187
8383
    if(ROUND_NONE==opts.round)
8188
8384
        round=ROUNDED_NONE;
8189
8385
 
8190
 
#if QT_VERSION >= 0x040400
8191
 
    bool         window(WIDGET_MDI_WINDOW==w || WIDGET_MDI_WINDOW_TITLE==w);
8192
 
    double       xd(window ? r.x() : (r.x()+0.5)),
8193
 
                 yd(window ? r.y() : (r.y()+0.5));
8194
 
#else
8195
8386
    double       xd(r.x()+0.5),
8196
 
                 yd(r.y()+0.5);
8197
 
#endif
8198
 
    double       diameter(radius*2);
8199
 
    int          width(r.width()-1),
8200
 
                 height(r.height()-1);
 
8387
                 yd(r.y()+0.5),
 
8388
                 diameter(radius*2),
 
8389
                 width((r.width()-1)+wmod),
 
8390
                 height((r.height()-1)+hmod);
8201
8391
 
8202
8392
    QPainterPath path;
8203
8393
 
8233
8423
void QtCurveStyle::buildSplitPath(const QRect &r, EWidget w, int round, double radius, QPainterPath &tl, QPainterPath &br) const
8234
8424
{
8235
8425
    bool         window(WIDGET_MDI_WINDOW==w || WIDGET_MDI_WINDOW_TITLE==w);
8236
 
#if QT_VERSION >= 0x040400
8237
 
    double       xd(window ? r.x() : (r.x()+0.5)),
8238
 
                 yd(window ? r.y() : (r.y()+0.5));
8239
 
#else
 
8426
// #if QT_VERSION >= 0x040400
 
8427
//     double       xd(window ? r.x() : (r.x()+0.5)),
 
8428
//                  yd(window ? r.y() : (r.y()+0.5));
 
8429
// #else
8240
8430
    double       xd(r.x()+0.5),
8241
8431
                 yd(r.y()+0.5);
8242
 
#endif
 
8432
// #endif
8243
8433
    double       diameter(radius*2);
8244
8434
    bool         rounded=diameter>0.0;
8245
8435
    int          width(r.width()-1),
8294
8484
                 window(WIDGET_MDI_WINDOW==w || WIDGET_MDI_WINDOW_TITLE==w);
8295
8485
    const QColor *cols(enabled && hasFocus && (WIDGET_FRAME==w || WIDGET_ENTRY==w ||
8296
8486
                                               (WIDGET_SCROLLVIEW==w && opts.highlightScrollViews))
8297
 
                        ? itsMenuitemCols
 
8487
                        ? itsFocusCols
8298
8488
                        : custom
8299
8489
                            ? custom
8300
8490
                            : APP_KRUNNER==theThemedApp ? itsBackgroundCols : backgroundColors(option));
8308
8498
                                                ? QT_SLIDER_MO_BORDER
8309
8499
                                                : borderVal]);
8310
8500
 
8311
 
    if(!window)
 
8501
//     if(!window)
8312
8502
        p->setRenderHint(QPainter::Antialiasing, true);
8313
8503
 
8314
8504
    p->setBrush(Qt::NoBrush);
8315
8505
 
8316
 
    switch(borderProfile)
8317
 
    {
8318
 
        case BORDER_FLAT:
8319
 
            break;
8320
 
        case BORDER_RAISED:
8321
 
        case BORDER_SUNKEN:
 
8506
    if(!window || opts.titlebarBorder)
 
8507
        switch(borderProfile)
8322
8508
        {
8323
 
            EAppearance  app(widgetApp(w, &opts));
8324
 
            int          dark=window ? ORIGINAL_SHADE : QT_FRAME_DARK_SHADOW;
8325
 
 
8326
 
            if(APPEARANCE_FLAT==app && window)
8327
 
                app=APPEARANCE_RAISED;
8328
 
 
8329
 
            QColor       tl(cols[BORDER_RAISED==borderProfile ? 0 : dark]),
8330
 
                         br(cols[BORDER_RAISED==borderProfile ? dark : 0]);
8331
 
            QPainterPath topPath,
8332
 
                         botPath;
8333
 
 
8334
 
            if(doBlend && !window)
 
8509
            case BORDER_FLAT:
 
8510
                break;
 
8511
            case BORDER_RAISED:
 
8512
            case BORDER_SUNKEN:
8335
8513
            {
8336
 
                tl.setAlphaF(QTC_BORDER_BLEND_ALPHA);
8337
 
                br.setAlphaF(QTC_BORDER_BLEND_ALPHA);
8338
 
            }
8339
 
 
8340
 
            buildSplitPath(r.adjusted(1, 1, -1, -1), w, round, getRadius(opts.round, r.width(), r.height(), w, RADIUS_INTERNAL),
8341
 
                           topPath, botPath);
8342
 
 
8343
 
            p->setPen((enabled || BORDER_SUNKEN==borderProfile) &&
8344
 
                      (BORDER_RAISED==borderProfile || hasFocus || APPEARANCE_FLAT!=app)
8345
 
                            ? tl
8346
 
                            : option->palette.background().color());
8347
 
            p->drawPath(topPath);
8348
 
            p->setPen(WIDGET_SCROLLVIEW==w && !hasFocus
8349
 
                        ? option->palette.background().color()
8350
 
                        : WIDGET_ENTRY==w && !hasFocus
8351
 
                            ? option->palette.base().color()
8352
 
                            : enabled && (BORDER_SUNKEN==borderProfile || hasFocus || APPEARANCE_FLAT!=app ||
8353
 
                                          WIDGET_TAB_TOP==w || WIDGET_TAB_BOT==w)
8354
 
                                ? br
 
8514
                EAppearance  app(widgetApp(w, &opts));
 
8515
                int          dark=window ? ORIGINAL_SHADE : QT_FRAME_DARK_SHADOW;
 
8516
 
 
8517
                if(APPEARANCE_FLAT==app && window)
 
8518
                    app=APPEARANCE_RAISED;
 
8519
 
 
8520
                QColor       tl(cols[BORDER_RAISED==borderProfile ? 0 : dark]),
 
8521
                             br(cols[BORDER_RAISED==borderProfile ? dark : 0]);
 
8522
                QPainterPath topPath,
 
8523
                             botPath;
 
8524
 
 
8525
                if(doBlend && !window)
 
8526
                {
 
8527
                    tl.setAlphaF(QTC_BORDER_BLEND_ALPHA);
 
8528
                    br.setAlphaF(QTC_BORDER_BLEND_ALPHA);
 
8529
                }
 
8530
 
 
8531
    //             if(window)
 
8532
    //                 tl.setAlphaF(0.5);
 
8533
 
 
8534
                buildSplitPath(r.adjusted(1, 1, -1, -1), w, round, getRadius(&opts, r.width(), r.height(), w, RADIUS_INTERNAL),
 
8535
                               topPath, botPath);
 
8536
 
 
8537
                p->setPen((enabled || BORDER_SUNKEN==borderProfile) &&
 
8538
                          (BORDER_RAISED==borderProfile || hasFocus || APPEARANCE_FLAT!=app)
 
8539
                                ? tl
8355
8540
                                : option->palette.background().color());
8356
 
            p->drawPath(botPath);
 
8541
                p->drawPath(topPath);
 
8542
                p->setPen(WIDGET_SCROLLVIEW==w && !hasFocus
 
8543
                            ? option->palette.background().color()
 
8544
                            : WIDGET_ENTRY==w && !hasFocus
 
8545
                                ? option->palette.base().color()
 
8546
                                : enabled && (BORDER_SUNKEN==borderProfile || hasFocus || APPEARANCE_FLAT!=app ||
 
8547
                                            WIDGET_TAB_TOP==w || WIDGET_TAB_BOT==w)
 
8548
                                    ? br
 
8549
                                    : option->palette.background().color());
 
8550
                p->drawPath(botPath);
 
8551
            }
8357
8552
        }
8358
 
    }
8359
8553
 
8360
 
    p->setPen(window && state&QtC_StateKWinHighlight ? itsMenuitemCols[0] : border);
8361
 
    p->drawPath(buildPath(r, w, round, getRadius(opts.round, r.width(), r.height(), w, RADIUS_EXTERNAL)));
8362
 
    if(!window)
 
8554
    p->setPen(window && state&QtC_StateKWinHighlight ? itsFocusCols[0] : border);
 
8555
    p->drawPath(buildPath(r, w, round, getRadius(&opts, r.width(), r.height(), w, RADIUS_EXTERNAL)));
 
8556
//     if(!window)
8363
8557
        p->setRenderHint(QPainter::Antialiasing, false);
8364
8558
 
8365
8559
    if(QTC_FULLLY_ROUNDED && window)
8370
8564
            p->drawPoint(r.x()+1, r.y()+r.height()-1);
8371
8565
            p->drawPoint(r.x()+r.width()-2, r.y()+r.height()-1);
8372
8566
            p->drawPoint(r.x()+r.width()-1, r.y()+r.height()-2);
8373
 
            p->setPen(cols[ORIGINAL_SHADE]);
8374
 
            p->drawPoint(r.x()+1, r.y()+r.height()-2);
 
8567
//             p->setPen(cols[ORIGINAL_SHADE]);
 
8568
//             p->drawPoint(r.x()+1, r.y()+r.height()-2);
8375
8569
        }
8376
8570
 
8377
8571
        if(WIDGET_MDI_WINDOW_TITLE==w)
8387
8581
    }
8388
8582
}
8389
8583
 
 
8584
void QtCurveStyle::drawMdiControl(QPainter *p, const QStyleOptionTitleBar *titleBar, SubControl sc, const QWidget *widget,
 
8585
                                  ETitleBarButtons btn, const QColor &textColor, const QColor &shadow,
 
8586
                                  const QColor *btnCols, const QColor *bgndCols) const
 
8587
{
 
8588
    QRect rect(subControlRect(CC_TitleBar, titleBar, sc, widget));
 
8589
 
 
8590
    if (rect.isValid())
 
8591
    {
 
8592
        bool sunken((titleBar->activeSubControls&sc) && (titleBar->state&State_Sunken)),
 
8593
             hover((titleBar->activeSubControls&sc) && (titleBar->state&State_MouseOver)),
 
8594
             colored=coloredMdiButtons(titleBar->state&State_Active, hover),
 
8595
             useBtnCols(opts.titlebarButtons&QTC_TITLEBAR_BUTTON_STD_COLOR &&
 
8596
                         (hover ||
 
8597
                          !(opts.titlebarButtons&QTC_TITLEBAR_BUTTON_COLOR_MOUSE_OVER) ||
 
8598
                          opts.titlebarButtons&QTC_TITLEBAR_BUTTON_COLOR));
 
8599
 
 
8600
        drawMdiButton(p, rect, hover, sunken,
 
8601
                      colored && !(opts.titlebarButtons&QTC_TITLEBAR_BUTTON_COLOR_SYMBOL)
 
8602
                        ? itsTitleBarButtonsCols[btn] : (useBtnCols ? btnCols : bgndCols));
 
8603
        drawMdiIcon(p, colored && opts.titlebarButtons&QTC_TITLEBAR_BUTTON_COLOR_SYMBOL
 
8604
                        ? itsTitleBarButtonsCols[btn][ORIGINAL_SHADE]
 
8605
                        : (SC_TitleBarCloseButton==sc && !(opts.titlebarButtons&QTC_TITLEBAR_BUTTON_COLOR) && (hover || sunken) ? CLOSE_COLOR : textColor),
 
8606
                    shadow, rect, hover, sunken, sc,  colored && opts.titlebarButtons&QTC_TITLEBAR_BUTTON_COLOR_SYMBOL);
 
8607
    }
 
8608
}
 
8609
                
8390
8610
void QtCurveStyle::drawMdiButton(QPainter *painter, const QRect &r, bool hover, bool sunken, const QColor *cols) const
8391
8611
{
8392
 
    if(hover || sunken)
 
8612
    if(!(opts.titlebarButtons&QTC_TITLEBAR_BUTTON_NO_FRAME) &&
 
8613
       (hover || sunken || !(opts.titlebarButtons&QTC_TITLEBAR_BUTTON_HOVER_FRAME)))
8393
8614
    {
8394
8615
        QStyleOption opt;
8395
8616
 
8396
8617
        opt.rect=r; // .adjusted(1, 1, -1, -1);
 
8618
        if(opts.titlebarButtons&QTC_TITLEBAR_BUTTON_ROUND)
 
8619
            opt.rect.adjust(1, 1, -1, -1);
8397
8620
        opt.state=State_Enabled|State_Horizontal|State_Raised;
8398
8621
        if(hover)
8399
8622
            opt.state|=State_MouseOver;
8406
8629
}
8407
8630
 
8408
8631
void QtCurveStyle::drawMdiIcon(QPainter *painter, const QColor &color, const QColor &shadow, const QRect &r,
8409
 
                               bool sunken, int margin, SubControl button) const
 
8632
                               bool hover, bool sunken, SubControl button, bool customCol) const
8410
8633
{
8411
 
    if(!sunken)
 
8634
    static const int margin(6);
 
8635
 
 
8636
    if(!sunken) // && hover && !(opts.titlebarButtons&QTC_TITLEBAR_BUTTON_HOVER_SYMBOL) && !customCol)
8412
8637
        drawWindowIcon(painter, shadow, r.adjusted(1, 1, 1, 1), sunken, margin, button);
8413
 
    drawWindowIcon(painter, color, r, sunken, margin, button);
 
8638
 
 
8639
    QColor col(color);
 
8640
 
 
8641
    if(!sunken && !hover && opts.titlebarButtons&QTC_TITLEBAR_BUTTON_HOVER_SYMBOL)
 
8642
        col.setAlphaF(HOVER_BUTTON_ALPHA);
 
8643
 
 
8644
    drawWindowIcon(painter, col, r, sunken, margin, button);
8414
8645
}
8415
8646
 
8416
8647
void QtCurveStyle::drawWindowIcon(QPainter *painter, const QColor &color, const QRect &r, bool sunken, int margin, SubControl button) const
8417
8648
{
 
8649
    static const int constIconSize=9;
 
8650
    
8418
8651
    QRect rect(r);
8419
8652
 
8420
 
    // Icons look best at 22x22...
8421
 
    if(rect.height()>22)
8422
 
    {
8423
 
        int diff=(rect.height()-22)/2;
8424
 
        rect.adjust(diff, diff, -diff, -diff);
8425
 
    }
 
8653
    int diff=(rect.height()-constIconSize)/2;
 
8654
    rect.adjust(diff, diff, -diff, -diff);
 
8655
    rect.setHeight(constIconSize);
 
8656
    rect.setWidth(constIconSize);
8426
8657
 
8427
8658
    if(sunken)
8428
8659
        rect.adjust(1, 1, 1, 1);
8429
8660
 
8430
 
    if(margin)
8431
 
        rect.adjust(margin, margin, -margin, -margin);
8432
 
 
8433
8661
    painter->setPen(color);
8434
8662
 
8435
8663
    switch(button)
8436
8664
    {
8437
8665
        case SC_TitleBarMinButton:
8438
 
            painter->drawLine(rect.center().x() - 2, rect.center().y() + 3, rect.center().x() + 3, rect.center().y() + 3);
8439
 
            painter->drawLine(rect.center().x() - 2, rect.center().y() + 4, rect.center().x() + 3, rect.center().y() + 4);
8440
 
            painter->drawLine(rect.center().x() - 3, rect.center().y() + 3, rect.center().x() - 3, rect.center().y() + 4);
8441
 
            painter->drawLine(rect.center().x() + 4, rect.center().y() + 3, rect.center().x() + 4, rect.center().y() + 4);
 
8666
            drawRect(painter, QRect(rect.left(), rect.bottom()-1, rect.width(), 2));
8442
8667
            break;
8443
8668
        case SC_TitleBarMaxButton:
8444
 
            painter->drawRect(rect.adjusted(0, 0, -1, -1));
 
8669
            drawRect(painter, rect);
8445
8670
            painter->drawLine(rect.left() + 1, rect.top() + 1,  rect.right() - 1, rect.top() + 1);
8446
 
            painter->drawPoint(rect.topLeft());
8447
 
            painter->drawPoint(rect.topRight());
8448
 
            painter->drawPoint(rect.bottomLeft());
8449
 
            painter->drawPoint(rect.bottomRight());
8450
8671
            break;
8451
8672
        case SC_TitleBarCloseButton:
8452
 
            painter->drawLine(rect.left() + 1, rect.top(), rect.right(), rect.bottom() - 1);
8453
 
            painter->drawLine(rect.left(), rect.top() + 1, rect.right() - 1, rect.bottom());
8454
 
            painter->drawLine(rect.right() - 1, rect.top(), rect.left(), rect.bottom() - 1);
8455
 
            painter->drawLine(rect.right(), rect.top() + 1, rect.left() + 1, rect.bottom());
8456
 
            painter->drawPoint(rect.topLeft());
8457
 
            painter->drawPoint(rect.topRight());
8458
 
            painter->drawPoint(rect.bottomLeft());
8459
 
            painter->drawPoint(rect.bottomRight());
8460
 
            painter->drawLine(rect.left() + 1, rect.top() + 1, rect.right() - 1, rect.bottom() - 1);
8461
 
            painter->drawLine(rect.left() + 1, rect.bottom() - 1, rect.right() - 1, rect.top() + 1);
 
8673
        {
 
8674
            static unsigned char xbm[] = { 0x83, 0x01, 0xc7, 0x01, 0xee, 0x00, 0x7c, 0x00, 0x38, 0x00, 0x7c, 0x00,
 
8675
                                           0xee, 0x00, 0xc7, 0x01, 0x83, 0x01 };
 
8676
            static QBitmap bitmap=QBitmap::fromData(QSize(constIconSize, constIconSize), xbm);
 
8677
            painter->drawPixmap(rect.x()+(rect.width()-bitmap.width())/2, rect.y()+(rect.height()-bitmap.height())/2, bitmap);
8462
8678
            break;
 
8679
        }
8463
8680
        case SC_TitleBarNormalButton:
8464
8681
        {
8465
 
            QRect r2 = rect.adjusted(0, 3, -3, 0);
8466
 
 
8467
 
            painter->drawRect(r2.adjusted(0, 0, -1, -1));
8468
 
            painter->drawLine(r2.left() + 1, r2.top() + 1, r2.right() - 1, r2.top() + 1);
8469
 
            painter->drawPoint(r2.topLeft());
8470
 
            painter->drawPoint(r2.topRight());
8471
 
            painter->drawPoint(r2.bottomLeft());
8472
 
            painter->drawPoint(r2.bottomRight());
8473
 
 
8474
 
            QRect   backWindowRect(rect.adjusted(3, 0, 0, -3));
8475
 
            QRegion clipRegion(backWindowRect);
8476
 
 
8477
 
            clipRegion -= r2;
8478
 
            if(sunken)
8479
 
                backWindowRect.adjust(1, 1, 1, 1);
8480
 
            painter->drawRect(backWindowRect.adjusted(0, 0, -1, -1));
8481
 
            painter->drawLine(backWindowRect.left() + 1, backWindowRect.top() + 1,
8482
 
                            backWindowRect.right() - 1, backWindowRect.top() + 1);
8483
 
            painter->drawPoint(backWindowRect.topLeft());
8484
 
            painter->drawPoint(backWindowRect.topRight());
8485
 
            painter->drawPoint(backWindowRect.bottomLeft());
8486
 
            painter->drawPoint(backWindowRect.bottomRight());
 
8682
            static unsigned char xbm[] = {0xfc, 0x01, 0xfc, 0x01, 0x04, 0x01, 0x7f, 0x01, 0x7f, 0x01, 0xc1, 0x01,
 
8683
                                          0x41, 0x00, 0x41, 0x00, 0x7f, 0x00 };
 
8684
            static QBitmap bitmap=QBitmap::fromData(QSize(constIconSize, constIconSize), xbm);
 
8685
            painter->drawPixmap(rect.x()+(rect.width()-bitmap.width())/2, rect.y()+(rect.height()-bitmap.height())/2, bitmap);
8487
8686
            break;
8488
8687
        }
8489
8688
        case SC_TitleBarShadeButton:
8490
 
            drawArrow(painter, rect, PE_IndicatorArrowUp, color);
 
8689
            drawArrow(painter, rect, PE_IndicatorArrowUp, color, false, true);
8491
8690
            break;
8492
8691
        case SC_TitleBarUnshadeButton:
8493
 
            drawArrow(painter, rect, PE_IndicatorArrowDown, color);
 
8692
            drawArrow(painter, rect, PE_IndicatorArrowDown, color, false, true);
 
8693
            break;
 
8694
        case SC_TitleBarSysMenu:
 
8695
            for(int i=1; i<=constIconSize; i+=3)
 
8696
                painter->drawLine(rect.left() + 1, rect.top() + i,  rect.right() - 1, rect.top() + i);
8494
8697
        default:
8495
8698
            break;
8496
8699
    }
8507
8710
    if(fill)
8508
8711
    {
8509
8712
        p->setClipPath(buildPath(r, WIDGET_ENTRY, round,
8510
 
                                 getRadius(opts.round, r.width(), r.height(), WIDGET_ENTRY, RADIUS_INTERNAL)));
 
8713
                                 getRadius(&opts, r.width(), r.height(), WIDGET_ENTRY, RADIUS_INTERNAL)));
8511
8714
        p->fillRect(r.adjusted(1, 1, -1, -1), option->palette.brush(QPalette::Base));
8512
8715
        p->setClipping(false);
8513
8716
    }
8515
8718
    if(doEtch)
8516
8719
        drawEtch(p, rx, widget, WIDGET_ENTRY, false);
8517
8720
 
8518
 
    drawBorder(p, r, option, round, NULL, w, BORDER_SUNKEN);
 
8721
    drawBorder(p, r, option, round, 0L, w, BORDER_SUNKEN);
8519
8722
}
8520
8723
 
8521
8724
void QtCurveStyle::drawMenuItem(QPainter *p, const QRect &r, const QStyleOption *option, bool mbi, int round, const QColor *cols) const
8522
8725
{
8523
 
    int fill=opts.useHighlightForMenu && (!mbi || itsMenuitemCols==cols) ? ORIGINAL_SHADE : 4,
 
8726
    int fill=opts.useHighlightForMenu && (!mbi || itsHighlightCols==cols) ? ORIGINAL_SHADE : 4,
8524
8727
        border=opts.borderMenuitems ? 0 : fill;
8525
8728
 
8526
 
    if(itsMenuitemCols!=cols && mbi && !(option->state&(State_On|State_Sunken)) &&
 
8729
    if(itsHighlightCols!=cols && mbi && !(option->state&(State_On|State_Sunken)) &&
8527
8730
       !opts.colorMenubarMouseOver && (opts.borderMenuitems || !IS_FLAT(opts.menuitemAppearance)))
8528
8731
        fill=ORIGINAL_SHADE;
8529
8732
    
8555
8758
    }
8556
8759
    else if(mbi || opts.borderMenuitems)
8557
8760
    {
8558
 
        bool stdColor(!mbi || SHADE_BLEND_SELECTED!=opts.shadeMenubars);
 
8761
        bool stdColor(!mbi || (SHADE_BLEND_SELECTED!=opts.shadeMenubars && SHADE_SELECTED!=opts.shadeMenubars));
8559
8762
 
8560
8763
        QStyleOption opt(*option);
8561
8764
 
8585
8788
void QtCurveStyle::drawProgress(QPainter *p, const QRect &r, const QStyleOption *option, int round, bool vertical, bool reverse) const
8586
8789
{
8587
8790
    QStyleOption opt(*option);
 
8791
    QRect        rx(r);
8588
8792
 
8589
8793
    opt.state|=State_Raised;
8590
8794
 
8598
8802
    else
8599
8803
        opt.state&=~QTC_STATE_REVERSE;
8600
8804
 
8601
 
    if(r.width()<1)
 
8805
    if((vertical ? r.height() : r.width())<1)
8602
8806
        return;
8603
8807
 
8604
 
    int  length(vertical ? r.height() : r.width());
8605
 
    bool drawFull(length > 3);
 
8808
    if(vertical && r.height()<3)
 
8809
        rx.setHeight(3);
 
8810
 
 
8811
    if(!vertical && rx.width()<3)
 
8812
        rx.setWidth(3);
 
8813
 
 
8814
    int          length(vertical ? rx.height() : rx.width());
8606
8815
    const QColor *use=option->state&State_Enabled || ECOLOR_BACKGROUND==opts.progressGrooveColor
8607
 
                    ? itsMenuitemCols : itsBackgroundCols;
8608
 
 
8609
 
    drawLightBevel(p, r, &opt, 0L, opts.fillProgress ? ROUNDED_ALL : round, use[ORIGINAL_SHADE], use, true, WIDGET_PROGRESSBAR);
 
8816
                    ? itsHighlightCols : itsBackgroundCols;
 
8817
                                         
 
8818
    drawLightBevel(p, rx, &opt, 0L, opts.fillProgress ? ROUNDED_ALL : round, use[ORIGINAL_SHADE], use, true,
 
8819
                   WIDGET_PROGRESSBAR);
8610
8820
 
8611
8821
    if(!opts.fillProgress && QTC_ROUNDED && length>2 && ROUNDED_ALL!=round)
8612
8822
    {
8613
 
        QRect rb(r);
 
8823
        bool drawFull(length > 3);
8614
8824
 
8615
 
        if(opts.fillProgress)
8616
 
        {
8617
 
            p->setPen(backgroundColors(option)[QT_STD_BORDER]);
8618
 
            rb.adjust(1, 1, -1, -1);
8619
 
        }
8620
 
        else
8621
 
            p->setPen(midColor(option->palette.background().color(), itsMenuitemCols[QT_PBAR_BORDER]));
 
8825
        p->setPen(midColor(option->palette.background().color(), itsHighlightCols[QT_PBAR_BORDER]));
8622
8826
        if(!(round&CORNER_TL) || !drawFull)
8623
 
            p->drawPoint(rb.x(), rb.y());
 
8827
            p->drawPoint(rx.x(), rx.y());
8624
8828
        if(!(round&CORNER_BL) || !drawFull)
8625
 
            p->drawPoint(rb.x(), rb.y()+rb.height()-1);
 
8829
            p->drawPoint(rx.x(), rx.y()+rx.height()-1);
8626
8830
        if(!(round&CORNER_TR) || !drawFull)
8627
 
            p->drawPoint(rb.x()+rb.width()-1, rb.y());
 
8831
            p->drawPoint(rx.x()+rx.width()-1, rx.y());
8628
8832
        if(!(round&CORNER_BR) || !drawFull)
8629
 
            p->drawPoint(rb.x()+rb.width()-1, rb.y()+rb.height()-1);
 
8833
            p->drawPoint(rx.x()+rx.width()-1, rx.y()+rx.height()-1);
8630
8834
    }
8631
8835
}
8632
8836
 
8633
 
void QtCurveStyle::drawArrow(QPainter *p, const QRect &r, PrimitiveElement pe, QColor col, bool small) const
 
8837
void QtCurveStyle::drawArrow(QPainter *p, const QRect &r, PrimitiveElement pe, QColor col, bool small, bool mdi) const
8634
8838
{
8635
8839
    QPolygon     a;
8636
8840
    QPainterPath path;
8683
8887
    // Just using 'aa' and drawing the arrows would be fine - but this makes them look
8684
8888
    // slightly blurry, and I dont like that.
8685
8889
    p->save();
8686
 
    col.setAlpha(255);
 
8890
    if(!mdi)
 
8891
        col.setAlpha(255);
 
8892
    p->setRenderHint(QPainter::Antialiasing, true);
8687
8893
    p->setPen(col);
8688
8894
    p->setBrush(col);
8689
 
    p->setRenderHint(QPainter::Antialiasing, true);
8690
8895
    p->fillPath(path, col);
8691
8896
    p->setRenderHint(QPainter::Antialiasing, false);
8692
8897
    p->drawPolygon(a);
8719
8924
                   || SCROLLBAR_NONE==opts.scrollbarType || opts.flatSbarButtons
8720
8925
#endif
8721
8926
                    ? ROUNDED_ALL : ROUNDED_NONE,
8722
 
                   getFill(&opt, use), use, true, WIDGET_SB_SLIDER);
 
8927
                   getFill(&opt, use, false, SHADE_DARKEN==opts.shadeSliders), use, true, WIDGET_SB_SLIDER);
8723
8928
 
8724
8929
    const QColor *markers(/*opts.coloredMouseOver && opt.state&State_MouseOver
8725
8930
                              ? itsMouseOverCols
8766
8971
                         *border(opt.state&State_MouseOver && (MO_GLOW==opts.coloredMouseOver ||
8767
8972
                                                               MO_COLORED==opts.coloredMouseOver)
8768
8973
                                    ? itsMouseOverCols : use);
8769
 
        const QColor     &fill(getFill(&opt, use));
 
8974
        const QColor     &fill(getFill(&opt, use, false, SHADE_DARKEN==opts.shadeSliders));
8770
8975
        int              x(r.x()),
8771
8976
                         y(r.y()),
8772
8977
                         xo(horiz ? 8 : 0),
9008
9213
 
9009
9214
        if(opts.fillSlider && slider->maximum!=slider->minimum && slider->state&State_Enabled)
9010
9215
        {
9011
 
            const QColor *usedCols=itsSliderCols ? itsSliderCols : itsMenuitemCols;
 
9216
            const QColor *usedCols=itsSliderCols ? itsSliderCols : itsHighlightCols;
9012
9217
 
9013
9218
            if (horiz)
9014
9219
                if (slider->upsideDown)
9095
9300
    }
9096
9301
}
9097
9302
 
 
9303
void QtCurveStyle::colorTab(QPainter *p, const QRect &r, bool horiz, EWidget tab, int round) const
 
9304
{
 
9305
    p->save();
 
9306
    p->setRenderHint(QPainter::Antialiasing, true);
 
9307
    QLinearGradient grad(r.topLeft(), horiz ? r.bottomLeft() : r.topRight());
 
9308
    QColor          start(itsHighlightCols[ORIGINAL_SHADE]),
 
9309
                    end(itsHighlightCols[ORIGINAL_SHADE]);
 
9310
 
 
9311
    start.setAlphaF(QTC_COLOR_SEL_TAB_FACTOR);
 
9312
    end.setAlphaF(0.0);
 
9313
    grad.setColorAt(0, WIDGET_TAB_TOP==tab ? start : end);
 
9314
    grad.setColorAt(1, WIDGET_TAB_TOP==tab ? end : start);
 
9315
    p->fillPath(buildPath(r, tab, round, getRadius(&opts, r.width(), r.height(), tab, RADIUS_EXTERNAL)), grad);
 
9316
    p->restore();
 
9317
}
 
9318
 
9098
9319
void QtCurveStyle::shadeColors(const QColor &base, QColor *vals) const
9099
9320
{
9100
9321
    QTC_SHADES
9112
9333
 
9113
9334
const QColor * QtCurveStyle::buttonColors(const QStyleOption *option) const
9114
9335
{
 
9336
    if(option && option->version>=QTC_TBAR_VERSION_HACK &&
 
9337
       option->version<QTC_TBAR_VERSION_HACK+NUM_TITLEBAR_BUTTONS &&
 
9338
       coloredMdiButtons(option->state&State_Active, option->state&(State_MouseOver|State_Sunken)))
 
9339
        return itsTitleBarButtonsCols[option->version-QTC_TBAR_VERSION_HACK];
 
9340
 
9115
9341
    if(option && option->palette.button()!=itsButtonCols[ORIGINAL_SHADE])
9116
9342
    {
9117
9343
        shadeColors(option->palette.button().color(), itsColoredButtonCols);
9124
9350
const QColor * QtCurveStyle::sliderColors(const QStyleOption *option) const
9125
9351
{
9126
9352
    return (option && option->state&State_Enabled)
9127
 
                ? SHADE_NONE!=opts.shadeSliders// && option->palette.button()==itsButtonCols[ORIGINAL_SHADE]
 
9353
                ? SHADE_NONE!=opts.shadeSliders && itsSliderCols &&
 
9354
                  (!opts.colorSliderMouseOver || option->state&State_MouseOver)
9128
9355
                        ? itsSliderCols
9129
9356
                        : itsButtonCols //buttonColors(option)
9130
9357
                : itsBackgroundCols;
9158
9385
        else
9159
9386
        {
9160
9387
            itsSidebarButtonsCols=new QColor [TOTAL_SHADES+1];
9161
 
            shadeColors(midColor(itsMenuitemCols[ORIGINAL_SHADE], itsButtonCols[ORIGINAL_SHADE]),
 
9388
            shadeColors(midColor(itsHighlightCols[ORIGINAL_SHADE], itsButtonCols[ORIGINAL_SHADE]),
9162
9389
                        itsSidebarButtonsCols);
9163
9390
        }
9164
9391
    }
9173
9400
        case SHADE_NONE:
9174
9401
            memcpy(itsMenubarCols, itsBackgroundCols, sizeof(QColor)*(TOTAL_SHADES+1));
9175
9402
            break;
9176
 
        case SHADE_BLEND_SELECTED:  // For menubars we dont actually blend...
 
9403
        case SHADE_BLEND_SELECTED:
 
9404
            shadeColors(midColor(itsHighlightCols[ORIGINAL_SHADE], itsBackgroundCols[ORIGINAL_SHADE]), itsMenubarCols);
 
9405
            break;
 
9406
        case SHADE_SELECTED:
9177
9407
            shadeColors(IS_GLASS(opts.appearance)
9178
 
                            ? shade(itsMenuitemCols[ORIGINAL_SHADE], MENUBAR_GLASS_SELECTED_DARK_FACTOR)
9179
 
                            : itsMenuitemCols[ORIGINAL_SHADE],
 
9408
                            ? shade(itsHighlightCols[ORIGINAL_SHADE], MENUBAR_GLASS_SELECTED_DARK_FACTOR)
 
9409
                            : itsHighlightCols[ORIGINAL_SHADE],
9180
9410
                        itsMenubarCols);
9181
9411
            break;
9182
9412
        case SHADE_CUSTOM:
9187
9417
    }
9188
9418
}
9189
9419
 
 
9420
bool QtCurveStyle::coloredMdiButtons(bool active, bool mouseOver) const
 
9421
{
 
9422
    return opts.titlebarButtons&QTC_TITLEBAR_BUTTON_COLOR &&
 
9423
            (active
 
9424
                ? (mouseOver || !(opts.titlebarButtons&QTC_TITLEBAR_BUTTON_COLOR_MOUSE_OVER))
 
9425
                : ( (opts.titlebarButtons&QTC_TITLEBAR_BUTTON_COLOR_MOUSE_OVER && mouseOver) ||
 
9426
                    (!(opts.titlebarButtons&QTC_TITLEBAR_BUTTON_COLOR_MOUSE_OVER) &&
 
9427
                       opts.titlebarButtons&QTC_TITLEBAR_BUTTON_COLOR_INACTIVE)) );
 
9428
}
 
9429
 
9190
9430
const QColor * QtCurveStyle::getMdiColors(const QStyleOption *option, bool active) const
9191
9431
{
9192
9432
    if(!itsActiveMdiColors)
9194
9434
        itsActiveMdiTextColor=option->palette.highlightedText().color();
9195
9435
        itsMdiTextColor=option->palette.text().color();
9196
9436
 
9197
 
#ifdef QTC_USE_KDE4
9198
 
        checkKComponentData();
9199
 
 
9200
 
        QColor col;
9201
 
 
9202
 
        col=KGlobalSettings::activeTitleColor();
9203
 
 
9204
 
        if(col!=itsMenuitemCols[ORIGINAL_SHADE])
 
9437
#if !defined QTC_QT_ONLY
 
9438
        QColor col=KGlobalSettings::activeTitleColor();
 
9439
 
 
9440
        if(col!=itsHighlightCols[ORIGINAL_SHADE])
9205
9441
        {
9206
9442
            itsActiveMdiColors=new QColor [TOTAL_SHADES+1];
9207
9443
            shadeColors(col, itsActiveMdiColors);
9216
9452
 
9217
9453
        itsActiveMdiTextColor=KGlobalSettings::activeTextColor();
9218
9454
        itsMdiTextColor=KGlobalSettings::inactiveTextColor();
9219
 
#else
9220
 
        QFile f(kdeHome()+QLatin1String("/share/config/kdeglobals"));
9221
 
 
9222
 
        if(f.open(QIODevice::ReadOnly))
9223
 
        {
9224
 
            QTextStream in(&f);
9225
 
            bool        inPal(false);
9226
 
 
9227
 
            while (!in.atEnd())
9228
 
            {
9229
 
                QString line(in.readLine());
9230
 
 
9231
 
                if(inPal)
9232
 
                {
9233
 
                    if(!itsActiveMdiColors && 0==line.indexOf("activeBackground=", Qt::CaseInsensitive))
9234
 
                    {
9235
 
                        QColor col;
9236
 
 
9237
 
                        setRgb(&col, line.mid(17).split(QLatin1String(",")));
9238
 
 
9239
 
                        if(col!=itsMenuitemCols[ORIGINAL_SHADE])
9240
 
                        {
9241
 
                            itsActiveMdiColors=new QColor [TOTAL_SHADES+1];
9242
 
                            shadeColors(col, itsActiveMdiColors);
9243
 
                        }
9244
 
                    }
9245
 
                    else if(!itsMdiColors && 0==line.indexOf("inactiveBackground=", Qt::CaseInsensitive))
9246
 
                    {
9247
 
                        QColor col;
9248
 
 
9249
 
                        setRgb(&col, line.mid(19).split(QLatin1String(",")));
9250
 
                        if(col!=itsButtonCols[ORIGINAL_SHADE])
9251
 
                        {
9252
 
                            itsMdiColors=new QColor [TOTAL_SHADES+1];
9253
 
                            shadeColors(col, itsMdiColors);
9254
 
                        }
9255
 
                    }
9256
 
                    else if(0==line.indexOf("activeForeground=", Qt::CaseInsensitive))
9257
 
                        setRgb(&itsActiveMdiTextColor, line.mid(17).split(QLatin1String(",")));
9258
 
                    else if(0==line.indexOf("inactiveForeground=", Qt::CaseInsensitive))
9259
 
                        setRgb(&itsMdiTextColor, line.mid(19).split(QLatin1String(",")));
9260
 
                    else if (-1!=line.indexOf('['))
9261
 
                        break;
9262
 
                }
9263
 
                else if(0==line.indexOf("[WM]", Qt::CaseInsensitive))
9264
 
                    inPal=true;
9265
 
            }
9266
 
            f.close();
9267
 
        }
9268
9455
#endif
 
9456
 
9269
9457
        if(!itsActiveMdiColors)
9270
 
            itsActiveMdiColors=(QColor *)itsMenuitemCols;
 
9458
            itsActiveMdiColors=(QColor *)itsHighlightCols;
9271
9459
        if(!itsMdiColors)
9272
9460
            itsMdiColors=(QColor *)itsBackgroundCols;
9273
9461
    }
9289
9477
        itsMdiButtons[1].append(WINDOWTITLE_SPACER);
9290
9478
        itsMdiButtons[1].append(SC_TitleBarCloseButton);
9291
9479
 
9292
 
#ifdef QTC_USE_KDE4
9293
 
        checkKComponentData();
9294
 
 
 
9480
#if !defined QTC_QT_ONLY
9295
9481
        KConfig      cfg("kwinrc");
9296
9482
        KConfigGroup grp(&cfg, "Style");
9297
 
        QString      val;
9298
 
 
9299
 
        val=grp.readEntry("ButtonsOnLeft");
9300
 
        if(!val.isEmpty())
9301
 
        {
9302
 
            itsMdiButtons[0].clear();
9303
 
            parseWindowLine(val, itsMdiButtons[0]);
9304
 
        }
9305
 
 
9306
 
        val=grp.readEntry("ButtonsOnRight");
9307
 
        if(!val.isEmpty())
9308
 
        {
9309
 
            itsMdiButtons[1].clear();
9310
 
            parseWindowLine(val, itsMdiButtons[1]);
9311
 
        }
9312
 
#else
9313
 
        // Read in KWin settings...
9314
 
        QFile f(kdeHome()+QLatin1String("/share/config/kwinrc"));
9315
 
 
9316
 
        if(f.open(QIODevice::ReadOnly))
9317
 
        {
9318
 
            QTextStream in(&f);
9319
 
            bool        inStyle(false);
9320
 
 
9321
 
            while (!in.atEnd())
9322
 
            {
9323
 
                QString line(in.readLine());
9324
 
 
9325
 
                if(inStyle)
 
9483
 
 
9484
        if(grp.readEntry("CustomButtonPositions", false))
 
9485
        {
 
9486
            QString val=grp.readEntry("ButtonsOnLeft");
 
9487
            if(!val.isEmpty())
 
9488
            {
 
9489
                itsMdiButtons[0].clear();
 
9490
                parseWindowLine(val, itsMdiButtons[0]);
 
9491
            }
 
9492
 
 
9493
            val=grp.readEntry("ButtonsOnRight");
 
9494
            if(!val.isEmpty())
 
9495
            {
 
9496
                itsMdiButtons[1].clear();
 
9497
                parseWindowLine(val, itsMdiButtons[1]);
 
9498
            }
 
9499
 
 
9500
            // Designer uses shade buttons, not min/max - so if we dont have shade in our kwin config. then add this
 
9501
            // button near the max button...
 
9502
            if(-1==itsMdiButtons[0].indexOf(SC_TitleBarShadeButton) && -1==itsMdiButtons[1].indexOf(SC_TitleBarShadeButton))
 
9503
            {
 
9504
                int maxPos=itsMdiButtons[0].indexOf(SC_TitleBarMaxButton);
 
9505
 
 
9506
                if(-1==maxPos) // Left doesnt have max button, assume right does and add shade there
9326
9507
                {
9327
 
                    if(0==line.indexOf("ButtonsOnLeft=", Qt::CaseInsensitive))
9328
 
                    {
9329
 
                        itsMdiButtons[0].clear();
9330
 
                        parseWindowLine(line.mid(14), itsMdiButtons[0]);
9331
 
                    }
9332
 
                    else if(0==line.indexOf("ButtonsOnRight=", Qt::CaseInsensitive))
9333
 
                    {
9334
 
                        itsMdiButtons[1].clear();
9335
 
                        parseWindowLine(line.mid(15), itsMdiButtons[1]);
9336
 
                    }
9337
 
                    else if (-1!=line.indexOf('['))
9338
 
                        break;
 
9508
                    int minPos=itsMdiButtons[1].indexOf(SC_TitleBarMinButton);
 
9509
                    maxPos=itsMdiButtons[1].indexOf(SC_TitleBarMaxButton);
 
9510
 
 
9511
                    itsMdiButtons[1].insert(minPos<maxPos ? (minPos==-1 ? 0 : minPos)
 
9512
                                                            : (maxPos==-1 ? 0 : maxPos), SC_TitleBarShadeButton);
9339
9513
                }
9340
 
                else if(0==line.indexOf("[Style]", Qt::CaseInsensitive))
9341
 
                    inStyle=true;
9342
 
            }
9343
 
            f.close();
9344
 
        }
9345
 
#endif
9346
 
 
9347
 
        // Designer uses shade buttons, not min/max - so if we dont have shade in our kwin config. then add this
9348
 
        // button near the max button...
9349
 
        if(-1==itsMdiButtons[0].indexOf(SC_TitleBarShadeButton) && -1==itsMdiButtons[1].indexOf(SC_TitleBarShadeButton))
9350
 
        {
9351
 
            int maxPos=itsMdiButtons[0].indexOf(SC_TitleBarMaxButton);
9352
 
 
9353
 
            if(-1==maxPos) // Left doesnt have max button, assume right does and add shade there
9354
 
            {
9355
 
                int minPos=itsMdiButtons[1].indexOf(SC_TitleBarMinButton);
9356
 
                maxPos=itsMdiButtons[1].indexOf(SC_TitleBarMaxButton);
9357
 
 
9358
 
                itsMdiButtons[1].insert(minPos<maxPos ? (minPos==-1 ? 0 : minPos)
 
9514
                else // Add to left button
 
9515
                {
 
9516
                    int minPos=itsMdiButtons[0].indexOf(SC_TitleBarMinButton);
 
9517
 
 
9518
                    itsMdiButtons[1].insert(minPos>maxPos ? (minPos==-1 ? 0 : minPos)
9359
9519
                                                        : (maxPos==-1 ? 0 : maxPos), SC_TitleBarShadeButton);
9360
 
            }
9361
 
            else // Add to left button
9362
 
            {
9363
 
                int minPos=itsMdiButtons[0].indexOf(SC_TitleBarMinButton);
9364
 
 
9365
 
                itsMdiButtons[1].insert(minPos>maxPos ? (minPos==-1 ? 0 : minPos)
9366
 
                                                      : (maxPos==-1 ? 0 : maxPos), SC_TitleBarShadeButton);
 
9520
                }
9367
9521
            }
9368
9522
        }
 
9523
#endif
9369
9524
    }
9370
9525
}
9371
9526
 
9372
 
const QColor & QtCurveStyle::getFill(const QStyleOption *option, const QColor *use, bool cr) const
 
9527
const QColor & QtCurveStyle::getFill(const QStyleOption *option, const QColor *use, bool cr, bool darker) const
9373
9528
{
9374
9529
    return !option || !(option->state&State_Enabled)
9375
 
               ? use[ORIGINAL_SHADE]
 
9530
               ? use[darker ? 2 : ORIGINAL_SHADE]
9376
9531
               : option->state&State_Sunken  // State_Down ????
9377
 
                   ? use[4]
 
9532
                   ? use[darker ? 5 : 4]
9378
9533
                   : option->state&State_MouseOver
9379
9534
                         ? !cr && option->state&State_On
9380
 
                               ? use[SHADE_4_HIGHLIGHT]
9381
 
                               : use[SHADE_ORIG_HIGHLIGHT]
 
9535
                               ? use[darker ? 3 : SHADE_4_HIGHLIGHT]
 
9536
                               : use[darker ? SHADE_2_HIGHLIGHT : SHADE_ORIG_HIGHLIGHT]
9382
9537
                         : !cr && option->state&State_On
9383
 
                               ? use[4]
9384
 
                               : use[ORIGINAL_SHADE];
 
9538
                               ? use[darker ? 5 : 4]
 
9539
                               : use[darker ? 2 : ORIGINAL_SHADE];
9385
9540
}
9386
9541
 
9387
9542
static QImage rotateImage(const QImage &img, double angle=90.0)
9494
9649
 
9495
9650
const QColor & QtCurveStyle::menuStripeCol() const
9496
9651
{
9497
 
    return opts.lighterPopupMenuBgnd<0
 
9652
    switch(opts.menuStripe)
 
9653
    {
 
9654
        default:
 
9655
        case SHADE_NONE:
 
9656
            return itsBackgroundCols[ORIGINAL_SHADE];
 
9657
        case SHADE_CUSTOM:
 
9658
            return opts.customMenuStripeColor;
 
9659
        case SHADE_BLEND_SELECTED:
 
9660
            // Hack! Use opts.customMenuStripeColor to store this setting!
 
9661
            if(QTC_IS_BLACK(opts.customMenuStripeColor))
 
9662
                opts.customMenuStripeColor=midColor(itsHighlightCols[ORIGINAL_SHADE],
 
9663
                                opts.lighterPopupMenuBgnd<0
 
9664
                                    ? itsLighterPopupMenuBgndCol
 
9665
                                    : itsBackgroundCols[ORIGINAL_SHADE]);
 
9666
            return opts.customMenuStripeColor;
 
9667
        case SHADE_SELECTED:
 
9668
            return itsHighlightCols[QTC_MENU_STRIPE_SHADE];
 
9669
        case SHADE_DARKEN:
 
9670
            return opts.lighterPopupMenuBgnd<0
9498
9671
                ? itsLighterPopupMenuBgndCol
9499
9672
                : itsBackgroundCols[QTC_MENU_STRIPE_SHADE];
 
9673
    }
9500
9674
}
9501
9675
 
9502
9676
const QColor & QtCurveStyle::checkRadioCol(const QStyleOption *opt) const
9506
9680
            : opt->palette.buttonText().color();
9507
9681
}
9508
9682
 
 
9683
QColor QtCurveStyle::shade(const QColor &a, float k) const
 
9684
{
 
9685
    QColor mod;
 
9686
 
 
9687
    ::shade(&opts, a, &mod, k);
 
9688
    return mod;
 
9689
}
 
9690
 
 
9691
void QtCurveStyle::shade(const color &ca, color *cb, double k) const
 
9692
{
 
9693
    ::shade(&opts, ca, cb, k);
 
9694
}
 
9695
 
 
9696
QColor QtCurveStyle::getLowerEtchCol(const QWidget *widget) const
 
9697
 
9698
    bool doEtch=widget && widget->parentWidget() && !theNoEtchWidgets.contains(widget);
 
9699
// CPD: Don't really want to check here for every widget, when (so far) on problem seems to be in
 
9700
// KPackageKit, and thats with its KTextBrowser - so just check when we draw scrollviews...
 
9701
//     if(doEtch && isInQAbstractItemView(widget->parentWidget()))
 
9702
//     {
 
9703
//         doEtch=false;
 
9704
//         theNoEtchWidgets.insert(widget);
 
9705
//     }
 
9706
 
 
9707
    if(doEtch)
 
9708
    {
 
9709
        QColor bgnd(widget->parentWidget()->palette().color(widget->parentWidget()->backgroundRole()));
 
9710
 
 
9711
        if(bgnd.alpha()>0)
 
9712
            return shade(bgnd, 1.06);
 
9713
    }
 
9714
        
 
9715
    QColor col(Qt::white);
 
9716
    col.setAlphaF(0.25);
 
9717
    return col;
 
9718
}
 
9719
 
9509
9720
void QtCurveStyle::widgetDestroyed(QObject *o)
9510
9721
{
9511
9722
    QWidget *w=static_cast<const QWidget *>(o);
9532
9743
    }
9533
9744
}
9534
9745
 
 
9746
#if !defined QTC_QT_ONLY
9535
9747
void QtCurveStyle::setupKde4()
9536
9748
{
9537
 
#ifdef QTC_USE_KDE4
9538
 
    checkKComponentData();
9539
 
    if(!kapp)
 
9749
    if(kapp)
 
9750
        setDecorationColors();
 
9751
    else
9540
9752
    {
9541
9753
        applyKdeSettings(true);
9542
9754
        applyKdeSettings(false);
9543
9755
    }
 
9756
}
 
9757
 
 
9758
void QtCurveStyle::setDecorationColors()
 
9759
{
 
9760
    KColorScheme kcs(QPalette::Active);
 
9761
    if(opts.coloredMouseOver)
 
9762
        shadeColors(kcs.decoration(KColorScheme::HoverColor).color(), itsMouseOverCols);
 
9763
    shadeColors(kcs.decoration(KColorScheme::FocusColor).color(), itsFocusCols);
 
9764
}
 
9765
 
 
9766
void QtCurveStyle::applyKdeSettings(bool pal)
 
9767
{
 
9768
    if(pal)
 
9769
    {
 
9770
        QApplication::setPalette(KGlobalSettings::createApplicationPalette());
 
9771
        setDecorationColors();
 
9772
    }
 
9773
    else
 
9774
    {
 
9775
        QApplication::setFont(KGlobalSettings::generalFont());
 
9776
        QApplication::setFont(KGlobalSettings::menuFont(), "QMenuBar");
 
9777
        QApplication::setFont(KGlobalSettings::menuFont(), "QMenu");
 
9778
        QApplication::setFont(KGlobalSettings::menuFont(), "KPopupTitle");
 
9779
// Don't set toolbar font - messes things up with Arora...
 
9780
//         QApplication::setFont(KGlobalSettings::toolBarFont(), "QToolBar");
 
9781
    }
 
9782
}
9544
9783
#endif
9545
 
}
9546
9784
 
9547
9785
void QtCurveStyle::kdeGlobalSettingsChange(int type, int)
9548
9786
{
9549
 
#ifdef QTC_USE_KDE4
9550
 
    checkKComponentData();
 
9787
#if defined QTC_QT_ONLY
 
9788
    Q_UNUSED(type)
 
9789
#else
9551
9790
    switch(type)
9552
9791
    {
9553
9792
        case KGlobalSettings::PaletteChanged: