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/theme/CMakeLists.txt | 10 +- src/modules/theme/PackThemeDialog.cpp | 576 +++++++++++++++++++++++++++++++++ src/modules/theme/PackThemeDialog.h | 124 +++++++ src/modules/theme/SaveThemeDialog.cpp | 306 ++++++++++++++++++ src/modules/theme/SaveThemeDialog.h | 66 ++++ src/modules/theme/ThemeFunctions.cpp | 405 +++++++++++++++++++++++ src/modules/theme/ThemeFunctions.h | 57 ++++ src/modules/theme/libkvitheme.cpp | 12 +- src/modules/theme/managementdialog.cpp | 76 ++--- src/modules/theme/managementdialog.h | 16 +- src/modules/theme/packthemedialog.cpp | 576 --------------------------------- src/modules/theme/packthemedialog.h | 124 ------- src/modules/theme/savethemedialog.cpp | 306 ------------------ src/modules/theme/savethemedialog.h | 66 ---- src/modules/theme/themefunctions.cpp | 405 ----------------------- src/modules/theme/themefunctions.h | 57 ---- 16 files changed, 1591 insertions(+), 1591 deletions(-) create mode 100644 src/modules/theme/PackThemeDialog.cpp create mode 100644 src/modules/theme/PackThemeDialog.h create mode 100644 src/modules/theme/SaveThemeDialog.cpp create mode 100644 src/modules/theme/SaveThemeDialog.h create mode 100644 src/modules/theme/ThemeFunctions.cpp create mode 100644 src/modules/theme/ThemeFunctions.h delete mode 100644 src/modules/theme/packthemedialog.cpp delete mode 100644 src/modules/theme/packthemedialog.h delete mode 100644 src/modules/theme/savethemedialog.cpp delete mode 100644 src/modules/theme/savethemedialog.h delete mode 100644 src/modules/theme/themefunctions.cpp delete mode 100644 src/modules/theme/themefunctions.h (limited to 'src/modules/theme') diff --git a/src/modules/theme/CMakeLists.txt b/src/modules/theme/CMakeLists.txt index 2e810769b..600ec61cf 100644 --- a/src/modules/theme/CMakeLists.txt +++ b/src/modules/theme/CMakeLists.txt @@ -2,16 +2,16 @@ SET(kvitheme_MOC_HDRS managementdialog.h - packthemedialog.h - savethemedialog.h + PackThemeDialog.h + SaveThemeDialog.h ) SET(kvitheme_SRCS libkvitheme.cpp managementdialog.cpp - packthemedialog.cpp - savethemedialog.cpp - themefunctions.cpp + PackThemeDialog.cpp + SaveThemeDialog.cpp + ThemeFunctions.cpp ) # After this call, files will be moc'ed to moc_kvi_*.cpp diff --git a/src/modules/theme/PackThemeDialog.cpp b/src/modules/theme/PackThemeDialog.cpp new file mode 100644 index 000000000..c3560ec78 --- /dev/null +++ b/src/modules/theme/PackThemeDialog.cpp @@ -0,0 +1,576 @@ +//============================================================================= +// +// File : PackThemeDialog.cpp +// Creation date : Wed 03 Jan 2007 01:11:44 by Szymon Stefanek +// +// This file is part of the KVIrc IRC Client distribution +// Copyright (C) 2007-2010 Szymon Stefanek +// Copyright (C) 2010 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 "PackThemeDialog.h" +#include "ThemeFunctions.h" + +#include "KviOptions.h" +#include "KviLocale.h" +#include "KviConfigurationFile.h" +#include "KviFileUtils.h" +#include "KviApplication.h" +#include "KviMainWindow.h" +#include "KviIconManager.h" +#include "KviPackageWriter.h" +#include "kvi_fileextensions.h" +#include "KviFileDialog.h" +//#include "KviMessageBox.h" +#include "KviSelectors.h" +#include "KviMiscUtils.h" +#include "kvi_sourcesdate.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +//#include +//#include +//#include + + + +PackThemeDialog::PackThemeDialog(QWidget * pParent, KviPointerList * pThemeInfoList) +: QWizard(pParent) +{ + setWindowTitle(__tr2qs_ctx("Export Theme - KVIrc","theme")); + setMinimumSize(400,350); + setDefaultProperty("QTextEdit","plainText",SIGNAL(textChanged())); + m_pThemeInfoList = pThemeInfoList; + + 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","theme")); + + QString szText = "

"; + szText += __tr2qs_ctx("This procedure allows you to export the selected themes to a single package. It is useful when you want to distribute your themes to the public.","theme"); + szText += "

"; + szText += __tr2qs_ctx("You will be asked to provide a package name, a description and, if you want, an icon/screenshot.","theme"); + szText += "

"; + szText += __tr2qs_ctx("Hit the \"Next\" button to begin.","theme"); + szText += "

"; + + QLabel * pLabel = new QLabel(pPage); + pLabel->setWordWrap(true); + pLabel->setText(szText); + pLayout->addWidget(pLabel); + addPage(pPage); + + // Theme data + m_pPackThemeDataWidget = new PackThemeDataWidget(this); + addPage(m_pPackThemeDataWidget); + + // Packager information + m_pPackThemeInfoWidget = new PackThemeInfoWidget(this); + addPage(m_pPackThemeInfoWidget); + + // Screenshot/logo/icon + m_pPackThemeImageWidget = new PackThemeImageWidget(this); + addPage(m_pPackThemeImageWidget); + + // Save file name + m_pPackThemeSaveWidget = new PackThemeSaveWidget(this); + addPage(m_pPackThemeSaveWidget); + + //last thing to do before starting + m_pPackThemeDataWidget->parseThemes(m_pThemeInfoList); +} + +PackThemeDataWidget::PackThemeDataWidget(PackThemeDialog * pParent) +: QWizardPage(pParent) +{ + setObjectName("theme_package_data_page"); + setTitle(__tr2qs_ctx("Theme Data","theme")); + setSubTitle(__tr2qs_ctx("This is the information list for the themes you're packaging. If it looks OK press \"Next\" to continue, otherwise press \"Cancel\" and rewiew your themes first.","theme")); +} + +void PackThemeDataWidget::parseThemes(KviPointerList * pThemeInfoList) +{ + QString szPackageName; + QString szPackageAuthor; + QString szPackageDescription; + QString szPackageVersion; + KviThemeInfo * pThemeInfo = 0; + bool bPackagePathSet = false; + + + QString szPackagePath = QDir::homePath(); + KviQString::ensureLastCharIs(szPackagePath,QChar(KVI_PATH_SEPARATOR_CHAR)); + + if(pThemeInfoList->count() > 1) + { + szPackageName = "MyThemes"; + szPackageAuthor = __tr2qs_ctx("Your name here","theme"); + szPackageVersion = "1.0.0"; + szPackageDescription = __tr2qs_ctx("Put a package description here...","theme"); + } else { + if(pThemeInfoList->count() > 0) + { + pThemeInfo = pThemeInfoList->first(); + szPackageName = pThemeInfo->subdirectory(); + szPackageAuthor = pThemeInfo->author(); + szPackageDescription = pThemeInfo->description(); + szPackageVersion = pThemeInfo->version(); + + szPackagePath += pThemeInfo->subdirectory(); + if(szPackagePath.indexOf(QRegExp("[0-9]\\.[0-9]")) == -1) + { + szPackagePath += "-"; + szPackagePath += szPackageVersion; + } + szPackagePath += KVI_FILEEXTENSION_THEMEPACKAGE; + + bPackagePathSet = true; + } + } + + if(!bPackagePathSet) + { + szPackagePath += szPackageName; + szPackagePath += "-"; + szPackagePath += szPackageVersion; + szPackagePath += KVI_FILEEXTENSION_THEMEPACKAGE; + } + + QVBoxLayout * pLayout = new QVBoxLayout(this); + + QString szThemesDescription = ""; + + int iIdx = 0; + QPixmap pixScreenshot; + QString szScreenshotPath; + + for(pThemeInfo = pThemeInfoList->first(); pThemeInfo; pThemeInfo = pThemeInfoList->next()) + { + QString szThemeDescription; + + if(pixScreenshot.isNull()) + { + pixScreenshot = pThemeInfo->smallScreenshot(); + if(!pixScreenshot.isNull()) + szScreenshotPath = pThemeInfo->smallScreenshotPath(); + } + + ThemeFunctions::getThemeHtmlDescription( + szThemeDescription, + pThemeInfo->name(), + pThemeInfo->version(), + pThemeInfo->description(), + pThemeInfo->subdirectory(), + pThemeInfo->application(), + pThemeInfo->author(), + pThemeInfo->date(), + pThemeInfo->themeEngineVersion(), + pThemeInfo->smallScreenshot(), + iIdx + ); + + if(iIdx > 0) + szThemesDescription += "


