From c601b5a27f74b16158adafe429faefbe573e64a2 Mon Sep 17 00:00:00 2001 From: Szymon Tomasz Stefanek Date: Sat, 1 Jan 2011 20:19:56 +0000 Subject: The big rename for modules. Still some details remaining. git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@5284 17fca916-40b9-46aa-a4ea-0a15b648b75c --- src/modules/addon/AddonFunctions.cpp | 272 ++++++++++++++ src/modules/addon/AddonFunctions.h | 42 +++ src/modules/addon/CMakeLists.txt | 6 +- src/modules/addon/PackAddonDialog.cpp | 664 +++++++++++++++++++++++++++++++++ src/modules/addon/PackAddonDialog.h | 252 +++++++++++++ src/modules/addon/addonfunctions.cpp | 272 -------------- src/modules/addon/addonfunctions.h | 42 --- src/modules/addon/libkviaddon.cpp | 10 +- src/modules/addon/managementdialog.cpp | 62 +-- src/modules/addon/managementdialog.h | 16 +- src/modules/addon/packaddondialog.cpp | 664 --------------------------------- src/modules/addon/packaddondialog.h | 252 ------------- 12 files changed, 1277 insertions(+), 1277 deletions(-) create mode 100644 src/modules/addon/AddonFunctions.cpp create mode 100644 src/modules/addon/AddonFunctions.h create mode 100644 src/modules/addon/PackAddonDialog.cpp create mode 100644 src/modules/addon/PackAddonDialog.h delete mode 100644 src/modules/addon/addonfunctions.cpp delete mode 100644 src/modules/addon/addonfunctions.h delete mode 100644 src/modules/addon/packaddondialog.cpp delete mode 100644 src/modules/addon/packaddondialog.h (limited to 'src/modules/addon') diff --git a/src/modules/addon/AddonFunctions.cpp b/src/modules/addon/AddonFunctions.cpp new file mode 100644 index 000000000..83641d90e --- /dev/null +++ b/src/modules/addon/AddonFunctions.cpp @@ -0,0 +1,272 @@ +//============================================================================= +// +// File : AddonFunctions.cpp +// Creation date : Fri 02 May 2008 17:36:07 by Elvio Basello +// +// This file is part of the KVIrc IRC Client distribution +// Copyright (C) 2008 Elvio Basello +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "AddonFunctions.h" + +#include "KviPackageReader.h" +#include "KviLocale.h" +#include "KviMessageBox.h" +#include "KviApplication.h" +#include "KviHtmlDialog.h" +#include "KviIconManager.h" +#include "KviFileUtils.h" +#include "KviMiscUtils.h" +#include "kvi_sourcesdate.h" +#include "KviMainWindow.h" +#include "KviKvsScript.h" + +#include + +#include + +namespace AddonFunctions +{ + bool notAValidAddonPackage(QString &szError) + { + szError = __tr2qs_ctx("The selected file does not seem to be a valid KVIrc addon package","addon"); + return false; + } + + bool installAddonPackage(const QString &szAddonPackageFileName,QString &szError,QWidget * pDialogParent) + { + KviPointerHashTable * pInfoFields; + QString * pValue; + QString szErr; + QPixmap pix; + QByteArray * pByteArray; + bool bInstall; + KviHtmlDialogData hd; + + const char * check_fields[] = { "Name", "Version", "Author", "Description", "Date", "Application" }; + + // check if it is a valid addon file + KviPackageReader r; + if(!r.readHeader(szAddonPackageFileName)) + { + szErr = r.lastError(); + KviQString::sprintf(szError,__tr2qs_ctx("The selected file does not seem to be a valid KVIrc package: %Q","addon"),&szErr); + return false; + } + + pInfoFields = r.stringInfoFields(); + + pValue = pInfoFields->find("PackageType"); + + if(!pValue) + return notAValidAddonPackage(szError); + + if(!KviQString::equalCI(*pValue,"AddonPack")) + return notAValidAddonPackage(szError); + + pValue = pInfoFields->find("AddonPackVersion"); + + if(!pValue) + return notAValidAddonPackage(szError); + + // make sure the default fields exist + for(int i=0;i<6;i++) + { + pValue = pInfoFields->find(check_fields[i]); + if(!pValue) + return notAValidAddonPackage(szError); + } + + // ok.. it should be really valid at this point + // load its picture + pByteArray = r.binaryInfoFields()->find("Image"); + if(pByteArray) + pix.loadFromData(*pByteArray,0,0); + + if(pix.isNull()) + { + // load the default icon + pix = *(g_pIconManager->getBigIcon(KVI_BIGICON_ADDONS)); + } + + QString szPackageName; + QString szPackageVersion; + QString szPackageAuthor; + QString szPackageDescription; + QString szPackageDate; + QString szAddonPackVersion; + QString szPackageApplication; + + QString szAuthor = __tr2qs_ctx("Author","addon"); + QString szCreatedAt = __tr2qs_ctx("Created at","addon"); + QString szCreatedWith = __tr2qs_ctx("Created with","addon"); + + r.getStringInfoField("Name",szPackageName); + r.getStringInfoField("Version",szPackageVersion); + r.getStringInfoField("Author",szPackageAuthor); + r.getStringInfoField("Description",szPackageDescription); + r.getStringInfoField("Application",szPackageApplication); + r.getStringInfoField("Date",szPackageDate); + r.getStringInfoField("AddonPackVersion",szAddonPackVersion); + + QString szWarnings; + QString szTmp; + + bool bValid = true; + + if(szPackageName.isEmpty() || szPackageVersion.isEmpty() || szAddonPackVersion.isEmpty()) + bValid = false; + + if(KviMiscUtils::compareVersions(szAddonPackVersion,KVI_CURRENT_ADDONS_ENGINE_VERSION) < 0) + bValid = false; + + + if(!bValid) + { + szWarnings += "

"; + szWarnings += __tr2qs_ctx("Warning: The addon might be incompatible with this version of KVIrc","addon"); + szWarnings += "

"; + } + + KviQString::sprintf(hd.szHtmlText, + "" \ + "" \ + "

" \ + "

%Q %Q

" \ + "

" \ + "

" \ + "" \ + "

" \ + "

" \ + "%Q" \ + "

" \ + "

" \ + "%Q: %Q
" \ + "%Q: %Q
" \ + "

" \ + "

" \ + "" \ + "%Q: %Q
" \ + "
" \ + "

