From c12f38c52866b12e1e588f80265ab3b4c09d72b9 Mon Sep 17 00:00:00 2001 From: Elvio Basello Date: Thu, 17 Sep 2009 17:01:03 +0000 Subject: 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 --- src/modules/addon/AddonTest-1.0.0.kva | Bin 8854 -> 0 bytes src/modules/addon/addonfunctions.h | 21 +- src/modules/addon/managementdialog.cpp | 31 +- src/modules/addon/managementdialog.h | 25 +- src/modules/addon/packaddondialog.cpp | 608 ++++++++++++++++++++++++--------- src/modules/addon/packaddondialog.h | 409 ++++++++++++++++++---- 6 files changed, 837 insertions(+), 257 deletions(-) delete mode 100644 src/modules/addon/AddonTest-1.0.0.kva (limited to 'src/modules/addon') 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 Binary files a/src/modules/addon/AddonTest-1.0.0.kva and /dev/null 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 += "
"; - 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"; - 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 += "
"; - szText += __tr2qs_ctx("You will be asked to provide a package name, a version and a description.","addon"); - szText += "
"; - szText += __tr2qs_ctx("Hit the \"Next\" button to begin.","addon"); - szText += "
";
+ 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 += "
";
+ 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;
+
+ QGridLayout * pLayout = new QGridLayout(this);
- 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);
+ 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);
+
+ // Store data in the fields
+ // FIXME: these fields don't get registered
+ //registerField("packageSavePath*",m_pSavePathSelector,"","selectionChanged");
+ registerField("packageSavePath",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());
+KviPackAddonSaveSelectionWidget::~KviPackAddonSaveSelectionWidget()
+{
+}
- // Setting dialog filter
- QString szFilter = "*.";
- szFilter += KVI_FILEEXTENSION_ADDONPACKAGE;
+void KviPackAddonSaveSelectionWidget::initializePage()
+{
+ // Get data from registered fields
+ QString szName = field("packageName").toString();
+ QString szVersion = field("packageVersion").toString();
- // 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);
+ // 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;
-
- QString szText = __tr2qs_ctx("This is what I will check for","addon") + "
";
- szText += "" + __tr2qs_ctx("Package Author","addon") + ": " + pCreateWidget->authorName() + "
";
- szText += "" + __tr2qs_ctx("Package Name","addon") + ": " + pCreateWidget->packageName() + "
";
- szText += "" + __tr2qs_ctx("Package Version","addon") + ": " + pCreateWidget->packageVersion() + "
";
- szText += "" + __tr2qs_ctx("Package Description","addon") + ": " + pCreateWidget->packageDescription() + "
";
- szText += "" + __tr2qs_ctx("Installer Script","addon") + ": " + pFileWidget->installerPath() + "
";
- szText += "" + __tr2qs_ctx("Source Directory","addon") + ": " + pFileWidget->sourcePath() + "
";
- szText += "" + __tr2qs_ctx("Configuration Directory","addon") + ": " + pFileWidget->configPath() + "
";
- szText += "" + __tr2qs_ctx("Image Directory","addon") + ": " + pFileWidget->imagePath() + "
";
- szText += "" + __tr2qs_ctx("Localization Directory","addon") + ": " + pFileWidget->localePath() + "
";
- szText += "" + __tr2qs_ctx("Help Directory","addon") + ": " + pFileWidget->helpPath() + "
";
- szText += "" + __tr2qs_ctx("Sound Directory","addon") + ": " + pFileWidget->soundPath() + "
";
- szText += "" + __tr2qs_ctx("Save Path","addon") + ": " + pSaveWidget->savePath();
+}
+
+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 += "
";
+ szText += __tr2qs_ctx("Package Author","addon");
+ szText += ": ";
+ szText += szAuthor;
+ szText += "
";
+ szText += __tr2qs_ctx("Package Name","addon");
+ szText += ": ";
+ szText += szName;
+ szText += "
";
+ szText += __tr2qs_ctx("Package Version","addon");
+ szText += ": ";
+ szText += szVersion;
+ szText += "
";
+ szText += __tr2qs_ctx("Package Description","addon");
+ szText += ": ";
+ szText += szDescription;
+ szText += "
";
+ szText += __tr2qs_ctx("Minimum KVIrc Version","addon");
+ szText += ": ";
+ szText += szMinVersion;
+ szText += "
";
+ szText += __tr2qs_ctx("Icon File","addon");
+ szText += ": ";
+ szText += szIcon;
+ szText += "
";
+ szText += __tr2qs_ctx("Source Directory","addon");
+ szText += ": ";
+ szText += szDirPath;
+ szText += "
";
+ szText += __tr2qs_ctx("Save Path","addon");
+ szText += ": ";
+ szText += szSavePath;
+
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