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