"; + szThemesDescription += szThemeDescription; + iIdx++; + } + + szThemesDescription += ""; + + QTextEdit * pTextEdit = new QTextEdit(this); + pTextEdit->setBackgroundRole(QPalette::Window); + pTextEdit->setReadOnly(true); + QTextDocument * pDoc = new QTextDocument(pTextEdit); + pDoc->setHtml(szThemesDescription); + pTextEdit->setDocument(pDoc); + pLayout->addWidget(pTextEdit); + + setField("packageName",QVariant(szPackageName)); + setField("packageVersion",szPackageVersion); + setField("packageDescription",szPackageDescription); + setField("packageAuthor",szPackageAuthor); +} + +PackThemeDataWidget::~PackThemeDataWidget() +{ +} + +PackThemeInfoWidget::PackThemeInfoWidget(PackThemeDialog * pParent) +: QWizardPage(pParent) +{ + setObjectName("theme_package_info_page"); + setTitle(__tr2qs_ctx("Package Information","theme")); + setSubTitle(__tr2qs_ctx("Here you need to provide information about you (the packager) and a short description of the package you're creating.","theme")); + + + QGridLayout * pLayout = new QGridLayout(this); + + QLabel * pLabel = new QLabel(this); + pLabel->setText(__tr2qs_ctx("Package Name:","theme")); + pLayout->addWidget(pLabel,1,0); + + m_pPackageNameEdit = new QLineEdit(this); + + pLabel->setBuddy(m_pPackageNameEdit); + pLayout->addWidget(m_pPackageNameEdit,1,1); + + pLabel = new QLabel(this); + pLabel->setText(__tr2qs_ctx("Version:","theme")); + pLayout->addWidget(pLabel,2,0); + + m_pPackageVersionEdit = new QLineEdit(this); + + pLabel->setBuddy(m_pPackageVersionEdit); + pLayout->addWidget(m_pPackageVersionEdit,2,1); + + pLabel = new QLabel(this); + pLabel->setText(__tr2qs_ctx("Description:","theme")); + pLayout->addWidget(pLabel,3,0); + + m_pPackageDescriptionEdit = new QTextEdit(this); + + pLabel->setBuddy(m_pPackageDescriptionEdit); + pLayout->addWidget(m_pPackageDescriptionEdit,3,1); + + pLabel = new QLabel(this); + pLabel->setText(__tr2qs_ctx("Package Author:","theme")); + pLayout->addWidget(pLabel,4,0); + + m_pPackageAuthorEdit = new QLineEdit(this); + + pLabel->setBuddy(m_pPackageAuthorEdit); + pLayout->addWidget(m_pPackageAuthorEdit,4,1); + + pLayout->setRowStretch(3,1); + pLayout->setColumnStretch(1,1); + + // Store data in the fields + registerField("packageName*",m_pPackageNameEdit); + registerField("packageVersion*",m_pPackageVersionEdit); + registerField("packageDescription*",m_pPackageDescriptionEdit); + registerField("packageAuthor*",m_pPackageAuthorEdit); + +} +void PackThemeInfoWidget::initializePage() +{ + QString szPackageName = field("packageName").toString(); + QString szPackageVersion = field("packageVersion").toString(); + QString szPackageDescription = field("packageDescription").toString(); + QString szPackageAuthor = field("packageAuthor").toString(); + m_pPackageNameEdit->setText(szPackageName); + m_pPackageVersionEdit->setText(szPackageVersion); + m_pPackageDescriptionEdit->setText(szPackageDescription); + m_pPackageAuthorEdit->setText(szPackageAuthor); +} + +PackThemeInfoWidget::~PackThemeInfoWidget() +{ +} + +PackThemeImageWidget::PackThemeImageWidget(PackThemeDialog * pParent) +: QWizardPage(pParent) +{ + setObjectName("theme_package_image_page"); + setTitle(__tr2qs_ctx("Icon/Screenshot","theme")); + setSubTitle(__tr2qs_ctx("Here you can choose the image that will appear in the installation dialog for your theme package. It can be an icon, a logo or a screenshot and it should be not larger than 300x225. If you don't provide an image a simple default icon will be used at installation stage.","theme")); + + QVBoxLayout * pLayout = new QVBoxLayout(this); + + m_pImageLabel = new QLabel(this); + m_pImageLabel->setFrameStyle(QFrame::Sunken | QFrame::Panel); + m_pImageLabel->setMinimumSize(300,225); + m_pImageLabel->setAlignment(Qt::AlignCenter | Qt::AlignVCenter); + pLayout->addWidget(m_pImageLabel); + + m_pImageSelector = new KviFileSelector(this,"",&m_szImagePath,true,0,KVI_FILTER_IMAGE); + connect(m_pImageSelector,SIGNAL(selectionChanged(const QString &)),this,SLOT(imageSelectionChanged(const QString &))); + pLayout->addWidget(m_pImageSelector); + // Store data in the fields + registerField("packageImagePath*",m_pImageSelector); + + //m_pImageSelectionPage = pPage; +} + +PackThemeImageWidget::~PackThemeImageWidget() +{ +} + +void PackThemeImageWidget::imageSelectionChanged(const QString & szImagePath) +{ + QImage pix(szImagePath); + if(!pix.isNull()) + { + QPixmap out; + if(pix.width() > 300 || pix.height() > 225) + { + pix=pix.scaled(300,225,Qt::KeepAspectRatio,Qt::SmoothTransformation); + out=out.fromImage(pix); + } else { + out=out.fromImage(pix); + } + m_pImageLabel->setPixmap(out); + return; + } + + QMessageBox::critical(this,__tr2qs_ctx("Export Theme - KVIrc","theme"),__tr2qs_ctx("Failed to load the selected image","theme"), + QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); + + m_pImageSelector->setSelection(""); + m_pImageLabel->setPixmap(QPixmap()); +} + +PackThemeSaveWidget::PackThemeSaveWidget(PackThemeDialog * pParent) +: QWizardPage(pParent) +{ + setObjectName("theme_package_save_page"); + setTitle(__tr2qs_ctx("Package Path","theme")); + setSubTitle(__tr2qs_ctx("Here you must choose the file name for the theme package. It should have a *%1 extension.","theme").arg(KVI_FILEEXTENSION_THEMEPACKAGE)); + + QVBoxLayout * pLayout = new QVBoxLayout(this); + + QString szFilter = "*"; + szFilter += KVI_FILEEXTENSION_THEMEPACKAGE; + m_pSavePathSelector = new KviFileSelector(this,"",&m_szPackagePath,true,KviFileSelector::ChooseSaveFileName,szFilter); + pLayout->addWidget(m_pSavePathSelector); + + QLabel * pLabel = new QLabel(this); + pLabel->setWordWrap(true); + pLabel->setText(__tr2qs_ctx("Finally hit the \"Finish\" button to complete the packaging operation.","theme")); + pLayout->addWidget(pLabel); + + // Store data in the fields + registerField("packageSavePath*",m_pSavePathSelector); +} + +PackThemeSaveWidget::~PackThemeSaveWidget() +{ +} + +void PackThemeSaveWidget::initializePage() +{ + m_szPackagePath = field("packageSavePath").toString(); +} +#if 0 + if(!szScreenshotPath.isEmpty()) + { + m_pImageSelector->setSelection(szScreenshotPath); + imageSelectionChanged(szScreenshotPath); + } +} +#endif + +PackThemeDialog::~PackThemeDialog() +{ +} + +void PackThemeDialog::accept() +{ + if(!packTheme()) return; + QWizard::accept(); +} + +bool PackThemeDialog::packTheme() +{ + //m_pImageSelector->commit(); + //m_pPathSelector->commit(); + + // 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_szImagePath = field("packageImagePath").toString(); + m_szPackagePath = field("packageSavePath").toString(); + //m_szSavePath = field("packageSavePath").toString(); + + //return false; + + QImage pix(m_szImagePath); + QPixmap out; + if(!pix.isNull()) + { + if((pix.width() > 300) || (pix.height() > 225)) + { + out=out.fromImage(pix.scaled(300,225,Qt::KeepAspectRatio)); + } else { + out=out.fromImage(pix); + } + } else { + if(!m_szImagePath.isEmpty()) + { + QMessageBox::critical(this, + __tr2qs_ctx("Export Theme - KVIrc","theme"), + __tr2qs_ctx("Failed to load the selected image: please fix it","theme"), + QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton + ); + //setCurrentPage(m_pImageSelectionPage); + return false; + } + } + + KviPackageWriter f; + + QString szTmp; + QDateTime date = QDateTime::currentDateTime(); + + switch(KVI_OPTION_UINT(KviOption_uintOutputDatetimeFormat)) + { + case 0: + szTmp = date.toString(); + break; + case 1: + szTmp = date.toString(Qt::ISODate); + break; + case 2: + szTmp = date.toString(Qt::SystemLocaleDate); + break; + } + + f.addInfoField("PackageType","ThemePack"); + f.addInfoField("ThemePackVersion",KVI_CURRENT_THEME_ENGINE_VERSION); + f.addInfoField("Name",m_szName); + f.addInfoField("Version",m_szVersion); + f.addInfoField("Author",m_szAuthor); + f.addInfoField("Description",m_szDescription); + f.addInfoField("Date",szTmp); + f.addInfoField("Application","KVIrc " KVI_VERSION "." KVI_SOURCES_DATE); + + if(!out.isNull()) + { + QByteArray * pba = new QByteArray(); + QBuffer buffer(pba,0); + buffer.open(QIODevice::WriteOnly); + out.save(&buffer,"PNG"); + buffer.close(); + f.addInfoField("Image",pba); // cool :) [no disk access needed] + } + + szTmp.setNum(m_pThemeInfoList->count()); + f.addInfoField("ThemeCount",szTmp); + + int iIdx = 0; + for(KviThemeInfo * pInfo = m_pThemeInfoList->first(); pInfo; pInfo = m_pThemeInfoList->next()) + { + KviQString::sprintf(szTmp,"Theme%dName",iIdx); + f.addInfoField(szTmp,pInfo->name()); + KviQString::sprintf(szTmp,"Theme%dVersion",iIdx); + f.addInfoField(szTmp,pInfo->version()); + KviQString::sprintf(szTmp,"Theme%dDescription",iIdx); + f.addInfoField(szTmp,pInfo->description()); + KviQString::sprintf(szTmp,"Theme%dDate",iIdx); + f.addInfoField(szTmp,pInfo->date()); + KviQString::sprintf(szTmp,"Theme%dSubdirectory",iIdx); + f.addInfoField(szTmp,pInfo->subdirectory()); + KviQString::sprintf(szTmp,"Theme%dAuthor",iIdx); + f.addInfoField(szTmp,pInfo->author()); + KviQString::sprintf(szTmp,"Theme%dApplication",iIdx); + f.addInfoField(szTmp,pInfo->application()); + KviQString::sprintf(szTmp,"Theme%dThemeEngineVersion",iIdx); + f.addInfoField(szTmp,pInfo->themeEngineVersion()); + QPixmap pixScreenshot = pInfo->smallScreenshot(); + if(!pixScreenshot.isNull()) + { + KviQString::sprintf(szTmp,"Theme%dScreenshot",iIdx); + QByteArray * pba = new QByteArray(); + + QBuffer bufferz(pba,0); + bufferz.open(QIODevice::WriteOnly); + pixScreenshot.save(&bufferz,"PNG"); + bufferz.close(); + f.addInfoField(szTmp,pba); + } + + if(!f.addDirectory(pInfo->absoluteDirectory(),pInfo->subdirectory())) + { + szTmp = __tr2qs_ctx("Packaging failed","theme"); + szTmp += ": "; + szTmp += f.lastError(); + QMessageBox::critical(this, + __tr2qs_ctx("Export Theme - KVIrc","theme"), + szTmp, + QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton + ); + } + + iIdx++; + } + + if(!f.pack(m_szPackagePath)) + { + szTmp = __tr2qs_ctx("Packaging failed","theme"); + szTmp += ": "; + szTmp += f.lastError(); + QMessageBox::critical(this, + __tr2qs_ctx("Export Theme - KVIrc","theme"), + szTmp, + QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton + ); + + return false; + } + + //KviPackageReader r; + //r.unpack("/root/test.kvt","/root/unpacked_test_kvt"); + + QMessageBox::information(this, + __tr2qs_ctx("Export Theme - KVIrc","theme"), + __tr2qs("Package saved successfully"), + QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton + ); + + return true; +} diff --git a/src/modules/theme/PackThemeDialog.h b/src/modules/theme/PackThemeDialog.h new file mode 100644 index 000000000..920bed2a1 --- /dev/null +++ b/src/modules/theme/PackThemeDialog.h @@ -0,0 +1,124 @@ +#ifndef _PACKTHEMEDIALOG_H_ +#define _PACKTHEMEDIALOG_H_ +//============================================================================= +// +// File : PackThemeDialog.h +// Creation date : Wed 03 Jan 2007 01:11:44 by Szymon Stefanek +// +// This file is part of the KVIrc IRC Client distribution +// Copyright (C) 2007-2010 Szymon Stefanek +// Copyright (C) 2010 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 "KviPointerList.h" +#include "KviTheme.h" + +#include +#include + +class QLineEdit; +class QLabel; +class QTextEdit; +class KviFileSelector; + +class PackThemeDataWidget; +class PackThemeInfoWidget; +class PackThemeImageWidget; +class PackThemeSaveWidget; + +class PackThemeDialog : public QWizard +{ + Q_OBJECT +public: + PackThemeDialog(QWidget * pParent, KviPointerList * pThemeInfoList); + ~PackThemeDialog(); +protected: + PackThemeDataWidget * m_pPackThemeDataWidget; + PackThemeInfoWidget * m_pPackThemeInfoWidget; + PackThemeImageWidget * m_pPackThemeImageWidget; + PackThemeSaveWidget * m_pPackThemeSaveWidget; + KviPointerList * m_pThemeInfoList; + + QString m_szAuthor; + QString m_szName; + QString m_szVersion; + QString m_szDescription; + QString m_szImagePath; + QString m_szPackagePath; + QString m_szSavePath; + + //QWidget * m_pImageSelectionPage; +protected: + virtual void accept(); + bool packTheme(); +}; + +class PackThemeDataWidget : public QWizardPage +{ + Q_OBJECT +public: + PackThemeDataWidget(PackThemeDialog * pParent); + ~PackThemeDataWidget(); +public: + void parseThemes(KviPointerList * pThemeInfoList); +}; + +class PackThemeInfoWidget : public QWizardPage +{ + Q_OBJECT +public: + PackThemeInfoWidget(PackThemeDialog * pParent); + ~PackThemeInfoWidget(); +public: + QLineEdit * m_pPackageNameEdit; + QTextEdit * m_pPackageDescriptionEdit; + QLineEdit * m_pPackageVersionEdit; + QLineEdit * m_pPackageAuthorEdit; +protected: + virtual void initializePage(); +}; + +class PackThemeImageWidget : public QWizardPage +{ + Q_OBJECT +public: + PackThemeImageWidget(PackThemeDialog * pParent); + ~PackThemeImageWidget(); +protected: + KviFileSelector * m_pImageSelector; + QLabel * m_pImageLabel; + QString m_szImagePath; +protected slots: + void imageSelectionChanged(const QString & szImagePath); +}; + +class PackThemeSaveWidget : public QWizardPage +{ + Q_OBJECT +public: + PackThemeSaveWidget(PackThemeDialog * pParent); + ~PackThemeSaveWidget(); +protected: + KviFileSelector * m_pSavePathSelector; + QString m_szPackagePath; +protected: + virtual void initializePage(); +}; + +#endif //!_PACKTHEMEDIALOG_H_ diff --git a/src/modules/theme/SaveThemeDialog.cpp b/src/modules/theme/SaveThemeDialog.cpp new file mode 100644 index 000000000..388f7b163 --- /dev/null +++ b/src/modules/theme/SaveThemeDialog.cpp @@ -0,0 +1,306 @@ +//============================================================================= +// +// File : SaveThemeDialog.cpp +// Creation date : Wed 03 Jan 2007 03:01:34 by Szymon Stefanek +// +// This file is part of the KVIrc IRC Client distribution +// Copyright (C) 2007-2010 Szymon Stefanek +// +// 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 "SaveThemeDialog.h" +#include "ThemeFunctions.h" + +#include "KviOptions.h" +#include "KviLocale.h" +#include "KviConfigurationFile.h" +#include "KviFileUtils.h" +#include "KviApplication.h" +#include "KviMainWindow.h" +#include "KviIconManager.h" +#include "KviPackageWriter.h" +#include "kvi_fileextensions.h" +#include "KviFileDialog.h" +#include "KviMessageBox.h" +#include "KviSelectors.h" +#include "KviMiscUtils.h" +#include "kvi_sourcesdate.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + + +SaveThemeDialog::SaveThemeDialog(QWidget * pParent) +: KviTalWizard(pParent) +{ + setWindowTitle(__tr2qs_ctx("Save Current Theme - KVIrc","theme")); + setMinimumSize(400,350); + + // welcome page ================================================================================== + QWidget * pPage = new QWidget(this); + QGridLayout * pLayout = new QGridLayout(pPage); + + QLabel * pLabel = new QLabel(pPage); + pLabel->setWordWrap(true); + QString szText = "

"; + szText += __tr2qs_ctx("This procedure allows you to save the current theme settings to a single directory. It is useful if you want to apply other themes or play with the theme settings and later come back to this theme with a single click. It will also allow you to manually modify the theme settings and later export them to a distributable package.","theme"); + szText += "

"; + szText += __tr2qs_ctx("You will be asked to provide a theme name, a description and, if you want, a screenshot.","theme"); + szText += "

"; + szText += __tr2qs_ctx("Hit the \"Next\" button to begin.","theme"); + szText += "

