aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Elvio Basello2009-10-28 01:48:31 +0000
committerGravatar Elvio Basello2009-10-28 01:48:31 +0000
commit9da6b24b5684270fc96eed34cffb969b786fa389 (patch)
tree8714a31b41fa22564818154dd8ae4c3ddea5132d
parentfix for #587 (diff)
downloadKVIrc-9da6b24b5684270fc96eed34cffb969b786fa389.tar.gz
KVIrc-9da6b24b5684270fc96eed34cffb969b786fa389.tar.bz2
KVIrc-9da6b24b5684270fc96eed34cffb969b786fa389.zip
moar work on addon packaging system (wip), updated its doc;
removed useless filter; I somehow introduced a glitch in the installer creation, I'll investigate on this git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@3580 17fca916-40b9-46aa-a4ea-0a15b648b75c
-rw-r--r--src/kvilib/config/kvi_fileextensions.h11
-rw-r--r--src/kvirc/kvs/kvi_kvs_parser.cpp316
-rw-r--r--src/modules/addon/managementdialog.cpp13
-rw-r--r--src/modules/addon/packaddondialog.cpp362
-rw-r--r--src/modules/addon/packaddondialog.h80
5 files changed, 460 insertions, 322 deletions
diff --git a/src/kvilib/config/kvi_fileextensions.h b/src/kvilib/config/kvi_fileextensions.h
index 341c4a92f..d33a66e27 100644
--- a/src/kvilib/config/kvi_fileextensions.h
+++ b/src/kvilib/config/kvi_fileextensions.h
@@ -45,13 +45,12 @@
#define KVI_FILEEXTENSION_ADDONPACKAGE ".kva"
/**
-* \brief Filters
+* \brief File filters
*
* \def KVI_FILTER_CONFIG Configuration file *.kvs
* \def KVI_FILTER_SCRIPT Script file *.kvs
* \def KVI_FILTER_THEME Theme package *.kvt
* \def KVI_FILTER_ADDON Addon package *.kva
-* \def KVI_FILTER_SCRIPTS Script files *.kvs *.kva
* \def KVI_FILTER_INI Ini file *.ini
* \def KVI_FILTER_IMAGE Image file *.png *.jpg *.jpeg *.bmp *.gif *.xpm
* \def KVI_FILTER_UI User interface file *.ui
@@ -62,21 +61,17 @@
#define KVI_FILTER_SCRIPT "*.kvs|KVIrc Script (*.kvs)"
#define KVI_FILTER_THEME "*.kvt|KVIrc Theme (*.kvt)"
#define KVI_FILTER_ADDON "*.kva|KVIrc Addon (*.kva)"
- // Provided for convenience
- #define KVI_FILTER_SCRIPTS "*.kvs *.kva|KVIrc Script and Addon (*.kvs *.kva)"
#define KVI_FILTER_INI "*.ini|INI File (*.ini)"
#define KVI_FILTER_IMAGE "*.png *.jpg *.jpeg *.bmp *.gif *.xpm|Image File (*.png *.jpg *.jpeg *.bmp *.gif *.xpm)"
- #define KVI_FILTER_UI "*.ui|User Interface File (*.ui)"
+ //#define KVI_FILTER_UI "*.ui|User Interface File (*.ui)"
#else
#define KVI_FILTER_CONFIG "KVIrc Config (*.kvc)"
#define KVI_FILTER_SCRIPT "KVIrc Script (*.kvs)"
#define KVI_FILTER_THEME "KVIrc Theme (*.kvt)"
#define KVI_FILTER_ADDON "KVIrc Addon (*.kva)"
- // Provided for convenience
- #define KVI_FILTER_SCRIPTS "KVIrc Script and Addon (*.kvs *.kva)"
#define KVI_FILTER_INI "INI File (*.ini)"
#define KVI_FILTER_IMAGE "Image File (*.png *.jpg *.jpeg *.bmp *.gif *.xpm)"
- #define KVI_FILTER_UI "User Interface File (*.ui)"
+ //#define KVI_FILTER_UI "User Interface File (*.ui)"
#endif //COMPILE_KDE_SUPPORT
#endif //_KVI_FILEEXTENSIONS_H_
diff --git a/src/kvirc/kvs/kvi_kvs_parser.cpp b/src/kvirc/kvs/kvi_kvs_parser.cpp
index 265530bd8..569079265 100644
--- a/src/kvirc/kvs/kvi_kvs_parser.cpp
+++ b/src/kvirc/kvs/kvi_kvs_parser.cpp
@@ -1269,41 +1269,42 @@ KviKvsTreeNodeInstruction * KviKvsParser::parseAsParameter(const QChar * pBuffer
[p]
An addon is basically a set of KVS scripts, multimedia, documentation
and accessory files that implement a KVIrc feature.
- It might be a simple automatic-away subsystem, a GUI newsticker or a complex file sharing
+ It might be a simple automatic-away subsystem, a GUI newsticker or a complex
+ file sharing
service (commonly called "fserve"). Addons are sometimes called "scripts".
In fact a KVIrc addon is usually made of more than one KVS script.
[/p]
[p]
- KVIrc has a builtin addon management system that allows the users
- to install, configure and uninstall features with a nice graphical interface.
- The management system allows the addons to have documentation integrated in the
- KVIrc help and to be translated in several languages.
+ KVIrc has a builtin addon management system that allows the users to create,
+ install, configure and uninstall features with a nice graphical interface.
+ The management system allows the addons to have documentation integrated in
+ the KVIrc help and to be translated in several languages.
[/p]
[big]Addon installation[/big]
[p]
- The addons are usually shipped in compressed archives (such as tar.gz "tarballs" or
- zip files). Once uncompressed they should contain a KVS script file called "install.kvs".
- KVIrc will look for and execute this file when the user will ask for your addon to
- be installed. The install.kvs will usually contain the code for the [b]registration[/b]
- of your addon and will [cmd]include[/cmd] all the other necessary source files.
+ The addons are usually shipped in compressed archives (.kva). KVIrc will look
+ for the installer file called "install.kvs" and executes it when the user will
+ ask for your addon to be installed. The install.kvs contains the code for the
+ [b]registration[/b] of your addon and will [cmd]include[/cmd] all the other
+ necessary source files.
[/p]
[big]The minimal addon[/big]
[p]
The smallest addon that you can write is the one that does nothing.
- It just need to be writte in a file named install.kvs and contain code
- similar to the following:
[example]
- [cmd]addon.register[/cmd]("myaddon", \
- "1.0.0", \
- "My First Addon", \
- "An addon that is really cool but does simply nothing", \
- "3.2.0.99.20051230")
+ [cmd]addon.register[/cmd]("MyAddon", \
+ "1.0.0", \
+ "My First Addon", \
+ "An addon that is really cool but does
+ simply nothing", \
+ "4.0.0", \
+ "MyAddon_32.png")
{
}
[/example]
- The code above does nothing but registers the "myaddon" addon.
+ The code above does nothing but registers the "MyAddon" addon.
[/p]
[p]
The first parameter is the internal addon id which can be used to identify
@@ -1311,134 +1312,231 @@ KviKvsTreeNodeInstruction * KviKvsParser::parseAsParameter(const QChar * pBuffer
name cannot be installed. The second parameter is the addon version. It should
be expressed in the classic format [major].[minor].[pathlevel] or something
really similar (in fact KVIrc just expects the version to be a string composed
- of numbers separated by dots). The version is compared when an addon is installed
- and KVIrc complains if the user tries to downgrade an addon (that is to install
- a less recent version over a more recent one). The third parameter
+ of numbers separated by dots). The version is compared when an addon is
+ installed and KVIrc complains if the user tries to downgrade an addon (that is
+ to install a less recent version over a more recent one). The third parameter
is the visible name of your addon: it will be displayed to the user in the
addon management dialog. It can contain the [fnc]$tr[/fnc] function so you
can have it translated to several languages. The fourth parameter
- is a short description of the feature that the addon implements; it can contain
- the $tr() function too. The fifth parameter is the minimal KVIrc version
- required to run the addon. There is also a sixth parameter (the icon) and
- some switches that can be used to fiddle a little bit more :)
+ is a short description of the feature that the addon implements; it can
+ contain the $tr() function too. The fifth parameter is the minimal KVIrc
+ version required to run the addon. The sixth parameter is the icon to show in
+ the manager: it has to be 32x32 pixel big. There are also some switches that
+ can be used to fiddle a little bit more :)
[/p]
[p]
The callback instruction that follows the registration command is the
- uninstallation code. KVIrc will invoke it when the user will ask for
- your addon to be uninstalled. Don't assume that your addon will be never uninstalled:
- sooner or later it will be. For example, when upgrading an addon KVIrc
- will first uninstall the existing version and after that install the new one.
- The uninstallation process is a very important requisite for any program (in any
- programming language). In the example above there is nothing to uninstall (yet)
- so the callback code is empty, but if you continue reading we will soon fill it.
+ uninstallation code. KVIrc will invoke it when the user will ask for your
+ addon to be uninstalled. Don't assume that your addon will be never
+ uninstalled: sooner or later it will be. For example, when upgrading an addon
+ KVIrc will first uninstall the existing version and after that install the new
+ one. The uninstallation process is a very important requisite for any program
+ (in any programming language). In the example above there is nothing to
+ uninstall (yet) so the callback code is empty, but if you continue reading we
+ will soon fill it.
+ To uninstall all files which are not automatically spotted by the installation
+ process, you need to write an alias which handles them.
+ [example]
+ alias(MyAddon::uninstall::uninstall)
+ {
+ ...
+ }
+ [/example]
[/p]
[big]A typical addon layout[/big]
[p]
As stated above, the addons are usually shipped in a compressed archive.
- Once uncompressed, the archive will expand into a small directory tree
- containing the addon code and all the related files.
- In order to have uniformity I encourage you to use the following directory structure.
+ Once uncompressed, the installer will check the directory tree containing the
+ addon code and all the related files.
+ In order to have uniformity the installer complains if the structure is not
+ respected.
[/p]
[p]
[pre]
-     [b]addonId-version/[/b]
-         install.kvs
-         INSTALL
-         [b]src[/b]
-                 source1.kvs
-                 source2.kvs
-                 source3.kvs
-                 ...
-         [b]pics[/b]
-                 addonId_pic1.png
-                 addonId_pic2.png
-                 addonId_pic3.png
-                 ...
-         [b]audio[/b]
-                 addonId_audio1.png
-                 addonId_audio2.png
-                 addonId_audio3.png
-                 ...
-         [b]help[/b]
-                 en
-                         index.html
-                         hints.html
-                         ...
-                 it
-                         index.html
-                         hints.html
-                         ...
-                 ...
-         [b]locale[/b]
-                 addonId_it.mo
-                 addonId_ru.mo
-                 addonId_de.mo
-                 ...
-         [b]...[/b]
-                 ...
-                 ...
-                 ...
-                 ...
+ [b]name-version[/b]
+ +- init.kvs
+ +- [b]src[/b]
+ | +- source1.kvs
+ | +- source2.kvs
+ | \- ...
+ +- [b]locale[/b]
+ | +- name_it.mo
+ | +- name_de.mo
+ | \- ...
+ +- [b]config[/b]
+ | +- config1.kvc
+ | +- config2.kvc
+ | \- ...
+ +- [b]sound[/b]
+ | +- audio1.wav
+ | +- audio2.wav
+ | \- ...
+ +- [b]pics[/b]
+ | +- pic1.png
+ | +- pic2.png
+ | \- ...
+ +- [b]help[/b]
+ +- [b]en[/b]
+ | +- index.html
+ | +- hints.html
+ | \- ...
+ +- [b]it[/b]
+ +- index.html
+ +- hints.html
+ \- ...
[/pre]
[/p]
[p]
The entries in [b]bold[/b] are directories while the other are files.
- Please note that this is a general layout for a huge and rather complex
- addon: you might not need all of these directories. Remember: the minimal
- addon has only an install.kvs file. Anyway, a really cool addon
- will probably have all of them and maybe some more.
+ Please note that you need all of these directories or the routine that
+ automagically creates the installer will fail.
[/p]
[p]
- The toplevel directory should be named with your addonId and version.
- Try to use no spaces in the directory entries (this will make the things
- simplier for people that want to use your addon). The toplevel
- directory should contain your install.kvs script and a file with
- a small description and the basic installation instructions.
- This file can be named INSTALL or README.
+ The toplevel directory should be named with your addon name and version.
+ Use no spaces in the directory entries (this will make the things simplier for
+ people that want to use your addon).
[/p]
[p]
Hint: Remember that your addon is going to be installed on different platforms
(at least linux, macosx and windows based).
- The poor windows notepad has serious problems with reading text
+ The poor windows' notepad has serious problems with reading text
files that contain only linefeeds as line separators. Keep it in mind...
[/p]
[p]
- The main source directory for your addon should be named "src" and
- should contain the implementation of the feature(s) you're going to provide.
- These files should be executed by the means of the [cmd]parse[/cmd]
- command (or [cmd]include[/cmd] if you like the C/C++ style) from install.kvs.
+ The [b]initialization script[/b] has to be named init.kvs and must contain all the
+ routines to register your addon.
+ [example]
+ [comment]# Register classes[/comment]
+ MyAddon::classes::register
+
+ [comment]# Initialize events[/comment]
+ MyAddon::events::init
+
+ [comment]# Load configuration[/comment]
+ MyAddon::config::load
+
+ [comment]# Setup popups[/comment]
+ defpopup("MyAddon")
+ {
+ item($tr("Something","MyAddon"),110)
+ {
+ ...
+ }
+ }
+
+ [comment]# Set options[/comment]
+ option boolAutoAcceptDccSend 1
+ option boolShowMinimizedDebugWindow 1
+ [/example]
+ [/p]
+ [p]
+ The main [b]source directory[/b] for your addon have to be named "src" and must
+ contain the implementation of the feature(s) you're going to provide.
+ File names should contain the namespace of the addon, the optional subnamespace
+ and the name of the feature like $addonNS_$subNS_[$subNS_[...]]$name.kvs
+ [example]
+ [comment]# A class which handles a database[/comment]
+ MyAddon_classes_database.kvs
+
+ [comment]# A class which handles the options of our addon in a GUI[/comment]
+ MyAddon_classes_gui_options.kvs
+
+ [comment]# A script containing some logging functions[/comment]
+ MyAddon_functions_logging.kvs
+ [/example]
+ [/p]
+ [p]
+ The "[b]locale[/b]" directory should contain the *.mo files for your tranlations.
+ The localization process of a script is explained in [doc:localization]this document[/doc].
+ Your *.mo filenames should be prefixed by your addon name.
+ [/p]
+ [p]
+ The [b]configuration directory[/b] "config" should contains only the files
+ which store the configuration of your addon and must end with the .kvc
+ extension.
[/p]
[p]
- The "pics" and "audio" (if relevant) directories should contain your
- multimedia files. It is a good idea to prefix the filenames with your addon id
- in order to avoid collisions with other addons. The install.kvs script
- should copy these files to the appropriate locations under the KVIrc local
- directory returned by [fnc]$file.localdir[/fnc]().
+ The "[b]pics[/b]" and "[b]sound[/b]" (if relevant) directories should contain
+ your multimedia files. I's a good idea to have your pics file in PNG format
+ and sound files in WAV format.
[/p]
[p]
- The "help" directory should contain subdirectories for each language that
+ The "[b]help[/b]" directory should contain subdirectories for each language
your help files are written in. The languages dirs should be named
- with the language code also used for the translation files (like "en","it" etc...).
+ with the language code also used for the translation files (like "en", "it"
+ etc...).
Please note that english is the default language and KVIrc will
fallback to the "en" subdirectory when no other language is found around...
- The help files (and subdirectories) should be copied to the "help" subdirectory of the KVIrc local
- directory returned by [fnc]$file.localdir[/fnc]().
- Since there will be many help files inside the language dirs, it is a good idea
- to either prefix your help files with your addon id or (better) to create
- a subdirectory named agains your addon inside the help language directory.
- For an english file this would lead to something like...
+ [/p]
+
+ [big]Some examples[/big]
+ [p]The code below is just an example of how to write a useful initalizazion of
+ your own addon. The name of the classes refer to the ones described above.
+
[example]
- file.copy index.html $file.localdir("help/en/myaddon")
+ [comment]# Register the classes[/comment]
+ alias(MyAddon::classes::register)
+ {
+ [comment]# Create an array with all the classes of our addon.[/comment]
+ [comment]# In this way it's easy to add or remove classes to registering routine[/comment]
+ %classes[] = [fnc]$array[/fnc]( \
+ MyAddon::classes::database, \
+ MyAddon::classes::gui::options, \
+ ...
+ )
+
+ [comment]# Scan the array and register the classes[/comment]
+ for(%i=0; %i < [fnc]$length[/fnc](%classes[]); %i++)
+ {
+ if([fnc]$classDefined[/fnc]("%classes[%i]"))
+ {
+ [cmd]objects.killclass[/cmd] %classes[%i]
+ }
+ [cmd]eval[/cmd] %classes[%i]
+ }
+ }
+
+ [comment]# Initialize events[/comment]
+ alias(MyAddon::events::init)
+ {
+ event(OnKVIrcStartup,"MyAddon")
+ {
+ ...
+ [comment]# Load the catalogue (translation) file "myaddon" from the path provided[/comment]
+ [cmd]trload[/cmd] myaddon [fnc]$file.localdir[/fnc]("locale/MyAddon")
+ MyAddon::config::load
+ ...
+ }
+ event(OnChannelMessage,"MyAddon_something")
+ {
+ ...
+ }
+ }
+
+ [comment]# Load configuration[/comment]
+ alias(MyAddon::config::load)
+ {
+ [comment]# If the class ConfHandler is not defined, register all classes we have[/comment]
+ if(![fnc]$classDefined[/fnc](MyAddon::classes::ConfHandler))
+ {
+ MyAddon::classes::register
+ }
+
+ [comment]# Sets some variables[/comment]
+ %MyAddonConfig = [fnc]$new[/fnc](MyAddon::classes::ConfHandler)
+ %MyAddonConfigPath = [fnc]$file.localdir[/fnc](config/scripts/MyAddon)
+
+ [comment]# Open the configuration file and sets the section "general"[/comment]
+ %c = [fnc]$config.open[/fnc](%MyAddonConfigPath/MyAddon.kvc,"r")
+ [cmd]config.setsection[/cmd] %c general
+
+ [comment]# Store the value of the key "Key" in the global variable %Key[/comment]
+ %Key = [fnc]$config.read[/fnc](%c,"Key",2)
+ ...
+ }
[/example]
[/p]
- [p]
- The "locale" directory should contain the *.mo files for your tranlations.
- The localization process of a script is explained in [doc:localization]this document[/doc].
- The *.mo files should be copied to the "locale" subdirectory of the KVIrc local
- directory returned by [fnc]$file.localdir[/fnc]().
- Your *.mo filenames should be prefixed by your addon id (again to avoid collisions).
- [/p]
[big]The help and configuration callbacks[/big]
[p]
diff --git a/src/modules/addon/managementdialog.cpp b/src/modules/addon/managementdialog.cpp
index 8acfd3e53..6f01d26da 100644
--- a/src/modules/addon/managementdialog.cpp
+++ b/src/modules/addon/managementdialog.cpp
@@ -277,20 +277,13 @@ void KviScriptManagementDialog::installScript()
if(!KviFileDialog::askForOpenFileName(
szFileName,
__tr2qs("Please select the addon installation file"),
- QString(),KVI_FILTER_SCRIPTS,false,true
+ QString(),KVI_FILTER_ADDON,false,true
)) return;
szFileName.replace("\\","\\\\");
- // Switch between script and addon
- if(szFileName.endsWith(".kvs"))
- {
- QString szCmd = "parse \"";
- szCmd += szFileName;
- szCmd += "\"";
-
- KviKvsScript::run(szCmd,g_pActiveWindow);
- } else if(szFileName.endsWith(".kva"))
+ // Sanity check
+ if(szFileName.endsWith(".kva"))
{
if(!KviAddonFunctions::installAddonPackage(szFileName,szError,this))
{
diff --git a/src/modules/addon/packaddondialog.cpp b/src/modules/addon/packaddondialog.cpp
index bbbbfc028..c51e9542d 100644
--- a/src/modules/addon/packaddondialog.cpp
+++ b/src/modules/addon/packaddondialog.cpp
@@ -25,28 +25,21 @@
#include "packaddondialog.h"
#include "addonfunctions.h"
-#include "kvi_options.h"
#include "kvi_locale.h"
-#include "kvi_config.h"
#include "kvi_fileutils.h"
#include "kvi_app.h"
-#include "kvi_frame.h"
#include "kvi_iconmanager.h"
#include "kvi_packagefile.h"
#include "kvi_fileextensions.h"
-#include "kvi_filedialog.h"
-#include "kvi_msgbox.h"
-#include "kvi_selectors.h"
-#include "kvi_miscutils.h"
#include "kvi_sourcesdate.h"
#include <QTextEdit>
#include <QLineEdit>
+#include <QLabel>
#include <QMessageBox>
#include <QDir>
+#include <QDirIterator>
#include <QDateTime>
-#include <QLabel>
-#include <QString>
KviPackAddonDialog::KviPackAddonDialog(QWidget * pParent)
@@ -81,10 +74,8 @@ KviPackAddonDialog::KviPackAddonDialog(QWidget * pParent)
setPixmap(QWizard::LogoPixmap,*pLogo);
#endif
- // Add the properties to handle fields
- setDefaultProperty("QTextEdit","plainText","textChanged()");
- setDefaultProperty("KviFileSelector","file","selectionChanged()");
- setDefaultProperty("KviDirectorySelector","dir","selectionChanged()");
+ // Add a default property for file selectors
+ setDefaultProperty("KviFileSelector","tmpFile",SIGNAL(selectionChanged(const QString &)));
// Welcome page
QWizardPage * pPage = new QWizardPage(this);
@@ -118,9 +109,9 @@ KviPackAddonDialog::KviPackAddonDialog(QWidget * pParent)
m_pPackAddonSaveSelectionWidget = new KviPackAddonSaveSelectionWidget(this);
addPage(m_pPackAddonSaveSelectionWidget);
- // Final results
- m_pPackAddonSummaryWidget = new KviPackAddonSummaryWidget(this);
- addPage(m_pPackAddonSummaryWidget);
+ // Summary info
+ m_pPackAddonSummaryInfoWidget = new KviPackAddonSummaryInfoWidget(this);
+ addPage(m_pPackAddonSummaryInfoWidget);
}
KviPackAddonDialog::~KviPackAddonDialog()
@@ -133,114 +124,87 @@ void KviPackAddonDialog::accept()
QWizard::accept();
}
-bool KviPackAddonDialog::checkDirTree(QString & szAddonDir, QString * pszError)
+bool KviPackAddonDialog::checkDirTree(QString * pszError)
{
if(pszError) *pszError = "";
- QDir addon(szAddonDir);
+ QDir addon(m_szDirPath);
if(!addon.exists())
{
*pszError = __tr2qs_ctx("The selected directory does not exist.","addon");
return false;
}
- QDir source(szAddonDir + "/src");
+ QDir source(m_szDirPath + "/src");
if(!source.exists())
{
*pszError = __tr2qs_ctx("The sources directory (src) does not exist.","addon");
return false;
}
- QDir locale(szAddonDir + "/locale");
+ QDir locale(m_szDirPath + "/locale");
if(!locale.exists())
{
*pszError = __tr2qs_ctx("The translations directory (locale) does not exist.","addon");
return false;
}
- QDir sound(szAddonDir + "/sound");
+ QDir sound(m_szDirPath + "/sound");
if(!sound.exists())
{
*pszError = __tr2qs_ctx("The sounds directory (sound) does not exist.","addon");
return false;
}
- QDir pics(szAddonDir + "/pics");
+ QDir pics(m_szDirPath + "/pics");
if(!pics.exists())
{
*pszError = __tr2qs_ctx("The pictures directory (pics) does not exist.","addon");
return false;
}
- QDir config(szAddonDir + "/config");
+ QDir config(m_szDirPath + "/config");
if(!config.exists())
{
*pszError = __tr2qs_ctx("The configurations directory (config) does not exist.","addon");
return false;
}
- QDir help(szAddonDir + "/help");
+ QDir help(m_szDirPath + "/help");
if(!help.exists())
{
*pszError = __tr2qs_ctx("The help directory (help) does not exist.","addon");
return false;
}
+ QFileInfo init(m_szDirPath + "/init.kvs");
+ if(!init.exists())
+ {
+ *pszError = __tr2qs_ctx("The initialization script (init.kvs) does not exist.","addon");
+ return false;
+ }
+
return true;
}
-bool KviPackAddonDialog::createInstaller(QString & szAddonDir, QString * pszError)
+bool KviPackAddonDialog::createInstaller(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 += QString("# %1 %2\n# Written by %3\n# %4\n\n").arg(m_szName) \
+ .arg(m_szVersion).arg(m_szAuthor).arg(m_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);
+ .arg(m_szName).arg(m_szVersion) \
+ .arg(m_szDescription).arg(m_szMinVersion) \
+ .arg(m_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 += QString("%1::uninstall::uninstall\n}\n\n").arg(m_szName);
szTmp += "# Ok, addon.register succeeded. We can go on with the installation.\n\n";
// install.kvs: run path
@@ -253,16 +217,16 @@ bool KviPackAddonDialog::createInstaller(QString & szAddonDir, QString * pszErro
// 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 += QString("%installer->$copyFiles(\"%mypath/pics/\",\"*.png\",$file.localdir(\"pics/%1\"))\n\n").arg(m_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);
+ szTmp += QString("%installer->$copyFiles(\"%mypath/help/en/%1/\",\"*.html\",$file.localdir(\"help/en/%1\"))\n\n").arg(m_szName);
// install.kvs: generate uninstall alias
szTmp += "# Generate the uninstall alias\n";
szTmp += QString("%installer->$generateUninstallAlias(\"%1::uninstall::uninstallfiles\")\n\n") \
- .arg(szName);
+ .arg(m_szName);
// install.kvs: kill the installer class
szTmp += "# Kill the installer helper\n";
@@ -272,14 +236,14 @@ bool KviPackAddonDialog::createInstaller(QString & szAddonDir, QString * pszErro
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);
+ .arg(m_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);
+ .arg(m_szName);
szTmp += "%alias .= \"}\"\n";
szTmp += "eval %alias\n\n";
@@ -291,7 +255,18 @@ bool KviPackAddonDialog::createInstaller(QString & szAddonDir, QString * pszErro
QByteArray buffer;
buffer.append(szTmp.toUtf8());
- // Finally, write the buffer to the file descriptor
+ // We don't need to check dir existance since it was checked just before
+ QDir addon(m_szDirPath);
+
+ // 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;
+ }
+
+ // Write the buffer to the file descriptor
if(installer.write(buffer) == -1)
{
*pszError = __tr2qs_ctx("Cannot write to the file descriptor.","addon");
@@ -306,31 +281,35 @@ bool KviPackAddonDialog::packAddon()
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();
-*//*
+ m_szAuthor = field("packageAuthor").toString();
+ m_szName = field("packageName").toString();
+ m_szVersion = field("packageVersion").toString();
+ m_szDescription = field("packageDescription").toString();
+ m_szMinVersion = field("packageMinVersion").toString();
+ m_szIcon = field("packageIcon").toString().section("/",-1);
+ m_szDirPath = field("packageDirPath").toString();
+ m_szSavePath = field("packageSavePath").toString();
+
// Check the addon tree
- if(!checkDirTree(szDirPath,&szError))
+ if(!checkDirTree(&szError))
{
QMessageBox::critical(this,
__tr2qs_ctx("Addon Packaging Error","addon"),
szError,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton
);
return false;
- }*/
+ }
+
+ // Raise the files summary dialog
+ m_pPackAddonSummaryFilesWidget = new KviPackAddonSummaryFilesWidget(this);
+ m_pPackAddonSummaryFilesWidget->setPath(m_szDirPath);
+ if(m_pPackAddonSummaryFilesWidget->exec() == QDialog::Rejected)
+ {
+ return false;
+ }
// Create the installer file
- if(!createInstaller(szDirPath,&szError))
+ if(!createInstaller(&szError))
{
QMessageBox::critical(this,
__tr2qs_ctx("Addon Packaging Error","addon"),
@@ -338,45 +317,24 @@ bool KviPackAddonDialog::packAddon()
return false;
}
-return false;
-#if 0
-/*
- QString szSourcePath = m_pPackAddonFileSelectionWidget->sourcePath();
- QString szConfigPath = m_pPackAddonFileSelectionWidget->configPath();
- QString szImagePath = m_pPackAddonFileSelectionWidget->imagePath();
- QString szLocalePath = m_pPackAddonFileSelectionWidget->localePath();
- 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('\\',"/");
- szLocalePath.replace('\\',"/");
- szHelpPath.replace('\\',"/");
- szSoundPath.replace('\\',"/");
- szInstallPath.replace('\\',"/");
-*/
- szPackagePath.replace('\\',"/");
+ // We need mandatory UNIX like path separators
+ m_szDirPath.replace("\\","/");
+ m_szSavePath.replace("\\","/");
QString szTmp = QDateTime::currentDateTime().toString();
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("Name",m_szName);
+ pw.addInfoField("Version",m_szVersion);
+ pw.addInfoField("Author",m_szAuthor);
+ pw.addInfoField("Description",m_szDescription);
pw.addInfoField("Date",szTmp);
pw.addInfoField("Application","KVIrc " KVI_VERSION "." KVI_SOURCES_DATE);
// Add source dir
- if(!pw.addDirectory(szSourcePath,"src/"))
+ if(!pw.addDirectory(m_szDirPath + "/src","src/"))
{
szTmp = __tr2qs_ctx("Packaging failed","addon");
szTmp += ": ";
@@ -386,7 +344,7 @@ return false;
}
// Add config dir
- if(!pw.addDirectory(szConfigPath,"config/scripts/"))
+ if(!pw.addDirectory(m_szDirPath + "/config","config/scripts/" + m_szName))
{
szTmp = __tr2qs_ctx("Packaging failed","addon");
szTmp += ": ";
@@ -396,7 +354,17 @@ return false;
}
// Add image dir
- if(!pw.addDirectory(szImagePath,"pics/"))
+ if(!pw.addDirectory(m_szDirPath + "/pics","pics/" + m_szName))
+ {
+ 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);
+ return false;
+ }
+
+ // Add sound dir
+ if(!pw.addDirectory(m_szDirPath + "/sound","sound/" + m_szName))
{
szTmp = __tr2qs_ctx("Packaging failed","addon");
szTmp += ": ";
@@ -406,7 +374,7 @@ return false;
}
// Add localization dir
- if(!pw.addDirectory(szLocalePath,"locale/"))
+ if(!pw.addDirectory(m_szDirPath + "/locale","locale/" + m_szName))
{
szTmp = __tr2qs_ctx("Packaging failed","addon");
szTmp += ": ";
@@ -414,9 +382,9 @@ return false;
QMessageBox::critical(this,__tr2qs_ctx("Export Addon - KVIrc","addon"),szTmp,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
return false;
}
-
+#if 0
// Add help dir
- if(!pw.addDirectory(szImagePath,"help/en/"))
+ if(!pw.addDirectory(m_szDirPath + "/help","help/"))
{
szTmp = __tr2qs_ctx("Packaging failed","addon");
szTmp += ": ";
@@ -424,9 +392,9 @@ return false;
QMessageBox::critical(this,__tr2qs_ctx("Export Addon - KVIrc","addon"),szTmp,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
return false;
}
-
- // Add sound dir
- if(!pw.addDirectory(szImagePath,"audio/"))
+#endif
+ // Add initialization script
+ if(!pw.addFile(m_szDirPath + "/init.kvs","init.kvs"))
{
szTmp = __tr2qs_ctx("Packaging failed","addon");
szTmp += ": ";
@@ -434,9 +402,9 @@ return false;
QMessageBox::critical(this,__tr2qs_ctx("Export Addon - KVIrc","addon"),szTmp,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
return false;
}
-
+
// Add installer script
- if(!pw.addFile(szInstallPath,"install.kvs"))
+ if(!pw.addFile(m_szDirPath + "/install.kvs","install.kvs"))
{
szTmp = __tr2qs_ctx("Packaging failed","addon");
szTmp += ": ";
@@ -446,18 +414,17 @@ return false;
}
// Create the addon package
- if(szPackagePath.isEmpty())
+ if(m_szSavePath.isEmpty())
{
- szPackagePath = QDir::homePath();
- KviQString::ensureLastCharIs(szPackagePath,QChar(KVI_PATH_SEPARATOR_CHAR));
- szPackagePath += szPackageName;
- szPackagePath += "-";
- szPackagePath += szPackageVersion;
- szPackagePath += KVI_FILEEXTENSION_ADDONPACKAGE;
- qDebug("Addon name used: %s",szPackagePath.toUtf8().data());
+ m_szSavePath = QDir::homePath();
+ KviQString::ensureLastCharIs(m_szSavePath,QChar(KVI_PATH_SEPARATOR_CHAR));
+ m_szSavePath += m_szName;
+ m_szSavePath += "-";
+ m_szSavePath += m_szVersion;
+ m_szSavePath += KVI_FILEEXTENSION_ADDONPACKAGE;
}
- if(!pw.pack(szPackagePath))
+ if(!pw.pack(m_szSavePath))
{
szTmp = __tr2qs_ctx("Packaging failed","addon");
szTmp += ": ";
@@ -466,16 +433,20 @@ return false;
return false;
}
- QMessageBox::information(this,__tr2qs_ctx("Export Addon - KVIrc","addon"),__tr2qs("Package saved successfully in ") + szPackagePath,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
+ // Debug purpose
+ KviPackageReader pr;
+ pr.unpack("/home/hellvis69/Test-2.0.3.kva","/home/hellvis69/unpacked_test_kva");
+
+ QMessageBox::information(this,__tr2qs_ctx("Export Addon - KVIrc","addon"),__tr2qs("Package saved successfully in ") + m_szSavePath,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
return true;
-#endif
}
KviPackAddonInfoPackageWidget::KviPackAddonInfoPackageWidget(KviPackAddonDialog * pParent)
: QWizardPage(pParent)
{
+ setObjectName("addon_package_info_page");
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"));
@@ -511,13 +482,11 @@ KviPackAddonInfoPackageWidget::KviPackAddonInfoPackageWidget(KviPackAddonDialog
pLabel = new QLabel(this);
pLabel->setText(__tr2qs_ctx("Package &Description:","addon"));
pLayout->addWidget(pLabel,3,0);
-
- m_pPackageDescriptionEdit = new QTextEdit(this);
- m_pPackageDescriptionEdit->setBackgroundRole(QPalette::Window);
- m_pPackageDescriptionEdit->setText(__tr2qs_ctx("Put a package description here...","addon"));
+
+ m_pPackageDescriptionEdit = new QLineEdit(this);
+ m_pPackageDescriptionEdit->setText(__tr2qs_ctx("Description must be short","addon"));
pLabel->setBuddy(m_pPackageDescriptionEdit);
- pLayout->addWidget(m_pPackageDescriptionEdit,3,1,1,2);
- pLayout->setRowStretch(1,1);
+ pLayout->addWidget(m_pPackageDescriptionEdit,3,1);
pLabel = new QLabel(this);
pLabel->setText(__tr2qs_ctx("Minimum &KVIrc Version:","addon"));
@@ -532,9 +501,7 @@ KviPackAddonInfoPackageWidget::KviPackAddonInfoPackageWidget(KviPackAddonDialog
registerField("packageAuthor*",m_pPackageAuthorEdit);
registerField("packageName*",m_pPackageNameEdit);
registerField("packageVersion*",m_pPackageVersionEdit);
- // FIXME: if the description field is changed before the others, it work, otherwise not
- //registerField("packageDescription*",m_pPackageDescriptionEdit);
- registerField("packageDescription",m_pPackageDescriptionEdit);
+ registerField("packageDescription*",m_pPackageDescriptionEdit);
registerField("packageMinVersion",m_pPackageMinVersionEdit);
}
@@ -546,6 +513,7 @@ KviPackAddonInfoPackageWidget::~KviPackAddonInfoPackageWidget()
KviPackAddonFileSelectionWidget::KviPackAddonFileSelectionWidget(KviPackAddonDialog * pParent)
: QWizardPage(pParent)
{
+ setObjectName("addon_package_file_page");
setTitle(__tr2qs_ctx("Package Files","addon"));
setSubTitle(__tr2qs_ctx("Here you need to select the directory where the addon files are.","addon"));
@@ -560,11 +528,8 @@ KviPackAddonFileSelectionWidget::KviPackAddonFileSelectionWidget(KviPackAddonDia
pLayout->addWidget(m_pPackageIconEdit);
// Store data in the fields
- // FIXME they seem to ignore KviFile/DirSelector properties
- //registerField("packageDirPath*",m_pPackageIconEdit);
- //registerField("packageIcon*",m_pPackageIconEdit);
- registerField("packageDirPath",m_pDirPathSelector);
- registerField("packageIcon",m_pPackageIconEdit);
+ registerField("packageDirPath*",m_pDirPathSelector);
+ registerField("packageIcon*",m_pPackageIconEdit);
}
KviPackAddonFileSelectionWidget::~KviPackAddonFileSelectionWidget()
@@ -575,19 +540,20 @@ KviPackAddonFileSelectionWidget::~KviPackAddonFileSelectionWidget()
KviPackAddonSaveSelectionWidget::KviPackAddonSaveSelectionWidget(KviPackAddonDialog * pParent)
: QWizardPage(pParent)
{
+ setObjectName("addon_package_save_page");
setTitle(__tr2qs_ctx("Save Package","addon"));
setSubTitle(__tr2qs_ctx("Here you need to provide the path where to save the addon package","addon"));
QVBoxLayout * pLayout = new QVBoxLayout(this);
+ QString szDummy;
+
// Select save path
- m_pSavePathSelector = new KviFileSelector(this,__tr2qs_ctx("Select save path:","addon"),&m_szSavePath,true,KviFileSelector::ChooseSaveFileName,KVI_FILTER_ADDON);
+ m_pSavePathSelector = new KviFileSelector(this,__tr2qs_ctx("Select save path:","addon"),&szDummy,true,KviFileSelector::ChooseSaveFileName,KVI_FILTER_ADDON);
pLayout->addWidget(m_pSavePathSelector);
// Store data in the fields
- // FIXME they seem to ignore KviFile/DirSelector properties
- //registerField("packageSavePath*",m_pSavePathSelector);
- registerField("packageSavePath",m_pSavePathSelector);
+ registerField("packageSavePath*",m_pSavePathSelector);
}
KviPackAddonSaveSelectionWidget::~KviPackAddonSaveSelectionWidget()
@@ -601,33 +567,33 @@ void KviPackAddonSaveSelectionWidget::initializePage()
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;
+ QString szSavePath = QDir::homePath();
+ KviQString::ensureLastCharIs(szSavePath,QChar(KVI_PATH_SEPARATOR_CHAR));
+ szSavePath += szName;
+ szSavePath += "-";
+ szSavePath += szVersion;
+ szSavePath += KVI_FILEEXTENSION_ADDONPACKAGE;
+ m_pSavePathSelector->setTmpFile(szSavePath);
}
-KviPackAddonSummaryWidget::KviPackAddonSummaryWidget(KviPackAddonDialog * pParent)
+KviPackAddonSummaryInfoWidget::KviPackAddonSummaryInfoWidget(KviPackAddonDialog * pParent)
: QWizardPage(pParent)
{
+ setObjectName("addon_package_summary_info_page");
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"));
-
- m_pParent = pParent;
+ setSubTitle(__tr2qs_ctx("Here there are the informations you provided. If these informations are correct, hit the \"Finish\" button to complete the packaging operations.","addon"));
QVBoxLayout * pLayout = new QVBoxLayout(this);
m_pLabelInfo = new QLabel(this);
pLayout->addWidget(m_pLabelInfo);
}
-KviPackAddonSummaryWidget::~KviPackAddonSummaryWidget()
+KviPackAddonSummaryInfoWidget::~KviPackAddonSummaryInfoWidget()
{
}
-void KviPackAddonSummaryWidget::initializePage()
+void KviPackAddonSummaryInfoWidget::initializePage()
{
// Get data from registered fields
QString szAuthor = field("packageAuthor").toString();
@@ -675,3 +641,65 @@ void KviPackAddonSummaryWidget::initializePage()
m_pLabelInfo->setText(szText);
}
+
+
+KviPackAddonSummaryFilesWidget::KviPackAddonSummaryFilesWidget(KviPackAddonDialog * pParent)
+: QDialog(pParent)
+{
+ setObjectName("addon_package_summary_file_dialog");
+ setWindowTitle(__tr2qs_ctx("File Summary","addon"));
+ setWindowModality(Qt::WindowModal);
+ setModal(true);
+
+ QVBoxLayout * pLayout = new QVBoxLayout(this);
+
+ QLabel * pLabel = new QLabel(this);
+ pLabel->setText(__tr2qs_ctx("Here there are the files I found in the directories you provided.\nIf these and the informations showed in the previous page are correct, hit the \"Finish\" button to complete\nthe packaging operations.","addon"));
+ pLayout->addWidget(pLabel);
+
+ m_pFiles = new QTextEdit(this);
+ m_pFiles->setReadOnly(true);
+ pLayout->addWidget(m_pFiles);
+
+ KviTalHBox * pBox = new KviTalHBox(this);
+ QPushButton * pCancel = new QPushButton(pBox);
+ pCancel->setText(__tr2qs_ctx("Cancel","addon"));
+ connect(pCancel,SIGNAL(clicked()),this,SLOT(reject()));
+
+ QPushButton * pAccept = new QPushButton(pBox);
+ pAccept->setText(__tr2qs_ctx("Finish","addon"));
+ connect(pAccept,SIGNAL(clicked()),this,SLOT(accept()));
+ pLayout->addWidget(pBox);
+}
+
+KviPackAddonSummaryFilesWidget::~KviPackAddonSummaryFilesWidget()
+{
+}
+
+void KviPackAddonSummaryFilesWidget::accept()
+{
+ QDialog::accept();
+}
+
+void KviPackAddonSummaryFilesWidget::reject()
+{
+ QDialog::reject();
+}
+
+void KviPackAddonSummaryFilesWidget::showEvent(QShowEvent *)
+{
+ QStringList list;
+
+ QDirIterator it(m_szPath,QDir::AllEntries | QDir::NoDotAndDotDot,QDirIterator::Subdirectories);
+
+ // Iterate through the addon dir and its subdirs
+ while(it.hasNext())
+ {
+ list.append(it.next());
+ }
+
+ // QDirIterator does not support sorting, so do it manually
+ list.sort();
+
+ m_pFiles->setPlainText(list.join("\n"));
+}
diff --git a/src/modules/addon/packaddondialog.h b/src/modules/addon/packaddondialog.h
index c4943e757..fea728d0f 100644
--- a/src/modules/addon/packaddondialog.h
+++ b/src/modules/addon/packaddondialog.h
@@ -47,7 +47,8 @@ class QLabel;
class KviPackAddonInfoPackageWidget;
class KviPackAddonFileSelectionWidget;
class KviPackAddonSaveSelectionWidget;
-class KviPackAddonSummaryWidget;
+class KviPackAddonSummaryInfoWidget;
+class KviPackAddonSummaryFilesWidget;
/**
* \class KviPackAddonDialog
@@ -68,11 +69,20 @@ public:
* \brief Destroys the wizard object
*/
~KviPackAddonDialog();
-public:
+protected:
KviPackAddonInfoPackageWidget * m_pPackAddonInfoPackageWidget;
KviPackAddonFileSelectionWidget * m_pPackAddonFileSelectionWidget;
KviPackAddonSaveSelectionWidget * m_pPackAddonSaveSelectionWidget;
- KviPackAddonSummaryWidget * m_pPackAddonSummaryWidget;
+ KviPackAddonSummaryInfoWidget * m_pPackAddonSummaryInfoWidget;
+ KviPackAddonSummaryFilesWidget * m_pPackAddonSummaryFilesWidget;
+ QString m_szAuthor;
+ QString m_szName;
+ QString m_szVersion;
+ QString m_szDescription;
+ QString m_szMinVersion;
+ QString m_szIcon;
+ QString m_szDirPath;
+ QString m_szSavePath;
protected:
/**
* \brief Runs the packAddon() function and closes the wizard
@@ -81,26 +91,24 @@ protected:
virtual void accept();
/**
- * \brief Create the addon package
+ * \brief Creates 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);
+ bool checkDirTree(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);
+ bool createInstaller(QString * pszError);
};
/**
@@ -123,11 +131,11 @@ public:
*/
~KviPackAddonInfoPackageWidget();
protected:
- QLineEdit * m_pPackageAuthorEdit;
- QLineEdit * m_pPackageNameEdit;
- QLineEdit * m_pPackageVersionEdit;
- QTextEdit * m_pPackageDescriptionEdit;
- QLineEdit * m_pPackageMinVersionEdit;
+ QLineEdit * m_pPackageAuthorEdit;
+ QLineEdit * m_pPackageNameEdit;
+ QLineEdit * m_pPackageVersionEdit;
+ QLineEdit * m_pPackageDescriptionEdit;
+ QLineEdit * m_pPackageMinVersionEdit;
};
/**
@@ -157,7 +165,7 @@ protected:
};
/**
-* \class KviPackAddonCreateInfoPackageWidget
+* \class KviPackAddonSaveSelectionWidget
* \brief Wizard page for saving package
*/
class KviPackAddonSaveSelectionWidget : public QWizardPage
@@ -177,7 +185,6 @@ public:
~KviPackAddonSaveSelectionWidget();
protected:
KviFileSelector * m_pSavePathSelector;
- QString m_szSavePath;
protected:
/**
* \brief Perform initial tasks before showing the widget
@@ -187,31 +194,30 @@ protected:
};
/**
-* \class KviPackAddonSummaryWidget
+* \class KviPackAddonSummaryInfoWidget
* \brief Wizard page for showing informations inserted
*/
-class KviPackAddonSummaryWidget : public QWizardPage
+class KviPackAddonSummaryInfoWidget : public QWizardPage
{
Q_OBJECT
public:
/**
- * \brief Create the wizard save page object
+ * \brief Create the wizard summary info page object
* \param pParent The parent widget
- * \return KviPackAddonSaveSelectionWidget
+ * \return KviPackAddonSummaryInfoWidget
*/
- KviPackAddonSummaryWidget(KviPackAddonDialog * pParent);
+ KviPackAddonSummaryInfoWidget(KviPackAddonDialog * pParent);
/**
- * \brief Destroys the wizard save page object
+ * \brief Destroys the wizard summary info page object
*/
- ~KviPackAddonSummaryWidget();
+ ~KviPackAddonSummaryInfoWidget();
protected:
- KviPackAddonDialog * m_pParent;
- QLabel * m_pLabelInfo;
- QLabel * m_pLabelAuthor;
- QLabel * m_pPackageName;
- QLabel * m_pPackageVersion;
- QLabel * m_pPackageDescription;
+ QLabel * m_pLabelInfo;
+ QLabel * m_pLabelAuthor;
+ QLabel * m_pPackageName;
+ QLabel * m_pPackageVersion;
+ QLabel * m_pPackageDescription;
protected:
/**
* \brief Perform initial tasks before showing the widget
@@ -220,4 +226,22 @@ protected:
virtual void initializePage();
};
+
+class KviPackAddonSummaryFilesWidget : public QDialog
+{
+ Q_OBJECT
+public:
+ KviPackAddonSummaryFilesWidget(KviPackAddonDialog * pParent);
+ ~KviPackAddonSummaryFilesWidget();
+protected:
+ QTextEdit * m_pFiles;
+ QString m_szPath;
+public:
+ void setPath(QString & szPath){ m_szPath = szPath; };
+protected:
+ virtual void showEvent(QShowEvent *);
+ virtual void accept();
+ virtual void reject();
+};
+
#endif //!_PACKADDONDIALOG_H_