diff options
| author | 2007-01-10 04:36:47 +0000 | |
|---|---|---|
| committer | 2007-01-10 04:36:47 +0000 | |
| commit | 61d94f624faddab7aca95ac40d14929718c1fdf1 (patch) | |
| tree | 49c9cccefce21bb2a886087d644c0fc54ac64d01 /src | |
| parent | Added shortcuts to connect to kvirc channels (diff) | |
| download | KVIrc-61d94f624faddab7aca95ac40d14929718c1fdf1.tar.gz KVIrc-61d94f624faddab7aca95ac40d14929718c1fdf1.tar.bz2 KVIrc-61d94f624faddab7aca95ac40d14929718c1fdf1.zip | |
More themeing fixes
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@154 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src')
| -rw-r--r-- | src/kvilib/file/kvi_packagefile.cpp | 1 | ||||
| -rw-r--r-- | src/kvirc/kernel/kvi_theme.cpp | 41 | ||||
| -rw-r--r-- | src/kvirc/kernel/kvi_theme.h | 10 | ||||
| -rw-r--r-- | src/kvirc/kvs/kvi_kvs_parser_specialcommands.cpp | 2 | ||||
| -rw-r--r-- | src/kvirc/kvs/kvi_kvs_treenode_specialcommandswitch.cpp | 44 | ||||
| -rw-r--r-- | src/modules/theme/packthemedialog.cpp | 66 | ||||
| -rw-r--r-- | src/modules/theme/themefunctions.cpp | 164 | ||||
| -rw-r--r-- | src/modules/theme/themefunctions.h | 11 |
8 files changed, 177 insertions, 162 deletions
diff --git a/src/kvilib/file/kvi_packagefile.cpp b/src/kvilib/file/kvi_packagefile.cpp index 9c0e4225c..1e0ea89bc 100644 --- a/src/kvilib/file/kvi_packagefile.cpp +++ b/src/kvilib/file/kvi_packagefile.cpp @@ -701,6 +701,7 @@ bool KviPackageReader::unpackFile(KviFile * pFile,const QString &szUnpackPath) szFileName += szPath; + // no attacks please :) szFileName.replace(QString("..\\"),QString("")); szFileName.replace(QString("..//"),QString("")); diff --git a/src/kvirc/kernel/kvi_theme.cpp b/src/kvirc/kernel/kvi_theme.cpp index 7823a1b85..fee548535 100644 --- a/src/kvirc/kernel/kvi_theme.cpp +++ b/src/kvirc/kernel/kvi_theme.cpp @@ -30,9 +30,6 @@ #include "kvi_miscutils.h" #include "kvi_sourcesdate.h" -// increment only when there are INCOMPATIBLE changes in the file format (should never happen) -#define CURRENT_THEMEINFO_FILE_VERSION "1.0.0" - KviThemeInfo::KviThemeInfo() : KviHeapObject() @@ -57,9 +54,12 @@ bool KviThemeInfo::load(const QString &szThemeFileName) cfg.setGroup(KVI_THEMEINFO_CONFIG_GROUP); - QString tmp = cfg.readQStringEntry("ThemeInfoFileVersion",CURRENT_THEMEINFO_FILE_VERSION); - if(KviMiscUtils::compareVersions(tmp,CURRENT_THEMEINFO_FILE_VERSION) < 0) - return false; // incompatible ThemeInfoFileVersion + m_szThemeEngineVersion = cfg.readQStringEntry("ThemeEngineVersion","1.0.0"); + if(KviMiscUtils::compareVersions(m_szThemeEngineVersion,KVI_CURRENT_THEME_ENGINE_VERSION) < 0) + { + KviQString::sprintf(m_szLastError,__tr2qs("This KVIrc executable is too old for this theme (minimum theme engine version required is %Q while this theme engine has version %s)"),&m_szThemeEngineVersion,KVI_CURRENT_THEME_ENGINE_VERSION); + return false; // incompatible theme engine (will not work) + } // mandatory fields m_szName = cfg.readQStringEntry("Name",""); @@ -86,18 +86,6 @@ bool KviThemeInfo::load(const QString &szThemeFileName) if(m_szApplication.isEmpty()) m_szApplication = szUnknown; - m_szMinimumKVIrcVersion = cfg.readQStringEntry("MinimumKVIrcVersion","3.0.0"); - // if present, must be verified - - if(!m_szMinimumKVIrcVersion.isEmpty()) - { - if(KviMiscUtils::compareVersions(m_szMinimumKVIrcVersion,KVI_VERSION "." KVI_SOURCES_DATE) < 0) - { - KviQString::sprintf(m_szLastError,__tr2qs("This KVIrc executable is too old for this theme (minimum version required is %Q)"),&m_szMinimumKVIrcVersion); - return false; - } - } - return true; } @@ -114,22 +102,7 @@ bool KviThemeInfo::save(const QString &szThemeFileName) inf.writeEntry("Author",m_szAuthor); inf.writeEntry("Description",m_szDescription); inf.writeEntry("Date",m_szDate); - - if(!m_szMinimumKVIrcVersion.isEmpty()) - { - if( - (!KviMiscUtils::isValidVersionString(m_szMinimumKVIrcVersion)) - || - (KviMiscUtils::compareVersions(m_szMinimumKVIrcVersion,KVI_VERSION "." KVI_SOURCES_DATE) < 0) - ) - { - m_szLastError = __tr2qs("The specified minimum KVIrc version is not valid"); - return false; - } - } - - inf.writeEntry("MinimumKVIrcVersion",m_szMinimumKVIrcVersion); - inf.writeEntry("ThemeInfoFileVersion",CURRENT_THEMEINFO_FILE_VERSION); + inf.writeEntry("ThemeEngineVersion",KVI_CURRENT_THEME_ENGINE_VERSION); inf.writeEntry("Application","KVIrc " KVI_VERSION "." KVI_SOURCES_DATE); return true; diff --git a/src/kvirc/kernel/kvi_theme.h b/src/kvirc/kernel/kvi_theme.h index 3bf15a3bc..35f36e421 100644 --- a/src/kvirc/kernel/kvi_theme.h +++ b/src/kvirc/kernel/kvi_theme.h @@ -36,6 +36,10 @@ #define KVI_THEMEINFO_CONFIG_GROUP "ThemeInfo" #define KVI_THEMEDATA_CONFIG_GROUP "ThemeData" +// The current theme engine version: bump up if you make INCOMPATIBLE +// changes in the method of saving the theme. +#define KVI_CURRENT_THEME_ENGINE_VERSION "1.0.0" + class KVIRC_API KviThemeInfo : public KviHeapObject { public: @@ -50,7 +54,7 @@ protected: QString m_szDescription; // description of the theme QString m_szDate; // theme creation date QString m_szApplication; // theme creation (KVIrc) version - QString m_szMinimumKVIrcVersion; // minimum KVIrc version for this theme to work + QString m_szThemeEngineVersion; // the theme engine version that saved this theme QString m_szLastError; // reported when some function fails public: @@ -77,8 +81,8 @@ public: void setDate(const QString &szDate){ m_szDate = szDate; }; const QString & application(){ return m_szApplication; }; void setApplication(const QString &szApplication){ m_szApplication = szApplication; }; - const QString & minimumKVIrcVersion(){ return m_szMinimumKVIrcVersion; }; - void setMinimumKVIrcVersion(const QString &szMinimumKVIrcVersion){ m_szMinimumKVIrcVersion = szMinimumKVIrcVersion; }; + const QString & themeEngineVersion(){ return m_szThemeEngineVersion; }; + void setThemeEngineVersion(const QString &szThemeEngineVersion){ m_szThemeEngineVersion = szThemeEngineVersion; }; // Attempt to load a themeinfo file present in the specified directory // This function will fail if the directory contains a valid themeinfo diff --git a/src/kvirc/kvs/kvi_kvs_parser_specialcommands.cpp b/src/kvirc/kvs/kvi_kvs_parser_specialcommands.cpp index e5cfeaa57..6a7037438 100644 --- a/src/kvirc/kvs/kvi_kvs_parser_specialcommands.cpp +++ b/src/kvirc/kvs/kvi_kvs_parser_specialcommands.cpp @@ -1290,7 +1290,7 @@ KviKvsTreeNodeCommand * KviKvsParser::parseSpecialCommandSwitch() The <value> is evaluated and is compared against the result of <expression>. The comparison is case insensitive (if the values are strings).[br] If <value> is equal to <expression> then <command> is executed. - <command> is a single instruction or an instruction block enclosed in braces. + Please note that <command> must be either a single instruction or an instruction block [b]enclosed in braces[/b]. If <command> contains a [cmd]break[/cmd] statement inside or if [cmd]break[/cmd] is specified just after the <command> then the execution of the switch is terminated otherwise the nex label is evaluated.[br] diff --git a/src/kvirc/kvs/kvi_kvs_treenode_specialcommandswitch.cpp b/src/kvirc/kvs/kvi_kvs_treenode_specialcommandswitch.cpp index c4515892e..8b7f4e803 100644 --- a/src/kvirc/kvs/kvi_kvs_treenode_specialcommandswitch.cpp +++ b/src/kvirc/kvs/kvi_kvs_treenode_specialcommandswitch.cpp @@ -35,37 +35,29 @@ KviKvsTreeNodeSpecialCommandSwitchLabel::KviKvsTreeNodeSpecialCommandSwitchLabel(const QChar * pLocation) : KviKvsTreeNode(pLocation) { -#ifdef COMPILE_NEW_KVS m_pParameter = 0; m_pInstruction = 0; m_bHasTerminatingBreak = false; -#endif } KviKvsTreeNodeSpecialCommandSwitchLabel::~KviKvsTreeNodeSpecialCommandSwitchLabel() { -#ifdef COMPILE_NEW_KVS if(m_pParameter)delete m_pParameter; if(m_pInstruction)delete m_pInstruction; -#endif } void KviKvsTreeNodeSpecialCommandSwitchLabel::setParameter(KviKvsTreeNodeData * pParameter) { -#ifdef COMPILE_NEW_KVS if(m_pParameter)delete m_pParameter; m_pParameter = pParameter; if(m_pParameter)m_pParameter->setParent(this); -#endif } void KviKvsTreeNodeSpecialCommandSwitchLabel::setInstruction(KviKvsTreeNodeInstruction * pInstruction) { -#ifdef COMPILE_NEW_KVS if(m_pInstruction)delete m_pInstruction; m_pInstruction = pInstruction; if(m_pInstruction)m_pInstruction->setParent(this); -#endif } @@ -83,25 +75,20 @@ KviKvsTreeNodeSpecialCommandSwitchLabelCase::~KviKvsTreeNodeSpecialCommandSwitch void KviKvsTreeNodeSpecialCommandSwitchLabelCase::contextDescription(QString &szBuffer) { -#ifdef COMPILE_NEW_KVS szBuffer = "Label \"case\" For Special Command \"switch\""; -#endif } void KviKvsTreeNodeSpecialCommandSwitchLabelCase::dump(const char * prefix) { -#ifdef COMPILE_NEW_KVS debug("%s SpecialCommandSwitchLabelCase",prefix); QString tmp = prefix; tmp.append(" "); if(m_pParameter)m_pParameter->dump(tmp.utf8().data()); if(m_pInstruction)m_pInstruction->dump(tmp.utf8().data()); -#endif } bool KviKvsTreeNodeSpecialCommandSwitchLabelCase::execute(KviKvsRunTimeContext * c,KviKvsVariant * pRealParameter) { -#ifdef COMPILE_NEW_KVS KviKvsVariant v; if(!m_pParameter->evaluateReadOnly(c,&v))return false; @@ -146,7 +133,6 @@ bool KviKvsTreeNodeSpecialCommandSwitchLabelCase::execute(KviKvsRunTimeContext * c->setBreakPending(); return false; } -#endif return true; } @@ -164,26 +150,21 @@ KviKvsTreeNodeSpecialCommandSwitchLabelMatch::~KviKvsTreeNodeSpecialCommandSwitc void KviKvsTreeNodeSpecialCommandSwitchLabelMatch::contextDescription(QString &szBuffer) { -#ifdef COMPILE_NEW_KVS szBuffer = "Label \"match\" For Special Command \"switch\""; -#endif } void KviKvsTreeNodeSpecialCommandSwitchLabelMatch::dump(const char * prefix) { -#ifdef COMPILE_NEW_KVS debug("%s SpecialCommandSwitchLabelMatch",prefix); QString tmp = prefix; tmp.append(" "); if(m_pParameter)m_pParameter->dump(tmp.utf8().data()); if(m_pInstruction)m_pInstruction->dump(tmp.utf8().data()); -#endif } bool KviKvsTreeNodeSpecialCommandSwitchLabelMatch::execute(KviKvsRunTimeContext * c,KviKvsVariant * pRealParameter) { -#ifdef COMPILE_NEW_KVS KviKvsVariant v; if(!m_pParameter->evaluateReadOnly(c,&v))return false; @@ -206,7 +187,6 @@ bool KviKvsTreeNodeSpecialCommandSwitchLabelMatch::execute(KviKvsRunTimeContext c->setBreakPending(); return false; } -#endif return true; } @@ -224,26 +204,21 @@ KviKvsTreeNodeSpecialCommandSwitchLabelRegexp::~KviKvsTreeNodeSpecialCommandSwit void KviKvsTreeNodeSpecialCommandSwitchLabelRegexp::contextDescription(QString &szBuffer) { -#ifdef COMPILE_NEW_KVS szBuffer = "Label \"regexp\" For Special Command \"switch\""; -#endif } void KviKvsTreeNodeSpecialCommandSwitchLabelRegexp::dump(const char * prefix) { -#ifdef COMPILE_NEW_KVS debug("%s SpecialCommandSwitchLabelRegexp",prefix); QString tmp = prefix; tmp.append(" "); if(m_pParameter)m_pParameter->dump(tmp.utf8().data()); if(m_pInstruction)m_pInstruction->dump(tmp.utf8().data()); -#endif } bool KviKvsTreeNodeSpecialCommandSwitchLabelRegexp::execute(KviKvsRunTimeContext * c,KviKvsVariant * pRealParameter) { -#ifdef COMPILE_NEW_KVS KviKvsVariant v; if(!m_pParameter->evaluateReadOnly(c,&v))return false; @@ -266,7 +241,6 @@ bool KviKvsTreeNodeSpecialCommandSwitchLabelRegexp::execute(KviKvsRunTimeContext c->setBreakPending(); return false; } -#endif return true; } @@ -286,25 +260,20 @@ KviKvsTreeNodeSpecialCommandSwitchLabelDefault::~KviKvsTreeNodeSpecialCommandSwi void KviKvsTreeNodeSpecialCommandSwitchLabelDefault::contextDescription(QString &szBuffer) { -#ifdef COMPILE_NEW_KVS szBuffer = "Label \"default\" For Special Command \"switch\""; -#endif } void KviKvsTreeNodeSpecialCommandSwitchLabelDefault::dump(const char * prefix) { -#ifdef COMPILE_NEW_KVS debug("%s SpecialCommandSwitchLabelDefault",prefix); QString tmp = prefix; tmp.append(" "); if(m_pInstruction)m_pInstruction->dump(tmp.utf8().data()); -#endif } bool KviKvsTreeNodeSpecialCommandSwitchLabelDefault::execute(KviKvsRunTimeContext * c,KviKvsVariant * pRealParameter) { -#ifdef COMPILE_NEW_KVS if(m_pInstruction) { if(!m_pInstruction->execute(c))return false; // might be a break too @@ -314,7 +283,6 @@ bool KviKvsTreeNodeSpecialCommandSwitchLabelDefault::execute(KviKvsRunTimeContex c->setBreakPending(); return false; } -#endif return true; } @@ -324,53 +292,42 @@ bool KviKvsTreeNodeSpecialCommandSwitchLabelDefault::execute(KviKvsRunTimeContex KviKvsTreeNodeSpecialCommandSwitch::KviKvsTreeNodeSpecialCommandSwitch(const QChar * pLocation,KviKvsTreeNodeExpression * e) : KviKvsTreeNodeSpecialCommand(pLocation,"switch") { -#ifdef COMPILE_NEW_KVS m_pExpression = e; m_pExpression->setParent(this); m_pLabels = new KviPtrList<KviKvsTreeNodeSpecialCommandSwitchLabel>; m_pLabels->setAutoDelete(true); -#endif } KviKvsTreeNodeSpecialCommandSwitch::~KviKvsTreeNodeSpecialCommandSwitch() { -#ifdef COMPILE_NEW_KVS delete m_pExpression; delete m_pLabels; -#endif } void KviKvsTreeNodeSpecialCommandSwitch::addLabel(KviKvsTreeNodeSpecialCommandSwitchLabel * l) { -#ifdef COMPILE_NEW_KVS m_pLabels->append(l); l->setParent(this); -#endif } void KviKvsTreeNodeSpecialCommandSwitch::contextDescription(QString &szBuffer) { -#ifdef COMPILE_NEW_KVS szBuffer = "Special Command \"switch\""; -#endif } void KviKvsTreeNodeSpecialCommandSwitch::dump(const char * prefix) { -#ifdef COMPILE_NEW_KVS debug("%s SpecialCommandSwitch",prefix); QString tmp = prefix; tmp.append(" "); m_pExpression->dump(tmp.utf8().data()); for(KviKvsTreeNodeSpecialCommandSwitchLabel * l = m_pLabels->first();l;l = m_pLabels->next()) l->dump(tmp.utf8().data()); -#endif } bool KviKvsTreeNodeSpecialCommandSwitch::execute(KviKvsRunTimeContext * c) { -#ifdef COMPILE_NEW_KVS KviKvsVariant v; if(!m_pExpression->evaluateReadOnly(c,&v))return false; @@ -388,6 +345,5 @@ bool KviKvsTreeNodeSpecialCommandSwitch::execute(KviKvsRunTimeContext * c) return false; } } -#endif return true; } diff --git a/src/modules/theme/packthemedialog.cpp b/src/modules/theme/packthemedialog.cpp index 8b53941cc..73352abbd 100644 --- a/src/modules/theme/packthemedialog.cpp +++ b/src/modules/theme/packthemedialog.cpp @@ -23,6 +23,7 @@ //============================================================================= #include "packthemedialog.h" +#include "themefunctions.h" #include <qlayout.h> #include <qpushbutton.h> @@ -57,6 +58,7 @@ #include "kvi_sourcesdate.h" + KviPackThemeDialog::KviPackThemeDialog(QWidget * pParent,KviPtrList<KviThemeInfo> * pThemeInfoList) : QWizard(pParent) { @@ -121,51 +123,25 @@ KviPackThemeDialog::KviPackThemeDialog(QWidget * pParent,KviPtrList<KviThemeInfo pLabel->setTextFormat(Qt::RichText); pLayout->addWidget(pLabel,0,0); - QString szAuthor = __tr2qs_ctx("Author","theme"); - QString szCreatedAt = __tr2qs_ctx("Created at","theme"); - QString szCreatedOn = __tr2qs_ctx("Created with","theme"); - QString szMinKVIrc = __tr2qs_ctx("Minimum KVIrc version","theme"); - QString szSubdirectory = __tr2qs_ctx("Subdirectory","theme"); - QString szThemesDescription = "<html><body bgcolor=\"#ffffff\">"; int iIdx = 0; for(pThemeInfo = m_pThemeInfoList->first();pThemeInfo;pThemeInfo = m_pThemeInfoList->next()) { QString szThemeDescription; - KviQString::sprintf( + + KviThemeFunctions::getThemeHtmlDescription( szThemeDescription, - "<p>" \ - "<h2>%Q %Q</h2>" \ - "</p>" \ - "<p>" \ - "<i>%Q</i>" \ - "</p>" \ - "<p>" \ - "%Q: <b>%Q</b><br>" \ - "%Q: <b>%Q</b><br>" \ - "</p>" \ - "<p>" \ - "<font color=\"#808080\">" \ - "%Q: %Q<br>" \ - "%Q: %Q<br>" \ - "%Q: %Q<br>" \ - "</font>" \ - "</p>", - &(pThemeInfo->name()), - &(pThemeInfo->version()), - &(pThemeInfo->description()), - &szAuthor, - &(pThemeInfo->author()), - &szCreatedAt, - &(pThemeInfo->date()), - &szCreatedOn, - &(pThemeInfo->application()), - &szMinKVIrc, - &(pThemeInfo->minimumKVIrcVersion()), - &szSubdirectory, - &(pThemeInfo->subdirectory()) + pThemeInfo->name(), + pThemeInfo->version(), + pThemeInfo->description(), + pThemeInfo->subdirectory(), + pThemeInfo->application(), + pThemeInfo->author(), + pThemeInfo->date(), + pThemeInfo->themeEngineVersion() ); + if(iIdx > 0) szThemesDescription += "<hr>"; szThemesDescription += szThemeDescription; @@ -394,8 +370,6 @@ bool KviPackThemeDialog::packTheme() szTmp.setNum(m_pThemeInfoList->count()); f.addInfoField("ThemeCount",szTmp); - QString szMinimumKVIrcVersion = "0"; - int iIdx = 0; for(KviThemeInfo * pInfo = m_pThemeInfoList->first();pInfo;pInfo = m_pThemeInfoList->next()) { @@ -413,8 +387,8 @@ bool KviPackThemeDialog::packTheme() f.addInfoField(szTmp,pInfo->author()); KviQString::sprintf(szTmp,"Theme%dApplication",iIdx); f.addInfoField(szTmp,pInfo->application()); - KviQString::sprintf(szTmp,"Theme%dMinimumKVIrcVersion",iIdx); - f.addInfoField(szTmp,pInfo->minimumKVIrcVersion()); + KviQString::sprintf(szTmp,"Theme%dThemeEngineVersion",iIdx); + f.addInfoField(szTmp,pInfo->themeEngineVersion()); if(!f.addDirectory(pInfo->absoluteDirectory(),pInfo->subdirectory())) { szTmp = __tr2qs_ctx("Packaging failed","theme"); @@ -423,18 +397,10 @@ bool KviPackThemeDialog::packTheme() QMessageBox::critical(this,__tr2qs_ctx("Export Theme - KVIrc","theme"),szTmp, QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); } - - if(KviMiscUtils::compareVersions(pInfo->minimumKVIrcVersion(),szMinimumKVIrcVersion) < 0) - szMinimumKVIrcVersion = pInfo->minimumKVIrcVersion(); - + iIdx++; } - // This is the maximum of the minimum KVIrc versions of the packed themes! - // FIXME: The packages should be warned if in this way we're raising the - // requirements on one of the packed themes... - f.addInfoField("MinimumKVIrcVersion",szMinimumKVIrcVersion); - if(!f.pack(m_szPackagePath)) { szTmp = __tr2qs_ctx("Packaging failed","theme"); diff --git a/src/modules/theme/themefunctions.cpp b/src/modules/theme/themefunctions.cpp index 8a071add3..d6fef4dc6 100644 --- a/src/modules/theme/themefunctions.cpp +++ b/src/modules/theme/themefunctions.cpp @@ -32,6 +32,7 @@ #include "kvi_iconmanager.h" #include "kvi_miscutils.h" #include "kvi_sourcesdate.h" +#include "kvi_theme.h" #include <qmime.h> @@ -53,7 +54,7 @@ namespace KviThemeFunctions QByteArray * pByteArray; KviHtmlDialogData hd; - const char * check_fields[] = { "Name", "Version", "Author", "Description", "Date", "MinimumKVIrcVersion", "Application" }; + const char * check_fields[] = { "Name", "Version", "Author", "Description", "Date", "Application" }; // check if it is a valid theme file KviPackageReader r; @@ -100,13 +101,12 @@ namespace KviThemeFunctions pix = *(g_pIconManager->getBigIcon(KVI_BIGICON_THEME)); } - /////////////////////////////////// QString szPackageName; QString szPackageVersion; QString szPackageAuthor; QString szPackageDescription; QString szPackageDate; - QString szPackageMinimumKVIrcVersion; + QString szPackageThemeEngineVersion; QString szPackageApplication; QString szAuthor = __tr2qs_ctx("Author","theme"); @@ -117,50 +117,99 @@ namespace KviThemeFunctions r.getStringInfoField("Version",szPackageVersion); r.getStringInfoField("Author",szPackageAuthor); r.getStringInfoField("Description",szPackageDescription); - r.getStringInfoField("MinimumKVIrcVersion",szPackageMinimumKVIrcVersion); r.getStringInfoField("Application",szPackageApplication); r.getStringInfoField("Date",szPackageDate); - if(KviMiscUtils::compareVersions(KVI_VERSION "." KVI_SOURCES_DATE,szPackageMinimumKVIrcVersion) > 0) - { - KviQString::sprintf(szError,__tr2qs_ctx("The selected theme package requires at least KVIrc %Q","theme"),&szPackageMinimumKVIrcVersion); - return false; - } + QString szWarnings; + QString szDetails = "<html><body bgcolor=\"#ffffff\">"; + QString szTmp; - /* int iIdx = 0; - for(KviThemeInfo * pInfo = m_pThemeInfoList->first();pInfo;pInfo = m_pThemeInfoList->next()) + int iValidThemeCount = iThemeCount; + + while(iIdx < iThemeCount) { + bool bValid = true; + + QString szThemeName; + QString szThemeVersion; + QString szThemeDescription; + QString szThemeDate; + QString szThemeSubdirectory; + QString szThemeAuthor; + QString szThemeThemeEngineVersion; + QString szThemeApplication; + KviQString::sprintf(szTmp,"Theme%dName",iIdx); - f.addInfoField(szTmp,pInfo->szName); + r.getStringInfoField(szTmp,szThemeName); KviQString::sprintf(szTmp,"Theme%dVersion",iIdx); - f.addInfoField(szTmp,pInfo->szVersion); + r.getStringInfoField(szTmp,szThemeVersion); + KviQString::sprintf(szTmp,"Theme%dApplication",iIdx); + r.getStringInfoField(szTmp,szThemeApplication); KviQString::sprintf(szTmp,"Theme%dDescription",iIdx); - f.addInfoField(szTmp,pInfo->szDescription); + r.getStringInfoField(szTmp,szThemeDescription); KviQString::sprintf(szTmp,"Theme%dDate",iIdx); - f.addInfoField(szTmp,pInfo->szDate); + r.getStringInfoField(szTmp,szThemeDate); KviQString::sprintf(szTmp,"Theme%dSubdirectory",iIdx); - f.addInfoField(szTmp,pInfo->szSubdirectory); + r.getStringInfoField(szTmp,szThemeSubdirectory); KviQString::sprintf(szTmp,"Theme%dAuthor",iIdx); - f.addInfoField(szTmp,pInfo->szAuthor); - KviQString::sprintf(szTmp,"Theme%dKVIrcVersion",iIdx); - f.addInfoField(szTmp,pInfo->szKvircVersion); - if(!f.addDirectory(pInfo->szAbsoluteDirectory,pInfo->szSubdirectory)) + r.getStringInfoField(szTmp,szThemeAuthor); + KviQString::sprintf(szTmp,"Theme%dThemeEngineVersion",iIdx); + r.getStringInfoField(szTmp,szThemeThemeEngineVersion); + + if(szThemeName.isEmpty() || szThemeVersion.isEmpty() || szThemeSubdirectory.isEmpty() || szThemeThemeEngineVersion.isEmpty()) + bValid = false; + if(KviMiscUtils::compareVersions(szThemeThemeEngineVersion,KVI_CURRENT_THEME_ENGINE_VERSION) < 0) + bValid = false; + + QString szDetailsBuffer; + + getThemeHtmlDescription( + szDetailsBuffer, + szThemeName, + szThemeVersion, + szThemeDescription, + szThemeSubdirectory, + szThemeApplication, + szThemeAuthor, + szThemeDate, + szThemeThemeEngineVersion + ); + + szDetails += szDetailsBuffer; + + if(!bValid) { - szTmp = __tr2qs_ctx("Packaging failed","theme"); - szTmp += ": "; - szTmp += f.lastError(); - QMessageBox::critical(this,__tr2qs_ctx("Export Theme - KVIrc","theme"),szTmp, - QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); + szDetails += "<p><center><font color=\"#ff0000\"><b>"; + szDetails += __tr2qs_ctx("Warning: The theme might be incompatible with this version of KVIrc","theme"); + szDetails += "</b></font></center></p>"; + iValidThemeCount--; } + + if(iIdx > 0) + szDetails += "<hr>"; + iIdx++; } - */ + + szDetails += "<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) + { + szWarnings += "<p><center><font color=\"#ff0000\"><b>"; + szWarnings += __tr2qs_ctx("Warning: Some of the theme contained in this package might be either corrupted or incompatible with this version of KVIrc","theme"); + szWarnings += "</b></font></center></p>"; + } + + QString szShowDetails = __tr2qs_ctx("Show Details","theme"); KviQString::sprintf(hd.szHtmlText, "<html bgcolor=\"#ffffff\">" \ "<body bgcolor=\"#ffffff\">" \ - "<br>" \ "<p><center>" \ "<h2>%Q %Q</h2>" \ "</center></p>" \ @@ -179,9 +228,10 @@ namespace KviThemeFunctions "%Q: %Q<br>" \ "</font>" \ "</center></p>" \ + "%Q" \ "<br>" \ "<p><center>" \ - "<a href=\"theme_dialog_details\">Show Details</a>" \ + "<a href=\"theme_dialog_details\">%Q</a>" \ "</center></p>" \ "</body>" \ "</html>", @@ -193,10 +243,10 @@ namespace KviThemeFunctions &szCreatedAt, &szPackageDate, &szCreatedOn, - &szPackageApplication + &szPackageApplication, + &szWarnings ); - QString szDetails = "Doh.. da details"; QMimeSourceFactory::defaultFactory()->setPixmap("theme_dialog_pack_image",pix); @@ -236,5 +286,59 @@ namespace KviThemeFunctions } + void getThemeHtmlDescription( + QString &szBuffer, + const QString &szThemeName, + const QString &szThemeVersion, + const QString &szThemeDescription, + const QString &szThemeSubdirectory, + const QString &szThemeApplication, + const QString &szThemeAuthor, + const QString &szThemeDate, + const QString &szThemeThemeEngineVersion + ) + { + QString szAuthor = __tr2qs_ctx("Author","theme"); + QString szCreatedAt = __tr2qs_ctx("Created at","theme"); + QString szCreatedOn = __tr2qs_ctx("Created with","theme"); + QString szThemeEngineVersion = __tr2qs_ctx("Theme Engine Version","theme"); + QString szSubdirectory = __tr2qs_ctx("Subdirectory","theme"); + + KviQString::sprintf( + szBuffer, + "<p>" \ + "<h2>%Q %Q</h2>" \ + "</p>" \ + "<p>" \ + "<i>%Q</i>" \ + "</p>" \ + "<p>" \ + "%Q: <b>%Q</b><br>" \ + "%Q: <b>%Q</b><br>" \ + "</p>" \ + "<p>" \ + "<font color=\"#808080\">" \ + "%Q: %Q<br>" \ + "%Q: %Q<br>" \ + "%Q: %Q<br>" \ + "</font>" \ + "</p>", + &szThemeName, + &szThemeVersion, + &szThemeDescription, + &szAuthor, + &szThemeAuthor, + &szCreatedAt, + &szThemeDate, + &szCreatedOn, + &szThemeApplication, + &szThemeEngineVersion, + &szThemeThemeEngineVersion, + &szSubdirectory, + &szThemeSubdirectory + ); + } + + }; diff --git a/src/modules/theme/themefunctions.h b/src/modules/theme/themefunctions.h index 42949c1b4..b628df4fb 100644 --- a/src/modules/theme/themefunctions.h +++ b/src/modules/theme/themefunctions.h @@ -32,6 +32,17 @@ namespace KviThemeFunctions { bool installThemePackage(const QString &szThemePackageFileName,QString &szError,QWidget * pDialogParent = 0); + void getThemeHtmlDescription( + QString &szBuffer, + const QString &szThemeName, + const QString &szThemeVersion, + const QString &szThemeDescription, + const QString &szThemeSubdirectory, + const QString &szThemeApplication, + const QString &szThemeAuthor, + const QString &szThemeDate, + const QString &szThemeThemeEngineVersion + ); }; |