"; + + pLabel->setText(szText); + pLayout->addWidget(pLabel,0,0); + pLayout->setRowStretch(1,1); + + addPage(pPage,__tr2qs_ctx("Welcome","theme")); + setBackEnabled(pPage,false); + setNextEnabled(pPage,true); + setHelpEnabled(pPage,false); + setFinishEnabled(pPage,false); + + // packager information ================================================================================ + + pPage = new QWidget(this); + pLayout = new QGridLayout(pPage); + + pLabel = new QLabel(pPage); + pLabel->setText(__tr2qs_ctx("Here you need to provide information about you (the author) and a short description of the theme you're creating.","theme")); + pLabel->setWordWrap(true); + pLabel->setTextFormat(Qt::RichText); + pLayout->addWidget(pLabel,0,0,1,2); + + pLabel = new QLabel(pPage); + pLabel->setText(__tr2qs_ctx("Theme Name:","theme")); + pLayout->addWidget(pLabel,1,0); + + m_pThemeNameEdit = new QLineEdit(pPage); + //m_pThemeNameEdit->setText(szThemeName); + pLayout->addWidget(m_pThemeNameEdit,1,1); + + pLabel = new QLabel(pPage); + pLabel->setText(__tr2qs_ctx("Version:","theme")); + pLayout->addWidget(pLabel,2,0); + + m_pThemeVersionEdit = new QLineEdit(pPage); + //m_pThemeVersionEdit->setText(szThemeVersion); + pLayout->addWidget(m_pThemeVersionEdit,2,1); + + pLabel = new QLabel(pPage); + pLabel->setText(__tr2qs_ctx("Description:","theme")); + pLayout->addWidget(pLabel,3,0); + + m_pThemeDescriptionEdit = new QTextEdit(pPage); + //m_pThemeDescriptionEdit->setText(szThemeDescription); + pLayout->addWidget(m_pThemeDescriptionEdit,3,1); + + pLabel = new QLabel(pPage); + pLabel->setText(__tr2qs_ctx("Theme Author:","theme")); + pLayout->addWidget(pLabel,4,0); + + m_pAuthorNameEdit = new QLineEdit(pPage); + //m_pAuthorNameEdit->setText(szThemeAuthor); + pLayout->addWidget(m_pAuthorNameEdit,4,1); + + + pLayout->setRowStretch(3,1); + pLayout->setColumnStretch(1,1); + + addPage(pPage,__tr2qs_ctx("Theme Information","theme")); + setBackEnabled(pPage,true); + setHelpEnabled(pPage,false); + setNextEnabled(pPage,true); + setFinishEnabled(pPage,false); + + // screenshot/logo/icon ================================================================================ + + pPage = new QWidget(this); + pLayout = new QGridLayout(pPage); + + pLabel = new QLabel(pPage); + pLabel->setText(__tr2qs_ctx("Here you can either choose a screenshot image from disk or make one now. The screenshot will be displayed in the tooltips of the theme management dialog and will be also visible in the package installation dialog if you will export the theme to a distributable package.","theme")); + pLabel->setWordWrap(true); + pLabel->setTextFormat(Qt::RichText); + pLayout->addWidget(pLabel,0,0); + + m_pImageLabel = new QLabel(pPage); + m_pImageLabel->setFrameStyle(QFrame::Sunken | QFrame::Panel); + m_pImageLabel->setMinimumSize(300,225); + m_pImageLabel->setAlignment(Qt::AlignCenter | Qt::AlignVCenter); + pLayout->addWidget(m_pImageLabel,1,0); + + m_pImageSelector = new KviFileSelector(pPage,"",&m_szScreenshotPath,true,0,KVI_FILTER_IMAGE); + connect(m_pImageSelector,SIGNAL(selectionChanged(const QString &)),this,SLOT(imageSelectionChanged(const QString &))); + pLayout->addWidget(m_pImageSelector,2,0); + + QPushButton * pButton = new QPushButton(pPage); + pButton->setText(__tr2qs_ctx("Make Screenshot Now","theme")); + connect(pButton,SIGNAL(clicked()),this,SLOT(makeScreenshot())); + pLayout->addWidget(pButton,3,0); + + pLayout->setRowStretch(1,1); + + m_pImageSelectionPage = pPage; + addPage(pPage,__tr2qs_ctx("Screenshot","theme")); + setBackEnabled(pPage,true); + setHelpEnabled(pPage,false); + setNextEnabled(pPage,true); + setFinishEnabled(pPage,true); +} + +SaveThemeDialog::~SaveThemeDialog() +{ +} + +void SaveThemeDialog::imageSelectionChanged(const QString &szImagePath) +{ + QImage pix(szImagePath); + if(!pix.isNull()) + { + QPixmap out; + if(pix.width() > 300 || pix.height() > 225) + out = QPixmap::fromImage(pix.scaled(300,225,Qt::KeepAspectRatio)); + else + out = QPixmap::fromImage(pix); + m_pImageLabel->setPixmap(out); + return; + } + + QMessageBox::critical(this,__tr2qs_ctx("Save Current Theme - KVIrc","theme"),__tr2qs_ctx("Failed to load the selected image","theme"), + QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); + + m_pImageSelector->setSelection(""); + m_pImageLabel->setPixmap(QPixmap()); +} + +void SaveThemeDialog::accept() +{ + if(!saveTheme())return; + KviTalWizard::accept(); +} + +void SaveThemeDialog::makeScreenshot() +{ + QString szFileName; + g_pApp->getTmpFileName(szFileName,"screenshot.png"); + if(!ThemeFunctions::makeKVIrcScreenshot(szFileName)) + { + QMessageBox::critical(this,__tr2qs_ctx("Acquire Screenshot - KVIrc","theme"),__tr2qs_ctx("Failed to make screenshot","theme"), + QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); + return; + } + m_pImageSelector->setSelection(szFileName); + imageSelectionChanged(szFileName); +} + +bool SaveThemeDialog::saveTheme() +{ + m_pImageSelector->commit(); + + KviThemeInfo sto; + sto.setName(m_pThemeNameEdit->text()); + if(sto.name().isEmpty()) + { + QMessageBox::critical(this,__tr2qs_ctx("Save Current Theme - KVIrc","theme"),__tr2qs_ctx("You must choose a theme name!","theme"),QMessageBox::Ok, + QMessageBox::NoButton,QMessageBox::NoButton); + return false; + } + + sto.setAuthor(m_pAuthorNameEdit->text()); + sto.setDescription(m_pThemeDescriptionEdit->toPlainText()); + + QString szTmp; + QDateTime date = QDateTime::currentDateTime(); + switch(KVI_OPTION_UINT(KviOption_uintOutputDatetimeFormat)) + { + case 0: + szTmp = date.toString(); + break; + case 1: + szTmp = date.toString(Qt::ISODate); + break; + case 2: + szTmp = date.toString(Qt::SystemLocaleDate); + break; + } + + sto.setDate(szTmp); + sto.setVersion(m_pThemeVersionEdit->text()); + sto.setApplication("KVIrc " KVI_VERSION "." KVI_SOURCES_DATE); + + if(sto.version().isEmpty())sto.setVersion("1.0.0"); + + QString szSubdir = sto.name() + QString("-") + sto.version(); + szSubdir.replace(QRegExp("[ \\\\/:][ \\\\/:]*"),"_"); + sto.setSubdirectory(szSubdir); + + QString szAbsDir; + g_pApp->getLocalKvircDirectory(szAbsDir,KviApplication::Themes,sto.subdirectory(),true); + if(!KviFileUtils::makeDir(szAbsDir)) + { + QMessageBox::critical(this,__tr2qs_ctx("Save Current Theme - KVIrc","theme"),__tr2qs_ctx("Unable to create theme directory.","theme"), + QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); + return false; + } + + sto.setAbsoluteDirectory(szAbsDir); + + if(!KviTheme::save(sto)) + { + QString szMsg2; + QString szErr = sto.lastError(); + KviQString::sprintf(szMsg2,__tr2qs_ctx("Unable to save theme: %Q","theme"),&szErr); + QMessageBox::critical(this,__tr2qs_ctx("Save Current Theme - KVIrc","theme"),szMsg2, + QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); + return false; + } + // write down the screenshot, if needed + + if(!m_szScreenshotPath.isEmpty()) + { + if(!KviTheme::saveScreenshots(sto,m_szScreenshotPath)) + { + QMessageBox::critical(this,__tr2qs_ctx("Save Current Theme - KVIrc","theme"),__tr2qs_ctx("Failed to load the selected screenshot image: please fix it","theme"), + QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); + setCurrentPage(m_pImageSelectionPage); + return false; + } + } + + QString szMsg = __tr2qs_ctx("Theme saved successfully to ","theme"); + szMsg += sto.absoluteDirectory(); + + QMessageBox::information(this,__tr2qs_ctx("Save Theme - KVIrc","theme"),szMsg,QMessageBox::Ok, + QMessageBox::NoButton,QMessageBox::NoButton); + + return true; +} diff --git a/src/modules/theme/SaveThemeDialog.h b/src/modules/theme/SaveThemeDialog.h new file mode 100644 index 000000000..f28347be7 --- /dev/null +++ b/src/modules/theme/SaveThemeDialog.h @@ -0,0 +1,66 @@ +#ifndef _SAVETHEMEDIALOG_H_ +#define _SAVETHEMEDIALOG_H_ +//============================================================================= +// +// File : SaveThemeDialog.h +// Creation date : Wed 03 Jan 2007 03:01:34 by Szymon Stefanek +// +// This file is part of the KVIrc IRC Client distribution +// Copyright (C) 2007-2010 Szymon Stefanek +// +// 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 "KviPointerList.h" +#include "KviTheme.h" +#include "KviTalWizard.h" + +#include + +class QLineEdit; +class QPushButton; +class QLabel; +class QTextEdit; +class KviFileSelector; + + +class SaveThemeDialog : public KviTalWizard +{ + Q_OBJECT +public: + SaveThemeDialog(QWidget * pParent); + virtual ~SaveThemeDialog(); +protected: + QString m_szScreenshotPath; + KviFileSelector * m_pImageSelector; + QLabel * m_pImageLabel; + QLineEdit * m_pThemeNameEdit; + QTextEdit * m_pThemeDescriptionEdit; + QLineEdit * m_pThemeVersionEdit; + QLineEdit * m_pAuthorNameEdit; + QWidget * m_pImageSelectionPage; + QPushButton * m_pOkButton; +protected: + virtual void accept(); + bool saveTheme(); +protected slots: + void makeScreenshot(); + void imageSelectionChanged(const QString & szImagePath); + //void themeNameChanged(const QString &txt); +}; + +#endif //!_SAVETHEMEDIALOG_H_ diff --git a/src/modules/theme/ThemeFunctions.cpp b/src/modules/theme/ThemeFunctions.cpp new file mode 100644 index 000000000..f1062cb94 --- /dev/null +++ b/src/modules/theme/ThemeFunctions.cpp @@ -0,0 +1,405 @@ +//============================================================================= +// +// File : ThemeFunctions.cpp +// Creation date : Wed 03 Jan 2007 03:14:07 by Szymon Stefanek +// +// This file is part of the KVIrc IRC Client distribution +// Copyright (C) 2007-2010 Szymon Stefanek +// +// 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 "ThemeFunctions.h" + +#include "KviPackageReader.h" +#include "KviLocale.h" +#include "KviMessageBox.h" +#include "KviApplication.h" +#include "KviHtmlDialog.h" +#include "KviIconManager.h" +#include "KviMiscUtils.h" +#include "kvi_sourcesdate.h" +#include "KviTheme.h" +#include "KviMainWindow.h" + + +//#include + + +namespace ThemeFunctions +{ + + static bool notAValidThemePackage(QString &szError) + { + szError = __tr2qs_ctx("The selected file does not seem to be a valid KVIrc theme package","theme"); + return false; + } + + bool installThemePackage(const QString &szThemePackageFileName,QString &szError,QWidget * pDialogParent) + { + KviPointerHashTable * pInfoFields; + QString * pValue; + bool bInstall; + QPixmap pix; + QByteArray * pByteArray; + KviHtmlDialogData hd; + + const char * check_fields[] = { "Name", "Version", "Author", "Description", "Date", "Application" }; + + // check if it is a valid theme file + KviPackageReader r; + + if(!r.readHeader(szThemePackageFileName)) + { + QString szErr = r.lastError(); + KviQString::sprintf(szError,__tr2qs_ctx("The selected file does not seem to be a valid KVIrc package: %Q","theme"),&szErr); + return false; + } + + pInfoFields = r.stringInfoFields(); + + pValue = pInfoFields->find("PackageType"); + if(!pValue) + return notAValidThemePackage(szError); + + if(!KviQString::equalCI(*pValue,"ThemePack")) + return notAValidThemePackage(szError); + + pValue = pInfoFields->find("ThemePackVersion"); + + if(!pValue) + return notAValidThemePackage(szError); + + // make sure the default fields exist + for(int i=0;i<6;i++) + { + pValue = pInfoFields->find(check_fields[i]); + if(!pValue)return notAValidThemePackage(szError); + } + + pValue = pInfoFields->find("ThemeCount"); + if(!pValue) + return notAValidThemePackage(szError); + + bool bOk; + int iThemeCount = pValue->toInt(&bOk); + if(!bOk) + return notAValidThemePackage(szError); + + if(iThemeCount < 1) + return notAValidThemePackage(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_THEME)); + } + + QString szPackageName; + QString szPackageVersion; + QString szPackageAuthor; + QString szPackageDescription; + QString szPackageDate; + QString szPackageThemeEngineVersion; + QString szPackageApplication; + + QString szAuthor = __tr2qs_ctx("Author","theme"); + QString szCreatedAt = __tr2qs_ctx("Created at","theme"); + QString szCreatedOn = __tr2qs_ctx("Created with","theme"); + + r.getStringInfoField("Name",szPackageName); + r.getStringInfoField("Version",szPackageVersion); + r.getStringInfoField("Author",szPackageAuthor); + r.getStringInfoField("Description",szPackageDescription); + r.getStringInfoField("Application",szPackageApplication); + r.getStringInfoField("Date",szPackageDate); + + QString szWarnings; + QString szDetails = ""; + QString szTmp; + + int iIdx = 0; + int iValidThemeCount = iThemeCount; + + while(iIdx < iThemeCount) + { + bool bValid = true; + + QString szThemeName; + QString szThemeVersion; + QString szThemeDescription; + QString szThemeDate; + QString szThemeSubdirectory; + QString szThemeAuthor; + QString szThemeEngineVersion; + QString szThemeApplication; + + KviQString::sprintf(szTmp,"Theme%dName",iIdx); + r.getStringInfoField(szTmp,szThemeName); + KviQString::sprintf(szTmp,"Theme%dVersion",iIdx); + r.getStringInfoField(szTmp,szThemeVersion); + KviQString::sprintf(szTmp,"Theme%dApplication",iIdx); + r.getStringInfoField(szTmp,szThemeApplication); + KviQString::sprintf(szTmp,"Theme%dDescription",iIdx); + r.getStringInfoField(szTmp,szThemeDescription); + KviQString::sprintf(szTmp,"Theme%dDate",iIdx); + r.getStringInfoField(szTmp,szThemeDate); + KviQString::sprintf(szTmp,"Theme%dSubdirectory",iIdx); + r.getStringInfoField(szTmp,szThemeSubdirectory); + KviQString::sprintf(szTmp,"Theme%dAuthor",iIdx); + r.getStringInfoField(szTmp,szThemeAuthor); + KviQString::sprintf(szTmp,"Theme%dThemeEngineVersion",iIdx); + r.getStringInfoField(szTmp,szThemeEngineVersion); + KviQString::sprintf(szTmp,"Theme%dScreenshot",iIdx); + QPixmap pixScreenshot; + pByteArray = r.binaryInfoFields()->find(szTmp); + if(pByteArray) + pixScreenshot.loadFromData(*pByteArray,0,0); + + if(szThemeName.isEmpty() || szThemeVersion.isEmpty() || szThemeSubdirectory.isEmpty() || szThemeEngineVersion.isEmpty()) + bValid = false; + if(KviMiscUtils::compareVersions(szThemeEngineVersion,KVI_CURRENT_THEME_ENGINE_VERSION) < 0) + bValid = false; + + QString szDetailsBuffer; + + getThemeHtmlDescription( + szDetailsBuffer, + szThemeName, + szThemeVersion, + szThemeDescription, + szThemeSubdirectory, + szThemeApplication, + szThemeAuthor, + szThemeDate, + szThemeEngineVersion, + pixScreenshot, + iIdx,&hd + ); + + if(iIdx > 0) + szDetails += "


