aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Elvio Basello2009-09-17 17:01:03 +0000
committerGravatar Elvio Basello2009-09-17 17:01:03 +0000
commitc12f38c52866b12e1e588f80265ab3b4c09d72b9 (patch)
tree3360e05236ebdec287887466d21609084283d8c9 /src
parentsuppressed gcc warning (diff)
downloadKVIrc-c12f38c52866b12e1e588f80265ab3b4c09d72b9.tar.gz
KVIrc-c12f38c52866b12e1e588f80265ab3b4c09d72b9.tar.bz2
KVIrc-c12f38c52866b12e1e588f80265ab3b4c09d72b9.zip
reworked addon system:
- ported to the new way of handling wizard; - added automagic functions; modified file extensions; This new addon system is far to be complete and does NOT create any package yet. Please test the new GUI git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@3502 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src')
-rw-r--r--src/kvilib/config/kvi_confignames.h48
-rw-r--r--src/kvilib/config/kvi_fileextensions.h8
-rw-r--r--src/kvirc/kernel/kvi_theme.h4
-rw-r--r--src/modules/addon/AddonTest-1.0.0.kvabin8854 -> 0 bytes
-rw-r--r--src/modules/addon/addonfunctions.h21
-rw-r--r--src/modules/addon/managementdialog.cpp31
-rw-r--r--src/modules/addon/managementdialog.h25
-rw-r--r--src/modules/addon/packaddondialog.cpp606
-rw-r--r--src/modules/addon/packaddondialog.h409
-rw-r--r--src/modules/theme/packthemedialog.cpp6
10 files changed, 868 insertions, 290 deletions
diff --git a/src/kvilib/config/kvi_confignames.h b/src/kvilib/config/kvi_confignames.h
index d2e755dc9..ff5b3f589 100644
--- a/src/kvilib/config/kvi_confignames.h
+++ b/src/kvilib/config/kvi_confignames.h
@@ -61,29 +61,29 @@
#include "kvi_fileextensions.h"
-#define KVI_CONFIGFILE_MAIN "main." KVI_FILEEXTENSION_CONFIG
-#define KVI_CONFIGFILE_WINPROPERTIES "winproperties." KVI_FILEEXTENSION_CONFIG
-#define KVI_CONFIGFILE_SERVERDB "serverdb." KVI_FILEEXTENSION_CONFIG
-#define KVI_CONFIGFILE_PROXYDB "proxydb." KVI_FILEEXTENSION_CONFIG
-#define KVI_CONFIGFILE_EVENTS "events." KVI_FILEEXTENSION_CONFIG
-#define KVI_CONFIGFILE_RAWEVENTS "rawevents." KVI_FILEEXTENSION_CONFIG
-#define KVI_CONFIGFILE_POPUPS "popups." KVI_FILEEXTENSION_CONFIG
-#define KVI_CONFIGFILE_SCRIPTTOOLBARS "toolbars." KVI_FILEEXTENSION_CONFIG
-#define KVI_CONFIGFILE_CUSTOMTOOLBARS "customtoolbars." KVI_FILEEXTENSION_CONFIG
-#define KVI_CONFIGFILE_MEDIATYPES "mediatypes." KVI_FILEEXTENSION_CONFIG
-#define KVI_CONFIGFILE_REGUSERDB "reguserdb." KVI_FILEEXTENSION_CONFIG
-#define KVI_CONFIGFILE_SHAREDFILES "sharedfiles." KVI_FILEEXTENSION_CONFIG
-#define KVI_CONFIGFILE_RECENT "recent." KVI_FILEEXTENSION_CONFIG
-#define KVI_CONFIGFILE_TOOLBARS "toolbarpos." KVI_FILEEXTENSION_CONFIG
-#define KVI_CONFIGFILE_ALIASES "aliases." KVI_FILEEXTENSION_CONFIG
-#define KVI_CONFIGFILE_NICKSERVDATABASE "nickserv." KVI_FILEEXTENSION_CONFIG
-#define KVI_CONFIGFILE_PROFILESDATABASE "identityprofiles." KVI_FILEEXTENSION_CONFIG
-#define KVI_CONFIGFILE_TEXTICONS "texticons." KVI_FILEEXTENSION_CONFIG
-#define KVI_CONFIGFILE_REGCHANDB "regchan." KVI_FILEEXTENSION_CONFIG
-#define KVI_CONFIGFILE_INPUTHISTORY "inputhistory." KVI_FILEEXTENSION_CONFIG
-#define KVI_CONFIGFILE_AVATARCACHE "avatarcache." KVI_FILEEXTENSION_CONFIG
-#define KVI_CONFIGFILE_USERACTIONS "useractions." KVI_FILEEXTENSION_CONFIG
-#define KVI_CONFIGFILE_SCRIPTADDONS "scriptaddons." KVI_FILEEXTENSION_CONFIG
-#define KVI_CONFIGFILE_IDENTITIES "identities." KVI_FILEEXTENSION_CONFIG
+#define KVI_CONFIGFILE_MAIN "main" KVI_FILEEXTENSION_CONFIG
+#define KVI_CONFIGFILE_WINPROPERTIES "winproperties" KVI_FILEEXTENSION_CONFIG
+#define KVI_CONFIGFILE_SERVERDB "serverdb" KVI_FILEEXTENSION_CONFIG
+#define KVI_CONFIGFILE_PROXYDB "proxydb" KVI_FILEEXTENSION_CONFIG
+#define KVI_CONFIGFILE_EVENTS "events" KVI_FILEEXTENSION_CONFIG
+#define KVI_CONFIGFILE_RAWEVENTS "rawevents" KVI_FILEEXTENSION_CONFIG
+#define KVI_CONFIGFILE_POPUPS "popups" KVI_FILEEXTENSION_CONFIG
+#define KVI_CONFIGFILE_SCRIPTTOOLBARS "toolbars" KVI_FILEEXTENSION_CONFIG
+#define KVI_CONFIGFILE_CUSTOMTOOLBARS "customtoolbars" KVI_FILEEXTENSION_CONFIG
+#define KVI_CONFIGFILE_MEDIATYPES "mediatypes" KVI_FILEEXTENSION_CONFIG
+#define KVI_CONFIGFILE_REGUSERDB "reguserdb" KVI_FILEEXTENSION_CONFIG
+#define KVI_CONFIGFILE_SHAREDFILES "sharedfiles" KVI_FILEEXTENSION_CONFIG
+#define KVI_CONFIGFILE_RECENT "recent" KVI_FILEEXTENSION_CONFIG
+#define KVI_CONFIGFILE_TOOLBARS "toolbarpos" KVI_FILEEXTENSION_CONFIG
+#define KVI_CONFIGFILE_ALIASES "aliases" KVI_FILEEXTENSION_CONFIG
+#define KVI_CONFIGFILE_NICKSERVDATABASE "nickserv" KVI_FILEEXTENSION_CONFIG
+#define KVI_CONFIGFILE_PROFILESDATABASE "identityprofiles" KVI_FILEEXTENSION_CONFIG
+#define KVI_CONFIGFILE_TEXTICONS "texticons" KVI_FILEEXTENSION_CONFIG
+#define KVI_CONFIGFILE_REGCHANDB "regchan" KVI_FILEEXTENSION_CONFIG
+#define KVI_CONFIGFILE_INPUTHISTORY "inputhistory" KVI_FILEEXTENSION_CONFIG
+#define KVI_CONFIGFILE_AVATARCACHE "avatarcache" KVI_FILEEXTENSION_CONFIG
+#define KVI_CONFIGFILE_USERACTIONS "useractions" KVI_FILEEXTENSION_CONFIG
+#define KVI_CONFIGFILE_SCRIPTADDONS "scriptaddons" KVI_FILEEXTENSION_CONFIG
+#define KVI_CONFIGFILE_IDENTITIES "identities" KVI_FILEEXTENSION_CONFIG
#endif //_KVI_CONFIGNAMES_H_
diff --git a/src/kvilib/config/kvi_fileextensions.h b/src/kvilib/config/kvi_fileextensions.h
index be75de7a2..9658466fe 100644
--- a/src/kvilib/config/kvi_fileextensions.h
+++ b/src/kvilib/config/kvi_fileextensions.h
@@ -39,10 +39,10 @@
* \def KVI_FILEEXTENSION_THEMEPACKAGE Theme package .kvt
* \def KVI_FILEEXTENSION_ADDONPACKAGE Addon package .kva
*/
-#define KVI_FILEEXTENSION_CONFIG "kvc"
-#define KVI_FILEEXTENSION_SCRIPT "kvs"
-#define KVI_FILEEXTENSION_THEMEPACKAGE "kvt"
-#define KVI_FILEEXTENSION_ADDONPACKAGE "kva"
+#define KVI_FILEEXTENSION_CONFIG ".kvc"
+#define KVI_FILEEXTENSION_SCRIPT ".kvs"
+#define KVI_FILEEXTENSION_THEMEPACKAGE ".kvt"
+#define KVI_FILEEXTENSION_ADDONPACKAGE ".kva"
/**
* \brief Filters
diff --git a/src/kvirc/kernel/kvi_theme.h b/src/kvirc/kernel/kvi_theme.h
index f9266b2e5..41bb9a3f7 100644
--- a/src/kvirc/kernel/kvi_theme.h
+++ b/src/kvirc/kernel/kvi_theme.h
@@ -32,8 +32,8 @@
#include <QPixmap>
-#define KVI_THEMEINFO_FILE_NAME "themeinfo." KVI_FILEEXTENSION_CONFIG
-#define KVI_THEMEDATA_FILE_NAME "themedata." KVI_FILEEXTENSION_CONFIG
+#define KVI_THEMEINFO_FILE_NAME "themeinfo" KVI_FILEEXTENSION_CONFIG
+#define KVI_THEMEDATA_FILE_NAME "themedata" KVI_FILEEXTENSION_CONFIG
#define KVI_THEMEINFO_CONFIG_GROUP "ThemeInfo"
#define KVI_THEMEDATA_CONFIG_GROUP "ThemeData"
diff --git a/src/modules/addon/AddonTest-1.0.0.kva b/src/modules/addon/AddonTest-1.0.0.kva
deleted file mode 100644
index dc3d23b24..000000000
--- a/src/modules/addon/AddonTest-1.0.0.kva
+++ /dev/null
Binary files differ
diff --git a/src/modules/addon/addonfunctions.h b/src/modules/addon/addonfunctions.h
index 47f49813d..55c952c11 100644
--- a/src/modules/addon/addonfunctions.h
+++ b/src/modules/addon/addonfunctions.h
@@ -34,20 +34,19 @@
namespace KviAddonFunctions
{
- bool notAValidAddonPackage(QString &szError);
- bool installAddonPackage(const QString &szAddonPackageFileName,QString &szError,QWidget * pDialogParent = 0);
+ bool notAValidAddonPackage(QString & szError);
+ bool installAddonPackage(const QString & szAddonPackageFileName, QString & szError, QWidget * pDialogParent = 0);
void getAddonHtmlDescription(
- QString &szBuffer,
- const QString &szAddonName,
- const QString &szAddonVersion,
- const QString &szAddonDescription,
- const QString &szAddonApplication,
- const QString &szAddonAuthor,
- const QString &szAddonDate,
- const QString &szAddonAddonEngineVersion
+ QString & szBuffer,
+ const QString & szAddonName,
+ const QString & szAddonVersion,
+ const QString & szAddonDescription,
+ const QString & szAddonApplication,
+ const QString & szAddonAuthor,
+ const QString & szAddonDate,
+ const QString & szAddonAddonEngineVersion
);
QString createRandomDir();
}
-
#endif //!_ADDONFUNCTIONS_H_
diff --git a/src/modules/addon/managementdialog.cpp b/src/modules/addon/managementdialog.cpp
index b5e57554b..513eeef30 100644
--- a/src/modules/addon/managementdialog.cpp
+++ b/src/modules/addon/managementdialog.cpp
@@ -253,8 +253,11 @@ void KviScriptManagementDialog::uninstallScript()
txt += __tr2qs("Do you really want to uninstall the addon \"%1\" ?").arg(it->addon()->visibleName());
txt += "</p>";
- if(QMessageBox::question(this,
- __tr2qs("Confirm addon uninstallation"),txt,__tr2qs("&Yes"),__tr2qs("&No"),0,1) != 0)return;
+ if(QMessageBox::question(
+ this,
+ __tr2qs("Confirm addon uninstallation"),
+ txt, __tr2qs("&Yes"), __tr2qs("&No"),0,1
+ ) != 0) return;
KviKvsScriptAddonManager::instance()->unregisterAddon(it->addon()->name(),g_pActiveWindow);
@@ -271,7 +274,11 @@ void KviScriptManagementDialog::installScript()
{
QString szFileName, szError;
- if(!KviFileDialog::askForOpenFileName(szFileName,__tr2qs("Please select the addon installation file"),QString(),KVI_FILTER_SCRIPTS,false,true))return;
+ if(!KviFileDialog::askForOpenFileName(
+ szFileName,
+ __tr2qs("Please select the addon installation file"),
+ QString(),KVI_FILTER_SCRIPTS,false,true
+ )) return;
szFileName.replace("\\","\\\\");
@@ -288,14 +295,28 @@ void KviScriptManagementDialog::installScript()
qDebug("Addon file .kva");
if(!KviAddonFunctions::installAddonPackage(szFileName,szError,this))
{
- QMessageBox::critical(this,__tr2qs_ctx("Install Addon - KVIrc","addon"),szError,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
+ QMessageBox::critical(
+ this,
+ __tr2qs_ctx("Install Addon - KVIrc","addon"),
+ szError,
+ QMessageBox::Ok,
+ QMessageBox::NoButton,
+ QMessageBox::NoButton
+ );
return;
}
} else {
// Just for sanity check. We should NEVER enter here
qDebug("Entered sanity check");
KviAddonFunctions::notAValidAddonPackage(szError);
- QMessageBox::critical(this,__tr2qs_ctx("Install Addon - KVIrc","addon"),szError,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
+ QMessageBox::critical(
+ this,
+ __tr2qs_ctx("Install Addon - KVIrc","addon"),
+ szError,
+ QMessageBox::Ok,
+ QMessageBox::NoButton,
+ QMessageBox::NoButton
+ );
}
fillListView();
diff --git a/src/modules/addon/managementdialog.h b/src/modules/addon/managementdialog.h
index 20a23cb74..cfcfe8f31 100644
--- a/src/modules/addon/managementdialog.h
+++ b/src/modules/addon/managementdialog.h
@@ -39,8 +39,6 @@
class QPixmap;
class KviKvsScriptAddon;
-
-
class KviScriptAddonListViewItem : public KviTalListWidgetItem
{
public:
@@ -48,13 +46,12 @@ public:
~KviScriptAddonListViewItem();
protected:
KviKvsScriptAddon * m_pAddon;
- QTextDocument * m_pText;
- QPixmap * m_pIcon;
- QListWidget * m_pListWidget;
- QString m_szKey;
+ QTextDocument * m_pText;
+ QPixmap * m_pIcon;
+ QListWidget * m_pListWidget;
+ QString m_szKey;
public:
KviKvsScriptAddon * addon(){ return m_pAddon; };
-
};
@@ -66,12 +63,12 @@ protected:
public:
~KviScriptManagementDialog();
protected:
- KviTalListWidget * m_pListWidget;
+ KviTalListWidget * m_pListWidget;
static KviScriptManagementDialog * m_pInstance;
- QToolButton * m_pConfigureButton;
- QToolButton * m_pHelpButton;
- QToolButton * m_pPackButton;
- QToolButton * m_pUninstallButton;
+ QToolButton * m_pConfigureButton;
+ QToolButton * m_pHelpButton;
+ QToolButton * m_pPackButton;
+ QToolButton * m_pUninstallButton;
public:
static KviScriptManagementDialog * instance(){ return m_pInstance; };
static void display();
@@ -79,9 +76,9 @@ public:
protected:
void fillListView();
virtual void showEvent(QShowEvent * e);
- virtual void closeEvent(QCloseEvent *e);
+ virtual void closeEvent(QCloseEvent * e);
protected slots:
- void currentChanged(QListWidgetItem *i,QListWidgetItem *);
+ void currentChanged(QListWidgetItem * i, QListWidgetItem *);
void closeClicked();
void configureScript();
void showScriptHelp();
diff --git a/src/modules/addon/packaddondialog.cpp b/src/modules/addon/packaddondialog.cpp
index 242cef58c..05a3f93b4 100644
--- a/src/modules/addon/packaddondialog.cpp
+++ b/src/modules/addon/packaddondialog.cpp
@@ -4,8 +4,7 @@
// Creation date : Sat 03 May 2008 01:40:44 by Elvio Basello
//
// This file is part of the KVIrc IRC Client distribution
-// Copyright (C) 2008 Elvio Basello <hellvis69 at netsons dot org>
-// Copyright (C) 2008 Alessandro Carbone <elfonol at gmail dot com>
+// Copyright (C) 2008-2009 Elvio Basello <hellvis69 at netsons dot org>
//
// This program is FREE software. You can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -42,98 +41,301 @@
#include "kvi_sourcesdate.h"
#include "kvi_tal_textedit.h"
-#include <QLayout>
-#include <QPushButton>
#include <QLineEdit>
-#include <QRegExp>
#include <QMessageBox>
#include <QDir>
-#include <QComboBox>
-#include <QPainter>
-#include <QToolTip>
-#include <QImage>
#include <QDateTime>
-#include <QBuffer>
#include <QLabel>
#include <QString>
KviPackAddonDialog::KviPackAddonDialog(QWidget * pParent)
-: KviTalWizard(pParent)
+: QWizard(pParent)
{
- setWindowTitle(__tr2qs_ctx("Create Addon Package - KVIrc","addon"));
setMinimumSize(400,350);
+ setObjectName("addon_package_wizard");
+ setOption(QWizard::IndependentPages,true);
+ setWindowTitle(__tr2qs_ctx("Create Addon Package - KVIrc","addon"));
+
+ QPixmap * pSide = g_pIconManager->getBigIcon("kvi_setup_label.png");
+ QPixmap * pLogo = g_pIconManager->getBigIcon("kvi_bigicon_addons.png");
+
+#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)
+ #if (_WIN32_WINNT >= 0x0600)
+ // We are on a Windows Vista / Seven
+ // It will fallback to XP if alpha compositing is disabled
+ setWizardStyle(QWizard::AeroStyle);
+ #else
+ // Windows XP
+ setWizardStyle(QWizard::ModernStyle);
+ setPixmap(QWizard::WatermarkPixmap,*pSide);
+ setPixmap(QWizard::LogoPixmap,*pLogo);
+ #endif
+#elseif defined(COMPILE_ON_MAC)
+ setWizardStyle(QWizard::MacStyle);
+ setPixmap(QWizard::BackgroundPixmap,*pSide);
+#else
+ // All other systems
+ setWizardStyle(QWizard::ClassicStyle);
+ setPixmap(QWizard::WatermarkPixmap,*pSide);
+ setPixmap(QWizard::LogoPixmap,*pLogo);
+#endif
// Welcome page
- QWidget * pPage = new QWidget(this);
- QGridLayout * pLayout = new QGridLayout(pPage);
+ QWizardPage * pPage = new QWizardPage(this);
+ QVBoxLayout * pLayout = new QVBoxLayout(pPage);
+
+ pPage->setLayout(pLayout);
+ pPage->setTitle(__tr2qs_ctx("Welcome","addon"));
QLabel * pLabel = new QLabel(pPage);
- QString szText = "<p>";
- szText += __tr2qs_ctx("This procedure allows you to export the selected addon to a single package. It is useful when you want to distribute your addon to the public.","addon");
- szText += "</p><p>";
- szText += __tr2qs_ctx("You will be asked to provide a package name, a version and a description.","addon");
- szText += "</p><p>";
- szText += __tr2qs_ctx("Hit the \"Next\" button to begin.","addon");
- szText += "<p>";
+ pLabel->setText(__tr2qs_ctx("This procedure allows you to export the selected addon to a single package. It is useful when you want to distribute your addon to the public.","addon"));
+ pLayout->addWidget(pLabel);
+ pLabel = new QLabel(pPage);
+ QString szText;
+ szText += __tr2qs_ctx("You will be asked to provide some informations like the package name, the version, a description and so on.","addon");
+ szText += "<br><br>";
+ szText += __tr2qs_ctx("Hit the \"Next\" button to begin.","addon");
pLabel->setText(szText);
- pLayout->addWidget(pLabel,0,0);
- pLayout->setRowStretch(1,1);
-
- addPage(pPage,__tr2qs_ctx("Welcome","addon"));
-
- setBackEnabled(pPage,false);
- setNextEnabled(pPage,true);
- setHelpEnabled(pPage,false);
- setFinishEnabled(pPage,false);
+ pLayout->addWidget(pLabel);
+ addPage(pPage);
// Packager informations
- m_pPackAddonInfoCreateWidget=new KviPackAddonCreateInfoPackageWidget(this);
- addPage(m_pPackAddonInfoCreateWidget,__tr2qs_ctx("Package Informations","addon"));
- setBackEnabled(m_pPackAddonInfoCreateWidget,true);
- setHelpEnabled(m_pPackAddonInfoCreateWidget,false);
- setNextEnabled(m_pPackAddonInfoCreateWidget,true);
- setFinishEnabled(m_pPackAddonInfoCreateWidget,false);
+ m_pPackAddonInfoPackageWidget = new KviPackAddonInfoPackageWidget(this);
+ addPage(m_pPackAddonInfoPackageWidget);
// File selection
m_pPackAddonFileSelectionWidget = new KviPackAddonFileSelectionWidget(this);
- addPage(m_pPackAddonFileSelectionWidget,__tr2qs_ctx("Package Files","addon"));
- setBackEnabled(m_pPackAddonFileSelectionWidget,true);
- setHelpEnabled(m_pPackAddonFileSelectionWidget,false);
- setNextEnabled(m_pPackAddonFileSelectionWidget,true);
- setFinishEnabled(m_pPackAddonFileSelectionWidget,false);
+ addPage(m_pPackAddonFileSelectionWidget);
// Save selection
m_pPackAddonSaveSelectionWidget = new KviPackAddonSaveSelectionWidget(this);
- addPage(m_pPackAddonSaveSelectionWidget,__tr2qs_ctx("Save Package","addon"));
- setBackEnabled(m_pPackAddonFileSelectionWidget,true);
- setHelpEnabled(m_pPackAddonFileSelectionWidget,false);
- setNextEnabled(m_pPackAddonFileSelectionWidget,true);
- setFinishEnabled(m_pPackAddonFileSelectionWidget,false);
+ addPage(m_pPackAddonSaveSelectionWidget);
// Final results
- m_pPackAddonInfoWidget=new KviPackAddonInfoWidget(this);
- addPage(m_pPackAddonInfoWidget,__tr2qs_ctx("Final Informations","addon"));
- setBackEnabled(m_pPackAddonInfoWidget,true);
- setHelpEnabled(m_pPackAddonInfoWidget,false);
- setNextEnabled(m_pPackAddonInfoWidget,false);
- setFinishEnabled(m_pPackAddonInfoWidget,true);
+ m_pPackAddonSummaryWidget = new KviPackAddonSummaryWidget(this);
+ addPage(m_pPackAddonSummaryWidget);
+}
+
+KviPackAddonDialog::~KviPackAddonDialog()
+{
}
void KviPackAddonDialog::accept()
{
- if(!packAddon())return;
- KviTalWizard::accept();
+ if(!packAddon()) return;
+ QWizard::accept();
+}
+
+bool KviPackAddonDialog::checkDirTree(QString & szAddonDir, QString * pszError)
+{
+ if(pszError) *pszError = "";
+
+ QDir addon(szAddonDir);
+ if(!addon.exists())
+ {
+ *pszError = __tr2qs_ctx("The selected directory does not exist.","addon");
+ return false;
+ }
+
+ QDir source(szAddonDir + "/src");
+ if(!source.exists())
+ {
+ *pszError = __tr2qs_ctx("The sources directory (src) does not exist.","addon");
+ return false;
+ }
+
+ QDir locale(szAddonDir + "/locale");
+ if(!locale.exists())
+ {
+ *pszError = __tr2qs_ctx("The translations directory (locale) does not exist.","addon");
+ return false;
+ }
+
+ QDir sound(szAddonDir + "/sound");
+ if(!sound.exists())
+ {
+ *pszError = __tr2qs_ctx("The sounds directory (sound) does not exist.","addon");
+ return false;
+ }
+
+ QDir pics(szAddonDir + "/pics");
+ if(!pics.exists())
+ {
+ *pszError = __tr2qs_ctx("The pictures directory (pics) does not exist.","addon");
+ return false;
+ }
+
+ QDir config(szAddonDir + "/config");
+ if(!config.exists())
+ {
+ *pszError = __tr2qs_ctx("The configurations directory (config) does not exist.","addon");
+ return false;
+ }
+
+ QDir help(szAddonDir + "/help");
+ if(!help.exists())
+ {
+ *pszError = __tr2qs_ctx("The help directory (help) does not exist.","addon");
+ return false;
+ }
+
+ return true;
+}
+
+bool KviPackAddonDialog::createInstaller(QString & szAddonDir, QString * pszError)
+{
+ if(pszError) *pszError = "";
+
+ // We don't need to check dir existance since it was checked just before
+ QDir addon(szAddonDir);
+
+ // Open file for writing
+ QFile installer(addon.filePath("install.kvs"));
+ if(!installer.open(QIODevice::ReadWrite))
+ {
+ *pszError = __tr2qs_ctx("Cannot open file for writing.","addon");
+ return false;
+ }
+#if 0
+ // Get widgets data
+ KviPackAddonInfoPackageWidget * pInfo = infoWidget();
+ if(!pInfo)
+ {
+ *pszError = __tr2qs_ctx("The info widget does not exist","addon");
+ return false;
+ }
+
+ KviPackAddonFileSelectionWidget * pFile = fileWidget();
+ if(!pFile)
+ {
+ *pszError = __tr2qs_ctx("The file widget does not exist","addon");
+ return false;
+ }
+#endif
+ // Get data from registered fields
+ QString szAuthor = field("packageAuthor").toString();
+ QString szName = field("packageName").toString();
+ QString szVersion = field("packageVersion").toString();
+ QString szDescription = field("packageDescription").toString();
+ QString szMinVersion = field("packageMinVersion").toString();
+ QString szIcon = field("packageIcon").toString();
+
+ // Start creating install.kvs: header
+ QString szTmp;
+ szTmp += QString("# This file is generated automatically. Do NOT touch unless you know what are you doing\n#\n");
+ szTmp += QString("# %1\n# Written by %2\n# %3\n\n").arg(szName) \
+ .arg(szAuthor).arg(szDescription);
+ szTmp += "# Register the script: this must be the first instruction executed\n# since it will abort with an error when a greater version is already installed\n";
+
+ // install.kvs: addon registration
+ szTmp += QString("addon.register(\"%1\",\"%2\",\"%1\",\"%3\",\"%4\",\"%5\")\n") \
+ .arg(szName).arg(szVersion) \
+ .arg(szDescription).arg(szMinVersion) \
+ .arg(szIcon);
+ szTmp += "{\n\t# This is our uninstall callback: it will be called by KVIrc when addon.uninstall is invoked\n\t";
+ szTmp += QString("%1::uninstall::uninstall\n}\n\n").arg(szName);
+ szTmp += "# Ok, addon.register succeeded. We can go on with the installation.\n\n";
+
+ // install.kvs: run path
+ szTmp += "# Get the path that this script was launched from\n";
+ szTmp += "%mypath = $file.extractPath($0)\n\n";
+
+ // install.kvs: create an instance of the installer class
+ szTmp += "# The installer will copy our files and generate automatically an uninstallation\n# alias for them\n";
+ szTmp += "%installer = $new(installer,0,myaddon)\n\n";
+
+ // install.kvs: copy files
+ szTmp += "# Copy files in each subdirectory\n# the pics\n";
+ szTmp += QString("%installer->$copyFiles(\"%mypath/pics/\",\"*.png\",$file.localdir(\"pics/%1\"))\n\n").arg(szName);
+ szTmp += "# the translations\n";
+ szTmp += "%installer->$copyFiles(\"%mypath/locale/\",\"*.mo\",$file.localdir(\"locale\"))\n\n";
+ szTmp += "# the documentation\n";
+ szTmp += QString("%installer->$copyFiles(\"%mypath/help/en/%1/\",\"*.html\",$file.localdir(\"help/en/%1\"))\n\n").arg(szName);
+
+ // install.kvs: generate uninstall alias
+ szTmp += "# Generate the uninstall alias\n";
+ szTmp += QString("%installer->$generateUninstallAlias(\"%1::uninstall::uninstallfiles\")\n\n") \
+ .arg(szName);
+
+ // install.kvs: kill the installer class
+ szTmp += "# Kill the installer helper\n";
+ szTmp += "delete %installer\n\n";
+
+ // install.kvs: fetch the complete script
+ szTmp += "# Fetch the complete script\n";
+ szTmp += "%files[] = $file.ls($file.extractpath($0)/src,f)\n";
+ szTmp += QString("%alias = \"alias(%1::uninstall::uninstallaliases){$lf\"\n") \
+ .arg(szName);
+ szTmp += "for(%i=0; %i<$length(%files[]); %i++)\n{\n";
+ szTmp += "\tinclude $file.extractpath($0)/src/%files[%i]\n";
+ szTmp += "\t%flt = $str.left(%files[%i],$($str.len(%files[%i])-4))\n";
+ szTmp += "\t%file = $str.replace(%flt,\"::\",\"_\")\n";
+ szTmp += "\t%alias .= \"alias(%file){};$lf\"\n}\n";
+ szTmp += QString("%alias .= \"alias(%1::uninstall::uninstallaliases){};$lf\"\n") \
+ .arg(szName);
+ szTmp += "%alias .= \"}\"\n";
+ szTmp += "eval %alias\n\n";
+
+ // install.kvs: include initialization file
+ szTmp += "# Include initialization file\n";
+ szTmp += "include \"init.kvs\" %mypath\n\n";
+
+ // Put the install.kvs in the buffer
+ QByteArray buffer;
+ buffer.append(szTmp.toUtf8());
+
+ // Finally, write the buffer to the file descriptor
+ if(installer.write(buffer) == -1)
+ {
+ *pszError = __tr2qs_ctx("Cannot write to the file descriptor.","addon");
+ return false;
+ }
+
+ return true;
}
bool KviPackAddonDialog::packAddon()
{
- // Let's create the addon package
- QString szPackageAuthor = m_pPackAddonInfoCreateWidget->authorName();
- QString szPackageName = m_pPackAddonInfoCreateWidget->packageName();
- QString szPackageVersion = m_pPackAddonInfoCreateWidget->packageVersion();
- QString szPackageDescription = m_pPackAddonInfoCreateWidget->packageDescription();
+ QString szError;
+
+ // Get data from registered fields
+ QString szAuthor = field("packageAuthor").toString();
+ QString szName = field("packageName").toString();
+ QString szVersion = field("packageVersion").toString();
+ QString szDescription = field("packageDescription").toString();
+ QString szDirPath = field("packageDirPath").toString();
+ QString szSavePath = field("packageSavePath").toString();
+/*
+ QString szPackageAuthor = m_pPackAddonInfoPackageWidget->packageAuthor();
+ QString szPackageName = m_pPackAddonInfoPackageWidget->packageName();
+ QString szPackageVersion = m_pPackAddonInfoPackageWidget->packageVersion();
+ QString szPackageDescription = m_pPackAddonInfoPackageWidget->packageDescription();
+ QString szDirPath = m_pPackAddonFileSelectionWidget->dirPath();
+*//*
+ // Check the addon tree
+ if(!checkDirTree(szDirPath,&szError))
+ {
+ QMessageBox::critical(this,
+ __tr2qs_ctx("Addon Packaging Error","addon"),
+ szError,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton
+ );
+ return false;
+ }*/
+
+ // Create the installer file
+ if(!createInstaller(szDirPath,&szError))
+ {
+ QMessageBox::critical(this,
+ __tr2qs_ctx("Addon Packaging Error","addon"),
+ szError,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
+ return false;
+ }
+
+return false;
+#if 0
+/*
QString szSourcePath = m_pPackAddonFileSelectionWidget->sourcePath();
QString szConfigPath = m_pPackAddonFileSelectionWidget->configPath();
QString szImagePath = m_pPackAddonFileSelectionWidget->imagePath();
@@ -141,9 +343,11 @@ bool KviPackAddonDialog::packAddon()
QString szHelpPath = m_pPackAddonFileSelectionWidget->helpPath();
QString szSoundPath = m_pPackAddonFileSelectionWidget->soundPath();
QString szInstallPath = m_pPackAddonFileSelectionWidget->installerPath();
+*/
QString szPackagePath = m_pPackAddonSaveSelectionWidget->savePath();
// We need mandatory unix like path separator
+/*
szSourcePath.replace('\\',"/");
szConfigPath.replace('\\',"/");
szImagePath.replace('\\',"/");
@@ -151,6 +355,7 @@ bool KviPackAddonDialog::packAddon()
szHelpPath.replace('\\',"/");
szSoundPath.replace('\\',"/");
szInstallPath.replace('\\',"/");
+*/
szPackagePath.replace('\\',"/");
QString szTmp = QDateTime::currentDateTime().toString();
@@ -172,6 +377,7 @@ bool KviPackAddonDialog::packAddon()
szTmp += ": ";
szTmp += pw.lastError();
QMessageBox::critical(this,__tr2qs_ctx("Export Addon - KVIrc","addon"),szTmp,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
+ return false;
}
// Add config dir
@@ -181,6 +387,7 @@ bool KviPackAddonDialog::packAddon()
szTmp += ": ";
szTmp += pw.lastError();
QMessageBox::critical(this,__tr2qs_ctx("Export Addon - KVIrc","addon"),szTmp,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
+ return false;
}
// Add image dir
@@ -190,6 +397,7 @@ bool KviPackAddonDialog::packAddon()
szTmp += ": ";
szTmp += pw.lastError();
QMessageBox::critical(this,__tr2qs_ctx("Export Addon - KVIrc","addon"),szTmp,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
+ return false;
}
// Add localization dir
@@ -199,6 +407,7 @@ bool KviPackAddonDialog::packAddon()
szTmp += ": ";
szTmp += pw.lastError();
QMessageBox::critical(this,__tr2qs_ctx("Export Addon - KVIrc","addon"),szTmp,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
+ return false;
}
// Add help dir
@@ -208,6 +417,7 @@ bool KviPackAddonDialog::packAddon()
szTmp += ": ";
szTmp += pw.lastError();
QMessageBox::critical(this,__tr2qs_ctx("Export Addon - KVIrc","addon"),szTmp,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
+ return false;
}
// Add sound dir
@@ -217,6 +427,7 @@ bool KviPackAddonDialog::packAddon()
szTmp += ": ";
szTmp += pw.lastError();
QMessageBox::critical(this,__tr2qs_ctx("Export Addon - KVIrc","addon"),szTmp,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
+ return false;
}
// Add installer script
@@ -226,6 +437,7 @@ bool KviPackAddonDialog::packAddon()
szTmp += ": ";
szTmp += pw.lastError();
QMessageBox::critical(this,__tr2qs_ctx("Export Addon - KVIrc","addon"),szTmp,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
+ return false;
}
// Create the addon package
@@ -236,7 +448,6 @@ bool KviPackAddonDialog::packAddon()
szPackagePath += szPackageName;
szPackagePath += "-";
szPackagePath += szPackageVersion;
- szPackagePath += ".";
szPackagePath += KVI_FILEEXTENSION_ADDONPACKAGE;
qDebug("Addon name used: %s",szPackagePath.toUtf8().data());
}
@@ -253,160 +464,217 @@ bool KviPackAddonDialog::packAddon()
QMessageBox::information(this,__tr2qs_ctx("Export Addon - KVIrc","addon"),__tr2qs("Package saved successfully in ") + szPackagePath,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
return true;
+#endif
}
-KviPackAddonCreateInfoPackageWidget::KviPackAddonCreateInfoPackageWidget(KviPackAddonDialog *pParent)
-:QWidget(pParent)
+
+KviPackAddonInfoPackageWidget::KviPackAddonInfoPackageWidget(KviPackAddonDialog * pParent)
+: QWizardPage(pParent)
{
- QString szPackageName = "MyAddon";
- QString szPackageAuthor = __tr2qs_ctx("Your name here","addon");
- QString szPackageDescription = __tr2qs_ctx("Put a package description here...","addon");
- QString szPackageVersion = "1.0.0";
+ setTitle(__tr2qs_ctx("Package Informations","addon"));
+ setSubTitle(__tr2qs_ctx("Here you need to provide informations about you (the packager) and a short description of the package you're creating.","addon"));
+ //setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/watermark.png"));
- QGridLayout *pLayout = new QGridLayout(this);
+ // Default values
+ m_szPackageAuthor = __tr2qs_ctx("Your name here","addon");
+ m_szPackageName = "The name must NOT contains spaces, like MyAddon";
+ m_szPackageDescription = __tr2qs_ctx("Put a package description here...","addon");
+ m_szPackageVersion = "Version number in the form x.y[.z], like 1.0 or 2.0.3";
+ m_szPackageMinVersion = KVI_VERSION;
- QLabel *pLabel = new QLabel(this);
- pLabel->setText(__tr2qs_ctx("Here you need to provide informations about you (the packager) and a short description of the package you're creating.","addon"));
- pLabel->setWordWrap(true);
- pLabel->setTextFormat(Qt::RichText);
- pLayout->addWidget(pLabel,0,0,1,2);
+ QGridLayout * pLayout = new QGridLayout(this);
+
+ QLabel * pLabel = new QLabel(this);
+ pLabel->setText(__tr2qs_ctx("Package &Author:","addon"));
+ pLayout->addWidget(pLabel,0,0);
+
+ m_pPackageAuthorEdit = new QLineEdit(this);
+ m_pPackageAuthorEdit->setText(m_szPackageAuthor);
+ pLabel->setBuddy(m_pPackageAuthorEdit);
+ pLayout->addWidget(m_pPackageAuthorEdit,0,1);
pLabel = new QLabel(this);
- pLabel->setText(__tr2qs_ctx("Package Author:","addon"));
+ pLabel->setText(__tr2qs_ctx("Package &Name:","addon"));
pLayout->addWidget(pLabel,1,0);
-
- m_pAuthorNameEdit = new QLineEdit(this);
- m_pAuthorNameEdit->setText(szPackageAuthor);
- pLayout->addWidget(m_pAuthorNameEdit,1,1);
+
+ m_pPackageNameEdit = new QLineEdit(this);
+ m_pPackageNameEdit->setText(m_szPackageName);
+ pLabel->setBuddy(m_pPackageNameEdit);
+ pLayout->addWidget(m_pPackageNameEdit,1,1);
pLabel = new QLabel(this);
- pLabel->setText(__tr2qs_ctx("Package Name:","addon"));
+ pLabel->setText(__tr2qs_ctx("Package &Version:","addon"));
pLayout->addWidget(pLabel,2,0);
-
- m_pPackageNameEdit = new QLineEdit(this);
- m_pPackageNameEdit->setText(szPackageName);
- pLayout->addWidget(m_pPackageNameEdit,2,1);
+
+ m_pPackageVersionEdit = new QLineEdit(this);
+ m_pPackageVersionEdit->setText(m_szPackageVersion);
+ pLabel->setBuddy(m_pPackageVersionEdit);
+ pLayout->addWidget(m_pPackageVersionEdit,2,1);
pLabel = new QLabel(this);
- pLabel->setText(__tr2qs_ctx("Package Version:","addon"));
+ pLabel->setText(__tr2qs_ctx("Package &Description:","addon"));
pLayout->addWidget(pLabel,3,0);
-
- m_pPackageVersionEdit = new QLineEdit(this);
- m_pPackageVersionEdit->setText(szPackageVersion);
- pLayout->addWidget(m_pPackageVersionEdit,3,1);
+
+ m_pPackageDescriptionEdit = new KviTalTextEdit(this);
+ m_pPackageDescriptionEdit->setBackgroundRole(QPalette::Window);
+ m_pPackageDescriptionEdit->setText(m_szPackageDescription);
+ pLabel->setBuddy(m_pPackageDescriptionEdit);
+ pLayout->addWidget(m_pPackageDescriptionEdit,3,1,1,2);
+ pLayout->setRowStretch(1,1);
pLabel = new QLabel(this);
- pLabel->setText(__tr2qs_ctx("Package Description:","addon"));
+ pLabel->setText(__tr2qs_ctx("Minimum &KVIrc Version:","addon"));
pLayout->addWidget(pLabel,4,0);
- m_pPackageDescriptionEdit = new KviTalTextEdit(this);
- m_pPackageDescriptionEdit->setBackgroundRole(QPalette::Window);
- m_pPackageDescriptionEdit->setText(szPackageDescription);
- pLayout->addWidget(m_pPackageDescriptionEdit,4,1,1,2);
- pLayout->setRowStretch(1,1);
+ m_pPackageMinVersionEdit = new QLineEdit(this);
+ m_pPackageMinVersionEdit->setText(m_szPackageMinVersion);
+ pLabel->setBuddy(m_pPackageMinVersionEdit);
+ pLayout->addWidget(m_pPackageMinVersionEdit,4,1);
+
+ // Store data in the fields
+ registerField("packageAuthor*",m_pPackageAuthorEdit);
+ registerField("packageName*",m_pPackageNameEdit);
+ registerField("packageVersion*",m_pPackageVersionEdit);
+ registerField("packageDescription",m_pPackageDescriptionEdit);
+ // FIXME
+ //registerField("packageDescription*",m_pPackageDescriptionEdit,"QString toPlainText()","textChanged()");
+ registerField("packageMinVersion",m_pPackageMinVersionEdit);
}
-KviPackAddonFileSelectionWidget::KviPackAddonFileSelectionWidget(KviPackAddonDialog *pParent)
-: QWidget(pParent)
+KviPackAddonInfoPackageWidget::~KviPackAddonInfoPackageWidget()
{
- QGridLayout * pLayout = new QGridLayout(this);
-
- QLabel * pLabel = new QLabel(this);
- pLabel->setText(__tr2qs_ctx("Here you need to provide the real informations for the addon.","addon"));
- pLayout->addWidget(pLabel,0,0);
+}
- // Select installer script
- m_pInstallPathSelector = new KviFileSelector(this,__tr2qs_ctx("Select installer script:","addon"),&szInstallPath,true,0,"*.kvs");
- pLayout->addWidget(m_pInstallPathSelector,1,0);
- // Select script dir
- m_pSourcePathSelector = new KviDirectorySelector(this,__tr2qs_ctx("Select scripts directory:","addon"),&szSourcePath,true);
- pLayout->addWidget(m_pSourcePathSelector,2,0);
+KviPackAddonFileSelectionWidget::KviPackAddonFileSelectionWidget(KviPackAddonDialog * pParent)
+: QWizardPage(pParent)
+{
+ setTitle(__tr2qs_ctx("Package Files","addon"));
+ setSubTitle(__tr2qs_ctx("Here you need to select the directory where the addon files are.","addon"));
- // Select config dir
- m_pConfigPathSelector = new KviDirectorySelector(this,__tr2qs_ctx("Select config directory:","addon"),&szConfigPath,true);
- pLayout->addWidget(m_pConfigPathSelector,3,0);
+ QVBoxLayout * pLayout = new QVBoxLayout(this);
- // Select image dir
- m_pImagePathSelector = new KviDirectorySelector(this,__tr2qs_ctx("Select images directory:","addon"),&szImagePath,true);
- pLayout->addWidget(m_pImagePathSelector,4,0);
+ // Select source directory
+ m_pDirPathSelector = new KviDirectorySelector(this,__tr2qs_ctx("Select the source directory:","addon"),&m_szDirPath,true);
+ pLayout->addWidget(m_pDirPathSelector);
- // Select localization dir
- m_pLocalePathSelector = new KviDirectorySelector(this,__tr2qs_ctx("Select localization directory:","addon"),&szLocalePath,true);
- pLayout->addWidget(m_pLocalePathSelector,5,0);
+ // Select addon icon
+ m_pPackageIconEdit = new KviFileSelector(this,__tr2qs_ctx("Select the icon file:","addon"),&m_szPackageIcon,true,0,KVI_FILTER_IMAGE);
+ pLayout->addWidget(m_pPackageIconEdit);
- // Select help dir
- m_pHelpPathSelector = new KviDirectorySelector(this,__tr2qs_ctx("Select help directory:","addon"),&szHelpPath,true);
- pLayout->addWidget(m_pHelpPathSelector,6,0);
+ // Store data in the fields
+ // FIXME
+ //registerField("packageDirPath*",m_pPackageIconEdit);
+ //registerField("packageIcon*",m_pPackageIconEdit);
+ registerField("packageDirPath",m_pPackageIconEdit);
+ registerField("packageIcon",m_pPackageIconEdit);
+}
- // Select sound dir
- m_pSoundPathSelector = new KviDirectorySelector(this,__tr2qs_ctx("Select sounds directory:","addon"),&szSoundPath,true);
- pLayout->addWidget(m_pSoundPathSelector,7,0);
+KviPackAddonFileSelectionWidget::~KviPackAddonFileSelectionWidget()
+{
}
-KviPackAddonSaveSelectionWidget::KviPackAddonSaveSelectionWidget(KviPackAddonDialog *pParent)
-: QWidget(pParent)
+
+KviPackAddonSaveSelectionWidget::KviPackAddonSaveSelectionWidget(KviPackAddonDialog * pParent)
+: QWizardPage(pParent)
{
- QGridLayout * pLayout = new QGridLayout(this);
+ setTitle(__tr2qs_ctx("Save Package","addon"));
+ setSubTitle(__tr2qs_ctx("Here you need to provide the path where to save the addon package","addon"));
- QLabel * pLabel = new QLabel(this);
- pLabel->setText(__tr2qs_ctx("Here you need to provide the path where to save the addon package","addon"));
- pLayout->addWidget(pLabel,0,0);
+ QVBoxLayout * pLayout = new QVBoxLayout(this);
- // Create addon name
- KviPackAddonCreateInfoPackageWidget * pCreateWidget=pParent->m_pPackAddonInfoCreateWidget;
+ // Select save path
+ m_pSavePathSelector = new KviFileSelector(this,__tr2qs_ctx("Select save path:","addon"),&m_szSavePath,true,KviFileSelector::ChooseSaveFileName,KVI_FILTER_ADDON);
+ pLayout->addWidget(m_pSavePathSelector);
- szSavePath = QDir::homePath();
- KviQString::ensureLastCharIs(szSavePath,QChar(KVI_PATH_SEPARATOR_CHAR));
- szSavePath += pCreateWidget->packageName();
- szSavePath += "-";
- szSavePath += pCreateWidget->packageVersion();
- szSavePath += ".";
- szSavePath += KVI_FILEEXTENSION_ADDONPACKAGE;
- qDebug("Addon name selected: %s",szSavePath.toUtf8().data());
+ // Store data in the fields
+ // FIXME: these fields don't get registered
+ //registerField("packageSavePath*",m_pSavePathSelector,"","selectionChanged");
+ registerField("packageSavePath",m_pSavePathSelector);
+}
- // Setting dialog filter
- QString szFilter = "*.";
- szFilter += KVI_FILEEXTENSION_ADDONPACKAGE;
+KviPackAddonSaveSelectionWidget::~KviPackAddonSaveSelectionWidget()
+{
+}
- // Select save path
- m_pSavePathSelector = new KviFileSelector(this,__tr2qs_ctx("Select save path:","addon"),&szSavePath,true,KviFileSelector::ChooseSaveFileName,szFilter);
- pLayout->addWidget(m_pSavePathSelector,1,0);
+void KviPackAddonSaveSelectionWidget::initializePage()
+{
+ // Get data from registered fields
+ QString szName = field("packageName").toString();
+ QString szVersion = field("packageVersion").toString();
+
+ // Create addon name
+ QString m_szSavePath = QDir::homePath();
+ KviQString::ensureLastCharIs(m_szSavePath,QChar(KVI_PATH_SEPARATOR_CHAR));
+ m_szSavePath += szName;
+ m_szSavePath += "-";
+ m_szSavePath += szVersion;
+ m_szSavePath += KVI_FILEEXTENSION_ADDONPACKAGE;
}
-KviPackAddonInfoWidget::KviPackAddonInfoWidget(KviPackAddonDialog *pParent)
-:QWidget(pParent)
+
+KviPackAddonSummaryWidget::KviPackAddonSummaryWidget(KviPackAddonDialog * pParent)
+: QWizardPage(pParent)
{
- m_pParent=pParent;
- QGridLayout *pLayout = new QGridLayout(this);
+ setTitle(__tr2qs_ctx("Final Informations","addon"));
+ setSubTitle(__tr2qs_ctx("Here there are the informations you provided. If they are correct, hit the \"Finish\" button to complete the packaging operations.","addon"));
- QLabel *pLabel = new QLabel(this);
- pLabel->setText(__tr2qs_ctx("Here there are the informations you provided. If they are correct, hit the \"Finish\" button to complete the packaging operations.","addon"));
- pLabel->setWordWrap(true);
- pLayout->addWidget(pLabel,0,0);
+ m_pParent = pParent;
+ QVBoxLayout * pLayout = new QVBoxLayout(this);
m_pLabelInfo = new QLabel(this);
- pLayout->addWidget(m_pLabelInfo,1,0);
+ pLayout->addWidget(m_pLabelInfo);
}
-void KviPackAddonInfoWidget::showEvent(QShowEvent *)
+KviPackAddonSummaryWidget::~KviPackAddonSummaryWidget()
{
- KviPackAddonCreateInfoPackageWidget * pCreateWidget=m_pParent->m_pPackAddonInfoCreateWidget;
- KviPackAddonFileSelectionWidget * pFileWidget = m_pParent->m_pPackAddonFileSelectionWidget;
- KviPackAddonSaveSelectionWidget * pSaveWidget = m_pParent->m_pPackAddonSaveSelectionWidget;
+}
+
+void KviPackAddonSummaryWidget::initializePage()
+{
+ // Get data from registered fields
+ QString szAuthor = field("packageAuthor").toString();
+ QString szName = field("packageName").toString();
+ QString szVersion = field("packageVersion").toString();
+ QString szDescription = field("packageDescription").toString();
+ QString szMinVersion = field("packageMinVersion").toString();
+ QString szIcon = field("packageIcon").toString();
+ QString szDirPath = field("packageDirPath").toString();
+ QString szSavePath = field("packageSavePath").toString();
+
+ QString szText = __tr2qs_ctx("This is what I will check for:","addon");
+ szText += "<br><br><b>";
+ szText += __tr2qs_ctx("Package Author","addon");
+ szText += ":</b> ";
+ szText += szAuthor;
+ szText += "<br><b>";
+ szText += __tr2qs_ctx("Package Name","addon");
+ szText += ":</b> ";
+ szText += szName;
+ szText += "<br><b>";
+ szText += __tr2qs_ctx("Package Version","addon");
+ szText += ":</b> ";
+ szText += szVersion;
+ szText += "<br><b>";
+ szText += __tr2qs_ctx("Package Description","addon");
+ szText += ":</b> ";
+ szText += szDescription;
+ szText += "<br><b>";
+ szText += __tr2qs_ctx("Minimum KVIrc Version","addon");
+ szText += ":</b> ";
+ szText += szMinVersion;
+ szText += "<br><b>";
+ szText += __tr2qs_ctx("Icon File","addon");
+ szText += ":</b> ";
+ szText += szIcon;
+ szText += "<br><b>";
+ szText += __tr2qs_ctx("Source Directory","addon");
+ szText += ":</b> ";
+ szText += szDirPath;
+ szText += "<br><b>";
+ szText += __tr2qs_ctx("Save Path","addon");
+ szText += ":</b> ";
+ szText += szSavePath;
- QString szText = __tr2qs_ctx("This is what I will check for","addon") + "<br>";
- szText += "<b>" + __tr2qs_ctx("Package Author","addon") + ":</b> " + pCreateWidget->authorName() + "<br>";
- szText += "<b>" + __tr2qs_ctx("Package Name","addon") + ":</b> " + pCreateWidget->packageName() + "<br>";
- szText += "<b>" + __tr2qs_ctx("Package Version","addon") + ":</b> " + pCreateWidget->packageVersion() + "<br>";
- szText += "<b>" + __tr2qs_ctx("Package Description","addon") + ":</b> " + pCreateWidget->packageDescription() + "<br><br>";
- szText += "<b>" + __tr2qs_ctx("Installer Script","addon") + ":</b> " + pFileWidget->installerPath() + "<br>";
- szText += "<b>" + __tr2qs_ctx("Source Directory","addon") + ":</b> " + pFileWidget->sourcePath() + "<br>";
- szText += "<b>" + __tr2qs_ctx("Configuration Directory","addon") + ":</b> " + pFileWidget->configPath() + "<br>";
- szText += "<b>" + __tr2qs_ctx("Image Directory","addon") + ":</b> " + pFileWidget->imagePath() + "<br>";
- szText += "<b>" + __tr2qs_ctx("Localization Directory","addon") + ":</b> " + pFileWidget->localePath() + "<br>";
- szText += "<b>" + __tr2qs_ctx("Help Directory","addon") + ":</b> " + pFileWidget->helpPath() + "<br>";
- szText += "<b>" + __tr2qs_ctx("Sound Directory","addon") + ":</b> " + pFileWidget->soundPath() + "<br>";
- szText += "<b>" + __tr2qs_ctx("Save Path","addon") + ":</b> " + pSaveWidget->savePath();
m_pLabelInfo->setText(szText);
}
diff --git a/src/modules/addon/packaddondialog.h b/src/modules/addon/packaddondialog.h
index 17999b094..0aceab21e 100644
--- a/src/modules/addon/packaddondialog.h
+++ b/src/modules/addon/packaddondialog.h
@@ -6,8 +6,7 @@
// Creation date : Sat 03 May 2008 01:40:44 by Elvio Basello
//
// This file is part of the KVIrc IRC Client distribution
-// Copyright (C) 2008 Elvio Basello <hellvis69 at netsons dot org>
-// Copyright (C) 2008 Alessandro Carbone <elfonol at gmail dot com>
+// Copyright (C) 2008-2009 Elvio Basello <hellvis69 at netsons dot org>
//
// This program is FREE software. You can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -25,69 +24,298 @@
//
//=============================================================================
+/**
+* \file packaddondialog.h
+* \author Elvio Basello
+* \brief Addon package creator
+*
+* This set of classes allow users to create addon for KVIrc in a standard
+* distributable *.kva packages.
+*/
+
#include "kvi_settings.h"
#include "kvi_pointerlist.h"
#include "kvi_selectors.h"
-#include "kvi_tal_wizard.h"
#include "kvi_tal_textedit.h"
-#include <QLineEdit>
-#include <QLabel>
-#include <QWidget>
+#include <QWizard>
+#include <QWizardPage>
+
+class QLineEdit;
+class QLabel;
-class KviPackAddonCreateInfoPackageWidget;
+//class KviPackAddonDialog;
+class KviPackAddonInfoPackageWidget;
class KviPackAddonFileSelectionWidget;
class KviPackAddonSaveSelectionWidget;
-class KviPackAddonInfoWidget;
+class KviPackAddonSummaryWidget;
+
+#if 0
+/**
+* \class KviPackAddonDialogData
+* \brief Class for storing addon data
+*/
+class KviPackAddonData
+{
+public:
+ /**
+ * \brief Creates the addon data object
+ * \param pParent The parent wizard dialog
+ * \return KviPackAddonData
+ */
+ KviPackAddonData(KviPackAddonDialog * pParent);
+
+ /**
+ * \brief Destroys the addon data object
+ */
+ ~KviPackAddonData();
+protected:
+ QString m_szAuthor;
+ QString m_szName;
+ QString m_szVersion;
+ QString m_szDescription;
+ QString m_szMinVersion;
+public:
+ /**
+ * \brief Sets the package author
+ * \param szAuthor The author name
+ * \return void
+ */
+ void setAuthor(QString & szAuthor){ m_szAuthor = szAuthor; };
+
+ /**
+ * \brief Sets the package name
+ * \param szName The package name
+ * \return void
+ */
+ void setName(QString & szName){ m_szName = szName; };
+
+ /**
+ * \brief Sets the package version
+ * \param szVersion The author name
+ * \return void
+ */
+ void setVersion(QString & szVersion){ m_szVersion = szVersion; };
+
+ /**
+ * \brief Sets the package description
+ * \param szDescription
+ * \return void
+ */
+ void setDescription(QString & szDescription){ m_szDescription = szDescription; };
-class KviPackAddonDialog : public KviTalWizard
+ /**
+ * \brief Sets the package minimum version
+ * \param szMinVersion
+ * \return void
+ */
+ void setMinVersion(QString & szMinVersion){ m_szMinVersion = szMinVersion; };
+
+ /**
+ * \brief Returns the author name
+ * \return QString
+ */
+ QString author(){ return m_szAuthor; };
+
+ /**
+ * \brief Returns the package name
+ * \return QString
+ */
+ QString name(){ return m_szName; };
+
+ /**
+ * \brief Returns the package version
+ * \return QString
+ */
+ QString version(){ return m_szVersion; };
+
+ /**
+ * \brief Returns the package description
+ * \return QString
+ */
+ QString description(){ return m_szDescription; };
+
+ /**
+ * \brief Returns the minimum version allowed of KVIrc
+ * \return QString
+ */
+ QString minVersion(){ return m_szMinVersion; };
+};
+#endif
+/**
+* \class KviPackAddonDialog
+* \brief Wizard for addon creation
+*/
+class KviPackAddonDialog : public QWizard
{
Q_OBJECT
public:
+ /**
+ * \brief Create the wizard object
+ * \param pParent The parent widget
+ * \return KviPackAddonDialog
+ */
KviPackAddonDialog(QWidget * pParent);
- ~KviPackAddonDialog(){};
- KviPackAddonCreateInfoPackageWidget * m_pPackAddonInfoCreateWidget;
- KviPackAddonFileSelectionWidget * m_pPackAddonFileSelectionWidget;
- KviPackAddonSaveSelectionWidget * m_pPackAddonSaveSelectionWidget;
- KviPackAddonInfoWidget * m_pPackAddonInfoWidget;
+
+ /**
+ * \brief Destroys the wizard object
+ */
+ ~KviPackAddonDialog();
+public:
+ KviPackAddonInfoPackageWidget * m_pPackAddonInfoPackageWidget;
+ KviPackAddonFileSelectionWidget * m_pPackAddonFileSelectionWidget;
+ KviPackAddonSaveSelectionWidget * m_pPackAddonSaveSelectionWidget;
+ KviPackAddonSummaryWidget * m_pPackAddonSummaryWidget;
+ //KviPackAddonData * m_pData;
+#if 0
protected:
QString m_szPackagePath;
+public:
+ /**
+ * \brief Returns the author's info selection widget
+ * \return KviPackAddonCreateInfoPackageWidget *
+ */
+ KviPackAddonInfoPackageWidget * infoWidget(){ return m_pPackAddonInfoPackageWidget; };
+
+ /**
+ * \brief Returns the directory selection widget
+ * \return KviPackAddonFileSelectionWidget *
+ */
+ KviPackAddonFileSelectionWidget * fileWidget(){ return m_pPackAddonFileSelectionWidget; };
+
+ /**
+ * \brief Returns the saving selection widget
+ * \return KviPackAddonSaveSelectionWidget *
+ */
+ KviPackAddonSaveSelectionWidget * saveWidget(){ return m_pPackAddonSaveSelectionWidget; };
+
+ /**
+ * \brief Returns the addon data object
+ * \return KviPackAddonData *
+ */
+ KviPackAddonData * data(){ return m_pData; };
+#endif
protected:
+ /**
+ * \brief Runs the packAddon() function and closes the wizard
+ * \return void
+ */
virtual void accept();
+
+ /**
+ * \brief Create the addon package
+ * \return bool
+ */
bool packAddon();
+
+ /**
+ * \brief Ensures the source directory is complete
+ * \param szSourceDir The sources' directory
+ * \param pszError The buffer containing errors
+ * \return bool
+ */
+ bool checkDirTree(QString & szSourceDir, QString * pszError);
+
+ /**
+ * \brief Creates the installer file
+ * \param szSourceDir The sources' directory
+ * \param pszError The buffer containing errors
+ * \return bool
+ */
+ bool createInstaller(QString & szSourceDir, QString * pszError);
};
-class KviPackAddonCreateInfoPackageWidget : public QWidget
+/**
+* \class KviPackAddonInfoPackageWidget
+* \brief Wizard page for addon informations
+*/
+class KviPackAddonInfoPackageWidget : public QWizardPage
{
Q_OBJECT
public:
- KviPackAddonCreateInfoPackageWidget(KviPackAddonDialog *pParent);
- ~KviPackAddonCreateInfoPackageWidget(){};
- QString authorName(){return m_pAuthorNameEdit->text();};
- QString packageName(){return m_pPackageNameEdit->text();};
- QString packageVersion(){return m_pPackageVersionEdit->text();};
- QString packageDescription(){return m_pPackageDescriptionEdit->toPlainText();};
+ /**
+ * \brief Create the wizard package info page object
+ * \param pParent The parent widget
+ * \return KviPackAddonInfoPackageWidget
+ */
+ KviPackAddonInfoPackageWidget(KviPackAddonDialog * pParent);
+
+ /**
+ * \brief Destroys the wizard package info page object
+ */
+ ~KviPackAddonInfoPackageWidget();
+public:
+ QString m_szPackageName;
+ QString m_szPackageAuthor;
+ QString m_szPackageDescription;
+ QString m_szPackageVersion;
+ QString m_szPackageMinVersion;
protected:
- QLineEdit * m_pAuthorNameEdit;
- QLineEdit * m_pPackageNameEdit;
- QLineEdit * m_pPackageVersionEdit;
- KviTalTextEdit * m_pPackageDescriptionEdit;
+ QLineEdit * m_pPackageAuthorEdit;
+ QLineEdit * m_pPackageNameEdit;
+ QLineEdit * m_pPackageVersionEdit;
+ KviTalTextEdit * m_pPackageDescriptionEdit;
+ QLineEdit * m_pPackageMinVersionEdit;
+#if 0
+public:
+ /**
+ * \brief Returns the author name
+ * \return QString
+ */
+ QString packageAuthor(){ return m_pPackageAuthorEdit->text(); };
+
+ /**
+ * \brief Returns the package name
+ * \return QString
+ */
+ QString packageName(){ return m_pPackageNameEdit->text(); };
+
+ /**
+ * \brief Returns the package version
+ * \return QString
+ */
+ QString packageVersion(){ return m_pPackageVersionEdit->text(); };
+
+ /**
+ * \brief Returns the package description
+ * \return QString
+ */
+ QString packageDescription(){ return m_pPackageDescriptionEdit->toPlainText(); };
+
+ /**
+ * \brief Returns the minimum version allowed of KVIrc
+ * \return QString
+ */
+ QString packageMinVersion(){ return m_pPackageMinVersionEdit->text(); };
+#endif
};
-class KviPackAddonFileSelectionWidget : public QWidget
+/**
+* \class KviPackAddonFileSelectionWidget
+* \brief Wizard page for directory source selection
+*/
+class KviPackAddonFileSelectionWidget : public QWizardPage
{
Q_OBJECT
public:
- KviPackAddonFileSelectionWidget(KviPackAddonDialog *pParent);
- ~KviPackAddonFileSelectionWidget(){};
- QString sourcePath(){m_pSourcePathSelector->commit();return szSourcePath;};
- QString configPath(){m_pConfigPathSelector->commit();return szConfigPath;};
- QString imagePath(){m_pImagePathSelector->commit();return szImagePath;};
- QString localePath(){m_pLocalePathSelector->commit();return szLocalePath;};
- QString helpPath(){m_pHelpPathSelector->commit();return szHelpPath;};
- QString soundPath(){m_pSoundPathSelector->commit();return szSoundPath;};
- QString installerPath(){m_pInstallPathSelector->commit();return szInstallPath;};
+ /**
+ * \brief Create the wizard package source dir object
+ * \param pParent The parent widget
+ * \return KviPackAddonFileSelectionWidget
+ */
+ KviPackAddonFileSelectionWidget(KviPackAddonDialog * pParent);
+
+ /**
+ * \brief Destroys the wizard package source dir object
+ */
+ ~KviPackAddonFileSelectionWidget();
protected:
+ KviDirectorySelector * m_pDirPathSelector;
+ KviFileSelector * m_pPackageIconEdit;
+ QString m_szDirPath;
+ QString m_szPackageIcon;
+#if 0
+/*
KviDirectorySelector * m_pSourcePathSelector;
KviDirectorySelector * m_pConfigPathSelector;
KviDirectorySelector * m_pImagePathSelector;
@@ -95,41 +323,108 @@ protected:
KviDirectorySelector * m_pHelpPathSelector;
KviDirectorySelector * m_pSoundPathSelector;
KviFileSelector * m_pInstallPathSelector;
- QString szSourcePath;
- QString szConfigPath;
- QString szImagePath;
- QString szLocalePath;
- QString szHelpPath;
- QString szSoundPath;
- QString szInstallPath;
+ QString szSourcePath;
+ QString szConfigPath;
+ QString szImagePath;
+ QString szLocalePath;
+ QString szHelpPath;
+ QString szSoundPath;
+ QString szInstallPath;
+*/
+public:
+ /**
+ * \brief Returns the source directory
+ * \return QString
+ */
+ QString dirPath(){ m_pDirPathSelector->commit(); return m_szDirPath; };
+
+ /**
+ * \brief Returns the path to the package icon
+ * \return QString
+ */
+ QString packageIcon(){ m_pPackageIconEdit->commit(); return m_szPackageIcon; };
+/*
+ QString sourcePath(){ m_pSourcePathSelector->commit(); return szSourcePath; };
+ QString configPath(){ m_pConfigPathSelector->commit(); return szConfigPath; };
+ QString imagePath(){ m_pImagePathSelector->commit(); return szImagePath; };
+ QString localePath(){ m_pLocalePathSelector->commit(); return szLocalePath; };
+ QString helpPath(){ m_pHelpPathSelector->commit(); return szHelpPath; };
+ QString soundPath(){ m_pSoundPathSelector->commit(); return szSoundPath; };
+ QString installerPath(){ m_pInstallPathSelector->commit(); return szInstallPath; };
+*/
+#endif
};
-class KviPackAddonSaveSelectionWidget : public QWidget
+/**
+* \class KviPackAddonCreateInfoPackageWidget
+* \brief Wizard page for saving package
+*/
+class KviPackAddonSaveSelectionWidget : public QWizardPage
{
Q_OBJECT
public:
- KviPackAddonSaveSelectionWidget(KviPackAddonDialog *pParent);
- ~KviPackAddonSaveSelectionWidget(){};
- QString savePath(){m_pSavePathSelector->commit();return szSavePath;};
+ /**
+ * \brief Create the wizard save page object
+ * \param pParent The parent widget
+ * \return KviPackAddonSaveSelectionWidget
+ */
+ KviPackAddonSaveSelectionWidget(KviPackAddonDialog * pParent);
+
+ /**
+ * \brief Destroys the wizard save page object
+ */
+ ~KviPackAddonSaveSelectionWidget();
protected:
KviFileSelector * m_pSavePathSelector;
- QString szSavePath;
+ QString m_szSavePath;
+protected:
+ /**
+ * \brief Perform initial tasks before showing the widget
+ * \return void
+ */
+ virtual void initializePage();
+#if 0
+public:
+ /**
+ * \brief Returns the saving path
+ * \return QString
+ */
+ QString savePath(){ m_pSavePathSelector->commit(); return szSavePath; };
+#endif
};
-class KviPackAddonInfoWidget : public QWidget
+/**
+* \class KviPackAddonSummaryWidget
+* \brief Wizard page for showing informations inserted
+*/
+class KviPackAddonSummaryWidget : public QWizardPage
{
+ Q_OBJECT
public:
- KviPackAddonInfoWidget(KviPackAddonDialog *);
- ~KviPackAddonInfoWidget(){};
+ /**
+ * \brief Create the wizard save page object
+ * \param pParent The parent widget
+ * \return KviPackAddonSaveSelectionWidget
+ */
+ KviPackAddonSummaryWidget(KviPackAddonDialog * pParent);
+
+ /**
+ * \brief Destroys the wizard save page object
+ */
+ ~KviPackAddonSummaryWidget();
protected:
KviPackAddonDialog * m_pParent;
- QLabel * m_pLabelInfo;
- QLabel * m_pLabelAuthor;
- QLabel * m_pPackageName;
- QLabel * m_pPackageVersion;
- QLabel * m_pPackageDescription;
- void showEvent(QShowEvent *event);
+ QLabel * m_pLabelInfo;
+ QLabel * m_pLabelAuthor;
+ QLabel * m_pPackageName;
+ QLabel * m_pPackageVersion;
+ QLabel * m_pPackageDescription;
+protected:
+ /**
+ * \brief Perform initial tasks before showing the widget
+ * \return void
+ */
+ virtual void initializePage();
};
-
#endif //!_PACKADDONDIALOG_H_
diff --git a/src/modules/theme/packthemedialog.cpp b/src/modules/theme/packthemedialog.cpp
index c3d460db7..d28384296 100644
--- a/src/modules/theme/packthemedialog.cpp
+++ b/src/modules/theme/packthemedialog.cpp
@@ -94,7 +94,6 @@ KviPackThemeDialog::KviPackThemeDialog(QWidget * pParent,KviPointerList<KviTheme
m_szPackagePath += "-";
m_szPackagePath += szPackageVersion;
}
- m_szPackagePath += ".";
m_szPackagePath += KVI_FILEEXTENSION_THEMEPACKAGE;
bPackagePathSet = true;
@@ -106,7 +105,6 @@ KviPackThemeDialog::KviPackThemeDialog(QWidget * pParent,KviPointerList<KviTheme
m_szPackagePath += szPackageName;
m_szPackagePath += "-";
m_szPackagePath += szPackageVersion;
- m_szPackagePath += ".";
m_szPackagePath += KVI_FILEEXTENSION_THEMEPACKAGE;
}
@@ -294,12 +292,12 @@ KviPackThemeDialog::KviPackThemeDialog(QWidget * pParent,KviPointerList<KviTheme
pLayout = new QGridLayout(pPage);
pLabel = new QLabel(pPage);
- pLabel->setText(__tr2qs_ctx("Here you must choose the file name for the theme package. It should have a *.%1 extension.","theme").arg(KVI_FILEEXTENSION_THEMEPACKAGE));
+ pLabel->setText(__tr2qs_ctx("Here you must choose the file name for the theme package. It should have a *%1 extension.","theme").arg(KVI_FILEEXTENSION_THEMEPACKAGE));
pLabel->setWordWrap(true);
pLabel->setTextFormat(Qt::RichText);
pLayout->addWidget(pLabel,0,0);
- szFilter = "*.";
+ szFilter = "*";
szFilter += KVI_FILEEXTENSION_THEMEPACKAGE;
m_pPathSelector = new KviFileSelector(pPage,"",&m_szPackagePath,true,KviFileSelector::ChooseSaveFileName,szFilter);
pLayout->addWidget(m_pPathSelector,1,0);