aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Szymon Tomasz Stefanek2007-01-16 01:28:40 +0000
committerGravatar Szymon Tomasz Stefanek2007-01-16 01:28:40 +0000
commitf82d9bed8be9d4374dc219def31b6a516687db48 (patch)
treeb30fba3a355ecf15b1c6fdc6ad9e41bccee4ddb2 /src
parent*AUTOMATICALLY* updated KVI_SOURCES_DATE variable (diff)
downloadKVIrc-f82d9bed8be9d4374dc219def31b6a516687db48.tar.gz
KVIrc-f82d9bed8be9d4374dc219def31b6a516687db48.tar.bz2
KVIrc-f82d9bed8be9d4374dc219def31b6a516687db48.zip
First step in the Qt 4.x port
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@174 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src')
-rw-r--r--src/config.h.in23
-rw-r--r--src/kvilib/build/Makefile.am3
-rw-r--r--src/kvilib/config/kvi_settings.h4
-rw-r--r--src/kvilib/config/kvi_wincfg.h3
-rw-r--r--src/kvilib/core/kvi_asciidict.h39
-rw-r--r--src/kvilib/core/kvi_dict.h39
-rw-r--r--src/kvilib/core/kvi_list.h27
-rw-r--r--src/kvilib/core/kvi_qstring.cpp137
-rw-r--r--src/kvilib/core/kvi_string.cpp41
-rw-r--r--src/kvilib/core/kvi_string.h19
-rw-r--r--src/kvilib/core/kvi_valuelist.h37
-rw-r--r--src/kvilib/ext/kvi_cmdformatter.cpp22
-rw-r--r--src/kvilib/ext/kvi_config.cpp22
-rw-r--r--src/kvilib/ext/kvi_config.h18
-rw-r--r--src/kvilib/system/kvi_locale.cpp200
-rw-r--r--src/kvilib/system/kvi_locale.h12
-rw-r--r--src/kvirc/kernel/kvi_app.h2
-rw-r--r--src/kvirc/kernel/kvi_app_fs.cpp12
-rw-r--r--src/kvirc/kernel/kvi_coreactionnames.h1
-rw-r--r--src/kvirc/kernel/kvi_coreactions.cpp11
-rw-r--r--src/kvirc/kernel/kvi_iconmanager.cpp3
-rw-r--r--src/kvirc/kernel/kvi_iconmanager.h4
-rw-r--r--src/kvirc/kernel/kvi_theme.cpp161
-rw-r--r--src/kvirc/kernel/kvi_theme.h17
-rw-r--r--src/kvirc/kvs/kvi_kvs_coresimplecommands_mr.cpp2
-rw-r--r--src/kvirc/ui/kvi_menubar.cpp52
-rw-r--r--src/kvirc/ui/kvi_window.cpp6
-rw-r--r--src/modules/mircimport/libkvimircimport.cpp4
-rw-r--r--src/modules/str/libkvistr.cpp2
-rw-r--r--src/modules/theme/libkvitheme.cpp53
-rw-r--r--src/modules/theme/managementdialog.cpp30
-rw-r--r--src/modules/theme/managementdialog.h6
-rw-r--r--src/modules/theme/packthemedialog.cpp70
-rw-r--r--src/modules/theme/packthemedialog.h5
-rw-r--r--src/modules/theme/savethemedialog.cpp217
-rw-r--r--src/modules/theme/savethemedialog.h27
-rw-r--r--src/modules/theme/themefunctions.cpp79
-rw-r--r--src/modules/theme/themefunctions.h6
38 files changed, 1127 insertions, 289 deletions
diff --git a/src/config.h.in b/src/config.h.in
index ebd1e3ba8..0608196e3 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -39,7 +39,7 @@
/* define if you want the IpV6 support */
#undef COMPILE_IPV6_SUPPORT
-/* define if you want to compile the KDE 2.x support */
+/* define if you want to compile the KDE 3.x support */
#undef COMPILE_KDE_SUPPORT
/* define if you want the memory checks */
@@ -88,6 +88,9 @@
/* define if you have libgsm and want the GSM code to be compiled */
#undef COMPILE_USE_GSM
+/* define if you want to compile the Qt 4.x support */
+#undef COMPILE_USE_QT4
+
/* define if you trust your memmove() function */
#undef COMPILE_WITH_SYSTEM_MEMMOVE
@@ -187,31 +190,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/kvilib/build/Makefile.am b/src/kvilib/build/Makefile.am
index 6b2bd7bec..a1daf976e 100644
--- a/src/kvilib/build/Makefile.am
+++ b/src/kvilib/build/Makefile.am
@@ -101,7 +101,9 @@ headers_HEADERS = \
../config/kvi_settings.h \
../config/kvi_sourcesdate.h \
../config/kvi_wincfg.h \
+ ../core/kvi_asciidict.h \
../core/kvi_bswap.h \
+ ../core/kvi_dict.h \
../core/kvi_error.h \
../core/kvi_heapobject.h \
../core/kvi_inttypes.h \
@@ -112,6 +114,7 @@ headers_HEADERS = \
../core/kvi_strasm.h \
../core/kvi_string.h \
../core/kvi_stringarray.h \
+ ../core/kvi_valuelist.h \
../ext/kvi_cmdformatter.h \
../ext/kvi_config.h \
../ext/kvi_crypt.h \
diff --git a/src/kvilib/config/kvi_settings.h b/src/kvilib/config/kvi_settings.h
index 2577c65ba..7f6d10d19 100644
--- a/src/kvilib/config/kvi_settings.h
+++ b/src/kvilib/config/kvi_settings.h
@@ -132,6 +132,8 @@
*/
#define KVI_DEPRECATED
-
+#ifdef COMPILE_USE_QT4
+ #define debug qDebug
+#endif
#endif //_KVI_SETTINGS_H_
diff --git a/src/kvilib/config/kvi_wincfg.h b/src/kvilib/config/kvi_wincfg.h
index 7e6353e55..31d6642b1 100644
--- a/src/kvilib/config/kvi_wincfg.h
+++ b/src/kvilib/config/kvi_wincfg.h
@@ -32,6 +32,9 @@
/* define if you want to compile with new parser */
#define COMPILE_NEW_KVS 1
+/* define if you want to use the Qt 4.x support */
+/* #undef COMPILE_USE_QT4 */
+
/* define if you want to use only the new KVS parser */
#define COMPILE_ONLY_NEW_KVS 1
diff --git a/src/kvilib/core/kvi_asciidict.h b/src/kvilib/core/kvi_asciidict.h
new file mode 100644
index 000000000..9a5f2126f
--- /dev/null
+++ b/src/kvilib/core/kvi_asciidict.h
@@ -0,0 +1,39 @@
+#ifndef _KVI_ASCIIDICT_H_
+#define _KVI_ASCIIDICT_H_
+//=================================================================================================
+//
+// File : kvi_asciidict.h
+// Creation date : Mon Jan 15 2007 04:53 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"
+
+#if COMPILE_USE_QT4
+ #include <q3asciidict.h>
+ #define KviAsciiDict Q3AsciiDict
+ #define KviAsciiDictIterator Q3AsciiDictIterator
+#else
+ #include <qasciidict.h>
+ #define KviAsciiDict QAsciiDict
+ #define KviAsciiDictIterator QAsciiDictIterator
+#endif
+
+#endif //_KVI_ASCIIDICT_H_
diff --git a/src/kvilib/core/kvi_dict.h b/src/kvilib/core/kvi_dict.h
new file mode 100644
index 000000000..67fcfba38
--- /dev/null
+++ b/src/kvilib/core/kvi_dict.h
@@ -0,0 +1,39 @@
+#ifndef _KVI_DICT_H_
+#define _KVI_DICT_H_
+//=================================================================================================
+//
+// File : kvi_dict.h
+// Creation date : Mon Jan 15 2007 04:53 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"
+
+#if COMPILE_USE_QT4
+ #include <q3dict.h>
+ #define KviDict Q3Dict
+ #define KviDictIterator Q3DictIterator
+#else
+ #include <qdict.h>
+ #define KviDict QDict
+ #define KviDictIterator QDictIterator
+#endif
+
+#endif //_KVI_DICT_H_
diff --git a/src/kvilib/core/kvi_list.h b/src/kvilib/core/kvi_list.h
index cfe4d647a..067fd7988 100644
--- a/src/kvilib/core/kvi_list.h
+++ b/src/kvilib/core/kvi_list.h
@@ -6,7 +6,7 @@
// Creation date : Tue Jul 6 1999 14:52:20 by Szymon Stefanek
//
// This file is part of the KVirc irc client distribution
-// Copyright (C) 1999-2006 Szymon Stefanek (pragma at kvirc dot net)
+// Copyright (C) 1999-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
@@ -27,16 +27,23 @@
#include "kvi_settings.h"
-#if QT_VERSION >= 300
- #include <qptrlist.h>
- #define KviPtrList QPtrList
- #define KviPtrListBase QPtrList
- #define KviPtrListIterator QPtrListIterator
+#ifdef COMPILE_USE_QT4
+ #include <q3ptrlist.h>
+ #define KviPtrList Q3PtrList
+ #define KviPtrListBase Q3PtrList
+ #define KviPtrListIterator Q3PtrListIterator
#else
- #include <qlist.h>
- #define KviPtrList QList
- #define KviPtrListBase QList
- #define KviPtrListIterator QListIterator
+ #if QT_VERSION >= 300
+ #include <qptrlist.h>
+ #define KviPtrList QPtrList
+ #define KviPtrListBase QPtrList
+ #define KviPtrListIterator QPtrListIterator
+ #else
+ #include <qlist.h>
+ #define KviPtrList QList
+ #define KviPtrListBase QList
+ #define KviPtrListIterator QListIterator
+ #endif
#endif
// BROKEN MSVC LINKER
diff --git a/src/kvilib/core/kvi_qstring.cpp b/src/kvilib/core/kvi_qstring.cpp
index c11861841..9f0463936 100644
--- a/src/kvilib/core/kvi_qstring.cpp
+++ b/src/kvilib/core/kvi_qstring.cpp
@@ -43,6 +43,8 @@
extern unsigned char iso88591_toLower_map[256];
extern unsigned char iso88591_toUpper_map[256];
+#define MY_MIN(a,b) (((a) < (b)) ? (a) : (b))
+
namespace KviQString
{
bool equalCSN(const QString &sz1,const QString &sz2,unsigned int len)
@@ -50,7 +52,7 @@ namespace KviQString
if(len == 0)return true; // assume equal
const QChar * c1 = sz1.unicode();
const QChar * c2 = sz2.unicode();
- unsigned int lmin = QMIN(sz1.length(),sz2.length());
+ unsigned int lmin = MY_MIN(sz1.length(),sz2.length());
if(lmin < len)return false;
const QChar * c1e = c1 + len;
@@ -70,7 +72,7 @@ namespace KviQString
if(len == 0)return true; // assume equal
const QChar * c1 = sz1.unicode();
const QChar * c2 = sz2.unicode();
- unsigned int lmin = QMIN(sz1.length(),sz2.length());
+ unsigned int lmin = MY_MIN(sz1.length(),sz2.length());
if(lmin < len)return false;
const QChar * c1e = c1 + len;
@@ -78,7 +80,11 @@ namespace KviQString
while(c1 < c1e)
{
+#ifdef COMPILE_USE_QT4
+ if(c1->toLower().unicode() != c2->toLower().unicode())return false;
+#else
if(c1->lower().unicode() != c2->lower().unicode())return false;
+#endif
c1++;
c2++;
}
@@ -116,7 +122,11 @@ namespace KviQString
while((c1 < c1e) && (*sz2))
{
+#ifdef COMPILE_USE_QT4
+ if(c1->toLower().unicode() != tolower(*sz2))return false;
+#else
if(c1->lower().unicode() != tolower(*sz2))return false;
+#endif
c1++;
sz2++;
}
@@ -136,7 +146,11 @@ namespace KviQString
while((c1 < c1e) && (sz2->unicode()))
{
+#ifdef COMPILE_USE_QT4
+ if(c1->toLower().unicode() != sz2->toLower().unicode())return false;
+#else
if(c1->lower().unicode() != sz2->lower().unicode())return false;
+#endif
c1++;
sz2++;
}
@@ -174,7 +188,11 @@ namespace KviQString
while(c1 < c1e)
{
+#ifdef COMPILE_USE_QT4
+ if(c1->toLower().unicode() != c2->toLower().unicode())return false;
+#else
if(c1->lower().unicode() != c2->lower().unicode())return false;
+#endif
c1++;
c2++;
}
@@ -192,7 +210,11 @@ namespace KviQString
while(c1 < c1e)
{
if(!sz2->unicode())return false; // sz1 has at least another character
+#ifdef COMPILE_USE_QT4
+ if(c1->toLower().unicode() != sz2->toLower().unicode())return false;
+#else
if(c1->lower().unicode() != sz2->lower().unicode())return false;
+#endif
c1++;
sz2++;
}
@@ -224,7 +246,11 @@ namespace KviQString
while((c1 < c1e) && (*sz2))
{
+#ifdef COMPILE_USE_QT4
+ if(c1->toLower().unicode() != tolower(*sz2))return false;
+#else
if(c1->lower().unicode() != tolower(*sz2))return false;
+#endif
c1++;
sz2++;
}
@@ -283,12 +309,24 @@ namespace KviQString
{
if(c1 >= c1e)
{
+#ifdef COMPILE_USE_QT4
+ if(c2 < c2e)return /* 0 */ - (c2->toLower().unicode());
+#else
if(c2 < c2e)return /* 0 */ - (c2->lower().unicode());
+#endif
return 0;
}
+#ifdef COMPILE_USE_QT4
+ if(c2 >= c2e)return c1->toLower().unicode() /* - 0 */;
+#else
if(c2 >= c2e)return c1->lower().unicode() /* - 0 */;
+#endif
+#ifdef COMPILE_USE_QT4
+ int diff = c1->toLower().unicode() - c2->toLower().unicode();
+#else
int diff = c1->lower().unicode() - c2->lower().unicode();
+#endif
if(diff)return diff;
c1++;
@@ -301,8 +339,8 @@ namespace KviQString
int cmpCIN(const QString &sz1,const QString &sz2,unsigned int len)
{
if(len == 0)return 0; // assume equal
- unsigned int l1 = QMIN(len,sz1.length());
- unsigned int l = QMIN(l1,sz2.length()); // FIXME: THIS IS NOT OK
+ unsigned int l1 = MY_MIN(len,sz1.length());
+ unsigned int l = MY_MIN(l1,sz2.length()); // FIXME: THIS IS NOT OK
const QChar * c1 = sz1.unicode();
const QChar * c2 = sz2.unicode();
@@ -317,7 +355,11 @@ namespace KviQString
int diff = 0;
+#ifdef COMPILE_USE_QT4
+ while((c1 < c1e) && !(diff = (c1->toLower().unicode() - c2->toLower().unicode())))
+#else
while((c1 < c1e) && !(diff = (c1->lower().unicode() - c2->lower().unicode())))
+#endif
{
c1++;
c2++;
@@ -394,13 +436,21 @@ namespace KviQString
void detach(QString &sz)
{
+#ifdef COMPILE_USE_QT4
+ sz.resize(sz.length());
+#else
sz.setLength(sz.length());
+#endif
}
const QChar * nullTerminatedArray(const QString &sz)
{
//sz.setLength(sz.length()); // detach!
+#ifdef COMPILE_USE_QT4
+ return sz.constData();
+#else
return (const QChar *)sz.ucs2(); // MAY BE NULL!
+#endif
}
void appendNumber(QString &s,double dReal)
@@ -488,7 +538,7 @@ namespace KviQString
if(reallen == allocsize)INCREMENT_MEM
//copy up to a '%'
- if(*fmt != '%')
+ if(fmt->unicode() != '%')
{
*p++ = *fmt;
reallen++;
@@ -496,7 +546,7 @@ namespace KviQString
}
++fmt; //skip this '%'
- switch(*fmt)
+ switch(fmt->unicode())
{
case 's': // char * string
{
@@ -643,7 +693,7 @@ namespace KviQString
{
*p++ = '%'; //write it
reallen++;
- if(*fmt)
+ if(fmt->unicode())
{
if(reallen == allocsize)INCREMENT_MEM
*p++ = *fmt;
@@ -703,9 +753,14 @@ namespace KviQString
// s1
//
+#ifdef COMPILE_USE_QT4
+ const QChar * m1 = (const QChar *)szM1.constData();
+ const QChar * m2 = (const QChar *)szM2.constData();
+#else
const QChar * m1 = (const QChar *)szM1.ucs2();
const QChar * m2 = (const QChar *)szM2.ucs2();
-
+#endif
+
if(!(m1 && m2 && (m1->unicode())))return false;
const QChar * savePos1 = 0;
const QChar * savePos2 = m2;
@@ -721,7 +776,11 @@ namespace KviQString
continue; //and return
}
if(!m2->unicode())return false; //m2 finished and we had something to match here!
+#ifdef COMPILE_USE_QT4
+ if(m1->toLower()==m2->toLower())
+#else
if(m1->lower()==m2->lower())
+#endif
{
//chars matched
m1++; //Go ahead in the two strings
@@ -777,7 +836,11 @@ namespace KviQString
bool matchStringCI(const QString &szExp,const QString &szStr,bool bIsRegExp,bool bExact)
{
QString szWildcard;
+#ifdef COMPILE_USE_QT4
+ QChar* ptr=(QChar*)szExp.constData();
+#else
QChar* ptr=(QChar*)szExp.ucs2();
+#endif
if(!ptr) return 0;
while(ptr->unicode())
{
@@ -791,15 +854,27 @@ namespace KviQString
}
ptr++;
}
+#ifdef COMPILE_USE_QT4
+ QRegExp re(szWildcard,Qt::CaseInsensitive,bIsRegExp ? QRegExp::RegExp : QRegExp::Wildcard);
+#else
QRegExp re(szWildcard,false,!bIsRegExp);
+#endif
if(bExact) return re.exactMatch(szStr);
+#ifdef COMPILE_USE_QT4
+ return re.indexIn(szStr) != -1;
+#else
return re.search(szStr) != -1;
+#endif
}
bool matchStringCS(const QString &szExp,const QString &szStr,bool bIsRegExp,bool bExact)
{
QString szWildcard;
+#ifdef COMPILE_USE_QT4
+ QChar* ptr=(QChar*)szExp.constData();
+#else
QChar* ptr=(QChar*)szExp.ucs2();
+#endif
if(!ptr) return 0;
while(ptr->unicode())
{
@@ -813,28 +888,48 @@ namespace KviQString
}
ptr++;
}
+#ifdef COMPILE_USE_QT4
+ QRegExp re(szWildcard,Qt::CaseSensitive,bIsRegExp ? QRegExp::RegExp : QRegExp::Wildcard);
+#else
QRegExp re(szWildcard,true,!bIsRegExp);
+#endif
if(bExact) return re.exactMatch(szStr);
+#ifdef COMPILE_USE_QT4
+ return re.indexIn(szStr) != -1;
+#else
return re.search(szStr) != -1;
+#endif
}
void cutFromFirst(QString &s,const QChar &c,bool bIncluded)
{
+#ifdef COMPILE_USE_QT4
+ int idx = s.indexOf(c);
+#else
int idx = s.find(c);
+#endif
if(idx == -1)return;
s.truncate(bIncluded ? idx : idx + 1);
}
void cutFromLast(QString &s,const QChar &c,bool bIncluded)
{
+#ifdef COMPILE_USE_QT4
+ int idx = s.lastIndexOf(c);
+#else
int idx = s.findRev(c);
+#endif
if(idx == -1)return;
s.truncate(bIncluded ? idx : idx + 1);
}
void cutToFirst(QString &s,const QChar &c,bool bIncluded,bool bClearIfNotFound)
{
+#ifdef COMPILE_USE_QT4
+ int idx = s.indexOf(c);
+#else
int idx = s.find(c);
+#endif
if(idx == -1)
{
if(bClearIfNotFound)s = "";
@@ -845,7 +940,11 @@ namespace KviQString
void cutToLast(QString &s,const QChar &c,bool bIncluded,bool bClearIfNotFound)
{
+#ifdef COMPILE_USE_QT4
+ int idx = s.lastIndexOf(c);
+#else
int idx = s.findRev(c);
+#endif
if(idx == -1)
{
if(bClearIfNotFound)s = "";
@@ -856,21 +955,33 @@ namespace KviQString
void cutFromFirst(QString &s,const QString &c,bool bIncluded)
{
+#ifdef COMPILE_USE_QT4
+ int idx = s.indexOf(c);
+#else
int idx = s.find(c);
+#endif
if(idx == -1)return;
s.truncate(bIncluded ? idx : idx + c.length());
}
void cutFromLast(QString &s,const QString &c,bool bIncluded)
{
+#ifdef COMPILE_USE_QT4
+ int idx = s.lastIndexOf(c);
+#else
int idx = s.findRev(c);
+#endif
if(idx == -1)return;
s.truncate(bIncluded ? idx : idx + c.length());
}
void cutToFirst(QString &s,const QString &c,bool bIncluded,bool bClearIfNotFound)
{
+#ifdef COMPILE_USE_QT4
+ int idx = s.indexOf(c);
+#else
int idx = s.find(c);
+#endif
if(idx == -1)
{
if(bClearIfNotFound)s = "";
@@ -881,7 +992,11 @@ namespace KviQString
void cutToLast(QString &s,const QString &c,bool bIncluded,bool bClearIfNotFound)
{
+#ifdef COMPILE_USE_QT4
+ int idx = s.lastIndexOf(c);
+#else
int idx = s.findRev(c);
+#endif
if(idx == -1)
{
if(bClearIfNotFound)s = "";
@@ -946,7 +1061,7 @@ namespace KviQString
void transliterate(QString &s,const QString &szToFind,const QString &szReplacement)
{
int i=0;
- int il = QMIN(szToFind.length(),szReplacement.length());
+ int il = MY_MIN(szToFind.length(),szReplacement.length());
while(i < il)
{
int k=0;
@@ -964,7 +1079,11 @@ namespace KviQString
void bufferToHex(QString &szRetBuffer,const unsigned char * buffer,unsigned int len)
{
+#ifdef COMPILE_USE_QT4
+ szRetBuffer.resize(len * 2);
+#else
szRetBuffer.setLength(len * 2);
+#endif
unsigned int i=0;
while(i < (len*2))
{
diff --git a/src/kvilib/core/kvi_string.cpp b/src/kvilib/core/kvi_string.cpp
index 576996ff3..4b949de51 100644
--- a/src/kvilib/core/kvi_string.cpp
+++ b/src/kvilib/core/kvi_string.cpp
@@ -193,7 +193,11 @@ bool kvi_qstringEqualCI(const QString &s1,const QString &s2)
const QChar * p1 = s1.unicode();
const QChar * p2 = s2.unicode();
int l = s1.length() < s2.length() ? s1.length() : s2.length();
+#ifdef COMPILE_USE_QT4
+ while(l-- && (p1->toLower() == p2->toLower()))p1++,p2++;
+#else
while(l-- && (p1->lower() == p2->lower()))p1++,p2++;
+#endif
if(l==-1)return true;
return false;
}
@@ -742,7 +746,11 @@ int kvi_vsnprintf(char *buffer,int len,const char *fmt,kvi_va_list list)
case 'Q': // QString! (this should almost never happen)
{
QString * s = kvi_va_arg(list,QString *);
- QCString cs = s->utf8();
+#ifdef COMPILE_USE_QT4
+ _QCString cs = s->toUtf8();
+#else
+ _QCString cs = s->utf8();
+#endif
const char * t = cs.data();
if(!t)continue; // nothing to do
//check for space...
@@ -807,7 +815,11 @@ int kvi_irc_vsnprintf(char *buffer,const char *fmt,kvi_va_list list,bool *bTrunc
case 'Q': // QString! (this should almost never happen)
{
QString * s = kvi_va_arg(list,QString *);
- QCString cs = s->utf8();
+#ifdef COMPILE_USE_QT4
+ _QCString cs = s->toUtf8();
+#else
+ _QCString cs = s->utf8();
+#endif
const char * t = cs.data();
if(!t)continue; // nothing to do
while(*t)
@@ -1032,7 +1044,7 @@ KviStr::KviStr(const char *str)
}
}
-KviStr::KviStr(const QCString &str)
+KviStr::KviStr(const _QCString &str)
{
//Deep copy constructor
if(str.data())
@@ -1111,8 +1123,13 @@ KviStr::KviStr(const KviStr &str)
KviStr::KviStr(const QString &str)
{
- QCString sz = str.utf8();
- if(sz.length() > 0){
+#ifdef COMPILE_USE_QT4
+ _QCString sz = str.toUtf8();
+#else
+ _QCString sz = str.utf8();
+#endif
+ if(sz.length() > 0)
+ {
m_len = sz.length();
m_ptr = (char *)kvi_malloc(m_len+1);
kvi_fastmove(m_ptr,sz.data(),m_len+1);
@@ -1189,7 +1206,7 @@ KviStr & KviStr::operator=(const KviStr &str)
return (*this);
}
-KviStr & KviStr::operator=(const QCString &str)
+KviStr & KviStr::operator=(const _QCString &str)
{
m_len = str.length();
m_ptr = (char *)kvi_realloc(m_ptr,m_len+1);
@@ -1485,7 +1502,11 @@ KviStr & KviStr::setStr(const char *str,int len)
KviStr & KviStr::operator=(const QString &str)
{
- QCString sz =str.utf8();
+#ifdef COMPILE_USE_QT4
+ _QCString sz =str.toUtf8();
+#else
+ _QCString sz =str.utf8();
+#endif
if(sz.length() > 0){
m_len = sz.length();
m_ptr = (char *)kvi_realloc(m_ptr,m_len+1);
@@ -1534,7 +1555,11 @@ void KviStr::append(const char *str)
void KviStr::append(const QString &str)
{
- QCString sz=str.utf8();
+#ifdef COMPILE_USE_QT4
+ _QCString sz=str.toUtf8();
+#else
+ _QCString sz=str.utf8();
+#endif
if(sz.length() < 1)return;
m_ptr = (char *)kvi_realloc(m_ptr,m_len+sz.length()+1);
kvi_fastmove((m_ptr+m_len),sz.data(),sz.length()+1);
diff --git a/src/kvilib/core/kvi_string.h b/src/kvilib/core/kvi_string.h
index 519344577..a2ef6581f 100644
--- a/src/kvilib/core/kvi_string.h
+++ b/src/kvilib/core/kvi_string.h
@@ -36,8 +36,17 @@
#include <qglobal.h>
#include <qstring.h>
-#include <qcstring.h>
+#ifdef COMPILE_USE_QT4
+ #include <q3cstring.h> // includes <qbytearray.h>
+ #define _QCString QByteArray
+#else
+ // this is dead in Qt 4.x
+ #include <qcstring.h>
+ #define _QCString QCString
+#endif
+
+#include "kvi_inttypes.h"
#include "kvi_heapobject.h"
#include "kvi_stdarg.h"
@@ -90,8 +99,8 @@ __KVI_EXTERN KVILIB_API int kvi_strcmpCI(const char *str1,const char *str2);
__KVI_EXTERN KVILIB_API int kvi_strcmpCS(const char *str1,const char *str2);
// some wide char stuff
-typedef Q_UINT16 kvi_wchar_t;
-typedef Q_UINT32 kvi_wslen_t;
+typedef kvi_u16_t kvi_wchar_t;
+typedef kvi_u32_t kvi_wslen_t;
__KVI_EXTERN KVILIB_API kvi_wslen_t kvi_wstrlen(const kvi_wchar_t * str);
__KVI_EXTERN KVILIB_API int kvi_wvsnprintcf(kvi_wchar_t * buffer,kvi_wslen_t len,const char *fmt,kvi_va_list list);
@@ -147,7 +156,7 @@ public:
// Safe even if the QString is null.
KviStr(const QString &str);
- KviStr(const QCString &str);
+ KviStr(const _QCString &str);
// Fill sonstructor.
// Creates a string long fillLen characters filled with character c.<br>
@@ -256,7 +265,7 @@ public:
KviStr & operator=(const char *str); // str can be NULL here
KviStr & operator=(char c); // 2 bytes allocated ,m_len = 1
KviStr & operator=(const QString &str);
- KviStr & operator=(const QCString &str);
+ KviStr & operator=(const _QCString &str);
// Append operators
KviStr & operator+=(const KviStr &str) { append(str); return (*this); };
diff --git a/src/kvilib/core/kvi_valuelist.h b/src/kvilib/core/kvi_valuelist.h
new file mode 100644
index 000000000..4aeda319c
--- /dev/null
+++ b/src/kvilib/core/kvi_valuelist.h
@@ -0,0 +1,37 @@
+#ifndef _KVI_VALUELIST_H_
+#define _KVI_VALUELIST_H_
+//=================================================================================================
+//
+// File : kvi_valuelist.h
+// Creation date : Mon Jan 15 2007 04:53 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"
+
+#if COMPILE_USE_QT4
+ #include <q3valuelist.h>
+ #define KviValueList Q3ValueList
+#else
+ #include <qvaluelist.h>
+ #define KviValueList QValueList
+#endif
+
+#endif //_KVI_VALUELIST_H_
diff --git a/src/kvilib/ext/kvi_cmdformatter.cpp b/src/kvilib/ext/kvi_cmdformatter.cpp
index 536aa7873..1518433d4 100644
--- a/src/kvilib/ext/kvi_cmdformatter.cpp
+++ b/src/kvilib/ext/kvi_cmdformatter.cpp
@@ -63,7 +63,11 @@ namespace KviCommandFormatter
} else {
// we pretend this line to be empty
QString tmp = *it;
+#ifdef COMPILE_USE_QT4
+ tmp = tmp.trimmed();
+#else
tmp.stripWhiteSpace();
+#endif
if(!tmp.isEmpty())return false;
*it = ""; // set it to empty also in the main buffer
}
@@ -123,7 +127,11 @@ namespace KviCommandFormatter
void unindent(QString &buffer)
{
+#ifdef COMPILE_USE_QT4
+ QStringList list = buffer.split("\n",QString::KeepEmptyParts);
+#else
QStringList list = QStringList::split("\n",buffer,true);
+#endif
while(hasLeadingChars(list,QChar('\t')) || hasLeadingChars(list,QChar(' ')))trimLeading(list);
//buffer = list.join("\n"); join implementation sux :D
// we WANT the last newline
@@ -154,7 +162,11 @@ namespace KviCommandFormatter
void bufferFromBlock(QString &buffer)
{
+#ifdef COMPILE_USE_QT4
+ buffer = buffer.trimmed();
+#else
buffer.stripWhiteSpace();
+#endif
if(buffer.isEmpty())return;
@@ -168,7 +180,11 @@ namespace KviCommandFormatter
unindent(buffer);
- buffer = buffer.stripWhiteSpace();
+#ifdef COMPILE_USE_QT4
+ buffer = buffer.trimmed();
+#else
+ buffer.stripWhiteSpace();
+#endif
}
@@ -187,7 +203,11 @@ namespace KviCommandFormatter
void indent(QString &buffer)
{
+#ifdef COMPILE_USE_QT4
+ QStringList list = buffer.split("\n",QString::KeepEmptyParts);
+#else
QStringList list = QStringList::split("\n",buffer,true);
+#endif
addLeading(list,QChar('\t'));
//buffer = list.join("\n"); join implementation sux :D
// we WANT the last newline
diff --git a/src/kvilib/ext/kvi_config.cpp b/src/kvilib/ext/kvi_config.cpp
index 99728e648..0e40534ba 100644
--- a/src/kvilib/ext/kvi_config.cpp
+++ b/src/kvilib/ext/kvi_config.cpp
@@ -46,7 +46,7 @@ KviConfig::KviConfig(const QString &filename,FileMode f)
m_szGroup = KVI_CONFIG_DEFAULT_GROUP;
m_bPreserveEmptyGroups = false;
m_bReadOnly = (f == KviConfig::Read);
- m_pDict = new QDict<KviConfigGroup>(17,false);
+ m_pDict = new KviDict<KviConfigGroup>(17,false);
m_pDict->setAutoDelete(true);
if(f != KviConfig::Write)load();
}
@@ -58,7 +58,7 @@ KviConfig::KviConfig(const char* filename,FileMode f)
m_szGroup = KVI_CONFIG_DEFAULT_GROUP;
m_bPreserveEmptyGroups = false;
m_bReadOnly = (f == KviConfig::Read);
- m_pDict = new QDict<KviConfigGroup>(17,false);
+ m_pDict = new KviDict<KviConfigGroup>(17,false);
m_pDict->setAutoDelete(true);
if(f != KviConfig::Write)load();
}
@@ -73,7 +73,7 @@ KviConfig::~KviConfig()
void KviConfig::clear()
{
delete m_pDict;
- m_pDict = new QDict<KviConfigGroup>(17,false);
+ m_pDict = new KviDict<KviConfigGroup>(17,false);
m_pDict->setAutoDelete(true);
m_bDirty = false;
m_szGroup = KVI_CONFIG_DEFAULT_GROUP;
@@ -103,13 +103,13 @@ void KviConfig::getContentsString(KviStr &buffer)
buffer.append('\n');
int sections = 0;
int keys = 0;
- QDictIterator<KviStrDict> it(*m_pDict);
+ KviDictIterator<KviStrDict> it(*m_pDict);
while(it.current()){
buffer.append(" Section [");
buffer.append(it.currentKey());
buffer.append("]\n");
int sectionKeys = 0;
- QDictIterator<KviStr> it2(*it.current());
+ KviDictIterator<KviStr> it2(*it.current());
while(it2.current()){
buffer.append(" Key [");
buffer.append(it2.currentKey());
@@ -495,7 +495,7 @@ bool KviConfig::save()
if(!f.open(IO_WriteOnly | IO_Truncate))return false;
if(f.writeBlock("# KVIrc configuration file\n",27) != 27)return false;
- QDictIterator<KviConfigGroup> it(*m_pDict);
+ KviDictIterator<KviConfigGroup> it(*m_pDict);
while (it.current())
{
if((it.current()->count() != 0) || (m_bPreserveEmptyGroups))
@@ -636,9 +636,9 @@ void KviConfig::writeEntry(const QString & szKey,const QStringList &list)
p_group->replace(szKey,p_data);
}
-////////////////////////////////// QValueList<int>
+////////////////////////////////// KviValueList<int>
-QValueList<int> KviConfig::readIntListEntry(const QString & szKey,const QValueList<int> &list)
+KviValueList<int> KviConfig::readIntListEntry(const QString & szKey,const KviValueList<int> &list)
{
KviConfigGroup * p_group = getCurrentGroup();
QString * p_str = p_group->find(szKey);
@@ -648,7 +648,7 @@ QValueList<int> KviConfig::readIntListEntry(const QString & szKey,const QValueLi
return list;
}
QStringList sl = QStringList::split(",",*p_str);
- QValueList<int> ret;
+ KviValueList<int> ret;
//debug("Got option list for group %s and key %s: %s",m_szGroup.latin1(),szKey.latin1(),p_str->latin1());
@@ -663,12 +663,12 @@ QValueList<int> KviConfig::readIntListEntry(const QString & szKey,const QValueLi
}
-void KviConfig::writeEntry(const QString & szKey,const QValueList<int> &list)
+void KviConfig::writeEntry(const QString & szKey,const KviValueList<int> &list)
{
m_bDirty = true;
KviConfigGroup * p_group = getCurrentGroup();
KviStr szData;
- for(QValueList<int>::ConstIterator it = list.begin();it != list.end();++it)
+ for(KviValueList<int>::ConstIterator it = list.begin();it != list.end();++it)
{
if(szData.hasData())szData.append(',');
szData.append(KviStr::Format,"%d",*it);
diff --git a/src/kvilib/ext/kvi_config.h b/src/kvilib/ext/kvi_config.h
index b1e2cb653..0d6721c8b 100644
--- a/src/kvilib/ext/kvi_config.h
+++ b/src/kvilib/ext/kvi_config.h
@@ -28,22 +28,22 @@
#include "kvi_string.h"
#include "kvi_settings.h"
#include "kvi_heapobject.h"
+#include "kvi_dict.h"
+#include "kvi_valuelist.h"
-#include <qdict.h>
#include <qcolor.h>
#include <qfont.h>
#include <qrect.h>
#include <qstringlist.h>
-#include <qvaluelist.h>
#define KVI_CONFIG_DEFAULT_GROUP "KVIrc"
class KviPixmap;
class KviMsgType;
-typedef QDict<QString> KviConfigGroup;
-typedef QDictIterator<QString> KviConfigGroupIterator;
-typedef QDictIterator<KviConfigGroup> KviConfigIterator;
+typedef KviDict<QString> KviConfigGroup;
+typedef KviDictIterator<QString> KviConfigGroupIterator;
+typedef KviDictIterator<KviConfigGroup> KviConfigIterator;
class KVILIB_API KviConfig : public KviHeapObject
{
@@ -54,7 +54,7 @@ public:
KviConfig(const char *filename,FileMode f/* = ReadWrite*/);
~KviConfig();
private:
- QDict<KviConfigGroup> * m_pDict;
+ KviDict<KviConfigGroup> * m_pDict;
QString m_szFileName;
bool m_bDirty;
QString m_szStrBuffer;
@@ -88,7 +88,7 @@ public:
// as default configuration, alter its settings and save it to the
// user local configuration directory
void setSavePath(const QString & savePath){ m_szFileName = savePath; };
- QDict<KviConfigGroup> *dict(){ return m_pDict; };
+ KviDict<KviConfigGroup> *dict(){ return m_pDict; };
void clearDirtyFlag(){ m_bDirty = false; };
void clear();
@@ -124,8 +124,8 @@ public:
void writeEntry(const QString & szKey,const QRect &rct);
QStringList readStringListEntry(const QString & szKey,const QStringList &list);
void writeEntry(const QString & szKey,const QStringList &list);
- QValueList<int> readIntListEntry(const QString & ,const QValueList<int> &list);
- void writeEntry(const QString & szKey,const QValueList<int> &list);
+ KviValueList<int> readIntListEntry(const QString & ,const KviValueList<int> &list);
+ void writeEntry(const QString & szKey,const KviValueList<int> &list);
QString readQStringEntry(const QString & szKey,const QString &szDefault = QString::null)
{ return readEntry(szKey,szDefault); };
//void writeEntry(const QString & szKey,const QString &szValue);
diff --git a/src/kvilib/system/kvi_locale.cpp b/src/kvilib/system/kvi_locale.cpp
index 7b812355f..2c5570412 100644
--- a/src/kvilib/system/kvi_locale.cpp
+++ b/src/kvilib/system/kvi_locale.cpp
@@ -34,7 +34,6 @@
#include "kvi_locale.h"
#include <qglobal.h> //for debug()
-#include <qasciidict.h>
#include <qtextcodec.h>
#include <qdir.h>
@@ -43,13 +42,12 @@
#include "kvi_fileutils.h"
-static KviStr g_szLang;
-static KviTranslator * g_pTranslator = 0;
-KVILIB_API KviMessageCatalogue * g_pMainCatalogue = 0;
-static QAsciiDict<KviMessageCatalogue> * g_pCatalogueDict = 0;
-static QTextCodec * g_pUtf8TextCodec = 0;
-
+KVILIB_API KviMessageCatalogue * g_pMainCatalogue = 0;
+static KviStr g_szLang;
+static KviTranslator * g_pTranslator = 0;
+static KviAsciiDict<KviMessageCatalogue> * g_pCatalogueDict = 0;
+static QTextCodec * g_pUtf8TextCodec = 0;
// Code point 1st byte 2nd byte 3rd byte 4th byte
@@ -193,8 +191,13 @@ public:
virtual int mibEnum () const { return 0; };
virtual QTextDecoder * makeDecoder () const { return m_pRecvCodec->makeDecoder(); };
virtual QTextEncoder * makeEncoder () const { return m_pSendCodec->makeEncoder(); };
- QCString fromUnicode ( const QString & uc ) const { return m_pSendCodec->fromUnicode(uc); };
- virtual QCString fromUnicode ( const QString & uc, int & lenInOut ) const { return m_pSendCodec->fromUnicode(uc,lenInOut); };
+#ifdef COMPILE_USE_QT4
+ QByteArray fromUnicode (const QString & uc) const { return m_pSendCodec->fromUnicode(uc); };
+ virtual QByteArray fromUnicode (const QString & uc,int & lenInOut) const { return m_pSendCodec->fromUnicode(uc,lenInOut); };
+#else
+ QCString fromUnicode (const QString & uc) const { return m_pSendCodec->fromUnicode(uc); };
+ virtual QCString fromUnicode (const QString & uc,int & lenInOut) const { return m_pSendCodec->fromUnicode(uc,lenInOut); };
+#endif
QString toUnicode(const char * chars) const
{
if(may_be_utf8((const unsigned char *)chars))return g_pUtf8TextCodec->toUnicode(chars);
@@ -215,6 +218,7 @@ public:
if(may_be_utf8((const unsigned char *)(a.data()),a.size()))return g_pUtf8TextCodec->toUnicode(a);
return m_pRecvCodec->toUnicode(a);
};
+#ifndef COMPILE_USE_QT4
QString toUnicode(const QCString & a,int len) const
{
if(may_be_utf8((const unsigned char *)(a.data()),len))return g_pUtf8TextCodec->toUnicode(a,len);
@@ -225,6 +229,7 @@ public:
if(may_be_utf8((const unsigned char *)(a.data())))return g_pUtf8TextCodec->toUnicode(a);
return m_pRecvCodec->toUnicode(a);
};
+#endif
virtual bool canEncode(QChar ch) const { return m_pSendCodec->canEncode(ch); };
virtual bool canEncode(const QString &s) const { return m_pSendCodec->canEncode(s); };
virtual int heuristicContentMatch(const char * chars,int len) const
@@ -236,7 +241,7 @@ public:
virtual int heuristicNameMatch(const char * hint) const { return 0; };
};
-static QAsciiDict<KviSmartTextCodec> * g_pSmartCodecDict = 0;
+static KviAsciiDict<KviSmartTextCodec> * g_pSmartCodecDict = 0;
@@ -342,7 +347,7 @@ KviMessageCatalogue::KviMessageCatalogue()
//m_uEncoding = 0;
m_pTextCodec = QTextCodec::codecForLocale();
- m_pMessages = new QAsciiDict<KviTranslationEntry>(1123,true,false); // dictSize, case sensitive , don't copy keys
+ m_pMessages = new KviAsciiDict<KviTranslationEntry>(1123,true,false); // dictSize, case sensitive , don't copy keys
m_pMessages->setAutoDelete(true);
}
@@ -596,92 +601,92 @@ namespace KviLocale
{ "CP874" , 0 , 0 , "CP874" },
// smart codecs that send in the local charset
- { "ISO-8859-1 (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / Western Latin-1, O: Western Latin-1" },
- { "ISO-8859-2 (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / Central European 1, O: Central European 1" },
- { "ISO-8859-3 (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / Central European 2, O: Central European 2" },
- { "ISO-8859-4 (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / Baltic, Standard, O: Baltic, Standard" },
- { "ISO-8859-5 (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / Cyrillic, ISO, O: Cyrillic, ISO" },
- { "ISO-8859-6 (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / Arabic, Standard, O: Arabic, Standard" },
- { "ISO-8859-7 (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / Greek, O: Greek" },
- { "ISO-8859-8 (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / Hebrew, visually ordered, O: Hebrew, visually ordered" },
- { "ISO-8859-8-i (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / Hebrew, logically ordered, O: Hebrew, logically ordered" },
- { "ISO-8859-9 (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / Turkish, Latin-5, O: Turkish, Latin-5" },
- { "ISO-8859-15 (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / Western, Latin-1 + Euro, O: Western, Latin-1 + Euro" },
- { "KOI8-R (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / Cyrillic, KOI, O: Cyrillic, KOI" },
- { "KOI8-U (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / Ukrainian, O: Ukrainian" },
- { "CP-1250 (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / Central European 3, O: Central European 3" },
- { "CP-1251 (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / Cyrillic, Windows, O: Cyrillic, Windows" },
- { "CP-1252 (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / Western, CP, O: Western, CP" },
- { "CP-1253 (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / Greek, CP, O: Greek, CP" },
- { "CP-1256 (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / Arabic, CP, O: Arabic, CP" },
- { "CP-1257 (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / Baltic, CP, O: Baltic, CP" },
- { "CP-1255 (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / Hebrew, CP, O: Hebrew, CP" },
- { "CP-1254 (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / Turkish, CP, O: Turkish, CP" },
- { "TIS-620 (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / Thai, O: Thai" },
+ { "ISO-8859-1 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Western Latin-1, O: Western Latin-1" },
+ { "ISO-8859-2 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Central European 1, O: Central European 1" },
+ { "ISO-8859-3 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Central European 2, O: Central European 2" },
+ { "ISO-8859-4 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Baltic, Standard, O: Baltic, Standard" },
+ { "ISO-8859-5 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Cyrillic, ISO, O: Cyrillic, ISO" },
+ { "ISO-8859-6 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Arabic, Standard, O: Arabic, Standard" },
+ { "ISO-8859-7 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Greek, O: Greek" },
+ { "ISO-8859-8 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Hebrew, visually ordered, O: Hebrew, visually ordered" },
+ { "ISO-8859-8-i [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Hebrew, logically ordered, O: Hebrew, logically ordered" },
+ { "ISO-8859-9 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Turkish, Latin-5, O: Turkish, Latin-5" },
+ { "ISO-8859-15 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Western, Latin-1 + Euro, O: Western, Latin-1 + Euro" },
+ { "KOI8-R [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Cyrillic, KOI, O: Cyrillic, KOI" },
+ { "KOI8-U [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Ukrainian, O: Ukrainian" },
+ { "CP-1250 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Central European 3, O: Central European 3" },
+ { "CP-1251 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Cyrillic, Windows, O: Cyrillic, Windows" },
+ { "CP-1252 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Western, CP, O: Western, CP" },
+ { "CP-1253 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Greek, CP, O: Greek, CP" },
+ { "CP-1256 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Arabic, CP, O: Arabic, CP" },
+ { "CP-1257 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Baltic, CP, O: Baltic, CP" },
+ { "CP-1255 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Hebrew, CP, O: Hebrew, CP" },
+ { "CP-1254 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Turkish, CP, O: Turkish, CP" },
+ { "TIS-620 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Thai, O: Thai" },
#ifndef QT_NO_BIG_CODECS
- { "Big5 (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / Chinese Traditional, O: Chinese Traditional" },
- { "Big5-HKSCS (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / Chinese Traditional, Hong Kong, O: Chinese Traditional, Hong Kong" },
- { "GB18030 (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / Chinese Simplified, O: Chinese Simplified" },
- { "JIS7 (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / Japanese (JIS7), O: Japanese " },
- { "Shift-JIS (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / Japanese (Shift-JIS), O: Japanese (Shift-JIS)" },
- { "EUC-JP (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / Japanese (EUC-JP), O: Japanese (EUC-JP)" },
- { "EUC-KR (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / Korean, O: Korean" },
- { "TSCII (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / Tamil, O: Tamil" },
+ { "Big5 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Chinese Traditional, O: Chinese Traditional" },
+ { "Big5-HKSCS [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Chinese Traditional, Hong Kong, O: Chinese Traditional, Hong Kong" },
+ { "GB18030 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Chinese Simplified, O: Chinese Simplified" },
+ { "JIS7 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Japanese (JIS7), O: Japanese " },
+ { "Shift-JIS [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Japanese (Shift-JIS), O: Japanese (Shift-JIS)" },
+ { "EUC-JP [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Japanese (EUC-JP), O: Japanese (EUC-JP)" },
+ { "EUC-KR [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Korean, O: Korean" },
+ { "TSCII [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Tamil, O: Tamil" },
#endif
- { "ISO-8859-10 (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / ISO-8859-10, O: ISO-8859-10" },
- { "ISO-8859-13 (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / ISO-8859-13, O: ISO-8859-13" },
- { "ISO-8859-14 (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / ISO-8859-14, O: ISO-8859-14" },
- { "IBM-850 (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / IBM-850, O: IBM-850" },
- { "IBM-866 (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / IBM-866, O: IBM-866" },
- { "CP874 (UTF-8)" , 1 , 0 , "I: 8-bit Unicode / CP874, O: CP874" },
+ { "ISO-8859-10 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / ISO-8859-10, O: ISO-8859-10" },
+ { "ISO-8859-13 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / ISO-8859-13, O: ISO-8859-13" },
+ { "ISO-8859-14 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / ISO-8859-14, O: ISO-8859-14" },
+ { "IBM-850 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / IBM-850, O: IBM-850" },
+ { "IBM-866 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / IBM-866, O: IBM-866" },
+ { "CP874 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / CP874, O: CP874" },
// smart codecs that send in utf8
- { "UTF-8 (ISO-8859-1)" , 1 , 1 , "I: 8-bit Unicode / Western Latin-1, O: 8-bit Unicode" },
- { "UTF-8 (ISO-8859-2)" , 1 , 1 , "I: 8-bit Unicode / Central European 1, O: 8-bit Unicode" },
- { "UTF-8 (ISO-8859-3)" , 1 , 1 , "I: 8-bit Unicode / Central European 2, O: 8-bit Unicode" },
- { "UTF-8 (ISO-8859-4)" , 1 , 1 , "I: 8-bit Unicode / Baltic, Standard, O: 8-bit Unicode" },
+ { "UTF-8 [ISO-8859-1]" , 1 , 1 , "I: 8-bit Unicode / Western Latin-1, O: 8-bit Unicode" },
+ { "UTF-8 [ISO-8859-2]" , 1 , 1 , "I: 8-bit Unicode / Central European 1, O: 8-bit Unicode" },
+ { "UTF-8 [ISO-8859-3]" , 1 , 1 , "I: 8-bit Unicode / Central European 2, O: 8-bit Unicode" },
+ { "UTF-8 [ISO-8859-4]" , 1 , 1 , "I: 8-bit Unicode / Baltic, Standard, O: 8-bit Unicode" },
- { "UTF-8 (ISO-8859-5)" , 1 , 1 , "I: 8-bit Unicode / Cyrillic, ISO, O: 8-bit Unicode" },
- { "UTF-8 (ISO-8859-6)" , 1 , 1 , "I: 8-bit Unicode / Arabic, Standard, O: 8-bit Unicode" },
- { "UTF-8 (ISO-8859-7)" , 1 , 1 , "I: 8-bit Unicode / Greek, O: 8-bit Unicode" },
- { "UTF-8 (ISO-8859-8)" , 1 , 1 , "I: 8-bit Unicode / Hebrew, visually ordered, O: 8-bit Unicode" },
+ { "UTF-8 [ISO-8859-5]" , 1 , 1 , "I: 8-bit Unicode / Cyrillic, ISO, O: 8-bit Unicode" },
+ { "UTF-8 [ISO-8859-6]" , 1 , 1 , "I: 8-bit Unicode / Arabic, Standard, O: 8-bit Unicode" },
+ { "UTF-8 [ISO-8859-7]" , 1 , 1 , "I: 8-bit Unicode / Greek, O: 8-bit Unicode" },
+ { "UTF-8 [ISO-8859-8]" , 1 , 1 , "I: 8-bit Unicode / Hebrew, visually ordered, O: 8-bit Unicode" },
- { "UTF-8 (ISO-8859-8-i)" , 1 , 1 , "I: 8-bit Unicode / Hebrew, logically ordered, O: 8-bit Unicode" },
- { "UTF-8 (ISO-8859-9)" , 1 , 1 , "I: 8-bit Unicode / Turkish, Latin-5, O: 8-bit Unicode" },
- { "UTF-8 (ISO-8859-15)" , 1 , 1 , "I: 8-bit Unicode / Western, Latin-1 + Euro, O: 8-bit Unicode" },
- { "UTF-8 (KOI8-R)" , 1 , 1 , "I: 8-bit Unicode / Cyrillic, KOI, O: 8-bit Unicode" },
+ { "UTF-8 [ISO-8859-8-i]" , 1 , 1 , "I: 8-bit Unicode / Hebrew, logically ordered, O: 8-bit Unicode" },
+ { "UTF-8 [ISO-8859-9]" , 1 , 1 , "I: 8-bit Unicode / Turkish, Latin-5, O: 8-bit Unicode" },
+ { "UTF-8 [ISO-8859-15]" , 1 , 1 , "I: 8-bit Unicode / Western, Latin-1 + Euro, O: 8-bit Unicode" },
+ { "UTF-8 [KOI8-R]" , 1 , 1 , "I: 8-bit Unicode / Cyrillic, KOI, O: 8-bit Unicode" },
- { "UTF-8 (KOI8-U)" , 1 , 1 , "I: 8-bit Unicode / Ukrainian, O: 8-bit Unicode" },
- { "UTF-8 (CP-1250)" , 1 , 1 , "I: 8-bit Unicode / Central European 3, O: 8-bit Unicode" },
- { "UTF-8 (CP-1251)" , 1 , 1 , "I: 8-bit Unicode / Cyrillic, Windows, O: 8-bit Unicode" },
- { "UTF-8 (CP-1252)" , 1 , 1 , "I: 8-bit Unicode / Western, CP, O: 8-bit Unicode" },
+ { "UTF-8 [KOI8-U]" , 1 , 1 , "I: 8-bit Unicode / Ukrainian, O: 8-bit Unicode" },
+ { "UTF-8 [CP-1250]" , 1 , 1 , "I: 8-bit Unicode / Central European 3, O: 8-bit Unicode" },
+ { "UTF-8 [CP-1251]" , 1 , 1 , "I: 8-bit Unicode / Cyrillic, Windows, O: 8-bit Unicode" },
+ { "UTF-8 [CP-1252]" , 1 , 1 , "I: 8-bit Unicode / Western, CP, O: 8-bit Unicode" },
- { "UTF-8 (CP-1253)" , 1 , 1 , "I: 8-bit Unicode / Greek, CP, O: 8-bit Unicode" },
- { "UTF-8 (CP-1256)" , 1 , 1 , "I: 8-bit Unicode / Arabic, CP, O: 8-bit Unicode" },
- { "UTF-8 (CP-1257)" , 1 , 1 , "I: 8-bit Unicode / Baltic, CP, O: 8-bit Unicode" },
- { "UTF-8 (CP-1255)" , 1 , 1 , "I: 8-bit Unicode / Hebrew, CP, O: 8-bit Unicode" },
+ { "UTF-8 [CP-1253]" , 1 , 1 , "I: 8-bit Unicode / Greek, CP, O: 8-bit Unicode" },
+ { "UTF-8 [CP-1256]" , 1 , 1 , "I: 8-bit Unicode / Arabic, CP, O: 8-bit Unicode" },
+ { "UTF-8 [CP-1257]" , 1 , 1 , "I: 8-bit Unicode / Baltic, CP, O: 8-bit Unicode" },
+ { "UTF-8 [CP-1255]" , 1 , 1 , "I: 8-bit Unicode / Hebrew, CP, O: 8-bit Unicode" },
- { "UTF-8 (CP-1254)" , 1 , 1 , "I: 8-bit Unicode / Turkish, CP, O: 8-bit Unicode" },
- { "UTF-8 (TIS-620)" , 1 , 1 , "I: 8-bit Unicode / Thai, O: 8-bit Unicode" },
+ { "UTF-8 [CP-1254]" , 1 , 1 , "I: 8-bit Unicode / Turkish, CP, O: 8-bit Unicode" },
+ { "UTF-8 [TIS-620]" , 1 , 1 , "I: 8-bit Unicode / Thai, O: 8-bit Unicode" },
#ifndef QT_NO_BIG_CODECS
- { "UTF-8 (Big5)" , 1 , 1 , "I: 8-bit Unicode / Chinese Traditional, O: 8-bit Unicode" },
- { "UTF-8 (Big5-HKSCS)" , 1 , 1 , "I: 8-bit Unicode / Chinese Traditional, Hong Kong, O: 8-bit Unicode" },
+ { "UTF-8 [Big5]" , 1 , 1 , "I: 8-bit Unicode / Chinese Traditional, O: 8-bit Unicode" },
+ { "UTF-8 [Big5-HKSCS]" , 1 , 1 , "I: 8-bit Unicode / Chinese Traditional, Hong Kong, O: 8-bit Unicode" },
- { "UTF-8 (GB18030)" , 1 , 1 , "I: 8-bit Unicode / Chinese Simplified, O: 8-bit Unicode" },
- { "UTF-8 (JIS7)" , 1 , 1 , "I: 8-bit Unicode / Japanese (JIS7), O: 8-bit Unicode" },
- { "UTF-8 (Shift-JIS)" , 1 , 1 , "I: 8-bit Unicode / Japanese (Shift-JIS), O: Japanese (Shift-JIS)" },
- { "UTF-8 (EUC-JP)" , 1 , 1 , "I: 8-bit Unicode / Japanese (EUC-JP), O: Japanese (EUC-JP)" },
+ { "UTF-8 [GB18030]" , 1 , 1 , "I: 8-bit Unicode / Chinese Simplified, O: 8-bit Unicode" },
+ { "UTF-8 [JIS7]" , 1 , 1 , "I: 8-bit Unicode / Japanese (JIS7), O: 8-bit Unicode" },
+ { "UTF-8 [Shift-JIS]" , 1 , 1 , "I: 8-bit Unicode / Japanese (Shift-JIS), O: Japanese (Shift-JIS)" },
+ { "UTF-8 [EUC-JP]" , 1 , 1 , "I: 8-bit Unicode / Japanese (EUC-JP), O: Japanese (EUC-JP)" },
- { "UTF-8 (EUC-KR)" , 1 , 1 , "I: 8-bit Unicode / Korean, O: 8-bit Unicode" },
- { "UTF-8 (TSCII)" , 1 , 1 , "I: 8-bit Unicode / Tamil, O: 8-bit Unicode" },
+ { "UTF-8 [EUC-KR]" , 1 , 1 , "I: 8-bit Unicode / Korean, O: 8-bit Unicode" },
+ { "UTF-8 [TSCII]" , 1 , 1 , "I: 8-bit Unicode / Tamil, O: 8-bit Unicode" },
#endif
- { "UTF-8 (ISO-8859-10)" , 1 , 1 , "I: 8-bit Unicode / ISO-8859-10, O: 8-bit Unicode" },
- { "UTF-8 (ISO-8859-13)" , 1 , 1 , "I: 8-bit Unicode / ISO-8859-13, O: 8-bit Unicode" },
+ { "UTF-8 [ISO-8859-10]" , 1 , 1 , "I: 8-bit Unicode / ISO-8859-10, O: 8-bit Unicode" },
+ { "UTF-8 [ISO-8859-13]" , 1 , 1 , "I: 8-bit Unicode / ISO-8859-13, O: 8-bit Unicode" },
- { "UTF-8 (ISO-8859-14)" , 1 , 1 , "I: 8-bit Unicode / ISO-8859-14, O: 8-bit Unicode" },
- { "UTF-8 (IBM-850)" , 1 , 1 , "I: 8-bit Unicode / IBM-850, O: 8-bit Unicode" },
- { "UTF-8 (IBM-866)" , 1 , 1 , "I: 8-bit Unicode / IBM-866, O: 8-bit Unicode" },
- { "UTF-8 (CP874)" , 1 , 1 , "I: 8-bit Unicode / CP874, O: 8-bit Unicode" },
+ { "UTF-8 [ISO-8859-14]" , 1 , 1 , "I: 8-bit Unicode / ISO-8859-14, O: 8-bit Unicode" },
+ { "UTF-8 [IBM-850]" , 1 , 1 , "I: 8-bit Unicode / IBM-850, O: 8-bit Unicode" },
+ { "UTF-8 [IBM-866]" , 1 , 1 , "I: 8-bit Unicode / IBM-866, O: 8-bit Unicode" },
+ { "UTF-8 [CP874]" , 1 , 1 , "I: 8-bit Unicode / CP874, O: 8-bit Unicode" },
{ 0 , 0 , 0 , 0 }
};
@@ -695,21 +700,22 @@ namespace KviLocale
QTextCodec * codecForName(const char * szName)
{
KviStr szTmp = szName;
- int idx = szTmp.findFirstIdx('(');
+ int idx = szTmp.findFirstIdx('[');
if(idx != -1)
{
- // composite codec: either UTF-8 (child codec) or child codec (UTF-8)
+ // composite codec: either UTF-8 [child codec] or child codec [UTF-8]
KviSmartTextCodec * c = g_pSmartCodecDict->find(szName);
if(c)return c;
- szTmp.replaceAll("UTF-8 (","");
- szTmp.replaceAll(")","");
- if(kvi_strEqualCIN("UTF-8 (",szName,7))
+ if(kvi_strEqualCIN("UTF-8 [",szName,7))
{
+ szTmp.replaceAll("UTF-8 [","");
+ szTmp.replaceAll("]","");
// smart codec that sends UTF-8
c = new KviSmartTextCodec(szName,szTmp.ptr(),true);
} else {
+ szTmp.cutFromFirst(' ');
// smart codec that sends child encoding
c = new KviSmartTextCodec(szName,szTmp.ptr(),false);
}
@@ -832,11 +838,11 @@ namespace KviLocale
// the main catalogue is supposed to be kvirc_<language>.mo
g_pMainCatalogue = new KviMessageCatalogue();
// the catalogue dict
- g_pCatalogueDict = new QAsciiDict<KviMessageCatalogue>;
+ g_pCatalogueDict = new KviAsciiDict<KviMessageCatalogue>;
g_pCatalogueDict->setAutoDelete(true);
// the smart codec dict
- g_pSmartCodecDict = new QAsciiDict<KviSmartTextCodec>;
+ g_pSmartCodecDict = new KviAsciiDict<KviSmartTextCodec>;
// the Qt docs explicitly state that we shouldn't delete
// the codecs by ourselves...
g_pSmartCodecDict->setAutoDelete(false);
@@ -930,7 +936,11 @@ namespace KviLocale
};
KviTranslator::KviTranslator(QObject * par,const char * nam)
+#ifdef COMPILE_USE_QT4
+: QTranslator(par)
+#else
: QTranslator(par,nam)
+#endif
{
}
@@ -938,17 +948,27 @@ KviTranslator::~KviTranslator()
{
}
+#ifdef COMPILE_USE_QT4
+QString KviTranslator::translate(const char *context,const char * message,const char * comment) const
+{
+ // we ignore contexts and comments for qt translations
+ return g_pMainCatalogue->translateToQString(message);
+}
+#endif
+
QString KviTranslator::find(const char *context,const char * message) const
{
// we ignore contexts for qt translations
return g_pMainCatalogue->translateToQString(message);
}
+#ifndef COMPILE_USE_QT4
QTranslatorMessage KviTranslator::findMessage(const char * context,const char * sourceText,const char * comment) const
{
// we ignore contexts for qt translations
return QTranslatorMessage(context,sourceText,comment,g_pMainCatalogue->translateToQString(sourceText));
}
+#endif
#if 0
diff --git a/src/kvilib/system/kvi_locale.h b/src/kvilib/system/kvi_locale.h
index 2cce46799..a138fd6d8 100644
--- a/src/kvilib/system/kvi_locale.h
+++ b/src/kvilib/system/kvi_locale.h
@@ -29,6 +29,7 @@
#include "kvi_settings.h"
#include "kvi_qstring.h"
#include "kvi_string.h"
+#include "kvi_asciidict.h"
#include <qapplication.h>
@@ -93,8 +94,8 @@ public:
KviMessageCatalogue();
~KviMessageCatalogue();
protected:
- QAsciiDict<KviTranslationEntry> * m_pMessages;
- QTextCodec * m_pTextCodec;
+ KviAsciiDict<KviTranslationEntry> * m_pMessages;
+ QTextCodec * m_pTextCodec;
public:
bool load(const QString& name);
const char * translate(const char * text);
@@ -129,8 +130,15 @@ class KVILIB_API KviTranslator : public QTranslator
KviTranslator(QObject * parent,const char * name);
~KviTranslator();
public:
+#ifdef COMPILE_USE_QT4
+ virtual QString translate(const char * context,const char * message,const char * comment) const;
+#endif
+ // Deprecated in qt 4.x
virtual QString find(const char * context,const char * message) const;
+#ifndef COMPILE_USE_QT4
+ // Dead in qt 4.x
virtual QTranslatorMessage findMessage(const char * context,const char * sourceText,const char * comment = 0) const;
+#endif
};
diff --git a/src/kvirc/kernel/kvi_app.h b/src/kvirc/kernel/kvi_app.h
index de6bbe961..5931bbe7c 100644
--- a/src/kvirc/kernel/kvi_app.h
+++ b/src/kvirc/kernel/kvi_app.h
@@ -185,7 +185,7 @@ public:
void getGlobalKvircDirectory(KviStr &szData,KvircSubdir dir,const QString &appendFile = QString::null);
void getLocalKvircDirectory(KviStr &szData,KvircSubdir dir,const QString &appendFile = QString::null,bool bCreateIfNeeded = true);
void getLocalKvircDirectory(QString &szData,KvircSubdir dir,const QString &appendFile = QString::null,bool bCreateIfNeeded = true);
- void getTmpFileName(KviStr &szBuffer,const char * pattern = 0);
+ void getTmpFileName(QString &szBuffer,const QString &szEndingFileName = QString::null);
bool trashFile(const char *filename);
void getChannelDumpLogFileName(KviStr &str);
diff --git a/src/kvirc/kernel/kvi_app_fs.cpp b/src/kvirc/kernel/kvi_app_fs.cpp
index 1c24cb2ab..7e56bf1d7 100644
--- a/src/kvirc/kernel/kvi_app_fs.cpp
+++ b/src/kvirc/kernel/kvi_app_fs.cpp
@@ -190,19 +190,21 @@ void KviApp::getLocalKvircDirectory(KviStr &szData,KvircSubdir dir,const QString
szData=szBuffer;
}
-void KviApp::getTmpFileName(KviStr &szBuffer,const char * pattern)
+void KviApp::getTmpFileName(QString &szBuffer,const QString &szEndingFileName)
{
- KviStr tmp;
+ QString tmp;
getLocalKvircDirectory(tmp,Tmp);
- tmp.ensureLastCharIs(KVI_PATH_SEPARATOR_CHAR);
+ KviQString::ensureLastCharIs(tmp,KVI_PATH_SEPARATOR_CHAR);
struct timeval tmv;
kvi_gettimeofday(&tmv,0);
+ QString szFileName = szEndingFileName.isNull() ? QString("file.tmp") : szEndingFileName;
do {
- szBuffer.append(KviStr::Format,"kvirc_%d_%s",tmv.tv_usec,pattern ? pattern : "file.tmp");
+ szBuffer = tmp;
+ KviQString::appendFormatted(szBuffer,"kvirc_%d_%Q",tmv.tv_usec,&szFileName);
tmv.tv_usec++;
- } while(KviFileUtils::fileExists(szBuffer.ptr()));
+ } while(KviFileUtils::fileExists(szBuffer));
}
//====================== trashFile ====================//
diff --git a/src/kvirc/kernel/kvi_coreactionnames.h b/src/kvirc/kernel/kvi_coreactionnames.h
index 18080825a..50539a46c 100644
--- a/src/kvirc/kernel/kvi_coreactionnames.h
+++ b/src/kvirc/kernel/kvi_coreactionnames.h
@@ -64,5 +64,6 @@
#define KVI_COREACTION_MANAGEADDONS (KVI_COREACTION_NAME_PREFIX "manageaddons")
#define KVI_COREACTION_THEMEOPTIONS (KVI_COREACTION_NAME_PREFIX "themeoptions")
#define KVI_COREACTION_MANAGETHEMES (KVI_COREACTION_NAME_PREFIX "managethemes")
+#define KVI_COREACTION_SCREENSHOT (KVI_COREACTION_NAME_PREFIX "screenshot")
#endif //!_KVI_COREACTIONNAMES_H_
diff --git a/src/kvirc/kernel/kvi_coreactions.cpp b/src/kvirc/kernel/kvi_coreactions.cpp
index dc9fc7c58..9b385be45 100644
--- a/src/kvirc/kernel/kvi_coreactions.cpp
+++ b/src/kvirc/kernel/kvi_coreactions.cpp
@@ -366,6 +366,17 @@ void register_core_actions(KviActionManager * m)
0,
QString::null);
+ SCRIPT_ACTION(
+ KVI_COREACTION_SCREENSHOT,
+ "theme.screenshot",
+ __tr2qs("Acquire Screenshot"),
+ __tr2qs("Acquires a Screenshot of the KVIrc main window"),
+ KviActionManager::categoryGeneric(),
+ "kvi_bigicon_screenshot.png",
+ KVI_SMALLICON_SCREENSHOT,
+ 0,
+ QString::null);
+
SLOT_ACTION(
KVI_COREACTION_CASCADEWINDOWS,
diff --git a/src/kvirc/kernel/kvi_iconmanager.cpp b/src/kvirc/kernel/kvi_iconmanager.cpp
index 610bdde74..4bef15837 100644
--- a/src/kvirc/kernel/kvi_iconmanager.cpp
+++ b/src/kvirc/kernel/kvi_iconmanager.cpp
@@ -341,7 +341,8 @@ static const char * g_szIconNames[KVI_NUM_SMALL_ICONS]=
"themeoptions", // 287
"bug", // 288
"refresh", //289
- "theme" // 290
+ "theme", // 290
+ "screenshot" // 291
};
KviIconWidget::KviIconWidget()
diff --git a/src/kvirc/kernel/kvi_iconmanager.h b/src/kvirc/kernel/kvi_iconmanager.h
index 2c7ab1219..dadc3c2ea 100644
--- a/src/kvirc/kernel/kvi_iconmanager.h
+++ b/src/kvirc/kernel/kvi_iconmanager.h
@@ -329,8 +329,9 @@
#define KVI_SMALLICON_BUG 288
#define KVI_SMALLICON_REFRESH 289
#define KVI_SMALLICON_THEME 290
+#define KVI_SMALLICON_SCREENSHOT 291
-#define KVI_NUM_SMALL_ICONS 291
+#define KVI_NUM_SMALL_ICONS 292
#define KVI_BIGICON_DISCONNECTED "kvi_bigicon_disconnected.png"
@@ -356,6 +357,7 @@
#define KVI_BIGICON_REMOVE "kvi_bigicon_remove.png"
#define KVI_BIGICON_WWW "kvi_bigicon_www.png"
#define KVI_BIGICON_PACK "kvi_bigicon_pack.png"
+#define KVI_BIGICON_SCREENSHOT "kvi_bigicon_screenshot.png"
#define KVI_SMALLICONS_SUBDIRECTORY "coresmall"
#define KVI_SMALLICONS_PREFIX "kcs_"
diff --git a/src/kvirc/kernel/kvi_theme.cpp b/src/kvirc/kernel/kvi_theme.cpp
index fee548535..1e3221b20 100644
--- a/src/kvirc/kernel/kvi_theme.cpp
+++ b/src/kvirc/kernel/kvi_theme.cpp
@@ -30,6 +30,11 @@
#include "kvi_miscutils.h"
#include "kvi_sourcesdate.h"
+#include <qimage.h>
+
+#define KVI_THEME_SMALL_SCREENSHOT_NAME "screenshot_small.png"
+#define KVI_THEME_MEDIUM_SCREENSHOT_NAME "screenshot_medium.png"
+#define KVI_THEME_LARGE_SCREENSHOT_NAME "screenshot.png"
KviThemeInfo::KviThemeInfo()
: KviHeapObject()
@@ -130,3 +135,159 @@ bool KviThemeInfo::loadFromDirectory(const QString &szThemeDirectory,bool bIgnor
return KviFileUtils::fileExists(szD);
}
+QString KviThemeInfo::smallScreenshotPath()
+{
+ QString ret;
+ if(!m_szAbsoluteDirectory.isEmpty())
+ {
+ ret = m_szAbsoluteDirectory;
+ KviQString::ensureLastCharIs(ret,KVI_PATH_SEPARATOR_CHAR);
+ ret.append(KVI_THEME_SMALL_SCREENSHOT_NAME);
+ }
+ return ret;
+}
+
+const QPixmap & KviThemeInfo::smallScreenshot()
+{
+ if(!m_pixScreenshotSmall.isNull())return m_pixScreenshotSmall;
+
+ if(!m_szAbsoluteDirectory.isEmpty())
+ {
+ QString szFileName = m_szAbsoluteDirectory;
+ KviQString::ensureLastCharIs(szFileName,KVI_PATH_SEPARATOR_CHAR);
+ szFileName.append(KVI_THEME_SMALL_SCREENSHOT_NAME);
+ QPixmap pix(szFileName);
+ if(!pix.isNull())
+ {
+ m_pixScreenshotSmall = pix;
+ return m_pixScreenshotSmall;
+ }
+ // try to scale it from the large one (and save it by the way)
+ pix = mediumScreenshot();
+ if(pix.isNull())return m_pixScreenshotSmall;
+
+ if(pix.width() > 300 || pix.height() > 225)
+ {
+ QImage sbri = pix.convertToImage();
+ pix.convertFromImage(sbri.smoothScale(300,225,QImage::ScaleMin));
+ }
+
+ pix.save(szFileName,"PNG");
+
+ m_pixScreenshotSmall = pix;
+ return m_pixScreenshotSmall;
+ }
+
+ return m_pixScreenshotSmall;
+}
+
+const QPixmap & KviThemeInfo::mediumScreenshot()
+{
+ if(!m_pixScreenshotMedium.isNull())return m_pixScreenshotMedium;
+
+ if(!m_szAbsoluteDirectory.isEmpty())
+ {
+ QString szFileName = m_szAbsoluteDirectory;
+ KviQString::ensureLastCharIs(szFileName,KVI_PATH_SEPARATOR_CHAR);
+ szFileName.append(KVI_THEME_MEDIUM_SCREENSHOT_NAME);
+ QPixmap pix(szFileName);
+ if(!pix.isNull())
+ {
+ m_pixScreenshotMedium = pix;
+ return m_pixScreenshotMedium;
+ }
+ // try to scale it from the large one (and save it by the way)
+ pix = largeScreenshot();
+ if(pix.isNull())return m_pixScreenshotMedium;
+
+ if(pix.width() > 600 || pix.height() > 450)
+ {
+ QImage sbri = pix.convertToImage();
+ pix.convertFromImage(sbri.smoothScale(600,450,QImage::ScaleMin));
+ }
+
+ pix.save(szFileName,"PNG");
+
+ m_pixScreenshotMedium = pix;
+ return m_pixScreenshotMedium;
+ }
+
+ return m_pixScreenshotMedium;
+}
+
+const QPixmap & KviThemeInfo::largeScreenshot()
+{
+ if(!m_pixScreenshotLarge.isNull())return m_pixScreenshotLarge;
+
+ if(!m_szAbsoluteDirectory.isEmpty())
+ {
+ QString szFileName = m_szAbsoluteDirectory;
+ KviQString::ensureLastCharIs(szFileName,KVI_PATH_SEPARATOR_CHAR);
+ szFileName.append(KVI_THEME_LARGE_SCREENSHOT_NAME);
+ QPixmap pix(szFileName);
+ if(pix.isNull())return m_pixScreenshotLarge;
+ m_pixScreenshotLarge = pix;
+ }
+ return m_pixScreenshotLarge;
+}
+
+
+namespace KviTheme
+{
+ bool saveScreenshots(KviThemeInfo &options,const QString &szOriginalScreenshotPath)
+ {
+ QImage pix(szOriginalScreenshotPath);
+ if(pix.isNull())
+ {
+ options.setLastError(__tr2qs("Failed to load the specified screenshot image"));
+ return false;
+ }
+
+ QPixmap out;
+
+ QString szScreenshotFileName = options.absoluteDirectory();
+ if(szScreenshotFileName.isEmpty())
+ {
+ options.setLastError(__tr2qs("Invalid option"));
+ return false;
+ }
+
+ KviQString::ensureLastCharIs(szScreenshotFileName,KVI_PATH_SEPARATOR_CHAR);
+ szScreenshotFileName.append(KVI_THEME_LARGE_SCREENSHOT_NAME);
+ if(!pix.save(szScreenshotFileName,"PNG"))
+ {
+ options.setLastError(__tr2qs("Failed to save the screenshot image"));
+ return false;
+ }
+
+ if(pix.width() > 600 || pix.height() > 450)
+ out.convertFromImage(pix.smoothScale(600,450,QImage::ScaleMin));
+ else
+ out.convertFromImage(pix);
+
+ szScreenshotFileName = options.absoluteDirectory();
+ KviQString::ensureLastCharIs(szScreenshotFileName,KVI_PATH_SEPARATOR_CHAR);
+ szScreenshotFileName.append(KVI_THEME_MEDIUM_SCREENSHOT_NAME);
+ if(!out.save(szScreenshotFileName,"PNG"))
+ {
+ options.setLastError(__tr2qs("Failed to save the screenshot image"));
+ return false;
+ }
+
+ if(pix.width() > 300 || pix.height() > 225)
+ out.convertFromImage(pix.smoothScale(300,225,QImage::ScaleMin));
+ else
+ out.convertFromImage(pix);
+
+ szScreenshotFileName = options.absoluteDirectory();
+ KviQString::ensureLastCharIs(szScreenshotFileName,KVI_PATH_SEPARATOR_CHAR);
+ szScreenshotFileName.append(KVI_THEME_SMALL_SCREENSHOT_NAME);
+ if(!out.save(szScreenshotFileName,"PNG"))
+ {
+ options.setLastError(__tr2qs("Failed to save the screenshot image"));
+ return false;
+ }
+
+ return true;
+ }
+};
diff --git a/src/kvirc/kernel/kvi_theme.h b/src/kvirc/kernel/kvi_theme.h
index 35f36e421..c4acfbdbf 100644
--- a/src/kvirc/kernel/kvi_theme.h
+++ b/src/kvirc/kernel/kvi_theme.h
@@ -31,6 +31,8 @@
#include "kvi_fileextensions.h"
+#include <qpixmap.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"
@@ -57,6 +59,10 @@ protected:
QString m_szThemeEngineVersion; // the theme engine version that saved this theme
QString m_szLastError; // reported when some function fails
+
+ QPixmap m_pixScreenshotLarge;
+ QPixmap m_pixScreenshotMedium;
+ QPixmap m_pixScreenshotSmall;
public:
// load a specified themeinfo file
bool load(const QString &szThemeFileName);
@@ -88,6 +94,14 @@ public:
// 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);
+
+ // Attempt to load the theme screenshot from THEMEDIR/screenshot_*.png
+ // These functions will work only if the absoluteDirectory() of the theme
+ // has been set, otherwise the returned pixmaps will be null.
+ const QPixmap & smallScreenshot();
+ const QPixmap & mediumScreenshot();
+ const QPixmap & largeScreenshot();
+ QString smallScreenshotPath();
};
namespace KviTheme
@@ -107,6 +121,9 @@ namespace KviTheme
// but this feature is actually unused.
// Note that for convenience this function is implemented in kvi_options.cpp
bool KVIRC_API save(KviThemeInfo &options);
+ // Save the theme screenshots in the given EXISTING directory and given
+ // an existing screenshot on disk.
+ bool KVIRC_API saveScreenshots(KviThemeInfo &options,const QString &szOriginalScreenshotPath);
};
diff --git a/src/kvirc/kvs/kvi_kvs_coresimplecommands_mr.cpp b/src/kvirc/kvs/kvi_kvs_coresimplecommands_mr.cpp
index 26f29e8e2..7a35fd43e 100644
--- a/src/kvirc/kvs/kvi_kvs_coresimplecommands_mr.cpp
+++ b/src/kvirc/kvs/kvi_kvs_coresimplecommands_mr.cpp
@@ -591,8 +591,6 @@ namespace KviKvsCoreSimpleCommands
if(KviFileUtils::directoryExists(szFileName))
{
- // FIXME: Throw away KviStr!!!
- //KviStr szTmp;
QString szTmp;
KVSCSC_pContext->enterBlockingSection();
diff --git a/src/kvirc/ui/kvi_menubar.cpp b/src/kvirc/ui/kvi_menubar.cpp
index 4d3311601..5e3891679 100644
--- a/src/kvirc/ui/kvi_menubar.cpp
+++ b/src/kvirc/ui/kvi_menubar.cpp
@@ -266,35 +266,37 @@ void KviMenuBar::newConnectionToServer(int id)
void KviMenuBar::setupToolsPopup()
{
- QPopupMenu * m = (QPopupMenu *)sender();
- if(!m)return;
+ QPopupMenu * m = (QPopupMenu *)sender();
+ if(!m)return;
- m->clear();
+ m->clear();
- KviModuleExtensionDescriptorList * l = g_pModuleExtensionManager->getExtensionList("tool");
- if(l)
- {
- for(KviModuleExtensionDescriptor * d = l->first();d;d = l->next())
- {
- int id;
- if(d->icon())id = m->insertItem(*(d->icon()),d->visibleName());
- else id = m->insertItem(d->visibleName());
- //m->setItemChecked(id,(m_pFrm->moduleExtensionToolBar(d->id())));
- m->setItemParameter(id,d->id());
- }
- }
- m->insertSeparator();
- ACTION_POPUP_ITEM(KVI_COREACTION_SOCKETSPY,m)
- ACTION_POPUP_ITEM(KVI_COREACTION_NETWORKLINKS,m)
- ACTION_POPUP_ITEM(KVI_COREACTION_CHANNELLIST,m)
- m->insertSeparator();
+ KviModuleExtensionDescriptorList * l = g_pModuleExtensionManager->getExtensionList("tool");
+ if(l)
+ {
+ for(KviModuleExtensionDescriptor * d = l->first();d;d = l->next())
+ {
+ int id;
+ if(d->icon())id = m->insertItem(*(d->icon()),d->visibleName());
+ else id = m->insertItem(d->visibleName());
+ //m->setItemChecked(id,(m_pFrm->moduleExtensionToolBar(d->id())));
+ m->setItemParameter(id,d->id());
+ }
+ }
+ m->insertSeparator();
+ ACTION_POPUP_ITEM(KVI_COREACTION_SOCKETSPY,m)
+ ACTION_POPUP_ITEM(KVI_COREACTION_NETWORKLINKS,m)
+ ACTION_POPUP_ITEM(KVI_COREACTION_CHANNELLIST,m)
+ m->insertSeparator();
+
+ ACTION_POPUP_ITEM(KVI_COREACTION_SCREENSHOT,m)
- // moved the old tools here
- m->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_ICONMANAGER)),__tr2qs("Show &Icon Table"),g_pIconManager,SLOT(showIconWidget()));
+ // moved the old tools here
+ m->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_ICONMANAGER)),__tr2qs("Show &Icon Table"),g_pIconManager,SLOT(showIconWidget()));
#ifdef COMPILE_KDE_SUPPORT
- int id;
- id = m->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_TERMINAL)),__tr2qs("Open &Terminal"),m_pFrm,SLOT(executeInternalCommand(int)));
- m->setItemParameter(id,KVI_INTERNALCOMMAND_TERM_OPEN);
+ int id;
+ id = m->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_TERMINAL)),__tr2qs("Open &Terminal"),m_pFrm,SLOT(executeInternalCommand(int)));
+ m->setItemParameter(id,KVI_INTERNALCOMMAND_TERM_OPEN);
#endif
diff --git a/src/kvirc/ui/kvi_window.cpp b/src/kvirc/ui/kvi_window.cpp
index 108cb755f..41cf97fac 100644
--- a/src/kvirc/ui/kvi_window.cpp
+++ b/src/kvirc/ui/kvi_window.cpp
@@ -827,7 +827,7 @@ void KviWindow::systemTextEncodingPopupSmartActivated(int id)
if(!g_pMdiWindowSystemTextEncodingPopupSmart)
return;
QString tmp = g_pMdiWindowSystemTextEncodingPopupSmart->text(id);
- KviQString::cutFromFirst(tmp,' ');
+ KviQString::cutFromFirst(tmp," (");
setTextEncoding(tmp);
}
@@ -836,7 +836,7 @@ void KviWindow::systemTextEncodingPopupSmartUtf8Activated(int id)
if(!g_pMdiWindowSystemTextEncodingPopupSmartUtf8)
return;
QString tmp = g_pMdiWindowSystemTextEncodingPopupSmartUtf8->text(id);
- KviQString::cutFromFirst(tmp,' ');
+ KviQString::cutFromFirst(tmp," (");
setTextEncoding(tmp);
}
@@ -845,7 +845,7 @@ void KviWindow::systemTextEncodingPopupStandardActivated(int id)
if(!g_pMdiWindowSystemTextEncodingPopupStandard)
return;
QString tmp = g_pMdiWindowSystemTextEncodingPopupStandard->text(id);
- KviQString::cutFromFirst(tmp,' ');
+ KviQString::cutFromFirst(tmp," (");
setTextEncoding(tmp);
}
diff --git a/src/modules/mircimport/libkvimircimport.cpp b/src/modules/mircimport/libkvimircimport.cpp
index 32f48cf98..cfca847f5 100644
--- a/src/modules/mircimport/libkvimircimport.cpp
+++ b/src/modules/mircimport/libkvimircimport.cpp
@@ -218,7 +218,9 @@ void KviRemoteMircServerImportWizard::start()
connect(m_pRequest,SIGNAL(terminated(bool)),this,SLOT(getListTerminated(bool)));
connect(m_pRequest,SIGNAL(status(const char *)),this,SLOT(getListMessage(const char *)));
- g_pApp->getTmpFileName(m_szTmpFileName,"servers.ini");
+ QString szTmp;
+ g_pApp->getTmpFileName(szTmp,"servers.ini");
+ m_szTmpFileName = szTmp;
if(!m_pRequest->get(KviUrl(url.ptr()),KviHttpRequest::StoreToFile,m_szTmpFileName.ptr()))
{
delete m_pRequest;
diff --git a/src/modules/str/libkvistr.cpp b/src/modules/str/libkvistr.cpp
index 035541475..14126657d 100644
--- a/src/modules/str/libkvistr.cpp
+++ b/src/modules/str/libkvistr.cpp
@@ -1640,7 +1640,7 @@ static bool str_kvs_fnc_join(KviKvsModuleFunctionCall * c)
@title:
$str.grep
@short:
- Emulates the GNU Regular ExPression engine
+ Emulates the GNU Regular Expression Parser
@syntax:
<array> $str.grep(<match:string>,<strings:array>[,<flags:string>])
@description:
diff --git a/src/modules/theme/libkvitheme.cpp b/src/modules/theme/libkvitheme.cpp
index 12c7786ca..6c2c570e1 100644
--- a/src/modules/theme/libkvitheme.cpp
+++ b/src/modules/theme/libkvitheme.cpp
@@ -34,6 +34,8 @@
#include "kvi_mirccntrl.h"
#include "kvi_config.h"
#include "kvi_sourcesdate.h"
+#include "kvi_fileutils.h"
+#include "kvi_filedialog.h"
#include "managementdialog.h"
#include "themefunctions.h"
@@ -74,6 +76,56 @@ static bool theme_kvs_cmd_install(KviKvsModuleCommandCall * c)
}
/*
+ @doc: theme.screenshot
+ @type:
+ command
+ @title:
+ theme.screenshot
+ @short:
+ Makes a screenshot of the KVIrc window
+ @syntax:
+ theme.screenshot [file_name_path:string]
+ @description:
+ Makes a screenshot of the KVIrc main window
+ and saves it in the specified file. If [file_name_path]
+ is not specified then a save file dialog is shown.
+*/
+
+static bool theme_kvs_cmd_screenshot(KviKvsModuleCommandCall * c)
+{
+ QString szFileName;
+
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSM_PARAMETER("file_name_path",KVS_PT_STRING,KVS_PF_OPTIONAL,szFileName)
+ KVSM_PARAMETERS_END(c)
+
+
+ KviFileUtils::adjustFilePath(szFileName);
+
+ QString szTmp;
+ c->enterBlockingSection();
+
+ bool bResult = KviFileDialog::askForSaveFileName(szTmp,__tr2qs_ctx("Choose a file to save the screenshot to","theme"),szFileName,"*.png");
+
+ if(!c->leaveBlockingSection())return false; // need to stop immediately
+ if(!bResult)return true;
+
+ szFileName = szTmp;
+
+ if(szFileName.isEmpty())return true; // done
+ KviFileUtils::adjustFilePath(szFileName);
+
+ QString szError;
+ if(!KviThemeFunctions::makeKVIrcScreenshot(szFileName))
+ {
+ c->error(__tr2qs_ctx("Error making screenshot","theme")); // FIXME: a nicer error ?
+ return false;
+ }
+
+ return true;
+}
+
+/*
@doc: theme.dialog
@type:
command
@@ -97,6 +149,7 @@ static bool theme_module_init(KviModule *m)
{
KVSM_REGISTER_SIMPLE_COMMAND(m,"dialog",theme_kvs_cmd_dialog);
KVSM_REGISTER_SIMPLE_COMMAND(m,"install",theme_kvs_cmd_install);
+ KVSM_REGISTER_SIMPLE_COMMAND(m,"screenshot",theme_kvs_cmd_screenshot);
QString szBuf;
m->getDefaultConfigFileName(szBuf);
diff --git a/src/modules/theme/managementdialog.cpp b/src/modules/theme/managementdialog.cpp
index 3f96ab13b..c066da522 100644
--- a/src/modules/theme/managementdialog.cpp
+++ b/src/modules/theme/managementdialog.cpp
@@ -69,6 +69,7 @@
#include "kvi_packagefile.h"
#include "kvi_fileextensions.h"
#include "kvi_filedialog.h"
+#include "kvi_dynamictooltip.h"
#include <stdlib.h> // rand & srand
@@ -116,7 +117,7 @@ KviThemeListBoxItem::~KviThemeListBoxItem()
delete m_pText;
}
-void KviThemeListBoxItem::paint ( QPainter * p )
+void KviThemeListBoxItem::paint(QPainter * p)
{
QListBoxText::paint(p);
p->drawPixmap(LVI_BORDER,LVI_BORDER, *(g_pIconManager->getBigIcon(QString(KVI_BIGICON_THEME))) );
@@ -126,7 +127,7 @@ void KviThemeListBoxItem::paint ( QPainter * p )
m_pText->draw(p,afterIcon,LVI_BORDER,QRect(afterIcon,LVI_BORDER,www,p->window().height() - (LVI_BORDER * 2)),listBox()->viewport()->colorGroup());
}
-int KviThemeListBoxItem::height ( const QListBox * lb ) const
+int KviThemeListBoxItem::height(const QListBox * lb) const
{
int iHeight = m_pText->height() + (2 * LVI_BORDER);
if(iHeight < (LVI_ICON_SIZE + (2 * LVI_BORDER)))iHeight = LVI_ICON_SIZE + (2 * LVI_BORDER);
@@ -205,6 +206,8 @@ KviThemeManagementDialog::KviThemeManagementDialog(QWidget * parent)
connect(m_pListBox,SIGNAL(selectionChanged()),this,SLOT(enableDisableButtons()));
g->addMultiCellWidget(m_pListBox,1,1,0,1);
+ KviDynamicToolTip * tip = new KviDynamicToolTip(m_pListBox);
+ connect(tip,SIGNAL(tipRequest(KviDynamicToolTip *,const QPoint &)),this,SLOT(tipRequest(KviDynamicToolTip *,const QPoint &)));
QPushButton * b = new QPushButton(__tr2qs("Close"),this);
connect(b,SIGNAL(clicked()),this,SLOT(closeClicked()));
@@ -238,6 +241,29 @@ void KviThemeManagementDialog::closeClicked()
m_pInstance = 0;
}
+void KviThemeManagementDialog::tipRequest(KviDynamicToolTip *pTip,const QPoint &pnt)
+{
+ KviThemeListBoxItem * it = (KviThemeListBoxItem *)(m_pListBox->itemAt(pnt));
+ if(!it)return;
+ KviThemeInfo * pThemeInfo = it->themeInfo();
+
+ QString szThemeDescription;
+ KviThemeFunctions::getThemeHtmlDescription(
+ szThemeDescription,
+ pThemeInfo->name(),
+ pThemeInfo->version(),
+ pThemeInfo->description(),
+ pThemeInfo->subdirectory(),
+ pThemeInfo->application(),
+ pThemeInfo->author(),
+ pThemeInfo->date(),
+ pThemeInfo->themeEngineVersion(),
+ pThemeInfo->mediumScreenshot(),
+ 0
+ );
+
+ pTip->tip(m_pListBox->itemRect(it),szThemeDescription);
+}
void KviThemeManagementDialog::display()
{
diff --git a/src/modules/theme/managementdialog.h b/src/modules/theme/managementdialog.h
index a734d557e..12762a9f9 100644
--- a/src/modules/theme/managementdialog.h
+++ b/src/modules/theme/managementdialog.h
@@ -44,6 +44,9 @@ class QLabel;
class QCheckBox;
class QMultiLineEdit;
+class KviDynamicToolTip;
+class KviStyledToolButton;
+
class KviThemeListBoxItem : public QListBoxText
{
@@ -61,8 +64,6 @@ protected:
};
-class KviStyledToolButton;
-
class KviThemeManagementDialog : public QDialog
{
Q_OBJECT
@@ -94,6 +95,7 @@ protected slots:
void applyCurrentTheme();
void enableDisableButtons();
void contextMenuRequested(QListBoxItem * item, const QPoint & pos);
+ void tipRequest(KviDynamicToolTip *pTip,const QPoint &pnt);
};
#endif //!_MANAGEMENTDIALOG_H_
diff --git a/src/modules/theme/packthemedialog.cpp b/src/modules/theme/packthemedialog.cpp
index 73352abbd..0efeb8bf5 100644
--- a/src/modules/theme/packthemedialog.cpp
+++ b/src/modules/theme/packthemedialog.cpp
@@ -39,6 +39,7 @@
#include <qmultilineedit.h>
#include <qbuffer.h>
#include <qlabel.h>
+#include <qregexp.h>
#include "kvi_options.h"
@@ -69,11 +70,17 @@ KviPackThemeDialog::KviPackThemeDialog(QWidget * pParent,KviPtrList<KviThemeInfo
QString szPackageAuthor;
QString szPackageDescription;
QString szPackageVersion;
+
+ m_szPackagePath = QDir::homeDirPath();
+ KviQString::ensureLastCharIs(m_szPackagePath,QChar(KVI_PATH_SEPARATOR_CHAR));
+
+ bool bPackagePathSet = false;
+
if(m_pThemeInfoList->count() > 1)
{
szPackageName = "MyThemes";
szPackageAuthor = __tr2qs_ctx("Your name here","theme");
- szPackageVersion = "1.0";
+ szPackageVersion = "1.0.0";
szPackageDescription = __tr2qs_ctx("Put a package description here...","theme");
} else {
if(m_pThemeInfoList->count() > 0)
@@ -83,9 +90,28 @@ KviPackThemeDialog::KviPackThemeDialog(QWidget * pParent,KviPtrList<KviThemeInfo
szPackageAuthor = pThemeInfo->author();
szPackageDescription = pThemeInfo->description();
szPackageVersion = pThemeInfo->version();
+
+ m_szPackagePath += pThemeInfo->subdirectory();
+ if(m_szPackagePath.find(QRegExp("[0-9]\\.[0-9]")) == -1)
+ {
+ m_szPackagePath += "-";
+ m_szPackagePath += szPackageVersion;
+ }
+ m_szPackagePath += ".";
+ m_szPackagePath += KVI_FILEEXTENSION_THEMEPACKAGE;
+
+ bPackagePathSet = true;
}
}
+ if(!bPackagePathSet)
+ {
+ m_szPackagePath += szPackageName;
+ m_szPackagePath += "-";
+ m_szPackagePath += szPackageVersion;
+ m_szPackagePath += ".";
+ m_szPackagePath += KVI_FILEEXTENSION_THEMEPACKAGE;
+ }
setCaption(__tr2qs_ctx("Export Theme - KVIrc","theme"));
setMinimumSize(400,350);
@@ -126,10 +152,20 @@ KviPackThemeDialog::KviPackThemeDialog(QWidget * pParent,KviPtrList<KviThemeInfo
QString szThemesDescription = "<html><body bgcolor=\"#ffffff\">";
int iIdx = 0;
+ QPixmap pixScreenshot;
+ QString szScreenshotPath;
+
for(pThemeInfo = m_pThemeInfoList->first();pThemeInfo;pThemeInfo = m_pThemeInfoList->next())
{
QString szThemeDescription;
+ if(pixScreenshot.isNull())
+ {
+ pixScreenshot = pThemeInfo->smallScreenshot();
+ if(!pixScreenshot.isNull())
+ szScreenshotPath = pThemeInfo->smallScreenshotPath();
+ }
+
KviThemeFunctions::getThemeHtmlDescription(
szThemeDescription,
pThemeInfo->name(),
@@ -139,7 +175,9 @@ KviPackThemeDialog::KviPackThemeDialog(QWidget * pParent,KviPtrList<KviThemeInfo
pThemeInfo->application(),
pThemeInfo->author(),
pThemeInfo->date(),
- pThemeInfo->themeEngineVersion()
+ pThemeInfo->themeEngineVersion(),
+ pThemeInfo->smallScreenshot(),
+ iIdx
);
if(iIdx > 0)
@@ -193,7 +231,7 @@ KviPackThemeDialog::KviPackThemeDialog(QWidget * pParent,KviPtrList<KviThemeInfo
pLabel->setText(__tr2qs_ctx("Description:","theme"));
pLayout->addWidget(pLabel,3,0);
- m_pPackageDescriptionEdit = new QMultiLineEdit(pPage);
+ m_pPackageDescriptionEdit = new QTextEdit(pPage);
m_pPackageDescriptionEdit->setText(szPackageDescription);
pLayout->addWidget(m_pPackageDescriptionEdit,3,1);
@@ -254,15 +292,6 @@ KviPackThemeDialog::KviPackThemeDialog(QWidget * pParent,KviPtrList<KviThemeInfo
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);
@@ -281,6 +310,11 @@ KviPackThemeDialog::KviPackThemeDialog(QWidget * pParent,KviPtrList<KviThemeInfo
setNextEnabled(pPage,false);
setFinishEnabled(pPage,true);
+ if(!szScreenshotPath.isEmpty())
+ {
+ m_pImageSelector->setSelection(szScreenshotPath);
+ imageSelectionChanged(szScreenshotPath);
+ }
}
KviPackThemeDialog::~KviPackThemeDialog()
@@ -389,6 +423,18 @@ bool KviPackThemeDialog::packTheme()
f.addInfoField(szTmp,pInfo->application());
KviQString::sprintf(szTmp,"Theme%dThemeEngineVersion",iIdx);
f.addInfoField(szTmp,pInfo->themeEngineVersion());
+ QPixmap pixScreenshot = pInfo->smallScreenshot();
+ if(!pixScreenshot.isNull())
+ {
+ KviQString::sprintf(szTmp,"Theme%dScreenshot",iIdx);
+ QByteArray * pba = new QByteArray();
+ QBuffer bufferz(*pba);
+ bufferz.open(IO_WriteOnly);
+ pixScreenshot.save(&bufferz,"PNG");
+ bufferz.close();
+ f.addInfoField(szTmp,pba);
+ }
+
if(!f.addDirectory(pInfo->absoluteDirectory(),pInfo->subdirectory()))
{
szTmp = __tr2qs_ctx("Packaging failed","theme");
diff --git a/src/modules/theme/packthemedialog.h b/src/modules/theme/packthemedialog.h
index 1316369bc..b3916dab6 100644
--- a/src/modules/theme/packthemedialog.h
+++ b/src/modules/theme/packthemedialog.h
@@ -32,6 +32,7 @@
#include <qwizard.h>
class QLineEdit;
+class QTextEdit;
class QLabel;
class QMultiLineEdit;
class KviFileSelector;
@@ -51,14 +52,14 @@ protected:
QLabel * m_pImageLabel;
KviPtrList<KviThemeInfo> * m_pThemeInfoList;
QLineEdit * m_pPackageNameEdit;
- QMultiLineEdit * m_pPackageDescriptionEdit;
+ QTextEdit * m_pPackageDescriptionEdit;
QLineEdit * m_pPackageVersionEdit;
QLineEdit * m_pPackagerNameEdit;
QWidget * m_pImageSelectionPage;
protected:
virtual void accept();
-protected slots:
bool packTheme();
+protected slots:
void imageSelectionChanged(const QString &szImagePath);
};
diff --git a/src/modules/theme/savethemedialog.cpp b/src/modules/theme/savethemedialog.cpp
index 7a7a200c3..6e187fdb7 100644
--- a/src/modules/theme/savethemedialog.cpp
+++ b/src/modules/theme/savethemedialog.cpp
@@ -23,6 +23,7 @@
//=============================================================================
#include "savethemedialog.h"
+#include "themefunctions.h"
#include <qlayout.h>
#include <qpushbutton.h>
@@ -53,87 +54,194 @@
#include "kvi_filedialog.h"
#include "kvi_msgbox.h"
#include "kvi_selectors.h"
+#include "kvi_miscutils.h"
#include "kvi_sourcesdate.h"
-KviSaveThemeDialog::KviSaveThemeDialog(QWidget * par)
-: QDialog(par)
+
+KviSaveThemeDialog::KviSaveThemeDialog(QWidget * pParent)
+: QWizard(pParent)
{
- setCaption(__tr2qs_ctx("Save Current Theme","theme"));
+ setCaption(__tr2qs_ctx("Save Current 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 save the current theme settings to a single directory. It is useful if you want to apply other themes or play with the theme settings and later come back to this theme with a single click. It will also allow you to manually modify the theme settings and later export them to a distributable package.","theme");
+ szText += "</p><p>";
+ szText += __tr2qs_ctx("You will be asked to provide a theme name, a description and, if you want, a 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);
- QGridLayout * g = new QGridLayout(this,8,2,4,4);
+ // packager informations ================================================================================
- QLabel * l;
+ pPage = new QWidget(this);
+ pLayout = new QGridLayout(pPage,5,2,4,4);
- l = new QLabel(__tr2qs_ctx("Theme name:","theme"),this);
- g->addWidget(l,0,0);
+ pLabel = new QLabel(pPage);
+ pLabel->setText(__tr2qs_ctx("Here you need to provide informations about you (the author) and a short description of the theme you're creating.","theme"));
+ pLabel->setTextFormat(Qt::RichText);
+ pLayout->addMultiCellWidget(pLabel,0,0,0,1);
+
+ pLabel = new QLabel(pPage);
+ pLabel->setText(__tr2qs_ctx("Theme Name:","theme"));
+ pLayout->addWidget(pLabel,1,0);
+
+ m_pThemeNameEdit = new QLineEdit(pPage);
+ //m_pThemeNameEdit->setText(szThemeName);
+ pLayout->addWidget(m_pThemeNameEdit,1,1);
- 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 &)));
+ pLabel = new QLabel(pPage);
+ pLabel->setText(__tr2qs_ctx("Version:","theme"));
+ pLayout->addWidget(pLabel,2,0);
+
+ m_pThemeVersionEdit = new QLineEdit(pPage);
+ //m_pThemeVersionEdit->setText(szThemeVersion);
+ pLayout->addWidget(m_pThemeVersionEdit,2,1);
+
+ pLabel = new QLabel(pPage);
+ pLabel->setText(__tr2qs_ctx("Description:","theme"));
+ pLayout->addWidget(pLabel,3,0);
+
+ m_pThemeDescriptionEdit = new QTextEdit(pPage);
+ //m_pThemeDescriptionEdit->setText(szThemeDescription);
+ pLayout->addWidget(m_pThemeDescriptionEdit,3,1);
+ pLabel = new QLabel(pPage);
+ pLabel->setText(__tr2qs_ctx("Theme Author:","theme"));
+ pLayout->addWidget(pLabel,4,0);
+
+ m_pAuthorNameEdit = new QLineEdit(pPage);
+ //m_pAuthorNameEdit->setText(szThemeAuthor);
+ pLayout->addWidget(m_pAuthorNameEdit,4,1);
- 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);
+ pLayout->setRowStretch(3,1);
+ pLayout->setColStretch(1,1);
+ addPage(pPage,__tr2qs_ctx("Theme Informations","theme"));
+ setBackEnabled(pPage,true);
+ setHelpEnabled(pPage,false);
+ setNextEnabled(pPage,true);
+ setFinishEnabled(pPage,false);
- l = new QLabel(__tr2qs_ctx("Author:","theme"),this);
- g->addWidget(l,2,0);
+ // screenshot/logo/icon ================================================================================
- m_pAuthorEdit = new QLineEdit(this);
- g->addMultiCellWidget(m_pAuthorEdit,2,2,1,2);
+ pPage = new QWidget(this);
+ pLayout = new QGridLayout(pPage,4,1,4,4);
- l = new QLabel(__tr2qs_ctx("Description:","theme"),this);
- g->addWidget(l,3,0);
+ pLabel = new QLabel(pPage);
+ pLabel->setText(__tr2qs_ctx("Here you can either choose a screenshot image from disk or make one now. The screenshot will be displayed in the tooltips of the theme management dialog and will be also visible in the package installation dialog if you will export the theme to a distributable package.","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);
- m_pDescriptionEdit = new QTextEdit(this);
- g->addMultiCellWidget(m_pDescriptionEdit,3,4,1,2);
+ QString szFilter = "*.png *.jpg *.xpm";
+ m_pImageSelector = new KviFileSelector(pPage,"",&m_szScreenshotPath,true,0,szFilter);
+ connect(m_pImageSelector,SIGNAL(selectionChanged(const QString &)),this,SLOT(imageSelectionChanged(const QString &)));
+ pLayout->addWidget(m_pImageSelector,2,0);
- 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 * pButton = new QPushButton(pPage);
+ pButton->setText(__tr2qs_ctx("Make Screenshot Now","theme"));
+ connect(pButton,SIGNAL(clicked()),this,SLOT(makeScreenshot()));
+ pLayout->addWidget(pButton,3,0);
- QPushButton * pb = new QPushButton(__tr2qs_ctx("Cancel","theme"),h);
- connect(pb,SIGNAL(clicked()),this,SLOT(reject()));
- pb->setIconSet(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_DISCARD)));
+ pLayout->setRowStretch(1,1);
+ m_pImageSelectionPage = pPage;
+ addPage(pPage,__tr2qs_ctx("Screenshot","theme"));
+ setBackEnabled(pPage,true);
+ setHelpEnabled(pPage,false);
+ setNextEnabled(pPage,true);
+ setFinishEnabled(pPage,true);
}
KviSaveThemeDialog::~KviSaveThemeDialog()
{
+}
+
+void KviSaveThemeDialog::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("Save Current 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 KviSaveThemeDialog::themeNameChanged(const QString &txt)
+
+void KviSaveThemeDialog::accept()
{
- m_pOkButton->setEnabled(!txt.isEmpty());
+ if(!saveTheme())return;
+ QWizard::accept();
}
-void KviSaveThemeDialog::saveTheme()
+void KviSaveThemeDialog::makeScreenshot()
{
+ QString szFileName;
+ g_pApp->getTmpFileName(szFileName,"screenshot.png");
+ if(!KviThemeFunctions::makeKVIrcScreenshot(szFileName))
+ {
+ QMessageBox::critical(this,__tr2qs_ctx("Acquire Screenshot - KVIrc","theme"),__tr2qs_ctx("Failed to make screenshot","theme"),
+ QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
+ return;
+ }
+ m_pImageSelector->setSelection(szFileName);
+ imageSelectionChanged(szFileName);
+}
+
+bool KviSaveThemeDialog::saveTheme()
+{
+ m_pImageSelector->commit();
+
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::critical(this,__tr2qs_ctx("Save Current Theme - KVIrc","theme"),__tr2qs_ctx("You must choose a theme name!","theme"),QMessageBox::Ok,
QMessageBox::NoButton,QMessageBox::NoButton);
- return;
+ return false;
}
- sto.setAuthor(m_pAuthorEdit->text());
- sto.setDescription(m_pDescriptionEdit->text());
+ sto.setAuthor(m_pAuthorNameEdit->text());
+ sto.setDescription(m_pThemeDescriptionEdit->text());
sto.setDate(QDateTime::currentDateTime().toString());
- sto.setVersion(m_pVersionEdit->text());
+ sto.setVersion(m_pThemeVersionEdit->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();
@@ -144,23 +252,34 @@ void KviSaveThemeDialog::saveTheme()
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::critical(this,__tr2qs_ctx("Save Current Theme - KVIrc","theme"),__tr2qs_ctx("Unable to create theme directory.","theme"),
QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
- return;
+ return false;
}
-
+
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::critical(this,__tr2qs_ctx("Save Current Theme - KVIrc","theme"),szMsg2,
QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
- return;
+ return false;
+ }
+ // write down the screenshot, if needed
+
+ if(!m_szScreenshotPath.isEmpty())
+ {
+ if(!KviTheme::saveScreenshots(sto,m_szScreenshotPath))
+ {
+ QMessageBox::critical(this,__tr2qs_ctx("Save Current Theme - KVIrc","theme"),__tr2qs_ctx("Failed to load the selected screenshot image: please fix it","theme"),
+ QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
+ showPage(m_pImageSelectionPage);
+ return false;
+ }
}
- // write down the images
QString szMsg = __tr2qs_ctx("Theme saved successfully to ","theme");
szMsg += sto.absoluteDirectory();
@@ -168,6 +287,6 @@ void KviSaveThemeDialog::saveTheme()
QMessageBox::information(this,__tr2qs_ctx("Save Theme - KVIrc","theme"),szMsg,QMessageBox::Ok,
QMessageBox::NoButton,QMessageBox::NoButton);
- accept();
+ return true;
}
diff --git a/src/modules/theme/savethemedialog.h b/src/modules/theme/savethemedialog.h
index af9dd2186..5e780f750 100644
--- a/src/modules/theme/savethemedialog.h
+++ b/src/modules/theme/savethemedialog.h
@@ -26,10 +26,11 @@
#include "kvi_settings.h"
#include "kvi_list.h"
+#include "kvi_theme.h"
#include <qdialog.h>
+#include <qwizard.h>
-#include "kvi_theme.h"
class QLineEdit;
class QTextEdit;
@@ -40,21 +41,29 @@ class QMultiLineEdit;
class KviFileSelector;
-class KviSaveThemeDialog : public QDialog
+class KviSaveThemeDialog : public QWizard
{
Q_OBJECT
public:
- KviSaveThemeDialog(QWidget *par);
+ KviSaveThemeDialog(QWidget * pParent);
virtual ~KviSaveThemeDialog();
protected:
- QLineEdit * m_pAuthorEdit;
- QLineEdit * m_pThemeNameEdit;
- QLineEdit * m_pVersionEdit;
- QTextEdit * m_pDescriptionEdit;
+ QString m_szScreenshotPath;
+ KviFileSelector * m_pImageSelector;
+ QLabel * m_pImageLabel;
+ QLineEdit * m_pThemeNameEdit;
+ QTextEdit * m_pThemeDescriptionEdit;
+ QLineEdit * m_pThemeVersionEdit;
+ QLineEdit * m_pAuthorNameEdit;
+ QWidget * m_pImageSelectionPage;
QPushButton * m_pOkButton;
+protected:
+ virtual void accept();
+ bool saveTheme();
protected slots:
- void saveTheme();
- void themeNameChanged(const QString &txt);
+ void makeScreenshot();
+ void imageSelectionChanged(const QString &szImagePath);
+ //void themeNameChanged(const QString &txt);
};
diff --git a/src/modules/theme/themefunctions.cpp b/src/modules/theme/themefunctions.cpp
index d6fef4dc6..86b786f0e 100644
--- a/src/modules/theme/themefunctions.cpp
+++ b/src/modules/theme/themefunctions.cpp
@@ -33,6 +33,7 @@
#include "kvi_miscutils.h"
#include "kvi_sourcesdate.h"
#include "kvi_theme.h"
+#include "kvi_frame.h"
#include <qmime.h>
@@ -156,6 +157,11 @@ namespace KviThemeFunctions
r.getStringInfoField(szTmp,szThemeAuthor);
KviQString::sprintf(szTmp,"Theme%dThemeEngineVersion",iIdx);
r.getStringInfoField(szTmp,szThemeThemeEngineVersion);
+ KviQString::sprintf(szTmp,"Theme%dScreenshot",iIdx);
+ QPixmap pixScreenshot;
+ pByteArray = r.binaryInfoFields()->find(szTmp);
+ if(pByteArray)
+ pixScreenshot.loadFromData(*pByteArray,0,0);
if(szThemeName.isEmpty() || szThemeVersion.isEmpty() || szThemeSubdirectory.isEmpty() || szThemeThemeEngineVersion.isEmpty())
bValid = false;
@@ -173,9 +179,14 @@ namespace KviThemeFunctions
szThemeApplication,
szThemeAuthor,
szThemeDate,
- szThemeThemeEngineVersion
+ szThemeThemeEngineVersion,
+ pixScreenshot,
+ iIdx
);
+ if(iIdx > 0)
+ szDetails += "<hr>";
+
szDetails += szDetailsBuffer;
if(!bValid)
@@ -186,16 +197,12 @@ namespace KviThemeFunctions
iValidThemeCount--;
}
- if(iIdx > 0)
- szDetails += "<hr>";
-
iIdx++;
}
- szDetails += "<p><center><a href=\"theme_dialog_main\">";
+ szDetails += "<br><p><center><a href=\"theme_dialog_main\">";
szDetails += __tr2qs_ctx("Go Back to Package Data","theme");
szDetails += "</a></center></p>";
-
szDetails += "</body></html>";
if(iValidThemeCount < iThemeCount)
@@ -244,7 +251,8 @@ namespace KviThemeFunctions
&szPackageDate,
&szCreatedOn,
&szPackageApplication,
- &szWarnings
+ &szWarnings,
+ &szShowDetails
);
@@ -295,7 +303,9 @@ namespace KviThemeFunctions
const QString &szThemeApplication,
const QString &szThemeAuthor,
const QString &szThemeDate,
- const QString &szThemeThemeEngineVersion
+ const QString &szThemeThemeEngineVersion,
+ const QPixmap &pixScreenshot,
+ int iUniqueIndexInDocument
)
{
QString szAuthor = __tr2qs_ctx("Author","theme");
@@ -304,27 +314,40 @@ namespace KviThemeFunctions
QString szThemeEngineVersion = __tr2qs_ctx("Theme Engine Version","theme");
QString szSubdirectory = __tr2qs_ctx("Subdirectory","theme");
+ QString szScreenshot;
+ if(!pixScreenshot.isNull())
+ {
+ KviQString::sprintf(szScreenshot,"<p><center><img src=\"theme_shot%d\"></center></p>",iUniqueIndexInDocument);
+ QString szTmp;
+ KviQString::sprintf(szTmp,"theme_shot%d",iUniqueIndexInDocument);
+ QMimeSourceFactory::defaultFactory()->setPixmap(szTmp,pixScreenshot);
+ } else {
+ szScreenshot = "";
+ }
+
KviQString::sprintf(
szBuffer,
- "<p>" \
+ "<p><center>" \
"<h2>%Q %Q</h2>" \
- "</p>" \
- "<p>" \
+ "</center></p>" \
+ "%Q" \
+ "<p><center>" \
"<i>%Q</i>" \
- "</p>" \
- "<p>" \
+ "</center></p>" \
+ "<p><center>" \
"%Q: <b>%Q</b><br>" \
"%Q: <b>%Q</b><br>" \
- "</p>" \
- "<p>" \
+ "</center></p>" \
+ "<p><center>" \
"<font color=\"#808080\">" \
"%Q: %Q<br>" \
"%Q: %Q<br>" \
"%Q: %Q<br>" \
"</font>" \
- "</p>",
+ "</center></p>",
&szThemeName,
&szThemeVersion,
+ &szScreenshot,
&szThemeDescription,
&szAuthor,
&szThemeAuthor,
@@ -339,6 +362,30 @@ namespace KviThemeFunctions
);
}
+ bool makeKVIrcScreenshot(const QString &szSavePngFilePath,bool bMaximizeFrame)
+ {
+ if(bMaximizeFrame)
+ {
+ if(g_pFrame->isMaximized())
+ bMaximizeFrame = false;
+ }
+
+ if(bMaximizeFrame)
+ g_pFrame->showMaximized();
+
+ QPixmap pix = QPixmap::grabWidget(g_pFrame);
+ bool bResult = true;
+
+ if(pix.isNull())
+ bResult = false;
+ else {
+ if(!pix.save(szSavePngFilePath,"PNG",100))
+ bResult = false;
+ }
+ if(bMaximizeFrame)
+ g_pFrame->showNormal();
+ return bResult;
+ }
};
diff --git a/src/modules/theme/themefunctions.h b/src/modules/theme/themefunctions.h
index b628df4fb..d3b058865 100644
--- a/src/modules/theme/themefunctions.h
+++ b/src/modules/theme/themefunctions.h
@@ -28,6 +28,7 @@
#include "kvi_qstring.h"
#include <qwidget.h>
+#include <qpixmap.h>
namespace KviThemeFunctions
{
@@ -41,8 +42,11 @@ namespace KviThemeFunctions
const QString &szThemeApplication,
const QString &szThemeAuthor,
const QString &szThemeDate,
- const QString &szThemeThemeEngineVersion
+ const QString &szThemeThemeEngineVersion,
+ const QPixmap &pixScreenshot,
+ int iUniqueIndexInDocument = 0
);
+ bool makeKVIrcScreenshot(const QString &szSavePngFilePath,bool bMaximizeFrame = false);
};