KVIrc  4.9.2
DeveloperAPIs
KviTheme.h
Go to the documentation of this file.
1 #ifndef _KVI_THEME_H_
2 #define _KVI_THEME_H_
3 
4 //=============================================================================
5 //
6 // File : KviTheme.h
7 // Creation date : Mon Jan 08 2007 03:23:00 CEST by Szymon Stefanek
8 //
9 // This file is part of the KVIrc IRC client distribution
10 // Copyright (C) 2007-2010 Szymon Stefanek (pragma at kvirc dot net)
11 //
12 // This program is FREE software. You can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the HOPE that it will be USEFUL,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 // See the GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program. If not, write to the Free Software Foundation,
24 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 //
26 //=============================================================================
27 
28 #include "kvi_settings.h"
29 #include "KviQString.h"
30 #include "KviHeapObject.h"
31 #include "kvi_fileextensions.h"
32 #include "KviApplication.h"
33 #include "KviFileUtils.h"
34 
35 #include <QPixmap>
36 
37 #define KVI_THEMEINFO_FILE_NAME "themeinfo" KVI_FILEEXTENSION_CONFIG
38 #define KVI_THEMEDATA_FILE_NAME "themedata" KVI_FILEEXTENSION_CONFIG
39 #define KVI_THEMEINFO_CONFIG_GROUP "ThemeInfo"
40 #define KVI_THEMEDATA_CONFIG_GROUP "ThemeData"
41 
46 #define KVI_CURRENT_THEME_ENGINE_VERSION "1.1.0"
47 
59 {
60 public:
61  KviThemeInfo();
62  ~KviThemeInfo();
63 
64 public:
65  enum Location
66  {
70  Builtin = 0,
74  User = 1,
78  External = 3,
82  Auto = 4
83  };
84 
85 protected:
86  QString m_szName; //< name of the theme
87  QString m_szVersion; //< version of the theme
88 
89  QString m_szDirectory; //< the absolute directory of the theme
90  QString m_szSubdirectory; //< the last component of m_szDirectory (this is needed when the theme is installed)
91  Location m_eLocation; //< the location of the theme
92 
93  QString m_szAuthor; //< author of the theme
94  QString m_szDescription; //< description of the theme
95  QString m_szDate; //< theme creation date
96  QString m_szApplication; //< theme creation (KVIrc) version
97  QString m_szThemeEngineVersion; //< the theme engine version that saved this theme
98 
99  QString m_szLastError; //< reported when some function fails
100 
101  QPixmap m_pixScreenshotLarge; //< the large screenshot pixmap
102  QPixmap m_pixScreenshotMedium; //< the medium screenshot pixmap
103  QPixmap m_pixScreenshotSmall; //< the small screenshot pixmap
104 
105 public:
112  bool load(const QString & szDirectory, Location eLocation);
113 
117  bool save(const QString & szThemeFileName);
118 
119  const QString & lastError() { return m_szLastError; }
120  void setLastError(const QString & szLastError) { m_szLastError = szLastError; }
121  const QString & name() { return m_szName; }
122  void setName(const QString & szName) { m_szName = szName; }
123  const QString & version() { return m_szVersion; }
124  void setVersion(const QString & szVersion) { m_szVersion = szVersion; }
125 
126  const QString & directory() const
127  {
128  return m_szDirectory;
129  }
130 
131  const QString & subdirectory() const
132  {
133  return m_szSubdirectory;
134  }
135 
137  {
138  return m_eLocation;
139  }
140 
141  void setDirectoryAndLocation(const QString & szDirectory, Location eLocation);
142 
143  bool isBuiltin()
144  {
145  return m_eLocation == KviThemeInfo::Builtin;
146  }
147 
148  const QString & author() { return m_szAuthor; }
149  void setAuthor(const QString & szAuthor) { m_szAuthor = szAuthor; }
150  const QString & description() { return m_szDescription; }
151  void setDescription(const QString & szDescription) { m_szDescription = szDescription; }
152  const QString & date() { return m_szDate; }
153  void setDate(const QString & szDate) { m_szDate = szDate; }
154  const QString & application() { return m_szApplication; }
155  void setApplication(const QString & szApplication) { m_szApplication = szApplication; }
156  const QString & themeEngineVersion() { return m_szThemeEngineVersion; }
157  void setThemeEngineVersion(const QString & szThemeEngineVersion) { m_szThemeEngineVersion = szThemeEngineVersion; }
158 
164  const QPixmap & smallScreenshot();
170  const QPixmap & mediumScreenshot();
176  const QPixmap & largeScreenshot();
182  QString smallScreenshotPath();
183 };
184 
185 namespace KviTheme
186 {
197  bool KVIRC_API apply(const QString & szThemeDirectory, KviThemeInfo::Location eLocation, KviThemeInfo & buffer);
198 
209  bool KVIRC_API save(KviThemeInfo & options, bool bSaveIcons);
210 
215  bool KVIRC_API saveScreenshots(KviThemeInfo & options, const QString & szOriginalScreenshotPath);
216 
220  void KVIRC_API installedThemeDirectories(QStringList & slThemes, KviThemeInfo::Location eLocation);
221 }
222 
223 #endif //_KVI_THEME_H_
const QString & subdirectory() const
Definition: KviTheme.h:131
Definition: KviHeapObject.h:124
QString m_szDate
Definition: KviTheme.h:95
#define KVIRC_API
Definition: kvi_settings.h:128
void setThemeEngineVersion(const QString &szThemeEngineVersion)
Definition: KviTheme.h:157
QString m_szName
Definition: KviTheme.h:86
QPixmap m_pixScreenshotLarge
Definition: KviTheme.h:101
void setLastError(const QString &szLastError)
Definition: KviTheme.h:120
A set of information about a KVIrc theme.
Definition: KviTheme.h:58
void setAuthor(const QString &szAuthor)
Definition: KviTheme.h:149
void installedThemeDirectories(QStringList &slThemes, KviThemeInfo::Location eLocation)
Definition: KviTheme.cpp:318
bool isBuiltin()
Definition: KviTheme.h:143
const QString & themeEngineVersion()
Definition: KviTheme.h:156
Location location() const
Definition: KviTheme.h:136
File utilities functions.
Location
Definition: KviTheme.h:65
QString m_szApplication
Definition: KviTheme.h:96
const QString & application()
Definition: KviTheme.h:154
bool save(KviThemeInfo &options, bool bSaveIcons)
Definition: KviOptions.cpp:986
bool saveScreenshots(KviThemeInfo &options, const QString &szOriginalScreenshotPath)
Definition: KviTheme.cpp:268
void setName(const QString &szName)
Definition: KviTheme.h:122
QString m_szSubdirectory
Definition: KviTheme.h:90
bool apply(const QString &szThemeDir, KviThemeInfo::Location eLocation, KviThemeInfo &buffer)
Definition: KviOptions.cpp:1121
const QString & directory() const
Definition: KviTheme.h:126
QPixmap m_pixScreenshotMedium
Definition: KviTheme.h:102
const QString & name()
Definition: KviTheme.h:121
const QString & description()
Definition: KviTheme.h:150
Definition: KviTheme.h:70
QString m_szAuthor
Definition: KviTheme.h:93
QString m_szVersion
Definition: KviTheme.h:87
void setApplication(const QString &szApplication)
Definition: KviTheme.h:155
Heap Object.
QString m_szThemeEngineVersion
Definition: KviTheme.h:97
This file contains the file extensions and filters used by KVIrc.
QString m_szLastError
Definition: KviTheme.h:99
QString m_szDirectory
Definition: KviTheme.h:89
const QString & date()
Definition: KviTheme.h:152
QPixmap m_pixScreenshotSmall
Definition: KviTheme.h:103
This file contains compile time settings.
void setDate(const QString &szDate)
Definition: KviTheme.h:153
QString m_szDescription
Definition: KviTheme.h:94
void setVersion(const QString &szVersion)
Definition: KviTheme.h:124
const QString & version()
Definition: KviTheme.h:123
Helper functions for the QString class.
void setDescription(const QString &szDescription)
Definition: KviTheme.h:151
Location m_eLocation
Definition: KviTheme.h:91
const QString & lastError()
Definition: KviTheme.h:119
const QString & author()
Definition: KviTheme.h:148