diff options
| author | 2008-05-12 21:38:52 +0000 | |
|---|---|---|
| committer | 2008-05-12 21:38:52 +0000 | |
| commit | 276356074c3da91eb1807ab04c7ce6d6145313d2 (patch) | |
| tree | f1f16f82d2c12acb4eb4af47f129393cd0044112 /src/modules/addon | |
| parent | quick fix (diff) | |
| download | KVIrc-276356074c3da91eb1807ab04c7ce6d6145313d2.tar.gz KVIrc-276356074c3da91eb1807ab04c7ce6d6145313d2.tar.bz2 KVIrc-276356074c3da91eb1807ab04c7ce6d6145313d2.zip | |
addon manager now create packages :) ;
quick fixes around;
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@1756 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules/addon')
| -rw-r--r-- | src/modules/addon/addonfunctions.cpp | 2 | ||||
| -rw-r--r-- | src/modules/addon/addonfunctions.h | 2 | ||||
| -rw-r--r-- | src/modules/addon/libkviaddon.cpp | 2 | ||||
| -rw-r--r-- | src/modules/addon/packaddondialog.cpp | 179 | ||||
| -rw-r--r-- | src/modules/addon/packaddondialog.h | 19 |
5 files changed, 118 insertions, 86 deletions
diff --git a/src/modules/addon/addonfunctions.cpp b/src/modules/addon/addonfunctions.cpp index 697f7451b..f028f200b 100644 --- a/src/modules/addon/addonfunctions.cpp +++ b/src/modules/addon/addonfunctions.cpp @@ -38,8 +38,6 @@ #include <q3mimefactory.h> #define KviTalMimeSourceFactory Q3MimeSourceFactory -#define KVI_CURRENT_ADDONS_ENGINE_VERSION "1.0.0" - namespace KviAddonFunctions { static bool notAValidAddonPackage(QString &szError) diff --git a/src/modules/addon/addonfunctions.h b/src/modules/addon/addonfunctions.h index ae26351b4..ffed963cf 100644 --- a/src/modules/addon/addonfunctions.h +++ b/src/modules/addon/addonfunctions.h @@ -30,6 +30,8 @@ #include <QWidget> #include <QPixmap> +#define KVI_CURRENT_ADDONS_ENGINE_VERSION "1.0.0" + namespace KviAddonFunctions { static bool notAValidAddonPackage(QString &szError); diff --git a/src/modules/addon/libkviaddon.cpp b/src/modules/addon/libkviaddon.cpp index 6c69b3675..d8d8a40b7 100644 --- a/src/modules/addon/libkviaddon.cpp +++ b/src/modules/addon/libkviaddon.cpp @@ -687,7 +687,7 @@ KVIRC_MODULE( "4.0.0", // module version "Copyright (C) 2005 Szymon Stefanek (pragma at kvirc dot net)\n" \ " 2008 Elvio Basello (hellvis69 at netsons dot org)", // author & (C) - "Script management functions for the KVS engine", + "Script/addon management functions for the KVS engine", addon_module_init, addon_module_can_unload, 0, diff --git a/src/modules/addon/packaddondialog.cpp b/src/modules/addon/packaddondialog.cpp index 9411ef5d4..605b79b76 100644 --- a/src/modules/addon/packaddondialog.cpp +++ b/src/modules/addon/packaddondialog.cpp @@ -59,14 +59,13 @@ #include <QString> - KviPackAddonDialog::KviPackAddonDialog(QWidget * pParent) : KviTalWizard(pParent) { setWindowTitle(__tr2qs_ctx("Export Addon - KVIrc","addon")); setMinimumSize(400,350); - // welcome page + // Welcome page QWidget * pPage = new QWidget(this); QGridLayout * pLayout = new QGridLayout(pPage); @@ -90,7 +89,7 @@ KviPackAddonDialog::KviPackAddonDialog(QWidget * pParent) setHelpEnabled(pPage,false); setFinishEnabled(pPage,false); - // packager informations + // Packager informations m_pPackAddonInfoCreateWidget=new KviPackAddonCreateInfoPackageWidget(this); addPage(m_pPackAddonInfoCreateWidget,__tr2qs_ctx("Package Informations","addon")); setBackEnabled(m_pPackAddonInfoCreateWidget,true); @@ -98,7 +97,7 @@ KviPackAddonDialog::KviPackAddonDialog(QWidget * pParent) setNextEnabled(m_pPackAddonInfoCreateWidget,true); setFinishEnabled(m_pPackAddonInfoCreateWidget,false); - // file selection + // File selection m_pPackAddonFileSelectionWidget = new KviPackAddonFileSelectionWidget(this); addPage(m_pPackAddonFileSelectionWidget,__tr2qs_ctx("Package Files","addon")); setBackEnabled(m_pPackAddonFileSelectionWidget,true); @@ -106,7 +105,7 @@ KviPackAddonDialog::KviPackAddonDialog(QWidget * pParent) setNextEnabled(m_pPackAddonFileSelectionWidget,true); setFinishEnabled(m_pPackAddonFileSelectionWidget,false); - // final results + // Final results m_pPackAddonInfoWidget=new KviPackAddonInfoWidget(this); addPage(m_pPackAddonInfoWidget,__tr2qs_ctx("Package Path","addon")); setBackEnabled(m_pPackAddonInfoWidget,true); @@ -123,25 +122,82 @@ void KviPackAddonDialog::accept() bool KviPackAddonDialog::packAddon() { - //m_pPathSelector->commit(); - + // 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 szSourcePath = m_pPackAddonFileSelectionWidget->sourcePath(); + QString szImagePath = m_pPackAddonFileSelectionWidget->imagePath(); + QString szHelpPath = m_pPackAddonFileSelectionWidget->helpPath(); + QString szSoundPath = m_pPackAddonFileSelectionWidget->soundPath(); + QString szInstallPath = m_pPackAddonFileSelectionWidget->installerPath(); + + // We need mandatory unix like path separator + szSourcePath.replace('\\',"/"); + szImagePath.replace('\\',"/"); + szHelpPath.replace('\\',"/"); + szSoundPath.replace('\\',"/"); + szInstallPath.replace('\\',"/"); QString szTmp = QDateTime::currentDateTime().toString(); - KviPackageWriter f; - f.addInfoField("PackageType","AddonPack"); - f.addInfoField("AddonPackVersion","1"); - f.addInfoField("Name",szPackageName); - f.addInfoField("Version",szPackageVersion); - f.addInfoField("Author",szPackageAuthor); - f.addInfoField("Description",szPackageDescription); - f.addInfoField("Date",szTmp); - f.addInfoField("Application","KVIrc " KVI_VERSION "." KVI_SOURCES_DATE); - // create addon name + KviPackageWriter pw; + pw.addInfoField("PackageType","AddonPack"); + pw.addInfoField("AddonPackVersion",KVI_CURRENT_ADDONS_ENGINE_VERSION); + pw.addInfoField("Name",szPackageName); + pw.addInfoField("Version",szPackageVersion); + pw.addInfoField("Author",szPackageAuthor); + pw.addInfoField("Description",szPackageDescription); + pw.addInfoField("Date",szTmp); + pw.addInfoField("Application","KVIrc " KVI_VERSION "." KVI_SOURCES_DATE); + + // Add source dir + if(!pw.addDirectory(szSourcePath,"src/")) + { + szTmp = __tr2qs_ctx("Packaging failed","addon"); + szTmp += ": "; + szTmp += pw.lastError(); + QMessageBox::critical(this,__tr2qs_ctx("Export Addon - KVIrc","addon"),szTmp,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); + } + + // Add image dir + if(!pw.addDirectory(szImagePath,"pics/")) + { + szTmp = __tr2qs_ctx("Packaging failed","addon"); + szTmp += ": "; + szTmp += pw.lastError(); + QMessageBox::critical(this,__tr2qs_ctx("Export Addon - KVIrc","addon"),szTmp,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); + } + + // Add help dir + if(!pw.addDirectory(szImagePath,"help/en/")) + { + szTmp = __tr2qs_ctx("Packaging failed","addon"); + szTmp += ": "; + szTmp += pw.lastError(); + QMessageBox::critical(this,__tr2qs_ctx("Export Addon - KVIrc","addon"),szTmp,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); + } + + // Add sound dir + if(!pw.addDirectory(szImagePath,"audio/")) + { + szTmp = __tr2qs_ctx("Packaging failed","addon"); + szTmp += ": "; + szTmp += pw.lastError(); + QMessageBox::critical(this,__tr2qs_ctx("Export Addon - KVIrc","addon"),szTmp,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); + } + + // Add installer script + if(!pw.addFile(szInstallPath,"install.kvs")) + { + szTmp = __tr2qs_ctx("Packagin failed","addon"); + szTmp += ": "; + szTmp += pw.lastError(); + QMessageBox::critical(this,__tr2qs_ctx("Export Addon - KVIrc","addon"),szTmp,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); + } + + // Create addon name m_szPackagePath = QDir::homeDirPath(); KviQString::ensureLastCharIs(m_szPackagePath,QChar(KVI_PATH_SEPARATOR_CHAR)); m_szPackagePath += szPackageName; @@ -151,50 +207,23 @@ bool KviPackAddonDialog::packAddon() m_szPackagePath += KVI_FILEEXTENSION_ADDONPACKAGE; qDebug("Addon name: %s",m_szPackagePath.toUtf8().data()); -/* - szTmp.setNum(m_pThemeInfoList->count()); - f.addInfoField("AddonCount",szTmp); - - int iIdx = 0; - for(KviThemeInfo * pInfo = m_pThemeInfoList->first();pInfo;pInfo = m_pThemeInfoList->next()) - { - KviQString::sprintf(szTmp,"Theme%dName",iIdx); - f.addInfoField(szTmp,pInfo->name()); - KviQString::sprintf(szTmp,"Theme%dVersion",iIdx); - f.addInfoField(szTmp,pInfo->version()); - KviQString::sprintf(szTmp,"Theme%dDescription",iIdx); - f.addInfoField(szTmp,pInfo->description()); - KviQString::sprintf(szTmp,"Theme%dDate",iIdx); - f.addInfoField(szTmp,pInfo->date()); - KviQString::sprintf(szTmp,"Theme%dSubdirectory",iIdx); - f.addInfoField(szTmp,pInfo->subdirectory()); - KviQString::sprintf(szTmp,"Theme%dAuthor",iIdx); - f.addInfoField(szTmp,pInfo->author()); - KviQString::sprintf(szTmp,"Theme%dApplication",iIdx); - f.addInfoField(szTmp,pInfo->application()); - KviQString::sprintf(szTmp,"Theme%dThemeEngineVersion",iIdx); - f.addInfoField(szTmp,pInfo->themeEngineVersion()); - - if(!f.addDirectory(pInfo->absoluteDirectory(),pInfo->subdirectory())) - { - szTmp = __tr2qs_ctx("Packaging failed","addon"); - szTmp += ": "; - szTmp += f.lastError(); - QMessageBox::critical(this,__tr2qs_ctx("Export Addon - KVIrc","addon"),szTmp,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); - } - - iIdx++; - } - - if(!f.pack(m_szPackagePath)) + /* FIXME: this now saves only in home directory + // Select save path + const QString szSaveFile = __tr2qs_ctx("Select installer script:","addon"); + m_pSavePathSelector = new KviFileSelector(this,szSaveFile,&m_szPackagePath,true,1); + //pLayout->addWidget(m_pSavePathSelector,1,0); + m_pSavePathSelector->show(); + m_pSavePathSelector->commit(); + */ + // Create the addon package + if(!pw.pack(m_szPackagePath)) { szTmp = __tr2qs_ctx("Packaging failed","addon"); szTmp += ": "; - szTmp += f.lastError(); + szTmp += pw.lastError(); QMessageBox::critical(this,__tr2qs_ctx("Export Addon - KVIrc","addon"),szTmp,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); return false; } - */ QMessageBox::information(this,__tr2qs_ctx("Export Addon - KVIrc","addon"),__tr2qs("Package saved succesfully"),QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); @@ -224,7 +253,8 @@ void KviPackAddonInfoWidget::showEvent(QShowEvent *) QString szText = __tr2qs_ctx("Package Author:","addon") + " " + pCreateWidget->authorName() + "<br>"; szText += __tr2qs_ctx("Package Name:","addon") + " " + pCreateWidget->packageName() + "<br>"; szText += __tr2qs_ctx("Package Version:","addon") + " " + pCreateWidget->packageVersion() + "<br>"; - szText +=__tr2qs_ctx("Package Description:","addon") + " " + pCreateWidget->packageDescription() + "<br>"; + szText += __tr2qs_ctx("Package Description:","addon") + " " + pCreateWidget->packageDescription() + "<br>"; + szText += __tr2qs_ctx("Installer Script:","addon") + " " + pFileWidget->installerPath() + "<br>"; szText += __tr2qs_ctx("Source Directory:","addon") + " " + pFileWidget->sourcePath() + "<br>"; szText += __tr2qs_ctx("Image Directory:","addon") + " " + pFileWidget->imagePath() + "<br>"; szText += __tr2qs_ctx("Help Directory:","addon") + " " + pFileWidget->helpPath() + "<br>"; @@ -299,33 +329,32 @@ KviPackAddonFileSelectionWidget::KviPackAddonFileSelectionWidget(KviPackAddonDia 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 + const QString szInstallFile = __tr2qs_ctx("Select installer script:","addon"); + const QString szFilter = "*.kvs"; + m_pInstallPathSelector = new KviFileSelector(this,szInstallFile,&szInstallPath,true,0,szFilter); + pLayout->addWidget(m_pInstallPathSelector,1,0); - // per Hellvis: il famoso "option" è il puntatore alla stringa che conterrà il risultato del selettore - // che nel nostro caso è la directory scelta. Ma il meccanismo dei selettori è fatto in modo da memorizzare il valore - // nel puntatore che gli passiamo solo al momento in cui viene chiamato il metodo commit() del selettore stesso. E' stato pensato così - // per dare la possibilità di annullare il tutto nei vari menù di configurazione di kvirc. - // Noi lo richiameremo nell'header del packageaddondialog.h al momento di restituire la var richiesta: - // QString sourcePath(){m_pSourcePathSelector->commit();return szSourcePath;}; per esempio :) - - // select script dir + // Select script dir const QString szScriptDir = __tr2qs_ctx("Select scripts directory:","addon"); - m_pSourcePathSelector=new KviDirectorySelector(this,szScriptDir,&szSourcePath,true); - pLayout->addWidget(m_pSourcePathSelector,1,0); + m_pSourcePathSelector = new KviDirectorySelector(this,szScriptDir,&szSourcePath,true); + pLayout->addWidget(m_pSourcePathSelector,2,0); - // select image dir + // Select image dir const QString szImageDir = __tr2qs_ctx("Select images directory:","addon"); - m_pImagePathSelector=new KviDirectorySelector(this,szImageDir,&szImagePath,true); - pLayout->addWidget(m_pImagePathSelector,2,0); + m_pImagePathSelector = new KviDirectorySelector(this,szImageDir,&szImagePath,true); + pLayout->addWidget(m_pImagePathSelector,3,0); - // select help dir + // Select help dir const QString szHelpDir = __tr2qs_ctx("Select help directory:","addon"); - m_pHelpPathSelector=new KviDirectorySelector(this,szHelpDir,&szHelpPath,true); - pLayout->addWidget(m_pHelpPathSelector,3,0); + m_pHelpPathSelector = new KviDirectorySelector(this,szHelpDir,&szHelpPath,true); + pLayout->addWidget(m_pHelpPathSelector,4,0); - // select sound dir + // Select sound dir const QString szSoundDir = __tr2qs_ctx("Select sounds directory:","addon"); - m_pSoundPathSelector=new KviDirectorySelector(this,szSoundDir,&szSoundPath,true); - pLayout->addWidget(m_pSoundPathSelector,4,0); + m_pSoundPathSelector = new KviDirectorySelector(this,szSoundDir,&szSoundPath,true); + pLayout->addWidget(m_pSoundPathSelector,5,0); } KviPackAddonFileSelectionWidget::~KviPackAddonFileSelectionWidget() diff --git a/src/modules/addon/packaddondialog.h b/src/modules/addon/packaddondialog.h index e50e18646..ce46ffeae 100644 --- a/src/modules/addon/packaddondialog.h +++ b/src/modules/addon/packaddondialog.h @@ -45,10 +45,11 @@ class KviPackAddonDialog : public KviTalWizard public: KviPackAddonDialog(QWidget * pParent); ~KviPackAddonDialog(){}; - KviPackAddonCreateInfoPackageWidget * m_pPackAddonInfoCreateWidget ; - KviPackAddonFileSelectionWidget * m_pPackAddonFileSelectionWidget; - KviPackAddonInfoWidget *m_pPackAddonInfoWidget ; + KviPackAddonCreateInfoPackageWidget * m_pPackAddonInfoCreateWidget; + KviPackAddonFileSelectionWidget * m_pPackAddonFileSelectionWidget; + KviPackAddonInfoWidget * m_pPackAddonInfoWidget; protected: + KviFileSelector * m_pSavePathSelector; QString m_szPackagePath; protected: virtual void accept(); @@ -82,16 +83,18 @@ public: QString imagePath(){m_pImagePathSelector->commit();return szImagePath;}; QString helpPath(){m_pHelpPathSelector->commit();return szHelpPath;}; QString soundPath(){m_pSoundPathSelector->commit();return szSoundPath;}; + QString installerPath(){m_pInstallPathSelector->commit();return szInstallPath;}; protected: KviDirectorySelector * m_pSourcePathSelector; KviDirectorySelector * m_pImagePathSelector; KviDirectorySelector * m_pHelpPathSelector; KviDirectorySelector * m_pSoundPathSelector; - QString szSourcePath;//(){return m_pSourcePath->text();}; - QString szImagePath;//(){return m_pImagePath->text();}; - QString szHelpPath;//(){return m_pHelpPath->text();}; - QString szSoundPath;//(){return m_pSoundPath->text();}; - + KviFileSelector * m_pInstallPathSelector; + QString szSourcePath; + QString szImagePath; + QString szHelpPath; + QString szSoundPath; + QString szInstallPath; }; class KviPackAddonInfoWidget : public QWidget |