" \ + "%Q" \ + "
" \ + "" \ + "", + &szPackageName, + &szPackageVersion, + &szPackageDescription, + &szAuthor, + &szPackageAuthor, + &szCreatedAt, + &szPackageDate, + &szCreatedWith, + &szPackageApplication, + &szWarnings + ); + + hd.addImageResource("addon_dialog_pack_image",pix); + hd.addHtmlResource("addon_dialog_main",hd.szHtmlText); + + QString beginCenter = "
"; + QString endCenter = "
"; + + hd.szCaption = __tr2qs_ctx("Install Addon Pack - KVIrc","addon"); + hd.szUpperLabelText = beginCenter + __tr2qs_ctx("You're about to install the following addon package","addon") + endCenter; + hd.szLowerLabelText = beginCenter + __tr2qs_ctx("Do you want to proceed with the installation ?","addon") + endCenter; + hd.szButton1Text = __tr2qs_ctx("Do Not Install","addon"); + hd.szButton2Text = __tr2qs_ctx("Yes, Proceed","addon"); + hd.iDefaultButton = 2; + hd.iCancelButton = 1; + hd.pixIcon = *(g_pIconManager->getSmallIcon(KVI_SMALLICON_ADDONS)); + hd.iMinimumWidth = 350; + hd.iMinimumHeight = 420; + hd.iFlags = KviHtmlDialogData::ForceMinimumSize; + + bInstall = KviHtmlDialog::display(pDialogParent,&hd) == 2; + + if(!bInstall) + return true; + + // Create a random extraction dir + QString szTmpPath, szUnpackPath; + QString szRandomDir = createRandomDir(); + + g_pApp->getLocalKvircDirectory(szTmpPath,KviApplication::Tmp); + KviQString::ensureLastCharIs(szTmpPath,QChar(KVI_PATH_SEPARATOR_CHAR)); + szUnpackPath = szTmpPath + szRandomDir; + QDir szTmpDir(szUnpackPath); + + // Check for dir existence + while(szTmpDir.exists()) + { + szRandomDir = createRandomDir(); + szUnpackPath = szTmpPath + szRandomDir; + szTmpDir = QDir(szUnpackPath); + } + + // Unpack addon package into the random tmp dir + if(!r.unpack(szAddonPackageFileName,szUnpackPath)) + { + szErr = r.lastError(); + KviQString::sprintf(szError,__tr2qs_ctx("Failed to unpack the selected file: %Q","addon"),&szErr); + return false; + } + + // Now we have all stuff in ~/.config/KVIrc/tmp/$rand + KviQString::escapeKvs(&szUnpackPath, KviQString::EscapeSpace); + if(!KviKvsScript::run(QString::fromAscii("parse %1/install.kvs").arg(szUnpackPath), g_pActiveWindow)) + { + // Parsing the script failed + // However, the user should already be notified via normal script output. + } + + if(!KviFileUtils::deleteDir(szUnpackPath)) + { + // FIXME: Just warn the user and assume success? + szErr = __tr2qs_ctx("One or more files can't be deleted","addon"); + KviQString::sprintf(szError,__tr2qs_ctx("Failed to unpack the selected file: %Q","addon"),&szErr); + return false; + } + + return true; + } + + QString createRandomDir() + { + QString szDirName; + char chars[] = { + 'A','B','C','D','E','F','G','H', + 'I','J','K','L','M','N','O','P', + 'Q','R','S','T','U','V','W','X', + 'Y','Z','a','b','c','d','e','f', + 'g','h','i','j','k','l','m','n', + 'o','p','q','r','s','t','u','v', + 'w','x','y','z','-','_','.' + }; + + // Generate dir name + for(int i=0;i<10;i++) + { + int n = rand() % sizeof(chars); + szDirName.append(chars[n]); + } + + return szDirName; + } +} diff --git a/src/modules/addon/AddonFunctions.h b/src/modules/addon/AddonFunctions.h new file mode 100644 index 000000000..adcc455c2 --- /dev/null +++ b/src/modules/addon/AddonFunctions.h @@ -0,0 +1,42 @@ +#ifndef _ADDONFUNCTIONS_H_ +#define _ADDONFUNCTIONS_H_ +//============================================================================= +// +// File : AddonFunctions.h +// Creation date : Fri 02 May 2008 17:36:07 by Elvio Basello +// +// This file is part of the KVIrc IRC Client distribution +// Copyright (C) 2008 Elvio Basello +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" +#include "KviQString.h" + +#include +#include + +#define KVI_CURRENT_ADDONS_ENGINE_VERSION "2.0.0" + +namespace AddonFunctions +{ + bool notAValidAddonPackage(QString & szError); + bool installAddonPackage(const QString & szAddonPackageFileName, QString & szError, QWidget * pDialogParent = 0); + QString createRandomDir(); +} + +#endif //!_ADDONFUNCTIONS_H_ diff --git a/src/modules/addon/CMakeLists.txt b/src/modules/addon/CMakeLists.txt index f52881251..53ee2e847 100644 --- a/src/modules/addon/CMakeLists.txt +++ b/src/modules/addon/CMakeLists.txt @@ -2,14 +2,14 @@ SET(kviaddon_MOC_HDRS managementdialog.h - packaddondialog.h + PackAddonDialog.h ) SET(kviaddon_SRCS libkviaddon.cpp managementdialog.cpp - packaddondialog.cpp - addonfunctions.cpp + PackAddonDialog.cpp + AddonFunctions.cpp ) # After this call, files will be moc'ed to moc_kvi_*.cpp diff --git a/src/modules/addon/PackAddonDialog.cpp b/src/modules/addon/PackAddonDialog.cpp new file mode 100644 index 000000000..0e36a1654 --- /dev/null +++ b/src/modules/addon/PackAddonDialog.cpp @@ -0,0 +1,664 @@ +//============================================================================ +// +// File : PackAddonDialog.cpp +// 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-2009 Elvio Basello +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================ + +#include "PackAddonDialog.h" +#include "AddonFunctions.h" + +#include "KviLocale.h" +#include "KviFileUtils.h" +#include "KviApplication.h" +#include "KviIconManager.h" +#include "KviPackageWriter.h" +#include "kvi_fileextensions.h" +#include "kvi_sourcesdate.h" +#include "KviOptions.h" + +#include +#include +#include +#include +#include +#include +#include +#include + + +PackAddonDialog::PackAddonDialog(QWidget * pParent) +: QWizard(pParent) +{ + setMinimumSize(400,350); + setObjectName("addon_package_wizard"); + setOption(QWizard::IndependentPages,true); + setWindowTitle(__tr2qs_ctx("Create Addon Package - KVIrc","addon")); + + QPixmap * pSide = g_pIconManager->getBigIcon("kvi_setup_label.png"); + QPixmap * pLogo = g_pIconManager->getBigIcon("kvi_bigicon_addons.png"); + +#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) + #if (_WIN32_WINNT >= 0x0600) + // We are on a Windows Vista / Seven + // It will fallback to XP if alpha compositing is disabled + setWizardStyle(QWizard::AeroStyle); + #else + // Windows XP + setWizardStyle(QWizard::ModernStyle); + setPixmap(QWizard::WatermarkPixmap,*pSide); + setPixmap(QWizard::LogoPixmap,*pLogo); + #endif +#elif defined(COMPILE_ON_MAC) + setWizardStyle(QWizard::MacStyle); + setPixmap(QWizard::BackgroundPixmap,*pSide); +#else + // All other systems + setWizardStyle(QWizard::ClassicStyle); + setPixmap(QWizard::WatermarkPixmap,*pSide); + setPixmap(QWizard::LogoPixmap,*pLogo); +#endif + + // Add a default property for file selectors + setDefaultProperty("KviFileSelector","tmpFile",SIGNAL(selectionChanged(const QString &))); + + // Welcome page + QWizardPage * pPage = new QWizardPage(this); + QVBoxLayout * pLayout = new QVBoxLayout(pPage); + + pPage->setLayout(pLayout); + pPage->setTitle(__tr2qs_ctx("Welcome","addon")); + + QLabel * pLabel = new QLabel(pPage); + pLabel->setWordWrap(true); + 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); + pLabel->setWordWrap(true); + QString szText; + szText += __tr2qs_ctx("You will be asked to provide some information 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); + + pPage->setMinimumWidth(350); + + addPage(pPage); + + // Packager information + m_pPackAddonInfoPackageWidget = new PackAddonInfoPackageWidget(this); + addPage(m_pPackAddonInfoPackageWidget); + + // File selection + m_pPackAddonFileSelectionWidget = new PackAddonFileSelectionWidget(this); + addPage(m_pPackAddonFileSelectionWidget); + + // Save selection + m_pPackAddonSaveSelectionWidget = new PackAddonSaveSelectionWidget(this); + addPage(m_pPackAddonSaveSelectionWidget); + + // Summary info + m_pPackAddonSummaryInfoWidget = new PackAddonSummaryInfoWidget(this); + addPage(m_pPackAddonSummaryInfoWidget); + +} + +PackAddonDialog::~PackAddonDialog() +{ +} + +void PackAddonDialog::accept() +{ + if(!packAddon()) + return; + QWizard::accept(); +} + +bool PackAddonDialog::checkDirTree(QString * pszError, QString * pszWarning) +{ + if(pszError) *pszError = ""; + if(pszWarning) *pszWarning = ""; + + QDir addon(m_szDirPath); + if(!addon.exists()) + { + *pszError = __tr2qs_ctx("The selected directory does not exist.","addon"); + return false; + } + + QFileInfo init(m_szDirPath + "/install.kvs"); + if(!init.exists()) + { + *pszError = __tr2qs_ctx("The initialization script (install.kvs) does not exist.","addon"); + return false; + } + + return true; +} + +#if 0 +bool PackAddonDialog::createInstaller(QString * pszError) +{ + if(pszError) + *pszError = ""; + + // 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 %2\n# Written by %3\n# %4\n\n").arg(m_szName, m_szVersion, m_szAuthor, 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 + /* FIXME: re-add in KVIrc 4.1! + * implement a backend with full automatic cleaning for aliases, classes, popups, + * actions, ... via snapshot/diff of kvirc state before/after installing a package + + szTmp += QString("addon.register(\"%1\",\"%2\",\"%1\",\"%3\",\"%4\",\"%5\")\n").arg(m_szName, m_szVersion, m_szDescription, m_szMinVersion, m_szIcon); + szTmp += "{\n"; + szTmp += "\t# This is our uninstall callback: it will be called by KVIrc when addon.uninstall is invoked\n"; + szTmp += QString("\t%1::uninstall::uninstall\n").arg(m_szName); + szTmp += QString("\t%1::uninstall::uninstallfiles\n").arg(m_szName); + szTmp += QString("\t%1::uninstall::uninstallaliases\n").arg(m_szName); + szTmp += "}\n\n"; + 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\"))\n\n"); + 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/\",\"*.html\",$file.localdir(\"help/\"))\n\n"); + + // install.kvs: generate uninstall alias + szTmp += "# Generate the uninstall alias\n"; + szTmp += QString("%installer->$generateUninstallAlias(\"%1::uninstallfiles\")\n\n") \ + .arg(m_szName); + + // kviinstall.kvs: kill the installer class + szTmp += "# Kill the installer helper\n"; + szTmp += "delete %installer\n\n"; + +#if 0 + // 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(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("\t%alias .= \"alias(%1::uninstall::uninstallfiles){};$lf\"\n") \ + .arg(m_szName); + szTmp += QString("\t%alias .= \"alias(%1::uninstall::uninstallaliases){};$lf\"\n") \ + .arg(m_szName); + szTmp += "%alias .= \"}\"\n"; + szTmp += "eval %alias\n\n"; +#endif + + // 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()); + + // 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::WriteOnly)) + { + *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"); + return false; + } + + return true; +} +#endif + + +bool PackAddonDialog::packAddon() +{ + // Get data from registered fields + 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(); + m_szDirPath = field("packageDirPath").toString(); + m_szSavePath = field("packageSavePath").toString(); + + // Check the addon tree + QString szError, szWarning; + + if(!checkDirTree(&szError,&szWarning)) + { + QMessageBox::critical(this, + __tr2qs_ctx("Addon Packaging Error","addon"), + szError,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton + ); + return false; + } + + if(szWarning != "") + { + QMessageBox::warning(this, + __tr2qs_ctx("Addon Packaging Warning","addon"), + szWarning,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton + ); + } + + // Raise the files summary dialog + m_pPackAddonSummaryFilesWidget = new PackAddonSummaryFilesWidget(this); + m_pPackAddonSummaryFilesWidget->setPath(m_szDirPath); + if(m_pPackAddonSummaryFilesWidget->exec() == QDialog::Rejected) + { + delete m_pPackAddonSummaryFilesWidget; + return false; + } + + + QString szTmp; + szTmp = QDateTime::currentDateTime().toString(); + + KviPackageWriter pw; + pw.addInfoField("PackageType","AddonPack"); + pw.addInfoField("AddonPackVersion",KVI_CURRENT_ADDONS_ENGINE_VERSION); + 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); + + QPixmap pix(m_szIcon); + if(!pix.isNull()) + { + QByteArray * pba = new QByteArray(); + QBuffer bufferz(pba,0); + + bufferz.open(QIODevice::WriteOnly); + pix.save(&bufferz,"PNG"); + bufferz.close(); + pw.addInfoField("Image",pba); + } + + QDir dir(m_szDirPath); + QFileInfoList ls = dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::Readable | QDir::NoSymLinks | QDir::NoDotAndDotDot); + + if(ls.isEmpty()) + { + szTmp = __tr2qs_ctx("Packaging failed","addon"); + szTmp += ": "; + szTmp += __tr2qs_ctx("The package file list is empty","addon"); + QMessageBox::critical(this,__tr2qs_ctx("Export Addon - KVIrc","addon"),szTmp,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); + return false; + } + + for(QFileInfoList::Iterator it = ls.begin();it != ls.end();++it) + { + const QFileInfo &inf = *it; + + if(inf.isDir()) + { + if(!pw.addDirectory(inf.absoluteFilePath(),QString("%1/").arg(inf.fileName()))) + { + QString 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; + } + + continue; + } + + // must be a file + if(!pw.addFile(inf.absoluteFilePath(),inf.fileName())) + { + 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; + } + } + + + // Create the addon package + if(m_szSavePath.isEmpty()) + { + 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(m_szSavePath)) + { + 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; + } + + + QMessageBox::information(this,__tr2qs_ctx("Export Addon - KVIrc","addon"),__tr2qs("Package saved successfully in ") + m_szSavePath,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); + + return true; +} + + +PackAddonInfoPackageWidget::PackAddonInfoPackageWidget(PackAddonDialog * pParent) +: QWizardPage(pParent) +{ + setObjectName("addon_package_info_page"); + setTitle(__tr2qs_ctx("Package Information","addon")); + setSubTitle(__tr2qs_ctx("Here you need to provide information about you (the packager) and a short description of the package you're creating.","addon")); + + QGridLayout * pLayout = new QGridLayout(this); + + QLabel * pLabel = new QLabel(this); + pLabel->setText(__tr2qs_ctx("Package &Author:","addon")); + pLayout->addWidget(pLabel,0,0); + + m_pPackageAuthorEdit = new QLineEdit(this); + m_pPackageAuthorEdit->setText(__tr2qs_ctx("Your name here","addon")); + pLabel->setBuddy(m_pPackageAuthorEdit); + pLayout->addWidget(m_pPackageAuthorEdit,0,1); + + pLabel = new QLabel(this); + pLabel->setText(__tr2qs_ctx("Package &Name:","addon")); + pLayout->addWidget(pLabel,1,0); + + m_pPackageNameEdit = new QLineEdit(this); + m_pPackageNameEdit->setText(__tr2qs_ctx("No spaces allowed, like MyAddon","addon")); + pLabel->setBuddy(m_pPackageNameEdit); + pLayout->addWidget(m_pPackageNameEdit,1,1); + + pLabel = new QLabel(this); + pLabel->setText(__tr2qs_ctx("Package &Version:","addon")); + pLayout->addWidget(pLabel,2,0); + + m_pPackageVersionEdit = new QLineEdit(this); + m_pPackageVersionEdit->setText(__tr2qs_ctx("Version in the form x.y[.z], like 1.0 or 2.0.3","addon")); + pLabel->setBuddy(m_pPackageVersionEdit); + pLayout->addWidget(m_pPackageVersionEdit,2,1); + + pLabel = new QLabel(this); + pLabel->setText(__tr2qs_ctx("Package &Description:","addon")); + pLayout->addWidget(pLabel,3,0); + + m_pPackageDescriptionEdit = new QLineEdit(this); + m_pPackageDescriptionEdit->setText(QString()); + pLabel->setBuddy(m_pPackageDescriptionEdit); + pLayout->addWidget(m_pPackageDescriptionEdit,3,1); + + pLabel = new QLabel(this); + pLabel->setText(__tr2qs_ctx("Minimum &KVIrc Version:","addon")); + pLayout->addWidget(pLabel,4,0); + + m_pPackageMinVersionEdit = new QLineEdit(this); + m_pPackageMinVersionEdit->setText(KVI_VERSION); + 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); + registerField("packageMinVersion",m_pPackageMinVersionEdit); +} + +PackAddonInfoPackageWidget::~PackAddonInfoPackageWidget() +{ +} + + +PackAddonFileSelectionWidget::PackAddonFileSelectionWidget(PackAddonDialog * 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")); + + QVBoxLayout * pLayout = new QVBoxLayout(this); + + // Select source directory + m_pDirPathSelector = new KviDirectorySelector(this,__tr2qs_ctx("Select the source directory:","addon"),&m_szDirPath,true,KviFileSelector::VerticalLayout); + pLayout->addWidget(m_pDirPathSelector); + + // Select addon icon + m_pPackageIconEdit = new KviFileSelector(this,__tr2qs_ctx("Select the icon file:","addon"),&m_szPackageIcon,true,KviFileSelector::VerticalLayout,KVI_FILTER_IMAGE); + pLayout->addWidget(m_pPackageIconEdit); + + // Store data in the fields + registerField("packageDirPath*",m_pDirPathSelector); + registerField("packageIcon*",m_pPackageIconEdit); +} + +PackAddonFileSelectionWidget::~PackAddonFileSelectionWidget() +{ +} + + +PackAddonSaveSelectionWidget::PackAddonSaveSelectionWidget(PackAddonDialog * 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); + + // Select save path + m_pSavePathSelector = new KviFileSelector( + this, + __tr2qs_ctx("Select save path:","addon"), + &m_szFilePath, + true, + KviFileSelector::ChooseSaveFileName | KviFileSelector::VerticalLayout, + KVI_FILTER_ADDON + ); + pLayout->addWidget(m_pSavePathSelector); + + // Store data in the fields + registerField("packageSavePath*",m_pSavePathSelector); +} + +PackAddonSaveSelectionWidget::~PackAddonSaveSelectionWidget() +{ +} + +void PackAddonSaveSelectionWidget::initializePage() +{ + // Get data from registered fields + QString szName = field("packageName").toString(); + QString szVersion = field("packageVersion").toString(); + + // Create addon name + 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); +} + + +PackAddonSummaryInfoWidget::PackAddonSummaryInfoWidget(PackAddonDialog * pParent) +: QWizardPage(pParent) +{ + setObjectName("addon_package_summary_info_page"); + setTitle(__tr2qs_ctx("Final Information","addon")); + setSubTitle(__tr2qs_ctx("Here there are the information you provided. If these information 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); +} + +PackAddonSummaryInfoWidget::~PackAddonSummaryInfoWidget() +{ +} + +void PackAddonSummaryInfoWidget::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); +} + + +PackAddonSummaryFilesWidget::PackAddonSummaryFilesWidget(PackAddonDialog * 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 information 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); +} + +PackAddonSummaryFilesWidget::~PackAddonSummaryFilesWidget() +{ +} + +void PackAddonSummaryFilesWidget::accept() +{ + QDialog::accept(); +} + +void PackAddonSummaryFilesWidget::reject() +{ + QDialog::reject(); +} + +void PackAddonSummaryFilesWidget::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()) + { + QString szStr = it.next(); + if(!szStr.contains("/.")) + list.append(szStr); + } + + // 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 new file mode 100644 index 000000000..5819a8186 --- /dev/null +++ b/src/modules/addon/PackAddonDialog.h @@ -0,0 +1,252 @@ +#ifndef _PACKADDONDIALOG_H_ +#define _PACKADDONDIALOG_H_ +//============================================================================= +// +// File : PackAddonDialog.h +// 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-2009 Elvio Basello +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +/** +* \file PackAddonDialog.h +* \author Elvio Basello +* \brief Addon package creator +* +* This set of classes allow users to create addon for KVIrc in a standard +* distributable *.kva packages. +*/ + +#include "kvi_settings.h" +#include "KviPointerList.h" +#include "KviSelectors.h" + +#include +#include + +class QTextEdit; +class QLineEdit; +class QLabel; + +class KviPackageWriter; + +class PackAddonInfoPackageWidget; +class PackAddonFileSelectionWidget; +class PackAddonSaveSelectionWidget; +class PackAddonSummaryInfoWidget; +class PackAddonSummaryFilesWidget; + +/** +* \class PackAddonDialog +* \brief Wizard for addon creation +*/ +class PackAddonDialog : public QWizard +{ + Q_OBJECT +public: + /** + * \brief Creates the wizard object + * \param pParent The parent widget + * \return PackAddonDialog + */ + PackAddonDialog(QWidget * pParent); + + /** + * \brief Destroys the wizard object + */ + ~PackAddonDialog(); +protected: + PackAddonInfoPackageWidget * m_pPackAddonInfoPackageWidget; + PackAddonFileSelectionWidget * m_pPackAddonFileSelectionWidget; + PackAddonSaveSelectionWidget * m_pPackAddonSaveSelectionWidget; + PackAddonSummaryInfoWidget * m_pPackAddonSummaryInfoWidget; + PackAddonSummaryFilesWidget * 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 + * \return void + */ + virtual void accept(); + + /** + * \brief Creates the addon package + * \return bool + */ + bool packAddon(); + + /** + * \brief Ensures the sources directory is complete + * \param pszError The buffer containing errors + * \param pszWarning The buffer containing warnings + * \return bool + */ + bool checkDirTree(QString * pszError, QString * pszWarning); + + /** + * \brief Creates the installer file + * \param pszError The buffer containing errors + * \return bool + */ + bool createInstaller(QString * pszError); +}; + +/** +* \class PackAddonInfoPackageWidget +* \brief Wizard page for addon information +*/ +class PackAddonInfoPackageWidget : public QWizardPage +{ + Q_OBJECT +public: + /** + * \brief Create the wizard package info page object + * \param pParent The parent widget + * \return PackAddonInfoPackageWidget + */ + PackAddonInfoPackageWidget(PackAddonDialog * pParent); + + /** + * \brief Destroys the wizard package info page object + */ + ~PackAddonInfoPackageWidget(); +protected: + QLineEdit * m_pPackageAuthorEdit; + QLineEdit * m_pPackageNameEdit; + QLineEdit * m_pPackageVersionEdit; + QLineEdit * m_pPackageDescriptionEdit; + QLineEdit * m_pPackageMinVersionEdit; +}; + +/** +* \class PackAddonFileSelectionWidget +* \brief Wizard page for directory source selection +*/ +class PackAddonFileSelectionWidget : public QWizardPage +{ + Q_OBJECT +public: + /** + * \brief Create the wizard package source dir object + * \param pParent The parent widget + * \return PackAddonFileSelectionWidget + */ + PackAddonFileSelectionWidget(PackAddonDialog * pParent); + + /** + * \brief Destroys the wizard package source dir object + */ + ~PackAddonFileSelectionWidget(); +protected: + KviDirectorySelector * m_pDirPathSelector; + KviFileSelector * m_pPackageIconEdit; + QString m_szDirPath; + QString m_szPackageIcon; +}; + +/** +* \class PackAddonSaveSelectionWidget +* \brief Wizard page for saving package +*/ +class PackAddonSaveSelectionWidget : public QWizardPage +{ + Q_OBJECT +public: + /** + * \brief Create the wizard save page object + * \param pParent The parent widget + * \return PackAddonSaveSelectionWidget + */ + PackAddonSaveSelectionWidget(PackAddonDialog * pParent); + + /** + * \brief Destroys the wizard save page object + */ + ~PackAddonSaveSelectionWidget(); +protected: + KviFileSelector * m_pSavePathSelector; + QString m_szFilePath; +protected: + /** + * \brief Perform initial tasks before showing the widget + * \return void + */ + virtual void initializePage(); +}; + +/** +* \class PackAddonSummaryInfoWidget +* \brief Wizard page for showing information inserted +*/ +class PackAddonSummaryInfoWidget : public QWizardPage +{ + Q_OBJECT +public: + /** + * \brief Create the wizard summary info page object + * \param pParent The parent widget + * \return PackAddonSummaryInfoWidget + */ + PackAddonSummaryInfoWidget(PackAddonDialog * pParent); + + /** + * \brief Destroys the wizard summary info page object + */ + ~PackAddonSummaryInfoWidget(); +protected: + QLabel * m_pLabelInfo; + QLabel * m_pLabelAuthor; + QLabel * m_pPackageName; + QLabel * m_pPackageVersion; + QLabel * m_pPackageDescription; +protected: + /** + * \brief Perform initial tasks before showing the widget + * \return void + */ + virtual void initializePage(); +}; + + +class PackAddonSummaryFilesWidget : public QDialog +{ + Q_OBJECT +public: + PackAddonSummaryFilesWidget(PackAddonDialog * pParent); + ~PackAddonSummaryFilesWidget(); +protected: + QTextEdit * m_pFiles; + QString m_szPath; +public: + void setPath(QString & szPath){ m_szPath = szPath; }; +protected: + virtual void showEvent(QShowEvent *); +protected slots: + virtual void accept(); + virtual void reject(); +}; + +#endif //!_PACKADDONDIALOG_H_ diff --git a/src/modules/addon/addonfunctions.cpp b/src/modules/addon/addonfunctions.cpp deleted file mode 100644 index 590935319..000000000 --- a/src/modules/addon/addonfunctions.cpp +++ /dev/null @@ -1,272 +0,0 @@ -//============================================================================= -// -// File : addonfunctions.cpp -// Creation date : Fri 02 May 2008 17:36:07 by Elvio Basello -// -// This file is part of the KVIrc IRC Client distribution -// Copyright (C) 2008 Elvio Basello -// -// This program is FREE software. You can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -#include "addonfunctions.h" - -#include "KviPackageReader.h" -#include "KviLocale.h" -#include "KviMessageBox.h" -#include "KviApplication.h" -#include "KviHtmlDialog.h" -#include "KviIconManager.h" -#include "KviFileUtils.h" -#include "KviMiscUtils.h" -#include "kvi_sourcesdate.h" -#include "KviMainWindow.h" -#include "KviKvsScript.h" - -#include - -#include - -namespace KviAddonFunctions -{ - bool notAValidAddonPackage(QString &szError) - { - szError = __tr2qs_ctx("The selected file does not seem to be a valid KVIrc addon package","addon"); - return false; - } - - bool installAddonPackage(const QString &szAddonPackageFileName,QString &szError,QWidget * pDialogParent) - { - KviPointerHashTable * pInfoFields; - QString * pValue; - QString szErr; - QPixmap pix; - QByteArray * pByteArray; - bool bInstall; - KviHtmlDialogData hd; - - const char * check_fields[] = { "Name", "Version", "Author", "Description", "Date", "Application" }; - - // check if it is a valid addon file - KviPackageReader r; - if(!r.readHeader(szAddonPackageFileName)) - { - szErr = r.lastError(); - KviQString::sprintf(szError,__tr2qs_ctx("The selected file does not seem to be a valid KVIrc package: %Q","addon"),&szErr); - return false; - } - - pInfoFields = r.stringInfoFields(); - - pValue = pInfoFields->find("PackageType"); - - if(!pValue) - return notAValidAddonPackage(szError); - - if(!KviQString::equalCI(*pValue,"AddonPack")) - return notAValidAddonPackage(szError); - - pValue = pInfoFields->find("AddonPackVersion"); - - if(!pValue) - return notAValidAddonPackage(szError); - - // make sure the default fields exist - for(int i=0;i<6;i++) - { - pValue = pInfoFields->find(check_fields[i]); - if(!pValue) - return notAValidAddonPackage(szError); - } - - // ok.. it should be really valid at this point - // load its picture - pByteArray = r.binaryInfoFields()->find("Image"); - if(pByteArray) - pix.loadFromData(*pByteArray,0,0); - - if(pix.isNull()) - { - // load the default icon - pix = *(g_pIconManager->getBigIcon(KVI_BIGICON_ADDONS)); - } - - QString szPackageName; - QString szPackageVersion; - QString szPackageAuthor; - QString szPackageDescription; - QString szPackageDate; - QString szAddonPackVersion; - QString szPackageApplication; - - QString szAuthor = __tr2qs_ctx("Author","addon"); - QString szCreatedAt = __tr2qs_ctx("Created at","addon"); - QString szCreatedWith = __tr2qs_ctx("Created with","addon"); - - r.getStringInfoField("Name",szPackageName); - r.getStringInfoField("Version",szPackageVersion); - r.getStringInfoField("Author",szPackageAuthor); - r.getStringInfoField("Description",szPackageDescription); - r.getStringInfoField("Application",szPackageApplication); - r.getStringInfoField("Date",szPackageDate); - r.getStringInfoField("AddonPackVersion",szAddonPackVersion); - - QString szWarnings; - QString szTmp; - - bool bValid = true; - - if(szPackageName.isEmpty() || szPackageVersion.isEmpty() || szAddonPackVersion.isEmpty()) - bValid = false; - - if(KviMiscUtils::compareVersions(szAddonPackVersion,KVI_CURRENT_ADDONS_ENGINE_VERSION) < 0) - bValid = false; - - - if(!bValid) - { - szWarnings += "

