1 /* 2 * Copyright (c) 2014-2021, Ilya Kotov <forkotov02@ya.ru> 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in 13 * the documentation and/or other materials provided with the 14 * distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #ifndef APPEARANCEPAGE_H 30 #define APPEARANCEPAGE_H 31 32 #include "tabpage.h" 33 34 namespace Ui { 35 class AppearancePage; 36 class PreviewForm; 37 } 38 39 class QStyle; 40 class QAction; 41 42 class AppearancePage : public TabPage 43 { 44 Q_OBJECT 45 46 public: 47 explicit AppearancePage(QWidget *parent = nullptr); 48 ~AppearancePage(); 49 50 void writeSettings() override; 51 52 private slots: 53 void on_styleComboBox_activated(const QString &text); 54 void on_colorSchemeComboBox_activated(int); 55 void createColorScheme(); 56 void changeColorScheme(); 57 void removeColorScheme(); 58 void copyColorScheme(); 59 void renameColorScheme(); 60 void updatePalette(); 61 void setPreviewPalette(const QPalette &p); 62 void updateActions(); 63 64 private: 65 void readSettings(); 66 void setStyle(QWidget *w, QStyle *s); 67 void setPalette(QWidget *w, QPalette p); 68 void findColorSchemes(const QString &path); 69 void findColorSchemes(const QStringList &paths); 70 QPalette loadColorScheme(const QString &filePath); 71 void createColorScheme(const QString &name, const QPalette &palette); 72 Ui::AppearancePage *m_ui; 73 QStyle *m_selectedStyle = nullptr; 74 QPalette m_customPalette; 75 QWidget *m_previewWidget; 76 QAction *m_changeColorSchemeAction, *m_renameColorSchemeAction, *m_removeColorSchemeAction; 77 Ui::PreviewForm *m_previewUi; 78 }; 79 80 #endif // APPEARANCEPAGE_H 81