1 /******************************************************************************* 2 ** 3 ** Photivo 4 ** 5 ** Copyright (C) 2010-2011 Michael Munzert <mail@mm-log.com> 6 ** Copyright (C) 2010-2011 Bernd Schoeler <brjohn@brother-john.net> 7 ** 8 ** This file is part of Photivo. 9 ** 10 ** Photivo is free software: you can redistribute it and/or modify 11 ** it under the terms of the GNU General Public License version 3 12 ** as published by the Free Software Foundation. 13 ** 14 ** Photivo is distributed in the hope that it will be useful, 15 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 16 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 ** GNU General Public License for more details. 18 ** 19 ** You should have received a copy of the GNU General Public License 20 ** along with Photivo. If not, see <http://www.gnu.org/licenses/>. 21 ** 22 *******************************************************************************/ 23 24 #ifndef PTTHEME_H 25 #define PTTHEME_H 26 27 //============================================================================== 28 29 #include <QApplication> 30 #include <QStringBuilder> 31 #include <QMap> 32 #include <QColor> 33 #include <QPalette> 34 #include <QStyle> 35 36 //============================================================================== 37 38 class ptTheme { 39 public: 40 // Values correspond to the UI combobox indexes. 41 enum Theme { 42 thInvalid = -1, // only needed for constructor 43 thNone = 0, 44 thShapeOnly = 1, 45 th50Grey = 2, 46 thDarkGrey = 3, 47 thNight = 4 48 }; 49 50 enum Highlight { 51 hlInvalid = -1, // only needed for constructor 52 hlWhite = 0, 53 hlPurple = 1, 54 hlBlue = 2, 55 hlGreen = 3, 56 hlOrange = 4 57 }; 58 59 ptTheme(const QApplication* app, Theme newTheme = thDarkGrey, Highlight newHighlight = hlGreen); 60 ~ptTheme(); 61 62 // TODO: make private and write getter 63 QPixmap* ptIconCircleGreen; 64 QPixmap* ptIconCircleRed; 65 QPixmap* ptIconCrossRed; 66 QPixmap* ptIconCheckGreen; 67 QPixmap* ptIconReset; 68 QPixmap* ptIconSavePreset; 69 QPixmap* ptIconAppendPreset; 70 QPixmap* ptIconQuestion; 71 QPixmap* ptIconStar; 72 QPixmap* ptIconStarGrey; 73 const QPixmap IconAddBookmark; 74 const QPixmap IconGoNext; 75 const QPixmap IconGoPrevious; 76 baseColor()77 QColor baseColor() { return c_Base; } altBaseColor()78 QColor altBaseColor() { return c_AltBase; } emphasizedColor()79 QColor emphasizedColor() { return c_Emphasized; } strongColor()80 QColor strongColor() { return c_Strong; } textColor()81 QColor textColor() { return c_Text; } textDisabledColor()82 QColor textDisabledColor() { return c_TextDisabled; } gradientColor()83 QColor gradientColor() { return c_Gradient; } sliderStartColor()84 QColor sliderStartColor() { return c_SliderStart; } sliderStopColor()85 QColor sliderStopColor() { return c_SliderStop; } sliderStartDisabledColor()86 QColor sliderStartDisabledColor() { return c_SliderStartDisabled; } sliderStopDisabledColor()87 QColor sliderStopDisabledColor() { return c_SliderStopDisabled; } highlightColor()88 QColor highlightColor() { return c_Highlight; } 89 90 QPalette menuPalette (); 91 QPalette palette (); 92 void Reset (); 93 void setCustomCSS (const QString& CSSFileName); 94 QStyle* style () const; stylesheet()95 QString stylesheet () { return m_Stylesheet % m_CustomCSS; } 96 bool SwitchTo (Theme newTheme, Highlight newHighlight = hlBlue); systemPalette()97 QPalette systemPalette () { return m_SystemPalette; } systemStyle()98 QStyle* systemStyle () const { return m_SystemStyle; } 99 100 #ifdef Q_OS_MAC 101 QString MacBackGround; 102 bool MacStyleFlag; 103 #endif 104 105 106 private: 107 bool ParseTheme (QString& data, QMap<QString, QString>* vars, int* dataPos); 108 QString ReadUTF8TextFile(const QString& FileName); 109 bool ReplaceColorVars(QString& data, QMap<QString, QString>* vars); 110 bool SetupStylesheet (QString ThemeFileName, const QColor& highlightColor); 111 112 const QStringList ColorNames; 113 const QStringList GraphicsNames; 114 115 Highlight m_CurrentHighlight; 116 Theme m_CurrentTheme; 117 QString m_CustomCSS; 118 QString m_Stylesheet; 119 QPalette m_SystemPalette; 120 QStyle* m_SystemStyle; 121 QPalette m_ThemeMenuPalette; 122 QPalette m_ThemePalette; 123 QStyle* m_ThemeStyle; 124 125 // colours 126 QColor c_Base; // formerly: Background 127 QColor c_AltBase; // formerly: Dark 128 QColor c_Emphasized; // formerly: Bright 129 QColor c_Strong; // formerly: VeryBright 130 QColor c_Text; 131 QColor c_TextDisabled; // formerly: Disabled 132 QColor c_Gradient; 133 QColor c_SliderStart; 134 QColor c_SliderStop; 135 QColor c_SliderStartDisabled; 136 QColor c_SliderStopDisabled; 137 QColor c_Highlight; 138 139 // other graphical elements 140 QString g_SliderStripe; 141 QString g_SliderStripeDisabled; 142 143 }; 144 145 //============================================================================== 146 147 extern ptTheme *Theme; 148 149 //============================================================================== 150 151 #endif // PTTHEME_H 152