"; - szWarnings += __tr2qs_ctx("Warning: The addon might be incompatible with this version of KVIrc","addon"); - szWarnings += "

"; - } - - KviQString::sprintf(hd.szHtmlText, - "" \ - "" \ - "

" \ - "

%Q %Q

" \ - "

" \ - "

" \ - "" \ - "

" \ - "

" \ - "%Q" \ - "

" \ - "

" \ - "%Q: %Q
" \ - "%Q: %Q
" \ - "

" \ - "

" \ - "" \ - "%Q: %Q
" \ - "
" \ - "

" \ - "%Q" \ - "
" \ - "" \ - "", - &szPackageName, - &szPackageVersion, - &szPackageDescription, - &szAuthor, - &szPackageAuthor, - &szCreatedAt, - &szPackageDate, - &szCreatedWith, - &szPackageApplication, - &szWarnings - ); - - hd.addImageResource("addon_dialog_pack_image",pix); - hd.addHtmlResource("addon_dialog_main",hd.szHtmlText); - - QString beginCenter = "
"; - QString endCenter = "
"; - - hd.szCaption = __tr2qs_ctx("Install Addon Pack - KVIrc","addon"); - hd.szUpperLabelText = beginCenter + __tr2qs_ctx("You're about to install the following addon package","addon") + endCenter; - hd.szLowerLabelText = beginCenter + __tr2qs_ctx("Do you want to proceed with the installation ?","addon") + endCenter; - hd.szButton1Text = __tr2qs_ctx("Do Not Install","addon"); - hd.szButton2Text = __tr2qs_ctx("Yes, Proceed","addon"); - hd.iDefaultButton = 2; - hd.iCancelButton = 1; - hd.pixIcon = *(g_pIconManager->getSmallIcon(KVI_SMALLICON_ADDONS)); - hd.iMinimumWidth = 350; - hd.iMinimumHeight = 420; - hd.iFlags = KviHtmlDialogData::ForceMinimumSize; - - bInstall = KviHtmlDialog::display(pDialogParent,&hd) == 2; - - if(!bInstall) - return true; - - // Create a random extraction dir - QString szTmpPath, szUnpackPath; - QString szRandomDir = createRandomDir(); - - g_pApp->getLocalKvircDirectory(szTmpPath,KviApplication::Tmp); - KviQString::ensureLastCharIs(szTmpPath,QChar(KVI_PATH_SEPARATOR_CHAR)); - szUnpackPath = szTmpPath + szRandomDir; - QDir szTmpDir(szUnpackPath); - - // Check for dir existence - while(szTmpDir.exists()) - { - szRandomDir = createRandomDir(); - szUnpackPath = szTmpPath + szRandomDir; - szTmpDir = QDir(szUnpackPath); - } - - // Unpack addon package into the random tmp dir - if(!r.unpack(szAddonPackageFileName,szUnpackPath)) - { - szErr = r.lastError(); - KviQString::sprintf(szError,__tr2qs_ctx("Failed to unpack the selected file: %Q","addon"),&szErr); - return false; - } - - // Now we have all stuff in ~/.config/KVIrc/tmp/$rand - KviQString::escapeKvs(&szUnpackPath, KviQString::EscapeSpace); - if(!KviKvsScript::run(QString::fromAscii("parse %1/install.kvs").arg(szUnpackPath), g_pActiveWindow)) - { - // Parsing the script failed - // However, the user should already be notified via normal script output. - } - - if(!KviFileUtils::deleteDir(szUnpackPath)) - { - // FIXME: Just warn the user and assume success? - szErr = __tr2qs_ctx("One or more files can't be deleted","addon"); - KviQString::sprintf(szError,__tr2qs_ctx("Failed to unpack the selected file: %Q","addon"),&szErr); - return false; - } - - return true; - } - - QString createRandomDir() - { - QString szDirName; - char chars[] = { - 'A','B','C','D','E','F','G','H', - 'I','J','K','L','M','N','O','P', - 'Q','R','S','T','U','V','W','X', - 'Y','Z','a','b','c','d','e','f', - 'g','h','i','j','k','l','m','n', - 'o','p','q','r','s','t','u','v', - 'w','x','y','z','-','_','.' - }; - - // Generate dir name - for(int i=0;i<10;i++) - { - int n = rand() % sizeof(chars); - szDirName.append(chars[n]); - } - - return szDirName; - } -} diff --git a/src/modules/addon/addonfunctions.h b/src/modules/addon/addonfunctions.h deleted file mode 100644 index c8b39e9b0..000000000 --- a/src/modules/addon/addonfunctions.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef _ADDONFUNCTIONS_H_ -#define _ADDONFUNCTIONS_H_ -//============================================================================= -// -// File : addonfunctions.h -// Creation date : Fri 02 May 2008 17:36:07 by Elvio Basello -// -// This file is part of the KVIrc IRC Client distribution -// Copyright (C) 2008 Elvio Basello -// -// This program is FREE software. You can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -#include "kvi_settings.h" -#include "KviQString.h" - -#include -#include - -#define KVI_CURRENT_ADDONS_ENGINE_VERSION "2.0.0" - -namespace KviAddonFunctions -{ - bool notAValidAddonPackage(QString & szError); - bool installAddonPackage(const QString & szAddonPackageFileName, QString & szError, QWidget * pDialogParent = 0); - QString createRandomDir(); -} - -#endif //!_ADDONFUNCTIONS_H_ diff --git a/src/modules/addon/libkviaddon.cpp b/src/modules/addon/libkviaddon.cpp index 79f39a851..c852c5b13 100644 --- a/src/modules/addon/libkviaddon.cpp +++ b/src/modules/addon/libkviaddon.cpp @@ -23,7 +23,7 @@ //============================================================================= #include "managementdialog.h" -#include "addonfunctions.h" +#include "AddonFunctions.h" #include "KviModule.h" #include "KviKvsScriptAddonManager.h" @@ -776,7 +776,7 @@ static bool addon_kvs_cmd_installfiles(KviKvsModuleCommandCall * c) static bool addon_kvs_cmd_dialog(KviKvsModuleCommandCall *c) { - KviScriptManagementDialog::display(c->hasSwitch('t',"toplevel")); + AddonManagementDialog::display(c->hasSwitch('t',"toplevel")); return true; } @@ -803,7 +803,7 @@ static bool addon_kvs_cmd_install(KviKvsModuleCommandCall * c) KVSM_PARAMETERS_END(c) QString szError; - if(!KviAddonFunctions::installAddonPackage(szAddonPackFile,szError)) + if(!AddonFunctions::installAddonPackage(szAddonPackFile,szError)) { c->error(__tr2qs_ctx("Error installing addon package: %Q","addon"),&szError); return false; @@ -839,7 +839,7 @@ static bool addon_module_init(KviModule *m) static bool addon_module_cleanup(KviModule *m) { - KviScriptManagementDialog::cleanup(); + AddonManagementDialog::cleanup(); QString szBuf; m->getDefaultConfigFileName(szBuf); @@ -851,7 +851,7 @@ static bool addon_module_cleanup(KviModule *m) static bool addon_module_can_unload(KviModule *) { - return (!KviScriptManagementDialog::instance()); + return (!AddonManagementDialog::instance()); } diff --git a/src/modules/addon/managementdialog.cpp b/src/modules/addon/managementdialog.cpp index 846c5e112..d2f4d2ef9 100644 --- a/src/modules/addon/managementdialog.cpp +++ b/src/modules/addon/managementdialog.cpp @@ -23,8 +23,8 @@ //============================================================================= #include "managementdialog.h" -#include "packaddondialog.h" -#include "addonfunctions.h" +#include "PackAddonDialog.h" +#include "AddonFunctions.h" #include "KviApplication.h" #include "KviLocale.h" @@ -56,10 +56,10 @@ #include -KviScriptManagementDialog * KviScriptManagementDialog::m_pInstance = 0; +AddonManagementDialog * AddonManagementDialog::m_pInstance = 0; extern QRect g_rectManagementDialogGeometry; -KviScriptAddonListViewItem::KviScriptAddonListViewItem(KviTalListWidget *v,KviKvsScriptAddon * a) +AddonListViewItem::AddonListViewItem(KviTalListWidget *v,KviKvsScriptAddon * a) : KviTalListWidgetItem(v) { m_pAddon = new KviKvsScriptAddon(*a); @@ -81,12 +81,12 @@ KviScriptAddonListViewItem::KviScriptAddonListViewItem(KviTalListWidget *v,KviKv if (p) setIcon(*p); } -KviScriptAddonListViewItem::~KviScriptAddonListViewItem() +AddonListViewItem::~AddonListViewItem() { delete m_pAddon; } -KviScriptManagementDialog::KviScriptManagementDialog(QWidget * p) +AddonManagementDialog::AddonManagementDialog(QWidget * p) : QWidget(p) { setWindowTitle(__tr2qs_ctx("Manage Script-Based Addons","addon")); @@ -186,13 +186,13 @@ KviScriptManagementDialog::KviScriptManagementDialog(QWidget * p) g_rectManagementDialogGeometry.y()); } -KviScriptManagementDialog::~KviScriptManagementDialog() +AddonManagementDialog::~AddonManagementDialog() { g_rectManagementDialogGeometry = QRect(pos().x(),pos().y(),size().width(),size().height()); m_pInstance = 0; } -void KviScriptManagementDialog::fillListView() +void AddonManagementDialog::fillListView() { m_pListWidget->clear(); KviPointerHashTable * d = KviKvsScriptAddonManager::instance()->addonDict(); @@ -201,14 +201,14 @@ void KviScriptManagementDialog::fillListView() while(KviKvsScriptAddon * a = it.current()) { - new KviScriptAddonListViewItem(m_pListWidget,a); + new AddonListViewItem(m_pListWidget,a); ++it; } } -void KviScriptManagementDialog::currentChanged(QListWidgetItem *item,QListWidgetItem *) +void AddonManagementDialog::currentChanged(QListWidgetItem *item,QListWidgetItem *) { - KviScriptAddonListViewItem * it = (KviScriptAddonListViewItem *)item; + AddonListViewItem * it = (AddonListViewItem *)item; if(!it) { m_pConfigureButton->setEnabled(false); @@ -221,32 +221,32 @@ void KviScriptManagementDialog::currentChanged(QListWidgetItem *item,QListWidget } } -void KviScriptManagementDialog::showScriptHelp() +void AddonManagementDialog::showScriptHelp() { - KviScriptAddonListViewItem * it = (KviScriptAddonListViewItem *)m_pListWidget->currentItem(); + AddonListViewItem * it = (AddonListViewItem *)m_pListWidget->currentItem(); if(!it)return; if(it->addon()->helpCallbackCode().isEmpty())return; it->addon()->executeHelpCallback(g_pActiveWindow); } -void KviScriptManagementDialog::configureScript() +void AddonManagementDialog::configureScript() { - KviScriptAddonListViewItem * it = (KviScriptAddonListViewItem *)m_pListWidget->currentItem(); + AddonListViewItem * it = (AddonListViewItem *)m_pListWidget->currentItem(); if(!it)return; if(it->addon()->configureCallbackCode().isEmpty())return; it->addon()->executeConfigureCallback(g_pActiveWindow); } -void KviScriptManagementDialog::packScript() +void AddonManagementDialog::packScript() { - KviPackAddonDialog * pDialog = new KviPackAddonDialog(this); + PackAddonDialog * pDialog = new PackAddonDialog(this); pDialog->exec(); delete pDialog; } -void KviScriptManagementDialog::uninstallScript() +void AddonManagementDialog::uninstallScript() { - KviScriptAddonListViewItem * it = (KviScriptAddonListViewItem *)m_pListWidget->currentItem(); + AddonListViewItem * it = (AddonListViewItem *)m_pListWidget->currentItem(); if(!it)return; QString txt = "