"; + + szDetails += szDetailsBuffer; + + if(!bValid) + { + szDetails += "

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

"; + iValidThemeCount--; + } + + iIdx++; + } + + szDetails += "

"; + szDetails += __tr2qs_ctx("Go Back to Package Data","theme"); + szDetails += "

"; + szDetails += ""; + + if(iValidThemeCount < iThemeCount) + { + szWarnings += "

"; + szWarnings += __tr2qs_ctx("Warning: Some of the theme contained in this package might be either corrupted or incompatible with this version of KVIrc","theme"); + szWarnings += "

"; + } + + QString szShowDetails = __tr2qs_ctx("Show Details","theme"); + + KviQString::sprintf(hd.szHtmlText, + "" \ + "" \ + "

" \ + "

%Q %Q

" \ + "

" \ + "

" \ + "" \ + "

" \ + "

" \ + "%Q" \ + "

" \ + "

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

" \ + "

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

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

" \ + "%Q" \ + "

" \ + "" \ + "", + &szPackageName, + &szPackageVersion, + &szPackageDescription, + &szAuthor, + &szPackageAuthor, + &szCreatedAt, + &szPackageDate, + &szCreatedOn, + &szPackageApplication, + &szWarnings, + &szShowDetails + ); + + hd.addImageResource("theme_dialog_pack_image",pix); + hd.addHtmlResource("theme_dialog_details",szDetails); + hd.addHtmlResource("theme_dialog_main",hd.szHtmlText); + + QString beginCenter = "
"; + QString endCenter = "
"; + + hd.szCaption = __tr2qs_ctx("Install Theme Pack - KVIrc","theme"); + hd.szUpperLabelText = beginCenter + __tr2qs_ctx("You're about to install the following theme package","theme") + endCenter; + hd.szLowerLabelText = beginCenter + __tr2qs_ctx("Do you want to proceed with the installation ?","theme") + endCenter; + hd.szButton1Text = __tr2qs_ctx("Do Not Install","theme"); + hd.szButton2Text = __tr2qs_ctx("Yes, Proceed","theme"); + hd.iDefaultButton = 2; + hd.iCancelButton = 1; + hd.pixIcon = *(g_pIconManager->getSmallIcon(KVI_SMALLICON_THEME)); + hd.iMinimumWidth = 350; + hd.iMinimumHeight = 420; + hd.iFlags = KviHtmlDialogData::ForceMinimumSize; + + bInstall = KviHtmlDialog::display(pDialogParent,&hd) == 2; + if(bInstall) + { + QString szUnpackPath; + g_pApp->getLocalKvircDirectory(szUnpackPath,KviApplication::Themes); + if(!r.unpack(szThemePackageFileName,szUnpackPath)) + { + QString szErr2 = r.lastError(); + KviQString::sprintf(szError,__tr2qs_ctx("Failed to unpack the selected file: %Q","theme"),&szErr2); + return false; + } + } + + return true; + } + + + void getThemeHtmlDescription( + QString &szBuffer, + const QString &szThemeName, + const QString &szThemeVersion, + const QString &szThemeDescription, + const QString &szThemeSubdirectory, + const QString &szThemeApplication, + const QString &szThemeAuthor, + const QString &szThemeDate, + const QString &szThemeThemeEngineVersion, + const QPixmap &pixScreenshot, + int iUniqueIndexInDocument, + KviHtmlDialogData *hd + ) + { + QString szAuthor = __tr2qs_ctx("Author","theme"); + QString szCreatedAt = __tr2qs_ctx("Created at","theme"); + QString szCreatedOn = __tr2qs_ctx("Created with","theme"); + QString szThemeEngineVersion = __tr2qs_ctx("Theme Engine Version","theme"); + QString szSubdirectory = __tr2qs_ctx("Subdirectory","theme"); + + QString szScreenshot; + if(!pixScreenshot.isNull()) + { + KviQString::sprintf(szScreenshot,"

",iUniqueIndexInDocument); + QString szTmp; + KviQString::sprintf(szTmp,"theme_shot%d",iUniqueIndexInDocument); + //FIXME in tooltip + if (hd) + hd->addImageResource(szTmp,pixScreenshot); + else szScreenshot = ""; + } else { + szScreenshot = ""; + } + + KviQString::sprintf( + szBuffer, + "

" \ + "

%Q %Q

" \ + "

" \ + "%Q" \ + "

" \ + "%Q" \ + "

" \ + "

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

" \ + "

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

