4
//=============================================================================
7
// Creation date : Mon Jan 08 2007 03:23:00 CEST by Szymon Stefanek
9
// This file is part of the KVirc irc client distribution
10
// Copyright (C) 2007-2008 Szymon Stefanek (pragma at kvirc dot net)
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 opinion) any later version.
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.
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.
26
//=============================================================================
28
#include "kvi_settings.h"
29
#include "kvi_qstring.h"
30
#include "kvi_heapobject.h"
31
#include "kvi_fileextensions.h"
35
#define KVI_THEMEINFO_FILE_NAME "themeinfo" KVI_FILEEXTENSION_CONFIG
36
#define KVI_THEMEDATA_FILE_NAME "themedata" KVI_FILEEXTENSION_CONFIG
37
#define KVI_THEMEINFO_CONFIG_GROUP "ThemeInfo"
38
#define KVI_THEMEDATA_CONFIG_GROUP "ThemeData"
41
/// The current theme engine version: bump up if you make INCOMPATIBLE
42
/// changes in the method of saving the theme.
44
#define KVI_CURRENT_THEME_ENGINE_VERSION "1.0.0"
47
/// \class KviThemeInfo
49
/// \brief A set of information about a KVIrc theme
51
/// This object contains a set of information about
52
/// a theme that can be read and stored to a standard
53
/// KVIrc configuration file (which is usually named
54
/// themeinfo.kvc but this is not strictly necessary).
56
class KVIRC_API KviThemeInfo : public KviHeapObject
62
QString m_szName; //< name of the theme
63
QString m_szVersion; //< version of the theme
64
QString m_szSubdirectory; //< subdirectory of $LOCALKVIRCDIR/themes where the theme is saved to (not always used)
65
QString m_szAbsoluteDirectory; //< absolute directory where the theme should be saved to (or is loaded from)
66
QString m_szAuthor; //< author of the theme
67
QString m_szDescription; //< description of the theme
68
QString m_szDate; //< theme creation date
69
QString m_szApplication; //< theme creation (KVIrc) version
70
QString m_szThemeEngineVersion; //< the theme engine version that saved this theme
72
QString m_szLastError; //< reported when some function fails
74
QPixmap m_pixScreenshotLarge; //< the large screenshot pixmap
75
QPixmap m_pixScreenshotMedium; //< the medium screenshot pixmap
76
QPixmap m_pixScreenshotSmall; //< the small screenshot pixmap
79
/// load data from a specified theme config file
81
bool load(const QString &szThemeFileName);
83
/// save the currently defined theme configuration in the specified file
85
bool save(const QString &szThemeFileName);
87
const QString & lastError(){ return m_szLastError; };
88
void setLastError(const QString &szLastError){ m_szLastError = szLastError; };
89
const QString & name(){ return m_szName; };
90
void setName(const QString &szName){ m_szName = szName; };
91
const QString & version(){ return m_szVersion; };
92
void setVersion(const QString &szVersion){ m_szVersion = szVersion; };
93
const QString & subdirectory(){ return m_szSubdirectory; };
94
void setSubdirectory(const QString &szSubdirectory){ m_szSubdirectory = szSubdirectory; };
95
const QString & absoluteDirectory(){ return m_szAbsoluteDirectory; };
96
void setAbsoluteDirectory(const QString &szAbsoluteDirectory){ m_szAbsoluteDirectory = szAbsoluteDirectory; }
97
const QString & author(){ return m_szAuthor; };
98
void setAuthor(const QString &szAuthor){ m_szAuthor = szAuthor; };
99
const QString & description(){ return m_szDescription; };
100
void setDescription(const QString &szDescription){ m_szDescription = szDescription; };
101
const QString & date(){ return m_szDate; };
102
void setDate(const QString &szDate){ m_szDate = szDate; };
103
const QString & application(){ return m_szApplication; };
104
void setApplication(const QString &szApplication){ m_szApplication = szApplication; };
105
const QString & themeEngineVersion(){ return m_szThemeEngineVersion; };
106
void setThemeEngineVersion(const QString &szThemeEngineVersion){ m_szThemeEngineVersion = szThemeEngineVersion; };
109
/// Attempt to load a themeinfo.kvc file present in the specified directory.
110
/// This function will fail if the directory contains a valid themeinfo.kvc
111
/// file but no themedata.kvc file unless bIgnoreThemeData is set to true
113
bool loadFromDirectory(const QString &szThemeDirectory,bool bIgnoreThemeData = false);
116
/// Attempt to load the theme screenshot from THEMEDIR/screenshot_*.png
117
/// This function will work only if the absoluteDirectory() of the theme
118
/// has been set, otherwise the returned pixmap will be null.
120
const QPixmap & smallScreenshot();
122
/// Attempt to load the theme screenshot from THEMEDIR/screenshot_*.png
123
/// This function will work only if the absoluteDirectory() of the theme
124
/// has been set, otherwise the returned pixmap will be null.
126
const QPixmap & mediumScreenshot();
128
/// Attempt to load the theme screenshot from THEMEDIR/screenshot_*.png
129
/// This function will work only if the absoluteDirectory() of the theme
130
/// has been set, otherwise the returned pixmap will be null.
132
const QPixmap & largeScreenshot();
134
/// Attempt to load the theme screenshot from THEMEDIR/screenshot_*.png
135
/// This function will work only if the absoluteDirectory() of the theme
136
/// has been set, otherwise the returned pixmap will be null.
138
QString smallScreenshotPath();
144
/// Attempt to load (apply) a theme in the specified directory
145
/// Will return true on success and false on failure.
146
/// On success this function will return the theme information in the buffer.
147
/// On failure this function will also set buffer.lastError() to a meaningful value
148
/// Note that for convenience this function is implemented in kvi_options.cpp
150
bool KVIRC_API load(const QString &szThemeDir,KviThemeInfo &buffer);
152
/// Save a theme given the specified options.
153
/// Will return true on success and false on failure.
154
/// On failure this function will also set options.lastError() to a meaningful value
155
/// This function requires both absoluteDirectory() and subdirectory() to be
156
/// set to the right values. In theory this function could save a theme
157
/// in a directory different than $KVIRC_LOCAL_DIR/themes/subdirectory
158
/// but this feature is actually unused.
159
/// Note that for convenience this function is implemented in kvi_options.cpp
161
bool KVIRC_API save(KviThemeInfo &options);
163
/// Save the theme screenshots in the given EXISTING directory and given
164
/// an existing screenshot on disk (usually in the tmp directory).
166
bool KVIRC_API saveScreenshots(KviThemeInfo &options,const QString &szOriginalScreenshotPath);
170
#endif //_KVI_THEME_H_