"; @@ -265,13 +265,13 @@ void KviScriptManagementDialog::uninstallScript() currentChanged(0,0); } -void KviScriptManagementDialog::getMoreScripts() +void AddonManagementDialog::getMoreScripts() { // If change this introducing not-fixed text, remember to escape this using KviQString::escapeKvs()! KviKvsScript::run("openurl http://www.kvirc.net/?id=addons&version=" KVI_VERSION "." KVI_SOURCES_DATE,g_pActiveWindow); } -void KviScriptManagementDialog::installScript() +void AddonManagementDialog::installScript() { QString szFileName, szError; @@ -286,7 +286,7 @@ void KviScriptManagementDialog::installScript() // Sanity check if(szFileName.endsWith(".kva")) { - if(!KviAddonFunctions::installAddonPackage(szFileName,szError,this)) + if(!AddonFunctions::installAddonPackage(szFileName,szError,this)) { QMessageBox::critical( this, @@ -301,7 +301,7 @@ void KviScriptManagementDialog::installScript() } else { // Just for sanity check. We should NEVER enter here qDebug("Entered sanity check"); - KviAddonFunctions::notAValidAddonPackage(szError); + AddonFunctions::notAValidAddonPackage(szError); QMessageBox::critical( this, __tr2qs_ctx("Install Addon - KVIrc","addon"), @@ -319,7 +319,7 @@ void KviScriptManagementDialog::installScript() //m_pListWidget->triggerUpdate(); } -void KviScriptManagementDialog::showEvent(QShowEvent * e) +void AddonManagementDialog::showEvent(QShowEvent * e) { QRect rect = g_pApp->desktop()->screenGeometry(g_pApp->desktop()->primaryScreen()); move((rect.width() - width())/2,(rect.height() - height())/2); @@ -327,19 +327,19 @@ void KviScriptManagementDialog::showEvent(QShowEvent * e) QWidget::showEvent(e); } -void KviScriptManagementDialog::closeClicked() +void AddonManagementDialog::closeClicked() { delete this; } -void KviScriptManagementDialog::cleanup() +void AddonManagementDialog::cleanup() { if(!m_pInstance)return; delete m_pInstance; m_pInstance = 0; } -void KviScriptManagementDialog::display(bool bTopLevel) +void AddonManagementDialog::display(bool bTopLevel) { if(m_pInstance) { @@ -358,9 +358,9 @@ void KviScriptManagementDialog::display(bool bTopLevel) } else { if(bTopLevel) { - m_pInstance = new KviScriptManagementDialog(0); + m_pInstance = new AddonManagementDialog(0); } else { - m_pInstance = new KviScriptManagementDialog(g_pFrame->splitter()); + m_pInstance = new AddonManagementDialog(g_pFrame->splitter()); } } m_pInstance->show(); @@ -368,13 +368,13 @@ void KviScriptManagementDialog::display(bool bTopLevel) m_pInstance->setFocus(); } -void KviScriptManagementDialog::closeEvent(QCloseEvent * e) +void AddonManagementDialog::closeEvent(QCloseEvent * e) { e->ignore(); delete this; } -void KviScriptManagementDialog::reject() +void AddonManagementDialog::reject() { cleanup(); } diff --git a/src/modules/addon/managementdialog.h b/src/modules/addon/managementdialog.h index 45a6b8656..dd9fe1780 100644 --- a/src/modules/addon/managementdialog.h +++ b/src/modules/addon/managementdialog.h @@ -38,11 +38,11 @@ class QPixmap; class KviKvsScriptAddon; -class KviScriptAddonListViewItem : public KviTalListWidgetItem +class AddonListViewItem : public KviTalListWidgetItem { public: - KviScriptAddonListViewItem(KviTalListWidget * v,KviKvsScriptAddon * a); - ~KviScriptAddonListViewItem(); + AddonListViewItem(KviTalListWidget * v,KviKvsScriptAddon * a); + ~AddonListViewItem(); protected: KviKvsScriptAddon * m_pAddon; QTextDocument * m_pText; @@ -54,22 +54,22 @@ public: }; -class KviScriptManagementDialog : public QWidget +class AddonManagementDialog : public QWidget { Q_OBJECT protected: - KviScriptManagementDialog(QWidget * p); + AddonManagementDialog(QWidget * p); public: - ~KviScriptManagementDialog(); + ~AddonManagementDialog(); protected: KviTalListWidget * m_pListWidget; - static KviScriptManagementDialog * m_pInstance; + static AddonManagementDialog * m_pInstance; QToolButton * m_pConfigureButton; QToolButton * m_pHelpButton; QToolButton * m_pPackButton; QToolButton * m_pUninstallButton; public: - static KviScriptManagementDialog * instance(){ return m_pInstance; }; + static AddonManagementDialog * instance(){ return m_pInstance; }; static void display(bool bTopLevel); static void cleanup(); protected: diff --git a/src/modules/addon/packaddondialog.cpp b/src/modules/addon/packaddondialog.cpp deleted file mode 100644 index ce2c52890..000000000 --- a/src/modules/addon/packaddondialog.cpp +++ /dev/null @@ -1,664 +0,0 @@ -//============================================================================ -// -// File : packaddondialog.cpp -// 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-2009 Elvio Basello -// -// This program is FREE software. You can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================ - -#include "packaddondialog.h" -#include "addonfunctions.h" - -#include "KviLocale.h" -#include "KviFileUtils.h" -#include "KviApplication.h" -#include "KviIconManager.h" -#include "KviPackageWriter.h" -#include "kvi_fileextensions.h" -#include "kvi_sourcesdate.h" -#include "KviOptions.h" - -#include -#include -#include -#include -#include -#include -#include -#include - - -KviPackAddonDialog::KviPackAddonDialog(QWidget * pParent) -: QWizard(pParent) -{ - setMinimumSize(400,350); - setObjectName("addon_package_wizard"); - setOption(QWizard::IndependentPages,true); - setWindowTitle(__tr2qs_ctx("Create Addon Package - KVIrc","addon")); - - QPixmap * pSide = g_pIconManager->getBigIcon("kvi_setup_label.png"); - QPixmap * pLogo = g_pIconManager->getBigIcon("kvi_bigicon_addons.png"); - -#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) - #if (_WIN32_WINNT >= 0x0600) - // We are on a Windows Vista / Seven - // It will fallback to XP if alpha compositing is disabled - setWizardStyle(QWizard::AeroStyle); - #else - // Windows XP - setWizardStyle(QWizard::ModernStyle); - setPixmap(QWizard::WatermarkPixmap,*pSide); - setPixmap(QWizard::LogoPixmap,*pLogo); - #endif -#elif defined(COMPILE_ON_MAC) - setWizardStyle(QWizard::MacStyle); - setPixmap(QWizard::BackgroundPixmap,*pSide); -#else - // All other systems - setWizardStyle(QWizard::ClassicStyle); - setPixmap(QWizard::WatermarkPixmap,*pSide); - setPixmap(QWizard::LogoPixmap,*pLogo); -#endif - - // Add a default property for file selectors - setDefaultProperty("KviFileSelector","tmpFile",SIGNAL(selectionChanged(const QString &))); - - // Welcome page - QWizardPage * pPage = new QWizardPage(this); - QVBoxLayout * pLayout = new QVBoxLayout(pPage); - - pPage->setLayout(pLayout); - pPage->setTitle(__tr2qs_ctx("Welcome","addon")); - - QLabel * pLabel = new QLabel(pPage); - pLabel->setWordWrap(true); - 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); - pLabel->setWordWrap(true); - QString szText; - szText += __tr2qs_ctx("You will be asked to provide some information 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); - - pPage->setMinimumWidth(350); - - addPage(pPage); - - // Packager information - m_pPackAddonInfoPackageWidget = new KviPackAddonInfoPackageWidget(this); - addPage(m_pPackAddonInfoPackageWidget); - - // File selection - m_pPackAddonFileSelectionWidget = new KviPackAddonFileSelectionWidget(this); - addPage(m_pPackAddonFileSelectionWidget); - - // Save selection - m_pPackAddonSaveSelectionWidget = new KviPackAddonSaveSelectionWidget(this); - addPage(m_pPackAddonSaveSelectionWidget); - - // Summary info - m_pPackAddonSummaryInfoWidget = new KviPackAddonSummaryInfoWidget(this); - addPage(m_pPackAddonSummaryInfoWidget); - -} - -KviPackAddonDialog::~KviPackAddonDialog() -{ -} - -void KviPackAddonDialog::accept() -{ - if(!packAddon()) - return; - QWizard::accept(); -} - -bool KviPackAddonDialog::checkDirTree(QString * pszError, QString * pszWarning) -{ - if(pszError) *pszError = ""; - if(pszWarning) *pszWarning = ""; - - QDir addon(m_szDirPath); - if(!addon.exists()) - { - *pszError = __tr2qs_ctx("The selected directory does not exist.","addon"); - return false; - } - - QFileInfo init(m_szDirPath + "/install.kvs"); - if(!init.exists()) - { - *pszError = __tr2qs_ctx("The initialization script (install.kvs) does not exist.","addon"); - return false; - } - - return true; -} - -#if 0 -bool KviPackAddonDialog::createInstaller(QString * pszError) -{ - if(pszError) - *pszError = ""; - - // 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 %2\n# Written by %3\n# %4\n\n").arg(m_szName, m_szVersion, m_szAuthor, 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 - /* FIXME: re-add in KVIrc 4.1! - * implement a backend with full automatic cleaning for aliases, classes, popups, - * actions, ... via snapshot/diff of kvirc state before/after installing a package - - szTmp += QString("addon.register(\"%1\",\"%2\",\"%1\",\"%3\",\"%4\",\"%5\")\n").arg(m_szName, m_szVersion, m_szDescription, m_szMinVersion, m_szIcon); - szTmp += "{\n"; - szTmp += "\t# This is our uninstall callback: it will be called by KVIrc when addon.uninstall is invoked\n"; - szTmp += QString("\t%1::uninstall::uninstall\n").arg(m_szName); - szTmp += QString("\t%1::uninstall::uninstallfiles\n").arg(m_szName); - szTmp += QString("\t%1::uninstall::uninstallaliases\n").arg(m_szName); - szTmp += "}\n\n"; - 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\"))\n\n"); - 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/\",\"*.html\",$file.localdir(\"help/\"))\n\n"); - - // install.kvs: generate uninstall alias - szTmp += "# Generate the uninstall alias\n"; - szTmp += QString("%installer->$generateUninstallAlias(\"%1::uninstallfiles\")\n\n") \ - .arg(m_szName); - - // kviinstall.kvs: kill the installer class - szTmp += "# Kill the installer helper\n"; - szTmp += "delete %installer\n\n"; - -#if 0 - // 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(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("\t%alias .= \"alias(%1::uninstall::uninstallfiles){};$lf\"\n") \ - .arg(m_szName); - szTmp += QString("\t%alias .= \"alias(%1::uninstall::uninstallaliases){};$lf\"\n") \ - .arg(m_szName); - szTmp += "%alias .= \"}\"\n"; - szTmp += "eval %alias\n\n"; -#endif - - // 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()); - - // 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::WriteOnly)) - { - *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"); - return false; - } - - return true; -} -#endif - - -bool KviPackAddonDialog::packAddon() -{ - // Get data from registered fields - 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(); - m_szDirPath = field("packageDirPath").toString(); - m_szSavePath = field("packageSavePath").toString(); - - // Check the addon tree - QString szError, szWarning; - - if(!checkDirTree(&szError,&szWarning)) - { - QMessageBox::critical(this, - __tr2qs_ctx("Addon Packaging Error","addon"), - szError,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton - ); - return false; - } - - if(szWarning != "") - { - QMessageBox::warning(this, - __tr2qs_ctx("Addon Packaging Warning","addon"), - szWarning,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton - ); - } - - // Raise the files summary dialog - m_pPackAddonSummaryFilesWidget = new KviPackAddonSummaryFilesWidget(this); - m_pPackAddonSummaryFilesWidget->setPath(m_szDirPath); - if(m_pPackAddonSummaryFilesWidget->exec() == QDialog::Rejected) - { - delete m_pPackAddonSummaryFilesWidget; - return false; - } - - - QString szTmp; - szTmp = QDateTime::currentDateTime().toString(); - - KviPackageWriter pw; - pw.addInfoField("PackageType","AddonPack"); - pw.addInfoField("AddonPackVersion",KVI_CURRENT_ADDONS_ENGINE_VERSION); - 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); - - QPixmap pix(m_szIcon); - if(!pix.isNull()) - { - QByteArray * pba = new QByteArray(); - QBuffer bufferz(pba,0); - - bufferz.open(QIODevice::WriteOnly); - pix.save(&bufferz,"PNG"); - bufferz.close(); - pw.addInfoField("Image",pba); - } - - QDir dir(m_szDirPath); - QFileInfoList ls = dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::Readable | QDir::NoSymLinks | QDir::NoDotAndDotDot); - - if(ls.isEmpty()) - { - szTmp = __tr2qs_ctx("Packaging failed","addon"); - szTmp += ": "; - szTmp += __tr2qs_ctx("The package file list is empty","addon"); - QMessageBox::critical(this,__tr2qs_ctx("Export Addon - KVIrc","addon"),szTmp,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); - return false; - } - - for(QFileInfoList::Iterator it = ls.begin();it != ls.end();++it) - { - const QFileInfo &inf = *it; - - if(inf.isDir()) - { - if(!pw.addDirectory(inf.absoluteFilePath(),QString("%1/").arg(inf.fileName()))) - { - QString 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; - } - - continue; - } - - // must be a file - if(!pw.addFile(inf.absoluteFilePath(),inf.fileName())) - { - 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; - } - } - - - // Create the addon package - if(m_szSavePath.isEmpty()) - { - 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(m_szSavePath)) - { - 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; - } - - - QMessageBox::information(this,__tr2qs_ctx("Export Addon - KVIrc","addon"),__tr2qs("Package saved successfully in ") + m_szSavePath,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); - - return true; -} - - -KviPackAddonInfoPackageWidget::KviPackAddonInfoPackageWidget(KviPackAddonDialog * pParent) -: QWizardPage(pParent) -{ - setObjectName("addon_package_info_page"); - setTitle(__tr2qs_ctx("Package Information","addon")); - setSubTitle(__tr2qs_ctx("Here you need to provide information about you (the packager) and a short description of the package you're creating.","addon")); - - QGridLayout * pLayout = new QGridLayout(this); - - QLabel * pLabel = new QLabel(this); - pLabel->setText(__tr2qs_ctx("Package &Author:","addon")); - pLayout->addWidget(pLabel,0,0); - - m_pPackageAuthorEdit = new QLineEdit(this); - m_pPackageAuthorEdit->setText(__tr2qs_ctx("Your name here","addon")); - pLabel->setBuddy(m_pPackageAuthorEdit); - pLayout->addWidget(m_pPackageAuthorEdit,0,1); - - pLabel = new QLabel(this); - pLabel->setText(__tr2qs_ctx("Package &Name:","addon")); - pLayout->addWidget(pLabel,1,0); - - m_pPackageNameEdit = new QLineEdit(this); - m_pPackageNameEdit->setText(__tr2qs_ctx("No spaces allowed, like MyAddon","addon")); - pLabel->setBuddy(m_pPackageNameEdit); - pLayout->addWidget(m_pPackageNameEdit,1,1); - - pLabel = new QLabel(this); - pLabel->setText(__tr2qs_ctx("Package &Version:","addon")); - pLayout->addWidget(pLabel,2,0); - - m_pPackageVersionEdit = new QLineEdit(this); - m_pPackageVersionEdit->setText(__tr2qs_ctx("Version in the form x.y[.z], like 1.0 or 2.0.3","addon")); - pLabel->setBuddy(m_pPackageVersionEdit); - pLayout->addWidget(m_pPackageVersionEdit,2,1); - - pLabel = new QLabel(this); - pLabel->setText(__tr2qs_ctx("Package &Description:","addon")); - pLayout->addWidget(pLabel,3,0); - - m_pPackageDescriptionEdit = new QLineEdit(this); - m_pPackageDescriptionEdit->setText(QString()); - pLabel->setBuddy(m_pPackageDescriptionEdit); - pLayout->addWidget(m_pPackageDescriptionEdit,3,1); - - pLabel = new QLabel(this); - pLabel->setText(__tr2qs_ctx("Minimum &KVIrc Version:","addon")); - pLayout->addWidget(pLabel,4,0); - - m_pPackageMinVersionEdit = new QLineEdit(this); - m_pPackageMinVersionEdit->setText(KVI_VERSION); - 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); - registerField("packageMinVersion",m_pPackageMinVersionEdit); -} - -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")); - - QVBoxLayout * pLayout = new QVBoxLayout(this); - - // Select source directory - m_pDirPathSelector = new KviDirectorySelector(this,__tr2qs_ctx("Select the source directory:","addon"),&m_szDirPath,true,KviFileSelector::VerticalLayout); - pLayout->addWidget(m_pDirPathSelector); - - // Select addon icon - m_pPackageIconEdit = new KviFileSelector(this,__tr2qs_ctx("Select the icon file:","addon"),&m_szPackageIcon,true,KviFileSelector::VerticalLayout,KVI_FILTER_IMAGE); - pLayout->addWidget(m_pPackageIconEdit); - - // Store data in the fields - registerField("packageDirPath*",m_pDirPathSelector); - registerField("packageIcon*",m_pPackageIconEdit); -} - -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); - - // Select save path - m_pSavePathSelector = new KviFileSelector( - this, - __tr2qs_ctx("Select save path:","addon"), - &m_szFilePath, - true, - KviFileSelector::ChooseSaveFileName | KviFileSelector::VerticalLayout, - KVI_FILTER_ADDON - ); - pLayout->addWidget(m_pSavePathSelector); - - // Store data in the fields - registerField("packageSavePath*",m_pSavePathSelector); -} - -KviPackAddonSaveSelectionWidget::~KviPackAddonSaveSelectionWidget() -{ -} - -void KviPackAddonSaveSelectionWidget::initializePage() -{ - // Get data from registered fields - QString szName = field("packageName").toString(); - QString szVersion = field("packageVersion").toString(); - - // Create addon name - 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); -} - - -KviPackAddonSummaryInfoWidget::KviPackAddonSummaryInfoWidget(KviPackAddonDialog * pParent) -: QWizardPage(pParent) -{ - setObjectName("addon_package_summary_info_page"); - setTitle(__tr2qs_ctx("Final Information","addon")); - setSubTitle(__tr2qs_ctx("Here there are the information you provided. If these information 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); -} - -KviPackAddonSummaryInfoWidget::~KviPackAddonSummaryInfoWidget() -{ -} - -void KviPackAddonSummaryInfoWidget::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); -} - - -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 information 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()) - { - QString szStr = it.next(); - if(!szStr.contains("/.")) - list.append(szStr); - } - - // 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 deleted file mode 100644 index bf5dbf1ba..000000000 --- a/src/modules/addon/packaddondialog.h +++ /dev/null @@ -1,252 +0,0 @@ -#ifndef _PACKADDONDIALOG_H_ -#define _PACKADDONDIALOG_H_ -//============================================================================= -// -// File : packaddondialog.h -// 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-2009 Elvio Basello -// -// This program is FREE software. You can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -/** -* \file packaddondialog.h -* \author Elvio Basello -* \brief Addon package creator -* -* This set of classes allow users to create addon for KVIrc in a standard -* distributable *.kva packages. -*/ - -#include "kvi_settings.h" -#include "KviPointerList.h" -#include "KviSelectors.h" - -#include -#include - -class QTextEdit; -class QLineEdit; -class QLabel; - -class KviPackageWriter; - -class KviPackAddonInfoPackageWidget; -class KviPackAddonFileSelectionWidget; -class KviPackAddonSaveSelectionWidget; -class KviPackAddonSummaryInfoWidget; -class KviPackAddonSummaryFilesWidget; - -/** -* \class KviPackAddonDialog -* \brief Wizard for addon creation -*/ -class KviPackAddonDialog : public QWizard -{ - Q_OBJECT -public: - /** - * \brief Creates the wizard object - * \param pParent The parent widget - * \return KviPackAddonDialog - */ - KviPackAddonDialog(QWidget * pParent); - - /** - * \brief Destroys the wizard object - */ - ~KviPackAddonDialog(); -protected: - KviPackAddonInfoPackageWidget * m_pPackAddonInfoPackageWidget; - KviPackAddonFileSelectionWidget * m_pPackAddonFileSelectionWidget; - KviPackAddonSaveSelectionWidget * m_pPackAddonSaveSelectionWidget; - 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 - * \return void - */ - virtual void accept(); - - /** - * \brief Creates the addon package - * \return bool - */ - bool packAddon(); - - /** - * \brief Ensures the sources directory is complete - * \param pszError The buffer containing errors - * \param pszWarning The buffer containing warnings - * \return bool - */ - bool checkDirTree(QString * pszError, QString * pszWarning); - - /** - * \brief Creates the installer file - * \param pszError The buffer containing errors - * \return bool - */ - bool createInstaller(QString * pszError); -}; - -/** -* \class KviPackAddonInfoPackageWidget -* \brief Wizard page for addon information -*/ -class KviPackAddonInfoPackageWidget : public QWizardPage -{ - Q_OBJECT -public: - /** - * \brief Create the wizard package info page object - * \param pParent The parent widget - * \return KviPackAddonInfoPackageWidget - */ - KviPackAddonInfoPackageWidget(KviPackAddonDialog * pParent); - - /** - * \brief Destroys the wizard package info page object - */ - ~KviPackAddonInfoPackageWidget(); -protected: - QLineEdit * m_pPackageAuthorEdit; - QLineEdit * m_pPackageNameEdit; - QLineEdit * m_pPackageVersionEdit; - QLineEdit * m_pPackageDescriptionEdit; - QLineEdit * m_pPackageMinVersionEdit; -}; - -/** -* \class KviPackAddonFileSelectionWidget -* \brief Wizard page for directory source selection -*/ -class KviPackAddonFileSelectionWidget : public QWizardPage -{ - Q_OBJECT -public: - /** - * \brief Create the wizard package source dir object - * \param pParent The parent widget - * \return KviPackAddonFileSelectionWidget - */ - KviPackAddonFileSelectionWidget(KviPackAddonDialog * pParent); - - /** - * \brief Destroys the wizard package source dir object - */ - ~KviPackAddonFileSelectionWidget(); -protected: - KviDirectorySelector * m_pDirPathSelector; - KviFileSelector * m_pPackageIconEdit; - QString m_szDirPath; - QString m_szPackageIcon; -}; - -/** -* \class KviPackAddonSaveSelectionWidget -* \brief Wizard page for saving package -*/ -class KviPackAddonSaveSelectionWidget : public QWizardPage -{ - Q_OBJECT -public: - /** - * \brief Create the wizard save page object - * \param pParent The parent widget - * \return KviPackAddonSaveSelectionWidget - */ - KviPackAddonSaveSelectionWidget(KviPackAddonDialog * pParent); - - /** - * \brief Destroys the wizard save page object - */ - ~KviPackAddonSaveSelectionWidget(); -protected: - KviFileSelector * m_pSavePathSelector; - QString m_szFilePath; -protected: - /** - * \brief Perform initial tasks before showing the widget - * \return void - */ - virtual void initializePage(); -}; - -/** -* \class KviPackAddonSummaryInfoWidget -* \brief Wizard page for showing information inserted -*/ -class KviPackAddonSummaryInfoWidget : public QWizardPage -{ - Q_OBJECT -public: - /** - * \brief Create the wizard summary info page object - * \param pParent The parent widget - * \return KviPackAddonSummaryInfoWidget - */ - KviPackAddonSummaryInfoWidget(KviPackAddonDialog * pParent); - - /** - * \brief Destroys the wizard summary info page object - */ - ~KviPackAddonSummaryInfoWidget(); -protected: - QLabel * m_pLabelInfo; - QLabel * m_pLabelAuthor; - QLabel * m_pPackageName; - QLabel * m_pPackageVersion; - QLabel * m_pPackageDescription; -protected: - /** - * \brief Perform initial tasks before showing the widget - * \return void - */ - virtual void initializePage(); -}; - - -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 *); -protected slots: - virtual void accept(); - virtual void reject(); -}; - -#endif //!_PACKADDONDIALOG_H_ -- cgit v1.3.1-10-gc9f91