", + &szThemeName, + &szThemeVersion, + &szScreenshot, + &szThemeDescription, + &szAuthor, + &szThemeAuthor, + &szCreatedAt, + &szThemeDate, + &szCreatedOn, + &szThemeApplication, + &szThemeEngineVersion, + &szThemeThemeEngineVersion, + &szSubdirectory, + &szThemeSubdirectory + ); + } + + bool makeKVIrcScreenshot(const QString &szSavePngFilePath,bool bMaximizeFrame) + { + if(bMaximizeFrame) + { + if(g_pFrame->isMaximized()) + bMaximizeFrame = false; + } + + if(bMaximizeFrame) + g_pFrame->showMaximized(); + + QPixmap pix = QPixmap::grabWidget(g_pFrame); + bool bResult = true; + + if(pix.isNull()) + bResult = false; + else { + if(!pix.save(szSavePngFilePath,"PNG")) + bResult = false; + } + + if(bMaximizeFrame) + g_pFrame->showNormal(); + return bResult; + } +} + diff --git a/src/modules/theme/ThemeFunctions.h b/src/modules/theme/ThemeFunctions.h new file mode 100644 index 000000000..08cf1b4b9 --- /dev/null +++ b/src/modules/theme/ThemeFunctions.h @@ -0,0 +1,57 @@ +#ifndef _THEMEFUNCTIONS_H_ +#define _THEMEFUNCTIONS_H_ +//============================================================================= +// +// File : ThemeFunctions.h +// Creation date : Wed 03 Jan 2007 03:14:07 by Szymon Stefanek +// +// This file is part of the KVIrc IRC Client distribution +// Copyright (C) 2007-2010 Szymon Stefanek +// +// 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 "KviHtmlDialog.h" + +#include +#include + +namespace ThemeFunctions +{ + bool installThemePackage(const QString &szThemePackageFileName,QString &szError,QWidget * pDialogParent = 0); + void getThemeHtmlDescription( + QString &szBuffer, + const QString &szThemeName, + const QString &szThemeVersion, + const QString &szThemeDescription, + const QString &szThemeSubdirectory, + const QString &szThemeApplication, + const QString &szThemeAuthor, + const QString &szThemeDate, + const QString &szThemeThemeEngineVersion, + const QPixmap &pixScreenshot, + int iUniqueIndexInDocument = 0, + KviHtmlDialogData *hd=0 + + ); + bool makeKVIrcScreenshot(const QString &szSavePngFilePath,bool bMaximizeFrame = false); +} + + + +#endif //!_THEMEFUNCTIONS_H_ diff --git a/src/modules/theme/libkvitheme.cpp b/src/modules/theme/libkvitheme.cpp index f21979048..d17b3fe7f 100644 --- a/src/modules/theme/libkvitheme.cpp +++ b/src/modules/theme/libkvitheme.cpp @@ -23,7 +23,7 @@ //============================================================================= #include "managementdialog.h" -#include "themefunctions.h" +#include "ThemeFunctions.h" #include "KviMessageBox.h" #include "KviModule.h" @@ -70,7 +70,7 @@ static bool theme_kvs_cmd_install(KviKvsModuleCommandCall * c) KVSM_PARAMETERS_END(c) QString szError; - if(!KviThemeFunctions::installThemePackage(szThemePackFile,szError)) + if(!ThemeFunctions::installThemePackage(szThemePackFile,szError)) { c->error(__tr2qs_ctx("Error installing theme package: %Q","theme"),&szError); return false; @@ -245,7 +245,7 @@ static bool theme_kvs_cmd_screenshot(KviKvsModuleCommandCall * c) szFileName+=".png"; QString szError; - if(!KviThemeFunctions::makeKVIrcScreenshot(szFileName)) + if(!ThemeFunctions::makeKVIrcScreenshot(szFileName)) { c->error(__tr2qs_ctx("Error making screenshot","theme")); // FIXME: a nicer error ? return false; @@ -273,7 +273,7 @@ static bool theme_kvs_cmd_screenshot(KviKvsModuleCommandCall * c) static bool theme_kvs_cmd_dialog(KviKvsModuleCommandCall *c) { - KviThemeManagementDialog::display(c->hasSwitch('t',"toplevel")); + ThemeManagementDialog::display(c->hasSwitch('t',"toplevel")); return true; } @@ -297,7 +297,7 @@ static bool theme_module_init(KviModule *m) static bool theme_module_cleanup(KviModule *m) { - KviThemeManagementDialog::cleanup(); + ThemeManagementDialog::cleanup(); QString szBuf; m->getDefaultConfigFileName(szBuf); @@ -309,7 +309,7 @@ static bool theme_module_cleanup(KviModule *m) static bool theme_module_can_unload(KviModule *) { - return (!KviThemeManagementDialog::instance()); + return (!ThemeManagementDialog::instance()); } diff --git a/src/modules/theme/managementdialog.cpp b/src/modules/theme/managementdialog.cpp index 6e9032bd9..5595cd19e 100644 --- a/src/modules/theme/managementdialog.cpp +++ b/src/modules/theme/managementdialog.cpp @@ -23,9 +23,9 @@ //============================================================================= #include "managementdialog.h" -#include "packthemedialog.h" -#include "savethemedialog.h" -#include "themefunctions.h" +#include "PackThemeDialog.h" +#include "SaveThemeDialog.h" +#include "ThemeFunctions.h" #include "KviOptions.h" #include "KviLocale.h" @@ -67,7 +67,7 @@ extern QRect g_rectManagementDialogGeometry; -KviThemeListWidgetItem::KviThemeListWidgetItem(KviTalListWidget * box,KviThemeInfo * inf) +ThemeListWidgetItem::ThemeListWidgetItem(KviTalListWidget * box,KviThemeInfo * inf) : KviTalListWidgetItem(box) { m_pThemeInfo = inf; @@ -97,16 +97,16 @@ KviThemeListWidgetItem::KviThemeListWidgetItem(KviTalListWidget * box,KviThemeIn setText(t); } -KviThemeListWidgetItem::~KviThemeListWidgetItem() +ThemeListWidgetItem::~ThemeListWidgetItem() { delete m_pThemeInfo; } -KviThemeManagementDialog * KviThemeManagementDialog::m_pInstance = 0; +ThemeManagementDialog * ThemeManagementDialog::m_pInstance = 0; -KviThemeManagementDialog::KviThemeManagementDialog(QWidget * parent) +ThemeManagementDialog::ThemeManagementDialog(QWidget * parent) : QWidget(parent) { m_pItemDelegate=0; @@ -211,20 +211,20 @@ KviThemeManagementDialog::KviThemeManagementDialog(QWidget * parent) g_rectManagementDialogGeometry.y()); } -KviThemeManagementDialog::~KviThemeManagementDialog() +ThemeManagementDialog::~ThemeManagementDialog() { if (m_pItemDelegate) delete m_pItemDelegate; g_rectManagementDialogGeometry = QRect(pos().x(),pos().y(),size().width(),size().height()); m_pInstance = 0; } -void KviThemeManagementDialog::closeClicked() +void ThemeManagementDialog::closeClicked() { delete this; m_pInstance = 0; } -void KviThemeManagementDialog::display(bool bTopLevel) +void ThemeManagementDialog::display(bool bTopLevel) { if(m_pInstance) { @@ -243,9 +243,9 @@ void KviThemeManagementDialog::display(bool bTopLevel) } else { if(bTopLevel) { - m_pInstance = new KviThemeManagementDialog(0); + m_pInstance = new ThemeManagementDialog(0); } else { - m_pInstance = new KviThemeManagementDialog(g_pFrame->splitter()); + m_pInstance = new ThemeManagementDialog(g_pFrame->splitter()); } } m_pInstance->show(); @@ -253,28 +253,28 @@ void KviThemeManagementDialog::display(bool bTopLevel) m_pInstance->setFocus(); } -void KviThemeManagementDialog::cleanup() +void ThemeManagementDialog::cleanup() { if(!m_pInstance)return; delete m_pInstance; m_pInstance = 0; } -void KviThemeManagementDialog::packTheme() +void ThemeManagementDialog::packTheme() { KviPointerList dl; dl.setAutoDelete(false); QList itemsSelected = m_pListWidget->selectedItems (); for(int i=0;ithemeInfo()); + dl.append(((ThemeListWidgetItem *)itemsSelected.at(i))->themeInfo()); if(dl.isEmpty())return; - KviPackThemeDialog * pDialog = new KviPackThemeDialog(this,&dl); + PackThemeDialog * pDialog = new PackThemeDialog(this,&dl); pDialog->exec(); delete pDialog; } -void KviThemeManagementDialog::contextMenuRequested(const QPoint & pos) +void ThemeManagementDialog::contextMenuRequested(const QPoint & pos) { if(m_pListWidget->itemAt(pos)!=0) { @@ -286,15 +286,15 @@ void KviThemeManagementDialog::contextMenuRequested(const QPoint & pos) } } -void KviThemeManagementDialog::applyTheme ( QListWidgetItem * it) +void ThemeManagementDialog::applyTheme ( QListWidgetItem * it) { if(it)m_pListWidget->setCurrentItem(it); applyCurrentTheme(); } -void KviThemeManagementDialog::applyCurrentTheme() +void ThemeManagementDialog::applyCurrentTheme() { - KviThemeListWidgetItem * it = (KviThemeListWidgetItem *)m_pListWidget->currentItem(); + ThemeListWidgetItem * it = (ThemeListWidgetItem *)m_pListWidget->currentItem(); if(!it)return; if(KviMessageBox::yesNo(__tr2qs_ctx("Apply theme - KVIrc","theme"), @@ -318,28 +318,28 @@ void KviThemeManagementDialog::applyCurrentTheme() } } -void KviThemeManagementDialog::deleteTheme() +void ThemeManagementDialog::deleteTheme() { QList itemsSelected = m_pListWidget->selectedItems (); for(int i=0;ithemeInfo()->name()),&(((KviThemeListWidgetItem *)itemsSelected.at(i))->themeInfo()->version())))goto jump_out; - KviFileUtils::deleteDir(((KviThemeListWidgetItem *)itemsSelected.at(i))->themeInfo()->absoluteDirectory()); + &(((ThemeListWidgetItem *)itemsSelected.at(i))->themeInfo()->name()),&(((ThemeListWidgetItem *)itemsSelected.at(i))->themeInfo()->version())))goto jump_out; + KviFileUtils::deleteDir(((ThemeListWidgetItem *)itemsSelected.at(i))->themeInfo()->absoluteDirectory()); } jump_out: fillThemeBox(); } -void KviThemeManagementDialog::installFromFile() +void ThemeManagementDialog::installFromFile() { QString szFileName; QString szError; if(!KviFileDialog::askForOpenFileName(szFileName,__tr2qs_ctx("Open Theme - KVIrc","theme"),QString(),KVI_FILTER_THEME)) return; - if(!KviThemeFunctions::installThemePackage(szFileName,szError,this)) + if(!ThemeFunctions::installThemePackage(szFileName,szError,this)) { KviMessageBox::information(szError); return; @@ -347,21 +347,21 @@ void KviThemeManagementDialog::installFromFile() fillThemeBox(); } -void KviThemeManagementDialog::getMoreThemes() +void ThemeManagementDialog::getMoreThemes() { if(!g_pFrame)return; g_pFrame->executeInternalCommand(KVI_INTERNALCOMMAND_OPENURL_KVIRC_THEMES); } -void KviThemeManagementDialog::saveCurrentTheme() +void ThemeManagementDialog::saveCurrentTheme() { - KviSaveThemeDialog * pSaveThemeDialog = new KviSaveThemeDialog(this); + SaveThemeDialog * pSaveThemeDialog = new SaveThemeDialog(this); pSaveThemeDialog->exec(); delete pSaveThemeDialog; fillThemeBox(); } -void KviThemeManagementDialog::fillThemeBox(const QString &szDir) +void ThemeManagementDialog::fillThemeBox(const QString &szDir) { QDir d(szDir); @@ -380,14 +380,14 @@ void KviThemeManagementDialog::fillThemeBox(const QString &szDir) if(inf->loadFromDirectory(szTest)) { inf->setSubdirectory(*it); - new KviThemeListWidgetItem(m_pListWidget,inf); + new ThemeListWidgetItem(m_pListWidget,inf); } else { delete inf; } } } -void KviThemeManagementDialog::fillThemeBox() +void ThemeManagementDialog::fillThemeBox() { m_pListWidget->clear(); @@ -400,39 +400,39 @@ void KviThemeManagementDialog::fillThemeBox() enableDisableButtons(); } -bool KviThemeManagementDialog::hasSelectedItems() +bool ThemeManagementDialog::hasSelectedItems() { QList itemsSelected = m_pListWidget->selectedItems (); return itemsSelected.count()?true:false; } -void KviThemeManagementDialog::enableDisableButtons() +void ThemeManagementDialog::enableDisableButtons() { bool b = hasSelectedItems(); m_pPackThemeButton->setEnabled(b); m_pDeleteThemeButton->setEnabled(b); } -void KviThemeManagementDialog::closeEvent(QCloseEvent * e) +void ThemeManagementDialog::closeEvent(QCloseEvent * e) { e->ignore(); delete this; } -void KviThemeManagementDialog::tipRequest(QListWidgetItem *,const QPoint &) +void ThemeManagementDialog::tipRequest(QListWidgetItem *,const QPoint &) { // FIXME /* - //KviThemeListWidgetItem * it = (KviThemeListWidgetItem *)(m_pListWidget->itemAt(pnt)); + //ThemeListWidgetItem * it = (ThemeListWidgetItem *)(m_pListWidget->itemAt(pnt)); //if(!it)return; - KviThemeInfo * pThemeInfo = ((KviThemeListWidgetItem *)it)->themeInfo(); + KviThemeInfo * pThemeInfo = ((ThemeListWidgetItem *)it)->themeInfo(); QString szThemeDescription; - KviThemeFunctions::getThemeHtmlDescription( + ThemeFunctions::getThemeHtmlDescription( szThemeDescription, pThemeInfo->name(), pThemeInfo->version(), diff --git a/src/modules/theme/managementdialog.h b/src/modules/theme/managementdialog.h index be5995c3c..beed4ade9 100644 --- a/src/modules/theme/managementdialog.h +++ b/src/modules/theme/managementdialog.h @@ -45,11 +45,11 @@ class QLabel; class KviDynamicToolTip; -class KviThemeListWidgetItem : public KviTalListWidgetItem +class ThemeListWidgetItem : public KviTalListWidgetItem { public: - KviThemeListWidgetItem(KviTalListWidget * box,KviThemeInfo * inf); - virtual ~KviThemeListWidgetItem(); + ThemeListWidgetItem(KviTalListWidget * box,KviThemeInfo * inf); + virtual ~ThemeListWidgetItem(); public: KviThemeInfo * m_pThemeInfo; public: @@ -57,21 +57,21 @@ public: }; -class KviThemeManagementDialog : public QWidget +class ThemeManagementDialog : public QWidget { Q_OBJECT public: - KviThemeManagementDialog(QWidget * parent); - virtual ~KviThemeManagementDialog(); + ThemeManagementDialog(QWidget * parent); + virtual ~ThemeManagementDialog(); protected: - static KviThemeManagementDialog * m_pInstance; + static ThemeManagementDialog * m_pInstance; KviTalIconAndRichTextItemDelegate * m_pItemDelegate; KviTalListWidget * m_pListWidget; KviTalPopupMenu * m_pContextPopup; QToolButton * m_pDeleteThemeButton; QToolButton * m_pPackThemeButton; public: - static KviThemeManagementDialog * instance(){ return m_pInstance; }; + static ThemeManagementDialog * instance(){ return m_pInstance; }; static void display(bool bTopLevel); static void cleanup(); protected: diff --git a/src/modules/theme/packthemedialog.cpp b/src/modules/theme/packthemedialog.cpp deleted file mode 100644 index ba44c006c..000000000 --- a/src/modules/theme/packthemedialog.cpp +++ /dev/null @@ -1,576 +0,0 @@ -//============================================================================= -// -// File : packthemedialog.cpp -// Creation date : Wed 03 Jan 2007 01:11:44 by Szymon Stefanek -// -// This file is part of the KVIrc IRC Client distribution -// Copyright (C) 2007-2010 Szymon Stefanek -// Copyright (C) 2010 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 "packthemedialog.h" -#include "themefunctions.h" - -#include "KviOptions.h" -#include "KviLocale.h" -#include "KviConfigurationFile.h" -#include "KviFileUtils.h" -#include "KviApplication.h" -#include "KviMainWindow.h" -#include "KviIconManager.h" -#include "KviPackageWriter.h" -#include "kvi_fileextensions.h" -#include "KviFileDialog.h" -//#include "KviMessageBox.h" -#include "KviSelectors.h" -#include "KviMiscUtils.h" -#include "kvi_sourcesdate.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -//#include -//#include -//#include - - - -KviPackThemeDialog::KviPackThemeDialog(QWidget * pParent, KviPointerList * pThemeInfoList) -: QWizard(pParent) -{ - setWindowTitle(__tr2qs_ctx("Export Theme - KVIrc","theme")); - setMinimumSize(400,350); - setDefaultProperty("QTextEdit","plainText",SIGNAL(textChanged())); - m_pThemeInfoList = pThemeInfoList; - - 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","theme")); - - QString szText = "

"; - szText += __tr2qs_ctx("This procedure allows you to export the selected themes to a single package. It is useful when you want to distribute your themes to the public.","theme"); - szText += "

"; - szText += __tr2qs_ctx("You will be asked to provide a package name, a description and, if you want, an icon/screenshot.","theme"); - szText += "

"; - szText += __tr2qs_ctx("Hit the \"Next\" button to begin.","theme"); - szText += "

"; - - QLabel * pLabel = new QLabel(pPage); - pLabel->setWordWrap(true); - pLabel->setText(szText); - pLayout->addWidget(pLabel); - addPage(pPage); - - // Theme data - m_pPackThemeDataWidget = new KviPackThemeDataWidget(this); - addPage(m_pPackThemeDataWidget); - - // Packager information - m_pPackThemeInfoWidget = new KviPackThemeInfoWidget(this); - addPage(m_pPackThemeInfoWidget); - - // Screenshot/logo/icon - m_pPackThemeImageWidget = new KviPackThemeImageWidget(this); - addPage(m_pPackThemeImageWidget); - - // Save file name - m_pPackThemeSaveWidget = new KviPackThemeSaveWidget(this); - addPage(m_pPackThemeSaveWidget); - - //last thing to do before starting - m_pPackThemeDataWidget->parseThemes(m_pThemeInfoList); -} - -KviPackThemeDataWidget::KviPackThemeDataWidget(KviPackThemeDialog * pParent) -: QWizardPage(pParent) -{ - setObjectName("theme_package_data_page"); - setTitle(__tr2qs_ctx("Theme Data","theme")); - setSubTitle(__tr2qs_ctx("This is the information list for the themes you're packaging. If it looks OK press \"Next\" to continue, otherwise press \"Cancel\" and rewiew your themes first.","theme")); -} - -void KviPackThemeDataWidget::parseThemes(KviPointerList * pThemeInfoList) -{ - QString szPackageName; - QString szPackageAuthor; - QString szPackageDescription; - QString szPackageVersion; - KviThemeInfo * pThemeInfo = 0; - bool bPackagePathSet = false; - - - QString szPackagePath = QDir::homePath(); - KviQString::ensureLastCharIs(szPackagePath,QChar(KVI_PATH_SEPARATOR_CHAR)); - - if(pThemeInfoList->count() > 1) - { - szPackageName = "MyThemes"; - szPackageAuthor = __tr2qs_ctx("Your name here","theme"); - szPackageVersion = "1.0.0"; - szPackageDescription = __tr2qs_ctx("Put a package description here...","theme"); - } else { - if(pThemeInfoList->count() > 0) - { - pThemeInfo = pThemeInfoList->first(); - szPackageName = pThemeInfo->subdirectory(); - szPackageAuthor = pThemeInfo->author(); - szPackageDescription = pThemeInfo->description(); - szPackageVersion = pThemeInfo->version(); - - szPackagePath += pThemeInfo->subdirectory(); - if(szPackagePath.indexOf(QRegExp("[0-9]\\.[0-9]")) == -1) - { - szPackagePath += "-"; - szPackagePath += szPackageVersion; - } - szPackagePath += KVI_FILEEXTENSION_THEMEPACKAGE; - - bPackagePathSet = true; - } - } - - if(!bPackagePathSet) - { - szPackagePath += szPackageName; - szPackagePath += "-"; - szPackagePath += szPackageVersion; - szPackagePath += KVI_FILEEXTENSION_THEMEPACKAGE; - } - - QVBoxLayout * pLayout = new QVBoxLayout(this); - - QString szThemesDescription = ""; - - int iIdx = 0; - QPixmap pixScreenshot; - QString szScreenshotPath; - - for(pThemeInfo = pThemeInfoList->first(); pThemeInfo; pThemeInfo = pThemeInfoList->next()) - { - QString szThemeDescription; - - if(pixScreenshot.isNull()) - { - pixScreenshot = pThemeInfo->smallScreenshot(); - if(!pixScreenshot.isNull()) - szScreenshotPath = pThemeInfo->smallScreenshotPath(); - } - - KviThemeFunctions::getThemeHtmlDescription( - szThemeDescription, - pThemeInfo->name(), - pThemeInfo->version(), - pThemeInfo->description(), - pThemeInfo->subdirectory(), - pThemeInfo->application(), - pThemeInfo->author(), - pThemeInfo->date(), - pThemeInfo->themeEngineVersion(), - pThemeInfo->smallScreenshot(), - iIdx - ); - - if(iIdx > 0) - szThemesDescription += "


