aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config.h.in18
-rw-r--r--src/kvi_configstatus.h36
-rw-r--r--src/kvilib/build/Makefile.am2
-rw-r--r--src/kvilib/ext/kvi_cmdformatter.cpp6
-rw-r--r--src/kvilib/ext/kvi_cmdformatter.h8
-rw-r--r--src/kvilib/ext/kvi_miscutils.cpp77
-rw-r--r--src/kvilib/ext/kvi_miscutils.h44
-rw-r--r--src/kvilib/file/kvi_packagefile.cpp8
-rw-r--r--src/kvilib/file/kvi_packagefile.h1
-rw-r--r--src/kvirc/build/Makefile.am22
-rw-r--r--src/kvirc/kernel/kvi_app.h20
-rw-r--r--src/kvirc/kernel/kvi_options.cpp641
-rw-r--r--src/kvirc/kernel/kvi_theme.cpp159
-rw-r--r--src/kvirc/kernel/kvi_theme.h109
-rw-r--r--src/kvirc/kvs/kvi_kvs_corefunctions_af.cpp2
-rw-r--r--src/kvirc/kvs/kvi_kvs_scriptaddonmanager.cpp42
-rw-r--r--src/kvirc/kvs/kvi_kvs_scriptaddonmanager.h3
-rw-r--r--src/kvirc/ui/kvi_htmldialog.cpp152
-rw-r--r--src/kvirc/ui/kvi_htmldialog.h85
-rw-r--r--src/kvirc/ui/kvi_xmladdonloader.cpp3
-rw-r--r--src/kvirc/ui/kvi_xmladdonloader.h2
-rw-r--r--src/modules/addon/libkviaddon.cpp11
-rw-r--r--src/modules/math/libkvimath.cpp2
-rw-r--r--src/modules/mediaplayer/libkvimediaplayer.cpp3
-rw-r--r--src/modules/mediaplayer/mp_xmmsinterface.cpp183
-rw-r--r--src/modules/mediaplayer/mp_xmmsinterface.h25
-rw-r--r--src/modules/setup/libkvisetup.cpp4
-rw-r--r--src/modules/system/libkvisystem.cpp36
-rw-r--r--src/modules/theme/Makefile.am22
-rw-r--r--src/modules/theme/libkvitheme.cpp14
-rw-r--r--src/modules/theme/managementdialog.cpp834
-rw-r--r--src/modules/theme/managementdialog.h69
-rw-r--r--src/modules/theme/packthemedialog.cpp456
-rw-r--r--src/modules/theme/packthemedialog.h65
-rw-r--r--src/modules/theme/savethemedialog.cpp173
-rw-r--r--src/modules/theme/savethemedialog.h62
-rw-r--r--src/modules/theme/themefunctions.cpp240
-rw-r--r--src/modules/theme/themefunctions.h39
38 files changed, 2184 insertions, 1494 deletions
diff --git a/src/config.h.in b/src/config.h.in
index ebd1e3ba8..b4d456ee7 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -187,31 +187,31 @@
/* Define to the version of this package. */
#undef PACKAGE_VERSION
-/* The size of `int', as computed by sizeof. */
+/* The size of a `int', as computed by sizeof. */
#undef SIZEOF_INT
-/* The size of `long int', as computed by sizeof. */
+/* The size of a `long int', as computed by sizeof. */
#undef SIZEOF_LONG_INT
-/* The size of `long long int', as computed by sizeof. */
+/* The size of a `long long int', as computed by sizeof. */
#undef SIZEOF_LONG_LONG_INT
-/* The size of `short int', as computed by sizeof. */
+/* The size of a `short int', as computed by sizeof. */
#undef SIZEOF_SHORT_INT
-/* The size of `unsigned int', as computed by sizeof. */
+/* The size of a `unsigned int', as computed by sizeof. */
#undef SIZEOF_UNSIGNED_INT
-/* The size of `unsigned long int', as computed by sizeof. */
+/* The size of a `unsigned long int', as computed by sizeof. */
#undef SIZEOF_UNSIGNED_LONG_INT
-/* The size of `unsigned long long int', as computed by sizeof. */
+/* The size of a `unsigned long long int', as computed by sizeof. */
#undef SIZEOF_UNSIGNED_LONG_LONG_INT
-/* The size of `unsigned short int', as computed by sizeof. */
+/* The size of a `unsigned short int', as computed by sizeof. */
#undef SIZEOF_UNSIGNED_SHORT_INT
-/* The size of `void *', as computed by sizeof. */
+/* The size of a `void *', as computed by sizeof. */
#undef SIZEOF_VOID_P
/* Define to 1 if you have the ANSI C header files. */
diff --git a/src/kvi_configstatus.h b/src/kvi_configstatus.h
index b90b373e4..16932ea9b 100644
--- a/src/kvi_configstatus.h
+++ b/src/kvi_configstatus.h
@@ -1,4 +1,4 @@
-/* src/config.h. Generated from config.h.in by configure. */
+/* src/config.h. Generated by configure. */
/* src/config.h.in. Generated from configure.in by autoheader. */
/* define this to the number of average channel users */
@@ -8,16 +8,16 @@
/* #undef BIG_ENDIAN_MACHINE_BYTE_ORDER */
/* this is the build date (configure date rather) */
-#define BUILD_DATE "Sat Jan 6 18:57:30 UTC 2007"
+#define BUILD_DATE "Wed Jan 10 00:14:01 UTC 2007"
/* these are the build flags */
-#define BUILD_FLAGS "x86_64-ciopsAGTZ"
+#define BUILD_FLAGS "x86_64-cefgikopsAGTZ"
/* define if you want to enable the Arts daemon support */
/* #undef COMPILE_ARTS_SUPPORT */
/* define if you want to enable the Audiofile library support */
-/* #undef COMPILE_AUDIOFILE_SUPPORT */
+#define COMPILE_AUDIOFILE_SUPPORT 1
/* define if you want to compile the crypt support */
#define COMPILE_CRYPT_SUPPORT 1
@@ -26,7 +26,7 @@
/* #undef COMPILE_DISABLE_DCC_VOICE */
/* define if you want to enable the Esound daemon support */
-/* #undef COMPILE_ESD_SUPPORT */
+#define COMPILE_ESD_SUPPORT 1
/* define if you have the SIOCGIFADDR ioctl and the related headers */
#define COMPILE_GET_INTERFACE_ADDRESS 1
@@ -41,7 +41,7 @@
#define COMPILE_IPV6_SUPPORT 1
/* define if you want to compile the KDE 2.x support */
-/* #undef COMPILE_KDE_SUPPORT */
+#define COMPILE_KDE_SUPPORT 1
/* define if you want the memory checks */
/* #undef COMPILE_MEMORY_CHECKS */
@@ -57,7 +57,7 @@
/* #undef COMPILE_NO_IPC */
/* define if you want to ignore X Windows completely */
-#define COMPILE_NO_X 1
+/* #undef COMPILE_NO_X */
/* define if you want to disable the X bell support */
/* #undef COMPILE_NO_X_BELL */
@@ -69,7 +69,7 @@
#define COMPILE_OSS_SUPPORT 1
/* define if you have perl and want the perl scripting support in kvirc */
-/* #undef COMPILE_PERL_SUPPORT */
+#define COMPILE_PERL_SUPPORT 1
/* define if you have the KDE support and want the pseudo transparency */
#define COMPILE_PSEUDO_TRANSPARENCY 1
@@ -93,7 +93,7 @@
#define COMPILE_WITH_SYSTEM_MEMMOVE 1
/* define if you want to enable the ZLib library support */
-/* #undef COMPILE_XSS_SUPPORT */
+#define COMPILE_XSS_SUPPORT 1
/* define if you want to enable the ZLib library support */
#define COMPILE_ZLIB_SUPPORT 1
@@ -188,31 +188,31 @@
/* Define to the version of this package. */
#define PACKAGE_VERSION ""
-/* The size of `int', as computed by sizeof. */
+/* The size of a `int', as computed by sizeof. */
#define SIZEOF_INT 4
-/* The size of `long int', as computed by sizeof. */
+/* The size of a `long int', as computed by sizeof. */
#define SIZEOF_LONG_INT 8
-/* The size of `long long int', as computed by sizeof. */
+/* The size of a `long long int', as computed by sizeof. */
#define SIZEOF_LONG_LONG_INT 8
-/* The size of `short int', as computed by sizeof. */
+/* The size of a `short int', as computed by sizeof. */
#define SIZEOF_SHORT_INT 2
-/* The size of `unsigned int', as computed by sizeof. */
+/* The size of a `unsigned int', as computed by sizeof. */
#define SIZEOF_UNSIGNED_INT 4
-/* The size of `unsigned long int', as computed by sizeof. */
+/* The size of a `unsigned long int', as computed by sizeof. */
#define SIZEOF_UNSIGNED_LONG_INT 8
-/* The size of `unsigned long long int', as computed by sizeof. */
+/* The size of a `unsigned long long int', as computed by sizeof. */
#define SIZEOF_UNSIGNED_LONG_LONG_INT 8
-/* The size of `unsigned short int', as computed by sizeof. */
+/* The size of a `unsigned short int', as computed by sizeof. */
#define SIZEOF_UNSIGNED_SHORT_INT 2
-/* The size of `void *', as computed by sizeof. */
+/* The size of a `void *', as computed by sizeof. */
#define SIZEOF_VOID_P 8
/* Define to 1 if you have the ANSI C header files. */
diff --git a/src/kvilib/build/Makefile.am b/src/kvilib/build/Makefile.am
index cf7bbbbea..6b2bd7bec 100644
--- a/src/kvilib/build/Makefile.am
+++ b/src/kvilib/build/Makefile.am
@@ -48,6 +48,7 @@ libkvilib_la_SOURCES = \
../ext/kvi_imagelib.cpp \
../ext/kvi_md5.cpp \
../ext/kvi_mediatype.cpp \
+ ../ext/kvi_miscutils.cpp \
../ext/kvi_msgtype.cpp \
../ext/kvi_parameterlist.cpp \
../ext/kvi_pixmap.cpp \
@@ -122,6 +123,7 @@ headers_HEADERS = \
../ext/kvi_imagelib.h \
../ext/kvi_md5.h \
../ext/kvi_mediatype.h \
+ ../ext/kvi_miscutils.h \
../ext/kvi_msgtype.h \
../ext/kvi_parameterlist.h \
../ext/kvi_pixmap.h \
diff --git a/src/kvilib/ext/kvi_cmdformatter.cpp b/src/kvilib/ext/kvi_cmdformatter.cpp
index e91e50ca9..536aa7873 100644
--- a/src/kvilib/ext/kvi_cmdformatter.cpp
+++ b/src/kvilib/ext/kvi_cmdformatter.cpp
@@ -1,9 +1,10 @@
+//=============================================================================
//
// File : kvi_cmdformatter.cpp
// Creation date : Tue Jun 12 2001 03:08:12 CEST by Szymon Stefanek
//
// This file is part of the KVirc irc client distribution
-// Copyright (C) 2001 Szymon Stefanek (pragma at kvirc dot net)
+// Copyright (C) 2001-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
@@ -19,11 +20,10 @@
// along with this program. If not, write to the Free Software Foundation,
// Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
+//=============================================================================
#define __KVILIB__
-
-#define _KVI_CMDFORMATTER_CPP_
#include "kvi_cmdformatter.h"
namespace KviCommandFormatter
diff --git a/src/kvilib/ext/kvi_cmdformatter.h b/src/kvilib/ext/kvi_cmdformatter.h
index b73187068..d64e24b45 100644
--- a/src/kvilib/ext/kvi_cmdformatter.h
+++ b/src/kvilib/ext/kvi_cmdformatter.h
@@ -1,12 +1,13 @@
#ifndef _KVI_CMDFORMATTER_H_
#define _KVI_CMDFORMATTER_H_
+//=============================================================================
//
// File : kvi_cmdformatter.h
// Creation date : Tue Jun 12 2001 03:04:05 CEST by Szymon Stefanek
//
// This file is part of the KVirc irc client distribution
-// Copyright (C) 2001 Szymon Stefanek (pragma at kvirc dot net)
+// Copyright (C) 2001-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
@@ -22,6 +23,7 @@
// along with this program. If not, write to the Free Software Foundation,
// Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
+//=============================================================================
#include "kvi_string.h"
#include "kvi_settings.h"
@@ -29,8 +31,6 @@
#include "kvi_qstring.h"
#include <qstringlist.h>
-//#ifndef _KVI_CMDFORMATTER_CPP_
-
namespace KviCommandFormatter
{
extern KVILIB_API bool hasLeadingChars(KviStr * array,char c);
@@ -61,6 +61,4 @@ namespace KviCommandFormatter
extern KVILIB_API void blockFromBuffer(QString &buffer);
};
-//#endif //_KVI_CMDFORMATTER_CPP_
-
#endif //_KVI_CMDFORMATTER_H_
diff --git a/src/kvilib/ext/kvi_miscutils.cpp b/src/kvilib/ext/kvi_miscutils.cpp
new file mode 100644
index 000000000..a56197ecf
--- /dev/null
+++ b/src/kvilib/ext/kvi_miscutils.cpp
@@ -0,0 +1,77 @@
+//=============================================================================
+//
+// File : kvi_miscutils.cpp
+// Created on Mon 08 Jan 2007 04:07:31 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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//=============================================================================
+
+#define __KVILIB__
+#include "kvi_miscutils.h"
+
+#include <qstringlist.h>
+
+namespace KviMiscUtils
+{
+ int compareVersions(const QString &szVersion1,const QString &szVersion2)
+ {
+ QStringList sl1 = QStringList::split(".",szVersion1);
+ QStringList sl2 = QStringList::split(".",szVersion2);
+
+ QStringList::Iterator it1 = sl1.begin();
+ QStringList::Iterator it2 = sl2.begin();
+ while((it1 != sl1.end()) && (it2 != sl2.end()))
+ {
+ bool bOk;
+ int i1 = (*it1).toInt(&bOk);
+ if(!bOk)return 1;
+ int i2 = (*it2).toInt(&bOk);
+ if(!bOk)return -1;
+ if(i1 != i2)
+ {
+ // field not equal
+ if(i1 > i2)return -1;
+ else return 1;
+ }
+ it1++;
+ it2++;
+ }
+ // both are equal until now
+ if(it1 != sl1.end())return -1; // 1 has at least one field more
+ if(it2 != sl2.end())return 1; // 2 has at least one field more
+ // both are equal also in length
+ return 0;
+ }
+
+ bool isValidVersionString(const QString &szVersion)
+ {
+ QStringList sl = QStringList::split(".",szVersion);
+ if(sl.isEmpty())return false;
+ // must all be numbers
+ for(QStringList::Iterator it = sl.begin();it != sl.end();++it)
+ {
+ bool bOk;
+ int i = (*it).toInt(&bOk);
+ if(!bOk)return false;
+ if(i < 0)return false;
+ }
+ return true;
+ }
+
+};
diff --git a/src/kvilib/ext/kvi_miscutils.h b/src/kvilib/ext/kvi_miscutils.h
new file mode 100644
index 000000000..ba730620c
--- /dev/null
+++ b/src/kvilib/ext/kvi_miscutils.h
@@ -0,0 +1,44 @@
+#ifndef _KVI_MISCUTILS_H_
+#define _KVI_MISCUTILS_H_
+//=============================================================================
+//
+// File : kvi_miscutils.h
+// Created on Mon 08 Jan 2007 04:07:31 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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//=============================================================================
+
+#include "kvi_settings.h"
+#include "kvi_qstring.h"
+
+// this is the namespace for single function stuff that doesn't really fit anywhere else
+
+namespace KviMiscUtils
+{
+ // Compare two x.y.z... version strings.
+ // The function behaves like strcmp: it returns 0 when the versions
+ // are equal, -1 if the szVersion1 is greater and 1 if szVersion2 is greater
+ int compareVersions(const QString &szVersion1,const QString &szVersion2);
+
+ // Check if the argument string is a valid x.y.z.... version string
+ bool isValidVersionString(const QString &szVersion);
+
+};
+
+#endif //!_KVI_MISCUTILS_H_
diff --git a/src/kvilib/file/kvi_packagefile.cpp b/src/kvilib/file/kvi_packagefile.cpp
index 8da076d47..9c0e4225c 100644
--- a/src/kvilib/file/kvi_packagefile.cpp
+++ b/src/kvilib/file/kvi_packagefile.cpp
@@ -902,6 +902,14 @@ bool KviPackageReader::unpackFile(KviFile * pFile,const QString &szUnpackPath)
return true;
}
+bool KviPackageReader::getStringInfoField(const QString &szName,QString &szBuffer)
+{
+ QString * pVal = m_pStringInfoFields->find(szName);
+ if(!pVal)return false;
+ szBuffer = *pVal;
+ return true;
+}
+
bool KviPackageReader::unpack(const QString &szLocalFileName,const QString &szUnpackPath,kvi_u32_t uUnpackFlags)
{
bool bRet = unpackInternal(szLocalFileName,szUnpackPath,uUnpackFlags);
diff --git a/src/kvilib/file/kvi_packagefile.h b/src/kvilib/file/kvi_packagefile.h
index f8e1439b6..aba851d17 100644
--- a/src/kvilib/file/kvi_packagefile.h
+++ b/src/kvilib/file/kvi_packagefile.h
@@ -129,6 +129,7 @@ public:
enum UnpackFlags {
NoProgressDialog = 1
};
+ bool getStringInfoField(const QString &szName,QString &szBuffer);
bool unpack(const QString &szLocalFileName,const QString &szUnpackPath,kvi_u32_t uUnpackFlags = 0);
private:
bool unpackInternal(const QString &szLocalFileName,const QString &szUnpackPath,kvi_u32_t uUnpackFlags = 0);
diff --git a/src/kvirc/build/Makefile.am b/src/kvirc/build/Makefile.am
index 13d031ebc..751f0c175 100644
--- a/src/kvirc/build/Makefile.am
+++ b/src/kvirc/build/Makefile.am
@@ -44,6 +44,7 @@ nodist_kvirc_SOURCES = ../kernel/moc_kvi_action.cpp \
../ui/moc_kvi_actiondrawer.cpp \
../ui/moc_kvi_customtoolbar.cpp \
../ui/moc_kvi_debugwindow.cpp \
+../ui/moc_kvi_htmldialog.cpp \
../ui/moc_kvi_imagedialog.cpp \
../ui/moc_kvi_ircviewtools.cpp \
../ui/moc_kvi_mdicaption.cpp \
@@ -83,8 +84,13 @@ kvirc_SOURCES = ../kernel/kvi_action.cpp \
../kernel/kvi_irclink.cpp \
../kernel/kvi_ircsocket.cpp \
../kernel/kvi_ircurl.cpp \
-../kernel/kvi_main.cpp ../kernel/kvi_lagmeter.cpp ../kernel/kvi_notifylist.cpp \
-../kernel/kvi_options.cpp ../kernel/kvi_sslmaster.cpp ../kernel/kvi_texticonmanager.cpp \
+../kernel/kvi_main.cpp \
+../kernel/kvi_lagmeter.cpp \
+../kernel/kvi_notifylist.cpp \
+../kernel/kvi_options.cpp \
+../kernel/kvi_sslmaster.cpp \
+../kernel/kvi_texticonmanager.cpp \
+../kernel/kvi_theme.cpp \
../kernel/kvi_useraction.cpp \
../kernel/kvi_userinput.cpp \
../kvs/kvi_kvs.cpp \
@@ -219,6 +225,7 @@ kvirc_SOURCES = ../kernel/kvi_action.cpp \
../ui/kvi_filedialog.cpp \
../ui/kvi_frame.cpp \
../ui/kvi_historywin.cpp \
+../ui/kvi_htmldialog.cpp \
../ui/kvi_imagedialog.cpp \
../ui/kvi_input.cpp \
../ui/kvi_ipeditor.cpp \
@@ -289,8 +296,14 @@ headers_HEADERS = ../kernel/kvi_action.h \
../kernel/kvi_ircsocket.h \
../kernel/kvi_ircurl.h \
../kernel/kvi_lagmeter.h \
-../kernel/kvi_notifylist.h ../kernel/kvi_options.h ../kernel/kvi_out.h ../kernel/kvi_sslmaster.h \
-../kernel/kvi_texticonmanager.h ../sparser/kvi_antispam.h ../sparser/kvi_ircmessage.h \
+../kernel/kvi_notifylist.h \
+../kernel/kvi_options.h \
+../kernel/kvi_out.h \
+../kernel/kvi_sslmaster.h \
+../kernel/kvi_texticonmanager.h \
+../kernel/kvi_theme.h \
+../sparser/kvi_antispam.h \
+../sparser/kvi_ircmessage.h \
../kernel/kvi_useraction.h \
../kernel/kvi_userinput.h \
../kvs/kvi_kvs.h \
@@ -413,6 +426,7 @@ headers_HEADERS = ../kernel/kvi_action.h \
../ui/kvi_filedialog.h \
../ui/kvi_frame.h \
../ui/kvi_historywin.h \
+../ui/kvi_htmldialog.h \
../ui/kvi_imagedialog.h \
../ui/kvi_input.h \
../ui/kvi_ipeditor.h \
diff --git a/src/kvirc/kernel/kvi_app.h b/src/kvirc/kernel/kvi_app.h
index 76bbd9ea2..0f72956f7 100644
--- a/src/kvirc/kernel/kvi_app.h
+++ b/src/kvirc/kernel/kvi_app.h
@@ -67,19 +67,6 @@ typedef struct _KviPendingAvatarChange
QString szHost;
} KviPendingAvatarChange;
-typedef struct _KviThemeInfoTag
-{
- QString szName; // name of the theme
- QString szVersion; // version of the theme
- QString szSubdirectory; // subdirectory of $LOCALKVIRCDIR/themes where the theme is saved to
- QString szAbsoluteDirectory; // absolute directory where the theme should be saved to
- QString szAuthor; // author of the theme
- QString szDescription; // description of the theme
- QString szDate; // theme creation date
- QString szKvircVersion; // theme creation KVIrc version
- bool bIncludeMsgColors;
-} KviThemeInfo;
-
#ifdef Unsorted
#undef Unsorted
#endif
@@ -186,13 +173,6 @@ public:
void loadOptions();
void saveOptions();
- void saveTheme(KviThemeInfo &opt);
- void saveXmlTheme(KviThemeInfo &opt,const QString& filename);
- void loadXmlTheme(QDomElement *pElement);
- // returns false if the theme informations can't be loaded or the theme dir do not appear to contain a valid theme
- bool loadThemeInfo(const QString &themeDir,KviThemeInfo &inf);
- void loadTheme(const QString &themeDir);
-
void listAvailableOptions(KviWindow *wnd);
bool getOptionString(const char * optName,QString &buffer);
bool setOptionValue(const char * optName,const QString &value);
diff --git a/src/kvirc/kernel/kvi_options.cpp b/src/kvirc/kernel/kvi_options.cpp
index 67aef5263..b28815bdb 100644
--- a/src/kvirc/kernel/kvi_options.cpp
+++ b/src/kvirc/kernel/kvi_options.cpp
@@ -41,6 +41,7 @@
#include "kvi_splash.h"
#include "kvi_frame.h"
#include "kvi_internalcmd.h"
+#include "kvi_theme.h"
#include <qmessagebox.h>
#include <qregexp.h>
//#include "kvi_textencoding.h"
@@ -929,131 +930,6 @@ void KviApp::saveOptions()
#undef WRITE_OPTIONS
}
-/*
-void KviApp::loadThemeOptions(KviConfig * cfg)
-{
- int i;
-
- #define READ_OPTIONS(_num,_table,_readFnc) \
- for(i=0;i<_num;i++) \
- { \
- if(_table[i].flags & KviOption_groupTheme) \
- _table[i].option = cfg->_readFnc(_table[i].name,_table[i].option); \
- } \
-
- READ_OPTIONS(KVI_NUM_RECT_OPTIONS,g_rectOptionsTable,readRectEntry)
- READ_OPTIONS(KVI_NUM_BOOL_OPTIONS,g_boolOptionsTable,readBoolEntry)
- READ_OPTIONS(KVI_NUM_STRING_OPTIONS,g_stringOptionsTable,readEntry)
- READ_OPTIONS(KVI_NUM_COLOR_OPTIONS,g_colorOptionsTable,readColorEntry)
- READ_OPTIONS(KVI_NUM_PIXMAP_OPTIONS,g_pixmapOptionsTable,readPixmapEntry)
- READ_OPTIONS(KVI_NUM_UINT_OPTIONS,g_uintOptionsTable,readUIntEntry)
- READ_OPTIONS(KVI_NUM_FONT_OPTIONS,g_fontOptionsTable,readFontEntry)
- READ_OPTIONS(KVI_NUM_MSGTYPE_OPTIONS,g_msgtypeOptionsTable,readMsgTypeEntry)
- READ_OPTIONS(KVI_NUM_STRINGLIST_OPTIONS,g_stringlistOptionsTable,readStringListEntry)
- READ_OPTIONS(KVI_NUM_MIRCCOLOR_OPTIONS,g_mirccolorOptionsTable,readColorEntry)
- READ_OPTIONS(KVI_NUM_ICCOLOR_OPTIONS,g_iccolorOptionsTable,readColorEntry)
-
- #undef READ_OPTIONS
-}
-*/
-
-bool KviApp::loadThemeInfo(const QString &themeDir,KviThemeInfo &inf)
-{
- KviStr szD = themeDir;
- szD.append(KVI_PATH_SEPARATOR_CHAR);
- szD.append("themeinfo.kvc");
-
- if(!KviFileUtils::fileExists(szD.ptr()))return false;
-
- KviConfig cfg(szD.ptr(),KviConfig::Read);
-
- cfg.setGroup("ThemeInfo");
-
- inf.szAbsoluteDirectory = themeDir;
- inf.szName = cfg.readQStringEntry("Name","");
- inf.szVersion = cfg.readQStringEntry("Version","");
- inf.szAuthor = cfg.readQStringEntry("Author","");
- inf.szDescription = cfg.readQStringEntry("Description","");
- inf.szDate = cfg.readQStringEntry("Date","");
- inf.szKvircVersion = cfg.readQStringEntry("KvircVersion","");
-
- QString tmp = cfg.readQStringEntry("ThemeEngineVersion","");
-
- szD = themeDir;
- szD.append(KVI_PATH_SEPARATOR_CHAR);
- szD.append("themedata.kvc");
-
- if(!KviFileUtils::fileExists(szD.ptr()))return false;
-
- return !(inf.szName.isEmpty() || inf.szKvircVersion.isEmpty() || tmp.isEmpty());
-}
-
-#define XML_READ_ATTR(_tag,_buff) \
- list=pElement->elementsByTagName(_tag);\
- if(list.count()>0) \
- _buff=list.item(0).toElement().text();
-
-void KviApp::loadXmlTheme(QDomElement *pElement)
-{
- KviThemeInfo info;
- char * buf;
- QDomNodeList list;
- QFile file;
-
- info.szName=pElement->attribute("Name","Name");
- info.szVersion=pElement->attribute("Version","0.0.0");
-
- XML_READ_ATTR("Author",info.szAuthor);
- XML_READ_ATTR("Description",info.szDescription);
- XML_READ_ATTR("Date",info.szDate);
- XML_READ_ATTR("KvircVersion",info.szKvircVersion);
-
- info.szSubdirectory = info.szName + QString("-") + info.szVersion;
- info.szSubdirectory.replace(QRegExp("[ \\\\/:][ \\\\/:]*"),"_");
-
- getLocalKvircDirectory(info.szAbsoluteDirectory,KviApp::Themes,info.szSubdirectory,true);
- if(!KviFileUtils::makeDir(info.szAbsoluteDirectory))
- {
- QMessageBox::critical(0,__tr2qs("Load Theme - KVIrc"),__tr2qs("Unable to create theme directory."),
- QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
- return;
- }
- KviQString::ensureLastCharIs(info.szAbsoluteDirectory,KVI_PATH_SEPARATOR_CHAR);
-
- list=pElement->elementsByTagName("FileSystem");
- if(list.count()>0)
- {
- QDomElement element=list.item(0).toElement();
- for( QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling() )
- {
- if(n.nodeName()=="File" && n.isElement())
- {
- QDomElement tmp=n.toElement();
- QString szName=tmp.attribute("name");
- KviStr szValue=tmp.text();
-
- int len = szValue.base64ToBuffer(&buf);
- file.setName(info.szAbsoluteDirectory+QFileInfo(szName).fileName());
- if ( !file.open( IO_WriteOnly ) )
- break;
-
- file.writeBlock(buf,len);
- file.close();
- }
- }
- }
- KviConfig inf(info.szAbsoluteDirectory+"themeinfo.kvc",KviConfig::Write);
-
- inf.setGroup("ThemeInfo");
-
- inf.writeEntry("Version",info.szVersion);
- inf.writeEntry("Name",info.szName);
- inf.writeEntry("Author",info.szAuthor);
- inf.writeEntry("Description",info.szDescription);
- inf.writeEntry("Date",info.szDate);
- inf.writeEntry("KvircVersion",info.szKvircVersion);
- inf.writeEntry("ThemeEngineVersion","1.0.0");
-}
#undef WRITE_OPTIONS
@@ -1063,382 +939,251 @@ void KviApp::loadXmlTheme(QDomElement *pElement)
if(_table[i].flags & KviOption_groupTheme) \
cfg.writeEntry(_table[i].name,_table[i].option); \
}
-
-#define WRITE_MSGCOLORS_OPTIONS \
- if(opt.bIncludeMsgColors) \
- {\
- for(i=0;i<KVI_NUM_MSGTYPE_OPTIONS;i++) \
- { \
- cfg.writeEntry(g_msgtypeOptionsTable[i].name,g_msgtypeOptionsTable[i].option); \
- }\
- }
-
-#define SET_XML_THEME_OPTION(_option,_value) \
- option = doc.createElement( _option ); \
- cdata=doc.createTextNode(_value);\
- option.appendChild(cdata);\
- info.appendChild(option);\
-#define XML_APPEND_FILE(_name,_file) \
- reader.setName(_file); \
- if ( reader.open( IO_ReadOnly ) ) \
- { \
- data = reader.readAll(); \
- reader.close(); \
- decoder.bufferToBase64((char*)(data.data()),data.size()); \
- option = doc.createElement( "File" ); \
- option.setAttribute("name",(_name)); \
- cdata=doc.createTextNode(decoder.ptr()); \
- option.appendChild(cdata); \
- filesys.appendChild(option); \
- }
-void KviApp::saveXmlTheme(KviThemeInfo &opt,const QString& filename)
+namespace KviTheme
{
- // This function should be renamed to "Pack Theme"
- // and take a Directory as parameter instead of KviThemeInfo.
- // It should read the themeinfo file, add an apropriate header
- // to the xml and then append the whole (compressed?) directory
- // at the end.
-
- QDomDocument doc;
-
- //XML storing
- QDomElement info,root,option;
- QDomText cdata;
+ // utility functions for the KviTheme namespace (kvi_theme.h)
+ // that are implemented here for convenience (in saving the options)
+ bool save(KviThemeInfo &options)
+ {
+ QString szD = options.absoluteDirectory();
- //file storing;
- QFile reader;
- QByteArray data;
- KviStr decoder;
+ if(szD.isEmpty())
+ {
+ options.setLastError(__tr2qs("Missing absolute directory for the theme informations"));
+ return false;
+ }
- doc.appendChild(doc.createProcessingInstruction("xml","version=\"1.0\" encoding=\"UTF-8\""));
+ if(!KviFileUtils::directoryExists(szD))
+ {
+ if(!KviFileUtils::makeDir(szD))
+ {
+ options.setLastError(__tr2qs("Failed to create the theme directory"));
+ return false;
+ }
+ }
- root = doc.createElement( "Package" );
- doc.appendChild( root );
+ szD.append(KVI_PATH_SEPARATOR_CHAR);
+ szD.append(KVI_THEMEINFO_FILE_NAME);
- info = doc.createElement( "Theme" );
- root.appendChild( info );
- root=info;
+ if(!options.save(szD))
+ {
+ return false;
+ }
- info = doc.createElement( "ThemeInfo" );
- root.appendChild( info );
+ szD = options.absoluteDirectory();
+ szD.append(KVI_PATH_SEPARATOR_CHAR);
+ szD.append(KVI_THEMEDATA_FILE_NAME);
- root.appendChild( info );
- root.setAttribute("Name",opt.szName);
- root.setAttribute("Version",opt.szVersion);
-
- SET_XML_THEME_OPTION("Author",opt.szAuthor);
- SET_XML_THEME_OPTION("Description",opt.szDescription);
- SET_XML_THEME_OPTION("Date",opt.szDate);
- SET_XML_THEME_OPTION("KvircVersion",opt.szKvircVersion);
- SET_XML_THEME_OPTION("ThemeEngineVersion","1.0.0");
+ KviConfig cfg(szD,KviConfig::Write);
- QDomElement filesys = doc.createElement( "FileSystem" );
- root.appendChild( filesys );
+ cfg.setGroup(KVI_THEMEDATA_CONFIG_GROUP);
- QString szOptionsFile,szPixFile;
- getLocalKvircDirectory(szOptionsFile,Tmp,"themedata.kvc",TRUE);
- KviConfig cfg(szOptionsFile,KviConfig::Write);
+ int i;
- cfg.setGroup("ThemeData");
-
- int i;
-
- WRITE_OPTIONS(KVI_NUM_RECT_OPTIONS,g_rectOptionsTable)
- WRITE_OPTIONS(KVI_NUM_BOOL_OPTIONS,g_boolOptionsTable)
- WRITE_OPTIONS(KVI_NUM_STRING_OPTIONS,g_stringOptionsTable)
- WRITE_OPTIONS(KVI_NUM_COLOR_OPTIONS,g_colorOptionsTable)
- WRITE_OPTIONS(KVI_NUM_UINT_OPTIONS,g_uintOptionsTable)
- WRITE_OPTIONS(KVI_NUM_FONT_OPTIONS,g_fontOptionsTable)
- WRITE_MSGCOLORS_OPTIONS
- WRITE_OPTIONS(KVI_NUM_STRINGLIST_OPTIONS,g_stringlistOptionsTable)
- WRITE_OPTIONS(KVI_NUM_MIRCCOLOR_OPTIONS,g_mirccolorOptionsTable)
- WRITE_OPTIONS(KVI_NUM_ICCOLOR_OPTIONS,g_iccolorOptionsTable)
+ WRITE_OPTIONS(KVI_NUM_RECT_OPTIONS,g_rectOptionsTable)
+ WRITE_OPTIONS(KVI_NUM_BOOL_OPTIONS,g_boolOptionsTable)
+ WRITE_OPTIONS(KVI_NUM_STRING_OPTIONS,g_stringOptionsTable)
+ WRITE_OPTIONS(KVI_NUM_COLOR_OPTIONS,g_colorOptionsTable)
+ WRITE_OPTIONS(KVI_NUM_UINT_OPTIONS,g_uintOptionsTable)
+ WRITE_OPTIONS(KVI_NUM_FONT_OPTIONS,g_fontOptionsTable)
+ WRITE_OPTIONS(KVI_NUM_MSGTYPE_OPTIONS,g_msgtypeOptionsTable)
+ WRITE_OPTIONS(KVI_NUM_STRINGLIST_OPTIONS,g_stringlistOptionsTable)
+ WRITE_OPTIONS(KVI_NUM_MIRCCOLOR_OPTIONS,g_mirccolorOptionsTable)
+ WRITE_OPTIONS(KVI_NUM_ICCOLOR_OPTIONS,g_iccolorOptionsTable)
- for(i=0;i<KVI_NUM_PIXMAP_OPTIONS;i++)
- {
- if(g_pixmapOptionsTable[i].flags & KviOption_groupTheme)
+ #undef WRITE_OPTIONS
+
+ // the pixmap options need special processing
+ for(i=0;i<KVI_NUM_PIXMAP_OPTIONS;i++)
{
- if(g_pixmapOptionsTable[i].option.pixmap())
+ if(g_pixmapOptionsTable[i].flags & KviOption_groupTheme)
{
- QString szPixName = g_pixmapOptionsTable[i].name;
- szPixName += ".png";
- getLocalKvircDirectory(szPixFile,Tmp,szPixName,TRUE);
-
- if(g_pixmapOptionsTable[i].option.pixmap()->save(szPixFile,"PNG"))
+ if(g_pixmapOptionsTable[i].option.pixmap())
{
- cfg.writeEntry(g_pixmapOptionsTable[i].name,szPixName);
-
- XML_APPEND_FILE(szPixName,szPixFile);
- KviFileUtils::removeFile(szPixFile);
-
+ QString szPixPath = options.absoluteDirectory();
+ szPixPath.append(KVI_PATH_SEPARATOR_CHAR);
+ QString szPixName = g_pixmapOptionsTable[i].name;
+ szPixName += ".png";
+ szPixPath += szPixName;
+
+ if(g_pixmapOptionsTable[i].option.pixmap()->save(szPixPath,"PNG"))
+ {
+ cfg.writeEntry(g_pixmapOptionsTable[i].name,szPixName);
+ } else {
+ // we ignore this error for now
+ debug("failed to save %s",szPixPath.utf8().data());
+ cfg.writeEntry(g_pixmapOptionsTable[i].name,"");
+ }
} else {
- debug("failed to save %s",szPixFile.utf8().data());
cfg.writeEntry(g_pixmapOptionsTable[i].name,"");
}
- } else {
- cfg.writeEntry(g_pixmapOptionsTable[i].name,"");
}
}
- }
- QString szPixPath=KVI_OPTION_STRING(KviOption_stringIconThemeSubdir);
- QString szMainPicsPath;
-
- g_pApp->getGlobalKvircDirectory(szMainPicsPath,KviApp::Pics);
-
- QDir d(szMainPicsPath);
- // note that now the small icons are in the coresmall subdirectory (and in the theme must end there too)
- QStringList sl = d.entryList("kvi_bigicon_*.png",QDir::Files)+d.entryList("kvi_smallicon_*.png",QDir::Files);
-
- for(QStringList::Iterator it=sl.begin();it != sl.end();it++)
- {
- KviCachedPixmap * p = g_pIconManager->getPixmapWithCache(*it);
- if(p)
- {
- if(p->path().find(szMainPicsPath)!=0)
- XML_APPEND_FILE(*it,p->path());
- }
- }
-
- cfg.writeEntry("stringIconThemeSubdir",opt.szSubdirectory);
- cfg.sync();
+ cfg.writeEntry("stringIconThemeSubdir",options.subdirectory());
+ // find all the "kvi_bigicon" images that we can find in the main pics directory
+ QString szPicsPath;
- XML_APPEND_FILE("themedata.kvc",szOptionsFile);
- KviFileUtils::removeFile(szOptionsFile);
+ g_pApp->getGlobalKvircDirectory(szPicsPath,KviApp::Pics);
+ QDir d(szPicsPath);
+ QStringList sl = d.entryList("kvi_bigicon_*.png",QDir::Files);
- QString xml = doc.toString(5);
-
- gzFile file=gzopen(QTextCodec::codecForLocale()->fromUnicode(filename).data(),"wb9");
- if(file)
- {
- gzwrite(file,xml.utf8().data(),xml.utf8().length());
- gzclose(file);
- }
-}
-#undef SET_XML_THEME_OPTION
-#undef XML_APPEND_FILE
-
-void KviApp::saveTheme(KviThemeInfo &opt)
-{
- QString szD = opt.szAbsoluteDirectory;
-
- KviFileUtils::makeDir(szD);
-
- szD.append(KVI_PATH_SEPARATOR_CHAR);
- szD.append("themeinfo.kvc");
-
- KviConfig inf(szD,KviConfig::Write);
-
- inf.clear();
-
- inf.setGroup("ThemeInfo");
-
- inf.writeEntry("Version",opt.szVersion);
- inf.writeEntry("Name",opt.szName);
- inf.writeEntry("Author",opt.szAuthor);
- inf.writeEntry("Description",opt.szDescription);
- inf.writeEntry("Date",opt.szDate);
- inf.writeEntry("KvircVersion",opt.szKvircVersion);
- inf.writeEntry("ThemeEngineVersion","1.0.0");
-
-
- szD = opt.szAbsoluteDirectory;
- szD.append(KVI_PATH_SEPARATOR_CHAR);
- szD.append("themedata.kvc");
-
- KviConfig cfg(szD,KviConfig::Write);
-
- cfg.setGroup("ThemeData");
-
- int i;
-
- WRITE_OPTIONS(KVI_NUM_RECT_OPTIONS,g_rectOptionsTable)
- WRITE_OPTIONS(KVI_NUM_BOOL_OPTIONS,g_boolOptionsTable)
- WRITE_OPTIONS(KVI_NUM_STRING_OPTIONS,g_stringOptionsTable)
- WRITE_OPTIONS(KVI_NUM_COLOR_OPTIONS,g_colorOptionsTable)
- WRITE_OPTIONS(KVI_NUM_UINT_OPTIONS,g_uintOptionsTable)
- WRITE_OPTIONS(KVI_NUM_FONT_OPTIONS,g_fontOptionsTable)
- WRITE_MSGCOLORS_OPTIONS
- WRITE_OPTIONS(KVI_NUM_STRINGLIST_OPTIONS,g_stringlistOptionsTable)
- WRITE_OPTIONS(KVI_NUM_MIRCCOLOR_OPTIONS,g_mirccolorOptionsTable)
- WRITE_OPTIONS(KVI_NUM_ICCOLOR_OPTIONS,g_iccolorOptionsTable)
-
- #undef WRITE_OPTIONS
-
- // the pixmap options need special processing
- for(i=0;i<KVI_NUM_PIXMAP_OPTIONS;i++)
- {
- if(g_pixmapOptionsTable[i].flags & KviOption_groupTheme)
+ for(QStringList::Iterator it=sl.begin();it != sl.end();it++)
{
- if(g_pixmapOptionsTable[i].option.pixmap())
+ KviCachedPixmap * p = g_pIconManager->getPixmapWithCache(*it);
+ if(p)
{
- QString szPixPath = opt.szAbsoluteDirectory;
+ QString szPixPath = options.absoluteDirectory();
szPixPath.append(KVI_PATH_SEPARATOR_CHAR);
- QString szPixName = g_pixmapOptionsTable[i].name;
- szPixName += ".png";
- szPixPath += szPixName;
-
- if(g_pixmapOptionsTable[i].option.pixmap()->save(szPixPath,"PNG"))
+ szPixPath += *it;
+
+ if(!KviFileUtils::copyFile(p->path(),szPixPath))
{
- cfg.writeEntry(g_pixmapOptionsTable[i].name,szPixName);
- } else {
- debug("failed to save %s",szPixPath.utf8().data());
- cfg.writeEntry(g_pixmapOptionsTable[i].name,"");
+ options.setLastError(__tr2qs("Failed to save one of the theme images"));
+ return false;
}
- } else {
- cfg.writeEntry(g_pixmapOptionsTable[i].name,"");
}
}
- }
-
- cfg.writeEntry("stringIconThemeSubdir",opt.szSubdirectory);
-
- // find all the "kvi_bigicon" images that we can find in the main pics directory
- QString szPicsPath;
-
- g_pApp->getGlobalKvircDirectory(szPicsPath,KviApp::Pics);
- QDir d(szPicsPath);
- QStringList sl = d.entryList("kvi_bigicon_*.png",QDir::Files);
- //QStringList sl2 = d.entryList("kvi_smallicon_*.png",QDir::Files);
-
- for(QStringList::Iterator it=sl.begin();it != sl.end();it++)
- {
- KviCachedPixmap * p = g_pIconManager->getPixmapWithCache(*it);
- if(p)
+
+
+ szD = options.absoluteDirectory();
+ szD.append(KVI_PATH_SEPARATOR_CHAR);
+ szD.append(KVI_SMALLICONS_SUBDIRECTORY);
+
+ if(!KviFileUtils::makeDir(szD))
{
- QString szPixPath = opt.szAbsoluteDirectory;
+ options.setLastError(__tr2qs("Failed to create the theme subdirectory"));
+ return false;
+ }
+
+ // We actually need to *save* the small icons since
+ // we have a compatibility mode that can load them from
+ // the old format kvi_smallicon_XY.png multiimage libraries.
+
+ for(int j=0;j<KVI_NUM_SMALL_ICONS;j++)
+ {
+ QPixmap * pix = g_pIconManager->getSmallIcon(j);
+
+ QString szPixPath = options.absoluteDirectory();
szPixPath.append(KVI_PATH_SEPARATOR_CHAR);
- szPixPath += *it;
-
- KviFileUtils::copyFile(p->path(),szPixPath);
+ szPixPath.append(KVI_SMALLICONS_SUBDIRECTORY);
+ szPixPath.append(KVI_PATH_SEPARATOR_CHAR);
+ szPixPath.append("kcs_");
+ szPixPath.append(g_pIconManager->getSmallIconName(j));
+ szPixPath.append(".png");
+
+ if(!pix->save(szPixPath,"PNG",90))
+ {
+ options.setLastError(__tr2qs("Failed to save one of the theme images"));
+ return false;
+ }
}
+
+ return true;
}
-
-
- szD = opt.szAbsoluteDirectory;
- szD.append(KVI_PATH_SEPARATOR_CHAR);
- szD.append(KVI_SMALLICONS_SUBDIRECTORY);
-
- KviFileUtils::makeDir(szD);
-
- // We actually need to *save* the small icons since
- // we have a compatibility mode that can load them from
- // the old format kvi_smallicon_XY.png multiimage libraries.
-
- for(int j=0;j<KVI_NUM_SMALL_ICONS;j++)
+
+ bool load(const QString &themeDir,KviThemeInfo &buffer)
{
- QPixmap * pix = g_pIconManager->getSmallIcon(j);
-
- QString szPixPath = opt.szAbsoluteDirectory;
- szPixPath.append(KVI_PATH_SEPARATOR_CHAR);
- szPixPath.append(KVI_SMALLICONS_SUBDIRECTORY);
- szPixPath.append(KVI_PATH_SEPARATOR_CHAR);
- szPixPath.append("kcs_");
- szPixPath.append(g_pIconManager->getSmallIconName(j));
- szPixPath.append(".png");
+ if(!buffer.loadFromDirectory(themeDir))
+ return false; // makes sure that themedata exists too
+
+ // reset the current theme subdir
+ KVI_OPTION_STRING(KviOption_stringIconThemeSubdir) = "";
- pix->save(szPixPath,"PNG",90);
- }
+ // reset the splash screen pointer
+ QString szPointerFile;
+ g_pApp->getLocalKvircDirectory(szPointerFile,KviApp::Themes,"current-splash");
+ KviFileUtils::removeFile(szPointerFile);
-}
-
-void KviApp::loadTheme(const QString &themeDir)
-{
- // reset the current theme subdir
- KVI_OPTION_STRING(KviOption_stringIconThemeSubdir) = "";
+ QString szD = themeDir;
+ KviQString::ensureLastCharIs(szD,KVI_PATH_SEPARATOR_CHAR);
+ szD.append(KVI_THEMEDATA_FILE_NAME);
- // reset the splash screen pointer
- QString szPointerFile;
- getLocalKvircDirectory(szPointerFile,Themes,"current-splash");
- KviFileUtils::removeFile(szPointerFile);
-
-
- QString szD = themeDir;
- KviQString::ensureLastCharIs(szD,KVI_PATH_SEPARATOR_CHAR);
- szD.append("themedata.kvc");
-
- KviConfig cfg(szD,KviConfig::Read);
-
- cfg.setGroup("ThemeData");
-
- int i;
- int iResetFlags = 0;
-
- #undef READ_OPTIONS
-
- #define READ_OPTIONS(_num,_table,_readFnc) \
- for(i=0;i<_num;i++) \
- { \
- if(_table[i].flags & KviOption_groupTheme) \
+ KviConfig cfg(szD,KviConfig::Read);
+
+ cfg.setGroup(KVI_THEMEDATA_CONFIG_GROUP);
+
+ int i;
+ int iResetFlags = 0;
+
+ #undef READ_OPTIONS
+
+ #define READ_OPTIONS(_num,_table,_readFnc) \
+ for(i=0;i<_num;i++) \
+ { \
+ if(_table[i].flags & KviOption_groupTheme) \
+ { \
+ if(cfg.hasKey(_table[i].name)) \
+ { \
+ iResetFlags |= (_table[i].flags & KviOption_resetMask); \
+ _table[i].option = cfg._readFnc(_table[i].name,_table[i].option); \
+ } \
+ } \
+ }
+
+ #define READ_ALL_OPTIONS(_num,_table,_readFnc) \
+ for(i=0;i<_num;i++) \
{ \
if(cfg.hasKey(_table[i].name)) \
{ \
iResetFlags |= (_table[i].flags & KviOption_resetMask); \
_table[i].option = cfg._readFnc(_table[i].name,_table[i].option); \
} \
- } \
- }
+ }
- #define READ_ALL_OPTIONS(_num,_table,_readFnc) \
- for(i=0;i<_num;i++) \
- { \
- if(cfg.hasKey(_table[i].name)) \
- { \
- iResetFlags |= (_table[i].flags & KviOption_resetMask); \
- _table[i].option = cfg._readFnc(_table[i].name,_table[i].option); \
- } \
- }
-
- READ_OPTIONS(KVI_NUM_RECT_OPTIONS,g_rectOptionsTable,readRectEntry)
- READ_OPTIONS(KVI_NUM_BOOL_OPTIONS,g_boolOptionsTable,readBoolEntry)
- READ_OPTIONS(KVI_NUM_STRING_OPTIONS,g_stringOptionsTable,readQStringEntry)
- READ_OPTIONS(KVI_NUM_COLOR_OPTIONS,g_colorOptionsTable,readColorEntry)
- READ_OPTIONS(KVI_NUM_UINT_OPTIONS,g_uintOptionsTable,readUIntEntry)
- READ_OPTIONS(KVI_NUM_FONT_OPTIONS,g_fontOptionsTable,readFontEntry)
- READ_ALL_OPTIONS(KVI_NUM_MSGTYPE_OPTIONS,g_msgtypeOptionsTable,readMsgTypeEntry)
- READ_OPTIONS(KVI_NUM_STRINGLIST_OPTIONS,g_stringlistOptionsTable,readStringListEntry)
- READ_OPTIONS(KVI_NUM_MIRCCOLOR_OPTIONS,g_mirccolorOptionsTable,readColorEntry)
- READ_OPTIONS(KVI_NUM_ICCOLOR_OPTIONS,g_iccolorOptionsTable,readColorEntry)
-
- #undef READ_OPTIONS
- #undef READ_ALL_OPTIONS
- KVI_OPTION_STRING(KviOption_stringIconThemeSubdir).stripWhiteSpace();
-
-
- // the pixmap options need special processing
- for(i=0;i<KVI_NUM_PIXMAP_OPTIONS;i++)
- {
- if(g_pixmapOptionsTable[i].flags & KviOption_groupTheme)
+ READ_OPTIONS(KVI_NUM_RECT_OPTIONS,g_rectOptionsTable,readRectEntry)
+ READ_OPTIONS(KVI_NUM_BOOL_OPTIONS,g_boolOptionsTable,readBoolEntry)
+ READ_OPTIONS(KVI_NUM_STRING_OPTIONS,g_stringOptionsTable,readQStringEntry)
+ READ_OPTIONS(KVI_NUM_COLOR_OPTIONS,g_colorOptionsTable,readColorEntry)
+ READ_OPTIONS(KVI_NUM_UINT_OPTIONS,g_uintOptionsTable,readUIntEntry)
+ READ_OPTIONS(KVI_NUM_FONT_OPTIONS,g_fontOptionsTable,readFontEntry)
+ READ_ALL_OPTIONS(KVI_NUM_MSGTYPE_OPTIONS,g_msgtypeOptionsTable,readMsgTypeEntry)
+ READ_OPTIONS(KVI_NUM_STRINGLIST_OPTIONS,g_stringlistOptionsTable,readStringListEntry)
+ READ_OPTIONS(KVI_NUM_MIRCCOLOR_OPTIONS,g_mirccolorOptionsTable,readColorEntry)
+ READ_OPTIONS(KVI_NUM_ICCOLOR_OPTIONS,g_iccolorOptionsTable,readColorEntry)
+
+ #undef READ_OPTIONS
+ #undef READ_ALL_OPTIONS
+ KVI_OPTION_STRING(KviOption_stringIconThemeSubdir).stripWhiteSpace();
+
+
+ // the pixmap options need special processing
+ for(i=0;i<KVI_NUM_PIXMAP_OPTIONS;i++)
{
- if(cfg.hasKey(g_pixmapOptionsTable[i].name))
+ if(g_pixmapOptionsTable[i].flags & KviOption_groupTheme)
{
- QString szVal = cfg.readQStringEntry(g_pixmapOptionsTable[i].name,"");
- szVal.stripWhiteSpace();
- QString szBuffer;
- if(!szVal.isEmpty())
+ if(cfg.hasKey(g_pixmapOptionsTable[i].name))
{
- findImage(szBuffer,szVal);
- } else {
- szBuffer = szVal;
+ QString szVal = cfg.readQStringEntry(g_pixmapOptionsTable[i].name,"");
+ szVal.stripWhiteSpace();
+ QString szBuffer;
+ if(!szVal.isEmpty())
+ {
+ g_pApp->findImage(szBuffer,szVal);
+ } else {
+ szBuffer = szVal;
+ }
+
+ KviStringConversion::fromString(szBuffer,g_pixmapOptionsTable[i].option);
+
+ // reset anyway
+ iResetFlags |= g_pixmapOptionsTable[i].flags & KviOption_resetMask;
}
-
- KviStringConversion::fromString(szBuffer,g_pixmapOptionsTable[i].option);
-
- // reset anyway
- iResetFlags |= g_pixmapOptionsTable[i].flags & KviOption_resetMask;
}
}
- }
-
- // create the splash screen pointer if this theme has some pixmaps in it
- if(!KVI_OPTION_STRING(KviOption_stringIconThemeSubdir).isEmpty())
- KviFileUtils::writeFile(szPointerFile,KVI_OPTION_STRING(KviOption_stringIconThemeSubdir));
+
+ // create the splash screen pointer if this theme has some pixmaps in it
+ if(!KVI_OPTION_STRING(KviOption_stringIconThemeSubdir).isEmpty())
+ KviFileUtils::writeFile(szPointerFile,KVI_OPTION_STRING(KviOption_stringIconThemeSubdir));
+
+ // force reloading of images anyway
+ g_pApp->optionResetUpdate(iResetFlags | KviOption_resetReloadImages);
- // force reloading of images anyway
- optionResetUpdate(iResetFlags | KviOption_resetReloadImages);
-}
+ return true;
+ }
+};
void KviApp::listAvailableOptions(KviWindow *wnd)
{
diff --git a/src/kvirc/kernel/kvi_theme.cpp b/src/kvirc/kernel/kvi_theme.cpp
new file mode 100644
index 000000000..7823a1b85
--- /dev/null
+++ b/src/kvirc/kernel/kvi_theme.cpp
@@ -0,0 +1,159 @@
+//=============================================================================
+//
+// File : kvi_themeinfo.cpp
+// 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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//=============================================================================
+
+#define __KVIRC__
+#include "kvi_theme.h"
+#include "kvi_fileutils.h"
+#include "kvi_config.h"
+#include "kvi_locale.h"
+#include "kvi_miscutils.h"
+#include "kvi_sourcesdate.h"
+
+// increment only when there are INCOMPATIBLE changes in the file format (should never happen)
+#define CURRENT_THEMEINFO_FILE_VERSION "1.0.0"
+
+
+KviThemeInfo::KviThemeInfo()
+: KviHeapObject()
+{
+}
+
+KviThemeInfo::~KviThemeInfo()
+{
+}
+
+
+
+bool KviThemeInfo::load(const QString &szThemeFileName)
+{
+ if(!KviFileUtils::fileExists(szThemeFileName))
+ {
+ m_szLastError = __tr2qs("The theme information file does not exist");
+ return false;
+ }
+
+ KviConfig cfg(szThemeFileName,KviConfig::Read);
+
+ cfg.setGroup(KVI_THEMEINFO_CONFIG_GROUP);
+
+ QString tmp = cfg.readQStringEntry("ThemeInfoFileVersion",CURRENT_THEMEINFO_FILE_VERSION);
+ if(KviMiscUtils::compareVersions(tmp,CURRENT_THEMEINFO_FILE_VERSION) < 0)
+ return false; // incompatible ThemeInfoFileVersion
+
+ // mandatory fields
+ m_szName = cfg.readQStringEntry("Name","");
+
+ if(m_szName.isEmpty())
+ {
+ m_szLastError = __tr2qs("Theme information file is not valid");
+ return false;
+ }
+
+ // optional fields
+ m_szVersion = cfg.readQStringEntry("Version","");
+ if(m_szVersion.isEmpty())
+ m_szVersion = "?.?.?";
+ m_szAuthor = cfg.readQStringEntry("Author","");
+ QString szUnknown = __tr2qs("Unknown");
+ if(m_szAuthor.isEmpty())
+ m_szAuthor = szUnknown;
+ m_szDescription = cfg.readQStringEntry("Description","");
+ m_szDate = cfg.readQStringEntry("Date","");
+ if(m_szDate.isEmpty())
+ m_szDate = szUnknown;
+ m_szApplication = cfg.readQStringEntry("Application","");
+ if(m_szApplication.isEmpty())
+ m_szApplication = szUnknown;
+
+ m_szMinimumKVIrcVersion = cfg.readQStringEntry("MinimumKVIrcVersion","3.0.0");
+ // if present, must be verified
+
+ if(!m_szMinimumKVIrcVersion.isEmpty())
+ {
+ if(KviMiscUtils::compareVersions(m_szMinimumKVIrcVersion,KVI_VERSION "." KVI_SOURCES_DATE) < 0)
+ {
+ KviQString::sprintf(m_szLastError,__tr2qs("This KVIrc executable is too old for this theme (minimum version required is %Q)"),&m_szMinimumKVIrcVersion);
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool KviThemeInfo::save(const QString &szThemeFileName)
+{
+ KviConfig inf(szThemeFileName,KviConfig::Write);
+
+ inf.clear();
+
+ inf.setGroup(KVI_THEMEINFO_CONFIG_GROUP);
+
+ inf.writeEntry("Name",m_szName);
+ inf.writeEntry("Version",m_szVersion);
+ inf.writeEntry("Author",m_szAuthor);
+ inf.writeEntry("Description",m_szDescription);
+ inf.writeEntry("Date",m_szDate);
+
+ if(!m_szMinimumKVIrcVersion.isEmpty())
+ {
+ if(
+ (!KviMiscUtils::isValidVersionString(m_szMinimumKVIrcVersion))
+ ||
+ (KviMiscUtils::compareVersions(m_szMinimumKVIrcVersion,KVI_VERSION "." KVI_SOURCES_DATE) < 0)
+ )
+ {
+ m_szLastError = __tr2qs("The specified minimum KVIrc version is not valid");
+ return false;
+ }
+ }
+
+ inf.writeEntry("MinimumKVIrcVersion",m_szMinimumKVIrcVersion);
+ inf.writeEntry("ThemeInfoFileVersion",CURRENT_THEMEINFO_FILE_VERSION);
+ inf.writeEntry("Application","KVIrc " KVI_VERSION "." KVI_SOURCES_DATE);
+
+ return true;
+}
+
+bool KviThemeInfo::loadFromDirectory(const QString &szThemeDirectory,bool bIgnoreThemeData)
+{
+ QString szD = szThemeDirectory;
+ szD.append(KVI_PATH_SEPARATOR_CHAR);
+ szD.append(KVI_THEMEINFO_FILE_NAME);
+
+ if(!load(szD))
+ return false; // loading failed for some reason
+
+ m_szAbsoluteDirectory = szThemeDirectory;
+
+ if(bIgnoreThemeData)
+ return true; // assume success
+
+ // check if themedata file exists
+ szD = szThemeDirectory;
+ szD.append(KVI_PATH_SEPARATOR_CHAR);
+ szD.append(KVI_THEMEDATA_FILE_NAME);
+
+ return KviFileUtils::fileExists(szD);
+}
+
diff --git a/src/kvirc/kernel/kvi_theme.h b/src/kvirc/kernel/kvi_theme.h
new file mode 100644
index 000000000..3bf15a3bc
--- /dev/null
+++ b/src/kvirc/kernel/kvi_theme.h
@@ -0,0 +1,109 @@
+#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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//=============================================================================
+
+#include "kvi_settings.h"
+#include "kvi_qstring.h"
+#include "kvi_heapobject.h"
+
+#include "kvi_fileextensions.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"
+
+class KVIRC_API KviThemeInfo : public KviHeapObject
+{
+public:
+ KviThemeInfo();
+ ~KviThemeInfo();
+protected:
+ QString m_szName; // name of the theme
+ QString m_szVersion; // version of the theme
+ QString m_szSubdirectory; // subdirectory of $LOCALKVIRCDIR/themes where the theme is saved to (not always used)
+ QString m_szAbsoluteDirectory; // absolute directory where the theme should be saved to (or is loaded from)
+ QString m_szAuthor; // author of the theme
+ QString m_szDescription; // description of the theme
+ QString m_szDate; // theme creation date
+ QString m_szApplication; // theme creation (KVIrc) version
+ QString m_szMinimumKVIrcVersion; // minimum KVIrc version for this theme to work
+
+ QString m_szLastError; // reported when some function fails
+public:
+ // load a specified themeinfo file
+ bool load(const QString &szThemeFileName);
+ // save the currently defined themeinfo in the specified file
+ bool save(const QString &szThemeFileName);
+
+ const QString & lastError(){ return m_szLastError; };
+ void setLastError(const QString &szLastError){ m_szLastError = szLastError; };
+ const QString & name(){ return m_szName; };
+ void setName(const QString &szName){ m_szName = szName; };
+ const QString & version(){ return m_szVersion; };
+ void setVersion(const QString &szVersion){ m_szVersion = szVersion; };
+ const QString & subdirectory(){ return m_szSubdirectory; };
+ void setSubdirectory(const QString &szSubdirectory){ m_szSubdirectory = szSubdirectory; };
+ const QString & absoluteDirectory(){ return m_szAbsoluteDirectory; };
+ void setAbsoluteDirectory(const QString &szAbsoluteDirectory){ m_szAbsoluteDirectory = szAbsoluteDirectory; }
+ const QString & author(){ return m_szAuthor; };
+ void setAuthor(const QString &szAuthor){ m_szAuthor = szAuthor; };
+ const QString & description(){ return m_szDescription; };
+ void setDescription(const QString &szDescription){ m_szDescription = szDescription; };
+ const QString & date(){ return m_szDate; };
+ void setDate(const QString &szDate){ m_szDate = szDate; };
+ const QString & application(){ return m_szApplication; };
+ void setApplication(const QString &szApplication){ m_szApplication = szApplication; };
+ const QString & minimumKVIrcVersion(){ return m_szMinimumKVIrcVersion; };
+ void setMinimumKVIrcVersion(const QString &szMinimumKVIrcVersion){ m_szMinimumKVIrcVersion = szMinimumKVIrcVersion; };
+
+ // Attempt to load a themeinfo file present in the specified directory
+ // This function will fail if the directory contains a valid themeinfo
+ // file but no themedata file unless bIgnoreThemeData is set to true
+ bool loadFromDirectory(const QString &szThemeDirectory,bool bIgnoreThemeData = false);
+};
+
+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 QString &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);
+};
+
+
+#endif //_KVI_THEME_H_
diff --git a/src/kvirc/kvs/kvi_kvs_corefunctions_af.cpp b/src/kvirc/kvs/kvi_kvs_corefunctions_af.cpp
index eb97b5d4c..919731624 100644
--- a/src/kvirc/kvs/kvi_kvs_corefunctions_af.cpp
+++ b/src/kvirc/kvs/kvi_kvs_corefunctions_af.cpp
@@ -674,7 +674,7 @@ namespace KviKvsCoreFunctions
$context[(<server>,<nickname>)]
@description:
Returns the [b]IRC context ID[/b] of the IRC context that uses
- the specified <server> and <nickname>.[br] This function can
+ the specified <server> and local user's <nickname>.[br] This function can
find only connected IRC contexts.
If no context matches the server and nickname, and invalid
[b]IRC context ID[/b] is returned (0).[br]
diff --git a/src/kvirc/kvs/kvi_kvs_scriptaddonmanager.cpp b/src/kvirc/kvs/kvi_kvs_scriptaddonmanager.cpp
index a83b94979..5c1ed92fa 100644
--- a/src/kvirc/kvs/kvi_kvs_scriptaddonmanager.cpp
+++ b/src/kvirc/kvs/kvi_kvs_scriptaddonmanager.cpp
@@ -338,50 +338,8 @@ QDict<KviKvsScriptAddon> * KviKvsScriptAddonManager::addonDict()
}
-bool KviKvsScriptAddonManager::isValidVersionString(const QString &szVersion)
-{
- QStringList sl = QStringList::split(".",szVersion);
- if(sl.isEmpty())return false;
- // must all be numbers
- for(QStringList::Iterator it = sl.begin();it != sl.end();++it)
- {
- bool bOk;
- int i = (*it).toInt(&bOk);
- if(!bOk)return false;
- if(i < 0)return false;
- }
- return true;
-}
-int KviKvsScriptAddonManager::compareVersions(const QString &szVersion1,const QString &szVersion2)
-{
- QStringList sl1 = QStringList::split(".",szVersion1);
- QStringList sl2 = QStringList::split(".",szVersion2);
- QStringList::Iterator it1 = sl1.begin();
- QStringList::Iterator it2 = sl2.begin();
- while((it1 != sl1.end()) && (it2 != sl2.end()))
- {
- bool bOk;
- int i1 = (*it1).toInt(&bOk);
- if(!bOk)return 1;
- int i2 = (*it2).toInt(&bOk);
- if(!bOk)return -1;
- if(i1 != i2)
- {
- // field not equal
- if(i1 > i2)return -1;
- else return 1;
- }
- it1++;
- it2++;
- }
- // both are equal until now
- if(it1 != sl1.end())return -1; // 1 has at least one field more
- if(it2 != sl2.end())return 1; // 2 has at least one field more
- // both are equal also in length
- return 0;
-}
bool KviKvsScriptAddonManager::registerAddon(KviKvsScriptAddonRegistrationData * d)
{
diff --git a/src/kvirc/kvs/kvi_kvs_scriptaddonmanager.h b/src/kvirc/kvs/kvi_kvs_scriptaddonmanager.h
index b57bfebf1..6f50fcadb 100644
--- a/src/kvirc/kvs/kvi_kvs_scriptaddonmanager.h
+++ b/src/kvirc/kvs/kvi_kvs_scriptaddonmanager.h
@@ -114,9 +114,6 @@ public:
static void init(); // called by KviKvs::init()
static void done(); // called by KviKvs::done()
- bool isValidVersionString(const QString &szVersion);
- // returns x < 0 if szVersion1 is greater, x = 0 if the versions are equal and x > 0 otherwise
- int compareVersions(const QString &szVersion1,const QString &szVersion2);
bool registerAddon(KviKvsScriptAddonRegistrationData * d);
KviKvsScriptAddon * findAddon(const QString &szName);
bool unregisterAddon(const QString &szName,KviWindow * pWnd,bool bExecuteUninstallCallback = true);
diff --git a/src/kvirc/ui/kvi_htmldialog.cpp b/src/kvirc/ui/kvi_htmldialog.cpp
new file mode 100644
index 000000000..d9006458d
--- /dev/null
+++ b/src/kvirc/ui/kvi_htmldialog.cpp
@@ -0,0 +1,152 @@
+//=============================================================================
+//
+// File : kvi_htmldialog.cpp
+// Created on Wed 03 Jan 2007 03:36:36 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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//=============================================================================
+
+#include "kvi_htmldialog.h"
+#include "kvi_locale.h"
+
+#include <qlabel.h>
+#include <qtextbrowser.h>
+#include <qpushbutton.h>
+#include <qlayout.h>
+
+KviHtmlDialog::KviHtmlDialog(QWidget * pParent,KviHtmlDialogData * pData)
+: QDialog(pParent)
+{
+ m_pData = pData;
+
+ if(pData->szCaption.isEmpty())
+ setCaption("KVIrc");
+ else
+ setCaption(pData->szCaption);
+
+ if(!pData->pixIcon.isNull())
+ setIcon(pData->pixIcon);
+
+ QGridLayout * g = new QGridLayout(this,4,3,7,7);
+
+ QLabel * l;
+ QTextEdit * te;
+ QPushButton * pb;
+
+ int iUp = 0;
+ int iDown = 2;
+
+ if(!pData->szUpperLabelText.isEmpty())
+ {
+ l = new QLabel(this);
+ l->setText(pData->szUpperLabelText);
+ g->addMultiCellWidget(l,0,0,0,2);
+ iUp = 1;
+ }
+
+ if(!pData->szLowerLabelText.isEmpty())
+ {
+ l = new QLabel(this);
+ l->setText(pData->szLowerLabelText);
+ g->addMultiCellWidget(l,2,2,0,2);
+ iDown = 1;
+ }
+
+ te = new QTextBrowser(this);
+ te->setText(pData->szHtmlText);
+
+ if(pData->iFlags & KviHtmlDialogData::ForceMinimumSize)
+ te->setMinimumSize(pData->iMinimumWidth,pData->iMinimumHeight);
+
+ //te->setReadOnly(true);
+ g->addMultiCellWidget(te,iUp,iDown,0,2);
+
+ int iButtons = pData->szButton3Text.isEmpty() ? (pData->szButton2Text.isEmpty() ? 1 : 2) : 3;
+ if(pData->iCancelButton > iButtons)pData->iCancelButton = iButtons;
+ if(pData->iDefaultButton > iButtons)pData->iDefaultButton = iButtons;
+
+ pb = new QPushButton(this);
+ pb->setText(pData->szButton1Text.isEmpty() ? __tr2qs("OK") : pData->szButton1Text);
+ pb->setDefault(pData->iDefaultButton == 1);
+ int iCoord = iButtons == 1 ? 1 : 0;
+ g->addWidget(pb,3,iCoord);
+ connect(pb,SIGNAL(clicked()),this,SLOT(button1Pressed()));
+
+ if(!pData->szButton2Text.isEmpty())
+ {
+ pb = new QPushButton(this);
+ pb->setText(pData->szButton2Text);
+ pb->setDefault(pData->iDefaultButton == 2);
+ iCoord = iButtons == 2 ? 2 : 1;
+ g->addWidget(pb,3,iCoord);
+ connect(pb,SIGNAL(clicked()),this,SLOT(button2Pressed()));
+
+ if(!pData->szButton3Text.isEmpty())
+ {
+ pb = new QPushButton(this);
+ pb->setText(pData->szButton3Text);
+ pb->setDefault(pData->iDefaultButton == 3);
+ g->addWidget(pb,3,2);
+ connect(pb,SIGNAL(clicked()),this,SLOT(button3Pressed()));
+ }
+ }
+
+ g->setRowStretch(1,1);
+
+ m_pData->iSelectedButton = m_pData->iDefaultButton;
+}
+
+KviHtmlDialog::~KviHtmlDialog()
+{
+
+}
+
+void KviHtmlDialog::button1Pressed()
+{
+ m_pData->iSelectedButton = 1;
+ accept();
+}
+
+void KviHtmlDialog::button2Pressed()
+{
+ m_pData->iSelectedButton = 2;
+ accept();
+}
+
+void KviHtmlDialog::button3Pressed()
+{
+ m_pData->iSelectedButton = 3;
+ accept();
+}
+
+void KviHtmlDialog::reject()
+{
+ m_pData->iSelectedButton = m_pData->iCancelButton;
+ QDialog::reject();
+}
+
+int KviHtmlDialog::display(QWidget * pParent,KviHtmlDialogData * pData)
+{
+ KviHtmlDialog * pDialog = new KviHtmlDialog(pParent,pData);
+ pDialog->exec();
+ delete pDialog;
+ return pData->iSelectedButton;
+}
+
+
diff --git a/src/kvirc/ui/kvi_htmldialog.h b/src/kvirc/ui/kvi_htmldialog.h
new file mode 100644
index 000000000..7b182b7fa
--- /dev/null
+++ b/src/kvirc/ui/kvi_htmldialog.h
@@ -0,0 +1,85 @@
+#ifndef _KVI_HTMLDIALOG_H_
+#define _KVI_HTMLDIALOG_H_
+//=============================================================================
+//
+// File : kvi_htmldialog.h
+// Created on Wed 03 Jan 2007 03:36:36 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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//=============================================================================
+
+#include "kvi_qstring.h"
+
+#include <qpixmap.h>
+#include <qdialog.h>
+
+class KviHtmlDialogData
+{
+public:
+ // input
+
+ // mandatory fields
+ enum Flags { ForceMinimumSize = 1 };
+ int iFlags; // da flags :)
+ int iDefaultButton; // the button to use when Enter is pressed (1,2 or 3)
+ int iCancelButton; // the button to use when Esc is pressed (1,2 or 3)
+ QString szHtmlText; // Shouldn't be empty :D
+
+ // optional fields
+ QString szCaption; // KVIrc is used when this is empty
+ QString szUpperLabelText; // no label is shown if this is empty
+ QString szLowerLabelText; // no label is shown if this is empty
+ QString szButton1Text; // OK is used if this is empty
+ QString szButton2Text; // no button is shown if this is empty
+ QString szButton3Text; // no button is shown if this is empty
+
+ int iMinimumWidth;
+ int iMinimumHeight;
+
+ QPixmap pixIcon; // may be null
+
+ // output
+ int iSelectedButton; // returns 1,2 or 3
+};
+
+class KviHtmlDialog : public QDialog
+{
+ Q_OBJECT
+public:
+ // the dialog does NOT delete this structure and assumes that
+ // it remains alive until the dialog closes (i.e. it may access
+ // the structure in the destructor
+ KviHtmlDialog(QWidget * pParent,KviHtmlDialogData * pData);
+ ~KviHtmlDialog();
+protected:
+ KviHtmlDialogData * m_pData;
+public:
+ // displays the dialog as modal and returns 1,2 or 3
+ static int display(QWidget * pParent,KviHtmlDialogData * pData);
+protected slots:
+ void button1Pressed();
+ void button2Pressed();
+ void button3Pressed();
+protected:
+ virtual void reject();
+};
+
+
+
+#endif //!_KVI_HTMLDIALOG_H_
diff --git a/src/kvirc/ui/kvi_xmladdonloader.cpp b/src/kvirc/ui/kvi_xmladdonloader.cpp
index 7c50bfac5..31f90a184 100644
--- a/src/kvirc/ui/kvi_xmladdonloader.cpp
+++ b/src/kvirc/ui/kvi_xmladdonloader.cpp
@@ -22,6 +22,7 @@
//
///////////////////////////////////////////////////////////////////////////////
+/*
#define __KVIRC__
#include "kvi_locale.h"
@@ -144,3 +145,5 @@ void KviXmlAddonLoader::fillListView()
}
}
}
+
+*/
diff --git a/src/kvirc/ui/kvi_xmladdonloader.h b/src/kvirc/ui/kvi_xmladdonloader.h
index 968f15cad..04a5ad0fa 100644
--- a/src/kvirc/ui/kvi_xmladdonloader.h
+++ b/src/kvirc/ui/kvi_xmladdonloader.h
@@ -25,6 +25,7 @@
//
///////////////////////////////////////////////////////////////////////////////
+/*
#include "kvi_heapobject.h"
#include <qdialog.h>
#include <qlistview.h>
@@ -57,5 +58,6 @@ protected slots:
protected:
void fillListView();
};
+*/
#endif //!_KVI_XML_ADDON_LOADER_H_
diff --git a/src/modules/addon/libkviaddon.cpp b/src/modules/addon/libkviaddon.cpp
index 2dc34efab..2095bf216 100644
--- a/src/modules/addon/libkviaddon.cpp
+++ b/src/modules/addon/libkviaddon.cpp
@@ -35,6 +35,7 @@
#include "kvi_mirccntrl.h"
#include "kvi_config.h"
#include "kvi_sourcesdate.h"
+#include "kvi_miscutils.h"
#include "managementdialog.h"
@@ -75,7 +76,7 @@ static bool addon_kvs_fnc_exists(KviKvsModuleFunctionCall * c)
{
c->returnValue()->setBoolean(true);
} else {
- c->returnValue()->setBoolean(KviKvsScriptAddonManager::instance()->compareVersions(a->version(),szVersion) < 0);
+ c->returnValue()->setBoolean(KviMiscUtils::compareVersions(a->version(),szVersion) < 0);
}
} else {
c->returnValue()->setBoolean(false);
@@ -530,19 +531,19 @@ static bool addon_kvs_cmd_register(KviKvsModuleCallbackCommandCall * c)
if(c->callback())
rd.szUninstallCallbackScript = c->callback()->code();
- if(!KviKvsScriptAddonManager::instance()->isValidVersionString(rd.szVersion))
+ if(!KviMiscUtils::isValidVersionString(rd.szVersion))
{
c->error(__tr2qs("The specified version \"%Q\" is not a valid version string"),&(rd.szVersion));
return false;
}
- if(!KviKvsScriptAddonManager::instance()->isValidVersionString(szMinKVIrcVersion))
+ if(!KviMiscUtils::isValidVersionString(szMinKVIrcVersion))
{
c->error(__tr2qs("The specified KVIrc version \"%Q\" is not a valid version string"),&szMinKVIrcVersion);
return false;
}
- if(KviKvsScriptAddonManager::instance()->compareVersions(szMinKVIrcVersion,KVI_VERSION "." KVI_SOURCES_DATE) < 0)
+ if(KviMiscUtils::compareVersions(szMinKVIrcVersion,KVI_VERSION "." KVI_SOURCES_DATE) < 0)
{
c->error(__tr2qs("This KVIrc executable is too old to run this addon (minimum version required is %Q)"),&szMinKVIrcVersion);
return false;
@@ -555,7 +556,7 @@ static bool addon_kvs_cmd_register(KviKvsModuleCallbackCommandCall * c)
if(a)
{
// the same addon already exists
- if(KviKvsScriptAddonManager::instance()->compareVersions(a->version(),rd.szVersion) < 0)
+ if(KviMiscUtils::compareVersions(a->version(),rd.szVersion) < 0)
{
// and it has a higher version...
// complain unless -f is used
diff --git a/src/modules/math/libkvimath.cpp b/src/modules/math/libkvimath.cpp
index 829292acb..849a7c930 100644
--- a/src/modules/math/libkvimath.cpp
+++ b/src/modules/math/libkvimath.cpp
@@ -472,7 +472,7 @@ static bool math_module_cleanup(KviModule *m)
}
KVIRC_MODULE(
- "System", // module name
+ "Math", // module name
"1.0.0", // module version
"Copyright (C) 2006 Szymon Stefanek (pragma at kvirc dot net),"\
"Tonino Imbesi (grifisx at barmes dot org)," \
diff --git a/src/modules/mediaplayer/libkvimediaplayer.cpp b/src/modules/mediaplayer/libkvimediaplayer.cpp
index 1176c7bd4..4eb227f3f 100644
--- a/src/modules/mediaplayer/libkvimediaplayer.cpp
+++ b/src/modules/mediaplayer/libkvimediaplayer.cpp
@@ -1396,7 +1396,7 @@ MP_KVS_FUNCTION(status)
the informations about the currently played media (in order to implement the nice /playing
scripts). The module has replaced the old mediaplayer module which after
years of development had developed some design flaws and needed a complete rewrite.
- At the moment of writing the supported players are: xmms (unix), winamp (windows),
+ At the moment of writing the supported players are: xmms (unix), audacious (unix), winamp (windows),
amarok (kde) and juk (kde). You choose the player interface by either setting
the option in the settings dialog, by manually setting [cmd]option[/cmd] stringPreferredMediaPlayer
or by running [cmd]mediaplayer.detect[/cmd] that will guess the media player interface for you.[br]
@@ -1516,6 +1516,7 @@ static bool mediaplayer_module_init( KviModule * m )
#ifndef COMPILE_ON_WINDOWS
g_pDescriptorList->append(MP_CREATE_DESCRIPTOR(KviXmmsInterface));
+ g_pDescriptorList->append(MP_CREATE_DESCRIPTOR(KviAudaciousInterface));
#endif
#ifdef COMPILE_ON_WINDOWS
diff --git a/src/modules/mediaplayer/mp_xmmsinterface.cpp b/src/modules/mediaplayer/mp_xmmsinterface.cpp
index 5ace1ac55..1bb1caaba 100644
--- a/src/modules/mediaplayer/mp_xmmsinterface.cpp
+++ b/src/modules/mediaplayer/mp_xmmsinterface.cpp
@@ -4,7 +4,7 @@
// Created on Fri 25 Mar 2005 20:04:54 by Szymon Stefanek
//
// This file is part of the KVIrc IRC client distribution
-// Copyright (C) 2005 Szymon Stefanek <pragma at kvirc dot net>
+// Copyright (C) 2005-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
@@ -20,13 +20,15 @@
// along with this program. If not, write to the Free Software Foundation,
// Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
+// Thnx to Alexander Stillich <torque at pltn dot org> for Audacious
+// media player interface hints :)
+//
//=============================================================================
#include "mp_xmmsinterface.h"
#ifndef COMPILE_ON_WINDOWS
-#include "kvi_library.h"
#include "kvi_locale.h"
MP_IMPLEMENT_DESCRIPTOR(
@@ -40,77 +42,118 @@ MP_IMPLEMENT_DESCRIPTOR(
)
)
+MP_IMPLEMENT_DESCRIPTOR(
+ KviAudaciousInterface,
+ "audacious",
+ __tr2qs_ctx(
+ "An interface to the popular UNIX audacious media player.\n" \
+ "Download it from http://audacious-media-player.org\n"
+ ,
+ "mediaplayer"
+ )
+)
-static kvi_library_t g_hXmmsLib = 0;
+static const char *xmms_lib_names[] =
+{
+ "libxmms.so",
+ "libxmms.so.1",
+ "/usr/lib/libxmms.so",
+ "/usr/lib/libxmms.so.1",
+ "/usr/local/lib/libxmms.so",
+ "/usr/local/lib/libxmms.so.1",
+ 0
+};
-static inline kvi_library_t load_xmms_lib()
+static const char *audacious_lib_names[] =
{
- if(g_hXmmsLib)return g_hXmmsLib;
- g_hXmmsLib = kvi_library_load("libxmms.so");
- if(!g_hXmmsLib)
- {
- g_hXmmsLib = kvi_library_load("libxmms.so.1");
- if(!g_hXmmsLib)
- {
- g_hXmmsLib = kvi_library_load("/usr/lib/libxmms.so");
- if(!g_hXmmsLib)
- {
- g_hXmmsLib = kvi_library_load("/usr/lib/libxmms.so.1");
- if(!g_hXmmsLib)
- {
- g_hXmmsLib = kvi_library_load("/usr/local/lib/libxmms.so");
- if(!g_hXmmsLib)
- {
- g_hXmmsLib = kvi_library_load("/usr/local/lib/libxmms.so.1");
- }
- }
- }
- }
- }
- return g_hXmmsLib;
+ "libaudacious.so",
+ "libaudacious.so.4",
+ "/usr/lib/libaudacious.so",
+ "/usr/lib/libaudacious.so.4",
+ "/usr/local/lib/libaudacious.so",
+ "/usr/local/lib/libaudacious.so.4",
+ 0
+};
+
+
+
+KviXmmsInterface::KviXmmsInterface()
+: KviMediaPlayerInterface()
+{
+ m_hPlayerLibrary = 0;
+ m_szPlayerLibraryName = "libxmms.so";
+ m_pLibraryPaths = xmms_lib_names;
}
-static inline void * lookup_xmms_symbol(KviXmmsInterface * i,const char * sym)
+KviXmmsInterface::~KviXmmsInterface()
{
- if(!load_xmms_lib())
- {
- i->setLastError(__tr2qs_ctx("Can't load the xmms library (libxmms.so)","mediaplayer"));
- return 0;
- }
- void * symptr = kvi_library_symbol(g_hXmmsLib,sym);
- if(!symptr)
+ if(m_hPlayerLibrary)
{
- QString tmp;
- KviQString::sprintf(tmp,__tr2qs_ctx("Can't find symbol %s in libxmms.so","mediaplayer"),sym);
- i->setLastError(tmp);
+ kvi_library_close(m_hPlayerLibrary);
+ m_hPlayerLibrary = 0;
}
- return symptr;
}
+KviAudaciousInterface::KviAudaciousInterface()
+: KviXmmsInterface()
+{
+ m_szPlayerLibraryName = "libaudacious.so";
+ m_pLibraryPaths = audacious_lib_names;
+}
+KviAudaciousInterface::~KviAudaciousInterface()
+{
+}
-KviXmmsInterface::KviXmmsInterface()
-: KviMediaPlayerInterface()
+bool KviXmmsInterface::loadPlayerLibrary()
{
+ if(m_hPlayerLibrary)return true;
+
+ const char **lib_name = m_pLibraryPaths;
+ while(*lib_name)
+ {
+ m_hPlayerLibrary = kvi_library_load(*lib_name);
+ if(m_hPlayerLibrary)
+ {
+ m_szPlayerLibraryName = *lib_name;
+ break;
+ }
+ lib_name++;
+ }
+ return true;
}
-KviXmmsInterface::~KviXmmsInterface()
+void * KviXmmsInterface::lookupSymbol(const char * szSymbolName)
{
- if(g_hXmmsLib)
+ if(!m_hPlayerLibrary)
+ {
+ if(!loadPlayerLibrary())
+ {
+ QString tmp;
+ KviQString::sprintf(tmp,__tr2qs_ctx("Can't load the player library (%Q)","mediaplayer"),&m_szPlayerLibraryName);
+ setLastError(tmp);
+ return 0;
+ }
+ }
+ void * symptr = kvi_library_symbol(m_hPlayerLibrary,szSymbolName);
+ if(!symptr)
{
- kvi_library_close(g_hXmmsLib);
- g_hXmmsLib = 0;
+ QString tmp;
+ KviQString::sprintf(tmp,__tr2qs_ctx("Can't find symbol %s in %Q","mediaplayer"),szSymbolName,&m_szPlayerLibraryName);
+ setLastError(tmp);
}
+ return symptr;
}
+
int KviXmmsInterface::detect(bool bStart)
{
- void * sym = lookup_xmms_symbol(this,"xmms_remote_play");
+ void * sym = lookupSymbol("xmms_remote_play");
return sym ? 80 : 0;
}
#define XMMS_SIMPLE_CALL(__symname) \
- void (*sym)(int) = (void (*)(int))lookup_xmms_symbol(this,__symname); \
+ void (*sym)(int) = (void (*)(int))lookupSymbol(__symname); \
if(!sym)return false; \
sym(0); \
return true;
@@ -147,7 +190,7 @@ bool KviXmmsInterface::quit()
bool KviXmmsInterface::jumpTo(int &iPos)
{
- void (*sym)(int,int) = (void (*)(int,int))lookup_xmms_symbol(this,"xmms_remote_jump_to_time");
+ void (*sym)(int,int) = (void (*)(int,int))lookupSymbol("xmms_remote_jump_to_time");
if(!sym)return false;
sym(0,iPos);
return true;
@@ -155,7 +198,7 @@ bool KviXmmsInterface::jumpTo(int &iPos)
bool KviXmmsInterface::setVol(int &iVol)
{
- void (*sym)(int,int) = (void (*)(int,int))lookup_xmms_symbol(this,"xmms_remote_set_main_volume");
+ void (*sym)(int,int) = (void (*)(int,int))lookupSymbol("xmms_remote_set_main_volume");
if(!sym)return false;
sym(0,100*iVol/255);
return true;
@@ -163,7 +206,7 @@ bool KviXmmsInterface::setVol(int &iVol)
int KviXmmsInterface::getVol()
{
- int (*sym)(int) = (int (*)(int))lookup_xmms_symbol(this,"xmms_remote_get_main_volume");
+ int (*sym)(int) = (int (*)(int))lookupSymbol("xmms_remote_get_main_volume");
if(!sym)return -1;
int iVol = sym(0);
return iVol * 255 /100;
@@ -171,7 +214,7 @@ int KviXmmsInterface::getVol()
bool KviXmmsInterface::getRepeat()
{
- bool (*sym)(int) = (bool (*)(int))lookup_xmms_symbol(this,"xmms_remote_is_repeat");
+ bool (*sym)(int) = (bool (*)(int))lookupSymbol("xmms_remote_is_repeat");
if(!sym)return false;
bool ret = sym(0);
return ret;
@@ -179,12 +222,12 @@ bool KviXmmsInterface::getRepeat()
bool KviXmmsInterface::setRepeat(bool &bVal)
{
- bool (*sym1)(int) = (bool (*)(int))lookup_xmms_symbol(this,"xmms_remote_is_repeat");
+ bool (*sym1)(int) = (bool (*)(int))lookupSymbol("xmms_remote_is_repeat");
if(!sym1)return false;
bool bNow = sym1(0);
if(bNow != bVal)
{
- void (*sym2)(int) = (void (*)(int))lookup_xmms_symbol(this,"xmms_remote_toggle_repeat");
+ void (*sym2)(int) = (void (*)(int))lookupSymbol("xmms_remote_toggle_repeat");
if(!sym2)return false;
sym2(0);
}
@@ -193,7 +236,7 @@ bool KviXmmsInterface::setRepeat(bool &bVal)
bool KviXmmsInterface::getShuffle()
{
- bool (*sym)(int) = (bool (*)(int))lookup_xmms_symbol(this,"xmms_remote_is_shuffle");
+ bool (*sym)(int) = (bool (*)(int))lookupSymbol("xmms_remote_is_shuffle");
if(!sym)return false;
bool ret = sym(0);
return ret;
@@ -201,12 +244,12 @@ bool KviXmmsInterface::getShuffle()
bool KviXmmsInterface::setShuffle(bool &bVal)
{
- bool (*sym1)(int) = (bool (*)(int))lookup_xmms_symbol(this,"xmms_remote_is_shuffle");
+ bool (*sym1)(int) = (bool (*)(int))lookupSymbol("xmms_remote_is_shuffle");
if(!sym1)return false;
bool bNow = sym1(0);
if(bNow != bVal)
{
- void (*sym2)(int) = (void (*)(int))lookup_xmms_symbol(this,"xmms_remote_toggle_shuffle");
+ void (*sym2)(int) = (void (*)(int))lookupSymbol("xmms_remote_toggle_shuffle");
if(!sym2)return false;
sym2(0);
}
@@ -215,11 +258,11 @@ bool KviXmmsInterface::setShuffle(bool &bVal)
KviMediaPlayerInterface::PlayerStatus KviXmmsInterface::status()
{
- bool (*sym1)(int) = (bool (*)(int))lookup_xmms_symbol(this,"xmms_remote_is_paused");
+ bool (*sym1)(int) = (bool (*)(int))lookupSymbol("xmms_remote_is_paused");
if(sym1)
{
if(sym1(0))return KviMediaPlayerInterface::Paused;
- bool (*sym2)(int) = (bool (*)(int))lookup_xmms_symbol(this,"xmms_remote_is_playing");
+ bool (*sym2)(int) = (bool (*)(int))lookupSymbol("xmms_remote_is_playing");
if(sym2)
{
if(sym2(0))return KviMediaPlayerInterface::Playing;
@@ -232,20 +275,20 @@ KviMediaPlayerInterface::PlayerStatus KviXmmsInterface::status()
bool KviXmmsInterface::playMrl(const QString &mrl)
{
- void (*sym)(int,char *) = (void (*)(int,char *))lookup_xmms_symbol(this,"xmms_remote_playlist_add_url_string");
+ void (*sym)(int,char *) = (void (*)(int,char *))lookupSymbol("xmms_remote_playlist_add_url_string");
QCString tmp = mrl.local8Bit();
if(!tmp.isEmpty())
{
if(sym)
{
sym(0,tmp.data());
- int (*sym1)(int) = (int (*)(int))lookup_xmms_symbol(this,"xmms_remote_get_playlist_length");
+ int (*sym1)(int) = (int (*)(int))lookupSymbol("xmms_remote_get_playlist_length");
if(sym1)
{
int len = sym1(0);
if(len > 0)
{
- void (*sym2)(int,int) = (void (*)(int,int))lookup_xmms_symbol(this,"xmms_remote_set_playlist_pos");
+ void (*sym2)(int,int) = (void (*)(int,int))lookupSymbol("xmms_remote_set_playlist_pos");
if(sym2)
{
sym2(0,len - 1);
@@ -259,20 +302,20 @@ bool KviXmmsInterface::playMrl(const QString &mrl)
QString KviXmmsInterface::nowPlaying()
{
- int (*sym)(int) = (int (*)(int))lookup_xmms_symbol(this,"xmms_remote_get_playlist_pos");
+ int (*sym)(int) = (int (*)(int))lookupSymbol("xmms_remote_get_playlist_pos");
if(!sym)return QString::null;
int pos = sym(0);
- char * (*sym2)(int,int) = (char * (*)(int,int))lookup_xmms_symbol(this,"xmms_remote_get_playlist_title");
+ char * (*sym2)(int,int) = (char * (*)(int,int))lookupSymbol("xmms_remote_get_playlist_title");
if(!sym2)return QString::null;
return QString::fromLocal8Bit(sym2(0,pos));
}
QString KviXmmsInterface::mrl()
{
- int (*sym)(int) = (int (*)(int))lookup_xmms_symbol(this,"xmms_remote_get_playlist_pos");
+ int (*sym)(int) = (int (*)(int))lookupSymbol("xmms_remote_get_playlist_pos");
if(!sym)return QString::null;
int pos = sym(0);
- char * (*sym2)(int,int) = (char * (*)(int,int))lookup_xmms_symbol(this,"xmms_remote_get_playlist_file");
+ char * (*sym2)(int,int) = (char * (*)(int,int))lookupSymbol("xmms_remote_get_playlist_file");
if(!sym2)return QString::null;
QString ret = QString::fromLocal8Bit(sym2(0,pos));
if(ret.length() > 1)
@@ -282,27 +325,27 @@ QString KviXmmsInterface::mrl()
int KviXmmsInterface::position()
{
- int (*sym)(int) = (int (*)(int))lookup_xmms_symbol(this,"xmms_remote_get_playlist_pos");
+ int (*sym)(int) = (int (*)(int))lookupSymbol("xmms_remote_get_playlist_pos");
if(!sym)return -1;
int pos = sym(0);
- int (*sym2)(int,int) = (int (*)(int,int))lookup_xmms_symbol(this,"xmms_remote_get_output_time");
+ int (*sym2)(int,int) = (int (*)(int,int))lookupSymbol("xmms_remote_get_output_time");
if(!sym2)return -1;
return sym2(0,pos);
}
int KviXmmsInterface::length()
{
- int (*sym)(int) = (int (*)(int))lookup_xmms_symbol(this,"xmms_remote_get_playlist_pos");
+ int (*sym)(int) = (int (*)(int))lookupSymbol("xmms_remote_get_playlist_pos");
if(!sym)return -1;
int pos = sym(0);
- int (*sym2)(int,int) = (int (*)(int,int))lookup_xmms_symbol(this,"xmms_remote_get_playlist_time");
+ int (*sym2)(int,int) = (int (*)(int,int))lookupSymbol("xmms_remote_get_playlist_time");
if(!sym2)return -1;
return sym2(0,pos);
}
int KviXmmsInterface::getPlayListPos()
{
- int (*sym)(int) = (int (*)(int))lookup_xmms_symbol(this,"xmms_remote_get_playlist_pos");
+ int (*sym)(int) = (int (*)(int))lookupSymbol("xmms_remote_get_playlist_pos");
if(!sym)return -1;
return sym(0);
}
diff --git a/src/modules/mediaplayer/mp_xmmsinterface.h b/src/modules/mediaplayer/mp_xmmsinterface.h
index a49877e4e..8482defd2 100644
--- a/src/modules/mediaplayer/mp_xmmsinterface.h
+++ b/src/modules/mediaplayer/mp_xmmsinterface.h
@@ -6,7 +6,7 @@
// Created on Fri 25 Mar 2005 20:04:54 by Szymon Stefanek
//
// This file is part of the KVIrc IRC client distribution
-// Copyright (C) 2005 Szymon Stefanek <pragma at kvirc dot net>
+// Copyright (C) 2005-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
@@ -22,11 +22,14 @@
// along with this program. If not, write to the Free Software Foundation,
// Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
+// Thnx to Alexander Stillich <torque at pltn dot org> for Audacious
+// media player interface hints :)
+//
//=============================================================================
#include "kvi_settings.h"
#include "mp_interface.h"
-
+#include "kvi_library.h"
#ifndef COMPILE_ON_WINDOWS
class KviXmmsInterface : public KviMediaPlayerInterface
@@ -34,6 +37,10 @@
public:
KviXmmsInterface();
virtual ~KviXmmsInterface();
+ protected:
+ kvi_library_t m_hPlayerLibrary;
+ QString m_szPlayerLibraryName;
+ const char ** m_pLibraryPaths;
public:
virtual int detect(bool bStart);
virtual bool prev();
@@ -57,11 +64,23 @@
virtual bool setRepeat(bool &bVal);
virtual bool setShuffle(bool &bVal);
protected:
- bool initPlayer();
+ bool loadPlayerLibrary();
+ void * lookupSymbol(const char * szSymbolName);
};
MP_DECLARE_DESCRIPTOR(KviXmmsInterface)
+ class KviAudaciousInterface : public KviXmmsInterface
+ {
+ public:
+ KviAudaciousInterface();
+ virtual ~KviAudaciousInterface();
+ protected:
+ virtual void * lookupSymbol(const char * szSymbolName);
+ };
+
+ MP_DECLARE_DESCRIPTOR(KviAudaciousInterface)
+
#endif //!COMPILE_ON_WINDOWS
#endif //!_MP_XMMSINTERFACE_H_
diff --git a/src/modules/setup/libkvisetup.cpp b/src/modules/setup/libkvisetup.cpp
index c86287853..2c0365cbb 100644
--- a/src/modules/setup/libkvisetup.cpp
+++ b/src/modules/setup/libkvisetup.cpp
@@ -35,6 +35,7 @@
#include "kvi_kvs_script.h"
#include "kvi_kvs_variantlist.h"
#include "kvi_window.h"
+#include "kvi_theme.h"
// this will be choosen during the setup process
QString g_szChoosenIncomingDirectory;
@@ -97,7 +98,8 @@ KVIMODULEEXPORTFUNC void setup_finish()
}*/
g_pApp->getGlobalKvircDirectory(szDir,KviApp::Themes,"silverirc");
- g_pApp->loadTheme(szDir);
+ KviThemeInfo out;
+ KviTheme::load(szDir,out);
g_pApp->loadDefaultScript();
if(!szUrl.isEmpty())
diff --git a/src/modules/system/libkvisystem.cpp b/src/modules/system/libkvisystem.cpp
index 979336b87..7f29e2c23 100644
--- a/src/modules/system/libkvisystem.cpp
+++ b/src/modules/system/libkvisystem.cpp
@@ -44,6 +44,8 @@
#include <dcopclient.h>
#endif
+#include "kvi_modulemanager.h"
+
/*
@doc: system.ostype
@type:
@@ -334,6 +336,39 @@ static bool system_kvs_fnc_selection(KviKvsModuleFunctionCall *c)
/*
+ @doc: system.checkModule
+ @keyterms:
+ Module checking
+ @type:
+ function
+ @title:
+ $system.checkModule
+ @short:
+ Checks if a KVIrc module is loadable
+ @syntax:
+ <boolean> $system.checkModule(<module_name:string>)
+ @description:
+ Attempts to load the specified module and returns
+ $true if succesfull and $false otherwise. This can
+ be effectively used to test if a KVIrc exension module
+ is present on the system and can be loaded by the
+ KVIrc engine.
+*/
+
+static bool system_kvs_fnc_checkModule(KviKvsModuleFunctionCall *c)
+{
+ QString szModuleName;
+
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSM_PARAMETER("module_name",KVS_PT_STRING,0,szModuleName)
+ KVSM_PARAMETERS_END(c)
+
+ c->returnValue()->setBoolean(g_pModuleManager->loadModule(szModuleName.utf8().data()));
+ return true;
+}
+
+
+/*
@doc: system.hostname
@keyterms:
System information
@@ -622,6 +657,7 @@ static bool system_module_init(KviModule * m)
KVSM_REGISTER_FUNCTION(m,"dcop",system_kvs_fnc_dcop);
KVSM_REGISTER_FUNCTION(m,"clipboard",system_kvs_fnc_clipboard);
KVSM_REGISTER_FUNCTION(m,"selection",system_kvs_fnc_selection);
+ KVSM_REGISTER_FUNCTION(m,"checkModule",system_kvs_fnc_checkModule);
KVSM_REGISTER_SIMPLE_COMMAND(m,"setenv",system_kvs_cmd_setenv);
KVSM_REGISTER_SIMPLE_COMMAND(m,"setClipboard",system_kvs_cmd_setClipboard);
diff --git a/src/modules/theme/Makefile.am b/src/modules/theme/Makefile.am
index fba495058..5417e9e5e 100644
--- a/src/modules/theme/Makefile.am
+++ b/src/modules/theme/Makefile.am
@@ -9,12 +9,28 @@ pluglib_LTLIBRARIES = libkvitheme.la
libkvitheme_la_LDFLAGS = -module -avoid-version $(SS_LDFLAGS) $(SS_LIBDIRS)
-libkvitheme_la_SOURCES = libkvitheme.cpp managementdialog.cpp
-nodist_libkvitheme_la_SOURCES = moc_managementdialog.cpp
+libkvitheme_la_SOURCES = libkvitheme.cpp \
+ managementdialog.cpp \
+ packthemedialog.cpp \
+ savethemedialog.cpp \
+ themefunctions.cpp
+
+nodist_libkvitheme_la_SOURCES = moc_managementdialog.cpp \
+ moc_packthemedialog.cpp \
+ moc_savethemedialog.cpp
libkvitheme_la_LIBADD = $(SS_LIBLINK) ../../kvilib/build/libkvilib.la
-noinst_HEADERS= managementdialog.h
+noinst_HEADERS= managementdialog.h \
+ packthemedialog.h \
+ savethemedialog.h \
+ themefunctions.h
moc_managementdialog.cpp: managementdialog.h
$(SS_QT_MOC) $< -o $@
+
+moc_packthemedialog.cpp: packthemedialog.h
+ $(SS_QT_MOC) $< -o $@
+
+moc_savethemedialog.cpp: savethemedialog.h
+ $(SS_QT_MOC) $< -o $@
diff --git a/src/modules/theme/libkvitheme.cpp b/src/modules/theme/libkvitheme.cpp
index 72b6261a3..12c7786ca 100644
--- a/src/modules/theme/libkvitheme.cpp
+++ b/src/modules/theme/libkvitheme.cpp
@@ -36,6 +36,7 @@
#include "kvi_sourcesdate.h"
#include "managementdialog.h"
+#include "themefunctions.h"
QRect g_rectManagementDialogGeometry(0,0,0,0);
@@ -56,6 +57,19 @@ QRect g_rectManagementDialogGeometry(0,0,0,0);
static bool theme_kvs_cmd_install(KviKvsModuleCommandCall * c)
{
+ QString szThemePackFile;
+
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSM_PARAMETER("package_path",KVS_PT_STRING,0,szThemePackFile)
+ KVSM_PARAMETERS_END(c)
+
+ QString szError;
+ if(!KviThemeFunctions::installThemePackage(szThemePackFile,szError))
+ {
+ c->error(__tr2qs_ctx("Error installing theme package: %Q","theme"),&szError);
+ return false;
+ }
+
return true;
}
diff --git a/src/modules/theme/managementdialog.cpp b/src/modules/theme/managementdialog.cpp
index 17822fe0c..3f96ab13b 100644
--- a/src/modules/theme/managementdialog.cpp
+++ b/src/modules/theme/managementdialog.cpp
@@ -29,7 +29,10 @@
#define LVI_MINIMUM_CELL_WIDTH (LVI_MINIMUM_TEXT_WIDTH + LVI_BORDER + LVI_ICON_SIZE + LVI_SPACING + LVI_BORDER)
#include "managementdialog.h"
-#include "kvi_xmladdonloader.h"
+#include "packthemedialog.h"
+#include "savethemedialog.h"
+#include "themefunctions.h"
+
#include "kvi_iconmanager.h"
#include "kvi_msgbox.h"
@@ -71,676 +74,6 @@
extern QRect g_rectManagementDialogGeometry;
-KviSaveThemeDialog::KviSaveThemeDialog(QWidget * par)
-: QDialog(par)
-{
- setCaption(__tr2qs_ctx("Save Current Theme","theme"));
-
- QGridLayout * g = new QGridLayout(this,8,2,4,4);
-
- QLabel * l;
-
- l = new QLabel(__tr2qs_ctx("Theme name:","theme"),this);
- g->addWidget(l,0,0);
-
- m_pThemeNameEdit = new QLineEdit(this);
- g->addMultiCellWidget(m_pThemeNameEdit,0,0,1,2);
- connect(m_pThemeNameEdit,SIGNAL(textChanged(const QString &)),this,SLOT(themeNameChanged(const QString &)));
-
-
- l = new QLabel(__tr2qs_ctx("Version:","theme"),this);
- g->addWidget(l,1,0);
-
- m_pVersionEdit = new QLineEdit(this);
- g->addMultiCellWidget(m_pVersionEdit,1,1,1,2);
-
-
- l = new QLabel(__tr2qs_ctx("Author:","theme"),this);
- g->addWidget(l,2,0);
-
- m_pAuthorEdit = new QLineEdit(this);
- g->addMultiCellWidget(m_pAuthorEdit,2,2,1,2);
-
- l = new QLabel(__tr2qs_ctx("Description:","theme"),this);
- g->addWidget(l,3,0);
-
- m_pDescriptionEdit = new QTextEdit(this);
- g->addMultiCellWidget(m_pDescriptionEdit,3,4,1,2);
-
- m_pIncludeMsgcolors = new KviStyledCheckBox( __tr2qs_ctx("Include message colors information","theme"), this );
- m_pIncludeMsgcolors->setChecked(TRUE);
- g->addMultiCellWidget(m_pIncludeMsgcolors,5,5,0,1);
-
-// l = new QLabel(__tr2qs_ctx("Package type:","theme"),this);
-// g->addWidget(l,6,0);
-
-// m_pFormatCombo = new QComboBox(this);
-// m_pFormatCombo->insertItem(__tr2qs_ctx("KVIrc Package","theme"),0);
-// m_pFormatCombo->insertItem(__tr2qs_ctx("New multi-file format","theme"),1);
-// m_pFormatCombo->insertItem(__tr2qs_ctx("Dublicate Theme","theme"),1);
-// g->addWidget(m_pFormatCombo,6,1);
-
- QHBox * h = new QHBox(this);
- h->setSpacing(7);
- g->addWidget(h,7,2);
- m_pOkButton = new QPushButton(__tr2qs_ctx("OK","theme"),h);
- m_pOkButton->setEnabled(false);
- connect(m_pOkButton,SIGNAL(clicked()),this,SLOT(saveTheme()));
- m_pOkButton->setIconSet(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_ACCEPT)));
-
- QPushButton * pb = new QPushButton(__tr2qs_ctx("Cancel","theme"),h);
- connect(pb,SIGNAL(clicked()),this,SLOT(reject()));
- pb->setIconSet(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_DISCARD)));
-
-}
-
-KviSaveThemeDialog::~KviSaveThemeDialog()
-{
-
-}
-
-void KviSaveThemeDialog::themeNameChanged(const QString &txt)
-{
- m_pOkButton->setEnabled(!txt.isEmpty());
-}
-
-void KviSaveThemeDialog::saveThemeInOldFormat(KviThemeInfo& sto)
-{
- if(!KviFileUtils::directoryExists(sto.szAbsoluteDirectory))
- {
- g_pApp->getLocalKvircDirectory(sto.szAbsoluteDirectory,KviApp::Themes,sto.szSubdirectory,true);
- if(!KviFileUtils::makeDir(sto.szAbsoluteDirectory))
- {
- QMessageBox::critical(this,__tr2qs_ctx("Save Theme - KVIrc","theme"),__tr2qs_ctx("Unable to create theme directory.","theme"),
- QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
- return;
- }
- }
- g_pApp->saveTheme(sto);
- // write down the images
-
- QString szMsg = __tr2qs_ctx("Theme saved successfully to ","theme");
- szMsg += sto.szAbsoluteDirectory;
-
- QMessageBox::information(this,__tr2qs_ctx("Save Theme - KVIrc","theme"),szMsg,QMessageBox::Ok,
- QMessageBox::NoButton,QMessageBox::NoButton);
-}
-
-void KviSaveThemeDialog::saveThemeInNewFormat(KviThemeInfo& sto)
-{
- QString szBaseDir;
- QFileDialog * d = new QFileDialog(this);
- d->setCaption(__tr2qs_ctx("Choose save directory","theme"));
- d->setMode(QFileDialog::DirectoryOnly);
- if(d->exec() == QDialog::Accepted)
- {
- szBaseDir = d->selectedFile();
- KviFileUtils::adjustFilePath(szBaseDir);
- delete d;
- if(szBaseDir.isEmpty())
- {
- QMessageBox::critical(this,__tr2qs_ctx("Save Theme - KVIrc","theme"),__tr2qs_ctx("You must select save directory","theme"),
- QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
- return;
- }
- } else {
- delete d;
- QMessageBox::critical(this,__tr2qs_ctx("Save Theme - KVIrc","theme"),__tr2qs_ctx("You must select save directory","theme"),
- QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
- return;
- }
- KviQString::ensureLastCharIs(szBaseDir,KVI_PATH_SEPARATOR_CHAR);
- sto.szAbsoluteDirectory=szBaseDir+sto.szSubdirectory;
- KviQString::ensureLastCharIs(sto.szAbsoluteDirectory,KVI_PATH_SEPARATOR_CHAR);
- QString szThemeDir=sto.szAbsoluteDirectory;
- sto.szAbsoluteDirectory+="files";
-
- if(!KviFileUtils::makeDir(sto.szAbsoluteDirectory))
- {
- QMessageBox::critical(this,__tr2qs_ctx("Save Theme - KVIrc","theme"),__tr2qs_ctx("Unable to create theme files directory.","theme"),
- QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
- return;
- }
-
- g_pApp->saveTheme(sto);
-
- if(!KviFileUtils::makeDir(szThemeDir+"utils"))
- {
- QMessageBox::critical(this,__tr2qs_ctx("Save Theme - KVIrc","theme"),__tr2qs_ctx("Unable to create theme utils directory.","theme"),
- QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
- return;
- }
-
- QString szInstallerScript;
- g_pApp->getGlobalKvircDirectory(szInstallerScript,KviApp::DefScript,"installer.kvs");
- if(!KviFileUtils::fileExists(szInstallerScript))
- {
- QMessageBox::critical(this,__tr2qs_ctx("Save Theme - KVIrc","theme"),__tr2qs_ctx("Cannot find installer.kvs.","theme"),
- QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
- return;
- }
-
- if(!KviFileUtils::copyFile(szInstallerScript,szThemeDir+"utils/installer.kvs"))
- {
- QMessageBox::critical(this,__tr2qs_ctx("Save Theme - KVIrc","theme"),__tr2qs_ctx("Cannot write installer.kvs.","theme"),
- QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
- return;
- }
-
- g_pApp->getGlobalKvircDirectory(szInstallerScript,KviApp::DefScript,"theme-install.kvs");
- QString szMainScript=szThemeDir+"install.kvs";
- if(!KviFileUtils::copyFile(szInstallerScript,szMainScript))
- {
- QMessageBox::critical(this,__tr2qs_ctx("Save Theme - KVIrc","theme"),__tr2qs_ctx("Cannot write install.kvs.","theme"),
- QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
- return;
- }
- QFile installFile(szMainScript);
- if(!installFile.open(IO_ReadOnly))
- {
- QMessageBox::critical(this,__tr2qs_ctx("Save Theme - KVIrc","theme"),__tr2qs_ctx("Cannot open install.kvs for reading.","theme"),
- QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
- return;
- }
-
- QCString szFileContents;
- szFileContents=installFile.readAll();
- installFile.close();
-
- sto.szName.replace("\"","\\\"");
-
- szFileContents.replace("@THEMENAME@",sto.szName.utf8().data());
-// szFileContents.replace("@THEMENAME@",sto.szName.utf8().data());
- sto.szDescription.replace("\"","\\\"");
- if(sto.szDescription.isEmpty()) sto.szDescription="empty";
- szFileContents.replace("@THEMEDESCRIPTION@",sto.szDescription.utf8().data());
- sto.szVersion.replace("\"","\\\"");
- szFileContents.replace("@THEMEVERSION@",sto.szVersion.utf8().data());
- szFileContents.replace("@SUBDIR@",sto.szSubdirectory.utf8().data());
-
- QString szAliasName="";
- QString m_szId;
-
- struct timeval tv;
- kvi_gettimeofday(&tv,0);
-
- KviQString::sprintf(m_szId,"theme_%d%d%d",tv.tv_usec,rand() % 1000,rand() % 1000);
- szAliasName.prepend(m_szId);
- szFileContents.replace("@ALIASNAME@",szAliasName.utf8().data());
- if(!installFile.open(IO_WriteOnly))
- {
- QMessageBox::critical(this,__tr2qs_ctx("Save Theme - KVIrc","theme"),__tr2qs_ctx("Cannot open install.kvs for writing.","theme"),
- QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
- return;
- }
- installFile.writeBlock(szFileContents.data(),szFileContents.length());
- installFile.close();
-
- QString szMsg = __tr2qs_ctx("Theme saved successfully to ","theme");
- szMsg += szThemeDir;
-
- QMessageBox::information(this,__tr2qs_ctx("Save Theme - KVIrc","theme"),szMsg,QMessageBox::Ok,
- QMessageBox::NoButton,QMessageBox::NoButton);
-}
-
-void KviSaveThemeDialog::saveThemeInXmlFormat(KviThemeInfo& sto)
-{
- QString szFilename;
- QFileDialog * d = new QFileDialog(this);
- d->setCaption(__tr2qs_ctx("Choose filaname","theme"));
- d->setMode(QFileDialog::AnyFile);
- d->setFilter( "KVIrc Packages (*.kvp)" );
- if(d->exec() == QDialog::Accepted)
- {
- szFilename = d->selectedFile();
- KviFileUtils::adjustFilePath(szFilename);
- delete d;
- if(szFilename.isEmpty())
- {
- QMessageBox::critical(this,__tr2qs_ctx("Save Theme - KVIrc","theme"),__tr2qs_ctx("You must select filename","theme"),
- QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
- return;
- }
- } else {
- delete d;
- QMessageBox::critical(this,__tr2qs_ctx("Save Theme - KVIrc","theme"),__tr2qs_ctx("You must select filename","theme"),
- QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
- return;
- }
- if(QFileInfo(szFilename).extension()!="kvp") szFilename.append(".kvp");
- g_pApp->saveXmlTheme(sto,szFilename);
-}
-
-void KviSaveThemeDialog::saveTheme()
-{
- KviThemeInfo sto;
- sto.szName = m_pThemeNameEdit->text();
- if(sto.szName.isEmpty())
- {
- QMessageBox::critical(this,__tr2qs_ctx("Save Theme - KVIrc","theme"),__tr2qs_ctx("You must choose a theme name!","theme"),QMessageBox::Ok,
- QMessageBox::NoButton,QMessageBox::NoButton);
- return;
- }
-
- sto.szAuthor = m_pAuthorEdit->text();
- sto.szDescription = m_pDescriptionEdit->text();
- sto.szDate = QDateTime::currentDateTime().toString();
- sto.szVersion = m_pVersionEdit->text();
- sto.szKvircVersion = KVI_VERSION;
- sto.bIncludeMsgColors=m_pIncludeMsgcolors->isChecked();
-
- if(sto.szVersion.isEmpty())sto.szVersion = "1.0.0";
-
- sto.szSubdirectory = sto.szName + QString("-") + sto.szVersion;
- sto.szSubdirectory.replace(QRegExp("[ \\\\/:][ \\\\/:]*"),"_");
-
-/*
- switch(m_pFormatCombo->currentItem())
- {
- case 0:
- saveThemeInXmlFormat(sto);
- break;
- case 1:
- saveThemeInNewFormat(sto);
- break;
- case 2:*/
- saveThemeInOldFormat(sto);
-/* break;
- }
-*/
- accept();
-}
-
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-KviPackThemeDialog::KviPackThemeDialog(QWidget * pParent,KviPtrList<KviThemeInfo> * pThemeInfoList)
-: QWizard(pParent)
-{
- m_pThemeInfoList = pThemeInfoList;
-
- KviThemeInfo * pThemeInfo;
- QString szPackageName;
- QString szPackageAuthor;
- QString szPackageDescription;
- QString szPackageVersion;
- if(m_pThemeInfoList->count() > 1)
- {
- szPackageName = "MyThemes";
- szPackageAuthor = __tr2qs_ctx("Your name here","theme");
- szPackageVersion = "1.0";
- szPackageDescription = __tr2qs_ctx("Put a package description here...","theme");
- } else {
- if(m_pThemeInfoList->count() > 0)
- {
- pThemeInfo = m_pThemeInfoList->first();
- szPackageName = pThemeInfo->szSubdirectory;
- szPackageAuthor = pThemeInfo->szAuthor;
- szPackageDescription = pThemeInfo->szDescription;
- szPackageVersion = pThemeInfo->szVersion;
- }
- }
-
-
- setCaption(__tr2qs_ctx("Export Theme - KVIrc","theme"));
- setMinimumSize(400,350);
-
- // welcome page ==================================================================================
- QWidget * pPage = new QWidget(this);
- QGridLayout * pLayout = new QGridLayout(pPage,2,1,4,4);
-
- QLabel * pLabel = new QLabel(pPage);
- QString szText = "<p>";
- szText += __tr2qs_ctx("This procedure allows you to export the selected themes to a single package. It is useful when you want to distribute your themes to the public.","theme");
- szText += "</p><p>";
- szText += __tr2qs_ctx("You will be asked to provide a package name, a description and, if you want, an icon/screenshot.","theme");
- szText += "</p><p>";
- szText += __tr2qs_ctx("Hit the \"Next\" button to begin.","theme");
- szText += "<p>";
-
- pLabel->setText(szText);
- pLayout->addWidget(pLabel,0,0);
- pLayout->setRowStretch(1,1);
-
- addPage(pPage,__tr2qs_ctx("Welcome","theme"));
- setBackEnabled(pPage,false);
- setNextEnabled(pPage,true);
- setHelpEnabled(pPage,false);
- setFinishEnabled(pPage,false);
-
- // theme data name ================================================================================
-
- pPage = new QWidget(this);
- pLayout = new QGridLayout(pPage,2,1,4,4);
-
- pLabel = new QLabel(pPage);
- pLabel->setText(__tr2qs_ctx("This is the information list for the themes you're packaging. If it looks OK press \"Next\" to continue, otherwise press \"Cancel\" and rewiew your themes first.","theme"));
- pLabel->setTextFormat(Qt::RichText);
- pLayout->addWidget(pLabel,0,0);
-
- QString szAuthor = __tr2qs_ctx("Author","theme");
- QString szCreatedAt = __tr2qs_ctx("Created at","theme");
- QString szCreatedOn = __tr2qs_ctx("Created on","theme");
- QString szSubdirectory = __tr2qs_ctx("Subdirectory","theme");
-
- QString szThemesDescription = "<html><body bgcolor=\"#ffffff\">";
-
- int iIdx = 0;
- for(pThemeInfo = m_pThemeInfoList->first();pThemeInfo;pThemeInfo = m_pThemeInfoList->next())
- {
- QString szThemeDescription;
- KviQString::sprintf(
- szThemeDescription,
- "<p>" \
- "<h2>%Q %Q</h2>" \
- "</p>" \
- "<p>" \
- "<i>%Q</i>" \
- "</p>" \
- "<p>" \
- "%Q: <b>%Q</b><br>" \
- "%Q: <b>%Q</b><br>" \
- "</p>" \
- "<p>" \
- "<font color=\"#808080\">" \
- "%Q: KVIrc %Q<br>" \
- "%Q: %Q<br>" \
- "</font>" \
- "</p>",
- &(pThemeInfo->szName),
- &(pThemeInfo->szVersion),
- &(pThemeInfo->szDescription),
- &szAuthor,
- &(pThemeInfo->szAuthor),
- &szCreatedAt,
- &(pThemeInfo->szDate),
- &szCreatedOn,
- &(pThemeInfo->szKvircVersion),
- &szSubdirectory,
- &(pThemeInfo->szSubdirectory)
- );
- if(iIdx > 0)
- szThemesDescription += "<hr>";
- szThemesDescription += szThemeDescription;
- iIdx++;
- }
-
- szThemesDescription += "</body></html>";
-
- QTextEdit * pTextEdit = new QTextEdit(pPage);
- pTextEdit->setPaper(QBrush(QColor(255,255,255)));
- pTextEdit->setReadOnly(true);
- pTextEdit->setText(szThemesDescription);
- pLayout->addWidget(pTextEdit,1,0);
- pLayout->setRowStretch(1,1);
-
- addPage(pPage,__tr2qs_ctx("Theme Data","theme"));
- setBackEnabled(pPage,true);
- setHelpEnabled(pPage,false);
- setNextEnabled(pPage,true);
- setFinishEnabled(pPage,false);
-
- // packager informations ================================================================================
-
- pPage = new QWidget(this);
- pLayout = new QGridLayout(pPage,5,2,4,4);
-
- pLabel = new QLabel(pPage);
- pLabel->setText(__tr2qs_ctx("Here you need to provide informations about you (the packager) and a short description of the package you're creating.","theme"));
- pLabel->setTextFormat(Qt::RichText);
- pLayout->addMultiCellWidget(pLabel,0,0,0,1);
-
- pLabel = new QLabel(pPage);
- pLabel->setText(__tr2qs_ctx("Package Name:","theme"));
- pLayout->addWidget(pLabel,1,0);
-
- m_pPackageNameEdit = new QLineEdit(pPage);
- m_pPackageNameEdit->setText(szPackageName);
- pLayout->addWidget(m_pPackageNameEdit,1,1);
-
- pLabel = new QLabel(pPage);
- pLabel->setText(__tr2qs_ctx("Version:","theme"));
- pLayout->addWidget(pLabel,2,0);
-
- m_pPackageVersionEdit = new QLineEdit(pPage);
- m_pPackageVersionEdit->setText(szPackageVersion);
- pLayout->addWidget(m_pPackageVersionEdit,2,1);
-
- pLabel = new QLabel(pPage);
- pLabel->setText(__tr2qs_ctx("Description:","theme"));
- pLayout->addWidget(pLabel,3,0);
-
- m_pPackageDescriptionEdit = new QMultiLineEdit(pPage);
- m_pPackageDescriptionEdit->setText(szPackageDescription);
- pLayout->addWidget(m_pPackageDescriptionEdit,3,1);
-
- pLabel = new QLabel(pPage);
- pLabel->setText(__tr2qs_ctx("Package Author:","theme"));
- pLayout->addWidget(pLabel,4,0);
-
- m_pPackagerNameEdit = new QLineEdit(pPage);
- m_pPackagerNameEdit->setText(szPackageAuthor);
- pLayout->addWidget(m_pPackagerNameEdit,4,1);
-
-
- pLayout->setRowStretch(3,1);
- pLayout->setColStretch(1,1);
-
- addPage(pPage,__tr2qs_ctx("Package Informations","theme"));
- setBackEnabled(pPage,true);
- setHelpEnabled(pPage,false);
- setNextEnabled(pPage,true);
- setFinishEnabled(pPage,false);
-
- // screenshot/logo/icon ================================================================================
-
- pPage = new QWidget(this);
- pLayout = new QGridLayout(pPage,3,1,4,4);
-
- pLabel = new QLabel(pPage);
- pLabel->setText(__tr2qs_ctx("Here you can choose the image that will appear in the installation dialog for your theme package. It can be an icon, a logo or a screenshot and it should be not larger than 300x225. If you don't provide an image a simple default icon will be used at installation stage.","theme"));
- pLabel->setTextFormat(Qt::RichText);
- pLayout->addWidget(pLabel,0,0);
-
- m_pImageLabel = new QLabel(pPage);
- m_pImageLabel->setFrameStyle(QFrame::Sunken | QFrame::Panel);
- m_pImageLabel->setMinimumSize(300,225);
- m_pImageLabel->setAlignment(Qt::AlignCenter | Qt::AlignVCenter);
- pLayout->addWidget(m_pImageLabel,1,0);
-
- QString szFilter = "*.png *.jpg *.xpm";
- m_pImageSelector = new KviFileSelector(pPage,"",&m_szImagePath,true,0,szFilter);
- connect(m_pImageSelector,SIGNAL(selectionChanged(const QString &)),this,SLOT(imageSelectionChanged(const QString &)));
- pLayout->addWidget(m_pImageSelector,2,0);
- pLayout->setRowStretch(1,1);
-
- m_pImageSelectionPage = pPage;
- addPage(pPage,__tr2qs_ctx("Icon/Screenshot","theme"));
- setBackEnabled(pPage,true);
- setHelpEnabled(pPage,false);
- setNextEnabled(pPage,true);
- setFinishEnabled(pPage,false);
-
- // save file name ================================================================================
-
- pPage = new QWidget(this);
- pLayout = new QGridLayout(pPage,4,1,4,4);
-
- pLabel = new QLabel(pPage);
- pLabel->setText(__tr2qs_ctx("Here you must choose the file name for the theme package. It should have a *.%1 extension.","theme").arg(KVI_FILEEXTENSION_THEMEPACKAGE));
- pLabel->setTextFormat(Qt::RichText);
- pLayout->addWidget(pLabel,0,0);
-
- m_szPackagePath = QDir::homeDirPath();
- KviQString::ensureLastCharIs(m_szPackagePath,QChar(KVI_PATH_SEPARATOR_CHAR));
-
- m_szPackagePath += szPackageName;
- m_szPackagePath += "-";
- m_szPackagePath += szPackageVersion;
- m_szPackagePath += ".";
- m_szPackagePath += KVI_FILEEXTENSION_THEMEPACKAGE;
-
- szFilter = "*.";
- szFilter += KVI_FILEEXTENSION_THEMEPACKAGE;
- m_pPathSelector = new KviFileSelector(pPage,"",&m_szPackagePath,true,KviFileSelector::ChooseSaveFileName,szFilter);
- pLayout->addWidget(m_pPathSelector,1,0);
-
- pLabel = new QLabel(pPage);
- pLabel->setText(__tr2qs_ctx("Finally hit the \"Finish\" button to complete the packaging operation.","theme"));
- pLabel->setTextFormat(Qt::RichText);
- pLayout->addWidget(pLabel,3,0);
-
- pLayout->setRowStretch(2,1);
-
- addPage(pPage,__tr2qs_ctx("Package Path","theme"));
- setBackEnabled(pPage,true);
- setHelpEnabled(pPage,false);
- setNextEnabled(pPage,false);
- setFinishEnabled(pPage,true);
-
-}
-
-KviPackThemeDialog::~KviPackThemeDialog()
-{
-}
-
-void KviPackThemeDialog::imageSelectionChanged(const QString &szImagePath)
-{
- QImage pix(szImagePath);
- if(!pix.isNull())
- {
- QPixmap out;
- if(pix.width() > 300 || pix.height() > 225)
- out.convertFromImage(pix.smoothScale(300,225,QImage::ScaleMin));
- else
- out.convertFromImage(pix);
- m_pImageLabel->setPixmap(out);
- return;
- }
-
- QMessageBox::critical(this,__tr2qs_ctx("Export Theme - KVIrc","theme"),__tr2qs_ctx("Failed to load the selected image","theme"),
- QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
-
- m_pImageSelector->setSelection("");
- m_pImageLabel->setPixmap(QPixmap());
-}
-
-
-void KviPackThemeDialog::accept()
-{
- if(!packTheme())return;
- QWizard::accept();
-}
-
-
-bool KviPackThemeDialog::packTheme()
-{
- m_pImageSelector->commit();
- m_pPathSelector->commit();
-
- QString szPackageAuthor = m_pPackagerNameEdit->text();
- QString szPackageName = m_pPackageNameEdit->text();
- QString szPackageDescription = m_pPackageDescriptionEdit->text();
- QString szPackageVersion = m_pPackageVersionEdit->text();
-
- QImage pix(m_szImagePath);
- QPixmap out;
- if(!pix.isNull())
- {
- if(pix.width() > 300 || pix.height() > 225)
- out.convertFromImage(pix.smoothScale(300,225,QImage::ScaleMin));
- else
- out.convertFromImage(pix);
- } else {
- if(!m_szImagePath.isEmpty())
- {
- QMessageBox::critical(this,__tr2qs_ctx("Export Theme - KVIrc","theme"),__tr2qs_ctx("Failed to load the selected image: please fix it","theme"),
- QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
- showPage(m_pImageSelectionPage);
- return false;
- }
- }
-
- KviPackageWriter f;
-
- QString szTmp = QDateTime::currentDateTime().toString();
-
- f.addInfoField("PackageType","ThemePack");
- f.addInfoField("ThemePackVersion","1");
- f.addInfoField("Name",szPackageName);
- f.addInfoField("Version",szPackageVersion);
- f.addInfoField("Author",szPackageAuthor);
- f.addInfoField("Description",szPackageDescription);
- f.addInfoField("Date",szTmp);
- f.addInfoField("KVIrcVersion",KVI_VERSION);
-
- if(!out.isNull())
- {
- QByteArray * pba = new QByteArray();
- QBuffer buffer(*pba);
- buffer.open(IO_WriteOnly);
- out.save(&buffer,"PNG");
- buffer.close();
- f.addInfoField("Image",pba); // cool :) [no disk access needed]
- }
-
- szTmp.setNum(m_pThemeInfoList->count());
- f.addInfoField("ThemeCount",szTmp);
-
- int iIdx = 0;
- for(KviThemeInfo * pInfo = m_pThemeInfoList->first();pInfo;pInfo = m_pThemeInfoList->next())
- {
- KviQString::sprintf(szTmp,"Theme%dName",iIdx);
- f.addInfoField(szTmp,pInfo->szName);
- KviQString::sprintf(szTmp,"Theme%dVersion",iIdx);
- f.addInfoField(szTmp,pInfo->szVersion);
- KviQString::sprintf(szTmp,"Theme%dDescription",iIdx);
- f.addInfoField(szTmp,pInfo->szDescription);
- KviQString::sprintf(szTmp,"Theme%dDate",iIdx);
- f.addInfoField(szTmp,pInfo->szDate);
- KviQString::sprintf(szTmp,"Theme%dSubdirectory",iIdx);
- f.addInfoField(szTmp,pInfo->szSubdirectory);
- KviQString::sprintf(szTmp,"Theme%dAuthor",iIdx);
- f.addInfoField(szTmp,pInfo->szAuthor);
- KviQString::sprintf(szTmp,"Theme%dKVIrcVersion",iIdx);
- f.addInfoField(szTmp,pInfo->szKvircVersion);
- if(!f.addDirectory(pInfo->szAbsoluteDirectory,pInfo->szSubdirectory))
- {
- szTmp = __tr2qs_ctx("Packaging failed","theme");
- szTmp += ": ";
- szTmp += f.lastError();
- QMessageBox::critical(this,__tr2qs_ctx("Export Theme - KVIrc","theme"),szTmp,
- QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
- }
- iIdx++;
- }
-
- if(!f.pack(m_szPackagePath))
- {
- szTmp = __tr2qs_ctx("Packaging failed","theme");
- szTmp += ": ";
- szTmp += f.lastError();
- QMessageBox::critical(this,__tr2qs_ctx("Export Theme - KVIrc","theme"),szTmp,
- QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
- return false;
- }
-
- //KviPackageReader r;
- //r.unpack("/root/test.kvt","/root/unpacked_test_kvt");
-
- QMessageBox::information(this,__tr2qs_ctx("Export Theme - KVIrc","theme"),__tr2qs("Package saved succesfully"),
- QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
-
- return true;
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
KviThemeListBoxItem::KviThemeListBoxItem(QListBox * box,KviThemeInfo * inf)
@@ -749,26 +82,26 @@ KviThemeListBoxItem::KviThemeListBoxItem(QListBox * box,KviThemeInfo * inf)
m_pThemeInfo = inf;
QString t;
t = "<nobr><b>";
- t += inf->szName;
+ t += inf->name();
t += "</b>";
- if(!inf->szVersion.isEmpty()) {
+ if(!inf->version().isEmpty()) {
t += "[";
- t += inf->szVersion;
+ t += inf->version();
t += "]";
}
- if(!inf->szAuthor.isEmpty()) {
+ if(!inf->author().isEmpty()) {
t += " <font color=\"#a0a0a0\"> ";
t += __tr2qs_ctx("by","theme");
t += " ";
- t += inf->szAuthor;
+ t += inf->author();
t += "</font>";
}
t += "</nobr>";
t += "<br><nobr><font size=\"-1\">";
- t += inf->szDescription;
+ t += inf->description();
t += "</font></nobr>";
m_pText = new QSimpleRichText(t,box->font());
int iWidth = box->visibleWidth();
@@ -813,8 +146,6 @@ KviThemeManagementDialog::KviThemeManagementDialog(QWidget * parent)
m_pInstance = this;
- m_pSaveThemeDialog = 0;
-
QGridLayout * g = new QGridLayout(this,3,2,4,4);
QHBox *hb = new QHBox(this);
@@ -853,7 +184,7 @@ KviThemeManagementDialog::KviThemeManagementDialog(QWidget * parent)
tb->setIconSet(*(g_pIconManager->getBigIcon(KVI_BIGICON_OPEN)));
tb->setUsesBigPixmap(true);
QToolTip::add(tb,__tr2qs_ctx("Install Theme Package From Disk","theme"));
- connect(tb,SIGNAL(clicked()),this,SLOT(installFromXml()));
+ connect(tb,SIGNAL(clicked()),this,SLOT(installFromFile()));
tb = new KviStyledToolButton(hb);
tb->setIconSet(*(g_pIconManager->getBigIcon(KVI_BIGICON_WWW)));
@@ -898,19 +229,13 @@ KviThemeManagementDialog::KviThemeManagementDialog(QWidget * parent)
KviThemeManagementDialog::~KviThemeManagementDialog()
{
g_rectManagementDialogGeometry = QRect(pos().x(),pos().y(),size().width(),size().height());
-
- if(m_pSaveThemeDialog)
- {
- delete m_pSaveThemeDialog;
- m_pSaveThemeDialog = 0;
- }
-
m_pInstance = 0;
}
void KviThemeManagementDialog::closeClicked()
{
delete this;
+ m_pInstance = 0;
}
@@ -945,7 +270,7 @@ void KviThemeManagementDialog::packTheme()
}
-void KviThemeManagementDialog::contextMenuRequested ( QListBoxItem * it, const QPoint & pos )
+void KviThemeManagementDialog::contextMenuRequested(QListBoxItem * it,const QPoint & pos)
{
if(it)
{
@@ -959,7 +284,7 @@ void KviThemeManagementDialog::contextMenuRequested ( QListBoxItem * it, const Q
void KviThemeManagementDialog::applyTheme ( QListBoxItem * it)
{
- if(it) m_pListBox->setCurrentItem(it);
+ if(it)m_pListBox->setCurrentItem(it);
applyCurrentTheme();
}
@@ -970,12 +295,21 @@ void KviThemeManagementDialog::applyCurrentTheme()
if(KviMessageBox::yesNo(__tr2qs_ctx("Apply theme - KVIrc","theme"),
__tr2qs_ctx("Do you wish to apply theme \"%Q\" (version %Q)?","theme"),
- &(it->themeInfo()->szName),&(it->themeInfo()->szVersion))) {
-
- QString szPath = it->themeInfo()->szAbsoluteDirectory;
- if(szPath.isEmpty())return;
+ &(it->themeInfo()->name()),&(it->themeInfo()->version())))
+ {
+ QString szPath = it->themeInfo()->absoluteDirectory();
+ if(szPath.isEmpty())return;
+
+ KviThemeInfo out;
+ if(!KviTheme::load(szPath,out))
+ {
+ QString szErr = out.lastError();
+ QString szMsg;
+ KviQString::sprintf(szMsg,__tr2qs_ctx("Failed to apply the specified theme: %Q","theme"),&szErr);
+ QMessageBox::critical(this,__tr2qs_ctx("Apply theme - KVIrc","theme"),szMsg,
+ QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
- g_pApp->loadTheme(szPath);
+ }
}
}
@@ -987,105 +321,30 @@ void KviThemeManagementDialog::deleteTheme()
{
if(!KviMessageBox::yesNo(__tr2qs_ctx("Delete Theme - KVIrc","theme"),
__tr2qs_ctx("Do you really wish to delete theme \"%Q\" (version %Q)?","theme"),
- &(pItem->themeInfo()->szName),&(pItem->themeInfo()->szVersion)))goto jump_out;
+ &(pItem->themeInfo()->name()),&(pItem->themeInfo()->version())))goto jump_out;
- KviFileUtils::deleteDir(pItem->themeInfo()->szAbsoluteDirectory);
+ KviFileUtils::deleteDir(pItem->themeInfo()->absoluteDirectory());
}
}
jump_out:
fillThemeBox();
}
-void KviThemeManagementDialog::installFromXml()
+void KviThemeManagementDialog::installFromFile()
{
int iThemeCount=0;
QString szFileName;
- QDict<QString> * pInfoFields;
- QString * pValue;
- bool bInstall;
- QPixmap pix;
- QByteArray * pByteArray;
-
- const char * check_fields[] = { "Name", "Version", "Author", "Description", "Date", "KVIrcVersion" };
+ QString szError;
if(!KviFileDialog::askForOpenFileName(szFileName,__tr2qs_ctx("Open Theme - KVIrc","theme"),QString::null,"*.kvt"))
return;
- // check if it is a valid theme file
- KviPackageReader r;
- if(!r.readHeader(szFileName))
+ if(!KviThemeFunctions::installThemePackage(szFileName,szError,this))
{
- QString szErr = r.lastError();
- KviMessageBox::information(__tr2qs_ctx("The selected file does not seem to be a valid KVIrc package: %Q","theme"),&szErr);
+ KviMessageBox::information(szError);
return;
}
-
- pInfoFields = r.stringInfoFields();
-
- pValue = pInfoFields->find("PackageType");
- if(!pValue)goto not_a_valid_theme_package;
- if(!KviQString::equalCI(*pValue,"ThemePack"))goto not_a_valid_theme_package;
- pValue = pInfoFields->find("ThemePackVersion");
- if(!pValue)goto not_a_valid_theme_package;
- if(!KviQString::equalCI(*pValue,"1"))goto not_a_valid_theme_package;
-
- // make sure the default fields exist
- for(int i=0;i<6;i++)
- {
- pValue = pInfoFields->find(check_fields[i]);
- if(!pValue)goto not_a_valid_theme_package;
- }
-
- pValue = pInfoFields->find("ThemeCount");
- if(!pValue)goto not_a_valid_theme_package;
- bool bOk;
- iThemeCount = pValue->toInt(&bOk);
- if(!bOk)goto not_a_valid_theme_package;
- if(iThemeCount < 1)goto not_a_valid_theme_package;
-
- // ok.. it should be really valid at this point
-
- // load its picture
- pByteArray = r.binaryInfoFields()->find("Image");
- if(pByteArray)
- {
- pix.loadFromData(*pByteArray,0,0);
- }
-
- if(pix.isNull())
- {
- // load the default icon
- }
-
- /*
- KviUnpackThemeDialog * pDialog = new KviUnpackThemeDialog(this,szFileName);
- bool bInstall = pDialog->exec() == QDialog::Accepted;
- delete pDialog;
- */
-
- bInstall = true;
-
- if(bInstall)
- {
- QString szUnpackPath;
- g_pApp->getLocalKvircDirectory(szUnpackPath,KviApp::Themes);
- if(!r.unpack(szFileName,szUnpackPath))
- {
- QString szErr2 = r.lastError();
- KviMessageBox::information(__tr2qs_ctx("Failed to unpack the selected file: %Q","theme"),&szErr2);
- return;
- }
- }
-
- /*
- KviXmlAddonLoader * pLoader = new KviXmlAddonLoader(szFilename,this);
- pLoader->exec();
- */
fillThemeBox();
- return;
-not_a_valid_theme_package:
- KviMessageBox::information(__tr2qs_ctx("The selected file does not seem to be a valid KVIrc theme package","theme"));
- return;
}
void KviThemeManagementDialog::getMoreThemes()
@@ -1096,15 +355,10 @@ void KviThemeManagementDialog::getMoreThemes()
void KviThemeManagementDialog::saveCurrentTheme()
{
- if(m_pSaveThemeDialog)return;
- m_pSaveThemeDialog = new KviSaveThemeDialog(this);
- m_pSaveThemeDialog->exec();
- if(m_pSaveThemeDialog)
- {
- delete m_pSaveThemeDialog;
- m_pSaveThemeDialog = 0;
- fillThemeBox();
- }
+ KviSaveThemeDialog * pSaveThemeDialog = new KviSaveThemeDialog(this);
+ pSaveThemeDialog->exec();
+ delete pSaveThemeDialog;
+ fillThemeBox();
}
void KviThemeManagementDialog::fillThemeBox(const QString &szDir)
@@ -1122,10 +376,10 @@ void KviThemeManagementDialog::fillThemeBox(const QString &szDir)
szTest += KVI_PATH_SEPARATOR_CHAR;
szTest += *it;
- KviThemeInfo * inf = new KviThemeInfo;
- inf->szSubdirectory = *it;
- if(g_pApp->loadThemeInfo(szTest,*inf))
+ KviThemeInfo * inf = new KviThemeInfo();
+ if(inf->loadFromDirectory(szTest))
{
+ inf->setSubdirectory(*it);
KviThemeListBoxItem * item = 0;
item = new KviThemeListBoxItem(m_pListBox,inf);
} else {
@@ -1138,18 +392,12 @@ void KviThemeManagementDialog::fillThemeBox()
{
m_pListBox->clear();
-// KviThemeInfo * ti = new KviThemeInfo;
-// ti->szName = __tr2qs_ctx("Current Theme","theme");
-
-// KviThemeListBoxItem * itewrq = new KviThemeListBoxItem(m_pListBox,ti);
-
QString szDir;
g_pApp->getGlobalKvircDirectory(szDir,KviApp::Themes);
fillThemeBox(szDir);
g_pApp->getLocalKvircDirectory(szDir,KviApp::Themes);
fillThemeBox(szDir);
-// m_pListBox->setCurrentItem(itewrq);
enableDisableButtons();
}
diff --git a/src/modules/theme/managementdialog.h b/src/modules/theme/managementdialog.h
index 36af51a05..a734d557e 100644
--- a/src/modules/theme/managementdialog.h
+++ b/src/modules/theme/managementdialog.h
@@ -26,6 +26,7 @@
#include "kvi_optionswidget.h"
#include "kvi_list.h"
+#include "kvi_theme.h"
#include <qdialog.h>
#include <qsimplerichtext.h>
@@ -35,6 +36,7 @@
#include <qcursor.h>
#include <qwizard.h>
+
class QLineEdit;
class QTextEdit;
class QPushButton;
@@ -42,72 +44,12 @@ class QLabel;
class QCheckBox;
class QMultiLineEdit;
-typedef struct _KviThemeInfoTag KviThemeInfo;
-
-class KviSaveThemeDialog : public QDialog
-{
- Q_OBJECT
-public:
- KviSaveThemeDialog(QWidget *par);
- ~KviSaveThemeDialog();
-protected:
- QLineEdit * m_pAuthorEdit;
- QLineEdit * m_pThemeNameEdit;
- QLineEdit * m_pVersionEdit;
- QTextEdit * m_pDescriptionEdit;
- QPushButton * m_pOkButton;
-// QComboBox * m_pFormatCombo;
- QCheckBox * m_pIncludeMsgcolors;
-
-private:
- void saveThemeInNewFormat(KviThemeInfo& info);
- void saveThemeInOldFormat(KviThemeInfo& info);
- void saveThemeInXmlFormat(KviThemeInfo& info);
-protected slots:
- void saveTheme();
- void themeNameChanged(const QString &txt);
-};
-
-class KviPackThemeDialog : public QWizard
-{
- Q_OBJECT
-public:
- KviPackThemeDialog(QWidget * pParent,KviPtrList<KviThemeInfo> * pThemeInfoList);
- ~KviPackThemeDialog();
-protected:
- QString m_szImagePath;
- KviFileSelector * m_pImageSelector;
- QString m_szPackagePath;
- KviFileSelector * m_pPathSelector;
- QLabel * m_pImageLabel;
- KviPtrList<KviThemeInfo> * m_pThemeInfoList;
- QLineEdit * m_pPackageNameEdit;
- QMultiLineEdit * m_pPackageDescriptionEdit;
- QLineEdit * m_pPackageVersionEdit;
- QLineEdit * m_pPackagerNameEdit;
- QWidget * m_pImageSelectionPage;
-protected:
- virtual void accept();
-protected slots:
- bool packTheme();
- void imageSelectionChanged(const QString &szImagePath);
-};
-
-/*
-class KviUnpackThemeDialog : public QDialog
-{
- Q_OBJECT
-public:
- KviUnpackThemeDialog(QWidget * pParent);
- ~KviUnpackThemeDialog();
-};
-*/
class KviThemeListBoxItem : public QListBoxText
{
public:
KviThemeListBoxItem(QListBox * box,KviThemeInfo * inf);
- ~KviThemeListBoxItem();
+ virtual ~KviThemeListBoxItem();
public:
KviThemeInfo * m_pThemeInfo;
QSimpleRichText * m_pText;
@@ -126,12 +68,11 @@ class KviThemeManagementDialog : public QDialog
Q_OBJECT
public:
KviThemeManagementDialog(QWidget * parent);
- ~KviThemeManagementDialog();
+ virtual ~KviThemeManagementDialog();
protected:
static KviThemeManagementDialog * m_pInstance;
QListBox * m_pListBox;
QPopupMenu * m_pContextPopup;
- KviSaveThemeDialog * m_pSaveThemeDialog;
KviStyledToolButton * m_pDeleteThemeButton;
KviStyledToolButton * m_pPackThemeButton;
public:
@@ -144,7 +85,7 @@ protected:
protected slots:
void saveCurrentTheme();
void getMoreThemes();
- void installFromXml();
+ void installFromFile();
void fillThemeBox();
void deleteTheme();
void closeClicked();
diff --git a/src/modules/theme/packthemedialog.cpp b/src/modules/theme/packthemedialog.cpp
new file mode 100644
index 000000000..8b53941cc
--- /dev/null
+++ b/src/modules/theme/packthemedialog.cpp
@@ -0,0 +1,456 @@
+//=============================================================================
+//
+// File : packthemedialog.cpp
+// Created on Wed 03 Jan 2007 01:11:44 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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//=============================================================================
+
+#include "packthemedialog.h"
+
+#include <qlayout.h>
+#include <qpushbutton.h>
+#include <qlineedit.h>
+#include <qregexp.h>
+#include <qmessagebox.h>
+#include <qdir.h>
+#include <qcombobox.h>
+#include <qpainter.h>
+#include <qtooltip.h>
+#include <qimage.h>
+#include <qtextedit.h>
+#include <qmultilineedit.h>
+#include <qbuffer.h>
+#include <qlabel.h>
+
+
+#include "kvi_options.h"
+#include "kvi_locale.h"
+#include "kvi_config.h"
+#include "kvi_fileutils.h"
+#include "kvi_app.h"
+#include "kvi_frame.h"
+#include "kvi_iconmanager.h"
+#include "kvi_styled_controls.h"
+#include "kvi_packagefile.h"
+#include "kvi_fileextensions.h"
+#include "kvi_filedialog.h"
+#include "kvi_msgbox.h"
+#include "kvi_selectors.h"
+#include "kvi_miscutils.h"
+#include "kvi_sourcesdate.h"
+
+
+KviPackThemeDialog::KviPackThemeDialog(QWidget * pParent,KviPtrList<KviThemeInfo> * pThemeInfoList)
+: QWizard(pParent)
+{
+ m_pThemeInfoList = pThemeInfoList;
+
+ KviThemeInfo * pThemeInfo;
+ QString szPackageName;
+ QString szPackageAuthor;
+ QString szPackageDescription;
+ QString szPackageVersion;
+ if(m_pThemeInfoList->count() > 1)
+ {
+ szPackageName = "MyThemes";
+ szPackageAuthor = __tr2qs_ctx("Your name here","theme");
+ szPackageVersion = "1.0";
+ szPackageDescription = __tr2qs_ctx("Put a package description here...","theme");
+ } else {
+ if(m_pThemeInfoList->count() > 0)
+ {
+ pThemeInfo = m_pThemeInfoList->first();
+ szPackageName = pThemeInfo->subdirectory();
+ szPackageAuthor = pThemeInfo->author();
+ szPackageDescription = pThemeInfo->description();
+ szPackageVersion = pThemeInfo->version();
+ }
+ }
+
+
+ setCaption(__tr2qs_ctx("Export Theme - KVIrc","theme"));
+ setMinimumSize(400,350);
+
+ // welcome page ==================================================================================
+ QWidget * pPage = new QWidget(this);
+ QGridLayout * pLayout = new QGridLayout(pPage,2,1,4,4);
+
+ QLabel * pLabel = new QLabel(pPage);
+ QString szText = "<p>";
+ szText += __tr2qs_ctx("This procedure allows you to export the selected themes to a single package. It is useful when you want to distribute your themes to the public.","theme");
+ szText += "</p><p>";
+ szText += __tr2qs_ctx("You will be asked to provide a package name, a description and, if you want, an icon/screenshot.","theme");
+ szText += "</p><p>";
+ szText += __tr2qs_ctx("Hit the \"Next\" button to begin.","theme");
+ szText += "<p>";
+
+ pLabel->setText(szText);
+ pLayout->addWidget(pLabel,0,0);
+ pLayout->setRowStretch(1,1);
+
+ addPage(pPage,__tr2qs_ctx("Welcome","theme"));
+ setBackEnabled(pPage,false);
+ setNextEnabled(pPage,true);
+ setHelpEnabled(pPage,false);
+ setFinishEnabled(pPage,false);
+
+ // theme data name ================================================================================
+
+ pPage = new QWidget(this);
+ pLayout = new QGridLayout(pPage,2,1,4,4);
+
+ pLabel = new QLabel(pPage);
+ pLabel->setText(__tr2qs_ctx("This is the information list for the themes you're packaging. If it looks OK press \"Next\" to continue, otherwise press \"Cancel\" and rewiew your themes first.","theme"));
+ pLabel->setTextFormat(Qt::RichText);
+ pLayout->addWidget(pLabel,0,0);
+
+ QString szAuthor = __tr2qs_ctx("Author","theme");
+ QString szCreatedAt = __tr2qs_ctx("Created at","theme");
+ QString szCreatedOn = __tr2qs_ctx("Created with","theme");
+ QString szMinKVIrc = __tr2qs_ctx("Minimum KVIrc version","theme");
+ QString szSubdirectory = __tr2qs_ctx("Subdirectory","theme");
+
+ QString szThemesDescription = "<html><body bgcolor=\"#ffffff\">";
+
+ int iIdx = 0;
+ for(pThemeInfo = m_pThemeInfoList->first();pThemeInfo;pThemeInfo = m_pThemeInfoList->next())
+ {
+ QString szThemeDescription;
+ KviQString::sprintf(
+ szThemeDescription,
+ "<p>" \
+ "<h2>%Q %Q</h2>" \
+ "</p>" \
+ "<p>" \
+ "<i>%Q</i>" \
+ "</p>" \
+ "<p>" \
+ "%Q: <b>%Q</b><br>" \
+ "%Q: <b>%Q</b><br>" \
+ "</p>" \
+ "<p>" \
+ "<font color=\"#808080\">" \
+ "%Q: %Q<br>" \
+ "%Q: %Q<br>" \
+ "%Q: %Q<br>" \
+ "</font>" \
+ "</p>",
+ &(pThemeInfo->name()),
+ &(pThemeInfo->version()),
+ &(pThemeInfo->description()),
+ &szAuthor,
+ &(pThemeInfo->author()),
+ &szCreatedAt,
+ &(pThemeInfo->date()),
+ &szCreatedOn,
+ &(pThemeInfo->application()),
+ &szMinKVIrc,
+ &(pThemeInfo->minimumKVIrcVersion()),
+ &szSubdirectory,
+ &(pThemeInfo->subdirectory())
+ );
+ if(iIdx > 0)
+ szThemesDescription += "<hr>";
+ szThemesDescription += szThemeDescription;
+ iIdx++;
+ }
+
+ szThemesDescription += "</body></html>";
+
+ QTextEdit * pTextEdit = new QTextEdit(pPage);
+ pTextEdit->setPaper(QBrush(QColor(255,255,255)));
+ pTextEdit->setReadOnly(true);
+ pTextEdit->setText(szThemesDescription);
+ pLayout->addWidget(pTextEdit,1,0);
+ pLayout->setRowStretch(1,1);
+
+ addPage(pPage,__tr2qs_ctx("Theme Data","theme"));
+ setBackEnabled(pPage,true);
+ setHelpEnabled(pPage,false);
+ setNextEnabled(pPage,true);
+ setFinishEnabled(pPage,false);
+
+ // packager informations ================================================================================
+
+ pPage = new QWidget(this);
+ pLayout = new QGridLayout(pPage,5,2,4,4);
+
+ pLabel = new QLabel(pPage);
+ pLabel->setText(__tr2qs_ctx("Here you need to provide informations about you (the packager) and a short description of the package you're creating.","theme"));
+ pLabel->setTextFormat(Qt::RichText);
+ pLayout->addMultiCellWidget(pLabel,0,0,0,1);
+
+ pLabel = new QLabel(pPage);
+ pLabel->setText(__tr2qs_ctx("Package Name:","theme"));
+ pLayout->addWidget(pLabel,1,0);
+
+ m_pPackageNameEdit = new QLineEdit(pPage);
+ m_pPackageNameEdit->setText(szPackageName);
+ pLayout->addWidget(m_pPackageNameEdit,1,1);
+
+ pLabel = new QLabel(pPage);
+ pLabel->setText(__tr2qs_ctx("Version:","theme"));
+ pLayout->addWidget(pLabel,2,0);
+
+ m_pPackageVersionEdit = new QLineEdit(pPage);
+ m_pPackageVersionEdit->setText(szPackageVersion);
+ pLayout->addWidget(m_pPackageVersionEdit,2,1);
+
+ pLabel = new QLabel(pPage);
+ pLabel->setText(__tr2qs_ctx("Description:","theme"));
+ pLayout->addWidget(pLabel,3,0);
+
+ m_pPackageDescriptionEdit = new QMultiLineEdit(pPage);
+ m_pPackageDescriptionEdit->setText(szPackageDescription);
+ pLayout->addWidget(m_pPackageDescriptionEdit,3,1);
+
+ pLabel = new QLabel(pPage);
+ pLabel->setText(__tr2qs_ctx("Package Author:","theme"));
+ pLayout->addWidget(pLabel,4,0);
+
+ m_pPackagerNameEdit = new QLineEdit(pPage);
+ m_pPackagerNameEdit->setText(szPackageAuthor);
+ pLayout->addWidget(m_pPackagerNameEdit,4,1);
+
+
+ pLayout->setRowStretch(3,1);
+ pLayout->setColStretch(1,1);
+
+ addPage(pPage,__tr2qs_ctx("Package Informations","theme"));
+ setBackEnabled(pPage,true);
+ setHelpEnabled(pPage,false);
+ setNextEnabled(pPage,true);
+ setFinishEnabled(pPage,false);
+
+ // screenshot/logo/icon ================================================================================
+
+ pPage = new QWidget(this);
+ pLayout = new QGridLayout(pPage,3,1,4,4);
+
+ pLabel = new QLabel(pPage);
+ pLabel->setText(__tr2qs_ctx("Here you can choose the image that will appear in the installation dialog for your theme package. It can be an icon, a logo or a screenshot and it should be not larger than 300x225. If you don't provide an image a simple default icon will be used at installation stage.","theme"));
+ pLabel->setTextFormat(Qt::RichText);
+ pLayout->addWidget(pLabel,0,0);
+
+ m_pImageLabel = new QLabel(pPage);
+ m_pImageLabel->setFrameStyle(QFrame::Sunken | QFrame::Panel);
+ m_pImageLabel->setMinimumSize(300,225);
+ m_pImageLabel->setAlignment(Qt::AlignCenter | Qt::AlignVCenter);
+ pLayout->addWidget(m_pImageLabel,1,0);
+
+ QString szFilter = "*.png *.jpg *.xpm";
+ m_pImageSelector = new KviFileSelector(pPage,"",&m_szImagePath,true,0,szFilter);
+ connect(m_pImageSelector,SIGNAL(selectionChanged(const QString &)),this,SLOT(imageSelectionChanged(const QString &)));
+ pLayout->addWidget(m_pImageSelector,2,0);
+ pLayout->setRowStretch(1,1);
+
+ m_pImageSelectionPage = pPage;
+ addPage(pPage,__tr2qs_ctx("Icon/Screenshot","theme"));
+ setBackEnabled(pPage,true);
+ setHelpEnabled(pPage,false);
+ setNextEnabled(pPage,true);
+ setFinishEnabled(pPage,false);
+
+ // save file name ================================================================================
+
+ pPage = new QWidget(this);
+ pLayout = new QGridLayout(pPage,4,1,4,4);
+
+ pLabel = new QLabel(pPage);
+ pLabel->setText(__tr2qs_ctx("Here you must choose the file name for the theme package. It should have a *.%1 extension.","theme").arg(KVI_FILEEXTENSION_THEMEPACKAGE));
+ pLabel->setTextFormat(Qt::RichText);
+ pLayout->addWidget(pLabel,0,0);
+
+ m_szPackagePath = QDir::homeDirPath();
+ KviQString::ensureLastCharIs(m_szPackagePath,QChar(KVI_PATH_SEPARATOR_CHAR));
+
+ m_szPackagePath += szPackageName;
+ m_szPackagePath += "-";
+ m_szPackagePath += szPackageVersion;
+ m_szPackagePath += ".";
+ m_szPackagePath += KVI_FILEEXTENSION_THEMEPACKAGE;
+
+ szFilter = "*.";
+ szFilter += KVI_FILEEXTENSION_THEMEPACKAGE;
+ m_pPathSelector = new KviFileSelector(pPage,"",&m_szPackagePath,true,KviFileSelector::ChooseSaveFileName,szFilter);
+ pLayout->addWidget(m_pPathSelector,1,0);
+
+ pLabel = new QLabel(pPage);
+ pLabel->setText(__tr2qs_ctx("Finally hit the \"Finish\" button to complete the packaging operation.","theme"));
+ pLabel->setTextFormat(Qt::RichText);
+ pLayout->addWidget(pLabel,3,0);
+
+ pLayout->setRowStretch(2,1);
+
+ addPage(pPage,__tr2qs_ctx("Package Path","theme"));
+ setBackEnabled(pPage,true);
+ setHelpEnabled(pPage,false);
+ setNextEnabled(pPage,false);
+ setFinishEnabled(pPage,true);
+
+}
+
+KviPackThemeDialog::~KviPackThemeDialog()
+{
+}
+
+void KviPackThemeDialog::imageSelectionChanged(const QString &szImagePath)
+{
+ QImage pix(szImagePath);
+ if(!pix.isNull())
+ {
+ QPixmap out;
+ if(pix.width() > 300 || pix.height() > 225)
+ out.convertFromImage(pix.smoothScale(300,225,QImage::ScaleMin));
+ else
+ out.convertFromImage(pix);
+ m_pImageLabel->setPixmap(out);
+ return;
+ }
+
+ QMessageBox::critical(this,__tr2qs_ctx("Export Theme - KVIrc","theme"),__tr2qs_ctx("Failed to load the selected image","theme"),
+ QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
+
+ m_pImageSelector->setSelection("");
+ m_pImageLabel->setPixmap(QPixmap());
+}
+
+
+void KviPackThemeDialog::accept()
+{
+ if(!packTheme())return;
+ QWizard::accept();
+}
+
+
+bool KviPackThemeDialog::packTheme()
+{
+ m_pImageSelector->commit();
+ m_pPathSelector->commit();
+
+ QString szPackageAuthor = m_pPackagerNameEdit->text();
+ QString szPackageName = m_pPackageNameEdit->text();
+ QString szPackageDescription = m_pPackageDescriptionEdit->text();
+ QString szPackageVersion = m_pPackageVersionEdit->text();
+
+ QImage pix(m_szImagePath);
+ QPixmap out;
+ if(!pix.isNull())
+ {
+ if(pix.width() > 300 || pix.height() > 225)
+ out.convertFromImage(pix.smoothScale(300,225,QImage::ScaleMin));
+ else
+ out.convertFromImage(pix);
+ } else {
+ if(!m_szImagePath.isEmpty())
+ {
+ QMessageBox::critical(this,__tr2qs_ctx("Export Theme - KVIrc","theme"),__tr2qs_ctx("Failed to load the selected image: please fix it","theme"),
+ QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
+ showPage(m_pImageSelectionPage);
+ return false;
+ }
+ }
+
+ KviPackageWriter f;
+
+ QString szTmp = QDateTime::currentDateTime().toString();
+
+ f.addInfoField("PackageType","ThemePack");
+ f.addInfoField("ThemePackVersion","1");
+ f.addInfoField("Name",szPackageName);
+ f.addInfoField("Version",szPackageVersion);
+ f.addInfoField("Author",szPackageAuthor);
+ f.addInfoField("Description",szPackageDescription);
+ f.addInfoField("Date",szTmp);
+ f.addInfoField("Application","KVIrc " KVI_VERSION "." KVI_SOURCES_DATE);
+
+ if(!out.isNull())
+ {
+ QByteArray * pba = new QByteArray();
+ QBuffer buffer(*pba);
+ buffer.open(IO_WriteOnly);
+ out.save(&buffer,"PNG");
+ buffer.close();
+ f.addInfoField("Image",pba); // cool :) [no disk access needed]
+ }
+
+ szTmp.setNum(m_pThemeInfoList->count());
+ f.addInfoField("ThemeCount",szTmp);
+
+ QString szMinimumKVIrcVersion = "0";
+
+ int iIdx = 0;
+ for(KviThemeInfo * pInfo = m_pThemeInfoList->first();pInfo;pInfo = m_pThemeInfoList->next())
+ {
+ KviQString::sprintf(szTmp,"Theme%dName",iIdx);
+ f.addInfoField(szTmp,pInfo->name());
+ KviQString::sprintf(szTmp,"Theme%dVersion",iIdx);
+ f.addInfoField(szTmp,pInfo->version());
+ KviQString::sprintf(szTmp,"Theme%dDescription",iIdx);
+ f.addInfoField(szTmp,pInfo->description());
+ KviQString::sprintf(szTmp,"Theme%dDate",iIdx);
+ f.addInfoField(szTmp,pInfo->date());
+ KviQString::sprintf(szTmp,"Theme%dSubdirectory",iIdx);
+ f.addInfoField(szTmp,pInfo->subdirectory());
+ KviQString::sprintf(szTmp,"Theme%dAuthor",iIdx);
+ f.addInfoField(szTmp,pInfo->author());
+ KviQString::sprintf(szTmp,"Theme%dApplication",iIdx);
+ f.addInfoField(szTmp,pInfo->application());
+ KviQString::sprintf(szTmp,"Theme%dMinimumKVIrcVersion",iIdx);
+ f.addInfoField(szTmp,pInfo->minimumKVIrcVersion());
+ if(!f.addDirectory(pInfo->absoluteDirectory(),pInfo->subdirectory()))
+ {
+ szTmp = __tr2qs_ctx("Packaging failed","theme");
+ szTmp += ": ";
+ szTmp += f.lastError();
+ QMessageBox::critical(this,__tr2qs_ctx("Export Theme - KVIrc","theme"),szTmp,
+ QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
+ }
+
+ if(KviMiscUtils::compareVersions(pInfo->minimumKVIrcVersion(),szMinimumKVIrcVersion) < 0)
+ szMinimumKVIrcVersion = pInfo->minimumKVIrcVersion();
+
+ iIdx++;
+ }
+
+ // This is the maximum of the minimum KVIrc versions of the packed themes!
+ // FIXME: The packages should be warned if in this way we're raising the
+ // requirements on one of the packed themes...
+ f.addInfoField("MinimumKVIrcVersion",szMinimumKVIrcVersion);
+
+ if(!f.pack(m_szPackagePath))
+ {
+ szTmp = __tr2qs_ctx("Packaging failed","theme");
+ szTmp += ": ";
+ szTmp += f.lastError();
+ QMessageBox::critical(this,__tr2qs_ctx("Export Theme - KVIrc","theme"),szTmp,
+ QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
+ return false;
+ }
+
+ //KviPackageReader r;
+ //r.unpack("/root/test.kvt","/root/unpacked_test_kvt");
+
+ QMessageBox::information(this,__tr2qs_ctx("Export Theme - KVIrc","theme"),__tr2qs("Package saved succesfully"),
+ QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
+
+ return true;
+}
+
diff --git a/src/modules/theme/packthemedialog.h b/src/modules/theme/packthemedialog.h
new file mode 100644
index 000000000..1316369bc
--- /dev/null
+++ b/src/modules/theme/packthemedialog.h
@@ -0,0 +1,65 @@
+#ifndef _PACKTHEMEDIALOG_H_
+#define _PACKTHEMEDIALOG_H_
+//=============================================================================
+//
+// File : packthemedialog.h
+// Created on Wed 03 Jan 2007 01:11:44 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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//=============================================================================
+
+#include "kvi_settings.h"
+#include "kvi_list.h"
+#include "kvi_theme.h"
+
+#include <qdialog.h>
+#include <qwizard.h>
+
+class QLineEdit;
+class QLabel;
+class QMultiLineEdit;
+class KviFileSelector;
+
+
+class KviPackThemeDialog : public QWizard
+{
+ Q_OBJECT
+public:
+ KviPackThemeDialog(QWidget * pParent,KviPtrList<KviThemeInfo> * pThemeInfoList);
+ virtual ~KviPackThemeDialog();
+protected:
+ QString m_szImagePath;
+ KviFileSelector * m_pImageSelector;
+ QString m_szPackagePath;
+ KviFileSelector * m_pPathSelector;
+ QLabel * m_pImageLabel;
+ KviPtrList<KviThemeInfo> * m_pThemeInfoList;
+ QLineEdit * m_pPackageNameEdit;
+ QMultiLineEdit * m_pPackageDescriptionEdit;
+ QLineEdit * m_pPackageVersionEdit;
+ QLineEdit * m_pPackagerNameEdit;
+ QWidget * m_pImageSelectionPage;
+protected:
+ virtual void accept();
+protected slots:
+ bool packTheme();
+ void imageSelectionChanged(const QString &szImagePath);
+};
+
+#endif //!_PACKTHEMEDIALOG_H_
diff --git a/src/modules/theme/savethemedialog.cpp b/src/modules/theme/savethemedialog.cpp
new file mode 100644
index 000000000..7a7a200c3
--- /dev/null
+++ b/src/modules/theme/savethemedialog.cpp
@@ -0,0 +1,173 @@
+//=============================================================================
+//
+// File : savethemedialog.cpp
+// Created on Wed 03 Jan 2007 03:01:34 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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//=============================================================================
+
+#include "savethemedialog.h"
+
+#include <qlayout.h>
+#include <qpushbutton.h>
+#include <qlineedit.h>
+#include <qregexp.h>
+#include <qmessagebox.h>
+#include <qdir.h>
+#include <qcombobox.h>
+#include <qpainter.h>
+#include <qtooltip.h>
+#include <qimage.h>
+#include <qtextedit.h>
+#include <qmultilineedit.h>
+#include <qbuffer.h>
+#include <qlabel.h>
+
+
+#include "kvi_options.h"
+#include "kvi_locale.h"
+#include "kvi_config.h"
+#include "kvi_fileutils.h"
+#include "kvi_app.h"
+#include "kvi_frame.h"
+#include "kvi_iconmanager.h"
+#include "kvi_styled_controls.h"
+#include "kvi_packagefile.h"
+#include "kvi_fileextensions.h"
+#include "kvi_filedialog.h"
+#include "kvi_msgbox.h"
+#include "kvi_selectors.h"
+#include "kvi_sourcesdate.h"
+
+
+KviSaveThemeDialog::KviSaveThemeDialog(QWidget * par)
+: QDialog(par)
+{
+ setCaption(__tr2qs_ctx("Save Current Theme","theme"));
+
+ QGridLayout * g = new QGridLayout(this,8,2,4,4);
+
+ QLabel * l;
+
+ l = new QLabel(__tr2qs_ctx("Theme name:","theme"),this);
+ g->addWidget(l,0,0);
+
+ m_pThemeNameEdit = new QLineEdit(this);
+ g->addMultiCellWidget(m_pThemeNameEdit,0,0,1,2);
+ connect(m_pThemeNameEdit,SIGNAL(textChanged(const QString &)),this,SLOT(themeNameChanged(const QString &)));
+
+
+ l = new QLabel(__tr2qs_ctx("Version:","theme"),this);
+ g->addWidget(l,1,0);
+
+ m_pVersionEdit = new QLineEdit(this);
+ g->addMultiCellWidget(m_pVersionEdit,1,1,1,2);
+
+
+ l = new QLabel(__tr2qs_ctx("Author:","theme"),this);
+ g->addWidget(l,2,0);
+
+ m_pAuthorEdit = new QLineEdit(this);
+ g->addMultiCellWidget(m_pAuthorEdit,2,2,1,2);
+
+ l = new QLabel(__tr2qs_ctx("Description:","theme"),this);
+ g->addWidget(l,3,0);
+
+ m_pDescriptionEdit = new QTextEdit(this);
+ g->addMultiCellWidget(m_pDescriptionEdit,3,4,1,2);
+
+ QHBox * h = new QHBox(this);
+ h->setSpacing(7);
+ g->addWidget(h,7,2);
+ m_pOkButton = new QPushButton(__tr2qs_ctx("OK","theme"),h);
+ m_pOkButton->setEnabled(false);
+ connect(m_pOkButton,SIGNAL(clicked()),this,SLOT(saveTheme()));
+ m_pOkButton->setIconSet(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_ACCEPT)));
+
+ QPushButton * pb = new QPushButton(__tr2qs_ctx("Cancel","theme"),h);
+ connect(pb,SIGNAL(clicked()),this,SLOT(reject()));
+ pb->setIconSet(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_DISCARD)));
+
+}
+
+KviSaveThemeDialog::~KviSaveThemeDialog()
+{
+
+}
+
+void KviSaveThemeDialog::themeNameChanged(const QString &txt)
+{
+ m_pOkButton->setEnabled(!txt.isEmpty());
+}
+
+
+void KviSaveThemeDialog::saveTheme()
+{
+ KviThemeInfo sto;
+ sto.setName(m_pThemeNameEdit->text());
+ if(sto.name().isEmpty())
+ {
+ QMessageBox::critical(this,__tr2qs_ctx("Save Theme - KVIrc","theme"),__tr2qs_ctx("You must choose a theme name!","theme"),QMessageBox::Ok,
+ QMessageBox::NoButton,QMessageBox::NoButton);
+ return;
+ }
+
+ sto.setAuthor(m_pAuthorEdit->text());
+ sto.setDescription(m_pDescriptionEdit->text());
+ sto.setDate(QDateTime::currentDateTime().toString());
+ sto.setVersion(m_pVersionEdit->text());
+ sto.setApplication("KVIrc " KVI_VERSION "." KVI_SOURCES_DATE);
+
+ if(sto.version().isEmpty())sto.setVersion("1.0.0");
+
+ QString szSubdir = sto.name() + QString("-") + sto.version();
+ szSubdir.replace(QRegExp("[ \\\\/:][ \\\\/:]*"),"_");
+ sto.setSubdirectory(szSubdir);
+
+ QString szAbsDir;
+ g_pApp->getLocalKvircDirectory(szAbsDir,KviApp::Themes,sto.subdirectory(),true);
+ if(!KviFileUtils::makeDir(szAbsDir))
+ {
+ QMessageBox::critical(this,__tr2qs_ctx("Save Theme - KVIrc","theme"),__tr2qs_ctx("Unable to create theme directory.","theme"),
+ QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
+ return;
+ }
+
+ sto.setAbsoluteDirectory(szAbsDir);
+
+ if(!KviTheme::save(sto))
+ {
+ QString szMsg2;
+ QString szErr = sto.lastError();
+ KviQString::sprintf(szMsg2,__tr2qs_ctx("Unable to save theme: %Q","theme"),&szErr);
+ QMessageBox::critical(this,__tr2qs_ctx("Save Theme - KVIrc","theme"),szMsg2,
+ QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
+ return;
+ }
+ // write down the images
+
+ QString szMsg = __tr2qs_ctx("Theme saved successfully to ","theme");
+ szMsg += sto.absoluteDirectory();
+
+ QMessageBox::information(this,__tr2qs_ctx("Save Theme - KVIrc","theme"),szMsg,QMessageBox::Ok,
+ QMessageBox::NoButton,QMessageBox::NoButton);
+
+ accept();
+}
+
diff --git a/src/modules/theme/savethemedialog.h b/src/modules/theme/savethemedialog.h
new file mode 100644
index 000000000..af9dd2186
--- /dev/null
+++ b/src/modules/theme/savethemedialog.h
@@ -0,0 +1,62 @@
+#ifndef _SAVETHEMEDIALOG_H_
+#define _SAVETHEMEDIALOG_H_
+//=============================================================================
+//
+// File : savethemedialog.h
+// Created on Wed 03 Jan 2007 03:01:34 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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//=============================================================================
+
+#include "kvi_settings.h"
+#include "kvi_list.h"
+
+#include <qdialog.h>
+
+#include "kvi_theme.h"
+
+class QLineEdit;
+class QTextEdit;
+class QPushButton;
+class QCheckBox;
+class QLabel;
+class QMultiLineEdit;
+class KviFileSelector;
+
+
+class KviSaveThemeDialog : public QDialog
+{
+ Q_OBJECT
+public:
+ KviSaveThemeDialog(QWidget *par);
+ virtual ~KviSaveThemeDialog();
+protected:
+ QLineEdit * m_pAuthorEdit;
+ QLineEdit * m_pThemeNameEdit;
+ QLineEdit * m_pVersionEdit;
+ QTextEdit * m_pDescriptionEdit;
+ QPushButton * m_pOkButton;
+protected slots:
+ void saveTheme();
+ void themeNameChanged(const QString &txt);
+};
+
+
+
+#endif //!_SAVETHEMEDIALOG_H_
diff --git a/src/modules/theme/themefunctions.cpp b/src/modules/theme/themefunctions.cpp
new file mode 100644
index 000000000..8a071add3
--- /dev/null
+++ b/src/modules/theme/themefunctions.cpp
@@ -0,0 +1,240 @@
+//=============================================================================
+//
+// File : themefunctions.cpp
+// Created on Wed 03 Jan 2007 03:14:07 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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//=============================================================================
+
+#include "themefunctions.h"
+
+#include "kvi_packagefile.h"
+#include "kvi_locale.h"
+#include "kvi_msgbox.h"
+#include "kvi_app.h"
+#include "kvi_htmldialog.h"
+#include "kvi_iconmanager.h"
+#include "kvi_miscutils.h"
+#include "kvi_sourcesdate.h"
+
+#include <qmime.h>
+
+namespace KviThemeFunctions
+{
+
+ static bool notAValidThemePackage(QString &szError)
+ {
+ KviQString::sprintf(szError,__tr2qs_ctx("The selected file does not seem to be a valid KVIrc theme package","theme"));
+ return false;
+ }
+
+ bool installThemePackage(const QString &szThemePackageFileName,QString &szError,QWidget * pDialogParent)
+ {
+ QDict<QString> * pInfoFields;
+ QString * pValue;
+ bool bInstall;
+ QPixmap pix;
+ QByteArray * pByteArray;
+ KviHtmlDialogData hd;
+
+ const char * check_fields[] = { "Name", "Version", "Author", "Description", "Date", "MinimumKVIrcVersion", "Application" };
+
+ // check if it is a valid theme file
+ KviPackageReader r;
+ if(!r.readHeader(szThemePackageFileName))
+ {
+ QString szErr = r.lastError();
+ KviQString::sprintf(szError,__tr2qs_ctx("The selected file does not seem to be a valid KVIrc package: %Q","theme"),&szErr);
+ return false;
+ }
+
+ pInfoFields = r.stringInfoFields();
+
+ pValue = pInfoFields->find("PackageType");
+ if(!pValue)return notAValidThemePackage(szError);
+ if(!KviQString::equalCI(*pValue,"ThemePack"))return notAValidThemePackage(szError);
+ pValue = pInfoFields->find("ThemePackVersion");
+ if(!pValue)return notAValidThemePackage(szError);
+ if(!KviQString::equalCI(*pValue,"1"))return notAValidThemePackage(szError);
+
+ // make sure the default fields exist
+ for(int i=0;i<6;i++)
+ {
+ pValue = pInfoFields->find(check_fields[i]);
+ if(!pValue)return notAValidThemePackage(szError);
+ }
+
+ pValue = pInfoFields->find("ThemeCount");
+ if(!pValue)return notAValidThemePackage(szError);
+ bool bOk;
+ int iThemeCount = pValue->toInt(&bOk);
+ if(!bOk)return notAValidThemePackage(szError);
+ if(iThemeCount < 1)return notAValidThemePackage(szError);
+
+ // ok.. it should be really valid at this point
+
+ // load its picture
+ pByteArray = r.binaryInfoFields()->find("Image");
+ if(pByteArray)
+ pix.loadFromData(*pByteArray,0,0);
+
+ if(pix.isNull())
+ {
+ // load the default icon
+ pix = *(g_pIconManager->getBigIcon(KVI_BIGICON_THEME));
+ }
+
+ ///////////////////////////////////
+ QString szPackageName;
+ QString szPackageVersion;
+ QString szPackageAuthor;
+ QString szPackageDescription;
+ QString szPackageDate;
+ QString szPackageMinimumKVIrcVersion;
+ QString szPackageApplication;
+
+ QString szAuthor = __tr2qs_ctx("Author","theme");
+ QString szCreatedAt = __tr2qs_ctx("Created at","theme");
+ QString szCreatedOn = __tr2qs_ctx("Created with","theme");
+
+ r.getStringInfoField("Name",szPackageName);
+ r.getStringInfoField("Version",szPackageVersion);
+ r.getStringInfoField("Author",szPackageAuthor);
+ r.getStringInfoField("Description",szPackageDescription);
+ r.getStringInfoField("MinimumKVIrcVersion",szPackageMinimumKVIrcVersion);
+ r.getStringInfoField("Application",szPackageApplication);
+ r.getStringInfoField("Date",szPackageDate);
+
+ if(KviMiscUtils::compareVersions(KVI_VERSION "." KVI_SOURCES_DATE,szPackageMinimumKVIrcVersion) > 0)
+ {
+ KviQString::sprintf(szError,__tr2qs_ctx("The selected theme package requires at least KVIrc %Q","theme"),&szPackageMinimumKVIrcVersion);
+ return false;
+ }
+
+ /*
+ int iIdx = 0;
+ for(KviThemeInfo * pInfo = m_pThemeInfoList->first();pInfo;pInfo = m_pThemeInfoList->next())
+ {
+ KviQString::sprintf(szTmp,"Theme%dName",iIdx);
+ f.addInfoField(szTmp,pInfo->szName);
+ KviQString::sprintf(szTmp,"Theme%dVersion",iIdx);
+ f.addInfoField(szTmp,pInfo->szVersion);
+ KviQString::sprintf(szTmp,"Theme%dDescription",iIdx);
+ f.addInfoField(szTmp,pInfo->szDescription);
+ KviQString::sprintf(szTmp,"Theme%dDate",iIdx);
+ f.addInfoField(szTmp,pInfo->szDate);
+ KviQString::sprintf(szTmp,"Theme%dSubdirectory",iIdx);
+ f.addInfoField(szTmp,pInfo->szSubdirectory);
+ KviQString::sprintf(szTmp,"Theme%dAuthor",iIdx);
+ f.addInfoField(szTmp,pInfo->szAuthor);
+ KviQString::sprintf(szTmp,"Theme%dKVIrcVersion",iIdx);
+ f.addInfoField(szTmp,pInfo->szKvircVersion);
+ if(!f.addDirectory(pInfo->szAbsoluteDirectory,pInfo->szSubdirectory))
+ {
+ szTmp = __tr2qs_ctx("Packaging failed","theme");
+ szTmp += ": ";
+ szTmp += f.lastError();
+ QMessageBox::critical(this,__tr2qs_ctx("Export Theme - KVIrc","theme"),szTmp,
+ QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
+ }
+ iIdx++;
+ }
+ */
+
+ KviQString::sprintf(hd.szHtmlText,
+ "<html bgcolor=\"#ffffff\">" \
+ "<body bgcolor=\"#ffffff\">" \
+ "<br>" \
+ "<p><center>" \
+ "<h2>%Q %Q</h2>" \
+ "</center></p>" \
+ "<p><center>" \
+ "<img src=\"theme_dialog_pack_image\">" \
+ "</center></p>" \
+ "<p><center>" \
+ "<i>%Q</i>" \
+ "</center></p>" \
+ "<p><center>" \
+ "%Q: <b>%Q</b><br>" \
+ "%Q: <b>%Q</b><br>" \
+ "</center></p>" \
+ "<p><center>" \
+ "<font color=\"#808080\">" \
+ "%Q: %Q<br>" \
+ "</font>" \
+ "</center></p>" \
+ "<br>" \
+ "<p><center>" \
+ "<a href=\"theme_dialog_details\">Show Details</a>" \
+ "</center></p>" \
+ "</body>" \
+ "</html>",
+ &szPackageName,
+ &szPackageVersion,
+ &szPackageDescription,
+ &szAuthor,
+ &szPackageAuthor,
+ &szCreatedAt,
+ &szPackageDate,
+ &szCreatedOn,
+ &szPackageApplication
+ );
+
+ QString szDetails = "Doh.. da details";
+
+
+ QMimeSourceFactory::defaultFactory()->setPixmap("theme_dialog_pack_image",pix);
+ QMimeSourceFactory::defaultFactory()->setText("theme_dialog_details",szDetails);
+ QMimeSourceFactory::defaultFactory()->setText("theme_dialog_main",hd.szHtmlText);
+
+ QString beginCenter = "<center>";
+ QString endCenter = "</center>";
+
+ hd.szCaption = __tr2qs_ctx("Install Theme Pack - KVIrc","theme");
+ hd.szUpperLabelText = beginCenter + __tr2qs_ctx("You're about to install the following theme package","theme") + endCenter;
+ hd.szLowerLabelText = beginCenter + __tr2qs_ctx("Do you want to proceed with the installation ?","theme") + endCenter;
+ hd.szButton1Text = __tr2qs_ctx("Do Not Install","theme");
+ hd.szButton2Text = __tr2qs_ctx("Yes, Proceed","theme");
+ hd.iDefaultButton = 2;
+ hd.iCancelButton = 1;
+ hd.pixIcon = *(g_pIconManager->getSmallIcon(KVI_SMALLICON_THEME));
+ hd.iMinimumWidth = 350;
+ hd.iMinimumHeight = 420;
+ hd.iFlags = KviHtmlDialogData::ForceMinimumSize;
+
+ bInstall = KviHtmlDialog::display(pDialogParent,&hd) == 2;
+
+ if(bInstall)
+ {
+ QString szUnpackPath;
+ g_pApp->getLocalKvircDirectory(szUnpackPath,KviApp::Themes);
+ if(!r.unpack(szThemePackageFileName,szUnpackPath))
+ {
+ QString szErr2 = r.lastError();
+ KviQString::sprintf(szError,__tr2qs_ctx("Failed to unpack the selected file: %Q","theme"),&szErr2);
+ return true;
+ }
+ }
+
+ return true;
+ }
+
+
+};
+
diff --git a/src/modules/theme/themefunctions.h b/src/modules/theme/themefunctions.h
new file mode 100644
index 000000000..42949c1b4
--- /dev/null
+++ b/src/modules/theme/themefunctions.h
@@ -0,0 +1,39 @@
+#ifndef _THEMEFUNCTIONS_H_
+#define _THEMEFUNCTIONS_H_
+//=============================================================================
+//
+// File : themefunctions.h
+// Created on Wed 03 Jan 2007 03:14:07 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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//=============================================================================
+
+#include "kvi_settings.h"
+#include "kvi_qstring.h"
+
+#include <qwidget.h>
+
+namespace KviThemeFunctions
+{
+ bool installThemePackage(const QString &szThemePackageFileName,QString &szError,QWidget * pDialogParent = 0);
+};
+
+
+
+#endif //!_THEMEFUNCTIONS_H_