aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/addon
diff options
context:
space:
mode:
authorGravatar Elvio Basello2008-05-12 23:06:21 +0000
committerGravatar Elvio Basello2008-05-12 23:06:21 +0000
commit99fb169d1cddbf5cb1f49348635d924237b0e3c2 (patch)
tree040043a3dbe8bb5240c347afdd2e625239bb760e /src/modules/addon
parentsmall fix on KviInput Icons height; (diff)
downloadKVIrc-99fb169d1cddbf5cb1f49348635d924237b0e3c2.tar.gz
KVIrc-99fb169d1cddbf5cb1f49348635d924237b0e3c2.tar.bz2
KVIrc-99fb169d1cddbf5cb1f49348635d924237b0e3c2.zip
more work on addon manager (wip)
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@1758 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules/addon')
-rw-r--r--src/modules/addon/managementdialog.cpp12
-rw-r--r--src/modules/addon/packaddondialog.cpp159
-rw-r--r--src/modules/addon/packaddondialog.h23
3 files changed, 112 insertions, 82 deletions
diff --git a/src/modules/addon/managementdialog.cpp b/src/modules/addon/managementdialog.cpp
index 07c2f2b16..d968b25c1 100644
--- a/src/modules/addon/managementdialog.cpp
+++ b/src/modules/addon/managementdialog.cpp
@@ -115,6 +115,12 @@ KviScriptManagementDialog::KviScriptManagementDialog(QWidget * p)
QToolTip::add(m_pHelpButton,__tr2qs_ctx("Show Help","addon"));
connect(m_pHelpButton,SIGNAL(clicked()),this,SLOT(showScriptHelp()));
+ m_pUninstallButton = new QToolButton(hb);
+ m_pUninstallButton->setIcon(*(g_pIconManager->getBigIcon(KVI_BIGICON_REMOVE)));
+ m_pUninstallButton->setIconSize(QSize(32,32));
+ QToolTip::add(m_pUninstallButton,__tr2qs_ctx("Delete Selected Addons","addon"));
+ connect(m_pUninstallButton,SIGNAL(clicked()),this,SLOT(uninstallScript()));
+
sep = new QFrame(hb);
sep->setFrameStyle(QFrame::VLine | QFrame::Sunken);
sep->setMinimumWidth(12);
@@ -125,12 +131,6 @@ KviScriptManagementDialog::KviScriptManagementDialog(QWidget * p)
QToolTip::add(m_pPackButton,__tr2qs_ctx("Create an Addon as a Distributable Package","addon"));
connect(m_pPackButton,SIGNAL(clicked()),this,SLOT(packScript()));
- m_pUninstallButton = new QToolButton(hb);
- m_pUninstallButton->setIcon(*(g_pIconManager->getBigIcon(KVI_BIGICON_REMOVE)));
- m_pUninstallButton->setIconSize(QSize(32,32));
- QToolTip::add(m_pUninstallButton,__tr2qs_ctx("Delete Selected Addons","addon"));
- connect(m_pUninstallButton,SIGNAL(clicked()),this,SLOT(uninstallScript()));
-
sep = new QFrame(hb);
sep->setFrameStyle(QFrame::VLine | QFrame::Sunken);
sep->setMinimumWidth(12);
diff --git a/src/modules/addon/packaddondialog.cpp b/src/modules/addon/packaddondialog.cpp
index 605b79b76..d62379f55 100644
--- a/src/modules/addon/packaddondialog.cpp
+++ b/src/modules/addon/packaddondialog.cpp
@@ -105,6 +105,14 @@ KviPackAddonDialog::KviPackAddonDialog(QWidget * pParent)
setNextEnabled(m_pPackAddonFileSelectionWidget,true);
setFinishEnabled(m_pPackAddonFileSelectionWidget,false);
+ // 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);
+
// Final results
m_pPackAddonInfoWidget=new KviPackAddonInfoWidget(this);
addPage(m_pPackAddonInfoWidget,__tr2qs_ctx("Package Path","addon"));
@@ -132,6 +140,7 @@ 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('\\',"/");
@@ -139,6 +148,7 @@ bool KviPackAddonDialog::packAddon()
szHelpPath.replace('\\',"/");
szSoundPath.replace('\\',"/");
szInstallPath.replace('\\',"/");
+ szPackagePath.replace('\\',"/");
QString szTmp = QDateTime::currentDateTime().toString();
@@ -197,26 +207,19 @@ bool KviPackAddonDialog::packAddon()
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;
- m_szPackagePath += "-";
- m_szPackagePath += szPackageVersion;
- m_szPackagePath += ".";
- m_szPackagePath += KVI_FILEEXTENSION_ADDONPACKAGE;
- qDebug("Addon name: %s",m_szPackagePath.toUtf8().data());
-
- /* 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))
+ if(szPackagePath.isEmpty())
+ {
+ szPackagePath = QDir::homeDirPath();
+ KviQString::ensureLastCharIs(szPackagePath,QChar(KVI_PATH_SEPARATOR_CHAR));
+ szPackagePath += szPackageName;
+ szPackagePath += "-";
+ szPackagePath += szPackageVersion;
+ szPackagePath += ".";
+ szPackagePath += KVI_FILEEXTENSION_ADDONPACKAGE;
+ }
+
+ if(!pw.pack(szPackagePath))
{
szTmp = __tr2qs_ctx("Packaging failed","addon");
szTmp += ": ";
@@ -230,42 +233,6 @@ bool KviPackAddonDialog::packAddon()
return true;
}
-KviPackAddonInfoWidget::KviPackAddonInfoWidget(KviPackAddonDialog *pParent)
-:QWidget(pParent)
-{
- m_pParent=pParent;
- QGridLayout *pLayout = new QGridLayout(this);
-
- 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_pLabelInfo = new QLabel(this);
- pLayout->addWidget(m_pLabelInfo,1,0);
-}
-
-void KviPackAddonInfoWidget::showEvent(QShowEvent *)
-{
- KviPackAddonCreateInfoPackageWidget * pCreateWidget=m_pParent->m_pPackAddonInfoCreateWidget;
- KviPackAddonFileSelectionWidget * pFileWidget = m_pParent->m_pPackAddonFileSelectionWidget;
-
- 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("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>";
- szText += __tr2qs_ctx("Sound Directory:","addon") + " " + pFileWidget->soundPath();
- m_pLabelInfo->setText(szText);
-}
-
-KviPackAddonInfoWidget::~KviPackAddonInfoWidget()
-{
-}
-
KviPackAddonCreateInfoPackageWidget::KviPackAddonCreateInfoPackageWidget(KviPackAddonDialog *pParent)
:QWidget(pParent)
{
@@ -317,10 +284,6 @@ KviPackAddonCreateInfoPackageWidget::KviPackAddonCreateInfoPackageWidget(KviPack
pLayout->setRowStretch(1,1);
}
-KviPackAddonCreateInfoPackageWidget::~KviPackAddonCreateInfoPackageWidget()
-{
-}
-
KviPackAddonFileSelectionWidget::KviPackAddonFileSelectionWidget(KviPackAddonDialog *pParent)
: QWidget(pParent)
{
@@ -331,32 +294,86 @@ KviPackAddonFileSelectionWidget::KviPackAddonFileSelectionWidget(KviPackAddonDia
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);
+ m_pInstallPathSelector = new KviFileSelector(this,__tr2qs_ctx("Select installer script:","addon"),&szInstallPath,true,0,"*.kvs");
pLayout->addWidget(m_pInstallPathSelector,1,0);
// Select script dir
- const QString szScriptDir = __tr2qs_ctx("Select scripts directory:","addon");
- m_pSourcePathSelector = new KviDirectorySelector(this,szScriptDir,&szSourcePath,true);
+ m_pSourcePathSelector = new KviDirectorySelector(this,__tr2qs_ctx("Select scripts directory:","addon"),&szSourcePath,true);
pLayout->addWidget(m_pSourcePathSelector,2,0);
// Select image dir
- const QString szImageDir = __tr2qs_ctx("Select images directory:","addon");
- m_pImagePathSelector = new KviDirectorySelector(this,szImageDir,&szImagePath,true);
+ m_pImagePathSelector = new KviDirectorySelector(this,__tr2qs_ctx("Select images directory:","addon"),&szImagePath,true);
pLayout->addWidget(m_pImagePathSelector,3,0);
// Select help dir
- const QString szHelpDir = __tr2qs_ctx("Select help directory:","addon");
- m_pHelpPathSelector = new KviDirectorySelector(this,szHelpDir,&szHelpPath,true);
+ m_pHelpPathSelector = new KviDirectorySelector(this,__tr2qs_ctx("Select help directory:","addon"),&szHelpPath,true);
pLayout->addWidget(m_pHelpPathSelector,4,0);
// Select sound dir
- const QString szSoundDir = __tr2qs_ctx("Select sounds directory:","addon");
- m_pSoundPathSelector = new KviDirectorySelector(this,szSoundDir,&szSoundPath,true);
+ m_pSoundPathSelector = new KviDirectorySelector(this,__tr2qs_ctx("Select sounds directory:","addon"),&szSoundPath,true);
pLayout->addWidget(m_pSoundPathSelector,5,0);
}
-KviPackAddonFileSelectionWidget::~KviPackAddonFileSelectionWidget()
+KviPackAddonSaveSelectionWidget::KviPackAddonSaveSelectionWidget(KviPackAddonDialog *pParent)
+: QWidget(pParent)
+{
+ QGridLayout * pLayout = new QGridLayout(this);
+
+ 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);
+
+ // Create addon name
+ KviPackAddonCreateInfoPackageWidget * pCreateWidget=pParent->m_pPackAddonInfoCreateWidget;
+
+ szSavePath = QDir::homeDirPath();
+ KviQString::ensureLastCharIs(szSavePath,QChar(KVI_PATH_SEPARATOR_CHAR));
+ szSavePath += pCreateWidget->packageName();
+ szSavePath += "-";
+ szSavePath += pCreateWidget->packageVersion();
+ szSavePath += ".";
+ szSavePath += KVI_FILEEXTENSION_ADDONPACKAGE;
+ qDebug("Addon name: %s",szSavePath.toUtf8().data());
+
+ // Setting dialog filter
+ QString szFilter = "*.";
+ szFilter += KVI_FILEEXTENSION_ADDONPACKAGE;
+
+ // 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);
+}
+
+KviPackAddonInfoWidget::KviPackAddonInfoWidget(KviPackAddonDialog *pParent)
+:QWidget(pParent)
{
+ m_pParent=pParent;
+ QGridLayout *pLayout = new QGridLayout(this);
+
+ 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_pLabelInfo = new QLabel(this);
+ pLayout->addWidget(m_pLabelInfo,1,0);
+}
+
+void KviPackAddonInfoWidget::showEvent(QShowEvent *)
+{
+ KviPackAddonCreateInfoPackageWidget * pCreateWidget=m_pParent->m_pPackAddonInfoCreateWidget;
+ KviPackAddonFileSelectionWidget * pFileWidget = m_pParent->m_pPackAddonFileSelectionWidget;
+ KviPackAddonSaveSelectionWidget * pSaveWidget = m_pParent->m_pPackAddonSaveSelectionWidget;
+
+ QString 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>";
+ 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("Image Directory","addon") + ":</b> " + pFileWidget->imagePath() + "<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 ce46ffeae..46dfee362 100644
--- a/src/modules/addon/packaddondialog.h
+++ b/src/modules/addon/packaddondialog.h
@@ -37,6 +37,7 @@
class KviPackAddonCreateInfoPackageWidget;
class KviPackAddonFileSelectionWidget;
+class KviPackAddonSaveSelectionWidget;
class KviPackAddonInfoWidget;
class KviPackAddonDialog : public KviTalWizard
@@ -47,10 +48,10 @@ public:
~KviPackAddonDialog(){};
KviPackAddonCreateInfoPackageWidget * m_pPackAddonInfoCreateWidget;
KviPackAddonFileSelectionWidget * m_pPackAddonFileSelectionWidget;
+ KviPackAddonSaveSelectionWidget * m_pPackAddonSaveSelectionWidget;
KviPackAddonInfoWidget * m_pPackAddonInfoWidget;
protected:
- KviFileSelector * m_pSavePathSelector;
- QString m_szPackagePath;
+ QString m_szPackagePath;
protected:
virtual void accept();
bool packAddon();
@@ -61,7 +62,7 @@ class KviPackAddonCreateInfoPackageWidget : public QWidget
Q_OBJECT
public:
KviPackAddonCreateInfoPackageWidget(KviPackAddonDialog *pParent);
- ~KviPackAddonCreateInfoPackageWidget();
+ ~KviPackAddonCreateInfoPackageWidget(){};
QString authorName(){return m_pAuthorNameEdit->text();};
QString packageName(){return m_pPackageNameEdit->text();};
QString packageVersion(){return m_pPackageVersionEdit->text();};
@@ -78,7 +79,7 @@ class KviPackAddonFileSelectionWidget : public QWidget
Q_OBJECT
public:
KviPackAddonFileSelectionWidget(KviPackAddonDialog *pParent);
- ~KviPackAddonFileSelectionWidget();
+ ~KviPackAddonFileSelectionWidget(){};
QString sourcePath(){m_pSourcePathSelector->commit();return szSourcePath;};
QString imagePath(){m_pImagePathSelector->commit();return szImagePath;};
QString helpPath(){m_pHelpPathSelector->commit();return szHelpPath;};
@@ -97,11 +98,23 @@ protected:
QString szInstallPath;
};
+class KviPackAddonSaveSelectionWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ KviPackAddonSaveSelectionWidget(KviPackAddonDialog *pParent);
+ ~KviPackAddonSaveSelectionWidget(){};
+ QString savePath(){m_pSavePathSelector->commit();return szSavePath;};
+protected:
+ KviFileSelector * m_pSavePathSelector;
+ QString szSavePath;
+};
+
class KviPackAddonInfoWidget : public QWidget
{
public:
KviPackAddonInfoWidget(KviPackAddonDialog *);
- ~KviPackAddonInfoWidget();
+ ~KviPackAddonInfoWidget(){};
protected:
KviPackAddonDialog * m_pParent;
QLabel * m_pLabelInfo;