"; - szThemesDescription += szThemeDescription; - iIdx++; - } - - szThemesDescription += ""; - - QTextEdit * pTextEdit = new QTextEdit(this); - pTextEdit->setBackgroundRole(QPalette::Window); - pTextEdit->setReadOnly(true); - QTextDocument * pDoc = new QTextDocument(pTextEdit); - pDoc->setHtml(szThemesDescription); - pTextEdit->setDocument(pDoc); - pLayout->addWidget(pTextEdit); - - setField("packageName",QVariant(szPackageName)); - setField("packageVersion",szPackageVersion); - setField("packageDescription",szPackageDescription); - setField("packageAuthor",szPackageAuthor); -} - -KviPackThemeDataWidget::~KviPackThemeDataWidget() -{ -} - -KviPackThemeInfoWidget::KviPackThemeInfoWidget(KviPackThemeDialog * pParent) -: QWizardPage(pParent) -{ - setObjectName("theme_package_info_page"); - setTitle(__tr2qs_ctx("Package Information","theme")); - setSubTitle(__tr2qs_ctx("Here you need to provide information about you (the packager) and a short description of the package you're creating.","theme")); - - - QGridLayout * pLayout = new QGridLayout(this); - - QLabel * pLabel = new QLabel(this); - pLabel->setText(__tr2qs_ctx("Package Name:","theme")); - pLayout->addWidget(pLabel,1,0); - - m_pPackageNameEdit = new QLineEdit(this); - - pLabel->setBuddy(m_pPackageNameEdit); - pLayout->addWidget(m_pPackageNameEdit,1,1); - - pLabel = new QLabel(this); - pLabel->setText(__tr2qs_ctx("Version:","theme")); - pLayout->addWidget(pLabel,2,0); - - m_pPackageVersionEdit = new QLineEdit(this); - - pLabel->setBuddy(m_pPackageVersionEdit); - pLayout->addWidget(m_pPackageVersionEdit,2,1); - - pLabel = new QLabel(this); - pLabel->setText(__tr2qs_ctx("Description:","theme")); - pLayout->addWidget(pLabel,3,0); - - m_pPackageDescriptionEdit = new QTextEdit(this); - - pLabel->setBuddy(m_pPackageDescriptionEdit); - pLayout->addWidget(m_pPackageDescriptionEdit,3,1); - - pLabel = new QLabel(this); - pLabel->setText(__tr2qs_ctx("Package Author:","theme")); - pLayout->addWidget(pLabel,4,0); - - m_pPackageAuthorEdit = new QLineEdit(this); - - pLabel->setBuddy(m_pPackageAuthorEdit); - pLayout->addWidget(m_pPackageAuthorEdit,4,1); - - pLayout->setRowStretch(3,1); - pLayout->setColumnStretch(1,1); - - // Store data in the fields - registerField("packageName*",m_pPackageNameEdit); - registerField("packageVersion*",m_pPackageVersionEdit); - registerField("packageDescription*",m_pPackageDescriptionEdit); - registerField("packageAuthor*",m_pPackageAuthorEdit); - -} -void KviPackThemeInfoWidget::initializePage() -{ - QString szPackageName = field("packageName").toString(); - QString szPackageVersion = field("packageVersion").toString(); - QString szPackageDescription = field("packageDescription").toString(); - QString szPackageAuthor = field("packageAuthor").toString(); - m_pPackageNameEdit->setText(szPackageName); - m_pPackageVersionEdit->setText(szPackageVersion); - m_pPackageDescriptionEdit->setText(szPackageDescription); - m_pPackageAuthorEdit->setText(szPackageAuthor); -} - -KviPackThemeInfoWidget::~KviPackThemeInfoWidget() -{ -} - -KviPackThemeImageWidget::KviPackThemeImageWidget(KviPackThemeDialog * pParent) -: QWizardPage(pParent) -{ - setObjectName("theme_package_image_page"); - setTitle(__tr2qs_ctx("Icon/Screenshot","theme")); - setSubTitle(__tr2qs_ctx("Here you can choose the image that will appear in the installation dialog for your theme package. It can be an icon, a logo or a screenshot and it should be not larger than 300x225. If you don't provide an image a simple default icon will be used at installation stage.","theme")); - - QVBoxLayout * pLayout = new QVBoxLayout(this); - - m_pImageLabel = new QLabel(this); - m_pImageLabel->setFrameStyle(QFrame::Sunken | QFrame::Panel); - m_pImageLabel->setMinimumSize(300,225); - m_pImageLabel->setAlignment(Qt::AlignCenter | Qt::AlignVCenter); - pLayout->addWidget(m_pImageLabel); - - m_pImageSelector = new KviFileSelector(this,"",&m_szImagePath,true,0,KVI_FILTER_IMAGE); - connect(m_pImageSelector,SIGNAL(selectionChanged(const QString &)),this,SLOT(imageSelectionChanged(const QString &))); - pLayout->addWidget(m_pImageSelector); - // Store data in the fields - registerField("packageImagePath*",m_pImageSelector); - - //m_pImageSelectionPage = pPage; -} - -KviPackThemeImageWidget::~KviPackThemeImageWidget() -{ -} - -void KviPackThemeImageWidget::imageSelectionChanged(const QString & szImagePath) -{ - QImage pix(szImagePath); - if(!pix.isNull()) - { - QPixmap out; - if(pix.width() > 300 || pix.height() > 225) - { - pix=pix.scaled(300,225,Qt::KeepAspectRatio,Qt::SmoothTransformation); - out=out.fromImage(pix); - } else { - out=out.fromImage(pix); - } - m_pImageLabel->setPixmap(out); - return; - } - - QMessageBox::critical(this,__tr2qs_ctx("Export Theme - KVIrc","theme"),__tr2qs_ctx("Failed to load the selected image","theme"), - QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); - - m_pImageSelector->setSelection(""); - m_pImageLabel->setPixmap(QPixmap()); -} - -KviPackThemeSaveWidget::KviPackThemeSaveWidget(KviPackThemeDialog * pParent) -: QWizardPage(pParent) -{ - setObjectName("theme_package_save_page"); - setTitle(__tr2qs_ctx("Package Path","theme")); - setSubTitle(__tr2qs_ctx("Here you must choose the file name for the theme package. It should have a *%1 extension.","theme").arg(KVI_FILEEXTENSION_THEMEPACKAGE)); - - QVBoxLayout * pLayout = new QVBoxLayout(this); - - QString szFilter = "*"; - szFilter += KVI_FILEEXTENSION_THEMEPACKAGE; - m_pSavePathSelector = new KviFileSelector(this,"",&m_szPackagePath,true,KviFileSelector::ChooseSaveFileName,szFilter); - pLayout->addWidget(m_pSavePathSelector); - - QLabel * pLabel = new QLabel(this); - pLabel->setWordWrap(true); - pLabel->setText(__tr2qs_ctx("Finally hit the \"Finish\" button to complete the packaging operation.","theme")); - pLayout->addWidget(pLabel); - - // Store data in the fields - registerField("packageSavePath*",m_pSavePathSelector); -} - -KviPackThemeSaveWidget::~KviPackThemeSaveWidget() -{ -} - -void KviPackThemeSaveWidget::initializePage() -{ - m_szPackagePath = field("packageSavePath").toString(); -} -#if 0 - if(!szScreenshotPath.isEmpty()) - { - m_pImageSelector->setSelection(szScreenshotPath); - imageSelectionChanged(szScreenshotPath); - } -} -#endif - -KviPackThemeDialog::~KviPackThemeDialog() -{ -} - -void KviPackThemeDialog::accept() -{ - if(!packTheme()) return; - QWizard::accept(); -} - -bool KviPackThemeDialog::packTheme() -{ - //m_pImageSelector->commit(); - //m_pPathSelector->commit(); - - // 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_szImagePath = field("packageImagePath").toString(); - m_szPackagePath = field("packageSavePath").toString(); - //m_szSavePath = field("packageSavePath").toString(); - - //return false; - - QImage pix(m_szImagePath); - QPixmap out; - if(!pix.isNull()) - { - if((pix.width() > 300) || (pix.height() > 225)) - { - out=out.fromImage(pix.scaled(300,225,Qt::KeepAspectRatio)); - } else { - out=out.fromImage(pix); - } - } else { - if(!m_szImagePath.isEmpty()) - { - QMessageBox::critical(this, - __tr2qs_ctx("Export Theme - KVIrc","theme"), - __tr2qs_ctx("Failed to load the selected image: please fix it","theme"), - QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton - ); - //setCurrentPage(m_pImageSelectionPage); - return false; - } - } - - KviPackageWriter f; - - QString szTmp; - QDateTime date = QDateTime::currentDateTime(); - - switch(KVI_OPTION_UINT(KviOption_uintOutputDatetimeFormat)) - { - case 0: - szTmp = date.toString(); - break; - case 1: - szTmp = date.toString(Qt::ISODate); - break; - case 2: - szTmp = date.toString(Qt::SystemLocaleDate); - break; - } - - f.addInfoField("PackageType","ThemePack"); - f.addInfoField("ThemePackVersion",KVI_CURRENT_THEME_ENGINE_VERSION); - f.addInfoField("Name",m_szName); - f.addInfoField("Version",m_szVersion); - f.addInfoField("Author",m_szAuthor); - f.addInfoField("Description",m_szDescription); - f.addInfoField("Date",szTmp); - f.addInfoField("Application","KVIrc " KVI_VERSION "." KVI_SOURCES_DATE); - - if(!out.isNull()) - { - QByteArray * pba = new QByteArray(); - QBuffer buffer(pba,0); - buffer.open(QIODevice::WriteOnly); - out.save(&buffer,"PNG"); - buffer.close(); - f.addInfoField("Image",pba); // cool :) [no disk access needed] - } - - szTmp.setNum(m_pThemeInfoList->count()); - f.addInfoField("ThemeCount",szTmp); - - int iIdx = 0; - for(KviThemeInfo * pInfo = m_pThemeInfoList->first(); pInfo; pInfo = m_pThemeInfoList->next()) - { - KviQString::sprintf(szTmp,"Theme%dName",iIdx); - f.addInfoField(szTmp,pInfo->name()); - KviQString::sprintf(szTmp,"Theme%dVersion",iIdx); - f.addInfoField(szTmp,pInfo->version()); - KviQString::sprintf(szTmp,"Theme%dDescription",iIdx); - f.addInfoField(szTmp,pInfo->description()); - KviQString::sprintf(szTmp,"Theme%dDate",iIdx); - f.addInfoField(szTmp,pInfo->date()); - KviQString::sprintf(szTmp,"Theme%dSubdirectory",iIdx); - f.addInfoField(szTmp,pInfo->subdirectory()); - KviQString::sprintf(szTmp,"Theme%dAuthor",iIdx); - f.addInfoField(szTmp,pInfo->author()); - KviQString::sprintf(szTmp,"Theme%dApplication",iIdx); - f.addInfoField(szTmp,pInfo->application()); - KviQString::sprintf(szTmp,"Theme%dThemeEngineVersion",iIdx); - f.addInfoField(szTmp,pInfo->themeEngineVersion()); - QPixmap pixScreenshot = pInfo->smallScreenshot(); - if(!pixScreenshot.isNull()) - { - KviQString::sprintf(szTmp,"Theme%dScreenshot",iIdx); - QByteArray * pba = new QByteArray(); - - QBuffer bufferz(pba,0); - bufferz.open(QIODevice::WriteOnly); - pixScreenshot.save(&bufferz,"PNG"); - bufferz.close(); - f.addInfoField(szTmp,pba); - } - - if(!f.addDirectory(pInfo->absoluteDirectory(),pInfo->subdirectory())) - { - szTmp = __tr2qs_ctx("Packaging failed","theme"); - szTmp += ": "; - szTmp += f.lastError(); - QMessageBox::critical(this, - __tr2qs_ctx("Export Theme - KVIrc","theme"), - szTmp, - QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton - ); - } - - iIdx++; - } - - if(!f.pack(m_szPackagePath)) - { - szTmp = __tr2qs_ctx("Packaging failed","theme"); - szTmp += ": "; - szTmp += f.lastError(); - QMessageBox::critical(this, - __tr2qs_ctx("Export Theme - KVIrc","theme"), - szTmp, - QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton - ); - - return false; - } - - //KviPackageReader r; - //r.unpack("/root/test.kvt","/root/unpacked_test_kvt"); - - QMessageBox::information(this, - __tr2qs_ctx("Export Theme - KVIrc","theme"), - __tr2qs("Package saved successfully"), - QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton - ); - - return true; -} diff --git a/src/modules/theme/packthemedialog.h b/src/modules/theme/packthemedialog.h deleted file mode 100644 index d99862dfe..000000000 --- a/src/modules/theme/packthemedialog.h +++ /dev/null @@ -1,124 +0,0 @@ -#ifndef _PACKTHEMEDIALOG_H_ -#define _PACKTHEMEDIALOG_H_ -//============================================================================= -// -// File : packthemedialog.h -// Creation date : Wed 03 Jan 2007 01:11:44 by Szymon Stefanek -// -// This file is part of the KVIrc IRC Client distribution -// Copyright (C) 2007-2010 Szymon Stefanek -// Copyright (C) 2010 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 "KviPointerList.h" -#include "KviTheme.h" - -#include -#include - -class QLineEdit; -class QLabel; -class QTextEdit; -class KviFileSelector; - -class KviPackThemeDataWidget; -class KviPackThemeInfoWidget; -class KviPackThemeImageWidget; -class KviPackThemeSaveWidget; - -class KviPackThemeDialog : public QWizard -{ - Q_OBJECT -public: - KviPackThemeDialog(QWidget * pParent, KviPointerList * pThemeInfoList); - ~KviPackThemeDialog(); -protected: - KviPackThemeDataWidget * m_pPackThemeDataWidget; - KviPackThemeInfoWidget * m_pPackThemeInfoWidget; - KviPackThemeImageWidget * m_pPackThemeImageWidget; - KviPackThemeSaveWidget * m_pPackThemeSaveWidget; - KviPointerList * m_pThemeInfoList; - - QString m_szAuthor; - QString m_szName; - QString m_szVersion; - QString m_szDescription; - QString m_szImagePath; - QString m_szPackagePath; - QString m_szSavePath; - - //QWidget * m_pImageSelectionPage; -protected: - virtual void accept(); - bool packTheme(); -}; - -class KviPackThemeDataWidget : public QWizardPage -{ - Q_OBJECT -public: - KviPackThemeDataWidget(KviPackThemeDialog * pParent); - ~KviPackThemeDataWidget(); -public: - void parseThemes(KviPointerList * pThemeInfoList); -}; - -class KviPackThemeInfoWidget : public QWizardPage -{ - Q_OBJECT -public: - KviPackThemeInfoWidget(KviPackThemeDialog * pParent); - ~KviPackThemeInfoWidget(); -public: - QLineEdit * m_pPackageNameEdit; - QTextEdit * m_pPackageDescriptionEdit; - QLineEdit * m_pPackageVersionEdit; - QLineEdit * m_pPackageAuthorEdit; -protected: - virtual void initializePage(); -}; - -class KviPackThemeImageWidget : public QWizardPage -{ - Q_OBJECT -public: - KviPackThemeImageWidget(KviPackThemeDialog * pParent); - ~KviPackThemeImageWidget(); -protected: - KviFileSelector * m_pImageSelector; - QLabel * m_pImageLabel; - QString m_szImagePath; -protected slots: - void imageSelectionChanged(const QString & szImagePath); -}; - -class KviPackThemeSaveWidget : public QWizardPage -{ - Q_OBJECT -public: - KviPackThemeSaveWidget(KviPackThemeDialog * pParent); - ~KviPackThemeSaveWidget(); -protected: - KviFileSelector * m_pSavePathSelector; - QString m_szPackagePath; -protected: - virtual void initializePage(); -}; - -#endif //!_PACKTHEMEDIALOG_H_ diff --git a/src/modules/theme/savethemedialog.cpp b/src/modules/theme/savethemedialog.cpp deleted file mode 100644 index 4e65b550c..000000000 --- a/src/modules/theme/savethemedialog.cpp +++ /dev/null @@ -1,306 +0,0 @@ -//============================================================================= -// -// File : savethemedialog.cpp -// Creation date : Wed 03 Jan 2007 03:01:34 by Szymon Stefanek -// -// This file is part of the KVIrc IRC Client distribution -// Copyright (C) 2007-2010 Szymon Stefanek -// -// 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 "savethemedialog.h" -#include "themefunctions.h" - -#include "KviOptions.h" -#include "KviLocale.h" -#include "KviConfigurationFile.h" -#include "KviFileUtils.h" -#include "KviApplication.h" -#include "KviMainWindow.h" -#include "KviIconManager.h" -#include "KviPackageWriter.h" -#include "kvi_fileextensions.h" -#include "KviFileDialog.h" -#include "KviMessageBox.h" -#include "KviSelectors.h" -#include "KviMiscUtils.h" -#include "kvi_sourcesdate.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - - - -KviSaveThemeDialog::KviSaveThemeDialog(QWidget * pParent) -: KviTalWizard(pParent) -{ - setWindowTitle(__tr2qs_ctx("Save Current Theme - KVIrc","theme")); - setMinimumSize(400,350); - - // welcome page ================================================================================== - QWidget * pPage = new QWidget(this); - QGridLayout * pLayout = new QGridLayout(pPage); - - QLabel * pLabel = new QLabel(pPage); - pLabel->setWordWrap(true); - QString szText = "

