File indexing completed on 2024-05-12 05:49:28

0001 /*****************************************************************************
0002  *   Copyright 2007 - 2010 Craig Drummond <craig.p.drummond@gmail.com>       *
0003  *   Copyright 2013 - 2015 Yichao Yu <yyc1992@gmail.com>                     *
0004  *                                                                           *
0005  *   This program is free software; you can redistribute it and/or modify    *
0006  *   it under the terms of the GNU Lesser General Public License as          *
0007  *   published by the Free Software Foundation; either version 2.1 of the    *
0008  *   License, or (at your option) version 3, or any later version accepted   *
0009  *   by the membership of KDE e.V. (or its successor approved by the         *
0010  *   membership of KDE e.V.), which shall act as a proxy defined in          *
0011  *   Section 6 of version 3 of the license.                                  *
0012  *                                                                           *
0013  *   This program is distributed in the hope that it will be useful,         *
0014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
0015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU       *
0016  *   Lesser General Public License for more details.                         *
0017  *                                                                           *
0018  *   You should have received a copy of the GNU Lesser General Public        *
0019  *   License along with this library. If not,                                *
0020  *   see <http://www.gnu.org/licenses/>.                                     *
0021  *****************************************************************************/
0022 #include "config.h"
0023 
0024 #include <qtcurve-utils/dirs.h>
0025 #include <qtcurve-utils/process.h>
0026 
0027 #include "qtcurveconfig.h"
0028 #include <kwinconfig/qtcurvekwinconfig.h>
0029 #ifdef QTC_QT4_STYLE_SUPPORT
0030 #include "exportthemedialog.h"
0031 #endif
0032 #include "imagepropertiesdialog.h"
0033 #include <QCheckBox>
0034 #include <QComboBox>
0035 #include <QGroupBox>
0036 #include <QRadioButton>
0037 #include <QLabel>
0038 #include <QFrame>
0039 #include <QTabWidget>
0040 #include <QFileInfo>
0041 #include <QActionGroup>
0042 #include <QBoxLayout>
0043 #include <QGridLayout>
0044 #include <QTreeWidget>
0045 #include <QPainter>
0046 #include <QSettings>
0047 #include <QDBusConnection>
0048 #include <QDBusMessage>
0049 #include <QTextStream>
0050 #include <QMdiArea>
0051 #include <QMdiSubWindow>
0052 #include <QStyleFactory>
0053 #include <QCloseEvent>
0054 #include <QRegExp>
0055 #include <QRegExpValidator>
0056 #include <QMenu>
0057 #include <KGuiItem>
0058 #include <KInputDialog>
0059 #include <KDE/KLocale>
0060 #include <KDE/KColorButton>
0061 #include <KDE/KConfig>
0062 #include <KDE/KFileDialog>
0063 #include <KDE/KMessageBox>
0064 #include <KDE/KPushButton>
0065 #include <KDE/KCharSelect>
0066 #include <KDE/KDialog>
0067 #include <KDE/KIntNumInput>
0068 #include <KDE/KStandardAction>
0069 #include <KDE/KStatusBar>
0070 #include <KDE/KAboutData>
0071 #include <KDE/KComponentData>
0072 #include <KDE/KActionCollection>
0073 #include <KDE/KToolBar>
0074 #include <KDE/KTemporaryFile>
0075 #include <KDE/KTempDir>
0076 #include <KDE/KZip>
0077 #include <KDE/KMimeType>
0078 #include <KDE/KStandardDirs>
0079 #include <unistd.h>
0080 
0081 #include <style/qtcurve.h>
0082 #include <common/config_file.h>
0083 
0084 #include <mutex>
0085 
0086 #define EXTENSION                  ".qtcurve"
0087 #define VERSION_WITH_KWIN_SETTINGS qtcMakeVersion(1, 5)
0088 
0089 #define THEME_IMAGE_PREFIX "style"
0090 #define BGND_FILE "-bgnd"
0091 #define IMAGE_FILE "-img"
0092 #define MENU_FILE  "-menu"
0093 
0094 extern "C" Q_DECL_EXPORT QObject*
0095 allocate_kstyle_config(QWidget *parent)
0096 {
0097     KGlobal::locale()->insertCatalog("qtcurve");
0098     return new QtCurveConfig(parent);
0099 }
0100 
0101 static QString getExt(const QString &file)
0102 {
0103     int dotPos=file.lastIndexOf('.');
0104 
0105     return dotPos!=-1 ? file.mid(dotPos) : QString();
0106 }
0107 
0108 static inline QString getFileName(const QString &f)
0109 {
0110     return QFileInfo(f).fileName();
0111 }
0112 
0113 static QString getThemeFile(const QString &file)
0114 {
0115     if (file.startsWith(THEME_IMAGE_PREFIX BGND_FILE)) {
0116         QString f(QtCurve::getConfDir() + file);
0117 
0118         if (QFile::exists(f)) {
0119             return f.replace("//", "/");
0120         }
0121     }
0122     if (!file.startsWith("/")) {
0123         QString f(KGlobal::dirs()->saveLocation("data", "QtCurve/") +
0124                   '/' + file);
0125 
0126         if (QFile::exists(f)) {
0127             return f.replace("//", "/");
0128         }
0129     }
0130     return QString(file).replace("//", "/");
0131 }
0132 
0133 static void removeFile(const QString &f)
0134 {
0135     if(QFile::exists(f))
0136         QFile::remove(f);
0137 }
0138 
0139 static void copyFile(const QString &src, const QString &dest)
0140 {
0141     if(QFile::exists(src))
0142     {
0143         // QFile::copy will not overwrite existing files. If destination exists, it needs to be removed first.
0144         removeFile(dest);
0145         QFile::copy(src, dest);
0146     }
0147 }
0148 
0149 static QString installThemeFile(const QString &src, const QString &dest)
0150 {
0151     QString source(getThemeFile(src)),
0152             name(QLatin1String(THEME_IMAGE_PREFIX)+dest+getExt(source)),
0153             destination(QtCurve::getConfDir()+name);
0154 
0155     // printf("INST THM \"%s\" \"%s\"", source.toLatin1().constData(),
0156     //        destination.toLatin1().constData());
0157     if(source!=destination)
0158         copyFile(source, destination);
0159 
0160     return name;
0161 }
0162 
0163 static QString saveThemeFile(const QString &src, const QString &dest, const QString &themeName)
0164 {
0165     QString source(getThemeFile(src)),
0166             destination(KGlobal::dirs()->saveLocation("data", "QtCurve/") +
0167                         themeName + dest + getExt(source));
0168 
0169     // printf("SAVE THM \"%s\" \"%s\"", source.toLatin1().constData(),
0170     //        destination.toLatin1().constData());
0171     if(source!=destination)
0172         copyFile(source, destination);
0173 
0174     return destination;
0175 }
0176 
0177 static void removeInstalledThemeFile(const QString &file)
0178 {
0179     removeFile(QtCurve::getConfDir()+QLatin1String(THEME_IMAGE_PREFIX)+file);
0180 }
0181 
0182 static void
0183 removeThemeImages(const QString &themeFile)
0184 {
0185     QString themeName(getFileName(themeFile).remove(EXTENSION).replace(' ', '_'));
0186     QDir dir(KGlobal::dirs()->saveLocation("data", "QtCurve/"));
0187     foreach (const QString &file, dir.entryList()) {
0188         if (file.startsWith(themeName + BGND_FILE)) {
0189             QFile::remove(dir.path() + "/" + file);
0190         }
0191     }
0192 }
0193 
0194 static void setStyleRecursive(QWidget *w, QStyle *s)
0195 {
0196     if (!w) {
0197         return;
0198     }
0199     w->setStyle(s);
0200     foreach (QObject *child, w->children()) {
0201         if (child && child->isWidgetType()) {
0202             setStyleRecursive((QWidget*)child, s);
0203         }
0204     }
0205 }
0206 
0207 static const KStandardAction::StandardAction standardAction[] =
0208 {
0209     KStandardAction::New, KStandardAction::Open, KStandardAction::OpenRecent, KStandardAction::Save, KStandardAction::SaveAs, KStandardAction::Revert, KStandardAction::Close, KStandardAction::Quit,
0210     KStandardAction::Cut, KStandardAction::Copy, KStandardAction::Paste,
0211     KStandardAction::ActionNone
0212 };
0213 
0214 static QString toString(const QSet<QString> &set)
0215 {
0216     QStringList list=set.toList();
0217 
0218     qSort(list);
0219     return list.join(", ");
0220 }
0221 
0222 static QSet<QString> toSet(const QString &str)
0223 {
0224     QStringList           list=str.simplified().split(QRegExp("\\s*,\\s*"), QString::SkipEmptyParts);
0225     QStringList::Iterator it(list.begin()),
0226                           end(list.end());
0227 
0228     for(; it!=end; ++it)
0229         (*it)=(*it).simplified();
0230 
0231     return QSet<QString>::fromList(list);
0232 }
0233 
0234 CStylePreview::CStylePreview(QWidget *parent)
0235     : KXmlGuiWindow(parent),
0236       m_aboutData(new KAboutData("QtCurve", 0, ki18n("QtCurve"), qtcVersion(),
0237                                  ki18n("Unified widget style."),
0238                                  KAboutData::License_LGPL,
0239                                  ki18n("(C) Craig Drummond, 2003-2011 & "
0240                                        "Yichao Yu, 2013-2015"),
0241                                  KLocalizedString())),
0242       m_componentData(new KComponentData(m_aboutData.get()))
0243 {
0244     m_aboutData->setProgramIconName("preferences-desktop-theme");
0245 
0246     QWidget *main = new QWidget(this);
0247     setObjectName("QtCurvePreview");
0248     setupUi(main);
0249     setCentralWidget(main);
0250     setComponentData(*m_componentData);
0251     for (uint i = 0; standardAction[i] != KStandardAction::ActionNone; ++i)
0252         actionCollection()->addAction(standardAction[i]);
0253     createGUI();
0254     statusBar()->setSizeGripEnabled(true);
0255     toolBar()->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
0256     setCaption(i18n("Preview Window"));
0257     // implement the exclusive nature of the items supposed to be mutually exclusive
0258     // This can still be done in .ui files but would have to be maintained by hand
0259     // as Qt's Designer no longer supports QActionGroups.
0260     QActionGroup *aGroup = new QActionGroup(menu2SubMenu);
0261     aGroup->addAction(exclusiveItem1);
0262     aGroup->addAction(exclusiveItem2);
0263     aGroup->addAction(exclusiveItem3);
0264 }
0265 
0266 CStylePreview::~CStylePreview()
0267 {
0268     // So that the header doesn't have to include the full definition of
0269     // KAboutData and KComponentData
0270 }
0271 
0272 void CStylePreview::closeEvent(QCloseEvent *e)
0273 {
0274     emit closePressed();
0275     e->ignore();
0276 }
0277 
0278 QSize CStylePreview::sizeHint() const
0279 {
0280     return QSize(500, 260);
0281 }
0282 
0283 class CWorkspace : public QMdiArea
0284 {
0285     public:
0286 
0287     CWorkspace(QWidget *parent) : QMdiArea(parent)
0288     {
0289         setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
0290     }
0291 
0292     QSize sizeHint() const
0293     {
0294         return QSize(200, 200);
0295     }
0296 
0297     void paintEvent(QPaintEvent *)
0298     {
0299         QPainter p(viewport());
0300         p.fillRect(rect(), palette().color(backgroundRole()).dark(110));
0301     }
0302 };
0303 
0304 class CharSelectDialog : public KDialog {
0305 public:
0306     CharSelectDialog(QWidget *parent, int v)
0307         : KDialog(parent)
0308     {
0309         setCaption(i18n("Select Password Character"));
0310         setModal(true);
0311         setButtons(KDialog::Ok|KDialog::Cancel);
0312         enableButtonOk(true);
0313         enableButtonCancel(true);
0314 
0315         QFrame *page = new QFrame(this);
0316         setMainWidget(page);
0317 
0318         QBoxLayout *layout = new QBoxLayout(QBoxLayout::TopToBottom, page);
0319         layout->setMargin(0);
0320         layout->setSpacing(KDialog::spacingHint());
0321 
0322         m_selector = new KCharSelect(page, nullptr);
0323         m_selector->setCurrentChar(QChar(v));
0324         layout->addWidget(m_selector);
0325     }
0326 
0327     int
0328     currentChar() const
0329     {
0330         return m_selector->currentChar().unicode();
0331     }
0332 private:
0333     KCharSelect *m_selector;
0334 };
0335 
0336 class CGradItem : public QTreeWidgetItem {
0337 public:
0338     CGradItem(QTreeWidget *p, const QStringList &vals)
0339         : QTreeWidgetItem(p, vals)
0340     {
0341         setFlags(flags()|Qt::ItemIsEditable);
0342     }
0343 
0344     bool
0345     operator<(const QTreeWidgetItem &i) const
0346     {
0347         return (text(0).toDouble() < i.text(0).toDouble() ||
0348                 (qtcEqual(text(0).toDouble(), i.text(0).toDouble()) &&
0349                  (text(1).toDouble()<i.text(1).toDouble() ||
0350                   (qtcEqual(text(1).toDouble(), i.text(1).toDouble()) &&
0351                    (text(2).toDouble()<i.text(2).toDouble())))));
0352     }
0353 };
0354 
0355 static QStringList
0356 toList(const QString &str)
0357 {
0358     QStringList lst;
0359     lst.append(str);
0360     return lst;
0361 }
0362 
0363 class CStackItem : public QTreeWidgetItem {
0364 public:
0365     CStackItem(QTreeWidget *p, const QString &text, int s)
0366         : QTreeWidgetItem(p, toList(text)),
0367           stackId(s)
0368     {
0369         if (s == 0) {
0370             QFont fnt(font(0));
0371 
0372             fnt.setBold(true);
0373             setFont(0, fnt);
0374         }
0375         setTextAlignment(0, Qt::AlignRight);
0376     }
0377 
0378     bool
0379     operator<(const QTreeWidgetItem &o) const
0380     {
0381         return stackId < ((CStackItem&)o).stackId;
0382     }
0383     int
0384     stack()
0385     {
0386         return stackId;
0387     }
0388 private:
0389     int stackId;
0390 };
0391 
0392 CGradientPreview::CGradientPreview(QtCurveConfig *c, QWidget *p)
0393                 : QWidget(p),
0394                   cfg(c),
0395                   style(nullptr)
0396 {
0397     // setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
0398     setObjectName("QtCurveConfigDialog-GradientPreview");
0399 }
0400 
0401 CGradientPreview::~CGradientPreview()
0402 {
0403     delete style;
0404 }
0405 
0406 QSize CGradientPreview::sizeHint() const
0407 {
0408     return QSize(64, 24);
0409 }
0410 
0411 QSize CGradientPreview::minimumSizeHint() const
0412 {
0413     return sizeHint();
0414 }
0415 
0416 void CGradientPreview::paintEvent(QPaintEvent *)
0417 {
0418     QPainter p(this);
0419 
0420     if(!style)
0421         style=QStyleFactory::create("qtcurve");
0422 
0423     if(style)
0424     {
0425         QtCurve::Style::PreviewOption styleOpt;
0426 
0427         styleOpt.init(this);
0428 
0429         cfg->setOptions(styleOpt.opts);
0430         styleOpt.opts.appearance=APPEARANCE_CUSTOM1;
0431         styleOpt.opts.customGradient[APPEARANCE_CUSTOM1]=grad;
0432         styleOpt.palette.setColor(QPalette::Button, color);
0433         styleOpt.state|=QStyle::State_Raised;
0434         style->drawControl((QStyle::ControlElement)QtCurve::Style::CE_QtC_Preview, &styleOpt, &p, this);
0435     }
0436     p.end();
0437 }
0438 
0439 void CGradientPreview::setGrad(const Gradient &g)
0440 {
0441     grad=g;
0442     repaint();
0443 }
0444 
0445 void CGradientPreview::setColor(const QColor &col)
0446 {
0447     if(col!=color)
0448     {
0449         color=col;
0450         repaint();
0451     }
0452 }
0453 
0454 static QString readEnvPath(const char *env)
0455 {
0456    const char *path=getenv(env);
0457 
0458    return path ? QFile::decodeName(path) : QString::null;
0459 }
0460 
0461 static QString
0462 kdeHome(bool kde3)
0463 {
0464     static QString kdeHome[2];
0465 
0466     // Execute kde-config to ascertain users KDEHOME
0467     if (kdeHome[kde3 ? 0 : 1].isEmpty()) {
0468         size_t len = 0;
0469         const char *kde_config = kde3 ? "kde-config" : "kde4-config";
0470         const char *const argv[] = {kde_config, "--localprefix", nullptr};
0471         char *res = qtcPopenStdout(kde_config, argv, 300, &len);
0472         if (res) {
0473             res[len] = '\0';
0474             kdeHome[kde3 ? 0 : 1] = QFile::decodeName(res).replace("\n", "");
0475             free(res);
0476         }
0477     }
0478 
0479     // Try env vars...
0480     if (kdeHome[kde3 ? 0 : 1].isEmpty()) {
0481         kdeHome[kde3 ? 0 : 1] = readEnvPath(getuid() ? "KDEHOME" : "KDEROOTHOME");
0482         if (kdeHome[kde3 ? 0 : 1].isEmpty()) {
0483             QDir homeDir(QDir::homePath());
0484             QString kdeConfDir("/.kde");
0485             if (!kde3 && homeDir.exists(".kde4"))
0486                 kdeConfDir = QString("/.kde4");
0487             kdeHome[kde3 ? 0 : 1] = QDir::homePath() + kdeConfDir;
0488         }
0489     }
0490     return kdeHome[kde3 ? 0 : 1];
0491 }
0492 
0493 static int toInt(const QString &str)
0494 {
0495     return str.length()>1 ? str[0].unicode() : 0;
0496 }
0497 
0498 static int getHideFlags(const QCheckBox *kbd, const QCheckBox *kwin)
0499 {
0500     return (kbd->isChecked() ? HIDE_KEYBOARD : HIDE_NONE)+
0501            (kwin->isChecked() ? HIDE_KWIN : HIDE_NONE);
0502 }
0503 
0504 enum ShadeWidget
0505 {
0506     SW_MENUBAR,
0507     SW_SLIDER,
0508     SW_CHECK_RADIO,
0509     SW_MENU_STRIPE,
0510     SW_COMBO,
0511     SW_LV_HEADER,
0512     SW_CR_BGND,
0513     SW_PROGRESS
0514 };
0515 
0516 static QString uiString(EShade shade, ShadeWidget sw)
0517 {
0518     switch(shade)
0519     {
0520         case SHADE_NONE:
0521             switch(sw)
0522             {
0523                 case SW_MENUBAR:
0524                 case SW_PROGRESS:
0525                     return i18n("Background");
0526                 case SW_COMBO:
0527                 case SW_SLIDER:
0528                     return i18n("Button");
0529                 case SW_CHECK_RADIO:
0530                     return i18n("Text");
0531                 case SW_CR_BGND:
0532                 case SW_LV_HEADER:
0533                 case SW_MENU_STRIPE:
0534                     return i18n("None");
0535             }
0536         default:
0537             return i18n("<unknown>");
0538         case SHADE_CUSTOM:
0539             return i18n("Custom:");
0540         case SHADE_SELECTED:
0541             return i18n("Selected background");
0542         case SHADE_BLEND_SELECTED:
0543             return i18n("Blended selected background");
0544         case SHADE_DARKEN:
0545             return SW_MENU_STRIPE==sw ? i18n("Menu background") : i18n("Darken");
0546         case SHADE_WINDOW_BORDER:
0547             return i18n("Titlebar");
0548     }
0549 }
0550 
0551 static void insertShadeEntries(QComboBox *combo, ShadeWidget sw)
0552 {
0553     combo->insertItem(SHADE_NONE, uiString(SHADE_NONE, sw));
0554     combo->insertItem(SHADE_CUSTOM, uiString(SHADE_CUSTOM, sw));
0555     combo->insertItem(SHADE_SELECTED, uiString(SHADE_SELECTED, sw));
0556     if(SW_CHECK_RADIO!=sw) // For check/radio, we dont blend, and dont allow darken
0557     {
0558         combo->insertItem(SHADE_BLEND_SELECTED, uiString(SHADE_BLEND_SELECTED, sw));
0559         if(SW_PROGRESS!=sw)
0560             combo->insertItem(SHADE_DARKEN, uiString(SHADE_DARKEN, sw));
0561     }
0562     if(SW_MENUBAR==sw)
0563         combo->insertItem(SHADE_WINDOW_BORDER, uiString(SHADE_WINDOW_BORDER, sw));
0564 }
0565 
0566 static QString uiString(EAppearance app, EAppAllow allow=APP_ALLOW_BASIC, bool sameAsApp=false)
0567 {
0568     if(app>=APPEARANCE_CUSTOM1 && app<(APPEARANCE_CUSTOM1+NUM_CUSTOM_GRAD))
0569         return i18n("Custom gradient %1", (app-APPEARANCE_CUSTOM1)+1);
0570 
0571     switch(app)
0572     {
0573         case APPEARANCE_FLAT: return i18n("Flat");
0574         case APPEARANCE_RAISED: return i18n("Raised");
0575         case APPEARANCE_DULL_GLASS: return i18n("Dull glass");
0576         case APPEARANCE_SHINY_GLASS: return i18n("Shiny glass");
0577         case APPEARANCE_AGUA: return i18n("Agua");
0578         case APPEARANCE_SOFT_GRADIENT: return i18n("Soft gradient");
0579         case APPEARANCE_GRADIENT: return i18n("Standard gradient");
0580         case APPEARANCE_HARSH_GRADIENT: return i18n("Harsh gradient");
0581         case APPEARANCE_INVERTED: return i18n("Inverted gradient");
0582         case APPEARANCE_DARK_INVERTED: return i18n("Dark inverted gradient");
0583         case APPEARANCE_SPLIT_GRADIENT: return i18n("Split gradient");
0584         case APPEARANCE_BEVELLED: return i18n("Bevelled");
0585         case APPEARANCE_FADE:
0586             switch(allow)
0587             {
0588                 case APP_ALLOW_FADE:
0589                     return i18n("Fade out (popup menuitems)");
0590                 case APP_ALLOW_STRIPED:
0591                     return i18n("Striped");
0592                 default:
0593                 case APP_ALLOW_NONE:
0594                     return sameAsApp ? i18n("Same as general setting") : i18n("None");
0595             }
0596         case APPEARANCE_FILE:
0597             return i18n("Tiled image");
0598         default:
0599             return i18n("<unknown>");
0600     }
0601 }
0602 
0603 static void insertAppearanceEntries(QComboBox *combo, EAppAllow allow=APP_ALLOW_BASIC, bool sameAsApp=false)
0604 {
0605     int max=APP_ALLOW_BASIC==allow
0606                 ? APPEARANCE_FADE
0607                 : APP_ALLOW_STRIPED==allow
0608                     ? APPEARANCE_FADE+2
0609                     : APPEARANCE_FADE+1;
0610 
0611     for(int i=APPEARANCE_CUSTOM1; i<max; ++i)
0612         combo->insertItem(i, uiString((EAppearance)i, allow, sameAsApp));
0613 }
0614 
0615 static void insertLineEntries(QComboBox *combo,  bool singleDot, bool dashes)
0616 {
0617     combo->insertItem(LINE_NONE, i18n("None"));
0618     combo->insertItem(LINE_SUNKEN, i18n("Sunken lines"));
0619     combo->insertItem(LINE_FLAT, i18n("Flat lines"));
0620     combo->insertItem(LINE_DOTS, i18n("Dots"));
0621     if(singleDot)
0622     {
0623         combo->insertItem(LINE_1DOT, i18n("Single dot"));
0624         if(dashes)
0625             combo->insertItem(LINE_DASHES, i18n("Dashes"));
0626     }
0627 }
0628 
0629 static void insertDefBtnEntries(QComboBox *combo)
0630 {
0631     combo->insertItem(IND_CORNER, i18n("Corner indicator"));
0632     combo->insertItem(IND_FONT_COLOR, i18n("Font color thin border"));
0633     combo->insertItem(IND_COLORED, i18n("Selected background thick border"));
0634     combo->insertItem(IND_TINT, i18n("Selected background tinting"));
0635     combo->insertItem(IND_GLOW, i18n("A slight glow"));
0636     combo->insertItem(IND_DARKEN, i18n("Darken"));
0637     combo->insertItem(IND_SELECTED, i18n("Use selected background color"));
0638     combo->insertItem(IND_NONE, i18n("No indicator"));
0639 }
0640 
0641 static void insertScrollbarEntries(QComboBox *combo)
0642 {
0643     combo->insertItem(SCROLLBAR_KDE, i18n("KDE"));
0644     combo->insertItem(SCROLLBAR_WINDOWS, i18n("MS Windows"));
0645     combo->insertItem(SCROLLBAR_PLATINUM, i18n("Platinum"));
0646     combo->insertItem(SCROLLBAR_NEXT, i18n("NeXT"));
0647     combo->insertItem(SCROLLBAR_NONE, i18n("No buttons"));
0648 }
0649 
0650 static void insertRoundEntries(QComboBox *combo)
0651 {
0652     combo->insertItem(ROUND_NONE, i18n("Square"));
0653     combo->insertItem(ROUND_SLIGHT, i18n("Slightly rounded"));
0654     combo->insertItem(ROUND_FULL, i18n("Fully rounded"));
0655     combo->insertItem(ROUND_EXTRA, i18n("Extra rounded"));
0656     combo->insertItem(ROUND_MAX, i18n("Max rounded"));
0657 }
0658 
0659 static void insertMouseOverEntries(QComboBox *combo)
0660 {
0661     combo->insertItem(MO_NONE, i18n("No coloration"));
0662     combo->insertItem(MO_COLORED, i18n("Color border"));
0663     combo->insertItem(MO_COLORED_THICK, i18n("Thick color border"));
0664     combo->insertItem(MO_PLASTIK, i18n("Plastik style"));
0665     combo->insertItem(MO_GLOW, i18n("Glow"));
0666 }
0667 
0668 static void insertToolbarBorderEntries(QComboBox *combo)
0669 {
0670     combo->insertItem(TB_NONE, i18n("None"));
0671     combo->insertItem(TB_LIGHT, i18n("Light"));
0672     combo->insertItem(TB_DARK, i18n("Dark"));
0673     combo->insertItem(TB_LIGHT_ALL, i18n("Light (all sides)"));
0674     combo->insertItem(TB_DARK_ALL, i18n("Dark (all sides)"));
0675 }
0676 
0677 static void insertEffectEntries(QComboBox *combo, bool sameAsApp=false)
0678 {
0679     combo->insertItem(EFFECT_NONE, sameAsApp ? i18n("Same as general setting") : i18n("Plain"));
0680     combo->insertItem(EFFECT_ETCH, i18n("Etched"));
0681     combo->insertItem(EFFECT_SHADOW, i18n("Shadowed"));
0682 }
0683 
0684 static void insertShadingEntries(QComboBox *combo)
0685 {
0686     combo->insertItem(int(Shading::Simple), i18n("Simple"));
0687     combo->insertItem(int(Shading::HSL), i18n("Use HSL color space"));
0688     combo->insertItem(int(Shading::HSV), i18n("Use HSV color space"));
0689     combo->insertItem(int(Shading::HCY), i18n("Use HCY color space"));
0690 }
0691 
0692 static void insertStripeEntries(QComboBox *combo)
0693 {
0694     combo->insertItem(STRIPE_NONE, i18n("Plain"));
0695     combo->insertItem(STRIPE_PLAIN, i18n("Stripes"));
0696     combo->insertItem(STRIPE_DIAGONAL, i18n("Diagonal stripes"));
0697     combo->insertItem(STRIPE_FADE, i18n("Faded stripes"));
0698 }
0699 
0700 static void insertSliderStyleEntries(QComboBox *combo)
0701 {
0702     combo->insertItem(SLIDER_PLAIN, i18n("Plain"));
0703     combo->insertItem(SLIDER_ROUND, i18n("Round"));
0704     combo->insertItem(SLIDER_PLAIN_ROTATED, i18n("Plain - rotated"));
0705     combo->insertItem(SLIDER_ROUND_ROTATED, i18n("Round - rotated"));
0706     combo->insertItem(SLIDER_TRIANGULAR, i18n("Triangular"));
0707     combo->insertItem(SLIDER_CIRCULAR, i18n("Circular"));
0708 }
0709 
0710 static void insertEColorEntries(QComboBox *combo)
0711 {
0712     combo->insertItem(ECOLOR_BASE, i18n("Base color"));
0713     combo->insertItem(ECOLOR_BACKGROUND, i18n("Background color"));
0714     combo->insertItem(ECOLOR_DARK, i18n("Darkened background color"));
0715 }
0716 
0717 static void insertFocusEntries(QComboBox *combo)
0718 {
0719     combo->insertItem(FOCUS_STANDARD, i18n("Standard (dotted)"));
0720     combo->insertItem(FOCUS_RECTANGLE, i18n("Highlight color"));
0721     combo->insertItem(FOCUS_FULL, i18n("Highlight color (full size)"));
0722     combo->insertItem(FOCUS_FILLED, i18n("Highlight color, and fill"));
0723     combo->insertItem(FOCUS_LINE, i18n("Line drawn with highlight color"));
0724     combo->insertItem(FOCUS_GLOW, i18n("Glow"));
0725     combo->insertItem(FOCUS_NONE, i18n("Nothing"));
0726 }
0727 
0728 static void insertGradBorderEntries(QComboBox *combo)
0729 {
0730     combo->insertItem(GB_NONE, i18n("No border"));
0731     combo->insertItem(GB_LIGHT, i18n("Light border"));
0732     combo->insertItem(GB_3D, i18n("3D border (light only)"));
0733     combo->insertItem(GB_3D_FULL, i18n("3D border (dark and light)"));
0734     combo->insertItem(GB_SHINE, i18n("Shine"));
0735 }
0736 
0737 static void insertAlignEntries(QComboBox *combo)
0738 {
0739     combo->insertItem(ALIGN_LEFT, i18n("Left"));
0740     combo->insertItem(ALIGN_CENTER, i18n("Center (between controls)"));
0741     combo->insertItem(ALIGN_FULL_CENTER, i18n("Center (full width)"));
0742     combo->insertItem(ALIGN_RIGHT, i18n("Right"));
0743 }
0744 
0745 enum ETitleBarButtonColoration
0746 {
0747     TITLE_BTN_COL_BACKGROUND,
0748     TITLE_BTN_COL_BUTTON,
0749     TITLE_BTN_COL_CUSTOM
0750 };
0751 
0752 static void insertTitlebarIconEntries(QComboBox *combo)
0753 {
0754     combo->insertItem(TITLEBAR_ICON_NONE, i18n("Do not show"));
0755     combo->insertItem(TITLEBAR_ICON_MENU_BUTTON, i18n("Place on menu button"));
0756     combo->insertItem(TITLEBAR_ICON_NEXT_TO_TITLE, i18n("Place next to title"));
0757 }
0758 
0759 static void insertTabMoEntries(QComboBox *combo)
0760 {
0761     combo->insertItem(TAB_MO_TOP, i18n("Highlight on top"));
0762     combo->insertItem(TAB_MO_BOTTOM, i18n("Highlight on bottom"));
0763     combo->insertItem(TAB_MO_GLOW, i18n("Add a slight glow"));
0764 }
0765 
0766 static void insertGradTypeEntries(QComboBox *combo)
0767 {
0768     combo->insertItem(GT_HORIZ, i18n("Top to bottom"));
0769     combo->insertItem(GT_VERT, i18n("Left to right"));
0770 }
0771 
0772 #if 0
0773 static void insertLvLinesEntries(QComboBox *combo)
0774 {
0775     combo->insertItem(LV_NONE, i18n("None"));
0776     combo->insertItem(LV_NEW, i18n("New style (KDE and Gtk2 similar)"));
0777     combo->insertItem(LV_OLD, i18n("Old style (KDE and Gtk2 different)"));
0778 }
0779 #endif
0780 
0781 static void insertImageEntries(QComboBox *combo)
0782 {
0783     combo->insertItem(IMG_NONE, i18n("None"));
0784     combo->insertItem(IMG_BORDERED_RINGS, i18n("Bordered rings"));
0785     combo->insertItem(IMG_PLAIN_RINGS, i18n("Plain rings"));
0786     combo->insertItem(IMG_SQUARE_RINGS, i18n("Square rings"));
0787     combo->insertItem(IMG_FILE, i18n("File"));
0788 }
0789 
0790 static void insertGlowEntries(QComboBox *combo)
0791 {
0792     combo->insertItem(GLOW_NONE, i18n("No glow"));
0793     combo->insertItem(GLOW_START, i18n("Add glow at the start"));
0794     combo->insertItem(GLOW_MIDDLE, i18n("Add glow in the middle"));
0795     combo->insertItem(GLOW_END, i18n("Add glow at the end"));
0796 }
0797 
0798 static void insertCrSizeEntries(QComboBox *combo)
0799 {
0800     combo->insertItem(0, i18n("Small (%1 pixels)", CR_SMALL_SIZE));
0801     combo->insertItem(1, i18n("Large (%1 pixels)", CR_LARGE_SIZE));
0802 }
0803 
0804 static void setCrSize(QComboBox *combo, int size)
0805 {
0806     combo->setCurrentIndex(CR_SMALL_SIZE==size ? 0 : 1);
0807 }
0808 
0809 static int getCrSize(QComboBox *combo)
0810 {
0811     return 0==combo->currentIndex() ? CR_SMALL_SIZE : CR_LARGE_SIZE;
0812 }
0813 
0814 static void insertDragEntries(QComboBox *combo)
0815 {
0816     combo->insertItem(WM_DRAG_NONE, i18n("Titlebar only"));
0817     combo->insertItem(WM_DRAG_MENUBAR, i18n("Titlebar and menubar"));
0818     combo->insertItem(WM_DRAG_MENU_AND_TOOLBAR, i18n("Titlebar, menubar, and toolbars"));
0819     combo->insertItem(WM_DRAG_ALL, i18n("All empty areas"));
0820 }
0821 
0822 
0823 static void insertFrameEntries(QComboBox *combo)
0824 {
0825     combo->insertItem(FRAME_NONE, i18n("No border"));
0826     combo->insertItem(FRAME_PLAIN, i18n("Standard frame border"));
0827     combo->insertItem(FRAME_LINE, i18n("Single separator line"));
0828     combo->insertItem(FRAME_SHADED, i18n("Shaded background"));
0829     combo->insertItem(FRAME_FADED, i18n("Faded background"));
0830 }
0831 
0832 enum EGBLabelVPos
0833 {
0834     GBV_OUTSIDE,
0835     GBV_STANDARD,
0836     GBV_INSIDE
0837 };
0838 
0839 static void insertGbLabelEntries(QComboBox *combo)
0840 {
0841     combo->insertItem(GBV_OUTSIDE, i18n("Outside frame"));
0842     combo->insertItem(GBV_STANDARD, i18n("On frame"));
0843     combo->insertItem(GBV_INSIDE, i18n("Inside frame"));
0844 }
0845 
0846 static void insertTBarBtnEntries(QComboBox *combo)
0847 {
0848     combo->insertItem(TBTN_STANDARD, i18n("Standard (auto-raise)"));
0849     combo->insertItem(TBTN_RAISED, i18n("Raised"));
0850     combo->insertItem(TBTN_JOINED, i18n("Raised and joined"));
0851 }
0852 
0853 QtCurveConfig::QtCurveConfig(QWidget *parent)
0854              : QWidget(parent),
0855                workSpace(nullptr),
0856                stylePreview(nullptr),
0857                mdiWindow(nullptr),
0858 #ifdef QTC_QT4_STYLE_SUPPORT
0859                exportDialog(nullptr),
0860 #endif
0861                gradPreview(nullptr),
0862                readyForPreview(false)
0863 {
0864     setupUi(this);
0865     setObjectName("QtCurveConfigDialog");
0866     titleLabel->setText(QString("QtCurve %1 - (C) Craig Drummond, 2003-2010 & "
0867                                 "Yichao Yu, 2013-2015").arg(qtcVersion()));
0868     insertShadeEntries(shadeSliders, SW_SLIDER);
0869     insertShadeEntries(shadeMenubars, SW_MENUBAR);
0870     insertShadeEntries(shadeCheckRadio, SW_CHECK_RADIO);
0871     insertShadeEntries(menuStripe, SW_MENU_STRIPE);
0872     insertShadeEntries(comboBtn, SW_COMBO);
0873     insertShadeEntries(sortedLv, SW_LV_HEADER);
0874     insertShadeEntries(crColor, SW_CR_BGND);
0875     insertShadeEntries(progressColor, SW_PROGRESS);
0876     insertAppearanceEntries(appearance);
0877     insertAppearanceEntries(menubarAppearance);
0878     insertAppearanceEntries(toolbarAppearance);
0879     insertAppearanceEntries(lvAppearance);
0880     insertAppearanceEntries(sliderAppearance);
0881     insertAppearanceEntries(tabAppearance);
0882     insertAppearanceEntries(activeTabAppearance);
0883     insertAppearanceEntries(progressAppearance);
0884     insertAppearanceEntries(progressGrooveAppearance);
0885     insertAppearanceEntries(grooveAppearance);
0886     insertAppearanceEntries(sunkenAppearance);
0887     insertAppearanceEntries(menuitemAppearance, APP_ALLOW_FADE);
0888     insertAppearanceEntries(menuBgndAppearance, APP_ALLOW_STRIPED);
0889     insertAppearanceEntries(titlebarAppearance, APP_ALLOW_NONE);
0890     insertAppearanceEntries(inactiveTitlebarAppearance, APP_ALLOW_NONE);
0891     insertAppearanceEntries(titlebarButtonAppearance);
0892     insertAppearanceEntries(selectionAppearance);
0893     insertAppearanceEntries(menuStripeAppearance);
0894     insertAppearanceEntries(sbarBgndAppearance);
0895     insertAppearanceEntries(sliderFill);
0896     insertAppearanceEntries(bgndAppearance, APP_ALLOW_STRIPED);
0897     insertAppearanceEntries(dwtAppearance);
0898     insertAppearanceEntries(tooltipAppearance);
0899     insertAppearanceEntries(tbarBtnAppearance, APP_ALLOW_NONE, true);
0900     insertLineEntries(handles, true, true);
0901     insertLineEntries(sliderThumbs, true, false);
0902     insertLineEntries(toolbarSeparators, false, false);
0903     insertLineEntries(splitters, true, true);
0904     insertDefBtnEntries(defBtnIndicator);
0905     insertScrollbarEntries(scrollbarType);
0906     insertRoundEntries(round);
0907     insertMouseOverEntries(coloredMouseOver);
0908     insertToolbarBorderEntries(toolbarBorders);
0909     insertEffectEntries(buttonEffect);
0910     insertEffectEntries(tbarBtnEffect, true);
0911     insertShadingEntries(shading);
0912     insertStripeEntries(stripedProgress);
0913     insertSliderStyleEntries(sliderStyle);
0914     insertEColorEntries(progressGrooveColor);
0915     insertFocusEntries(focus);
0916     insertGradBorderEntries(gradBorder);
0917     insertAlignEntries(titlebarAlignment);
0918     insertEffectEntries(titlebarEffect);
0919     insertTitlebarIconEntries(titlebarIcon);
0920     insertTabMoEntries(tabMouseOver);
0921     insertGradTypeEntries(bgndGrad);
0922     insertGradTypeEntries(menuBgndGrad);
0923     //insertLvLinesEntries(lvLines);
0924     insertImageEntries(bgndImage);
0925     insertImageEntries(menuBgndImage);
0926     insertGlowEntries(glowProgress);
0927     insertCrSizeEntries(crSize);
0928     insertDragEntries(windowDrag);
0929     insertFrameEntries(groupBox);
0930     insertGbLabelEntries(gbLabel_textPos);
0931     insertTBarBtnEntries(tbarBtns);
0932 
0933     highlightFactor->setRange(MIN_HIGHLIGHT_FACTOR, MAX_HIGHLIGHT_FACTOR);
0934     highlightFactor->setValue(DEFAULT_HIGHLIGHT_FACTOR);
0935 
0936     crHighlight->setRange(MIN_HIGHLIGHT_FACTOR, MAX_HIGHLIGHT_FACTOR);
0937     crHighlight->setValue(DEFAULT_CR_HIGHLIGHT_FACTOR);
0938 
0939     splitterHighlight->setRange(MIN_HIGHLIGHT_FACTOR, MAX_HIGHLIGHT_FACTOR);
0940     splitterHighlight->setValue(DEFAULT_SPLITTER_HIGHLIGHT_FACTOR);
0941 
0942     lighterPopupMenuBgnd->setRange(MIN_LIGHTER_POPUP_MENU, MAX_LIGHTER_POPUP_MENU);
0943     lighterPopupMenuBgnd->setValue(DEF_POPUPMENU_LIGHT_FACTOR);
0944 
0945     expanderHighlight->setRange(MIN_HIGHLIGHT_FACTOR, MAX_HIGHLIGHT_FACTOR);
0946     expanderHighlight->setValue(DEFAULT_EXPANDER_HIGHLIGHT_FACTOR);
0947 
0948     menuDelay->setRange(MIN_MENU_DELAY, MAX_MENU_DELAY);
0949     menuDelay->setValue(DEFAULT_MENU_DELAY);
0950 
0951     menuCloseDelay->setRange(MIN_MENU_CLOSE_DELAY, MAX_MENU_CLOSE_DELAY);
0952     menuCloseDelay->setValue(DEFAULT_MENU_CLOSE_DELAY);
0953 
0954     gbFactor->setRange(MIN_GB_FACTOR, MAX_GB_FACTOR);
0955     gbFactor->setValue(DEF_GB_FACTOR);
0956 
0957     bgndOpacity->setRange(0, 100, 5);
0958     bgndOpacity->setValue(100);
0959     dlgOpacity->setRange(0, 100, 5);
0960     dlgOpacity->setValue(100);
0961     menuBgndOpacity->setRange(0, 100, 5);
0962     menuBgndOpacity->setValue(100);
0963     dropShadowSize->setRange(0, 100);
0964     dropShadowSize->setSingleStep(1);
0965     dropShadowSize->setValue(qtcX11ShadowSize());
0966 #ifndef QTC_ENABLE_X11
0967     dropShadowSize->setEnabled(false);
0968 #endif
0969 
0970     sliderWidth->setRange(MIN_SLIDER_WIDTH, MAX_SLIDER_WIDTH, 2);
0971     sliderWidth->setValue(DEFAULT_SLIDER_WIDTH);
0972     sliderWidth->setSuffix(i18n(" pixels"));
0973 
0974     tabBgnd->setRange(MIN_TAB_BGND, MAX_TAB_BGND);
0975     tabBgnd->setValue(DEF_TAB_BGND);
0976 
0977     colorSelTab->setRange(MIN_COLOR_SEL_TAB_FACTOR, MAX_COLOR_SEL_TAB_FACTOR);
0978     colorSelTab->setValue(DEF_COLOR_SEL_TAB_FACTOR);
0979 
0980     stopPosition->setValue(0);
0981     stopValue->setValue(100);
0982     stopAlpha->setValue(100);
0983 
0984     bgndPixmapDlg=new CImagePropertiesDialog(i18n("Background"), this, CImagePropertiesDialog::BASIC);
0985     menuBgndPixmapDlg=new CImagePropertiesDialog(i18n("Menu Background"), this, CImagePropertiesDialog::BASIC);
0986     bgndImageDlg=new CImagePropertiesDialog(i18n("Background Image"), this,
0987                                             CImagePropertiesDialog::POS|
0988                                             CImagePropertiesDialog::SCALE|
0989                                             CImagePropertiesDialog::BORDER);
0990     menuBgndImageDlg=new CImagePropertiesDialog(i18n("Menu Image"), this,
0991                                                 CImagePropertiesDialog::POS|
0992                                                 CImagePropertiesDialog::SCALE);
0993 
0994     connect(lighterPopupMenuBgnd, SIGNAL(valueChanged(int)), SLOT(updateChanged()));
0995     connect(tabBgnd, SIGNAL(valueChanged(int)), SLOT(updateChanged()));
0996     connect(menuDelay, SIGNAL(valueChanged(int)), SLOT(updateChanged()));
0997     connect(menuCloseDelay, SIGNAL(valueChanged(int)), SLOT(updateChanged()));
0998     connect(sliderWidth, SIGNAL(valueChanged(int)), SLOT(sliderWidthChanged()));
0999     connect(menuStripe, SIGNAL(currentIndexChanged(int)), SLOT(menuStripeChanged()));
1000     connect(customMenuStripeColor, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1001     connect(menuStripeAppearance, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1002     connect(bgndGrad, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1003     connect(menuBgndGrad, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1004     connect(round, SIGNAL(currentIndexChanged(int)), SLOT(roundChanged()));
1005     connect(toolbarBorders, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1006     connect(sliderThumbs, SIGNAL(currentIndexChanged(int)), SLOT(sliderThumbChanged()));
1007     connect(handles, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1008     connect(appearance, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1009     connect(customMenuTextColor, SIGNAL(toggled(bool)), SLOT(customMenuTextColorChanged()));
1010     connect(stripedProgress, SIGNAL(currentIndexChanged(int)), SLOT(stripedProgressChanged()));
1011     connect(animatedProgress, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1012     connect(embolden, SIGNAL(toggled(bool)), SLOT(emboldenToggled()));
1013     connect(defBtnIndicator, SIGNAL(currentIndexChanged(int)), SLOT(defBtnIndicatorChanged()));
1014     connect(highlightTab, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1015     connect(menubarAppearance, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1016     connect(toolbarAppearance, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1017     connect(lvAppearance, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1018     connect(sliderAppearance, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1019     connect(tabAppearance, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1020     connect(activeTabAppearance, SIGNAL(currentIndexChanged(int)), SLOT(activeTabAppearanceChanged()));
1021     connect(toolbarSeparators, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1022     connect(splitters, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1023     connect(fillSlider, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1024     connect(stripedSbar, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1025     connect(sliderStyle, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1026     connect(roundMbTopOnly, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1027     connect(menubarHiding_keyboard, SIGNAL(toggled(bool)), SLOT(menubarHidingChanged()));
1028     connect(menubarHiding_kwin, SIGNAL(toggled(bool)), SLOT(menubarHidingChanged()));
1029     connect(statusbarHiding_keyboard, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1030     connect(statusbarHiding_kwin, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1031     connect(glowProgress, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1032     connect(darkerBorders, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1033     connect(comboSplitter, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1034     connect(comboBtn, SIGNAL(currentIndexChanged(int)), SLOT(comboBtnChanged()));
1035     connect(sortedLv, SIGNAL(currentIndexChanged(int)), SLOT(sortedLvChanged()));
1036     connect(customComboBtnColor, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1037     connect(customSortedLvColor, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1038     connect(unifySpinBtns, SIGNAL(toggled(bool)), SLOT(unifySpinBtnsToggled()));
1039     connect(unifySpin, SIGNAL(toggled(bool)), SLOT(unifySpinToggled()));
1040     connect(unifyCombo, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1041     connect(vArrows, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1042     connect(xCheck, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1043     connect(crHighlight, SIGNAL(valueChanged(int)), SLOT(updateChanged()));
1044     connect(expanderHighlight, SIGNAL(valueChanged(int)), SLOT(updateChanged()));
1045     connect(crButton, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1046     connect(crSize, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1047     connect(colorSelTab, SIGNAL(valueChanged(int)), SLOT(updateChanged()));
1048     connect(roundAllTabs, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1049     connect(borderTab, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1050     connect(borderInactiveTab, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1051     connect(invertBotTab, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1052     connect(doubleGtkComboArrow, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1053     connect(tabMouseOver, SIGNAL(currentIndexChanged(int)), SLOT(tabMoChanged()));
1054     connect(stdSidebarButtons, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1055     connect(toolbarTabs, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1056     connect(centerTabText, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1057     connect(borderMenuitems, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1058     connect(shadePopupMenu, SIGNAL(toggled(bool)), SLOT(shadePopupMenuChanged()));
1059     connect(popupBorder, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1060     connect(progressAppearance, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1061     connect(progressColor, SIGNAL(currentIndexChanged(int)), SLOT(progressColorChanged()));
1062     connect(customProgressColor, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1063     connect(progressGrooveAppearance, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1064     connect(grooveAppearance, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1065     connect(sunkenAppearance, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1066     connect(progressGrooveColor, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1067     connect(menuitemAppearance, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1068     connect(menuBgndAppearance, SIGNAL(currentIndexChanged(int)), SLOT(menuBgndAppearanceChanged()));
1069     connect(titlebarAppearance, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1070     connect(inactiveTitlebarAppearance, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1071     connect(titlebarButtonAppearance, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1072     connect(windowBorder_colorTitlebarOnly, SIGNAL(toggled(bool)), SLOT(windowBorder_colorTitlebarOnlyChanged()));
1073     connect(windowBorder_blend, SIGNAL(toggled(bool)), SLOT(windowBorder_blendChanged()));
1074     connect(windowBorder_fill, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1075     connect(windowBorder_menuColor, SIGNAL(toggled(bool)), SLOT(windowBorder_menuColorChanged()));
1076     connect(windowBorder_separator, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1077     connect(selectionAppearance, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1078     connect(shadeCheckRadio, SIGNAL(currentIndexChanged(int)), SLOT(shadeCheckRadioChanged()));
1079     connect(customCheckRadioColor, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1080     connect(focus, SIGNAL(currentIndexChanged(int)), SLOT(focusChanged()));
1081     connect(lvLines, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1082     connect(lvButton, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1083     connect(drawStatusBarFrames, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1084     connect(buttonEffect, SIGNAL(currentIndexChanged(int)), SLOT(buttonEffectChanged()));
1085     connect(coloredMouseOver, SIGNAL(currentIndexChanged(int)), SLOT(coloredMouseOverChanged()));
1086     connect(menubarMouseOver, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1087     connect(shadeMenubarOnlyWhenActive, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1088     connect(thin_menuitems, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1089     connect(thin_buttons, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1090     connect(thin_frames, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1091     connect(hideShortcutUnderline, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1092     connect(customSlidersColor, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1093     connect(customMenubarsColor, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1094     connect(customMenuSelTextColor, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1095     connect(customMenuNormTextColor, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1096     connect(shadeSliders, SIGNAL(currentIndexChanged(int)), SLOT(shadeSlidersChanged()));
1097     connect(shadeMenubars, SIGNAL(currentIndexChanged(int)), SLOT(shadeMenubarsChanged()));
1098     connect(highlightFactor, SIGNAL(valueChanged(int)), SLOT(updateChanged()));
1099     connect(scrollbarType, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1100     connect(shading, SIGNAL(currentIndexChanged(int)), SLOT(shadingChanged()));
1101     connect(gtkScrollViews, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1102     connect(highlightScrollViews, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1103     connect(etchEntry, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1104     connect(flatSbarButtons, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1105     connect(borderSbarGroove, SIGNAL(toggled(bool)), SLOT(borderSbarGrooveChanged()));
1106     connect(thinSbarGroove, SIGNAL(toggled(bool)), SLOT(thinSbarGrooveChanged()));
1107     connect(colorSliderMouseOver, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1108     connect(windowBorder_addLightBorder, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1109     connect(windowDrag, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1110     connect(sbarBgndAppearance, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1111     connect(sliderFill, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1112     connect(bgndAppearance, SIGNAL(currentIndexChanged(int)), SLOT(bgndAppearanceChanged()));
1113     connect(bgndImage, SIGNAL(currentIndexChanged(int)), SLOT(bgndImageChanged()));
1114     connect(bgndOpacity, SIGNAL(valueChanged(int)), SLOT(updateChanged()));
1115     connect(dlgOpacity, SIGNAL(valueChanged(int)), SLOT(updateChanged()));
1116     connect(menuBgndImage, SIGNAL(currentIndexChanged(int)), SLOT(menuBgndImageChanged()));
1117     connect(menuBgndOpacity, SIGNAL(valueChanged(int)), SLOT(updateChanged()));
1118     connect(dropShadowSize, SIGNAL(valueChanged(int)), SLOT(updateChanged()));
1119     connect(dwtAppearance, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1120     connect(tooltipAppearance, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1121     connect(dwtBtnAsPerTitleBar, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1122     connect(dwtColAsPerTitleBar, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1123     connect(dwtIconColAsPerTitleBar, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1124     connect(dwtFontAsPerTitleBar, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1125     connect(dwtTextAsPerTitleBar, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1126     connect(dwtEffectAsPerTitleBar, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1127     connect(dwtRoundTopOnly, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1128     connect(xbar, SIGNAL(toggled(bool)), SLOT(xbarChanged()));
1129     connect(crColor, SIGNAL(currentIndexChanged(int)), SLOT(crColorChanged()));
1130     connect(customCrBgndColor, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1131     connect(smallRadio, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1132     connect(splitterHighlight, SIGNAL(valueChanged(int)), SLOT(updateChanged()));
1133     connect(gtkComboMenus, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1134     connect(gtkButtonOrder, SIGNAL(toggled(bool)), SLOT(gtkButtonOrderChanged()));
1135     connect(reorderGtkButtons, SIGNAL(toggled(bool)), SLOT(reorderGtkButtonsChanged()));
1136     connect(mapKdeIcons, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1137     connect(passwordChar, SIGNAL(clicked()), SLOT(passwordCharClicked()));
1138     connect(groupBox, SIGNAL(currentIndexChanged(int)), SLOT(groupBoxChanged()));
1139     connect(gbFactor, SIGNAL(valueChanged(int)), SLOT(updateChanged()));
1140     connect(colorMenubarMouseOver, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1141     connect(useHighlightForMenu, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1142     connect(gbLabel_bold, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1143     connect(gbLabel_textPos, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1144     connect(gbLabel_centred, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1145     connect(fadeLines, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1146     connect(menuIcons, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1147     connect(onlyTicksInMenu, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1148     connect(buttonStyleMenuSections, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1149     connect(stdBtnSizes, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1150     connect(forceAlternateLvCols, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1151     connect(titlebarAlignment, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1152     connect(titlebarEffect, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1153     connect(titlebarIcon, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1154     connect(boldProgress, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1155     connect(coloredTbarMo, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1156     connect(tbarBtns, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1157     connect(tbarBtnAppearance, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1158     connect(tbarBtnEffect, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()));
1159     connect(borderSelection, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1160     connect(borderProgress, SIGNAL(toggled(bool)), SLOT(borderProgressChanged()));
1161     connect(fillProgress, SIGNAL(toggled(bool)), SLOT(fillProgressChanged()));
1162     connect(squareEntry, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1163     connect(squareProgress, SIGNAL(toggled(bool)), SLOT(squareProgressChanged()));
1164     connect(squareLvSelection, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1165     connect(squareScrollViews, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1166     connect(squareFrame, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1167     connect(squareTabFrame, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1168     connect(squareSlider, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1169     connect(squareScrollbarSlider, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1170     connect(squareWindows, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1171     connect(squareTooltips, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1172     connect(squarePopupMenus, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1173     connect(titlebarButtons_button, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1174     connect(titlebarButtons_custom, SIGNAL(toggled(bool)), SLOT(titlebarButtons_customChanged()));
1175     connect(titlebarButtons_useHover, SIGNAL(toggled(bool)), SLOT(titlebarButtons_useHoverChanged()));
1176     connect(titlebarButtons_customIcon, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1177     connect(titlebarButtons_noFrame, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1178     connect(titlebarButtons_round, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1179     connect(titlebarButtons_hoverFrame, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1180     connect(titlebarButtons_hoverSymbol, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1181     connect(titlebarButtons_hoverSymbolFull, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1182     connect(titlebarButtons_sunkenBackground, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1183     connect(titlebarButtons_arrowMinMax, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1184     connect(titlebarButtons_colorOnMouseOver, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1185     connect(titlebarButtons_colorSymbolsOnly, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1186     connect(titlebarButtons_colorInactive, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1187     connect(titlebarButtons_colorClose, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1188     connect(titlebarButtons_colorMin, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1189     connect(titlebarButtons_colorMax, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1190     connect(titlebarButtons_colorKeepAbove, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1191     connect(titlebarButtons_colorKeepBelow, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1192     connect(titlebarButtons_colorHelp, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1193     connect(titlebarButtons_colorMenu, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1194     connect(titlebarButtons_colorShade, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1195     connect(titlebarButtons_colorAllDesktops, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1196     connect(titlebarButtons_colorCloseIcon, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1197     connect(titlebarButtons_colorMinIcon, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1198     connect(titlebarButtons_colorMaxIcon, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1199     connect(titlebarButtons_colorKeepAboveIcon, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1200     connect(titlebarButtons_colorKeepBelowIcon, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1201     connect(titlebarButtons_colorHelpIcon, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1202     connect(titlebarButtons_colorMenuIcon, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1203     connect(titlebarButtons_colorShadeIcon, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1204     connect(titlebarButtons_colorAllDesktopsIcon, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1205     connect(titlebarButtons_colorCloseInactiveIcon, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1206     connect(titlebarButtons_colorMinInactiveIcon, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1207     connect(titlebarButtons_colorMaxInactiveIcon, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1208     connect(titlebarButtons_colorKeepAboveInactiveIcon, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1209     connect(titlebarButtons_colorKeepBelowInactiveIcon, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1210     connect(titlebarButtons_colorHelpInactiveIcon, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1211     connect(titlebarButtons_colorMenuInactiveIcon, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1212     connect(titlebarButtons_colorShadeInactiveIcon, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1213     connect(titlebarButtons_colorAllDesktopsInactiveIcon, SIGNAL(changed(const QColor &)), SLOT(updateChanged()));
1214     connect(titlebarButtons_hideOnInactiveWindow, SIGNAL(toggled(bool)), SLOT(updateChanged()));
1215 
1216     connect(noBgndGradientApps, SIGNAL(editingFinished()), SLOT(updateChanged()));
1217     connect(noBgndOpacityApps, SIGNAL(editingFinished()), SLOT(updateChanged()));
1218     connect(noMenuBgndOpacityApps, SIGNAL(editingFinished()), SLOT(updateChanged()));
1219     connect(noBgndImageApps, SIGNAL(editingFinished()), SLOT(updateChanged()));
1220     connect(useQtFileDialogApps, SIGNAL(editingFinished()), SLOT(updateChanged()));
1221     connect(menubarApps, SIGNAL(editingFinished()), SLOT(updateChanged()));
1222     connect(statusbarApps, SIGNAL(editingFinished()), SLOT(updateChanged()));
1223     connect(noMenuStripeApps, SIGNAL(editingFinished()), SLOT(updateChanged()));
1224     connect(nonnativeMenubarApps, SIGNAL(editingFinished()), SLOT(updateChanged()));
1225 
1226     menubarBlend->setIcon(KIcon("configure"));
1227     connect(menubarBlend, SIGNAL(clicked(bool)), SLOT(menubarTitlebarBlend()));
1228     connect(previewControlButton, SIGNAL(clicked(bool)), SLOT(previewControlPressed()));
1229 
1230     connect(bgndAppearance_btn, SIGNAL(clicked(bool)), SLOT(configureBgndAppearanceFile()));
1231     connect(bgndImage_btn, SIGNAL(clicked(bool)), SLOT(configureBgndImageFile()));
1232     connect(menuBgndAppearance_btn, SIGNAL(clicked(bool)), SLOT(configureMenuBgndAppearanceFile()));
1233     connect(menuBgndImage_btn, SIGNAL(clicked(bool)), SLOT(configureMenuBgndImageFile()));
1234 
1235     bgndAppearance_btn->setAutoRaise(true);
1236     bgndAppearance_btn->setVisible(false);
1237     bgndAppearance_btn->setIcon(KIcon("configure"));
1238     bgndImage_btn->setAutoRaise(true);
1239     bgndImage_btn->setVisible(false);
1240     bgndImage_btn->setIcon(KIcon("configure"));
1241     menuBgndAppearance_btn->setAutoRaise(true);
1242     menuBgndAppearance_btn->setVisible(false);
1243     menuBgndAppearance_btn->setIcon(KIcon("configure"));
1244     menuBgndImage_btn->setAutoRaise(true);
1245     menuBgndImage_btn->setVisible(false);
1246     menuBgndImage_btn->setIcon(KIcon("configure"));
1247 
1248     setupStack();
1249 
1250     if (kwin->ok()) {
1251         Options currentStyle;
1252         Options defaultStyle;
1253 
1254         kwin->load(nullptr);
1255         qtcDefaultSettings(&defaultStyle);
1256         if (!qtcReadConfig(nullptr, &currentStyle, &defaultStyle))
1257             currentStyle = defaultStyle;
1258 
1259         previewStyle = currentStyle;
1260         setupShadesTab();
1261         setWidgetOptions(currentStyle);
1262 
1263         setupGradientsTab();
1264         setupPresets(currentStyle, defaultStyle);
1265         setupPreview();
1266         readyForPreview = true;
1267         updatePreview();
1268     } else {
1269         stack->setCurrentIndex(kwinPage);
1270         titleLabel->setVisible(false);
1271         stackList->setVisible(false);
1272     }
1273     // KMainWindow dereferences KGlobal when it closes. When KGlobal's refs get
1274     // to 0 it quits! ...running kcmshell4 style does not seem to increase ref
1275     // count of KGlobal - therefore we do it here - otherwse kcmshell4 would
1276     // exit immediately after QtCurve's config dialog was closed :-(
1277     if (QCoreApplication::applicationName() == QLatin1String("kcmshell")) {
1278         static std::once_flag ref_flag;
1279         std::call_once(ref_flag, [] { KGlobal::ref(); });
1280     }
1281 }
1282 
1283 QtCurveConfig::~QtCurveConfig()
1284 {
1285     // Remove QTCURVE_PREVIEW_CONFIG setting, so that main kcmstyle preview
1286     // does not revert to default settings!
1287     qputenv(QTCURVE_PREVIEW_CONFIG, "");
1288     previewFrame->hide();
1289     previewFrame->setParent(0);
1290     delete previewFrame;
1291     if (!mdiWindow) {
1292         delete stylePreview;
1293     }
1294 }
1295 
1296 QSize QtCurveConfig::sizeHint() const
1297 {
1298     return QSize(700, 500);
1299 }
1300 
1301 void QtCurveConfig::save()
1302 {
1303     if (!kwin->ok())
1304         return;
1305 
1306     Options opts = presets[currentText].opts;
1307 
1308     setOptions(opts);
1309 
1310     if (IMG_FILE == opts.bgndImage.type) {
1311         opts.bgndImage.pixmap.file = installThemeFile(bgndImageDlg->fileName(),
1312                                                       BGND_FILE IMAGE_FILE);
1313     } else {
1314         removeInstalledThemeFile(BGND_FILE IMAGE_FILE);
1315     }
1316     if (APPEARANCE_FILE == opts.bgndAppearance) {
1317         opts.bgndPixmap.file = installThemeFile(bgndPixmapDlg->fileName(),
1318                                                 BGND_FILE);
1319     } else {
1320         removeInstalledThemeFile(BGND_FILE);
1321     }
1322     if(IMG_FILE==opts.menuBgndImage.type)
1323     {
1324         opts.menuBgndImage.pixmap.file=installThemeFile(menuBgndImageDlg->fileName(), BGND_FILE MENU_FILE IMAGE_FILE);
1325 //         printf("SAVE MENU:%s\n", opts.menuBgndImage.pixmap.file.toLatin1().constData());
1326     }
1327     else
1328         removeInstalledThemeFile(BGND_FILE MENU_FILE IMAGE_FILE);
1329     if(APPEARANCE_FILE==opts.menuBgndAppearance)
1330         opts.menuBgndPixmap.file=installThemeFile(menuBgndPixmapDlg->fileName(), BGND_FILE MENU_FILE);
1331     else
1332         removeInstalledThemeFile(BGND_FILE MENU_FILE);
1333 
1334     // avoid surprises and always save the full config
1335     qtcWriteConfig(nullptr, opts, presets[defaultText].opts, true);
1336 
1337     // This is only read by KDE3...
1338     KConfig      k3globals(kdeHome(true)+"/share/config/kdeglobals", KConfig::CascadeConfig);
1339     KConfigGroup kde(&k3globals, "KDE");
1340 
1341     if(opts.gtkButtonOrder)
1342         kde.writeEntry("ButtonLayout", 2);
1343     else
1344         kde.deleteEntry("ButtonLayout");
1345 
1346     kwin->save(nullptr);
1347     // If using QtCurve window decoration, get this to update...
1348     KConfig kwin("kwinrc", KConfig::CascadeConfig);
1349     KConfigGroup style(&kwin, "Style");
1350 
1351     if (style.readEntry("PluginLib", QString()) == "kwin3_qtcurve") {
1352         QDBusConnection::sessionBus().send(
1353             QDBusMessage::createSignal("/KWin", "org.kde.KWin",
1354                                        "reloadConfig"));
1355     }
1356 
1357     // Remove QTCURVE_PREVIEW_CONFIG setting, so that main kcmstyle
1358     // preview does not revert to default settings!
1359     qputenv(QTCURVE_PREVIEW_CONFIG, "");
1360 }
1361 
1362 void QtCurveConfig::defaults()
1363 {
1364     if(!kwin->ok())
1365         return;
1366 
1367     int index=-1;
1368 
1369     for(int i=0; i<presetsCombo->count() && -1==index; ++i)
1370         if(presetsCombo->itemText(i)==defaultText)
1371             index=i;
1372 
1373     presetsCombo->setCurrentIndex(index);
1374     setPreset();
1375     kwin->defaults();
1376 }
1377 
1378 void QtCurveConfig::emboldenToggled()
1379 {
1380     if(!embolden->isChecked() && IND_NONE==defBtnIndicator->currentIndex())
1381         defBtnIndicator->setCurrentIndex(IND_TINT);
1382     updateChanged();
1383 }
1384 
1385 void QtCurveConfig::defBtnIndicatorChanged()
1386 {
1387     if(IND_NONE==defBtnIndicator->currentIndex() && !embolden->isChecked())
1388         embolden->setChecked(true);
1389     else if(IND_GLOW==defBtnIndicator->currentIndex() && EFFECT_NONE==buttonEffect->currentIndex())
1390         buttonEffect->setCurrentIndex(EFFECT_SHADOW);
1391 
1392     if(IND_COLORED==defBtnIndicator->currentIndex() && round->currentIndex()>ROUND_FULL)
1393         round->setCurrentIndex(ROUND_FULL);
1394 
1395     updateChanged();
1396 }
1397 
1398 void QtCurveConfig::buttonEffectChanged()
1399 {
1400     if(EFFECT_NONE==buttonEffect->currentIndex())
1401     {
1402         if(IND_GLOW==defBtnIndicator->currentIndex())
1403             defBtnIndicator->setCurrentIndex(IND_TINT);
1404         if(MO_GLOW==coloredMouseOver->currentIndex())
1405             coloredMouseOver->setCurrentIndex(MO_PLASTIK);
1406     }
1407 
1408     updateChanged();
1409 }
1410 
1411 void QtCurveConfig::coloredMouseOverChanged()
1412 {
1413     if(MO_GLOW==coloredMouseOver->currentIndex() &&
1414        EFFECT_NONE==buttonEffect->currentIndex())
1415         buttonEffect->setCurrentIndex(EFFECT_SHADOW);
1416 
1417     updateChanged();
1418 }
1419 
1420 void QtCurveConfig::shadeSlidersChanged()
1421 {
1422     customSlidersColor->setEnabled(SHADE_CUSTOM==shadeSliders->currentIndex());
1423     updateChanged();
1424     if(gradPreview)
1425         gradPreview->repaint();
1426 }
1427 
1428 void QtCurveConfig::shadeMenubarsChanged()
1429 {
1430     customMenubarsColor->setEnabled(SHADE_CUSTOM==shadeMenubars->currentIndex());
1431     customMenuNormTextColor->setEnabled(SHADE_WINDOW_BORDER!=shadeMenubars->currentIndex());
1432     customMenuSelTextColor->setEnabled(SHADE_WINDOW_BORDER!=shadeMenubars->currentIndex());
1433     customMenuTextColor->setEnabled(SHADE_WINDOW_BORDER!=shadeMenubars->currentIndex());
1434     shadeMenubarOnlyWhenActive->setEnabled(SHADE_WINDOW_BORDER!=shadeMenubars->currentIndex());
1435     if(SHADE_WINDOW_BORDER==shadeMenubars->currentIndex())
1436         windowBorder_menuColor->setChecked(false);
1437     updateChanged();
1438 }
1439 
1440 void QtCurveConfig::shadeCheckRadioChanged()
1441 {
1442     customCheckRadioColor->setEnabled(SHADE_CUSTOM==shadeCheckRadio->currentIndex());
1443     updateChanged();
1444 }
1445 
1446 void QtCurveConfig::customMenuTextColorChanged()
1447 {
1448     customMenuNormTextColor->setEnabled(SHADE_WINDOW_BORDER!=shadeMenubars->currentIndex() && customMenuTextColor->isChecked());
1449     customMenuSelTextColor->setEnabled(SHADE_WINDOW_BORDER!=shadeMenubars->currentIndex() && customMenuTextColor->isChecked());
1450     updateChanged();
1451 }
1452 
1453 void QtCurveConfig::menuStripeChanged()
1454 {
1455     customMenuStripeColor->setEnabled(SHADE_CUSTOM==menuStripe->currentIndex());
1456     menuStripeAppearance->setEnabled(SHADE_NONE!=menuStripe->currentIndex());
1457     updateChanged();
1458 }
1459 
1460 void QtCurveConfig::shadePopupMenuChanged()
1461 {
1462     lighterPopupMenuBgnd->setEnabled(!shadePopupMenu->isChecked());
1463 }
1464 
1465 void QtCurveConfig::progressColorChanged()
1466 {
1467     customProgressColor->setEnabled(SHADE_CUSTOM==progressColor->currentIndex());
1468     updateChanged();
1469 }
1470 
1471 void QtCurveConfig::comboBtnChanged()
1472 {
1473     customComboBtnColor->setEnabled(SHADE_CUSTOM==comboBtn->currentIndex());
1474     updateChanged();
1475 }
1476 
1477 void QtCurveConfig::sortedLvChanged()
1478 {
1479     customSortedLvColor->setEnabled(SHADE_CUSTOM==sortedLv->currentIndex());
1480     updateChanged();
1481 }
1482 
1483 void QtCurveConfig::crColorChanged()
1484 {
1485     customCrBgndColor->setEnabled(SHADE_CUSTOM==crColor->currentIndex());
1486     updateChanged();
1487 }
1488 
1489 void QtCurveConfig::stripedProgressChanged()
1490 {
1491     bool allowAnimation=STRIPE_NONE!=stripedProgress->currentIndex() &&
1492                         STRIPE_FADE!=stripedProgress->currentIndex();
1493 
1494     animatedProgress->setEnabled(allowAnimation);
1495     if(animatedProgress->isChecked() && !allowAnimation)
1496         animatedProgress->setChecked(false);
1497     updateChanged();
1498 }
1499 
1500 void QtCurveConfig::activeTabAppearanceChanged()
1501 {
1502     int  current(activeTabAppearance->currentIndex());
1503     bool disableCol(APPEARANCE_FLAT==current || APPEARANCE_RAISED==current);
1504 
1505     if(colorSelTab->value() && disableCol)
1506         colorSelTab->setValue(MIN_COLOR_SEL_TAB_FACTOR);
1507     colorSelTab->setEnabled(!disableCol);
1508     updateChanged();
1509 }
1510 
1511 void QtCurveConfig::tabMoChanged()
1512 {
1513     if(TAB_MO_GLOW==tabMouseOver->currentIndex())
1514         roundAllTabs->setChecked(true);
1515     roundAllTabs->setEnabled(TAB_MO_GLOW!=tabMouseOver->currentIndex());
1516     roundAllTabs_false->setEnabled(TAB_MO_GLOW!=tabMouseOver->currentIndex());
1517     updateChanged();
1518 }
1519 
1520 void QtCurveConfig::shadingChanged()
1521 {
1522     updateChanged();
1523     if(gradPreview)
1524         gradPreview->repaint();
1525 }
1526 
1527 void QtCurveConfig::passwordCharClicked()
1528 {
1529     int              cur(toInt(passwordChar->text()));
1530     CharSelectDialog dlg(this, cur);
1531 
1532     if(QDialog::Accepted==dlg.exec() && dlg.currentChar()!=cur)
1533     {
1534         setPasswordChar(dlg.currentChar());
1535         updateChanged();
1536     }
1537 }
1538 
1539 void QtCurveConfig::unifySpinBtnsToggled()
1540 {
1541     if(unifySpinBtns->isChecked())
1542         unifySpin->setChecked(false);
1543     unifySpin->setDisabled(unifySpinBtns->isChecked());
1544     updateChanged();
1545 }
1546 
1547 void QtCurveConfig::unifySpinToggled()
1548 {
1549     if(unifySpin->isChecked())
1550         unifySpinBtns->setChecked(false);
1551     unifySpinBtns->setDisabled(unifySpin->isChecked());
1552     updateChanged();
1553 }
1554 
1555 void QtCurveConfig::sliderThumbChanged()
1556 {
1557     if(LINE_NONE!=sliderThumbs->currentIndex() && sliderWidth->value()<DEFAULT_SLIDER_WIDTH)
1558         sliderWidth->setValue(DEFAULT_SLIDER_WIDTH);
1559     updateChanged();
1560 }
1561 
1562 void QtCurveConfig::sliderWidthChanged()
1563 {
1564     if(0==sliderWidth->value()%2)
1565         sliderWidth->setValue(sliderWidth->value()+1);
1566 
1567     if(LINE_NONE!=sliderThumbs->currentIndex() && sliderWidth->value()<DEFAULT_SLIDER_WIDTH)
1568         sliderThumbs->setCurrentIndex(LINE_NONE);
1569     updateChanged();
1570 }
1571 
1572 void QtCurveConfig::menubarHidingChanged()
1573 {
1574     if(menubarHiding_keyboard->isChecked() || menubarHiding_kwin->isChecked())
1575         xbar->setChecked(false);
1576     updateChanged();
1577 }
1578 
1579 void QtCurveConfig::xbarChanged()
1580 {
1581     if(xbar->isChecked())
1582     {
1583         menubarHiding_keyboard->setChecked(false);
1584         menubarHiding_kwin->setChecked(false);
1585     }
1586     updateChanged();
1587 }
1588 
1589 void QtCurveConfig::windowBorder_colorTitlebarOnlyChanged()
1590 {
1591     if(!windowBorder_colorTitlebarOnly->isChecked())
1592         windowBorder_blend->setChecked(false);
1593     updateChanged();
1594 }
1595 
1596 void QtCurveConfig::windowBorder_blendChanged()
1597 {
1598     if(windowBorder_blend->isChecked())
1599     {
1600         windowBorder_colorTitlebarOnly->setChecked(true);
1601         windowBorder_menuColor->setChecked(false);
1602     }
1603     updateChanged();
1604 }
1605 
1606 void QtCurveConfig::windowBorder_menuColorChanged()
1607 {
1608     if(windowBorder_menuColor->isChecked())
1609     {
1610         windowBorder_colorTitlebarOnly->setChecked(false);
1611         if(SHADE_WINDOW_BORDER==shadeMenubars->currentIndex())
1612             shadeMenubars->setCurrentIndex(SHADE_NONE);
1613     }
1614     updateChanged();
1615 }
1616 
1617 void QtCurveConfig::thinSbarGrooveChanged()
1618 {
1619     if(thinSbarGroove->isChecked())
1620         borderSbarGroove->setChecked(true);
1621     updateChanged();
1622 }
1623 
1624 void QtCurveConfig::borderSbarGrooveChanged()
1625 {
1626     if(!borderSbarGroove->isChecked())
1627         thinSbarGroove->setChecked(false);
1628     updateChanged();
1629 }
1630 
1631 void QtCurveConfig::borderProgressChanged()
1632 {
1633     if(!borderProgress->isChecked())
1634     {
1635         squareProgress->setChecked(true);
1636         fillProgress->setChecked(true);
1637     }
1638     updateChanged();
1639 }
1640 
1641 void QtCurveConfig::squareProgressChanged()
1642 {
1643     if(!fillProgress->isChecked() || !squareProgress->isChecked())
1644         borderProgress->setChecked(true);
1645     updateChanged();
1646 }
1647 
1648 void QtCurveConfig::fillProgressChanged()
1649 {
1650     if(!fillProgress->isChecked() || !squareProgress->isChecked())
1651         borderProgress->setChecked(true);
1652     updateChanged();
1653 }
1654 
1655 void QtCurveConfig::titlebarButtons_customChanged()
1656 {
1657     if(titlebarButtons_custom->isChecked())
1658         titlebarButtons_useHover->setChecked(false);
1659     updateChanged();
1660 }
1661 
1662 void QtCurveConfig::titlebarButtons_useHoverChanged()
1663 {
1664     if(titlebarButtons_useHover->isChecked())
1665         titlebarButtons_custom->setChecked(false);
1666     updateChanged();
1667 }
1668 
1669 void QtCurveConfig::bgndAppearanceChanged()
1670 {
1671     if(APPEARANCE_STRIPED==bgndAppearance->currentIndex())
1672         bgndGrad->setCurrentIndex(GT_HORIZ);
1673     bgndGrad->setEnabled(APPEARANCE_STRIPED!=bgndAppearance->currentIndex() && APPEARANCE_FILE!=bgndAppearance->currentIndex());
1674     bgndAppearance_btn->setVisible(APPEARANCE_FILE==bgndAppearance->currentIndex());
1675     updateChanged();
1676 }
1677 
1678 void QtCurveConfig::bgndImageChanged()
1679 {
1680     bgndImage_btn->setVisible(IMG_FILE==bgndImage->currentIndex());
1681     updateChanged();
1682 }
1683 
1684 void QtCurveConfig::menuBgndAppearanceChanged()
1685 {
1686     if(APPEARANCE_STRIPED==menuBgndAppearance->currentIndex())
1687         menuBgndGrad->setCurrentIndex(GT_HORIZ);
1688     menuBgndGrad->setEnabled(APPEARANCE_STRIPED!=menuBgndAppearance->currentIndex() && APPEARANCE_FILE!=menuBgndAppearance->currentIndex());
1689     menuBgndAppearance_btn->setVisible(APPEARANCE_FILE==menuBgndAppearance->currentIndex());
1690     updateChanged();
1691 }
1692 
1693 void QtCurveConfig::menuBgndImageChanged()
1694 {
1695     menuBgndImage_btn->setVisible(IMG_FILE==menuBgndImage->currentIndex());
1696     updateChanged();
1697 }
1698 
1699 void QtCurveConfig::configureBgndAppearanceFile()
1700 {
1701     if(bgndPixmapDlg->run())
1702         updateChanged();
1703 }
1704 
1705 void QtCurveConfig::configureBgndImageFile()
1706 {
1707     if(bgndImageDlg->run())
1708         updateChanged();
1709 }
1710 
1711 void QtCurveConfig::configureMenuBgndAppearanceFile()
1712 {
1713     if(menuBgndPixmapDlg->run())
1714         updateChanged();
1715 }
1716 
1717 void QtCurveConfig::configureMenuBgndImageFile()
1718 {
1719     if(menuBgndImageDlg->run())
1720         updateChanged();
1721 }
1722 
1723 void QtCurveConfig::groupBoxChanged()
1724 {
1725     gbFactor->setEnabled(FRAME_SHADED==groupBox->currentIndex() || FRAME_FADED==groupBox->currentIndex());
1726     updateChanged();
1727 }
1728 
1729 void QtCurveConfig::setupStack()
1730 {
1731     int i=0;
1732     CStackItem *first=new CStackItem(stackList, i18n("Presets and Preview"), i++);
1733     new CStackItem(stackList, i18n("General"), i++);
1734     new CStackItem(stackList, i18n("Rounding"), i++);
1735     new CStackItem(stackList, i18n("Opacity"), i++);
1736     new CStackItem(stackList, i18n("Group Boxes"), i++);
1737     new CStackItem(stackList, i18n("Combos"), i++);
1738     new CStackItem(stackList, i18n("Spin Buttons"), i++);
1739     new CStackItem(stackList, i18n("Splitters"), i++);
1740     new CStackItem(stackList, i18n("Sliders and Scrollbars"), i++);
1741     new CStackItem(stackList, i18n("Progressbars"), i++);
1742     new CStackItem(stackList, i18n("Default Button"),i++);
1743     new CStackItem(stackList, i18n("Mouse-over"), i++);
1744     new CStackItem(stackList, i18n("Item Views"), i++);
1745     new CStackItem(stackList, i18n("Scrollviews"), i++);
1746     new CStackItem(stackList, i18n("Tabs"), i++);
1747     new CStackItem(stackList, i18n("Checks and Radios"), i++);
1748     new CStackItem(stackList, i18n("Windows"), i++);
1749 
1750     kwin = new QtCurve::KWinConfig(nullptr, this);
1751     kwinPage = i;
1752 
1753     if(kwin->ok())
1754     {
1755         kwin->setNote(i18n("<p><b>NOTE:</b><i>The settings here affect the borders drawn around application windows and dialogs - and "
1756                            "not internal (or MDI) windows. Therefore, these settings will <b>not</b> be reflected in the Preview "
1757                            "page.</i></p>"));
1758         connect(kwin, SIGNAL(changed()), SLOT(updateChanged()));
1759     }
1760     stack->insertWidget(i, kwin);
1761     new CStackItem(stackList, i18n("Window Manager"), i++);
1762 
1763     new CStackItem(stackList, i18n("Window buttons"), i++);
1764     new CStackItem(stackList, i18n("Window button colors"), i++);
1765     new CStackItem(stackList, i18n("Menubars"), i++);
1766     new CStackItem(stackList, i18n("Popup menus"), i++);
1767     new CStackItem(stackList, i18n("Toolbars"), i++);
1768     new CStackItem(stackList, i18n("Statusbars"), i++);
1769     new CStackItem(stackList, i18n("Dock windows"), i++);
1770     new CStackItem(stackList, i18n("Advanced Settings"), i++);
1771     new CStackItem(stackList, i18n("Applications"), i++);
1772     new CStackItem(stackList, i18n("Legacy"), i++);
1773     new CStackItem(stackList, i18n("Custom Gradients"), i++);
1774     new CStackItem(stackList, i18n("Custom Shades"), i++);
1775 
1776     stackList->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
1777     stackList->setSelectionMode(QAbstractItemView::SingleSelection);
1778     first->setSelected(true);
1779     connect(stackList, SIGNAL(itemSelectionChanged()), SLOT(changeStack()));
1780 }
1781 
1782 void QtCurveConfig::setupPresets(const Options &currentStyle, const Options &defaultStyle)
1783 {
1784     QStringList files(KGlobal::dirs()->findAllResources("data", "QtCurve/*" EXTENSION, KStandardDirs::NoDuplicates));
1785 
1786     files.sort();
1787 
1788     QStringList::Iterator it(files.begin()),
1789                           end(files.end());
1790 
1791     saveButton->setGuiItem(KGuiItem(i18n("Save"), "document-save"));
1792     deleteButton->setGuiItem(KGuiItem(i18n("Delete"), "edit-delete"));
1793     importButton->setGuiItem(KGuiItem(i18n("Import..."), "document-import"));
1794     exportButton->setGuiItem(KGuiItem(i18n("Export..."), "document-export"));
1795 
1796     deleteButton->setEnabled(false);
1797 
1798     currentText=i18n("(Current)");
1799     defaultText=i18n("(Default)");
1800     presets[currentText]=Preset(currentStyle);
1801     presets[defaultText]=Preset(defaultStyle);
1802     for(; it!=end; ++it)
1803     {
1804         QString name(getFileName(*it).remove(EXTENSION).replace('_', ' '));
1805 
1806         if(!name.isEmpty() && name!=currentText && name!=defaultText)
1807         {
1808             presetsCombo->insertItem(0, name);
1809             presets[name]=Preset(*it);
1810         }
1811     }
1812 
1813     presetsCombo->insertItem(0, currentText);
1814     presetsCombo->insertItem(0, defaultText);
1815     presetsCombo->model()->sort(0);
1816     connect(presetsCombo, SIGNAL(currentIndexChanged(int)), SLOT(setPreset()));
1817     connect(saveButton, SIGNAL(clicked(bool)), SLOT(savePreset()));
1818     connect(deleteButton, SIGNAL(clicked(bool)), SLOT(deletePreset()));
1819     connect(importButton, SIGNAL(clicked(bool)), SLOT(importPreset()));
1820     connect(exportButton, SIGNAL(clicked(bool)), SLOT(exportPreset()));
1821 
1822     int index=-1;
1823 
1824     for(int i=0; i<presetsCombo->count() && -1==index; ++i)
1825         if(presetsCombo->itemText(i)==currentText)
1826             index=i;
1827 
1828     presetsCombo->setCurrentIndex(index);
1829     setPreset();
1830 }
1831 
1832 void QtCurveConfig::setupPreview()
1833 {
1834     QVBoxLayout *layout = new QVBoxLayout(previewFrame);
1835 
1836     workSpace = new CWorkspace(previewFrame);
1837     layout->setMargin(0);
1838     layout->addWidget(workSpace);
1839 
1840     previewControlPressed();
1841 }
1842 
1843 void QtCurveConfig::changeStack()
1844 {
1845     CStackItem *item=(CStackItem *)(stackList->currentItem());
1846 
1847     if(item && !item->isSelected())
1848         item->setSelected(true);
1849 
1850     if(item)
1851     {
1852         if(0==item->stack() && settingsChanged(previewStyle))
1853             updatePreview();
1854         stack->setCurrentIndex(item->stack());
1855     }
1856 }
1857 
1858 void QtCurveConfig::gradChanged(int i)
1859 {
1860     GradientCont::const_iterator it(customGradient.find((EAppearance)i));
1861 
1862     gradStops->clear();
1863 
1864     if(it!=customGradient.end())
1865     {
1866         gradPreview->setGrad((*it).second);
1867         gradBorder->setCurrentIndex((*it).second.border);
1868 
1869         GradientStopCont::const_iterator git((*it).second.stops.begin()),
1870                                          gend((*it).second.stops.end());
1871         CGradItem                        *first=nullptr;
1872 
1873         gradStops->blockSignals(true);
1874         for(; git!=gend; ++git)
1875         {
1876             QStringList details;
1877 
1878             details << QString().setNum((*git).pos*100.0)
1879                     << QString().setNum((*git).val*100.0)
1880                     << QString().setNum((*git).alpha*100.0);
1881             CGradItem *grad=new CGradItem(gradStops, details);
1882             if(!first)
1883                 first=grad;
1884         }
1885         gradStops->blockSignals(false);
1886         gradStops->sortItems(0, Qt::AscendingOrder);
1887         if(first)
1888             gradStops->setCurrentItem(first);
1889     }
1890     else
1891     {
1892         gradPreview->setGrad(Gradient());
1893         gradBorder->setCurrentIndex(GB_3D);
1894     }
1895 
1896     gradBorder->setEnabled(NUM_CUSTOM_GRAD!=i);
1897 }
1898 
1899 void QtCurveConfig::borderChanged(int i)
1900 {
1901     GradientCont::iterator it=customGradient.find((EAppearance)gradCombo->currentIndex());
1902     if(it!=customGradient.end())
1903     {
1904         (*it).second.border=(EGradientBorder)i;
1905         gradPreview->setGrad((*it).second);
1906         emit changed(true);
1907     }
1908 }
1909 
1910 static double prev=-1.0;
1911 
1912 void QtCurveConfig::editItem(QTreeWidgetItem *i, int col)
1913 {
1914     bool   ok;
1915     prev=i->text(col).toDouble(&ok);
1916     if(!ok)
1917         prev=-1.0;
1918 
1919     gradStops->editItem(i, col);
1920 }
1921 
1922 void QtCurveConfig::itemChanged(QTreeWidgetItem *i, int col)
1923 {
1924     bool   ok;
1925     double val=i->text(col).toDouble(&ok)/100.0;
1926 
1927     if(prev<0 || (ok && qtcEqual(val, prev)))
1928         return;
1929 
1930     if(!ok || ((0==col || 2==col) && (val<0.0 || val>1.0)) || (1==col && (val<0.0 || val>2.0)))
1931         i->setText(col, QString().setNum(prev));
1932     else
1933     {
1934         double other=i->text(col ? 0 : 1).toDouble(&ok)/100.0;
1935 
1936         GradientCont::iterator it=customGradient.find((EAppearance)gradCombo->currentIndex());
1937 
1938         if(it!=customGradient.end())
1939         {
1940             (*it).second.stops.erase(GradientStop(0==col ? prev : other, 1==col ? prev : other, 2==col ? prev : other));
1941             (*it).second.stops.insert(GradientStop(0==col ? val : other, 1==col ? val : other, 2==col ? val : other));
1942             gradPreview->setGrad((*it).second);
1943             i->setText(col, QString().setNum(val*100.0));
1944             emit changed(true);
1945         }
1946     }
1947 }
1948 
1949 void QtCurveConfig::addGradStop()
1950 {
1951     GradientCont::iterator cg=customGradient.find((EAppearance)gradCombo->currentIndex());
1952 
1953     if(cg==customGradient.end())
1954     {
1955         Gradient cust;
1956 
1957         cust.border=(EGradientBorder)gradBorder->currentIndex();
1958         cust.stops.insert(GradientStop(stopPosition->value()/100.0, stopValue->value()/100.0, stopAlpha->value()/100.0));
1959         customGradient[(EAppearance)gradCombo->currentIndex()]=cust;
1960         gradChanged(gradCombo->currentIndex());
1961         emit changed(true);
1962     }
1963     else
1964     {
1965         GradientStopCont::const_iterator it((*cg).second.stops.begin()),
1966                                          end((*cg).second.stops.end());
1967         double                           pos(stopPosition->value()/100.0),
1968                                          val(stopValue->value()/100.0),
1969                                          alpha(stopAlpha->value()/100.0);
1970 
1971         for(; it!=end; ++it)
1972             if(qtcEqual(pos, (*it).pos))
1973             {
1974                 if(qtcEqual(val, (*it).val) && qtcEqual(alpha, (*it).alpha))
1975                     return;
1976                 else
1977                 {
1978                     (*cg).second.stops.erase(it);
1979                     break;
1980                 }
1981             }
1982 
1983         unsigned int b4=(*cg).second.stops.size();
1984         (*cg).second.stops.insert(GradientStop(pos, val, alpha));
1985         if((*cg).second.stops.size()!=b4)
1986         {
1987             gradPreview->setGrad((*cg).second);
1988 
1989             QStringList details;
1990 
1991             details << QString().setNum(pos*100.0)
1992                     << QString().setNum(val*100.0)
1993                     << QString().setNum(alpha*100.0);
1994 
1995             QTreeWidgetItem *i=new CGradItem(gradStops, details);
1996 
1997             gradStops->setCurrentItem(i);
1998             gradStops->sortItems(0, Qt::AscendingOrder);
1999         }
2000     }
2001 }
2002 
2003 void QtCurveConfig::removeGradStop()
2004 {
2005     QTreeWidgetItem *cur=gradStops->currentItem();
2006 
2007     if(cur)
2008     {
2009         QTreeWidgetItem *next=gradStops->itemBelow(cur);
2010 
2011         if(!next)
2012             next=gradStops->itemAbove(cur);
2013 
2014         GradientCont::iterator it=customGradient.find((EAppearance)gradCombo->currentIndex());
2015 
2016         if(it!=customGradient.end())
2017         {
2018             bool   ok;
2019             double pos=cur->text(0).toDouble(&ok)/100.0,
2020                    val=cur->text(1).toDouble(&ok)/100.0,
2021                    alpha=cur->text(2).toDouble(&ok)/100.0;
2022 
2023             (*it).second.stops.erase(GradientStop(pos, val, alpha));
2024             gradPreview->setGrad((*it).second);
2025             emit changed(true);
2026 
2027             delete cur;
2028             if(next)
2029                 gradStops->setCurrentItem(next);
2030         }
2031     }
2032 }
2033 
2034 void QtCurveConfig::updateGradStop()
2035 {
2036     QTreeWidgetItem *i=gradStops->selectedItems().size() ? *(gradStops->selectedItems().begin()) : nullptr;
2037 
2038     GradientCont::iterator cg=customGradient.find((EAppearance)gradCombo->currentIndex());
2039 
2040     if(i)
2041     {
2042         double curPos=i->text(0).toDouble()/100.0,
2043                curVal=i->text(1).toDouble()/100.0,
2044                curAlpha=i->text(2).toDouble()/100.0,
2045                newPos(stopPosition->value()/100.0),
2046                newVal(stopValue->value()/100.0),
2047                newAlpha(stopAlpha->value()/100.0);
2048 
2049         if(!qtcEqual(newPos, curPos) || !qtcEqual(newVal, curVal) || !qtcEqual(newAlpha, curAlpha))
2050         {
2051             (*cg).second.stops.erase(GradientStop(curPos, curVal, curAlpha));
2052             (*cg).second.stops.insert(GradientStop(newPos, newVal, newAlpha));
2053 
2054             i->setText(0, QString().setNum(stopPosition->value()));
2055             i->setText(1, QString().setNum(stopValue->value()));
2056             i->setText(2, QString().setNum(stopAlpha->value()));
2057             gradPreview->setGrad((*cg).second);
2058             emit changed(true);
2059         }
2060     }
2061     else
2062         addGradStop();
2063 }
2064 
2065 void QtCurveConfig::stopSelected()
2066 {
2067     QTreeWidgetItem *i=gradStops->selectedItems().size() ? *(gradStops->selectedItems().begin()) : nullptr;
2068 
2069     removeButton->setEnabled(i);
2070     updateButton->setEnabled(i);
2071 
2072     if(i)
2073     {
2074         stopPosition->setValue(i->text(0).toInt());
2075         stopValue->setValue(i->text(1).toInt());
2076         stopAlpha->setValue(i->text(2).toInt());
2077     }
2078     else
2079     {
2080         stopPosition->setValue(0);
2081         stopValue->setValue(100);
2082         stopAlpha->setValue(100);
2083     }
2084 }
2085 
2086 void QtCurveConfig::exportKDE3()
2087 {
2088     if(KMessageBox::Yes==KMessageBox::questionYesNo(this, i18n("Export your current KDE4 color palette, and font, so "
2089                                                                "that they can be used by KDE3 applications?")))
2090     {
2091         QString      kde3Home(kdeHome(true));
2092         KConfig      k3globals(kde3Home+"/share/config/kdeglobals", KConfig::NoGlobals);
2093         KConfigGroup general(&k3globals, "General");
2094         KConfigGroup wm(&k3globals, "WM");
2095 
2096         general.writeEntry("alternateBackground", palette().color(QPalette::Active, QPalette::AlternateBase));
2097         general.writeEntry("background", palette().color(QPalette::Active, QPalette::Window));
2098         general.writeEntry("buttonBackground", palette().color(QPalette::Active, QPalette::Button));
2099         general.writeEntry("buttonForeground", palette().color(QPalette::Active, QPalette::ButtonText));
2100         general.writeEntry("foreground", palette().color(QPalette::Active, QPalette::WindowText));
2101         general.writeEntry("selectBackground", palette().color(QPalette::Active, QPalette::Highlight));
2102         general.writeEntry("selectForeground", palette().color(QPalette::Active, QPalette::HighlightedText));
2103         general.writeEntry("windowBackground", palette().color(QPalette::Active, QPalette::Base));
2104         general.writeEntry("windowForeground", palette().color(QPalette::Active, QPalette::Text));
2105         general.writeEntry("linkColor", palette().color(QPalette::Active, QPalette::Link));
2106         general.writeEntry("visitedLinkColor", palette().color(QPalette::Active, QPalette::LinkVisited));
2107 
2108         if(kdeHome(false)!=kde3Home)
2109         {
2110             KConfigGroup k4General(KGlobal::config(), "General");
2111             KConfigGroup k4wm(KGlobal::config(), "WM");
2112 
2113             // Mainly for K3B...
2114             wm.writeEntry("activeBackground", k4wm.readEntry("activeBackground",
2115                                                              palette().color(QPalette::Active, QPalette::Window)));
2116             wm.writeEntry("activeForeground", k4wm.readEntry("activeForeground",
2117                                                              palette().color(QPalette::Active, QPalette::WindowText)));
2118             wm.writeEntry("inactiveBackground", k4wm.readEntry("inactiveBackground",
2119                                                                palette().color(QPalette::Inactive, QPalette::Window)));
2120             wm.writeEntry("inactiveForeground", k4wm.readEntry("inactiveForeground",
2121                                                                palette().color(QPalette::Inactive, QPalette::WindowText)));
2122             // Font settings...
2123             general.writeEntry("font", k4General.readEntry("font", font()));
2124             general.writeEntry("fixed", k4General.readEntry("fixed", font()));
2125             general.writeEntry("desktopFont", k4General.readEntry("desktopFont", font()));
2126             general.writeEntry("taskbarFont", k4General.readEntry("taskbarFont", font()));
2127             general.writeEntry("toolBarFont", k4General.readEntry("toolBarFont", font()));
2128         }
2129     }
2130 }
2131 
2132 void QtCurveConfig::exportQt()
2133 {
2134     if(KMessageBox::Yes==KMessageBox::questionYesNo(this, i18n("Export your current KDE4 color palette, and font, so "
2135                                                                "that they can be used by pure-Qt3 applications?")))
2136     {
2137         KConfig        cfg(QDir::homePath()+"/.qt/qtrc", KConfig::NoGlobals);
2138         KConfigGroup   gen(&cfg, "General");
2139         KConfigGroup   pal(&cfg, "Palette");
2140         KConfigGroup   kde(&cfg, "KDE");
2141         const QPalette &p=palette();
2142         int            i;
2143         QStringList    act,
2144                        inact,
2145                        dis;
2146         QString        sep("^e");
2147 
2148         QPalette::ColorRole roles[]={QPalette::Foreground,
2149                                      QPalette::Button,
2150                                      QPalette::Light,
2151                                      QPalette::Midlight,
2152                                      QPalette::Dark,
2153                                      QPalette::Mid,
2154                                      QPalette::Text,
2155                                      QPalette::BrightText,
2156                                      QPalette::ButtonText,
2157                                      QPalette::Base,
2158                                      QPalette::Background,
2159                                      QPalette::Shadow,
2160                                      QPalette::Highlight,
2161                                      QPalette::HighlightedText,
2162                                      QPalette::Link,
2163                                      QPalette::LinkVisited,
2164                                      QPalette::NColorRoles
2165                                     };
2166 
2167         for (i = 0; roles[i] != QPalette::NColorRoles; i++)
2168         {
2169             act << p.color(QPalette::Active, roles[i]).name();
2170             inact << p.color(QPalette::Inactive, roles[i]).name();
2171             dis << p.color(QPalette::Disabled, roles[i]).name();
2172         }
2173 
2174         KConfigGroup k4General(KGlobal::config(), "General");
2175         gen.writeEntry("font", k4General.readEntry("font", font()));
2176         gen.writeEntry("font", font());
2177         pal.writeEntry("active", act.join(sep));
2178         pal.writeEntry("disabled", dis.join(sep));
2179         pal.writeEntry("inactive", inact.join(sep));
2180         kde.writeEntry("contrast", QSettings(QLatin1String("Trolltech")).value("/Qt/KDE/contrast", 7).toInt());
2181     }
2182 }
2183 
2184 void QtCurveConfig::menubarTitlebarBlend()
2185 {
2186     if(KMessageBox::Yes==KMessageBox::questionYesNo(this,
2187         i18n("<p>Set the following config items so that window titlebar and menubars appear blended?</p>"
2188              "<ul><li>Menubar, titlebar, and inactive titlebar gradient to \"%1\"</li>"
2189              "<li>Disable \"Blend titlebar color into background color\"</li>"
2190              "<li>Set menubar coloration to \"%2\"</li>"
2191              "<li>Extend window dragging into menubar</li>",
2192              uiString((EAppearance)menubarAppearance->currentIndex()),
2193              uiString(SHADE_WINDOW_BORDER, SW_MENUBAR))))
2194     {
2195         titlebarAppearance->setCurrentIndex(menubarAppearance->currentIndex());
2196         inactiveTitlebarAppearance->setCurrentIndex(menubarAppearance->currentIndex());
2197         windowBorder_blend->setChecked(false);
2198         windowBorder_fill->setChecked(true);
2199         shadeMenubars->setCurrentIndex(SHADE_WINDOW_BORDER);
2200         if(windowDrag->currentIndex()<WM_DRAG_MENUBAR)
2201             windowDrag->setCurrentIndex(WM_DRAG_MENUBAR);
2202     }
2203 }
2204 
2205 void QtCurveConfig::updatePreview()
2206 {
2207     if(!readyForPreview)
2208         return;
2209 
2210     setOptions(previewStyle);
2211 
2212     qputenv(QTCURVE_PREVIEW_CONFIG, mdiWindow ? QTCURVE_PREVIEW_CONFIG : QTCURVE_PREVIEW_CONFIG_FULL);
2213     QStyle *style = QStyleFactory::create("qtcurve");
2214     qputenv(QTCURVE_PREVIEW_CONFIG, "");
2215     if (!style)
2216         return;
2217 
2218     // Very hacky way to pass preview options to style!!!
2219     QtCurve::Style::PreviewOption styleOpt;
2220     styleOpt.opts=previewStyle;
2221 
2222     style->drawControl((QStyle::ControlElement)QtCurve::Style::CE_QtC_SetOptions, &styleOpt, nullptr, this);
2223 
2224     setStyleRecursive(mdiWindow ? (QWidget *)previewFrame : (QWidget *)stylePreview, style);
2225 }
2226 
2227 static const char * constGradValProp="qtc-grad-val";
2228 
2229 void QtCurveConfig::copyGradient(QAction *act)
2230 {
2231     int            val=act->property(constGradValProp).toInt();
2232     const Gradient *copy=nullptr;
2233 
2234     if(val>=APPEARANCE_CUSTOM1 && val <(APPEARANCE_CUSTOM1+NUM_CUSTOM_GRAD))
2235     {
2236         // Custom gradient!
2237         if(val!=gradCombo->currentIndex())
2238         {
2239             GradientCont::const_iterator grad(customGradient.find((EAppearance)val));
2240 
2241             if(grad!=customGradient.end())
2242                 copy=&((*grad).second);
2243         }
2244     }
2245     else
2246         copy=qtcGetGradient((EAppearance)val, &previewStyle);
2247 
2248     if(copy)
2249     {
2250         customGradient[(EAppearance)gradCombo->currentIndex()]=*copy;
2251         gradChanged(gradCombo->currentIndex());
2252         emit changed(true);
2253     }
2254 }
2255 
2256 void QtCurveConfig::previewControlPressed()
2257 {
2258     if(mdiWindow)
2259     {
2260         previewControlButton->setText(i18n("Reattach"));
2261         workSpace->removeSubWindow(stylePreview);
2262         if(stylePreview)
2263             stylePreview->deleteLater();
2264         mdiWindow->deleteLater();
2265         mdiWindow=nullptr;
2266         stylePreview = new CStylePreview(this);
2267         stylePreview->show();
2268     }
2269     else
2270     {
2271         if(stylePreview)
2272             stylePreview->deleteLater();
2273         stylePreview = new CStylePreview;
2274         mdiWindow = workSpace->addSubWindow(stylePreview, Qt::Window);
2275         mdiWindow->move(4, 4);
2276         mdiWindow->showMaximized();
2277         previewControlButton->setText(i18n("Detach"));
2278     }
2279     connect(stylePreview, SIGNAL(closePressed()), SLOT(previewControlPressed()));
2280     updatePreview();
2281 }
2282 
2283 void QtCurveConfig::setupGradientsTab()
2284 {
2285     QMenu *menu=new QMenu(copyGradientButton);
2286 
2287     for(int i=0; i<appearance->count(); ++i)
2288         menu->addAction(appearance->itemText(i))->setProperty(constGradValProp, i);
2289 
2290     for(int i=APPEARANCE_CUSTOM1; i<(APPEARANCE_CUSTOM1+NUM_CUSTOM_GRAD); ++i)
2291         gradCombo->insertItem(i-APPEARANCE_CUSTOM1, i18n("Custom gradient %1", (i-APPEARANCE_CUSTOM1)+1));
2292 
2293     gradCombo->setCurrentIndex(APPEARANCE_CUSTOM1);
2294 
2295     copyGradientButton->setIcon(KIcon("edit-copy"));
2296     copyGradientButton->setToolTip(i18n("Copy settings from another gradient"));
2297     copyGradientButton->setMenu(menu);
2298     copyGradientButton->setPopupMode(QToolButton::InstantPopup);
2299     connect(menu, SIGNAL(triggered(QAction *)), SLOT(copyGradient(QAction *)));
2300 
2301     gradPreview=new CGradientPreview(this, previewWidgetContainer);
2302     QBoxLayout *layout=new QBoxLayout(QBoxLayout::TopToBottom, previewWidgetContainer);
2303     layout->addWidget(gradPreview);
2304     layout->setMargin(0);
2305     layout->setSpacing(0);
2306     QColor col(palette().color(QPalette::Active, QPalette::Button));
2307     previewColor->setColor(col);
2308     gradPreview->setColor(col);
2309     gradChanged(APPEARANCE_CUSTOM1);
2310     addButton->setGuiItem(KGuiItem(i18n("Add"), "list-add"));
2311     removeButton->setGuiItem(KGuiItem(i18n("Remove"), "list-remove"));
2312     updateButton->setGuiItem(KGuiItem(i18n("Update"), "dialog-ok"));
2313 
2314     stopPosition->setRange(0, 100, 5);
2315     stopValue->setRange(0, 200, 5);
2316     stopAlpha->setRange(0, 100, 5);
2317     removeButton->setEnabled(false);
2318     updateButton->setEnabled(false);
2319     connect(gradCombo, SIGNAL(currentIndexChanged(int)), SLOT(gradChanged(int)));
2320     connect(gradBorder, SIGNAL(currentIndexChanged(int)), SLOT(borderChanged(int)));
2321     connect(previewColor, SIGNAL(changed(const QColor &)), gradPreview, SLOT(setColor(const QColor &)));
2322     connect(gradStops, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), SLOT(editItem(QTreeWidgetItem *, int)));
2323     connect(gradStops, SIGNAL(itemChanged(QTreeWidgetItem *, int)), SLOT(itemChanged(QTreeWidgetItem *, int)));
2324     connect(addButton, SIGNAL(clicked(bool)), SLOT(addGradStop()));
2325     connect(removeButton, SIGNAL(clicked(bool)), SLOT(removeGradStop()));
2326     connect(updateButton, SIGNAL(clicked(bool)), SLOT(updateGradStop()));
2327     connect(gradStops, SIGNAL(itemSelectionChanged()), SLOT(stopSelected()));
2328 }
2329 
2330 void QtCurveConfig::setupShadesTab()
2331 {
2332     int shade(0);
2333 
2334     setupShade(shade0, shade++);
2335     setupShade(shade1, shade++);
2336     setupShade(shade2, shade++);
2337     setupShade(shade3, shade++);
2338     setupShade(shade4, shade++);
2339     setupShade(shade5, shade++);
2340     connect(customShading, SIGNAL(toggled(bool)), SLOT(updateChanged()));
2341     shade=0;
2342     setupAlpha(alpha0, shade++);
2343     setupAlpha(alpha1, shade++);
2344     connect(customAlphas, SIGNAL(toggled(bool)), SLOT(updateChanged()));
2345 }
2346 
2347 void QtCurveConfig::setupShade(KDoubleNumInput *w, int shade)
2348 {
2349     w->setRange(0.0, 2.0, 0.05, false);
2350     connect(w, SIGNAL(valueChanged(double)), SLOT(updateChanged()));
2351     shadeVals[shade]=w;
2352 }
2353 
2354 void QtCurveConfig::setupAlpha(KDoubleNumInput *w, int alpha)
2355 {
2356     w->setRange(0.0, 1.0, 0.05, false);
2357     connect(w, SIGNAL(valueChanged(double)), SLOT(updateChanged()));
2358     alphaVals[alpha]=w;
2359 }
2360 
2361 void QtCurveConfig::populateShades(const Options &opts)
2362 {
2363     int contrast = (QSettings(QLatin1String("Trolltech"))
2364                     .value("/Qt/KDE/contrast", 7).toInt());
2365 
2366     if(contrast<0 || contrast>10)
2367         contrast=7;
2368 
2369     customShading->setChecked(USE_CUSTOM_SHADES(opts));
2370 
2371     for(int i=0; i<QTC_NUM_STD_SHADES; ++i)
2372         shadeVals[i]->setValue(USE_CUSTOM_SHADES(opts) ? opts.customShades[i] :
2373                                qtc_intern_shades[shading->currentIndex() ==
2374                                                  int(Shading::Simple) ? 1 : 0]
2375                                [contrast][i]);
2376 
2377     customAlphas->setChecked(USE_CUSTOM_ALPHAS(opts));
2378     alphaVals[0]->setValue(USE_CUSTOM_ALPHAS(opts) ? opts.customAlphas[0] : ETCH_TOP_ALPHA);
2379     alphaVals[1]->setValue(USE_CUSTOM_ALPHAS(opts) ? opts.customAlphas[1] : ETCH_BOTTOM_ALPHA);
2380 }
2381 
2382 bool QtCurveConfig::diffShades(const Options &opts)
2383 {
2384     if( (!USE_CUSTOM_SHADES(opts) && customShading->isChecked()) ||
2385         (USE_CUSTOM_SHADES(opts) && !customShading->isChecked()) )
2386         return true;
2387 
2388     if(customShading->isChecked())
2389     {
2390         for(int i=0; i<QTC_NUM_STD_SHADES; ++i)
2391             if(!qtcEqual(shadeVals[i]->value(), opts.customShades[i]))
2392                 return true;
2393     }
2394 
2395     if( (!USE_CUSTOM_ALPHAS(opts) && customAlphas->isChecked()) ||
2396         (USE_CUSTOM_ALPHAS(opts) && !customAlphas->isChecked()) )
2397         return true;
2398 
2399     if(customAlphas->isChecked())
2400     {
2401         for(int i=0; i<NUM_STD_ALPHAS; ++i)
2402             if(!qtcEqual(alphaVals[i]->value(), opts.customAlphas[i]))
2403                 return true;
2404     }
2405     return false;
2406 }
2407 
2408 bool QtCurveConfig::haveImages()
2409 {
2410     return IMG_FILE==bgndImage->currentIndex() ||
2411            IMG_FILE==menuBgndImage->currentIndex() ||
2412            APPEARANCE_FILE==bgndAppearance->currentIndex() ||
2413            APPEARANCE_FILE==menuBgndAppearance->currentIndex();
2414 }
2415 
2416 bool QtCurveConfig::diffImages(const Options &opts)
2417 {
2418     return (IMG_FILE==bgndImage->currentIndex() &&
2419                 ( getThemeFile(bgndImageDlg->fileName())!=getThemeFile(opts.bgndImage.pixmap.file) ||
2420                   bgndImageDlg->imgWidth()!=opts.bgndImage.width ||
2421                   bgndImageDlg->imgHeight()!=opts.bgndImage.height ||
2422                   bgndImageDlg->onWindowBorder()!=opts.bgndImage.onBorder ||
2423                   bgndImageDlg->imgPos()!=opts.bgndImage.pos ) ) ||
2424            (IMG_FILE==menuBgndImage->currentIndex() &&
2425                 ( getThemeFile(menuBgndImageDlg->fileName())!=getThemeFile(opts.menuBgndImage.pixmap.file) ||
2426                   menuBgndImageDlg->imgWidth()!=opts.menuBgndImage.width ||
2427                   menuBgndImageDlg->imgHeight()!=opts.menuBgndImage.height ||
2428                   menuBgndImageDlg->imgPos()!=opts.menuBgndImage.pos ) ) ||
2429            (APPEARANCE_FILE==bgndAppearance->currentIndex() &&
2430                 (getThemeFile(bgndPixmapDlg->fileName())!=getThemeFile(opts.bgndPixmap.file))) ||
2431            (APPEARANCE_FILE==menuBgndAppearance->currentIndex() &&
2432                 (getThemeFile(menuBgndPixmapDlg->fileName())!=getThemeFile(opts.menuBgndPixmap.file)));
2433 }
2434 
2435 void QtCurveConfig::setPasswordChar(int ch)
2436 {
2437     QString     str;
2438     QTextStream s(&str);
2439 
2440     s.setIntegerBase(16);
2441     s << QChar(ch) << " (" << ch << ')';
2442     passwordChar->setText(str);
2443 }
2444 
2445 void QtCurveConfig::updateChanged()
2446 {
2447     // Check if we have a floating preview!
2448     if(!mdiWindow && settingsChanged(previewStyle))
2449         updatePreview();
2450 
2451     if (settingsChanged())
2452         emit changed(true);
2453 }
2454 
2455 void QtCurveConfig::gtkButtonOrderChanged()
2456 {
2457     if(gtkButtonOrder->isChecked())
2458         reorderGtkButtons->setChecked(false);
2459     updateChanged();
2460 }
2461 
2462 void QtCurveConfig::reorderGtkButtonsChanged()
2463 {
2464     if(reorderGtkButtons->isChecked())
2465         gtkButtonOrder->setChecked(false);
2466     updateChanged();
2467 }
2468 
2469 void QtCurveConfig::focusChanged()
2470 {
2471     if(ROUND_MAX==round->currentIndex() && FOCUS_LINE!=focus->currentIndex() && !(EFFECT_NONE!=buttonEffect->currentIndex() && FOCUS_GLOW==focus->currentIndex()))
2472         round->setCurrentIndex(ROUND_EXTRA);
2473     updateChanged();
2474 }
2475 
2476 void QtCurveConfig::roundChanged()
2477 {
2478     if (ROUND_MAX == round->currentIndex() &&
2479         FOCUS_LINE != focus->currentIndex() &&
2480         !(EFFECT_NONE != buttonEffect->currentIndex() &&
2481           FOCUS_GLOW == focus->currentIndex())) {
2482         focus->setCurrentIndex(EFFECT_NONE == buttonEffect->currentIndex() ?
2483                                FOCUS_LINE : FOCUS_GLOW);
2484     }
2485 
2486     if(round->currentIndex()>ROUND_FULL && IND_COLORED==defBtnIndicator->currentIndex())
2487         defBtnIndicator->setCurrentIndex(IND_TINT);
2488     updateChanged();
2489 }
2490 
2491 void QtCurveConfig::setPreset()
2492 {
2493     readyForPreview=false;
2494     Preset &p(presets[presetsCombo->currentText()]);
2495 
2496     if(!p.loaded)
2497         qtcReadConfig(p.fileName, &p.opts, &presets[defaultText].opts, false);
2498 
2499     setWidgetOptions(p.opts);
2500 
2501     if(defaultText==presetsCombo->currentText())
2502         kwin->defaults();
2503     else if(currentText==presetsCombo->currentText())
2504         kwin->load(0);
2505     else if(p.opts.version>=VERSION_WITH_KWIN_SETTINGS)
2506     {
2507         KConfig cfg(p.fileName, KConfig::SimpleConfig);
2508 
2509         if(cfg.hasGroup(KWIN_GROUP))
2510             kwin->load(&cfg);
2511     }
2512 
2513     readyForPreview=true;
2514     if (settingsChanged(previewStyle))
2515         updatePreview();
2516     if (settingsChanged())
2517         emit changed(true);
2518 
2519     deleteButton->setEnabled(currentText!=presetsCombo->currentText() &&
2520                              defaultText!=presetsCombo->currentText() &&
2521                              0==presets[presetsCombo->currentText()].fileName.indexOf(QDir::homePath()));
2522     gradChanged(gradCombo->currentIndex());
2523 }
2524 
2525 void QtCurveConfig::savePreset()
2526 {
2527     QString name=getPresetName(i18n("Save Preset"), i18n("Please enter a name for the preset:"),
2528                                currentText==presetsCombo->currentText() || defaultText==presetsCombo->currentText()
2529                                 ? i18n("New preset")
2530                                 : 0==presets[presetsCombo->currentText()].fileName.indexOf(QDir::homePath())
2531                                     ? presetsCombo->currentText()
2532                                     : i18n("%1 New", presetsCombo->currentText()));
2533 
2534     if(!name.isEmpty() && !savePreset(name))
2535         KMessageBox::error(this, i18n("Sorry, failed to save preset"));
2536 }
2537 
2538 bool QtCurveConfig::savePreset(const QString &name)
2539 {
2540     if(!kwin->ok())
2541         return false;
2542 
2543     QString fname=QString(name).replace(' ', '_');
2544     QString dir(KGlobal::dirs()->saveLocation("data", "QtCurve/"));
2545 
2546     KConfig cfg(dir+fname+EXTENSION, KConfig::NoGlobals);
2547     Options opts;
2548 
2549     setOptions(opts);
2550 
2551     if(IMG_FILE==opts.bgndImage.type)
2552         opts.bgndImage.pixmap.file=saveThemeFile(bgndImageDlg->fileName(), BGND_FILE IMAGE_FILE, fname);
2553     if(APPEARANCE_FILE==opts.bgndAppearance)
2554         opts.bgndPixmap.file=saveThemeFile(bgndPixmapDlg->fileName(), BGND_FILE, fname);
2555     if(IMG_FILE==opts.menuBgndImage.type)
2556         opts.menuBgndImage.pixmap.file=saveThemeFile(menuBgndImageDlg->fileName(), BGND_FILE MENU_FILE IMAGE_FILE, fname);
2557     if(APPEARANCE_FILE==opts.menuBgndAppearance)
2558         opts.menuBgndPixmap.file=saveThemeFile(menuBgndPixmapDlg->fileName(), BGND_FILE MENU_FILE, fname);
2559 
2560     if(qtcWriteConfig(&cfg, opts, presets[defaultText].opts, true))
2561     {
2562         kwin->save(&cfg);
2563 
2564         QMap<QString, Preset>::iterator it(presets.find(name)),
2565                                         end(presets.end());
2566 
2567         presets[name]=Preset(opts, dir+fname+EXTENSION);
2568         if(it==end)
2569         {
2570             presetsCombo->insertItem(0, name);
2571             presetsCombo->model()->sort(0);
2572             int index=-1;
2573 
2574             for(int i=0; i<presetsCombo->count() && -1==index; ++i)
2575                 if(presetsCombo->itemText(i)==name)
2576                     index=i;
2577 
2578             presetsCombo->setCurrentIndex(index);
2579             setPreset();
2580         }
2581 
2582         return true;
2583     }
2584 
2585     return false;
2586 }
2587 
2588 QString QtCurveConfig::getPresetName(const QString &cap, QString label, QString def, QString name)
2589 {
2590     QRegExp exp("\\w+[^\\0042\\0044\\0045\\0046\\0047\\0052\\0057\\0077\\0137\\0140]*");
2591     QRegExpValidator validator(exp, this);
2592 
2593     while (true) {
2594         if (name.isEmpty())
2595             name = KInputDialog::getText(cap, label, def, 0, this, &validator);
2596 
2597         if (!name.isEmpty()) {
2598             name = name.replace('\"', ' ')
2599                 .replace('$', ' ')
2600                 .replace('%', ' ')
2601                 .replace('&', ' ')
2602                 .replace('\'', ' ')
2603                 .replace('*', ' ')
2604                 .replace('/', ' ')
2605                 .replace('?', ' ')
2606                 .replace('_', ' ')
2607                 .replace('`', ' ')
2608                 .simplified();
2609 
2610             if (name == currentText || name == defaultText) {
2611                 label = i18n("<p>You cannot use the name \"%1\".</p>"
2612                              "<p>Please enter a different name:</p>", name);
2613                 def = i18n("%1 New", name);
2614                 name = QString();
2615             } else {
2616                 QMap<QString, Preset>::iterator it(presets.find(name));
2617 
2618                 if (it != presets.end()) {
2619                     if ((*it).fileName.indexOf(QDir::homePath()) != 0) {
2620                         label = i18n("<p>A system defined preset named "
2621                                      "\"%1\" already exists.</p>"
2622                                      "<p>Please enter a new name:</p>", name);
2623                         def = i18n("%1 New", name);
2624                         name = QString();
2625                     } else if(name == presetsCombo->currentText() ||
2626                               KMessageBox::warningYesNo(
2627                                   this, i18n("<p>A preset named \"%1\" "
2628                                              "already exists.</p><p>Do you "
2629                                              "wish to overwrite this?</p>",
2630                                              name)) == KMessageBox::Yes) {
2631                         return name;
2632                     } else {
2633                         label = i18n("<p>Please enter a new name:</p>");
2634                         def = i18n("%1 New", name);
2635                         name = QString();
2636                     }
2637                 } else {
2638                     return name;
2639                 }
2640             }
2641         } else {
2642             return QString();
2643         }
2644     }
2645 
2646     return QString();
2647 }
2648 
2649 void QtCurveConfig::deletePreset()
2650 {
2651     if(KMessageBox::Yes==KMessageBox::warningYesNo(this, i18n("<p>Are you sure you wish to delete:</p><p><b>%1</b></p>",
2652                                                               presetsCombo->currentText())))
2653     {
2654         if(QFile::remove(presets[presetsCombo->currentText()].fileName))
2655         {
2656             removeThemeImages(presets[presetsCombo->currentText()].fileName);
2657             presets.remove(presetsCombo->currentText());
2658             presetsCombo->removeItem(presetsCombo->currentIndex());
2659         }
2660         else
2661             KMessageBox::error(this, i18n("<p>Sorry, failed to remove the preset file:</p><p><i>%1</i></p>",
2662                                           presets[presetsCombo->currentText()].fileName));
2663     }
2664 }
2665 
2666 void QtCurveConfig::importPreset()
2667 {
2668     QString file(KFileDialog::getOpenFileName(
2669                      KUrl(), i18n("*" EXTENSION "|QtCurve Settings Files\n"
2670                                   THEME_PREFIX "*" THEME_SUFFIX
2671                                   "|QtCurve KDE Theme Files"), this));
2672 
2673     if (!file.isEmpty()) {
2674         KMimeType::Ptr mimeType = KMimeType::findByFileContent(file);;
2675         bool compressed(mimeType && !mimeType->is("text/plain"));
2676         QString fileName(getFileName(file));
2677         QString baseName(fileName.remove(EXTENSION).replace(' ', '_'));
2678         QString name(QString(baseName).replace('_', ' '));
2679         Options opts;
2680 
2681         if (name.isEmpty()) {
2682             KMessageBox::error(this, i18n("<p>Sorry, failed to load file.</p>"
2683                                           "<p><i>Empty preset name?</i></p>"));
2684         } else if (QtCurve::oneOf(name, currentText, defaultText)) {
2685             KMessageBox::error(this, i18n("<p>Sorry, failed to load file.</p>"
2686                                           "<p><i>Cannot have a preset named "
2687                                           "\"%1\"</i></p>", name));
2688         } else {
2689             QString qtcFile(file);
2690             std::unique_ptr<KZip> zip(compressed ? new KZip(file) : nullptr);
2691             std::unique_ptr<KTempDir> tmpDir;
2692             if (compressed) {
2693                 qtcFile = QString();
2694                 if (!zip->open(QIODevice::ReadOnly)) {
2695                     KMessageBox::error(this, i18n("Sorry, failed to open "
2696                                                   "compressed file."));
2697                 } else {
2698                     const KArchiveDirectory *zipDir = zip->directory();
2699                     if (zipDir) {
2700                         tmpDir.reset(new KTempDir(KStandardDirs::locateLocal(
2701                                                       "tmp", "qtcurve")));
2702                         tmpDir->setAutoRemove(false);
2703                         zipDir->copyTo(tmpDir->name(), false);
2704 
2705                         // Find settings file...
2706                         QDir dir(tmpDir->name());
2707                         for (const QString &file: dir.entryList()) {
2708                             if (file.endsWith(EXTENSION)) {
2709                                 qtcFile = dir.path() + "/" + file;
2710                             }
2711                         }
2712                         if (qtcFile.isEmpty()) {
2713                             KMessageBox::error(
2714                                 this, i18n("Invalid compressed settings "
2715                                            "file.\n(Could not locate settings "
2716                                            "file.)"));
2717                         }
2718                     } else {
2719                         KMessageBox::error(
2720                             this, i18n("Invalid compressed settings file.\n"
2721                                        "(Could not list ZIP contents.)"));
2722                     }
2723                 }
2724             }
2725 
2726             if (!qtcFile.isEmpty()) {
2727                 if (qtcReadConfig(qtcFile, &opts, &presets[defaultText].opts,
2728                                   false)) {
2729                     name = getPresetName(i18n("Import Preset"), QString(),
2730                                          name, name);
2731                     if (!name.isEmpty()) {
2732                         QString qtcDir(KGlobal::dirs()
2733                                        ->saveLocation("data", "QtCurve/") + '/');
2734                         name = name.replace(' ', '_');
2735 
2736                         if (compressed && tmpDir) {
2737                             if (opts.bgndImage.type == IMG_FILE) {
2738                                 auto &file = opts.bgndImage.pixmap.file;
2739                                 QString fileName(name + BGND_FILE IMAGE_FILE +
2740                                                  getExt(file));
2741                                 saveThemeFile(tmpDir->name() + '/'+
2742                                               getFileName(file),
2743                                               BGND_FILE IMAGE_FILE, name);
2744                                 file = fileName;
2745                             }
2746                             if (opts.menuBgndImage.type == IMG_FILE) {
2747                                 auto &file = opts.menuBgndImage.pixmap.file;
2748                                 QString fileName(name + BGND_FILE MENU_FILE
2749                                                  IMAGE_FILE + getExt(file));
2750                                 saveThemeFile(tmpDir->name() + '/' +
2751                                               getFileName(file),
2752                                               BGND_FILE MENU_FILE IMAGE_FILE,
2753                                               name);
2754                                 file = fileName;
2755                             }
2756                             if (opts.bgndAppearance == APPEARANCE_FILE) {
2757                                 auto &file = opts.bgndPixmap.file;
2758                                 QString fileName(name + BGND_FILE +
2759                                                  getExt(file));
2760                                 saveThemeFile(tmpDir->name() + '/' +
2761                                               getFileName(file), BGND_FILE,
2762                                               name);
2763                                 file = fileName;
2764                             }
2765                             if (opts.menuBgndAppearance == APPEARANCE_FILE) {
2766                                 auto &file = opts.menuBgndPixmap.file;
2767                                 QString fileName(name + BGND_FILE MENU_FILE +
2768                                                  getExt(file));
2769                                 saveThemeFile(tmpDir->name() + '/' +
2770                                               getFileName(file),
2771                                               BGND_FILE MENU_FILE, name);
2772                                 file = fileName;
2773                             }
2774                         }
2775 
2776                         readyForPreview = false;
2777                         setWidgetOptions(opts);
2778                         savePreset(name);
2779 
2780                         // Load kwin options - if present
2781                         KConfig cfg(qtcFile, KConfig::SimpleConfig);
2782 
2783                         if (cfg.hasGroup(KWIN_GROUP)) {
2784                             KConfigGroup grp(&cfg, SETTINGS_GROUP);
2785                             QStringList  ver(
2786                                 grp.readEntry("version", QString()).split('.'));
2787 
2788                             if (ver.count() >= 3 &&
2789                                 qtcMakeVersion(ver[0].toInt(),
2790                                                ver[1].toInt()) >=
2791                                 VERSION_WITH_KWIN_SETTINGS) {
2792                                 kwin->load(&cfg);
2793                             }
2794                         }
2795                         readyForPreview = true;
2796                         updatePreview();
2797                     }
2798                 } else {
2799                     KMessageBox::error(this,
2800                                        i18n("Sorry, failed to load file."));
2801                 }
2802             }
2803         }
2804     }
2805 }
2806 
2807 void QtCurveConfig::exportPreset()
2808 {
2809 #ifdef QTC_QT4_STYLE_SUPPORT
2810     switch (KMessageBox::questionYesNoCancel(
2811                 this, i18n("<p>In which format would you like to export the "
2812                            "QtCurve settings?<ul><li><i>QtCurve settings "
2813                            "file</i> - a file to be imported via this config "
2814                            "dialog.</li><li><i>Standalone theme</i> - a style "
2815                            "that user\'s can select from the KDE style panel."
2816                            "</li></ul></p>"), i18n("Export Settings"),
2817                 KGuiItem(i18n("QtCurve Settings File")),
2818                 KGuiItem(i18n("Standalone Theme")))) {
2819     case KMessageBox::No:
2820         exportTheme();
2821     case KMessageBox::Cancel:
2822         return;
2823     case KMessageBox::Yes:
2824         break;
2825     }
2826 #endif
2827 
2828     bool compressed = haveImages();
2829     QString file(KFileDialog::getSaveFileName(
2830                      KUrl(), i18n("*" EXTENSION "|QtCurve Settings Files"),
2831                      this));
2832 
2833     if (!file.isEmpty()) {
2834         bool rv = [&] {
2835             std::unique_ptr<KZip> zip(compressed ? new KZip(file) : nullptr);
2836             if (zip && !zip->open(QIODevice::WriteOnly))
2837                 return false;
2838             std::unique_ptr<KTemporaryFile> temp(
2839                 compressed ? new KTemporaryFile() : nullptr);
2840             if (temp && !temp->open())
2841                 return false;
2842             KConfig cfg(compressed ? temp->fileName() : file,
2843                         KConfig::NoGlobals);
2844             Options opts;
2845             QString bgndImageName;
2846             QString menuBgndImageName;
2847             QString bgndPixmapName;
2848             QString menuBgndPixmapName;
2849             QString themeName(getFileName(file).remove(EXTENSION)
2850                               .replace(' ', '_'));
2851             setOptions(opts);
2852             if (compressed) {
2853                 if (opts.bgndImage.type == IMG_FILE) {
2854                     bgndImageName = getThemeFile(opts.bgndImage.pixmap.file);
2855                     opts.bgndImage.pixmap.file =
2856                         themeName + BGND_FILE IMAGE_FILE +
2857                         getExt(bgndImageName);
2858                 }
2859                 if (opts.menuBgndImage.type == IMG_FILE) {
2860                     menuBgndImageName =
2861                         getThemeFile(opts.menuBgndImage.pixmap.file);
2862                     opts.menuBgndImage.pixmap.file =
2863                         themeName + BGND_FILE MENU_FILE IMAGE_FILE +
2864                         getExt(menuBgndImageName);
2865                 }
2866                 if (opts.bgndAppearance == APPEARANCE_FILE) {
2867                     bgndPixmapName = getThemeFile(opts.bgndPixmap.file);
2868                     opts.bgndPixmap.file =
2869                         themeName + BGND_FILE + getExt(bgndPixmapName);
2870                 }
2871                 if (opts.menuBgndAppearance == APPEARANCE_FILE) {
2872                     menuBgndPixmapName = getThemeFile(opts.menuBgndPixmap.file);
2873                     opts.menuBgndPixmap.file =
2874                         themeName + BGND_FILE MENU_FILE +
2875                         getExt(menuBgndPixmapName);
2876                 }
2877             }
2878             if (!qtcWriteConfig(&cfg, opts, presets[defaultText].opts, true))
2879                 return false;
2880             kwin->save(&cfg);
2881             if (compressed) {
2882                 zip->addLocalFile(temp->fileName(), themeName + EXTENSION);
2883                 if (!bgndImageName.isEmpty())
2884                     zip->addLocalFile(bgndImageName,
2885                                       opts.bgndImage.pixmap.file);
2886                 if (!menuBgndImageName.isEmpty())
2887                     zip->addLocalFile(menuBgndImageName,
2888                                       opts.menuBgndImage.pixmap.file);
2889                 if (!bgndPixmapName.isEmpty())
2890                     zip->addLocalFile(bgndPixmapName, opts.bgndPixmap.file);
2891                 if (!menuBgndPixmapName.isEmpty())
2892                     zip->addLocalFile(menuBgndPixmapName,
2893                                       opts.menuBgndPixmap.file);
2894                 zip->close();
2895             }
2896             return true;
2897         }();
2898         if (!rv) {
2899             KMessageBox::error(this, i18n("Could not write to file:\n%1",
2900                                           file));
2901         }
2902     }
2903 }
2904 
2905 void QtCurveConfig::exportTheme()
2906 {
2907 #ifdef QTC_QT4_STYLE_SUPPORT
2908     if (!exportDialog)
2909         exportDialog = new CExportThemeDialog(this);
2910 
2911     Options opts;
2912 
2913     setOptions(opts);
2914     exportDialog->run(opts);
2915 #endif
2916 }
2917 
2918 int QtCurveConfig::getTitleBarButtonFlags()
2919 {
2920     int titlebarButtons=0;
2921 
2922     if(titlebarButtons_button->isChecked())
2923         titlebarButtons+=TITLEBAR_BUTTON_STD_COLOR;
2924     if(titlebarButtons_custom->isChecked())
2925         titlebarButtons+=TITLEBAR_BUTTON_COLOR;
2926     if(titlebarButtons_customIcon->isChecked())
2927         titlebarButtons+=TITLEBAR_BUTTON_ICON_COLOR;
2928     if(titlebarButtons_noFrame->isChecked())
2929         titlebarButtons+=TITLEBAR_BUTTON_NO_FRAME;
2930     if(titlebarButtons_round->isChecked())
2931         titlebarButtons+=TITLEBAR_BUTTON_ROUND;
2932     if(titlebarButtons_hoverFrame->isChecked())
2933         titlebarButtons+=TITLEBAR_BUTTON_HOVER_FRAME;
2934     if(titlebarButtons_hoverSymbol->isChecked())
2935         titlebarButtons+=TITLEBAR_BUTTON_HOVER_SYMBOL;
2936     if(titlebarButtons_hoverSymbolFull->isChecked())
2937         titlebarButtons+=TITLEBAR_BUTTON_HOVER_SYMBOL_FULL;
2938     if(titlebarButtons_colorOnMouseOver->isChecked())
2939         titlebarButtons+=TITLEBAR_BUTTON_COLOR_MOUSE_OVER;
2940     if(titlebarButtons_colorInactive->isChecked())
2941         titlebarButtons+=TITLEBAR_BUTTON_COLOR_INACTIVE;
2942     if(titlebarButtons_colorSymbolsOnly->isChecked())
2943         titlebarButtons+=TITLEBAR_BUTTON_COLOR_SYMBOL;
2944     if(titlebarButtons_sunkenBackground->isChecked())
2945         titlebarButtons+=TITLEBAR_BUTTON_SUNKEN_BACKGROUND;
2946     if(titlebarButtons_arrowMinMax->isChecked())
2947         titlebarButtons+=TITLEBAR_BUTTOM_ARROW_MIN_MAX;
2948     if(titlebarButtons_hideOnInactiveWindow->isChecked())
2949         titlebarButtons+=TITLEBAR_BUTTOM_HIDE_ON_INACTIVE_WINDOW;
2950     if(titlebarButtons_useHover->isChecked())
2951         titlebarButtons+=TITLEBAR_BUTTON_USE_HOVER_COLOR;
2952     return titlebarButtons;
2953 }
2954 
2955 int QtCurveConfig::getGroupBoxLabelFlags()
2956 {
2957     int flags=0;
2958     if(gbLabel_bold->isChecked())
2959         flags+=GB_LBL_BOLD;
2960     if(gbLabel_centred->isChecked())
2961         flags+=GB_LBL_CENTRED;
2962     switch(gbLabel_textPos->currentIndex())
2963     {
2964         case GBV_INSIDE:
2965             flags+=GB_LBL_INSIDE;
2966             break;
2967         case GBV_OUTSIDE:
2968             flags+=GB_LBL_OUTSIDE;
2969         default:
2970             break;
2971     }
2972     return flags;
2973 }
2974 
2975 void QtCurveConfig::setOptions(Options &opts)
2976 {
2977     opts.round=(ERound)round->currentIndex();
2978     opts.toolbarBorders=(ETBarBorder)toolbarBorders->currentIndex();
2979     opts.appearance=(EAppearance)appearance->currentIndex();
2980     opts.focus=(EFocus)focus->currentIndex();
2981     opts.lvLines=lvLines->isChecked();
2982     opts.lvButton=lvButton->isChecked();
2983     opts.drawStatusBarFrames=drawStatusBarFrames->isChecked();
2984     opts.buttonEffect=(EEffect)buttonEffect->currentIndex();
2985     opts.coloredMouseOver=(EMouseOver)coloredMouseOver->currentIndex();
2986     opts.menubarMouseOver=menubarMouseOver->isChecked();
2987     opts.shadeMenubarOnlyWhenActive=shadeMenubarOnlyWhenActive->isChecked();
2988     opts.thin=getThinFlags();
2989     opts.animatedProgress=animatedProgress->isChecked();
2990     opts.stripedProgress=(EStripe)stripedProgress->currentIndex();
2991     opts.lighterPopupMenuBgnd=lighterPopupMenuBgnd->value();
2992     opts.tabBgnd=tabBgnd->value();
2993     opts.menuDelay=menuDelay->value();
2994     opts.menuCloseDelay=menuCloseDelay->value();
2995     opts.sliderWidth=sliderWidth->value();
2996     opts.menuStripe=(EShade)menuStripe->currentIndex();
2997     opts.customMenuStripeColor=customMenuStripeColor->color();
2998     opts.menuStripeAppearance=(EAppearance)menuStripeAppearance->currentIndex();
2999     opts.bgndGrad=(EGradType)bgndGrad->currentIndex();
3000     opts.menuBgndGrad=(EGradType)menuBgndGrad->currentIndex();
3001     opts.embolden=embolden->isChecked();
3002     opts.scrollbarType=(EScrollbar)scrollbarType->currentIndex();
3003     opts.defBtnIndicator=(EDefBtnIndicator)defBtnIndicator->currentIndex();
3004     opts.sliderThumbs=(ELine)sliderThumbs->currentIndex();
3005     opts.handles=(ELine)handles->currentIndex();
3006     opts.highlightTab=highlightTab->isChecked();
3007     opts.shadeSliders=(EShade)shadeSliders->currentIndex();
3008     opts.shadeMenubars=(EShade)shadeMenubars->currentIndex();
3009     opts.menubarAppearance=(EAppearance)menubarAppearance->currentIndex();
3010     opts.toolbarAppearance=(EAppearance)toolbarAppearance->currentIndex();
3011     opts.lvAppearance=(EAppearance)lvAppearance->currentIndex();
3012     opts.sliderAppearance=(EAppearance)sliderAppearance->currentIndex();
3013     opts.tabAppearance=(EAppearance)tabAppearance->currentIndex();
3014     opts.activeTabAppearance=(EAppearance)activeTabAppearance->currentIndex();
3015     opts.toolbarSeparators=(ELine)toolbarSeparators->currentIndex();
3016     opts.splitters=(ELine)splitters->currentIndex();
3017     opts.customSlidersColor=customSlidersColor->color();
3018     opts.customMenubarsColor=customMenubarsColor->color();
3019     opts.highlightFactor=highlightFactor->value();
3020     opts.customMenuNormTextColor=customMenuNormTextColor->color();
3021     opts.customMenuSelTextColor=customMenuSelTextColor->color();
3022     opts.customMenuTextColor=customMenuTextColor->isChecked();
3023     opts.fillSlider=fillSlider->isChecked();
3024     opts.stripedSbar=stripedSbar->isChecked();
3025     opts.sliderStyle=(ESliderStyle)sliderStyle->currentIndex();
3026     opts.roundMbTopOnly=roundMbTopOnly->isChecked();
3027     opts.menubarHiding=getHideFlags(menubarHiding_keyboard, menubarHiding_kwin);
3028     opts.statusbarHiding=getHideFlags(statusbarHiding_keyboard, statusbarHiding_kwin);
3029     opts.fillProgress=fillProgress->isChecked();
3030     opts.glowProgress=(EGlow)glowProgress->currentIndex();
3031     opts.darkerBorders=darkerBorders->isChecked();
3032     opts.comboSplitter=comboSplitter->isChecked();
3033     opts.comboBtn=(EShade)comboBtn->currentIndex();
3034     opts.customComboBtnColor=customComboBtnColor->color();
3035     opts.sortedLv=(EShade)sortedLv->currentIndex();
3036     opts.customSortedLvColor=customSortedLvColor->color();
3037     opts.unifySpinBtns=unifySpinBtns->isChecked();
3038     opts.unifySpin=unifySpin->isChecked();
3039     opts.unifyCombo=unifyCombo->isChecked();
3040     opts.vArrows=vArrows->isChecked();
3041     opts.xCheck=xCheck->isChecked();
3042     opts.hideShortcutUnderline=hideShortcutUnderline->isChecked();
3043     opts.crHighlight=crHighlight->value();
3044     opts.expanderHighlight=expanderHighlight->value();
3045     opts.crButton=crButton->isChecked();
3046     opts.colorSelTab=colorSelTab->value();
3047     opts.roundAllTabs=roundAllTabs->isChecked();
3048     opts.borderTab=borderTab->isChecked();
3049     opts.borderInactiveTab=borderInactiveTab->isChecked();
3050     opts.invertBotTab=invertBotTab->isChecked();
3051     opts.doubleGtkComboArrow=doubleGtkComboArrow->isChecked();
3052     opts.tabMouseOver=(ETabMo)tabMouseOver->currentIndex();
3053     opts.stdSidebarButtons=stdSidebarButtons->isChecked();
3054     opts.toolbarTabs=toolbarTabs->isChecked();
3055     opts.centerTabText=centerTabText->isChecked();
3056     opts.borderMenuitems=borderMenuitems->isChecked();
3057     opts.shadePopupMenu=shadePopupMenu->isChecked();
3058     opts.popupBorder=popupBorder->isChecked();
3059     opts.progressAppearance=(EAppearance)progressAppearance->currentIndex();
3060     opts.progressColor=(EShade)progressColor->currentIndex();
3061     opts.customProgressColor=customProgressColor->color();
3062     opts.progressGrooveAppearance=(EAppearance)progressGrooveAppearance->currentIndex();
3063     opts.grooveAppearance=(EAppearance)grooveAppearance->currentIndex();
3064     opts.sunkenAppearance=(EAppearance)sunkenAppearance->currentIndex();
3065     opts.progressGrooveColor=(EColor)progressGrooveColor->currentIndex();
3066     opts.menuitemAppearance=(EAppearance)menuitemAppearance->currentIndex();
3067     opts.menuBgndAppearance=(EAppearance)menuBgndAppearance->currentIndex();
3068     opts.titlebarAppearance=(EAppearance)titlebarAppearance->currentIndex();
3069     opts.inactiveTitlebarAppearance=(EAppearance)inactiveTitlebarAppearance->currentIndex();
3070     opts.titlebarButtonAppearance=(EAppearance)titlebarButtonAppearance->currentIndex();
3071     opts.windowBorder=getWindowBorderFlags();
3072     opts.selectionAppearance=(EAppearance)selectionAppearance->currentIndex();
3073     opts.shadeCheckRadio=(EShade)shadeCheckRadio->currentIndex();
3074     opts.customCheckRadioColor=customCheckRadioColor->color();
3075     opts.shading=(Shading)shading->currentIndex();
3076     opts.gtkScrollViews=gtkScrollViews->isChecked();
3077     opts.highlightScrollViews=highlightScrollViews->isChecked();
3078     opts.etchEntry=etchEntry->isChecked();
3079     opts.flatSbarButtons=flatSbarButtons->isChecked();
3080     opts.borderSbarGroove=borderSbarGroove->isChecked();
3081     opts.thinSbarGroove=thinSbarGroove->isChecked();
3082     opts.colorSliderMouseOver=colorSliderMouseOver->isChecked();
3083     opts.windowDrag=windowDrag->currentIndex();
3084     opts.sbarBgndAppearance=(EAppearance)sbarBgndAppearance->currentIndex();
3085     opts.sliderFill=(EAppearance)sliderFill->currentIndex();
3086     opts.bgndAppearance=(EAppearance)bgndAppearance->currentIndex();
3087     opts.bgndImage.type=(EImageType)bgndImage->currentIndex();
3088     opts.bgndOpacity=bgndOpacity->value();
3089     opts.dlgOpacity=dlgOpacity->value();
3090     opts.menuBgndImage.type=(EImageType)menuBgndImage->currentIndex();
3091     opts.menuBgndOpacity=menuBgndOpacity->value();
3092     opts.shadowSize=dropShadowSize->value();
3093     qtcX11SetShadowSize(opts.shadowSize);
3094     opts.dwtAppearance=(EAppearance)dwtAppearance->currentIndex();
3095     opts.tooltipAppearance=(EAppearance)tooltipAppearance->currentIndex();
3096     opts.xbar=xbar->isChecked();
3097     opts.crColor=(EShade)crColor->currentIndex();
3098     opts.customCrBgndColor=customCrBgndColor->color();
3099     opts.smallRadio=smallRadio->isChecked();
3100     opts.splitterHighlight=splitterHighlight->value();
3101     opts.gtkComboMenus=gtkComboMenus->isChecked();
3102     opts.gtkButtonOrder=gtkButtonOrder->isChecked();
3103     opts.reorderGtkButtons=reorderGtkButtons->isChecked();
3104     opts.mapKdeIcons=mapKdeIcons->isChecked();
3105     opts.passwordChar=toInt(passwordChar->text());
3106     opts.groupBox=(EFrame)groupBox->currentIndex();
3107     opts.gbFactor=gbFactor->value();
3108     opts.customGradient=customGradient;
3109     opts.colorMenubarMouseOver=colorMenubarMouseOver->isChecked();
3110     opts.useHighlightForMenu=useHighlightForMenu->isChecked();
3111     opts.gbLabel=getGroupBoxLabelFlags();
3112     opts.fadeLines=fadeLines->isChecked();
3113     opts.menuIcons=menuIcons->isChecked();
3114     opts.onlyTicksInMenu=onlyTicksInMenu->isChecked();
3115     opts.buttonStyleMenuSections=buttonStyleMenuSections->isChecked();
3116     opts.stdBtnSizes=stdBtnSizes->isChecked();
3117     opts.boldProgress=boldProgress->isChecked();
3118     opts.coloredTbarMo=coloredTbarMo->isChecked();
3119     opts.tbarBtns=(ETBarBtn)tbarBtns->currentIndex();
3120     opts.tbarBtnAppearance=(EAppearance)tbarBtnAppearance->currentIndex();
3121     opts.tbarBtnEffect=(EEffect)tbarBtnEffect->currentIndex();
3122     opts.borderSelection=borderSelection->isChecked();
3123     opts.forceAlternateLvCols=forceAlternateLvCols->isChecked();
3124     opts.titlebarAlignment=(EAlign)titlebarAlignment->currentIndex();
3125     opts.titlebarEffect=(EEffect)titlebarEffect->currentIndex();
3126     opts.titlebarIcon=(ETitleBarIcon)titlebarIcon->currentIndex();
3127     opts.dwtSettings=getDwtSettingsFlags();
3128     opts.crSize=getCrSize(crSize);
3129     opts.square=getSquareFlags();
3130 
3131     opts.borderProgress=borderProgress->isChecked();
3132 
3133     if(customShading->isChecked())
3134     {
3135         for(int i=0; i<QTC_NUM_STD_SHADES; ++i)
3136             opts.customShades[i]=shadeVals[i]->value();
3137     }
3138     else
3139         opts.customShades[0]=0;
3140 
3141     if(customAlphas->isChecked())
3142     {
3143         for(int i=0; i<NUM_STD_ALPHAS; ++i)
3144             opts.customAlphas[i]=alphaVals[i]->value();
3145     }
3146     else
3147         opts.customAlphas[0]=0;
3148 
3149     opts.titlebarButtons=getTitleBarButtonFlags();
3150     opts.titlebarButtonColors[TITLEBAR_CLOSE]=titlebarButtons_colorClose->color();
3151     opts.titlebarButtonColors[TITLEBAR_MIN]=titlebarButtons_colorMin->color();
3152     opts.titlebarButtonColors[TITLEBAR_MAX]=titlebarButtons_colorMax->color();
3153     opts.titlebarButtonColors[TITLEBAR_KEEP_ABOVE]=titlebarButtons_colorKeepAbove->color();
3154     opts.titlebarButtonColors[TITLEBAR_KEEP_BELOW]=titlebarButtons_colorKeepBelow->color();
3155     opts.titlebarButtonColors[TITLEBAR_HELP]=titlebarButtons_colorHelp->color();
3156     opts.titlebarButtonColors[TITLEBAR_MENU]=titlebarButtons_colorMenu->color();
3157     opts.titlebarButtonColors[TITLEBAR_SHADE]=titlebarButtons_colorShade->color();
3158     opts.titlebarButtonColors[TITLEBAR_ALL_DESKTOPS]=titlebarButtons_colorAllDesktops->color();
3159 
3160     int offset=NUM_TITLEBAR_BUTTONS;
3161     opts.titlebarButtonColors[TITLEBAR_CLOSE+offset]=titlebarButtons_colorCloseIcon->color();
3162     opts.titlebarButtonColors[TITLEBAR_MIN+offset]=titlebarButtons_colorMinIcon->color();
3163     opts.titlebarButtonColors[TITLEBAR_MAX+offset]=titlebarButtons_colorMaxIcon->color();
3164     opts.titlebarButtonColors[TITLEBAR_KEEP_ABOVE+offset]=titlebarButtons_colorKeepAboveIcon->color();
3165     opts.titlebarButtonColors[TITLEBAR_KEEP_BELOW+offset]=titlebarButtons_colorKeepBelowIcon->color();
3166     opts.titlebarButtonColors[TITLEBAR_HELP+offset]=titlebarButtons_colorHelpIcon->color();
3167     opts.titlebarButtonColors[TITLEBAR_MENU+offset]=titlebarButtons_colorMenuIcon->color();
3168     opts.titlebarButtonColors[TITLEBAR_SHADE+offset]=titlebarButtons_colorShadeIcon->color();
3169     opts.titlebarButtonColors[TITLEBAR_ALL_DESKTOPS+offset]=titlebarButtons_colorAllDesktopsIcon->color();
3170     offset+=NUM_TITLEBAR_BUTTONS;
3171     opts.titlebarButtonColors[TITLEBAR_CLOSE+offset]=titlebarButtons_colorCloseInactiveIcon->color();
3172     opts.titlebarButtonColors[TITLEBAR_MIN+offset]=titlebarButtons_colorMinInactiveIcon->color();
3173     opts.titlebarButtonColors[TITLEBAR_MAX+offset]=titlebarButtons_colorMaxInactiveIcon->color();
3174     opts.titlebarButtonColors[TITLEBAR_KEEP_ABOVE+offset]=titlebarButtons_colorKeepAboveInactiveIcon->color();
3175     opts.titlebarButtonColors[TITLEBAR_KEEP_BELOW+offset]=titlebarButtons_colorKeepBelowInactiveIcon->color();
3176     opts.titlebarButtonColors[TITLEBAR_HELP+offset]=titlebarButtons_colorHelpInactiveIcon->color();
3177     opts.titlebarButtonColors[TITLEBAR_MENU+offset]=titlebarButtons_colorMenuInactiveIcon->color();
3178     opts.titlebarButtonColors[TITLEBAR_SHADE+offset]=titlebarButtons_colorShadeInactiveIcon->color();
3179     opts.titlebarButtonColors[TITLEBAR_ALL_DESKTOPS+offset]=titlebarButtons_colorAllDesktopsInactiveIcon->color();
3180 
3181     opts.noBgndGradientApps=toSet(noBgndGradientApps->text());
3182     opts.noBgndOpacityApps=toSet(noBgndOpacityApps->text());
3183     opts.noMenuBgndOpacityApps=toSet(noMenuBgndOpacityApps->text());
3184     opts.noBgndImageApps=toSet(noBgndImageApps->text());
3185     opts.useQtFileDialogApps=toSet(useQtFileDialogApps->text());
3186     opts.menubarApps=toSet(menubarApps->text());
3187     opts.statusbarApps=toSet(statusbarApps->text());
3188     opts.noMenuStripeApps=toSet(noMenuStripeApps->text());
3189     opts.nonnativeMenubarApps=toSet(nonnativeMenubarApps->text());
3190 
3191     if(IMG_FILE==opts.bgndImage.type)
3192     {
3193         opts.bgndImage.pixmap.file=getThemeFile(bgndImageDlg->fileName());
3194 //         printf("SET OP BGND:%s\n", opts.menuBgndImage.pixmap.file.toLatin1().constData());
3195         opts.bgndImage.width=bgndImageDlg->imgWidth();
3196         opts.bgndImage.height=bgndImageDlg->imgHeight();
3197         opts.bgndImage.onBorder=bgndImageDlg->onWindowBorder();
3198         opts.bgndImage.pos=(EPixPos)bgndImageDlg->imgPos();
3199         opts.bgndImage.loaded=false;
3200     }
3201     if(APPEARANCE_FILE==opts.bgndAppearance)
3202     {
3203         opts.bgndPixmap.file=getThemeFile(bgndPixmapDlg->fileName());
3204         if((&opts) == (&previewStyle))
3205             opts.bgndPixmap.img=QPixmap(opts.bgndPixmap.file);
3206     }
3207     if(IMG_FILE==opts.menuBgndImage.type)
3208     {
3209         opts.menuBgndImage.pixmap.file=getThemeFile(menuBgndImageDlg->fileName());
3210 //         printf("SET OP MENU:%s\n", opts.menuBgndImage.pixmap.file.toLatin1().constData());
3211         opts.menuBgndImage.width=menuBgndImageDlg->imgWidth();
3212         opts.menuBgndImage.height=menuBgndImageDlg->imgHeight();
3213         opts.menuBgndImage.onBorder=false; // Not used!!!
3214         opts.menuBgndImage.pos=(EPixPos)menuBgndImageDlg->imgPos();
3215         opts.menuBgndImage.loaded=false;
3216     }
3217     if(APPEARANCE_FILE==opts.menuBgndAppearance)
3218     {
3219         opts.menuBgndPixmap.file=getThemeFile(menuBgndPixmapDlg->fileName());
3220         if((&opts) == (&previewStyle))
3221             opts.menuBgndPixmap.img=QPixmap(opts.menuBgndPixmap.file);
3222     }
3223 }
3224 
3225 static QColor getColor(const TBCols &cols, int btn, int offset=0, const QColor &def=Qt::black)
3226 {
3227     TBCols::const_iterator it=cols.find(btn+(NUM_TITLEBAR_BUTTONS*offset));
3228 
3229     return cols.end()==it ? def : (*it).second;
3230 }
3231 
3232 void QtCurveConfig::setWidgetOptions(const Options &opts)
3233 {
3234     round->setCurrentIndex(opts.round);
3235     scrollbarType->setCurrentIndex(opts.scrollbarType);
3236     lighterPopupMenuBgnd->setValue(opts.lighterPopupMenuBgnd);
3237     tabBgnd->setValue(opts.tabBgnd);
3238     menuDelay->setValue(opts.menuDelay);
3239     menuCloseDelay->setValue(opts.menuCloseDelay);
3240     sliderWidth->setValue(opts.sliderWidth);
3241     menuStripe->setCurrentIndex(opts.menuStripe);
3242     customMenuStripeColor->setColor(opts.customMenuStripeColor);
3243     menuStripeAppearance->setCurrentIndex(opts.menuStripeAppearance);
3244     bgndGrad->setCurrentIndex(opts.bgndGrad);
3245     menuBgndGrad->setCurrentIndex(opts.menuBgndGrad);
3246     toolbarBorders->setCurrentIndex(opts.toolbarBorders);
3247     sliderThumbs->setCurrentIndex(opts.sliderThumbs);
3248     handles->setCurrentIndex(opts.handles);
3249     appearance->setCurrentIndex(opts.appearance);
3250     focus->setCurrentIndex(opts.focus);
3251     lvLines->setChecked(opts.lvLines);
3252     lvButton->setChecked(opts.lvButton);
3253     drawStatusBarFrames->setChecked(opts.drawStatusBarFrames);
3254     buttonEffect->setCurrentIndex(opts.buttonEffect);
3255     coloredMouseOver->setCurrentIndex(opts.coloredMouseOver);
3256     menubarMouseOver->setChecked(opts.menubarMouseOver);
3257     shadeMenubarOnlyWhenActive->setChecked(opts.shadeMenubarOnlyWhenActive);
3258     thin_menuitems->setChecked(opts.thin&THIN_MENU_ITEMS);
3259     thin_buttons->setChecked(opts.thin&THIN_BUTTONS);
3260     thin_frames->setChecked(opts.thin&THIN_FRAMES);
3261     animatedProgress->setChecked(opts.animatedProgress);
3262     stripedProgress->setCurrentIndex(opts.stripedProgress);
3263     embolden->setChecked(opts.embolden);
3264     defBtnIndicator->setCurrentIndex(opts.defBtnIndicator);
3265     highlightTab->setChecked(opts.highlightTab);
3266     menubarAppearance->setCurrentIndex(opts.menubarAppearance);
3267     toolbarAppearance->setCurrentIndex(opts.toolbarAppearance);
3268     lvAppearance->setCurrentIndex(opts.lvAppearance);
3269     sliderAppearance->setCurrentIndex(opts.sliderAppearance);
3270     tabAppearance->setCurrentIndex(opts.tabAppearance);
3271     activeTabAppearance->setCurrentIndex(opts.activeTabAppearance);
3272     toolbarSeparators->setCurrentIndex(opts.toolbarSeparators);
3273     splitters->setCurrentIndex(opts.splitters);
3274     shadeSliders->setCurrentIndex(opts.shadeSliders);
3275     shadeMenubars->setCurrentIndex(opts.shadeMenubars);
3276     highlightFactor->setValue(opts.highlightFactor);
3277     customSlidersColor->setColor(opts.customSlidersColor);
3278     customMenubarsColor->setColor(opts.customMenubarsColor);
3279     customMenuNormTextColor->setColor(opts.customMenuNormTextColor);
3280     customMenuSelTextColor->setColor(opts.customMenuSelTextColor);
3281     customMenuTextColor->setChecked(opts.customMenuTextColor);
3282 
3283     customSlidersColor->setEnabled(SHADE_CUSTOM==opts.shadeSliders);
3284     customMenubarsColor->setEnabled(SHADE_CUSTOM==opts.shadeMenubars);
3285     customMenuNormTextColor->setEnabled(customMenuTextColor->isChecked());
3286     customMenuSelTextColor->setEnabled(customMenuTextColor->isChecked());
3287     customCheckRadioColor->setEnabled(SHADE_CUSTOM==opts.shadeCheckRadio);
3288     customMenuStripeColor->setEnabled(SHADE_CUSTOM==opts.menuStripe);
3289     menuStripeAppearance->setEnabled(SHADE_NONE!=opts.menuStripe);
3290 
3291     animatedProgress->setEnabled(STRIPE_NONE!=stripedProgress->currentIndex() &&
3292                                  STRIPE_FADE!=stripedProgress->currentIndex());
3293 
3294     fillSlider->setChecked(opts.fillSlider);
3295     stripedSbar->setChecked(opts.stripedSbar);
3296     sliderStyle->setCurrentIndex(opts.sliderStyle);
3297     roundMbTopOnly->setChecked(opts.roundMbTopOnly);
3298     menubarHiding_keyboard->setChecked(opts.menubarHiding&HIDE_KEYBOARD);
3299     menubarHiding_kwin->setChecked(opts.menubarHiding&HIDE_KWIN);
3300     statusbarHiding_keyboard->setChecked(opts.statusbarHiding&HIDE_KEYBOARD);
3301     statusbarHiding_kwin->setChecked(opts.statusbarHiding&HIDE_KWIN);
3302     fillProgress->setChecked(opts.fillProgress);
3303     glowProgress->setCurrentIndex(opts.glowProgress);
3304     darkerBorders->setChecked(opts.darkerBorders);
3305     comboSplitter->setChecked(opts.comboSplitter);
3306     comboBtn->setCurrentIndex(opts.comboBtn);
3307     customComboBtnColor->setColor(opts.customComboBtnColor);
3308     sortedLv->setCurrentIndex(opts.sortedLv);
3309     customSortedLvColor->setColor(opts.customSortedLvColor);
3310     unifySpinBtns->setChecked(opts.unifySpinBtns);
3311     unifySpin->setChecked(opts.unifySpin);
3312     unifyCombo->setChecked(opts.unifyCombo);
3313     vArrows->setChecked(opts.vArrows);
3314     xCheck->setChecked(opts.xCheck);
3315     xCheck_false->setChecked(!opts.xCheck);
3316     hideShortcutUnderline->setChecked(opts.hideShortcutUnderline);
3317     crHighlight->setValue(opts.crHighlight);
3318     expanderHighlight->setValue(opts.expanderHighlight);
3319     crButton->setChecked(opts.crButton);
3320     colorSelTab->setValue(opts.colorSelTab);
3321     roundAllTabs->setChecked(opts.roundAllTabs);
3322     roundAllTabs_false->setChecked(!opts.roundAllTabs);
3323     borderTab->setChecked(opts.borderTab);
3324     borderInactiveTab->setChecked(opts.borderInactiveTab);
3325     invertBotTab->setChecked(opts.invertBotTab);
3326     doubleGtkComboArrow->setChecked(opts.doubleGtkComboArrow);
3327     borderTab_false->setChecked(!opts.borderTab);
3328     borderInactiveTab_false->setChecked(!opts.borderInactiveTab);
3329     invertBotTab_false->setChecked(!opts.invertBotTab);
3330     tabMouseOver->setCurrentIndex(opts.tabMouseOver);
3331     stdSidebarButtons->setChecked(opts.stdSidebarButtons);
3332     toolbarTabs->setChecked(opts.toolbarTabs);
3333     toolbarTabs_false->setChecked(!opts.toolbarTabs);
3334     centerTabText->setChecked(opts.centerTabText);
3335     centerTabText_false->setChecked(!opts.centerTabText);
3336     borderMenuitems->setChecked(opts.borderMenuitems);
3337     shadePopupMenu->setChecked(opts.shadePopupMenu);
3338     popupBorder->setChecked(opts.popupBorder);
3339     progressAppearance->setCurrentIndex(opts.progressAppearance);
3340     progressColor->setCurrentIndex(opts.progressColor);
3341     customProgressColor->setColor(opts.customProgressColor);
3342     progressGrooveAppearance->setCurrentIndex(opts.progressGrooveAppearance);
3343     grooveAppearance->setCurrentIndex(opts.grooveAppearance);
3344     sunkenAppearance->setCurrentIndex(opts.sunkenAppearance);
3345     progressGrooveColor->setCurrentIndex(opts.progressGrooveColor);
3346     menuitemAppearance->setCurrentIndex(opts.menuitemAppearance);
3347     menuBgndAppearance->setCurrentIndex(opts.menuBgndAppearance);
3348     titlebarAppearance->setCurrentIndex(opts.titlebarAppearance);
3349     inactiveTitlebarAppearance->setCurrentIndex(opts.inactiveTitlebarAppearance);
3350     titlebarButtonAppearance->setCurrentIndex(opts.titlebarButtonAppearance);
3351     windowBorder_colorTitlebarOnly->setChecked(opts.windowBorder&WINDOW_BORDER_COLOR_TITLEBAR_ONLY);
3352     windowBorder_blend->setChecked(opts.windowBorder&WINDOW_BORDER_BLEND_TITLEBAR);
3353     windowBorder_fill->setChecked(opts.windowBorder&WINDOW_BORDER_FILL_TITLEBAR);
3354     windowBorder_menuColor->setChecked(opts.windowBorder&WINDOW_BORDER_USE_MENUBAR_COLOR_FOR_TITLEBAR);
3355     windowBorder_separator->setChecked(opts.windowBorder&WINDOW_BORDER_SEPARATOR);
3356     selectionAppearance->setCurrentIndex(opts.selectionAppearance);
3357     shadeCheckRadio->setCurrentIndex(opts.shadeCheckRadio);
3358     customCheckRadioColor->setColor(opts.customCheckRadioColor);
3359     colorMenubarMouseOver->setChecked(opts.colorMenubarMouseOver);
3360     useHighlightForMenu->setChecked(opts.useHighlightForMenu);
3361     gbLabel_bold->setChecked(opts.gbLabel&GB_LBL_BOLD);
3362     gbLabel_centred->setChecked(opts.gbLabel&GB_LBL_CENTRED);
3363     gbLabel_textPos->setCurrentIndex(opts.gbLabel&GB_LBL_INSIDE
3364                                         ? GBV_INSIDE
3365                                         : opts.gbLabel&GB_LBL_OUTSIDE
3366                                             ? GBV_OUTSIDE
3367                                             : GBV_STANDARD);
3368     fadeLines->setChecked(opts.fadeLines);
3369     menuIcons->setChecked(opts.menuIcons);
3370     onlyTicksInMenu->setChecked(opts.onlyTicksInMenu);
3371     buttonStyleMenuSections->setChecked(opts.buttonStyleMenuSections);
3372     stdBtnSizes->setChecked(opts.stdBtnSizes);
3373     boldProgress->setChecked(opts.boldProgress);
3374     boldProgress_false->setChecked(!opts.boldProgress);
3375     coloredTbarMo->setChecked(opts.coloredTbarMo);
3376     coloredTbarMo_false->setChecked(!opts.coloredTbarMo);
3377     tbarBtns->setCurrentIndex(opts.tbarBtns);
3378     tbarBtnAppearance->setCurrentIndex(opts.tbarBtnAppearance);
3379     tbarBtnEffect->setCurrentIndex(opts.tbarBtnEffect);
3380     borderSelection->setChecked(opts.borderSelection);
3381     forceAlternateLvCols->setChecked(opts.forceAlternateLvCols);
3382     titlebarAlignment->setCurrentIndex(opts.titlebarAlignment);
3383     titlebarEffect->setCurrentIndex(opts.titlebarEffect);
3384     titlebarIcon->setCurrentIndex(opts.titlebarIcon);
3385 
3386     shading->setCurrentIndex(int(opts.shading));
3387     gtkScrollViews->setChecked(opts.gtkScrollViews);
3388     highlightScrollViews->setChecked(opts.highlightScrollViews);
3389     etchEntry->setChecked(opts.etchEntry);
3390     flatSbarButtons->setChecked(opts.flatSbarButtons);
3391     borderSbarGroove->setChecked(opts.borderSbarGroove);
3392     thinSbarGroove->setChecked(opts.thinSbarGroove);
3393     colorSliderMouseOver->setChecked(opts.colorSliderMouseOver);
3394     windowBorder_addLightBorder->setChecked(opts.windowBorder&WINDOW_BORDER_ADD_LIGHT_BORDER);
3395     windowDrag->setCurrentIndex(opts.windowDrag);
3396     sbarBgndAppearance->setCurrentIndex(opts.sbarBgndAppearance);
3397     sliderFill->setCurrentIndex(opts.sliderFill);
3398     bgndAppearance->setCurrentIndex(opts.bgndAppearance);
3399     bgndImage->setCurrentIndex(opts.bgndImage.type);
3400     bgndOpacity->setValue(opts.bgndOpacity);
3401     dlgOpacity->setValue(opts.dlgOpacity);
3402     menuBgndImage->setCurrentIndex(opts.menuBgndImage.type);
3403     menuBgndOpacity->setValue(opts.menuBgndOpacity);
3404     dropShadowSize->setValue(qtcX11ShadowSize());
3405     dwtAppearance->setCurrentIndex(opts.dwtAppearance);
3406     tooltipAppearance->setCurrentIndex(opts.tooltipAppearance);
3407     dwtBtnAsPerTitleBar->setChecked(opts.dwtSettings&DWT_BUTTONS_AS_PER_TITLEBAR);
3408     dwtColAsPerTitleBar->setChecked(opts.dwtSettings&DWT_COLOR_AS_PER_TITLEBAR);
3409     dwtIconColAsPerTitleBar->setChecked(opts.dwtSettings&DWT_ICON_COLOR_AS_PER_TITLEBAR);
3410     dwtFontAsPerTitleBar->setChecked(opts.dwtSettings&DWT_FONT_AS_PER_TITLEBAR);
3411     dwtTextAsPerTitleBar->setChecked(opts.dwtSettings&DWT_TEXT_ALIGN_AS_PER_TITLEBAR);
3412     dwtEffectAsPerTitleBar->setChecked(opts.dwtSettings&DWT_EFFECT_AS_PER_TITLEBAR);
3413     dwtRoundTopOnly->setChecked(opts.dwtSettings&DWT_ROUND_TOP_ONLY);
3414     xbar->setChecked(opts.xbar);
3415     crColor->setCurrentIndex(opts.crColor);
3416     customCrBgndColor->setColor(opts.customCrBgndColor);
3417     smallRadio->setChecked(opts.smallRadio);
3418     smallRadio_false->setChecked(!opts.smallRadio);
3419     splitterHighlight->setValue(opts.splitterHighlight);
3420     gtkComboMenus->setChecked(opts.gtkComboMenus);
3421     gtkButtonOrder->setChecked(opts.gtkButtonOrder);
3422     reorderGtkButtons->setChecked(opts.reorderGtkButtons);
3423     mapKdeIcons->setChecked(opts.mapKdeIcons);
3424     setPasswordChar(opts.passwordChar);
3425     groupBox->setCurrentIndex(opts.groupBox);
3426     gbFactor->setValue(opts.gbFactor);
3427     customGradient=opts.customGradient;
3428     gradCombo->setCurrentIndex(APPEARANCE_CUSTOM1);
3429     borderProgress->setChecked(opts.borderProgress);
3430 
3431     setCrSize(crSize, opts.crSize);
3432 
3433     squareLvSelection->setChecked(opts.square&SQUARE_LISTVIEW_SELECTION);
3434     squareScrollViews->setChecked(opts.square&SQUARE_SCROLLVIEW);
3435     squareEntry->setChecked(opts.square&SQUARE_ENTRY);
3436     squareProgress->setChecked(opts.square&SQUARE_PROGRESS);
3437     squareFrame->setChecked(opts.square&SQUARE_FRAME);
3438     squareTabFrame->setChecked(opts.square&SQUARE_TAB_FRAME);
3439     squareSlider->setChecked(opts.square&SQUARE_SLIDER);
3440     squareScrollbarSlider->setChecked(opts.square&SQUARE_SB_SLIDER);
3441     squareWindows->setChecked(opts.square&SQUARE_WINDOWS);
3442     squareTooltips->setChecked(opts.square&SQUARE_TOOLTIPS);
3443     squarePopupMenus->setChecked(opts.square&SQUARE_POPUP_MENUS);
3444 
3445     titlebarButtons_colorClose->setColor(getColor(opts.titlebarButtonColors, TITLEBAR_CLOSE));
3446     titlebarButtons_colorMin->setColor(getColor(opts.titlebarButtonColors, TITLEBAR_MIN));
3447     titlebarButtons_colorMax->setColor(getColor(opts.titlebarButtonColors, TITLEBAR_MAX));
3448     titlebarButtons_colorKeepAbove->setColor(getColor(opts.titlebarButtonColors, TITLEBAR_KEEP_ABOVE));
3449     titlebarButtons_colorKeepBelow->setColor(getColor(opts.titlebarButtonColors, TITLEBAR_KEEP_BELOW));
3450     titlebarButtons_colorHelp->setColor(getColor(opts.titlebarButtonColors, TITLEBAR_HELP));
3451     titlebarButtons_colorMenu->setColor(getColor(opts.titlebarButtonColors, TITLEBAR_MENU));
3452     titlebarButtons_colorShade->setColor(getColor(opts.titlebarButtonColors, TITLEBAR_SHADE));
3453     titlebarButtons_colorAllDesktops->setColor(getColor(opts.titlebarButtonColors, TITLEBAR_ALL_DESKTOPS));
3454     if (!(opts.titlebarButtons&TITLEBAR_BUTTON_COLOR)) {
3455         titlebarButtons_colorClose->setEnabled(false);
3456         titlebarButtons_colorMin->setEnabled(false);
3457         titlebarButtons_colorMax->setEnabled(false);
3458         titlebarButtons_colorKeepAbove->setEnabled(false);
3459         titlebarButtons_colorKeepBelow->setEnabled(false);
3460         titlebarButtons_colorHelp->setEnabled(false);
3461         titlebarButtons_colorMenu->setEnabled(false);
3462         titlebarButtons_colorShade->setEnabled(false);
3463         titlebarButtons_colorAllDesktops->setEnabled(false);
3464     }
3465 
3466     titlebarButtons_colorCloseIcon->setColor(getColor(opts.titlebarButtonColors, TITLEBAR_CLOSE, 1));
3467     titlebarButtons_colorMinIcon->setColor(getColor(opts.titlebarButtonColors, TITLEBAR_MIN, 1));
3468     titlebarButtons_colorMaxIcon->setColor(getColor(opts.titlebarButtonColors, TITLEBAR_MAX, 1));
3469     titlebarButtons_colorKeepAboveIcon->setColor(getColor(opts.titlebarButtonColors, TITLEBAR_KEEP_ABOVE, 1));
3470     titlebarButtons_colorKeepBelowIcon->setColor(getColor(opts.titlebarButtonColors, TITLEBAR_KEEP_BELOW, 1));
3471     titlebarButtons_colorHelpIcon->setColor(getColor(opts.titlebarButtonColors, TITLEBAR_HELP, 1));
3472     titlebarButtons_colorMenuIcon->setColor(getColor(opts.titlebarButtonColors, TITLEBAR_MENU, 1));
3473     titlebarButtons_colorShadeIcon->setColor(getColor(opts.titlebarButtonColors, TITLEBAR_SHADE, 1));
3474     titlebarButtons_colorAllDesktopsIcon->setColor(getColor(opts.titlebarButtonColors, TITLEBAR_ALL_DESKTOPS, 1));
3475 
3476     titlebarButtons_colorCloseInactiveIcon->setColor(getColor(opts.titlebarButtonColors, TITLEBAR_CLOSE, 2));
3477     titlebarButtons_colorMinInactiveIcon->setColor(getColor(opts.titlebarButtonColors, TITLEBAR_MIN, 2));
3478     titlebarButtons_colorMaxInactiveIcon->setColor(getColor(opts.titlebarButtonColors, TITLEBAR_MAX, 2));
3479     titlebarButtons_colorKeepAboveInactiveIcon->setColor(getColor(opts.titlebarButtonColors, TITLEBAR_KEEP_ABOVE, 2));
3480     titlebarButtons_colorKeepBelowInactiveIcon->setColor(getColor(opts.titlebarButtonColors, TITLEBAR_KEEP_BELOW, 2));
3481     titlebarButtons_colorHelpInactiveIcon->setColor(getColor(opts.titlebarButtonColors, TITLEBAR_HELP, 2));
3482     titlebarButtons_colorMenuInactiveIcon->setColor(getColor(opts.titlebarButtonColors, TITLEBAR_MENU, 2));
3483     titlebarButtons_colorShadeInactiveIcon->setColor(getColor(opts.titlebarButtonColors, TITLEBAR_SHADE, 2));
3484     titlebarButtons_colorAllDesktopsInactiveIcon->setColor(getColor(opts.titlebarButtonColors, TITLEBAR_ALL_DESKTOPS, 2));
3485     if (!(opts.titlebarButtons&TITLEBAR_BUTTON_ICON_COLOR)) {
3486         titlebarButtons_colorCloseIcon->setEnabled(false);
3487         titlebarButtons_colorMinIcon->setEnabled(false);
3488         titlebarButtons_colorMaxIcon->setEnabled(false);
3489         titlebarButtons_colorKeepAboveIcon->setEnabled(false);
3490         titlebarButtons_colorKeepBelowIcon->setEnabled(false);
3491         titlebarButtons_colorHelpIcon->setEnabled(false);
3492         titlebarButtons_colorMenuIcon->setEnabled(false);
3493         titlebarButtons_colorShadeIcon->setEnabled(false);
3494         titlebarButtons_colorAllDesktopsIcon->setEnabled(false);
3495 
3496         titlebarButtons_colorCloseInactiveIcon->setEnabled(false);
3497         titlebarButtons_colorMinInactiveIcon->setEnabled(false);
3498         titlebarButtons_colorMaxInactiveIcon->setEnabled(false);
3499         titlebarButtons_colorKeepAboveInactiveIcon->setEnabled(false);
3500         titlebarButtons_colorKeepBelowInactiveIcon->setEnabled(false);
3501         titlebarButtons_colorHelpInactiveIcon->setEnabled(false);
3502         titlebarButtons_colorMenuInactiveIcon->setEnabled(false);
3503         titlebarButtons_colorShadeInactiveIcon->setEnabled(false);
3504         titlebarButtons_colorAllDesktopsInactiveIcon->setEnabled(false);
3505     }
3506 
3507     titlebarButtons_button->setChecked(opts.titlebarButtons&TITLEBAR_BUTTON_STD_COLOR);
3508     titlebarButtons_custom->setChecked(opts.titlebarButtons&TITLEBAR_BUTTON_COLOR);
3509     titlebarButtons_customIcon->setChecked(opts.titlebarButtons&TITLEBAR_BUTTON_ICON_COLOR);
3510     titlebarButtons_noFrame->setChecked(opts.titlebarButtons&TITLEBAR_BUTTON_NO_FRAME);
3511     titlebarButtons_round->setChecked(opts.titlebarButtons&TITLEBAR_BUTTON_ROUND);
3512     titlebarButtons_hoverFrame->setChecked(opts.titlebarButtons&TITLEBAR_BUTTON_HOVER_FRAME);
3513     titlebarButtons_hoverSymbol->setChecked(opts.titlebarButtons&TITLEBAR_BUTTON_HOVER_SYMBOL);
3514     titlebarButtons_hoverSymbolFull->setChecked(opts.titlebarButtons&TITLEBAR_BUTTON_HOVER_SYMBOL_FULL);
3515     titlebarButtons_colorOnMouseOver->setChecked(opts.titlebarButtons&TITLEBAR_BUTTON_COLOR_MOUSE_OVER);
3516     titlebarButtons_colorInactive->setChecked(opts.titlebarButtons&TITLEBAR_BUTTON_COLOR_INACTIVE);
3517     titlebarButtons_colorSymbolsOnly->setChecked(opts.titlebarButtons&TITLEBAR_BUTTON_COLOR_SYMBOL);
3518     titlebarButtons_sunkenBackground->setChecked(opts.titlebarButtons&TITLEBAR_BUTTON_SUNKEN_BACKGROUND);
3519     titlebarButtons_arrowMinMax->setChecked(opts.titlebarButtons&TITLEBAR_BUTTOM_ARROW_MIN_MAX);
3520     titlebarButtons_hideOnInactiveWindow->setChecked(opts.titlebarButtons&TITLEBAR_BUTTOM_HIDE_ON_INACTIVE_WINDOW);
3521     titlebarButtons_useHover->setChecked(opts.titlebarButtons&TITLEBAR_BUTTON_USE_HOVER_COLOR);
3522 
3523     populateShades(opts);
3524 
3525     noBgndGradientApps->setText(toString(opts.noBgndGradientApps));
3526     noBgndOpacityApps->setText(toString(opts.noBgndOpacityApps));
3527     noMenuBgndOpacityApps->setText(toString(opts.noMenuBgndOpacityApps));
3528     noBgndImageApps->setText(toString(opts.noBgndImageApps));
3529     useQtFileDialogApps->setText(toString(opts.useQtFileDialogApps));
3530     nonnativeMenubarApps->setText(toString(opts.nonnativeMenubarApps));
3531     menubarApps->setText(toString(opts.menubarApps));
3532     statusbarApps->setText(toString(opts.statusbarApps));
3533     noMenuStripeApps->setText(toString(opts.noMenuStripeApps));
3534 
3535     bgndImageDlg->set(getThemeFile(opts.bgndImage.pixmap.file), opts.bgndImage.width, opts.bgndImage.height,
3536                       opts.bgndImage.pos, opts.bgndImage.onBorder);
3537 //     printf("SET WO BGND \"%s\"  \"%s\"", opts.bgndImage.pixmap.file.toLatin1().constData(), bgndImageDlg->fileName().toLatin1().constData());
3538     bgndPixmapDlg->set(getThemeFile(opts.bgndPixmap.file));
3539     menuBgndImageDlg->set(getThemeFile(opts.menuBgndImage.pixmap.file), opts.menuBgndImage.width, opts.menuBgndImage.height,
3540                           opts.menuBgndImage.pos);
3541 //     printf("SET WO MENU \"%s\"  \"%s\"", opts.menuBgndImage.pixmap.file.toLatin1().constData(), menuBgndImageDlg->fileName().toLatin1().constData());
3542     menuBgndPixmapDlg->set(getThemeFile(opts.menuBgndPixmap.file));
3543 }
3544 
3545 int QtCurveConfig::getDwtSettingsFlags()
3546 {
3547     int dwt(0);
3548 
3549     if(dwtBtnAsPerTitleBar->isChecked())
3550         dwt|=DWT_BUTTONS_AS_PER_TITLEBAR;
3551     if(dwtColAsPerTitleBar->isChecked())
3552         dwt|=DWT_COLOR_AS_PER_TITLEBAR;
3553     if(dwtIconColAsPerTitleBar->isChecked())
3554         dwt|=DWT_ICON_COLOR_AS_PER_TITLEBAR;
3555     if(dwtFontAsPerTitleBar->isChecked())
3556         dwt|=DWT_FONT_AS_PER_TITLEBAR;
3557     if(dwtTextAsPerTitleBar->isChecked())
3558         dwt|=DWT_TEXT_ALIGN_AS_PER_TITLEBAR;
3559     if(dwtEffectAsPerTitleBar->isChecked())
3560         dwt|=DWT_EFFECT_AS_PER_TITLEBAR;
3561     if(dwtRoundTopOnly->isChecked())
3562         dwt|=DWT_ROUND_TOP_ONLY;
3563     return dwt;
3564 }
3565 
3566 int QtCurveConfig::getSquareFlags()
3567 {
3568     int square(0);
3569 
3570     if(squareEntry->isChecked())
3571         square|=SQUARE_ENTRY;
3572     if(squareProgress->isChecked())
3573         square|=SQUARE_PROGRESS;
3574     if(squareScrollViews->isChecked())
3575         square|=SQUARE_SCROLLVIEW;
3576     if(squareLvSelection->isChecked())
3577         square|=SQUARE_LISTVIEW_SELECTION;
3578     if(squareFrame->isChecked())
3579         square|=SQUARE_FRAME;
3580     if(squareTabFrame->isChecked())
3581         square|=SQUARE_TAB_FRAME;
3582     if(squareSlider->isChecked())
3583         square|=SQUARE_SLIDER;
3584     if(squareScrollbarSlider->isChecked())
3585         square|=SQUARE_SB_SLIDER;
3586     if(squareWindows->isChecked())
3587         square|=SQUARE_WINDOWS;
3588     if(squareTooltips->isChecked())
3589         square|=SQUARE_TOOLTIPS;
3590     if(squarePopupMenus->isChecked())
3591         square|=SQUARE_POPUP_MENUS;
3592     return square;
3593 }
3594 
3595 int QtCurveConfig::getWindowBorderFlags()
3596 {
3597     int flags(0);
3598 
3599     if(windowBorder_colorTitlebarOnly->isChecked())
3600         flags|=WINDOW_BORDER_COLOR_TITLEBAR_ONLY;
3601     if(windowBorder_menuColor->isChecked())
3602         flags|=WINDOW_BORDER_USE_MENUBAR_COLOR_FOR_TITLEBAR;
3603     if(windowBorder_addLightBorder->isChecked())
3604         flags|=WINDOW_BORDER_ADD_LIGHT_BORDER;
3605     if(windowBorder_blend->isChecked())
3606         flags|=WINDOW_BORDER_BLEND_TITLEBAR;
3607     if(windowBorder_separator->isChecked())
3608         flags|=WINDOW_BORDER_SEPARATOR;
3609     if(windowBorder_fill->isChecked())
3610         flags|=WINDOW_BORDER_FILL_TITLEBAR;
3611     return flags;
3612 }
3613 
3614 int QtCurveConfig::getThinFlags()
3615 {
3616     int flags(0);
3617 
3618     if(thin_buttons->isChecked())
3619         flags|=THIN_BUTTONS;
3620     if(thin_menuitems->isChecked())
3621         flags|=THIN_MENU_ITEMS;
3622     if(thin_frames->isChecked())
3623         flags|=THIN_FRAMES;
3624     return flags;
3625 }
3626 
3627 bool QtCurveConfig::diffTitleBarButtonColors(const Options &opts)
3628 {
3629     return (titlebarButtons_custom->isChecked() &&
3630             ( titlebarButtons_colorClose->color()!=getColor(opts.titlebarButtonColors, TITLEBAR_CLOSE) ||
3631               titlebarButtons_colorMin->color()!=getColor(opts.titlebarButtonColors, TITLEBAR_MIN) ||
3632               titlebarButtons_colorMax->color()!=getColor(opts.titlebarButtonColors, TITLEBAR_MAX) ||
3633               titlebarButtons_colorKeepAbove->color()!=getColor(opts.titlebarButtonColors, TITLEBAR_KEEP_ABOVE) ||
3634               titlebarButtons_colorKeepBelow->color()!=getColor(opts.titlebarButtonColors, TITLEBAR_KEEP_BELOW) ||
3635               titlebarButtons_colorHelp->color()!=getColor(opts.titlebarButtonColors, TITLEBAR_HELP) ||
3636               titlebarButtons_colorMenu->color()!=getColor(opts.titlebarButtonColors, TITLEBAR_MENU) ||
3637               titlebarButtons_colorShade->color()!=getColor(opts.titlebarButtonColors, TITLEBAR_SHADE) ||
3638               titlebarButtons_colorAllDesktops->color()!=getColor(opts.titlebarButtonColors, TITLEBAR_ALL_DESKTOPS))) ||
3639             (titlebarButtons_customIcon->isChecked() &&
3640             ( titlebarButtons_colorCloseIcon->color()!=getColor(opts.titlebarButtonColors, TITLEBAR_CLOSE, 1) ||
3641               titlebarButtons_colorMinIcon->color()!=getColor(opts.titlebarButtonColors, TITLEBAR_MIN, 1) ||
3642               titlebarButtons_colorMaxIcon->color()!=getColor(opts.titlebarButtonColors, TITLEBAR_MAX, 1) ||
3643               titlebarButtons_colorKeepAboveIcon->color()!=getColor(opts.titlebarButtonColors, TITLEBAR_KEEP_ABOVE, 1) ||
3644               titlebarButtons_colorKeepBelowIcon->color()!=getColor(opts.titlebarButtonColors, TITLEBAR_KEEP_BELOW, 1) ||
3645               titlebarButtons_colorHelpIcon->color()!=getColor(opts.titlebarButtonColors, TITLEBAR_HELP, 1) ||
3646               titlebarButtons_colorMenuIcon->color()!=getColor(opts.titlebarButtonColors, TITLEBAR_MENU, 1) ||
3647               titlebarButtons_colorShadeIcon->color()!=getColor(opts.titlebarButtonColors, TITLEBAR_SHADE, 1) ||
3648               titlebarButtons_colorAllDesktopsIcon->color()!=getColor(opts.titlebarButtonColors, TITLEBAR_ALL_DESKTOPS, 1) ||
3649               titlebarButtons_colorCloseInactiveIcon->color()!=getColor(opts.titlebarButtonColors, TITLEBAR_CLOSE, 2) ||
3650               titlebarButtons_colorMinInactiveIcon->color()!=getColor(opts.titlebarButtonColors, TITLEBAR_MIN, 2) ||
3651               titlebarButtons_colorMaxInactiveIcon->color()!=getColor(opts.titlebarButtonColors, TITLEBAR_MAX, 2) ||
3652               titlebarButtons_colorKeepAboveInactiveIcon->color()!=getColor(opts.titlebarButtonColors, TITLEBAR_KEEP_ABOVE, 2) ||
3653               titlebarButtons_colorKeepBelowInactiveIcon->color()!=getColor(opts.titlebarButtonColors, TITLEBAR_KEEP_BELOW, 2) ||
3654               titlebarButtons_colorHelpInactiveIcon->color()!=getColor(opts.titlebarButtonColors, TITLEBAR_HELP, 2) ||
3655               titlebarButtons_colorMenuInactiveIcon->color()!=getColor(opts.titlebarButtonColors, TITLEBAR_MENU, 2) ||
3656               titlebarButtons_colorShadeInactiveIcon->color()!=getColor(opts.titlebarButtonColors, TITLEBAR_SHADE, 2) ||
3657               titlebarButtons_colorAllDesktopsInactiveIcon->color()!=getColor(opts.titlebarButtonColors, TITLEBAR_ALL_DESKTOPS, 2)));
3658 }
3659 
3660 bool QtCurveConfig::settingsChanged(const Options &opts)
3661 {
3662     return round->currentIndex()!=opts.round ||
3663          toolbarBorders->currentIndex()!=opts.toolbarBorders ||
3664          appearance->currentIndex()!=(int)opts.appearance ||
3665          focus->currentIndex()!=(int)opts.focus ||
3666          lvLines->isChecked()!=opts.lvLines ||
3667          lvButton->isChecked()!=opts.lvButton ||
3668          drawStatusBarFrames->isChecked()!=opts.drawStatusBarFrames ||
3669          buttonEffect->currentIndex()!=(EEffect)opts.buttonEffect ||
3670          coloredMouseOver->currentIndex()!=(int)opts.coloredMouseOver ||
3671          menubarMouseOver->isChecked()!=opts.menubarMouseOver ||
3672          shadeMenubarOnlyWhenActive->isChecked()!=opts.shadeMenubarOnlyWhenActive ||
3673          getThinFlags()!=opts.thin ||
3674          animatedProgress->isChecked()!=opts.animatedProgress ||
3675          stripedProgress->currentIndex()!=opts.stripedProgress ||
3676          lighterPopupMenuBgnd->value()!=opts.lighterPopupMenuBgnd ||
3677          tabBgnd->value()!=opts.tabBgnd ||
3678          menuDelay->value()!=opts.menuDelay ||
3679          menuCloseDelay->value()!=opts.menuCloseDelay ||
3680          sliderWidth->value()!=opts.sliderWidth ||
3681          menuStripe->currentIndex()!=opts.menuStripe ||
3682          menuStripeAppearance->currentIndex()!=opts.menuStripeAppearance ||
3683          bgndGrad->currentIndex()!=opts.bgndGrad ||
3684          menuBgndGrad->currentIndex()!=opts.menuBgndGrad ||
3685          embolden->isChecked()!=opts.embolden ||
3686          fillSlider->isChecked()!=opts.fillSlider ||
3687          stripedSbar->isChecked()!=opts.stripedSbar ||
3688          sliderStyle->currentIndex()!=opts.sliderStyle ||
3689          roundMbTopOnly->isChecked()!=opts.roundMbTopOnly ||
3690          getHideFlags(menubarHiding_keyboard, menubarHiding_kwin)!=opts.menubarHiding ||
3691          getHideFlags(statusbarHiding_keyboard, statusbarHiding_kwin)!=opts.statusbarHiding ||
3692          fillProgress->isChecked()!=opts.fillProgress ||
3693          glowProgress->currentIndex()!=opts.glowProgress ||
3694          darkerBorders->isChecked()!=opts.darkerBorders ||
3695          comboSplitter->isChecked()!=opts.comboSplitter ||
3696          comboBtn->currentIndex()!=(int)opts.comboBtn ||
3697          sortedLv->currentIndex()!=(int)opts.sortedLv ||
3698          unifySpinBtns->isChecked()!=opts.unifySpinBtns ||
3699          unifySpin->isChecked()!=opts.unifySpin ||
3700          unifyCombo->isChecked()!=opts.unifyCombo ||
3701          vArrows->isChecked()!=opts.vArrows ||
3702          xCheck->isChecked()!=opts.xCheck ||
3703          hideShortcutUnderline->isChecked()!=opts.hideShortcutUnderline ||
3704          crHighlight->value()!=opts.crHighlight ||
3705          expanderHighlight->value()!=opts.expanderHighlight ||
3706          crButton->isChecked()!=opts.crButton ||
3707          colorSelTab->value()!=opts.colorSelTab ||
3708          roundAllTabs->isChecked()!=opts.roundAllTabs ||
3709          borderTab->isChecked()!=opts.borderTab ||
3710          borderInactiveTab->isChecked()!=opts.borderInactiveTab ||
3711          invertBotTab->isChecked()!=opts.invertBotTab ||
3712          doubleGtkComboArrow->isChecked()!=opts.doubleGtkComboArrow ||
3713          tabMouseOver->currentIndex()!=opts.tabMouseOver ||
3714          stdSidebarButtons->isChecked()!=opts.stdSidebarButtons ||
3715          toolbarTabs->isChecked()!=opts.toolbarTabs ||
3716          centerTabText->isChecked()!=opts.centerTabText ||
3717          borderMenuitems->isChecked()!=opts.borderMenuitems ||
3718          shadePopupMenu->isChecked()!=opts.shadePopupMenu ||
3719          popupBorder->isChecked()!=opts.popupBorder ||
3720          defBtnIndicator->currentIndex()!=(int)opts.defBtnIndicator ||
3721          sliderThumbs->currentIndex()!=(int)opts.sliderThumbs ||
3722          handles->currentIndex()!=(int)opts.handles ||
3723          scrollbarType->currentIndex()!=(int)opts.scrollbarType ||
3724          highlightTab->isChecked()!=opts.highlightTab ||
3725          shadeSliders->currentIndex()!=(int)opts.shadeSliders ||
3726          shadeMenubars->currentIndex()!=(int)opts.shadeMenubars ||
3727          shadeCheckRadio->currentIndex()!=(int)opts.shadeCheckRadio ||
3728          menubarAppearance->currentIndex()!=opts.menubarAppearance ||
3729          toolbarAppearance->currentIndex()!=opts.toolbarAppearance ||
3730          lvAppearance->currentIndex()!=opts.lvAppearance ||
3731          sliderAppearance->currentIndex()!=opts.sliderAppearance ||
3732          tabAppearance->currentIndex()!=opts.tabAppearance ||
3733          activeTabAppearance->currentIndex()!=opts.activeTabAppearance ||
3734          progressAppearance->currentIndex()!=opts.progressAppearance ||
3735          progressColor->currentIndex()!=opts.progressColor ||
3736          progressGrooveAppearance->currentIndex()!=opts.progressGrooveAppearance ||
3737          grooveAppearance->currentIndex()!=opts.grooveAppearance ||
3738          sunkenAppearance->currentIndex()!=opts.sunkenAppearance ||
3739          progressGrooveColor->currentIndex()!=opts.progressGrooveColor ||
3740          menuitemAppearance->currentIndex()!=opts.menuitemAppearance ||
3741          menuBgndAppearance->currentIndex()!=opts.menuBgndAppearance ||
3742          titlebarAppearance->currentIndex()!=opts.titlebarAppearance ||
3743          inactiveTitlebarAppearance->currentIndex()!=opts.inactiveTitlebarAppearance ||
3744          titlebarButtonAppearance->currentIndex()!=opts.titlebarButtonAppearance ||
3745          selectionAppearance->currentIndex()!=opts.selectionAppearance ||
3746          toolbarSeparators->currentIndex()!=opts.toolbarSeparators ||
3747          splitters->currentIndex()!=opts.splitters ||
3748          colorMenubarMouseOver->isChecked()!=opts.colorMenubarMouseOver ||
3749          useHighlightForMenu->isChecked()!=opts.useHighlightForMenu ||
3750          getGroupBoxLabelFlags()!=opts.gbLabel ||
3751          fadeLines->isChecked()!=opts.fadeLines ||
3752          menuIcons->isChecked()!=opts.menuIcons ||
3753          stdBtnSizes->isChecked()!=opts.stdBtnSizes ||
3754          boldProgress->isChecked()!=opts.boldProgress ||
3755          coloredTbarMo->isChecked()!=opts.coloredTbarMo ||
3756          tbarBtns->currentIndex()!=opts.tbarBtns ||
3757          tbarBtnAppearance->currentIndex()!=opts.tbarBtnAppearance ||
3758          tbarBtnEffect->currentIndex()!=opts.tbarBtnEffect ||
3759          borderSelection->isChecked()!=opts.borderSelection ||
3760          forceAlternateLvCols->isChecked()!=opts.forceAlternateLvCols ||
3761          titlebarAlignment->currentIndex()!=opts.titlebarAlignment ||
3762          titlebarEffect->currentIndex()!=opts.titlebarEffect ||
3763          titlebarIcon->currentIndex()!=opts.titlebarIcon ||
3764          getCrSize(crSize)!=opts.crSize ||
3765          borderProgress->isChecked()!=opts.borderProgress ||
3766          shading->currentIndex()!=(int)opts.shading ||
3767          gtkScrollViews->isChecked()!=opts.gtkScrollViews ||
3768          highlightScrollViews->isChecked()!=opts.highlightScrollViews ||
3769          etchEntry->isChecked()!=opts.etchEntry ||
3770          flatSbarButtons->isChecked()!=opts.flatSbarButtons ||
3771          borderSbarGroove->isChecked()!=opts.borderSbarGroove ||
3772          thinSbarGroove->isChecked()!=opts.thinSbarGroove ||
3773          colorSliderMouseOver->isChecked()!=opts.colorSliderMouseOver ||
3774          getWindowBorderFlags()!=opts.windowBorder ||
3775          windowDrag->currentIndex()!=opts.windowDrag ||
3776          sbarBgndAppearance->currentIndex()!=opts.sbarBgndAppearance ||
3777          sliderFill->currentIndex()!=opts.sliderFill ||
3778          bgndAppearance->currentIndex()!=opts.bgndAppearance ||
3779          bgndImage->currentIndex()!=opts.bgndImage.type ||
3780          bgndOpacity->value()!=opts.bgndOpacity ||
3781          dlgOpacity->value()!=opts.dlgOpacity ||
3782          menuBgndImage->currentIndex()!=opts.menuBgndImage.type ||
3783          menuBgndOpacity->value()!=opts.menuBgndOpacity ||
3784          dropShadowSize->value()!=opts.shadowSize ||
3785          dwtAppearance->currentIndex()!=opts.dwtAppearance ||
3786          tooltipAppearance->currentIndex()!=opts.tooltipAppearance ||
3787          xbar->isChecked()!=opts.xbar ||
3788          crColor->currentIndex()!=opts.crColor ||
3789          smallRadio->isChecked()!=opts.smallRadio ||
3790          splitterHighlight->value()!=opts.splitterHighlight ||
3791          gtkComboMenus->isChecked()!=opts.gtkComboMenus ||
3792          gtkButtonOrder->isChecked()!=opts.gtkButtonOrder ||
3793          reorderGtkButtons->isChecked()!=opts.reorderGtkButtons ||
3794          mapKdeIcons->isChecked()!=opts.mapKdeIcons ||
3795          groupBox->currentIndex()!=opts.groupBox ||
3796          ((FRAME_SHADED==opts.groupBox || FRAME_FADED==opts.groupBox) && gbFactor->value()!=opts.gbFactor) ||
3797 
3798          toInt(passwordChar->text())!=opts.passwordChar ||
3799          highlightFactor->value()!=opts.highlightFactor ||
3800          getTitleBarButtonFlags()!=opts.titlebarButtons ||
3801 
3802          getDwtSettingsFlags()!=opts.dwtSettings ||
3803          getSquareFlags()!=opts.square ||
3804 
3805          diffTitleBarButtonColors(opts) ||
3806 
3807          customMenuTextColor->isChecked()!=opts.customMenuTextColor ||
3808          (SHADE_CUSTOM==opts.shadeSliders &&
3809                customSlidersColor->color()!=opts.customSlidersColor) ||
3810          (SHADE_CUSTOM==opts.shadeMenubars &&
3811                customMenubarsColor->color()!=opts.customMenubarsColor) ||
3812          (SHADE_CUSTOM==opts.shadeCheckRadio &&
3813                customCheckRadioColor->color()!=opts.customCheckRadioColor) ||
3814          (customMenuTextColor->isChecked() &&
3815                customMenuNormTextColor->color()!=opts.customMenuNormTextColor) ||
3816          (customMenuTextColor->isChecked() &&
3817                customMenuSelTextColor->color()!=opts.customMenuSelTextColor) ||
3818          (SHADE_CUSTOM==opts.menuStripe &&
3819                customMenuStripeColor->color()!=opts.customMenuStripeColor) ||
3820          (SHADE_CUSTOM==opts.comboBtn &&
3821                customComboBtnColor->color()!=opts.customComboBtnColor) ||
3822          (SHADE_CUSTOM==opts.sortedLv &&
3823                customSortedLvColor->color()!=opts.customSortedLvColor) ||
3824          (SHADE_CUSTOM==opts.crColor &&
3825                customCrBgndColor->color()!=opts.customCrBgndColor) ||
3826          (SHADE_CUSTOM==opts.progressColor &&
3827                customProgressColor->color()!=opts.customProgressColor) ||
3828 
3829          customGradient!=opts.customGradient ||
3830 
3831          toSet(noBgndGradientApps->text())!=opts.noBgndGradientApps ||
3832          toSet(noBgndOpacityApps->text())!=opts.noBgndOpacityApps ||
3833          toSet(noMenuBgndOpacityApps->text())!=opts.noMenuBgndOpacityApps ||
3834          toSet(noBgndImageApps->text())!=opts.noBgndImageApps ||
3835          toSet(useQtFileDialogApps->text())!=opts.useQtFileDialogApps ||
3836          toSet(menubarApps->text())!=opts.menubarApps ||
3837          toSet(statusbarApps->text())!=opts.statusbarApps ||
3838          toSet(noMenuStripeApps->text())!=opts.noMenuStripeApps ||
3839          toSet(nonnativeMenubarApps->text())!=opts.nonnativeMenubarApps ||
3840 
3841          diffShades(opts) ||
3842 
3843          diffImages(opts);
3844 }