You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kvirc/src/kvirc/kernel/kvi_theme.h

172 lines
7.3 KiB

#ifndef _KVI_THEME_H_
#define _KVI_THEME_H_
//=============================================================================
//
// File : kvi_theme.h
// Creation date : Mon Jan 08 2007 03:23:00 CEST by Szymon Stefanek
//
// This file is part of the KVirc irc client distribution
// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net)
//
// This program is FREE software. You can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your opinion) any later version.
//
// This program is distributed in the HOPE that it will be USEFUL,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, write to the Free Software Foundation,
// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
//=============================================================================
#include "kvi_settings.h"
#include "kvi_qstring.h"
#include "kvi_heapobject.h"
#include "kvi_fileextensions.h"
#include <tqpixmap.h>
#define KVI_THEMEINFO_FILE_NAME "themeinfo." KVI_FILEEXTENSION_CONFIG
#define KVI_THEMEDATA_FILE_NAME "themedata." KVI_FILEEXTENSION_CONFIG
#define KVI_THEMEINFO_CONFIG_GROUP "ThemeInfo"
#define KVI_THEMEDATA_CONFIG_GROUP "ThemeData"
///
/// The current theme engine version: bump up if you make INCOMPATIBLE
/// changes in the method of saving the theme.
///
#define KVI_CURRENT_THEME_ENGINE_VERSION "1.0.0"
///
/// \class KviThemeInfo
///
/// \brief A set of informations about a KVIrc theme
///
/// This object contains a set of informations about
/// a theme that can be read and stored to a standard
/// KVIrc configuration file (which is usually named
/// themeinfo.kvc but this is not strictly necessary).
///
class KVIRC_API KviThemeInfo : public KviHeapObject
{
public:
KviThemeInfo();
~KviThemeInfo();
protected:
TQString m_szName; //< name of the theme
TQString m_szVersion; //< version of the theme
TQString m_szSubdirectory; //< subdirectory of $LOCALKVIRCDIR/themes where the theme is saved to (not always used)
TQString m_szAbsoluteDirectory; //< absolute directory where the theme should be saved to (or is loaded from)
TQString m_szAuthor; //< author of the theme
TQString m_szDescription; //< description of the theme
TQString m_szDate; //< theme creation date
TQString m_szApplication; //< theme creation (KVIrc) version
TQString m_szThemeEngineVersion; //< the theme engine version that saved this theme
TQString m_szLastError; //< reported when some function fails
TQPixmap m_pixScreenshotLarge; //< the large screenshot pixmap
TQPixmap m_pixScreenshotMedium; //< the medium screenshot pixmap
TQPixmap m_pixScreenshotSmall; //< the small screenshot pixmap
public:
///
/// load data from a specified theme config file
///
bool load(const TQString &szThemeFileName);
///
/// save the currently defined theme configuration in the specified file
///
bool save(const TQString &szThemeFileName);
const TQString & lastError(){ return m_szLastError; };
void setLastError(const TQString &szLastError){ m_szLastError = szLastError; };
const TQString & name(){ return m_szName; };
void setName(const TQString &szName){ m_szName = szName; };
const TQString & version(){ return m_szVersion; };
void setVersion(const TQString &szVersion){ m_szVersion = szVersion; };
const TQString & subdirectory(){ return m_szSubdirectory; };
void setSubdirectory(const TQString &szSubdirectory){ m_szSubdirectory = szSubdirectory; };
const TQString & absoluteDirectory(){ return m_szAbsoluteDirectory; };
void setAbsoluteDirectory(const TQString &szAbsoluteDirectory){ m_szAbsoluteDirectory = szAbsoluteDirectory; }
const TQString & author(){ return m_szAuthor; };
void setAuthor(const TQString &szAuthor){ m_szAuthor = szAuthor; };
const TQString & description(){ return m_szDescription; };
void setDescription(const TQString &szDescription){ m_szDescription = szDescription; };
const TQString & date(){ return m_szDate; };
void setDate(const TQString &szDate){ m_szDate = szDate; };
const TQString & application(){ return m_szApplication; };
void setApplication(const TQString &szApplication){ m_szApplication = szApplication; };
const TQString & themeEngineVersion(){ return m_szThemeEngineVersion; };
void setThemeEngineVersion(const TQString &szThemeEngineVersion){ m_szThemeEngineVersion = szThemeEngineVersion; };
///
/// Attempt to load a themeinfo.kvc file present in the specified directory.
/// This function will fail if the directory contains a valid themeinfo.kvc
/// file but no themedata.kvc file unless bIgnoreThemeData is set to true
///
bool loadFromDirectory(const TQString &szThemeDirectory,bool bIgnoreThemeData = false);
///
/// Attempt to load the theme screenshot from THEMEDIR/screenshot_*.png
/// This function will work only if the absoluteDirectory() of the theme
/// has been set, otherwise the returned pixmap will be null.
///
const TQPixmap & smallScreenshot();
///
/// Attempt to load the theme screenshot from THEMEDIR/screenshot_*.png
/// This function will work only if the absoluteDirectory() of the theme
/// has been set, otherwise the returned pixmap will be null.
///
const TQPixmap & mediumScreenshot();
///
/// Attempt to load the theme screenshot from THEMEDIR/screenshot_*.png
/// This function will work only if the absoluteDirectory() of the theme
/// has been set, otherwise the returned pixmap will be null.
///
const TQPixmap & largeScreenshot();
///
/// Attempt to load the theme screenshot from THEMEDIR/screenshot_*.png
/// This function will work only if the absoluteDirectory() of the theme
/// has been set, otherwise the returned pixmap will be null.
///
TQString smallScreenshotPath();
};
namespace KviTheme
{
///
/// Attempt to load (apply) a theme in the specified directory
/// Will return true on success and false on failure.
/// On success this function will return the theme informations in the buffer.
/// On failure this function will also set buffer.lastError() to a meaningful value
/// Note that for convenience this function is implemented in kvi_options.cpp
///
bool KVIRC_API load(const TQString &szThemeDir,KviThemeInfo &buffer);
///
/// Save a theme given the specified options.
/// Will return true on success and false on failure.
/// On failure this function will also set options.lastError() to a meaningful value
/// This function requires both absoluteDirectory() and subdirectory() to be
/// set to the right values. In theory this function could save a theme
/// in a directory different than $KVIRC_LOCAL_DIR/themes/subdirectory
/// but this feature is actually unused.
/// Note that for convenience this function is implemented in kvi_options.cpp
///
bool KVIRC_API save(KviThemeInfo &options);
///
/// Save the theme screenshots in the given EXISTING directory and given
/// an existing screenshot on disk (usually in the tmp directory).
///
bool KVIRC_API saveScreenshots(KviThemeInfo &options,const TQString &szOriginalScreenshotPath);
};
#endif //_KVI_THEME_H_