"; - szText += __tr2qs_ctx("This procedure allows you to save the current theme settings to a single directory. It is useful if you want to apply other themes or play with the theme settings and later come back to this theme with a single click. It will also allow you to manually modify the theme settings and later export them to a distributable package.","theme"); - szText += "

"; - szText += __tr2qs_ctx("You will be asked to provide a theme name, a description and, if you want, a screenshot.","theme"); - szText += "

"; - szText += __tr2qs_ctx("Hit the \"Next\" button to begin.","theme"); - szText += "

"; - - pLabel->setText(szText); - pLayout->addWidget(pLabel,0,0); - pLayout->setRowStretch(1,1); - - addPage(pPage,__tr2qs_ctx("Welcome","theme")); - setBackEnabled(pPage,false); - setNextEnabled(pPage,true); - setHelpEnabled(pPage,false); - setFinishEnabled(pPage,false); - - // packager information ================================================================================ - - pPage = new QWidget(this); - pLayout = new QGridLayout(pPage); - - pLabel = new QLabel(pPage); - pLabel->setText(__tr2qs_ctx("Here you need to provide information about you (the author) and a short description of the theme you're creating.","theme")); - pLabel->setWordWrap(true); - pLabel->setTextFormat(Qt::RichText); - pLayout->addWidget(pLabel,0,0,1,2); - - pLabel = new QLabel(pPage); - pLabel->setText(__tr2qs_ctx("Theme Name:","theme")); - pLayout->addWidget(pLabel,1,0); - - m_pThemeNameEdit = new QLineEdit(pPage); - //m_pThemeNameEdit->setText(szThemeName); - pLayout->addWidget(m_pThemeNameEdit,1,1); - - pLabel = new QLabel(pPage); - pLabel->setText(__tr2qs_ctx("Version:","theme")); - pLayout->addWidget(pLabel,2,0); - - m_pThemeVersionEdit = new QLineEdit(pPage); - //m_pThemeVersionEdit->setText(szThemeVersion); - pLayout->addWidget(m_pThemeVersionEdit,2,1); - - pLabel = new QLabel(pPage); - pLabel->setText(__tr2qs_ctx("Description:","theme")); - pLayout->addWidget(pLabel,3,0); - - m_pThemeDescriptionEdit = new QTextEdit(pPage); - //m_pThemeDescriptionEdit->setText(szThemeDescription); - pLayout->addWidget(m_pThemeDescriptionEdit,3,1); - - pLabel = new QLabel(pPage); - pLabel->setText(__tr2qs_ctx("Theme Author:","theme")); - pLayout->addWidget(pLabel,4,0); - - m_pAuthorNameEdit = new QLineEdit(pPage); - //m_pAuthorNameEdit->setText(szThemeAuthor); - pLayout->addWidget(m_pAuthorNameEdit,4,1); - - - pLayout->setRowStretch(3,1); - pLayout->setColumnStretch(1,1); - - addPage(pPage,__tr2qs_ctx("Theme Information","theme")); - setBackEnabled(pPage,true); - setHelpEnabled(pPage,false); - setNextEnabled(pPage,true); - setFinishEnabled(pPage,false); - - // screenshot/logo/icon ================================================================================ - - pPage = new QWidget(this); - pLayout = new QGridLayout(pPage); - - pLabel = new QLabel(pPage); - pLabel->setText(__tr2qs_ctx("Here you can either choose a screenshot image from disk or make one now. The screenshot will be displayed in the tooltips of the theme management dialog and will be also visible in the package installation dialog if you will export the theme to a distributable package.","theme")); - pLabel->setWordWrap(true); - pLabel->setTextFormat(Qt::RichText); - pLayout->addWidget(pLabel,0,0); - - m_pImageLabel = new QLabel(pPage); - m_pImageLabel->setFrameStyle(QFrame::Sunken | QFrame::Panel); - m_pImageLabel->setMinimumSize(300,225); - m_pImageLabel->setAlignment(Qt::AlignCenter | Qt::AlignVCenter); - pLayout->addWidget(m_pImageLabel,1,0); - - m_pImageSelector = new KviFileSelector(pPage,"",&m_szScreenshotPath,true,0,KVI_FILTER_IMAGE); - connect(m_pImageSelector,SIGNAL(selectionChanged(const QString &)),this,SLOT(imageSelectionChanged(const QString &))); - pLayout->addWidget(m_pImageSelector,2,0); - - QPushButton * pButton = new QPushButton(pPage); - pButton->setText(__tr2qs_ctx("Make Screenshot Now","theme")); - connect(pButton,SIGNAL(clicked()),this,SLOT(makeScreenshot())); - pLayout->addWidget(pButton,3,0); - - pLayout->setRowStretch(1,1); - - m_pImageSelectionPage = pPage; - addPage(pPage,__tr2qs_ctx("Screenshot","theme")); - setBackEnabled(pPage,true); - setHelpEnabled(pPage,false); - setNextEnabled(pPage,true); - setFinishEnabled(pPage,true); -} - -KviSaveThemeDialog::~KviSaveThemeDialog() -{ -} - -void KviSaveThemeDialog::imageSelectionChanged(const QString &szImagePath) -{ - QImage pix(szImagePath); - if(!pix.isNull()) - { - QPixmap out; - if(pix.width() > 300 || pix.height() > 225) - out = QPixmap::fromImage(pix.scaled(300,225,Qt::KeepAspectRatio)); - else - out = QPixmap::fromImage(pix); - m_pImageLabel->setPixmap(out); - return; - } - - QMessageBox::critical(this,__tr2qs_ctx("Save Current Theme - KVIrc","theme"),__tr2qs_ctx("Failed to load the selected image","theme"), - QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); - - m_pImageSelector->setSelection(""); - m_pImageLabel->setPixmap(QPixmap()); -} - -void KviSaveThemeDialog::accept() -{ - if(!saveTheme())return; - KviTalWizard::accept(); -} - -void KviSaveThemeDialog::makeScreenshot() -{ - QString szFileName; - g_pApp->getTmpFileName(szFileName,"screenshot.png"); - if(!KviThemeFunctions::makeKVIrcScreenshot(szFileName)) - { - QMessageBox::critical(this,__tr2qs_ctx("Acquire Screenshot - KVIrc","theme"),__tr2qs_ctx("Failed to make screenshot","theme"), - QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); - return; - } - m_pImageSelector->setSelection(szFileName); - imageSelectionChanged(szFileName); -} - -bool KviSaveThemeDialog::saveTheme() -{ - m_pImageSelector->commit(); - - KviThemeInfo sto; - sto.setName(m_pThemeNameEdit->text()); - if(sto.name().isEmpty()) - { - QMessageBox::critical(this,__tr2qs_ctx("Save Current Theme - KVIrc","theme"),__tr2qs_ctx("You must choose a theme name!","theme"),QMessageBox::Ok, - QMessageBox::NoButton,QMessageBox::NoButton); - return false; - } - - sto.setAuthor(m_pAuthorNameEdit->text()); - sto.setDescription(m_pThemeDescriptionEdit->toPlainText()); - - QString szTmp; - QDateTime date = QDateTime::currentDateTime(); - switch(KVI_OPTION_UINT(KviOption_uintOutputDatetimeFormat)) - { - case 0: - szTmp = date.toString(); - break; - case 1: - szTmp = date.toString(Qt::ISODate); - break; - case 2: - szTmp = date.toString(Qt::SystemLocaleDate); - break; - } - - sto.setDate(szTmp); - sto.setVersion(m_pThemeVersionEdit->text()); - sto.setApplication("KVIrc " KVI_VERSION "." KVI_SOURCES_DATE); - - if(sto.version().isEmpty())sto.setVersion("1.0.0"); - - QString szSubdir = sto.name() + QString("-") + sto.version(); - szSubdir.replace(QRegExp("[ \\\\/:][ \\\\/:]*"),"_"); - sto.setSubdirectory(szSubdir); - - QString szAbsDir; - g_pApp->getLocalKvircDirectory(szAbsDir,KviApplication::Themes,sto.subdirectory(),true); - if(!KviFileUtils::makeDir(szAbsDir)) - { - QMessageBox::critical(this,__tr2qs_ctx("Save Current Theme - KVIrc","theme"),__tr2qs_ctx("Unable to create theme directory.","theme"), - QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); - return false; - } - - sto.setAbsoluteDirectory(szAbsDir); - - if(!KviTheme::save(sto)) - { - QString szMsg2; - QString szErr = sto.lastError(); - KviQString::sprintf(szMsg2,__tr2qs_ctx("Unable to save theme: %Q","theme"),&szErr); - QMessageBox::critical(this,__tr2qs_ctx("Save Current Theme - KVIrc","theme"),szMsg2, - QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); - return false; - } - // write down the screenshot, if needed - - if(!m_szScreenshotPath.isEmpty()) - { - if(!KviTheme::saveScreenshots(sto,m_szScreenshotPath)) - { - QMessageBox::critical(this,__tr2qs_ctx("Save Current Theme - KVIrc","theme"),__tr2qs_ctx("Failed to load the selected screenshot image: please fix it","theme"), - QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); - setCurrentPage(m_pImageSelectionPage); - return false; - } - } - - QString szMsg = __tr2qs_ctx("Theme saved successfully to ","theme"); - szMsg += sto.absoluteDirectory(); - - QMessageBox::information(this,__tr2qs_ctx("Save Theme - KVIrc","theme"),szMsg,QMessageBox::Ok, - QMessageBox::NoButton,QMessageBox::NoButton); - - return true; -} diff --git a/src/modules/theme/savethemedialog.h b/src/modules/theme/savethemedialog.h deleted file mode 100644 index 0eceffe9a..000000000 --- a/src/modules/theme/savethemedialog.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef _SAVETHEMEDIALOG_H_ -#define _SAVETHEMEDIALOG_H_ -//============================================================================= -// -// File : savethemedialog.h -// Creation date : Wed 03 Jan 2007 03:01:34 by Szymon Stefanek -// -// This file is part of the KVIrc IRC Client distribution -// Copyright (C) 2007-2010 Szymon Stefanek -// -// 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 "KviPointerList.h" -#include "KviTheme.h" -#include "KviTalWizard.h" - -#include - -class QLineEdit; -class QPushButton; -class QLabel; -class QTextEdit; -class KviFileSelector; - - -class KviSaveThemeDialog : public KviTalWizard -{ - Q_OBJECT -public: - KviSaveThemeDialog(QWidget * pParent); - virtual ~KviSaveThemeDialog(); -protected: - QString m_szScreenshotPath; - KviFileSelector * m_pImageSelector; - QLabel * m_pImageLabel; - QLineEdit * m_pThemeNameEdit; - QTextEdit * m_pThemeDescriptionEdit; - QLineEdit * m_pThemeVersionEdit; - QLineEdit * m_pAuthorNameEdit; - QWidget * m_pImageSelectionPage; - QPushButton * m_pOkButton; -protected: - virtual void accept(); - bool saveTheme(); -protected slots: - void makeScreenshot(); - void imageSelectionChanged(const QString & szImagePath); - //void themeNameChanged(const QString &txt); -}; - -#endif //!_SAVETHEMEDIALOG_H_ diff --git a/src/modules/theme/themefunctions.cpp b/src/modules/theme/themefunctions.cpp deleted file mode 100644 index ba7150b88..000000000 --- a/src/modules/theme/themefunctions.cpp +++ /dev/null @@ -1,405 +0,0 @@ -//============================================================================= -// -// File : themefunctions.cpp -// Creation date : Wed 03 Jan 2007 03:14:07 by Szymon Stefanek -// -// This file is part of the KVIrc IRC Client distribution -// Copyright (C) 2007-2010 Szymon Stefanek -// -// 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 "themefunctions.h" - -#include "KviPackageReader.h" -#include "KviLocale.h" -#include "KviMessageBox.h" -#include "KviApplication.h" -#include "KviHtmlDialog.h" -#include "KviIconManager.h" -#include "KviMiscUtils.h" -#include "kvi_sourcesdate.h" -#include "KviTheme.h" -#include "KviMainWindow.h" - - -//#include - - -namespace KviThemeFunctions -{ - - static bool notAValidThemePackage(QString &szError) - { - szError = __tr2qs_ctx("The selected file does not seem to be a valid KVIrc theme package","theme"); - return false; - } - - bool installThemePackage(const QString &szThemePackageFileName,QString &szError,QWidget * pDialogParent) - { - KviPointerHashTable * pInfoFields; - QString * pValue; - bool bInstall; - QPixmap pix; - QByteArray * pByteArray; - KviHtmlDialogData hd; - - const char * check_fields[] = { "Name", "Version", "Author", "Description", "Date", "Application" }; - - // check if it is a valid theme file - KviPackageReader r; - - if(!r.readHeader(szThemePackageFileName)) - { - QString szErr = r.lastError(); - KviQString::sprintf(szError,__tr2qs_ctx("The selected file does not seem to be a valid KVIrc package: %Q","theme"),&szErr); - return false; - } - - pInfoFields = r.stringInfoFields(); - - pValue = pInfoFields->find("PackageType"); - if(!pValue) - return notAValidThemePackage(szError); - - if(!KviQString::equalCI(*pValue,"ThemePack")) - return notAValidThemePackage(szError); - - pValue = pInfoFields->find("ThemePackVersion"); - - if(!pValue) - return notAValidThemePackage(szError); - - // make sure the default fields exist - for(int i=0;i<6;i++) - { - pValue = pInfoFields->find(check_fields[i]); - if(!pValue)return notAValidThemePackage(szError); - } - - pValue = pInfoFields->find("ThemeCount"); - if(!pValue) - return notAValidThemePackage(szError); - - bool bOk; - int iThemeCount = pValue->toInt(&bOk); - if(!bOk) - return notAValidThemePackage(szError); - - if(iThemeCount < 1) - return notAValidThemePackage(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_THEME)); - } - - QString szPackageName; - QString szPackageVersion; - QString szPackageAuthor; - QString szPackageDescription; - QString szPackageDate; - QString szPackageThemeEngineVersion; - QString szPackageApplication; - - QString szAuthor = __tr2qs_ctx("Author","theme"); - QString szCreatedAt = __tr2qs_ctx("Created at","theme"); - QString szCreatedOn = __tr2qs_ctx("Created with","theme"); - - r.getStringInfoField("Name",szPackageName); - r.getStringInfoField("Version",szPackageVersion); - r.getStringInfoField("Author",szPackageAuthor); - r.getStringInfoField("Description",szPackageDescription); - r.getStringInfoField("Application",szPackageApplication); - r.getStringInfoField("Date",szPackageDate); - - QString szWarnings; - QString szDetails = ""; - QString szTmp; - - int iIdx = 0; - int iValidThemeCount = iThemeCount; - - while(iIdx < iThemeCount) - { - bool bValid = true; - - QString szThemeName; - QString szThemeVersion; - QString szThemeDescription; - QString szThemeDate; - QString szThemeSubdirectory; - QString szThemeAuthor; - QString szThemeEngineVersion; - QString szThemeApplication; - - KviQString::sprintf(szTmp,"Theme%dName",iIdx); - r.getStringInfoField(szTmp,szThemeName); - KviQString::sprintf(szTmp,"Theme%dVersion",iIdx); - r.getStringInfoField(szTmp,szThemeVersion); - KviQString::sprintf(szTmp,"Theme%dApplication",iIdx); - r.getStringInfoField(szTmp,szThemeApplication); - KviQString::sprintf(szTmp,"Theme%dDescription",iIdx); - r.getStringInfoField(szTmp,szThemeDescription); - KviQString::sprintf(szTmp,"Theme%dDate",iIdx); - r.getStringInfoField(szTmp,szThemeDate); - KviQString::sprintf(szTmp,"Theme%dSubdirectory",iIdx); - r.getStringInfoField(szTmp,szThemeSubdirectory); - KviQString::sprintf(szTmp,"Theme%dAuthor",iIdx); - r.getStringInfoField(szTmp,szThemeAuthor); - KviQString::sprintf(szTmp,"Theme%dThemeEngineVersion",iIdx); - r.getStringInfoField(szTmp,szThemeEngineVersion); - KviQString::sprintf(szTmp,"Theme%dScreenshot",iIdx); - QPixmap pixScreenshot; - pByteArray = r.binaryInfoFields()->find(szTmp); - if(pByteArray) - pixScreenshot.loadFromData(*pByteArray,0,0); - - if(szThemeName.isEmpty() || szThemeVersion.isEmpty() || szThemeSubdirectory.isEmpty() || szThemeEngineVersion.isEmpty()) - bValid = false; - if(KviMiscUtils::compareVersions(szThemeEngineVersion,KVI_CURRENT_THEME_ENGINE_VERSION) < 0) - bValid = false; - - QString szDetailsBuffer; - - getThemeHtmlDescription( - szDetailsBuffer, - szThemeName, - szThemeVersion, - szThemeDescription, - szThemeSubdirectory, - szThemeApplication, - szThemeAuthor, - szThemeDate, - szThemeEngineVersion, - pixScreenshot, - iIdx,&hd - ); - - if(iIdx > 0) - szDetails += "


