File indexing completed on 2024-05-12 05:49:29
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 0023 #ifndef __QTCURVECONFIG_H__ 0024 #define __QTCURVECONFIG_H__ 0025 0026 #include <ui_qtcurveconfigbase.h> 0027 #include "ui_stylepreview.h" 0028 #include <QMap> 0029 #include <QComboBox> 0030 #include <KDE/KXmlGuiWindow> 0031 0032 #include <common/common.h> 0033 0034 #include <memory> 0035 0036 class QComboBox; 0037 class KDoubleNumInput; 0038 #ifdef QTC_QT4_STYLE_SUPPORT 0039 class CExportThemeDialog; 0040 #endif 0041 class QtCurveConfig; 0042 class QStyle; 0043 class QMdiSubWindow; 0044 class CWorkspace; 0045 class CStylePreview; 0046 class CImagePropertiesDialog; 0047 class KAboutData; 0048 class KComponentData; 0049 0050 namespace QtCurve { 0051 class KWinConfig; 0052 } 0053 0054 class CGradientPreview: public QWidget { 0055 Q_OBJECT 0056 public: 0057 CGradientPreview(QtCurveConfig *c, QWidget *p); 0058 ~CGradientPreview(); 0059 0060 QSize sizeHint() const; 0061 QSize minimumSizeHint() const; 0062 void paintEvent(QPaintEvent *); 0063 void setGrad(const Gradient &g); 0064 0065 public Q_SLOTS: 0066 void setColor(const QColor &col); 0067 0068 private: 0069 QtCurveConfig *cfg; 0070 QColor color; 0071 Gradient grad; 0072 QStyle *style; 0073 }; 0074 0075 struct Preset { 0076 Preset(const Options &o, const QString &f=QString()): 0077 loaded(true), opts(o), fileName(f) {} 0078 Preset(const QString &f=QString()): loaded(false), fileName(f) {} 0079 0080 bool loaded; 0081 Options opts; 0082 QString fileName; 0083 }; 0084 0085 class CStylePreview: public KXmlGuiWindow, public Ui::StylePreview { 0086 Q_OBJECT 0087 public: 0088 CStylePreview(QWidget *parent = 0); 0089 ~CStylePreview(); 0090 0091 void closeEvent(QCloseEvent *e); 0092 QSize sizeHint() const; 0093 0094 Q_SIGNALS: 0095 void closePressed(); 0096 0097 private: 0098 std::unique_ptr<KAboutData> m_aboutData; 0099 std::unique_ptr<KComponentData> m_componentData; 0100 }; 0101 0102 class QtCurveConfig : public QWidget, private Ui::QtCurveConfigBase { 0103 Q_OBJECT 0104 public: 0105 QtCurveConfig(QWidget *parent); 0106 ~QtCurveConfig() override; 0107 0108 QSize sizeHint() const override; 0109 Shading currentShading() const 0110 { 0111 return (Shading)shading->currentIndex(); 0112 } 0113 0114 Q_SIGNALS: 0115 void changed(bool); 0116 0117 public Q_SLOTS: 0118 void save(); 0119 void defaults(); 0120 0121 private Q_SLOTS: 0122 void setPreset(); 0123 void updateChanged(); 0124 void gtkButtonOrderChanged(); 0125 void reorderGtkButtonsChanged(); 0126 void focusChanged(); 0127 void roundChanged(); 0128 void savePreset(); 0129 void deletePreset(); 0130 void importPreset(); 0131 void exportPreset(); 0132 void exportTheme(); 0133 void emboldenToggled(); 0134 void defBtnIndicatorChanged(); 0135 void buttonEffectChanged(); 0136 void coloredMouseOverChanged(); 0137 void shadeSlidersChanged(); 0138 void shadeMenubarsChanged(); 0139 void shadeCheckRadioChanged(); 0140 void customMenuTextColorChanged(); 0141 void menuStripeChanged(); 0142 void shadePopupMenuChanged(); 0143 void progressColorChanged(); 0144 void comboBtnChanged(); 0145 void sortedLvChanged(); 0146 void crColorChanged(); 0147 void stripedProgressChanged(); 0148 void shadingChanged(); 0149 void activeTabAppearanceChanged(); 0150 void tabMoChanged(); 0151 void passwordCharClicked(); 0152 void unifySpinBtnsToggled(); 0153 void unifySpinToggled(); 0154 void sliderThumbChanged(); 0155 void sliderWidthChanged(); 0156 void menubarHidingChanged(); 0157 void xbarChanged(); 0158 void windowBorder_colorTitlebarOnlyChanged(); 0159 void windowBorder_blendChanged(); 0160 void windowBorder_menuColorChanged(); 0161 void thinSbarGrooveChanged(); 0162 void borderSbarGrooveChanged(); 0163 void borderProgressChanged(); 0164 void squareProgressChanged(); 0165 void fillProgressChanged(); 0166 void titlebarButtons_customChanged(); 0167 void titlebarButtons_useHoverChanged(); 0168 void bgndAppearanceChanged(); 0169 void bgndImageChanged(); 0170 void menuBgndAppearanceChanged(); 0171 void menuBgndImageChanged(); 0172 void configureBgndAppearanceFile(); 0173 void configureBgndImageFile(); 0174 void configureMenuBgndAppearanceFile(); 0175 void configureMenuBgndImageFile(); 0176 void groupBoxChanged(); 0177 void changeStack(); 0178 void gradChanged(int i); 0179 void borderChanged(int i); 0180 void editItem(QTreeWidgetItem *i, int col); 0181 void itemChanged(QTreeWidgetItem *i, int col); 0182 void addGradStop(); 0183 void removeGradStop(); 0184 void updateGradStop(); 0185 void stopSelected(); 0186 void exportKDE3(); 0187 void exportQt(); 0188 void menubarTitlebarBlend(); 0189 void updatePreview(); 0190 void copyGradient(QAction *act); 0191 void previewControlPressed(); 0192 0193 public: 0194 bool savePreset(const QString &name); 0195 QString getPresetName(const QString &cap, QString label, QString def, 0196 QString name=QString()); 0197 void setupStack(); 0198 void setupPresets(const Options ¤tStyle, const Options &defaultStyle); 0199 void setupPreview(); 0200 void setupGradientsTab(); 0201 void setupShadesTab(); 0202 void setupShade(KDoubleNumInput *w, int shade); 0203 void setupAlpha(KDoubleNumInput *w, int alpha); 0204 void populateShades(const Options &opts); 0205 bool diffShades(const Options &opts); 0206 bool haveImages(); 0207 bool diffImages(const Options &opts); 0208 void setPasswordChar(int ch); 0209 int getTitleBarButtonFlags(); 0210 void setOptions(Options &opts); 0211 void setWidgetOptions(const Options &opts); 0212 int getDwtSettingsFlags(); 0213 int getSquareFlags(); 0214 int getWindowBorderFlags(); 0215 int getGroupBoxLabelFlags(); 0216 int getThinFlags(); 0217 bool diffTitleBarButtonColors(const Options &opts); 0218 bool settingsChanged(const Options &opts); 0219 bool 0220 settingsChanged() 0221 { 0222 return settingsChanged(presets[currentText].opts); 0223 } 0224 0225 private: 0226 Options previewStyle; 0227 CWorkspace *workSpace; 0228 CStylePreview *stylePreview; 0229 QMdiSubWindow *mdiWindow; 0230 QMap<QString, Preset> presets; 0231 #ifdef QTC_QT4_STYLE_SUPPORT 0232 CExportThemeDialog *exportDialog; 0233 #endif 0234 CGradientPreview *gradPreview; 0235 GradientCont customGradient; 0236 KDoubleNumInput *shadeVals[QTC_NUM_STD_SHADES], 0237 *alphaVals[NUM_STD_ALPHAS]; 0238 QString currentText, 0239 defaultText; 0240 QtCurve::KWinConfig *kwin; 0241 int kwinPage; 0242 bool readyForPreview; 0243 CImagePropertiesDialog *bgndPixmapDlg, 0244 *menuBgndPixmapDlg, 0245 *bgndImageDlg, 0246 *menuBgndImageDlg; 0247 }; 0248 0249 #endif