File indexing completed on 2024-10-06 04:26:03
0001 /* 0002 SPDX-FileCopyrightText: 1998-2008 Sebastian Trueg <trueg@k3b.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef _K3B_THEME_MANAGER_H_ 0008 #define _K3B_THEME_MANAGER_H_ 0009 0010 #include <QObject> 0011 #include <QString> 0012 #include <QMap> 0013 #include <QColor> 0014 #include <QPixmap> 0015 0016 #include <KConfigGroup> 0017 0018 0019 namespace K3b { 0020 class Theme 0021 { 0022 public: 0023 Theme(); 0024 explicit Theme( QString name ); 0025 0026 QColor backgroundColor() const; 0027 QColor foregroundColor() const; 0028 0029 enum PixmapType { 0030 MEDIA_AUDIO, /**< Media information header, right side when showing an audio CD. */ 0031 MEDIA_DATA, /**< Media information header, right side when showing a data media. */ 0032 MEDIA_VIDEO, /**< Media information header, right side when showing a video media. */ 0033 MEDIA_EMPTY, /**< Media information header, right side when showing an empty media. */ 0034 MEDIA_MIXED, /**< Media information header, right side when showing a mixed mode CD. */ 0035 MEDIA_NONE, /**< Media information header, right side default pixmap (no media). */ 0036 MEDIA_LEFT, /**< Media information header, left side. */ 0037 PROGRESS_WORKING, /**< Progress dialog, left top while working. */ 0038 PROGRESS_SUCCESS, /**< Progress dialog, left top on success. */ 0039 PROGRESS_FAIL, /**< Progress dialog, left top on failure. */ 0040 PROGRESS_RIGHT, /**< Progress dialog, right top. */ 0041 DIALOG_LEFT, /**< Action dialog, left top. */ 0042 DIALOG_RIGHT, /**< Action dialog, right top. */ 0043 SPLASH, /**< K3b splash screen. Size not important. */ 0044 PROJECT_LEFT, /**< Project header left side. */ 0045 PROJECT_RIGHT, /**< Project header right side. */ 0046 WELCOME_BG /**< Background pixmap of the welcome window. */ 0047 }; 0048 0049 enum BackgroundMode { 0050 BG_TILE, /**< Keep the pixmap's size and tile the welcome widget */ 0051 BG_SCALE /**< Scale the pixmap to fill the welcome widget. */ 0052 }; 0053 0054 QPixmap pixmap( PixmapType ) const; 0055 0056 /** 0057 * \deprecated use pixmap( PixmapType ) 0058 */ 0059 QPixmap pixmap( const QString& name ) const; 0060 0061 BackgroundMode backgroundMode() const; 0062 0063 QString name() const { return m_name; } 0064 QString author() const { return m_author; } 0065 QString comment() const { return m_comment; } 0066 QString version() const { return m_version; } 0067 0068 /** 0069 * Global themes are installed for all users and cannot be deleted. 0070 */ 0071 bool global() const { return !local(); } 0072 0073 /** 0074 * Local themes are installed in the user's home directory and can be deleted. 0075 */ 0076 bool local() const { return m_local; } 0077 0078 QString path() const { return m_path; } 0079 0080 QPalette palette() const; 0081 0082 static QString filenameForPixmapType( PixmapType ); 0083 0084 private: 0085 QString m_path; 0086 bool m_local; 0087 QString m_name; 0088 QString m_author; 0089 QString m_comment; 0090 QString m_version; 0091 QColor m_bgColor; 0092 QColor m_fgColor; 0093 BackgroundMode m_bgMode; 0094 0095 mutable QMap<QString, QPixmap> m_pixmapMap; 0096 0097 QPixmap m_emptyPixmap; 0098 0099 friend class ThemeManager; 0100 }; 0101 0102 0103 class ThemeManager : public QObject 0104 { 0105 Q_OBJECT 0106 0107 public: 0108 explicit ThemeManager( QObject* parent = 0 ); 0109 ~ThemeManager() override; 0110 0111 QList<Theme*>& themes() const; 0112 0113 /** 0114 * This is never null. If no theme could be found an empty dummy theme 0115 * will be returns which does not contains any pixmaps. 0116 */ 0117 Theme* currentTheme() const; 0118 Theme* findTheme( const QString& ) const; 0119 0120 Q_SIGNALS: 0121 void themeChanged(); 0122 void themeChanged( Theme* ); 0123 0124 public Q_SLOTS: 0125 void readConfig( const KConfigGroup& ); 0126 void saveConfig( KConfigGroup ); 0127 void setCurrentTheme( const QString& ); 0128 void setCurrentTheme( Theme* ); 0129 void loadThemes(); 0130 0131 private: 0132 void loadTheme( const QString& name ); 0133 0134 class Private; 0135 Private* d; 0136 }; 0137 } 0138 0139 #endif