"; - - szDetails += szDetailsBuffer; - - if(!bValid) - { - szDetails += "

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

"; - iValidThemeCount--; - } - - iIdx++; - } - - szDetails += "

"; - szDetails += __tr2qs_ctx("Go Back to Package Data","theme"); - szDetails += "

"; - szDetails += ""; - - if(iValidThemeCount < iThemeCount) - { - szWarnings += "

"; - szWarnings += __tr2qs_ctx("Warning: Some of the theme contained in this package might be either corrupted or incompatible with this version of KVIrc","theme"); - szWarnings += "

"; - } - - QString szShowDetails = __tr2qs_ctx("Show Details","theme"); - - KviQString::sprintf(hd.szHtmlText, - "" \ - "" \ - "

" \ - "

%Q %Q

" \ - "

" \ - "

" \ - "" \ - "

" \ - "

" \ - "%Q" \ - "

" \ - "

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

" \ - "

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

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

" \ - "%Q" \ - "

" \ - "" \ - "", - &szPackageName, - &szPackageVersion, - &szPackageDescription, - &szAuthor, - &szPackageAuthor, - &szCreatedAt, - &szPackageDate, - &szCreatedOn, - &szPackageApplication, - &szWarnings, - &szShowDetails - ); - - hd.addImageResource("theme_dialog_pack_image",pix); - hd.addHtmlResource("theme_dialog_details",szDetails); - hd.addHtmlResource("theme_dialog_main",hd.szHtmlText); - - QString beginCenter = "
"; - QString endCenter = "
"; - - hd.szCaption = __tr2qs_ctx("Install Theme Pack - KVIrc","theme"); - hd.szUpperLabelText = beginCenter + __tr2qs_ctx("You're about to install the following theme package","theme") + endCenter; - hd.szLowerLabelText = beginCenter + __tr2qs_ctx("Do you want to proceed with the installation ?","theme") + endCenter; - hd.szButton1Text = __tr2qs_ctx("Do Not Install","theme"); - hd.szButton2Text = __tr2qs_ctx("Yes, Proceed","theme"); - hd.iDefaultButton = 2; - hd.iCancelButton = 1; - hd.pixIcon = *(g_pIconManager->getSmallIcon(KVI_SMALLICON_THEME)); - hd.iMinimumWidth = 350; - hd.iMinimumHeight = 420; - hd.iFlags = KviHtmlDialogData::ForceMinimumSize; - - bInstall = KviHtmlDialog::display(pDialogParent,&hd) == 2; - if(bInstall) - { - QString szUnpackPath; - g_pApp->getLocalKvircDirectory(szUnpackPath,KviApplication::Themes); - if(!r.unpack(szThemePackageFileName,szUnpackPath)) - { - QString szErr2 = r.lastError(); - KviQString::sprintf(szError,__tr2qs_ctx("Failed to unpack the selected file: %Q","theme"),&szErr2); - return false; - } - } - - return true; - } - - - void getThemeHtmlDescription( - QString &szBuffer, - const QString &szThemeName, - const QString &szThemeVersion, - const QString &szThemeDescription, - const QString &szThemeSubdirectory, - const QString &szThemeApplication, - const QString &szThemeAuthor, - const QString &szThemeDate, - const QString &szThemeThemeEngineVersion, - const QPixmap &pixScreenshot, - int iUniqueIndexInDocument, - KviHtmlDialogData *hd - ) - { - QString szAuthor = __tr2qs_ctx("Author","theme"); - QString szCreatedAt = __tr2qs_ctx("Created at","theme"); - QString szCreatedOn = __tr2qs_ctx("Created with","theme"); - QString szThemeEngineVersion = __tr2qs_ctx("Theme Engine Version","theme"); - QString szSubdirectory = __tr2qs_ctx("Subdirectory","theme"); - - QString szScreenshot; - if(!pixScreenshot.isNull()) - { - KviQString::sprintf(szScreenshot,"

",iUniqueIndexInDocument); - QString szTmp; - KviQString::sprintf(szTmp,"theme_shot%d",iUniqueIndexInDocument); - //FIXME in tooltip - if (hd) - hd->addImageResource(szTmp,pixScreenshot); - else szScreenshot = ""; - } else { - szScreenshot = ""; - } - - KviQString::sprintf( - szBuffer, - "

" \ - "

%Q %Q

" \ - "

" \ - "%Q" \ - "

" \ - "%Q" \ - "

" \ - "

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

" \ - "

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

", - &szThemeName, - &szThemeVersion, - &szScreenshot, - &szThemeDescription, - &szAuthor, - &szThemeAuthor, - &szCreatedAt, - &szThemeDate, - &szCreatedOn, - &szThemeApplication, - &szThemeEngineVersion, - &szThemeThemeEngineVersion, - &szSubdirectory, - &szThemeSubdirectory - ); - } - - bool makeKVIrcScreenshot(const QString &szSavePngFilePath,bool bMaximizeFrame) - { - if(bMaximizeFrame) - { - if(g_pFrame->isMaximized()) - bMaximizeFrame = false; - } - - if(bMaximizeFrame) - g_pFrame->showMaximized(); - - QPixmap pix = QPixmap::grabWidget(g_pFrame); - bool bResult = true; - - if(pix.isNull()) - bResult = false; - else { - if(!pix.save(szSavePngFilePath,"PNG")) - bResult = false; - } - - if(bMaximizeFrame) - g_pFrame->showNormal(); - return bResult; - } -} - diff --git a/src/modules/theme/themefunctions.h b/src/modules/theme/themefunctions.h deleted file mode 100644 index 639e66107..000000000 --- a/src/modules/theme/themefunctions.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef _THEMEFUNCTIONS_H_ -#define _THEMEFUNCTIONS_H_ -//============================================================================= -// -// File : themefunctions.h -// Creation date : Wed 03 Jan 2007 03:14:07 by Szymon Stefanek -// -// This file is part of the KVIrc IRC Client distribution -// Copyright (C) 2007-2010 Szymon Stefanek -// -// 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 "KviHtmlDialog.h" - -#include -#include - -namespace KviThemeFunctions -{ - bool installThemePackage(const QString &szThemePackageFileName,QString &szError,QWidget * pDialogParent = 0); - void getThemeHtmlDescription( - QString &szBuffer, - const QString &szThemeName, - const QString &szThemeVersion, - const QString &szThemeDescription, - const QString &szThemeSubdirectory, - const QString &szThemeApplication, - const QString &szThemeAuthor, - const QString &szThemeDate, - const QString &szThemeThemeEngineVersion, - const QPixmap &pixScreenshot, - int iUniqueIndexInDocument = 0, - KviHtmlDialogData *hd=0 - - ); - bool makeKVIrcScreenshot(const QString &szSavePngFilePath,bool bMaximizeFrame = false); -} - - - -#endif //!_THEMEFUNCTIONS_H_ -- cgit v1.3.1-10-gc9f91