From 690dd7a33ddc90678367d73adf313533536e10f2 Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Fri, 29 Apr 2016 23:57:30 +0100 Subject: Apply clang-format --- src/modules/theme/PackThemeDialog.cpp | 216 +++++++++++----------- src/modules/theme/PackThemeDialog.h | 35 ++-- src/modules/theme/SaveThemeDialog.cpp | 188 ++++++++++--------- src/modules/theme/SaveThemeDialog.h | 21 ++- src/modules/theme/ThemeFunctions.cpp | 255 +++++++++++++------------- src/modules/theme/ThemeFunctions.h | 48 +++-- src/modules/theme/ThemeManagementDialog.cpp | 191 ++++++++++--------- src/modules/theme/ThemeManagementDialog.h | 27 +-- src/modules/theme/WebThemeInterfaceDialog.cpp | 29 ++- src/modules/theme/WebThemeInterfaceDialog.h | 10 +- src/modules/theme/libkvitheme.cpp | 159 ++++++++-------- 11 files changed, 583 insertions(+), 596 deletions(-) (limited to 'src/modules/theme') diff --git a/src/modules/theme/PackThemeDialog.cpp b/src/modules/theme/PackThemeDialog.cpp index 838684003..65c56984b 100644 --- a/src/modules/theme/PackThemeDialog.cpp +++ b/src/modules/theme/PackThemeDialog.cpp @@ -54,56 +54,54 @@ //#include //#include - - PackThemeDialog::PackThemeDialog(QWidget * pParent, KviPointerList * pThemeInfoList) -: QWizard(pParent) + : QWizard(pParent) { - setWindowTitle(__tr2qs_ctx("Export Theme - KVIrc","theme")); - setMinimumSize(400,350); - setDefaultProperty("QTextEdit","plainText",SIGNAL(textChanged())); + 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 +#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); + setPixmap(QWizard::BackgroundPixmap, *pSide); #else // All other systems setWizardStyle(QWizard::ClassicStyle); - setPixmap(QWizard::WatermarkPixmap,*pSide); - setPixmap(QWizard::LogoPixmap,*pLogo); + setPixmap(QWizard::WatermarkPixmap, *pSide); + setPixmap(QWizard::LogoPixmap, *pLogo); #endif // Add a default property for file selectors - setDefaultProperty("KviFileSelector","tmpFile",SIGNAL(selectionChanged(const QString &))); + 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")); + 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 += __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 += __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 += __tr2qs_ctx("Hit the \"Next\" button to begin.", "theme"); szText += "

"; QLabel * pLabel = new QLabel(pPage); @@ -133,11 +131,11 @@ PackThemeDialog::PackThemeDialog(QWidget * pParent, KviPointerList } PackThemeDataWidget::PackThemeDataWidget(PackThemeDialog * pParent) -: QWizardPage(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 review your themes first.","theme")); + 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 review your themes first.", "theme")); } void PackThemeDataWidget::parseThemes(KviPointerList * pThemeInfoList) @@ -149,17 +147,18 @@ void PackThemeDataWidget::parseThemes(KviPointerList * pThemeInfoL KviThemeInfo * pThemeInfo = 0; bool bPackagePathSet = false; - QString szPackagePath = QDir::homePath(); - KviQString::ensureLastCharIs(szPackagePath,QChar(KVI_PATH_SEPARATOR_CHAR)); + KviQString::ensureLastCharIs(szPackagePath, QChar(KVI_PATH_SEPARATOR_CHAR)); if(pThemeInfoList->count() > 1) { szPackageName = "MyThemes"; - szPackageAuthor = __tr2qs_ctx("Your name here","theme"); + szPackageAuthor = __tr2qs_ctx("Your name here", "theme"); szPackageVersion = "1.0.0"; - szPackageDescription = __tr2qs_ctx("Enter a package description here...","theme"); - } else { + szPackageDescription = __tr2qs_ctx("Enter a package description here...", "theme"); + } + else + { if(pThemeInfoList->count() > 0) { pThemeInfo = pThemeInfoList->first(); @@ -208,18 +207,17 @@ void PackThemeDataWidget::parseThemes(KviPointerList * pThemeInfoL } ThemeFunctions::getThemeHtmlDescription( - szThemeDescription, - pThemeInfo->name(), - pThemeInfo->version(), - pThemeInfo->description(), - pThemeInfo->subdirectory(), - pThemeInfo->application(), - pThemeInfo->author(), - pThemeInfo->date(), - pThemeInfo->themeEngineVersion(), - pThemeInfo->smallScreenshot(), - iIdx - ); + szThemeDescription, + pThemeInfo->name(), + pThemeInfo->version(), + pThemeInfo->description(), + pThemeInfo->subdirectory(), + pThemeInfo->application(), + pThemeInfo->author(), + pThemeInfo->date(), + pThemeInfo->themeEngineVersion(), + pThemeInfo->smallScreenshot(), + iIdx); if(iIdx > 0) szThemesDescription += "


"; @@ -237,10 +235,10 @@ void PackThemeDataWidget::parseThemes(KviPointerList * pThemeInfoL pTextEdit->setDocument(pDoc); pLayout->addWidget(pTextEdit); - setField("packageName",QVariant(szPackageName)); - setField("packageVersion",szPackageVersion); - setField("packageDescription",szPackageDescription); - setField("packageAuthor",szPackageAuthor); + setField("packageName", QVariant(szPackageName)); + setField("packageVersion", szPackageVersion); + setField("packageDescription", szPackageDescription); + setField("packageAuthor", szPackageAuthor); } PackThemeDataWidget::~PackThemeDataWidget() @@ -248,60 +246,58 @@ PackThemeDataWidget::~PackThemeDataWidget() } PackThemeInfoWidget::PackThemeInfoWidget(PackThemeDialog * pParent) -: QWizardPage(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")); - + 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); + 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); + pLayout->addWidget(m_pPackageNameEdit, 1, 1); pLabel = new QLabel(this); - pLabel->setText(__tr2qs_ctx("Version:","theme")); - pLayout->addWidget(pLabel,2,0); + 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); + pLayout->addWidget(m_pPackageVersionEdit, 2, 1); pLabel = new QLabel(this); - pLabel->setText(__tr2qs_ctx("Description:","theme")); - pLayout->addWidget(pLabel,3,0); + 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); + pLayout->addWidget(m_pPackageDescriptionEdit, 3, 1); pLabel = new QLabel(this); - pLabel->setText(__tr2qs_ctx("Package author:","theme")); - pLayout->addWidget(pLabel,4,0); + 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->addWidget(m_pPackageAuthorEdit, 4, 1); - pLayout->setRowStretch(3,1); - pLayout->setColumnStretch(1,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); - + registerField("packageName*", m_pPackageNameEdit); + registerField("packageVersion*", m_pPackageVersionEdit); + registerField("packageDescription*", m_pPackageDescriptionEdit); + registerField("packageAuthor*", m_pPackageAuthorEdit); } void PackThemeInfoWidget::initializePage() { @@ -320,25 +316,25 @@ PackThemeInfoWidget::~PackThemeInfoWidget() } PackThemeImageWidget::PackThemeImageWidget(PackThemeDialog * pParent) -: QWizardPage(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")); + 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->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 &))); + 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); + registerField("packageImagePath*", m_pImageSelector); //m_pImageSelectionPage = pPage; } @@ -355,43 +351,45 @@ void PackThemeImageWidget::imageSelectionChanged(const QString & szImagePath) 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); + 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); + 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) + : 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)); + 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); + 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")); + 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); + registerField("packageSavePath*", m_pSavePathSelector); } PackThemeSaveWidget::~PackThemeSaveWidget() @@ -417,7 +415,8 @@ PackThemeDialog::~PackThemeDialog() void PackThemeDialog::accept() { - if(!packTheme()) return; + if(!packTheme()) + return; QWizard::accept(); } @@ -436,32 +435,27 @@ bool PackThemeDialog::packTheme() QString szError; - if(! - ThemeFunctions::packageThemes( - m_szPackagePath, - m_szName, - m_szVersion, - m_szDescription, - m_szAuthor, - m_szImagePath, - *m_pThemeInfoList, - szError - ) - ) + if(!ThemeFunctions::packageThemes( + m_szPackagePath, + m_szName, + m_szVersion, + m_szDescription, + m_szAuthor, + m_szImagePath, + *m_pThemeInfoList, + szError)) { QMessageBox::critical(this, - __tr2qs_ctx("Export Theme - KVIrc","theme"), - szError, - QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton - ); + __tr2qs_ctx("Export Theme - KVIrc", "theme"), + szError, + QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); return false; } QMessageBox::information(this, - __tr2qs_ctx("Exporting Theme - KVIrc","theme"), - __tr2qs("Theme package saved successfully."), - QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton - ); + __tr2qs_ctx("Exporting Theme - KVIrc", "theme"), + __tr2qs("Theme 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 index efe7a66f5..0fc4fe98e 100644 --- a/src/modules/theme/PackThemeDialog.h +++ b/src/modules/theme/PackThemeDialog.h @@ -48,20 +48,21 @@ class PackThemeDialog : public QWizard public: PackThemeDialog(QWidget * pParent, KviPointerList * pThemeInfoList); ~PackThemeDialog(); + protected: - PackThemeDataWidget * m_pPackThemeDataWidget; - PackThemeInfoWidget * m_pPackThemeInfoWidget; - PackThemeImageWidget * m_pPackThemeImageWidget; - PackThemeSaveWidget * m_pPackThemeSaveWidget; + 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; + 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: @@ -75,6 +76,7 @@ class PackThemeDataWidget : public QWizardPage public: PackThemeDataWidget(PackThemeDialog * pParent); ~PackThemeDataWidget(); + public: void parseThemes(KviPointerList * pThemeInfoList); }; @@ -85,11 +87,13 @@ class PackThemeInfoWidget : public QWizardPage public: PackThemeInfoWidget(PackThemeDialog * pParent); ~PackThemeInfoWidget(); + public: QLineEdit * m_pPackageNameEdit; QTextEdit * m_pPackageDescriptionEdit; QLineEdit * m_pPackageVersionEdit; QLineEdit * m_pPackageAuthorEdit; + protected: virtual void initializePage(); }; @@ -100,10 +104,11 @@ class PackThemeImageWidget : public QWizardPage public: PackThemeImageWidget(PackThemeDialog * pParent); ~PackThemeImageWidget(); + protected: KviFileSelector * m_pImageSelector; - QLabel * m_pImageLabel; - QString m_szImagePath; + QLabel * m_pImageLabel; + QString m_szImagePath; protected slots: void imageSelectionChanged(const QString & szImagePath); }; @@ -114,9 +119,11 @@ class PackThemeSaveWidget : public QWizardPage public: PackThemeSaveWidget(PackThemeDialog * pParent); ~PackThemeSaveWidget(); + protected: KviFileSelector * m_pSavePathSelector; - QString m_szPackagePath; + QString m_szPackagePath; + protected: virtual void initializePage(); }; diff --git a/src/modules/theme/SaveThemeDialog.cpp b/src/modules/theme/SaveThemeDialog.cpp index 5255a363a..e94ba10e0 100644 --- a/src/modules/theme/SaveThemeDialog.cpp +++ b/src/modules/theme/SaveThemeDialog.cpp @@ -55,16 +55,14 @@ #include #include - - SaveThemeDialog::SaveThemeDialog(QWidget * pParent) -: KviTalWizard(pParent) + : KviTalWizard(pParent) { - setWindowTitle(__tr2qs_ctx("Save Current Theme - KVIrc","theme")); - setMinimumSize(400,350); + setWindowTitle(__tr2qs_ctx("Save Current Theme - KVIrc", "theme")); + setMinimumSize(400, 350); KviThemeInfo info; - info.load(KVI_OPTION_STRING(KviOption_stringIconThemeSubdir),KviThemeInfo::Auto); + info.load(KVI_OPTION_STRING(KviOption_stringIconThemeSubdir), KviThemeInfo::Auto); // welcome page ================================================================================== QWidget * pPage = new QWidget(this); @@ -73,22 +71,22 @@ SaveThemeDialog::SaveThemeDialog(QWidget * pParent) 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 += __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 += __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 += __tr2qs_ctx("Hit the \"Next\" button to begin.", "theme"); szText += "

"; pLabel->setText(szText); - pLayout->addWidget(pLabel,0,0); - pLayout->setRowStretch(1,1); + 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); + addPage(pPage, __tr2qs_ctx("Welcome", "theme")); + setBackEnabled(pPage, false); + setNextEnabled(pPage, true); + setHelpEnabled(pPage, false); + setFinishEnabled(pPage, false); // packager information ================================================================================ @@ -96,83 +94,81 @@ SaveThemeDialog::SaveThemeDialog(QWidget * pParent) 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->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); + pLayout->addWidget(pLabel, 0, 0, 1, 2); pLabel = new QLabel(pPage); - pLabel->setText(__tr2qs_ctx("Theme name:","theme")); - pLayout->addWidget(pLabel,1,0); + pLabel->setText(__tr2qs_ctx("Theme name:", "theme")); + pLayout->addWidget(pLabel, 1, 0); m_pThemeNameEdit = new QLineEdit(pPage); m_pThemeNameEdit->setText(info.name()); - pLayout->addWidget(m_pThemeNameEdit,1,1); + pLayout->addWidget(m_pThemeNameEdit, 1, 1); pLabel = new QLabel(pPage); - pLabel->setText(__tr2qs_ctx("Version:","theme")); - pLayout->addWidget(pLabel,2,0); + pLabel->setText(__tr2qs_ctx("Version:", "theme")); + pLayout->addWidget(pLabel, 2, 0); m_pThemeVersionEdit = new QLineEdit(pPage); m_pThemeVersionEdit->setText(info.version()); QRegExp rx("\\d{1,2}\\.\\d{1,2}(\\.\\d{1,2})?"); - QValidator *validator = new QRegExpValidator(rx, this); + QValidator * validator = new QRegExpValidator(rx, this); m_pThemeVersionEdit->setValidator(validator); - pLayout->addWidget(m_pThemeVersionEdit,2,1); + pLayout->addWidget(m_pThemeVersionEdit, 2, 1); pLabel = new QLabel(pPage); - pLabel->setText(__tr2qs_ctx("Description:","theme")); - pLayout->addWidget(pLabel,3,0); + pLabel->setText(__tr2qs_ctx("Description:", "theme")); + pLayout->addWidget(pLabel, 3, 0); m_pThemeDescriptionEdit = new QTextEdit(pPage); m_pThemeDescriptionEdit->setText(info.description()); - pLayout->addWidget(m_pThemeDescriptionEdit,3,1); + pLayout->addWidget(m_pThemeDescriptionEdit, 3, 1); pLabel = new QLabel(pPage); - pLabel->setText(__tr2qs_ctx("Theme author:","theme")); - pLayout->addWidget(pLabel,4,0); + pLabel->setText(__tr2qs_ctx("Theme author:", "theme")); + pLayout->addWidget(pLabel, 4, 0); m_pAuthorNameEdit = new QLineEdit(pPage); m_pAuthorNameEdit->setText(info.author()); - pLayout->addWidget(m_pAuthorNameEdit,4,1); - + 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); + 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); // options page ================================================================================== pPage = new QWidget(this); pLayout = new QGridLayout(pPage); - m_pSaveIconsCheckBox = new QCheckBox(__tr2qs_ctx("Save icons and images with theme","theme"),this); + m_pSaveIconsCheckBox = new QCheckBox(__tr2qs_ctx("Save icons and images with theme", "theme"), this); m_pSaveIconsCheckBox->setChecked(true); pLabel = new QLabel(pPage); pLabel->setWordWrap(true); QString ozText = "

"; - ozText += __tr2qs_ctx("To use the default and latest icon/image set automatically, uncheck this option.

To replace specific icons/images in your theme, include only those you wish to replace.","theme"); + ozText += __tr2qs_ctx("To use the default and latest icon/image set automatically, uncheck this option.

To replace specific icons/images in your theme, include only those you wish to replace.", "theme"); ozText += "

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

"; - pLayout->addWidget(m_pSaveIconsCheckBox,0,0); + pLayout->addWidget(m_pSaveIconsCheckBox, 0, 0); pLabel->setText(ozText); - pLayout->addWidget(pLabel,1,0); - pLayout->setRowStretch(2,1); + pLayout->addWidget(pLabel, 1, 0); + pLayout->setRowStretch(2, 1); - addPage(pPage,__tr2qs_ctx("Theme options","theme")); - setBackEnabled(pPage,true); - setNextEnabled(pPage,true); - setHelpEnabled(pPage,false); - setFinishEnabled(pPage,false); + addPage(pPage, __tr2qs_ctx("Theme options", "theme")); + setBackEnabled(pPage, true); + setNextEnabled(pPage, true); + setHelpEnabled(pPage, false); + setFinishEnabled(pPage, false); // screenshot/logo/icon ================================================================================ @@ -180,80 +176,80 @@ SaveThemeDialog::SaveThemeDialog(QWidget * pParent) 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->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); + pLayout->addWidget(pLabel, 0, 0); m_pImageLabel = new QLabel(pPage); m_pImageLabel->setFrameStyle(QFrame::Sunken | QFrame::Panel); - m_pImageLabel->setMinimumSize(300,225); + m_pImageLabel->setMinimumSize(300, 225); m_pImageLabel->setAlignment(Qt::AlignCenter | Qt::AlignVCenter); - pLayout->addWidget(m_pImageLabel,1,0); + 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); + 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); + pButton->setText(__tr2qs_ctx("Make Screenshot Now", "theme")); + connect(pButton, SIGNAL(clicked()), this, SLOT(makeScreenshot())); + pLayout->addWidget(pButton, 3, 0); - pLayout->setRowStretch(1,1); + pLayout->setRowStretch(1, 1); m_pImageSelectionPage = pPage; - addPage(pPage,__tr2qs_ctx("Screenshot","theme")); - setBackEnabled(pPage,true); - setHelpEnabled(pPage,false); - setNextEnabled(pPage,false); // a screenshot should be ALWAYS provided. - setFinishEnabled(pPage,false); // a screenshot should be ALWAYS provided. - + addPage(pPage, __tr2qs_ctx("Screenshot", "theme")); + setBackEnabled(pPage, true); + setHelpEnabled(pPage, false); + setNextEnabled(pPage, false); // a screenshot should be ALWAYS provided. + setFinishEnabled(pPage, false); // a screenshot should be ALWAYS provided. } SaveThemeDialog::~SaveThemeDialog() { } -void SaveThemeDialog::imageSelectionChanged(const QString &szImagePath) +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)); + out = QPixmap::fromImage(pix.scaled(300, 225, Qt::KeepAspectRatio)); else out = QPixmap::fromImage(pix); m_pImageLabel->setPixmap(out); - setNextEnabled(m_pImageSelectionPage,true); - setFinishEnabled(m_pImageSelectionPage,true); + setNextEnabled(m_pImageSelectionPage, true); + setFinishEnabled(m_pImageSelectionPage, true); 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); + 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()); - setNextEnabled(m_pImageSelectionPage,false); - setFinishEnabled(m_pImageSelectionPage,false); + setNextEnabled(m_pImageSelectionPage, false); + setFinishEnabled(m_pImageSelectionPage, false); } void SaveThemeDialog::accept() { - if(!saveTheme())return; + if(!saveTheme()) + return; KviTalWizard::accept(); } void SaveThemeDialog::makeScreenshot() { QString szFileName; - g_pApp->getTmpFileName(szFileName,"screenshot.png"); + g_pApp->getTmpFileName(szFileName, "screenshot.png"); if(!ThemeFunctions::makeKVIrcScreenshot(szFileName)) { - QMessageBox::critical(this,__tr2qs_ctx("Acquire Screenshot - KVIrc","theme"),__tr2qs_ctx("Failed to make a theme screenshot.","theme"), - QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); + QMessageBox::critical(this, __tr2qs_ctx("Acquire Screenshot - KVIrc", "theme"), __tr2qs_ctx("Failed to make a theme screenshot.", "theme"), + QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); return; } m_pImageSelector->setSelection(szFileName); @@ -268,8 +264,8 @@ bool SaveThemeDialog::saveTheme() 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); + 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; } @@ -284,42 +280,42 @@ bool SaveThemeDialog::saveTheme() sto.setVersion("1.0.0"); QString szSubdir = sto.name() + QString("-") + sto.version(); - szSubdir.replace(QRegExp("[^a-zA-Z0-9_\\-.][^a-zA-Z0-9_\\-.]*"),"_"); - sto.setDirectoryAndLocation(szSubdir,KviThemeInfo::User); + szSubdir.replace(QRegExp("[^a-zA-Z0-9_\\-.][^a-zA-Z0-9_\\-.]*"), "_"); + sto.setDirectoryAndLocation(szSubdir, KviThemeInfo::User); QString szAbsDir = sto.directory(); 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); + 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; } - if(!KviTheme::save(sto,m_pSaveIconsCheckBox->isChecked())) + if(!KviTheme::save(sto, m_pSaveIconsCheckBox->isChecked())) { QString szErr = sto.lastError(); - QString szMsg2 = QString(__tr2qs_ctx("Unable to save theme: %1","theme")).arg(szErr); - QMessageBox::critical(this,__tr2qs_ctx("Save Current Theme - KVIrc","theme"),szMsg2, - QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); + QString szMsg2 = QString(__tr2qs_ctx("Unable to save theme: %1", "theme")).arg(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)) + 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); + 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 %1","theme").arg(szAbsDir); + QString szMsg = __tr2qs_ctx("Theme saved successfully to %1", "theme").arg(szAbsDir); - QMessageBox::information(this,__tr2qs_ctx("Save Current Theme - KVIrc","theme"),szMsg,QMessageBox::Ok, - QMessageBox::NoButton,QMessageBox::NoButton); + QMessageBox::information(this, __tr2qs_ctx("Save Current 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 index f9913e883..2f852615c 100644 --- a/src/modules/theme/SaveThemeDialog.h +++ b/src/modules/theme/SaveThemeDialog.h @@ -38,24 +38,25 @@ class QTextEdit; class QCheckBox; class KviFileSelector; - class SaveThemeDialog : public KviTalWizard { Q_OBJECT public: SaveThemeDialog(QWidget * pParent); virtual ~SaveThemeDialog(); + protected: - QString m_szScreenshotPath; + 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; - QCheckBox * m_pSaveIconsCheckBox; + QLabel * m_pImageLabel; + QLineEdit * m_pThemeNameEdit; + QTextEdit * m_pThemeDescriptionEdit; + QLineEdit * m_pThemeVersionEdit; + QLineEdit * m_pAuthorNameEdit; + QWidget * m_pImageSelectionPage; + QPushButton * m_pOkButton; + QCheckBox * m_pSaveIconsCheckBox; + protected: virtual void accept(); bool saveTheme(); diff --git a/src/modules/theme/ThemeFunctions.cpp b/src/modules/theme/ThemeFunctions.cpp index c49c08437..b2b8aa22d 100644 --- a/src/modules/theme/ThemeFunctions.cpp +++ b/src/modules/theme/ThemeFunctions.cpp @@ -45,19 +45,18 @@ //#include - namespace ThemeFunctions { - static bool notAValidThemePackage(QString &szError) + static bool notAValidThemePackage(QString & szError) { - szError = __tr2qs_ctx("The selected file doesn't seem to be a valid KVIrc theme package","theme"); + szError = __tr2qs_ctx("The selected file doesn't seem to be a valid KVIrc theme package", "theme"); return false; } - bool installThemePackage(const QString &szThemePackageFileName,QString &szError,QWidget * pDialogParent) + bool installThemePackage(const QString & szThemePackageFileName, QString & szError, QWidget * pDialogParent) { - KviPointerHashTable * pInfoFields; + KviPointerHashTable * pInfoFields; QString * pValue; bool bInstall; QPixmap pix; @@ -73,7 +72,7 @@ namespace ThemeFunctions { qDebug("The selected file doesn't seem to be a valid KVIrc package"); QString szErr = r.lastError(); - szError = QString(__tr2qs_ctx("The selected file doesn't seem to be a valid KVIrc package: %1","theme")).arg(szErr); + szError = QString(__tr2qs_ctx("The selected file doesn't seem to be a valid KVIrc package: %1", "theme")).arg(szErr); return false; } @@ -83,7 +82,7 @@ namespace ThemeFunctions if(!pValue) return notAValidThemePackage(szError); - if(!KviQString::equalCI(*pValue,"ThemePack")) + if(!KviQString::equalCI(*pValue, "ThemePack")) return notAValidThemePackage(szError); pValue = pInfoFields->find("ThemePackVersion"); @@ -92,10 +91,11 @@ namespace ThemeFunctions return notAValidThemePackage(szError); // make sure the default fields exist - for(int i=0;i<6;i++) + for(int i = 0; i < 6; i++) { pValue = pInfoFields->find(check_fields[i]); - if(!pValue)return notAValidThemePackage(szError); + if(!pValue) + return notAValidThemePackage(szError); } pValue = pInfoFields->find("ThemeCount"); @@ -115,7 +115,7 @@ namespace ThemeFunctions // load its picture pByteArray = r.binaryInfoFields()->find("Image"); if(pByteArray) - pix.loadFromData(*pByteArray,0,0); + pix.loadFromData(*pByteArray, 0, 0); if(pix.isNull()) { @@ -131,16 +131,16 @@ namespace ThemeFunctions QString szPackageThemeEngineVersion; QString szPackageApplication; - QString szAuthor = __tr2qs_ctx("Author","theme"); - QString szCreatedAt = __tr2qs_ctx("Created at","theme"); - QString szCreatedOn = __tr2qs_ctx("Created with","theme"); + 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); + 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 = ""; @@ -163,47 +163,46 @@ namespace ThemeFunctions QString szThemeApplication; szTmp = QString("Theme%1Name").arg(iIdx); - r.getStringInfoField(szTmp,szThemeName); + r.getStringInfoField(szTmp, szThemeName); szTmp = QString("Theme%1Version").arg(iIdx); - r.getStringInfoField(szTmp,szThemeVersion); + r.getStringInfoField(szTmp, szThemeVersion); szTmp = QString("Theme%1Application").arg(iIdx); - r.getStringInfoField(szTmp,szThemeApplication); + r.getStringInfoField(szTmp, szThemeApplication); szTmp = QString("Theme%1Description").arg(iIdx); - r.getStringInfoField(szTmp,szThemeDescription); + r.getStringInfoField(szTmp, szThemeDescription); szTmp = QString("Theme%1Date").arg(iIdx); - r.getStringInfoField(szTmp,szThemeDate); + r.getStringInfoField(szTmp, szThemeDate); szTmp = QString("Theme%1Subdirectory").arg(iIdx); - r.getStringInfoField(szTmp,szThemeSubdirectory); + r.getStringInfoField(szTmp, szThemeSubdirectory); szTmp = QString("Theme%1Author").arg(iIdx); - r.getStringInfoField(szTmp,szThemeAuthor); + r.getStringInfoField(szTmp, szThemeAuthor); szTmp = QString("Theme%1ThemeEngineVersion").arg(iIdx); - r.getStringInfoField(szTmp,szThemeEngineVersion); + r.getStringInfoField(szTmp, szThemeEngineVersion); szTmp = QString("Theme%1Screenshot").arg(iIdx); QPixmap pixScreenshot; pByteArray = r.binaryInfoFields()->find(szTmp); if(pByteArray) - pixScreenshot.loadFromData(*pByteArray,0,0); + 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) + 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 - ); + szDetailsBuffer, + szThemeName, + szThemeVersion, + szThemeDescription, + szThemeSubdirectory, + szThemeApplication, + szThemeAuthor, + szThemeDate, + szThemeEngineVersion, + pixScreenshot, + iIdx, &hd); if(iIdx > 0) szDetails += "


"; @@ -213,7 +212,7 @@ namespace ThemeFunctions if(!bValid) { szDetails += "

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

"; iValidThemeCount--; } @@ -222,18 +221,18 @@ namespace ThemeFunctions } szDetails += "

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

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

"; - szWarnings += __tr2qs_ctx("Warning: the theme contained in this package might be either corrupted or incompatible with this version of KVIrc","theme"); + szWarnings += __tr2qs_ctx("Warning: 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"); + QString szShowDetails = __tr2qs_ctx("Show Details", "theme"); // clang-format off hd.szHtmlText = QString( @@ -266,18 +265,18 @@ namespace ThemeFunctions "").arg(szPackageName,szPackageVersion,szPackageDescription,szAuthor,szPackageAuthor,szCreatedAt,szPackageDate,szCreatedOn,szPackageApplication).arg(szWarnings,szShowDetails); // clang-format on - hd.addImageResource("theme_dialog_pack_image",pix); - hd.addHtmlResource("theme_dialog_details",szDetails); - hd.addHtmlResource("theme_dialog_main",hd.szHtmlText); + 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.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(KviIconManager::Theme)); @@ -285,15 +284,15 @@ namespace ThemeFunctions hd.iMinimumHeight = 420; hd.iFlags = KviHtmlDialogData::ForceMinimumSize; - bInstall = KviHtmlDialog::display(pDialogParent,&hd) == 2; + bInstall = KviHtmlDialog::display(pDialogParent, &hd) == 2; if(bInstall) { QString szUnpackPath; - g_pApp->getLocalKvircDirectory(szUnpackPath,KviApplication::Themes); - if(!r.unpack(szThemePackageFileName,szUnpackPath)) + g_pApp->getLocalKvircDirectory(szUnpackPath, KviApplication::Themes); + if(!r.unpack(szThemePackageFileName, szUnpackPath)) { QString szErr2 = r.lastError(); - szError = QString(__tr2qs_ctx("Failed to unpack the selected file: %1","theme")).arg(szErr2); + szError = QString(__tr2qs_ctx("Failed to unpack the selected file: %1", "theme")).arg(szErr2); return false; } } @@ -301,27 +300,25 @@ namespace ThemeFunctions 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 & 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 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()) @@ -330,10 +327,13 @@ namespace ThemeFunctions QString szTmp; szTmp = QString("theme_shot%1").arg(iUniqueIndexInDocument); //FIXME in tooltip - if (hd) - hd->addImageResource(szTmp,pixScreenshot); - else szScreenshot = ""; - } else { + if(hd) + hd->addImageResource(szTmp, pixScreenshot); + else + szScreenshot = ""; + } + else + { szScreenshot = ""; } @@ -360,7 +360,7 @@ namespace ThemeFunctions // clang-format on } - bool makeKVIrcScreenshot(const QString &szSavePngFilePath,bool bMaximizeFrame) + bool makeKVIrcScreenshot(const QString & szSavePngFilePath, bool bMaximizeFrame) { if(bMaximizeFrame) { @@ -376,8 +376,9 @@ namespace ThemeFunctions if(pix.isNull()) bResult = false; - else { - if(!pix.save(szSavePngFilePath,"PNG")) + else + { + if(!pix.save(szSavePngFilePath, "PNG")) bResult = false; } @@ -386,27 +387,25 @@ namespace ThemeFunctions return bResult; } - bool packageThemes( - const QString &szPackagePath, - const QString &szPackageName, - const QString &szPackageVersion, - const QString &szPackageDescription, - const QString &szPackageAuthor, - const QString &szPackageImagePath, - KviPointerList &lThemeInfoList, - QString &szError - ) + const QString & szPackagePath, + const QString & szPackageName, + const QString & szPackageVersion, + const QString & szPackageDescription, + const QString & szPackageAuthor, + const QString & szPackageImagePath, + KviPointerList & lThemeInfoList, + QString & szError) { if(szPackagePath.isEmpty()) { - szError = __tr2qs_ctx("Invalid empty package path","theme"); + szError = __tr2qs_ctx("Invalid empty package path", "theme"); return false; } if(szPackageName.isEmpty()) { - szError = __tr2qs_ctx("Invalid empty package name","theme"); + szError = __tr2qs_ctx("Invalid empty package name", "theme"); return false; } @@ -417,93 +416,93 @@ namespace ThemeFunctions QImage pix(szPackageImagePath); if(pix.isNull()) { - szError = __tr2qs_ctx("Failed to load the selected image: please fix it","theme"); + szError = __tr2qs_ctx("Failed to load the selected image: please fix it", "theme"); return false; } if((pix.width() > 300) || (pix.height() > 225)) - out = out.fromImage(pix.scaled(300,225,Qt::KeepAspectRatio)); + out = out.fromImage(pix.scaled(300, 225, Qt::KeepAspectRatio)); else - out=out.fromImage(pix); + out = out.fromImage(pix); } KviPackageWriter f; - f.addInfoField("PackageType","ThemePack"); - f.addInfoField("ThemePackVersion",KVI_CURRENT_THEME_ENGINE_VERSION); - f.addInfoField("Name",szPackageName); - f.addInfoField("Version",szPackageVersion.isEmpty() ? "1.0.0" : szPackageVersion); - f.addInfoField("Author",szPackageAuthor); - f.addInfoField("Description",szPackageDescription); + f.addInfoField("PackageType", "ThemePack"); + f.addInfoField("ThemePackVersion", KVI_CURRENT_THEME_ENGINE_VERSION); + f.addInfoField("Name", szPackageName); + f.addInfoField("Version", szPackageVersion.isEmpty() ? "1.0.0" : szPackageVersion); + f.addInfoField("Author", szPackageAuthor); + f.addInfoField("Description", szPackageDescription); // this is the equivalent to an empty date.toString() call, but it's needed // to ensure qt4 will use the default() locale and not the system() one - f.addInfoField("Date",QDateTime::currentDateTime().toString(Qt::ISODate)); - f.addInfoField("Application","KVIrc " KVI_VERSION "." KVI_SOURCES_DATE); + f.addInfoField("Date", QDateTime::currentDateTime().toString(Qt::ISODate)); + f.addInfoField("Application", "KVIrc " KVI_VERSION "." KVI_SOURCES_DATE); if(!out.isNull()) { QByteArray * pba = new QByteArray(); - QBuffer buffer(pba,0); + QBuffer buffer(pba, 0); buffer.open(QIODevice::WriteOnly); - out.save(&buffer,"PNG"); + out.save(&buffer, "PNG"); buffer.close(); - f.addInfoField("Image",pba); // cool :) [no disk access needed] + f.addInfoField("Image", pba); // cool :) [no disk access needed] } QString szTmp; szTmp.setNum(lThemeInfoList.count()); - f.addInfoField("ThemeCount",szTmp); + f.addInfoField("ThemeCount", szTmp); int iIdx = 0; - for(KviThemeInfo * pInfo = lThemeInfoList.first();pInfo;pInfo = lThemeInfoList.next()) + for(KviThemeInfo * pInfo = lThemeInfoList.first(); pInfo; pInfo = lThemeInfoList.next()) { if(pInfo->name().isEmpty()) { - szError = __tr2qs_ctx("Invalid theme name","theme"); + szError = __tr2qs_ctx("Invalid theme name", "theme"); return false; } if(pInfo->version().isEmpty()) { - szError = __tr2qs_ctx("Invalid theme version","theme"); + szError = __tr2qs_ctx("Invalid theme version", "theme"); return false; } QString szSubdir = pInfo->name() + QString("-") + pInfo->version(); - szSubdir.replace(QRegExp("[^a-zA-Z0-9_\\-.][^a-zA-Z0-9_\\-.]*"),"_"); + szSubdir.replace(QRegExp("[^a-zA-Z0-9_\\-.][^a-zA-Z0-9_\\-.]*"), "_"); szTmp = QString("Theme%1Name").arg(iIdx); - f.addInfoField(szTmp,pInfo->name()); + f.addInfoField(szTmp, pInfo->name()); szTmp = QString("Theme%1Version").arg(iIdx); - f.addInfoField(szTmp,pInfo->version()); + f.addInfoField(szTmp, pInfo->version()); szTmp = QString("Theme%1Description").arg(iIdx); - f.addInfoField(szTmp,pInfo->description()); + f.addInfoField(szTmp, pInfo->description()); szTmp = QString("Theme%1Date").arg(iIdx); - f.addInfoField(szTmp,pInfo->date()); + f.addInfoField(szTmp, pInfo->date()); szTmp = QString("Theme%1Subdirectory").arg(iIdx); - f.addInfoField(szTmp,szSubdir); + f.addInfoField(szTmp, szSubdir); szTmp = QString("Theme%1Author").arg(iIdx); - f.addInfoField(szTmp,pInfo->author()); + f.addInfoField(szTmp, pInfo->author()); szTmp = QString("Theme%1Application").arg(iIdx); - f.addInfoField(szTmp,pInfo->application()); + f.addInfoField(szTmp, pInfo->application()); szTmp = QString("Theme%1ThemeEngineVersion").arg(iIdx); - f.addInfoField(szTmp,pInfo->themeEngineVersion()); + f.addInfoField(szTmp, pInfo->themeEngineVersion()); QPixmap pixScreenshot = pInfo->smallScreenshot(); if(!pixScreenshot.isNull()) { szTmp = QString("Theme%1Screenshot").arg(iIdx); QByteArray * pba = new QByteArray(); - QBuffer bufferz(pba,0); + QBuffer bufferz(pba, 0); bufferz.open(QIODevice::WriteOnly); - pixScreenshot.save(&bufferz,"PNG"); + pixScreenshot.save(&bufferz, "PNG"); bufferz.close(); - f.addInfoField(szTmp,pba); + f.addInfoField(szTmp, pba); } - if(!f.addDirectory(pInfo->directory(),szSubdir)) + if(!f.addDirectory(pInfo->directory(), szSubdir)) { - szError = __tr2qs_ctx("Packaging failed","theme"); + szError = __tr2qs_ctx("Packaging failed", "theme"); szError += ": "; szError += f.lastError(); return false; @@ -514,7 +513,7 @@ namespace ThemeFunctions if(!f.pack(szPackagePath)) { - szError = __tr2qs_ctx("Packaging failed","theme"); + szError = __tr2qs_ctx("Packaging failed", "theme"); szError += ": "; szError += f.lastError(); return false; diff --git a/src/modules/theme/ThemeFunctions.h b/src/modules/theme/ThemeFunctions.h index e427db83e..f4b68fdf9 100644 --- a/src/modules/theme/ThemeFunctions.h +++ b/src/modules/theme/ThemeFunctions.h @@ -35,37 +35,33 @@ namespace ThemeFunctions { - bool installThemePackage(const QString &szThemePackageFileName,QString &szError,QWidget * pDialogParent = 0); + 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 - ); + 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); + bool makeKVIrcScreenshot(const QString & szSavePngFilePath, bool bMaximizeFrame = false); bool packageThemes( - const QString &szPackagePath, - const QString &szPackageName, - const QString &szPackageVersion, - const QString &szPackageDescription, - const QString &szPackageAuthor, - const QString &szPackageImagePath, - KviPointerList &lThemeInfo, - QString &szError - ); + const QString & szPackagePath, + const QString & szPackageName, + const QString & szPackageVersion, + const QString & szPackageDescription, + const QString & szPackageAuthor, + const QString & szPackageImagePath, + KviPointerList & lThemeInfo, + QString & szError); } - - #endif //!_THEMEFUNCTIONS_H_ diff --git a/src/modules/theme/ThemeManagementDialog.cpp b/src/modules/theme/ThemeManagementDialog.cpp index a5394a530..1358961b6 100644 --- a/src/modules/theme/ThemeManagementDialog.cpp +++ b/src/modules/theme/ThemeManagementDialog.cpp @@ -24,7 +24,7 @@ #include "kvi_settings.h" #if defined(COMPILE_WEBKIT_SUPPORT) - #include "WebThemeInterfaceDialog.h" +#include "WebThemeInterfaceDialog.h" #endif #include "ThemeManagementDialog.h" @@ -72,7 +72,7 @@ extern QRect g_rectManagementDialogGeometry; ThemeListWidgetItem::ThemeListWidgetItem(KviTalListWidget * pBox, KviThemeInfo * pInfo) -: KviTalListWidgetItem(pBox) + : KviTalListWidgetItem(pBox) { m_pThemeInfo = pInfo; @@ -91,7 +91,7 @@ ThemeListWidgetItem::ThemeListWidgetItem(KviTalListWidget * pBox, KviThemeInfo * if(!pInfo->author().isEmpty()) { szText += " "; - szText += __tr2qs_ctx("by","theme"); + szText += __tr2qs_ctx("by", "theme"); szText += " "; szText += pInfo->author(); szText += ""; @@ -111,16 +111,15 @@ ThemeListWidgetItem::~ThemeListWidgetItem() ThemeManagementDialog * ThemeManagementDialog::m_pInstance = 0; - ThemeManagementDialog::ThemeManagementDialog(QWidget * parent) -: QWidget(parent) + : QWidget(parent) { m_pItemDelegate = NULL; #ifdef COMPILE_WEBKIT_SUPPORT m_pWebThemeInterfaceDialog = NULL; #endif setObjectName("theme_options_widget"); - setWindowTitle(__tr2qs_ctx("Manage Themes - KVIrc","theme")); + setWindowTitle(__tr2qs_ctx("Manage Themes - KVIrc", "theme")); setWindowIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Theme))); m_pInstance = this; @@ -137,9 +136,9 @@ ThemeManagementDialog::ThemeManagementDialog(QWidget * parent) pTool = new QToolButton(pHBox); pTool->setIcon(*(g_pIconManager->getBigIcon(KVI_BIGICON_SAVE))); - pTool->setIconSize(QSize(32,32)); - pTool->setToolTip(__tr2qs_ctx("Save current theme...","theme")); - connect(pTool,SIGNAL(clicked()),this,SLOT(saveCurrentTheme())); + pTool->setIconSize(QSize(32, 32)); + pTool->setToolTip(__tr2qs_ctx("Save current theme...", "theme")); + connect(pTool, SIGNAL(clicked()), this, SLOT(saveCurrentTheme())); pSep = new QFrame(pHBox); pSep->setFrameStyle(QFrame::VLine | QFrame::Sunken); @@ -148,15 +147,15 @@ ThemeManagementDialog::ThemeManagementDialog(QWidget * parent) m_pPackThemeButton = new QToolButton(pHBox); m_pPackThemeButton->setIcon(*(g_pIconManager->getBigIcon(KVI_BIGICON_PACK))); - m_pPackThemeButton->setIconSize(QSize(32,32)); - m_pPackThemeButton->setToolTip(__tr2qs_ctx("Export selected themes to a distributable package","theme")); - connect(m_pPackThemeButton,SIGNAL(clicked()),this,SLOT(packTheme())); + m_pPackThemeButton->setIconSize(QSize(32, 32)); + m_pPackThemeButton->setToolTip(__tr2qs_ctx("Export selected themes to a distributable package", "theme")); + connect(m_pPackThemeButton, SIGNAL(clicked()), this, SLOT(packTheme())); m_pDeleteThemeButton = new QToolButton(pHBox); m_pDeleteThemeButton->setIcon(*(g_pIconManager->getBigIcon(KVI_BIGICON_REMOVE))); - m_pDeleteThemeButton->setIconSize(QSize(32,32)); - m_pDeleteThemeButton->setToolTip(__tr2qs_ctx("Delete selected themes","theme")); - connect(m_pDeleteThemeButton,SIGNAL(clicked()),this,SLOT(deleteTheme())); + m_pDeleteThemeButton->setIconSize(QSize(32, 32)); + m_pDeleteThemeButton->setToolTip(__tr2qs_ctx("Delete selected themes", "theme")); + connect(m_pDeleteThemeButton, SIGNAL(clicked()), this, SLOT(deleteTheme())); pSep = new QFrame(pHBox); pSep->setFrameStyle(QFrame::VLine | QFrame::Sunken); @@ -164,39 +163,38 @@ ThemeManagementDialog::ThemeManagementDialog(QWidget * parent) pTool = new QToolButton(pHBox); pTool->setIcon(*(g_pIconManager->getBigIcon(KVI_BIGICON_OPEN))); - pTool->setIconSize(QSize(32,32)); - pTool->setToolTip(__tr2qs_ctx("Install theme package from disk","theme")); - connect(pTool,SIGNAL(clicked()),this,SLOT(installFromFile())); + pTool->setIconSize(QSize(32, 32)); + pTool->setToolTip(__tr2qs_ctx("Install theme package from disk", "theme")); + connect(pTool, SIGNAL(clicked()), this, SLOT(installFromFile())); pTool = new QToolButton(pHBox); pTool->setIcon(*(g_pIconManager->getBigIcon(KVI_BIGICON_WWW))); - pTool->setIconSize(QSize(32,32)); - pTool->setToolTip(__tr2qs_ctx("Get more themes...","theme")); - connect(pTool,SIGNAL(clicked()),this,SLOT(getMoreThemes())); + pTool->setIconSize(QSize(32, 32)); + pTool->setToolTip(__tr2qs_ctx("Get more themes...", "theme")); + connect(pTool, SIGNAL(clicked()), this, SLOT(getMoreThemes())); - QWidget *w= new QWidget(pHBox); - w->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum); + QWidget * w = new QWidget(pHBox); + w->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); m_pListWidget = new KviTalListWidget(this); m_pListWidget->setContextMenuPolicy(Qt::CustomContextMenu); m_pItemDelegate = new KviTalIconAndRichTextItemDelegate(m_pListWidget); - m_pItemDelegate->setDefaultIcon(g_pIconManager->getBigIcon(QString(KVI_BIGICON_THEME))->scaled(64,64,Qt::KeepAspectRatio)); // FIXME! - m_pItemDelegate->setMinimumSize(QSize(64,64)); - m_pItemDelegate->setIconSize(QSize(64,64)); + m_pItemDelegate->setDefaultIcon(g_pIconManager->getBigIcon(QString(KVI_BIGICON_THEME))->scaled(64, 64, Qt::KeepAspectRatio)); // FIXME! + m_pItemDelegate->setMinimumSize(QSize(64, 64)); + m_pItemDelegate->setIconSize(QSize(64, 64)); m_pListWidget->setItemDelegate(m_pItemDelegate); m_pListWidget->setMinimumHeight(400); m_pListWidget->setMinimumWidth(520); m_pListWidget->setSelectionMode(QAbstractItemView::ExtendedSelection); m_pListWidget->setSortingEnabled(true); - connect(m_pListWidget,SIGNAL(itemDoubleClicked(QListWidgetItem *)),this,SLOT(applyTheme(QListWidgetItem *))); - + connect(m_pListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(applyTheme(QListWidgetItem *))); //FIXME tooltip //connect(m_pListWidget,SIGNAL(tipRequest(QListWidgetItem *,const QPoint &)),this,SLOT(tipRequest(QListWidgetItem *,const QPoint &))); - connect(m_pListWidget,SIGNAL(customContextMenuRequested(const QPoint &)), - this,SLOT(contextMenuRequested(const QPoint &))); - connect(m_pListWidget,SIGNAL(itemSelectionChanged()),this,SLOT(enableDisableButtons())); + connect(m_pListWidget, SIGNAL(customContextMenuRequested(const QPoint &)), + this, SLOT(contextMenuRequested(const QPoint &))); + connect(m_pListWidget, SIGNAL(itemSelectionChanged()), this, SLOT(enableDisableButtons())); pSep = new QFrame(this); pSep->setFrameStyle(QFrame::HLine | QFrame::Sunken); @@ -207,32 +205,32 @@ ThemeManagementDialog::ThemeManagementDialog(QWidget * parent) //g->addWidget(pSep,2,0); m_pCurrentInstalledThemeLabel = new QLabel(this); - m_pCurrentInstalledThemeLabel->setText(__tr2qs_ctx("Current Installed Theme: ","theme") + " " + KVI_OPTION_STRING(KviOption_stringIconThemeSubdir) + ""); -// g->addWidget(pLabel,2,0); + m_pCurrentInstalledThemeLabel->setText(__tr2qs_ctx("Current Installed Theme: ", "theme") + " " + KVI_OPTION_STRING(KviOption_stringIconThemeSubdir) + ""); + // g->addWidget(pLabel,2,0); pVBox->addWidget(m_pCurrentInstalledThemeLabel); pSep = new QFrame(this); pSep->setFrameStyle(QFrame::HLine | QFrame::Sunken); pSep->setMinimumWidth(400); -// g->addWidget(pSep,3,0); + // g->addWidget(pSep,3,0); pVBox->addWidget(pSep); -// g->addWidget(m_pListWidget,4,0); + // g->addWidget(m_pListWidget,4,0); pVBox->addWidget(m_pListWidget); -// KviDynamicToolTip * tip = new KviDynamicToolTip(m_pListWidget); -// connect(tip,SIGNAL(tipRequest(KviDynamicToolTip *,const QPoint &)),this,SLOT(tipRequest(KviDynamicToolTip *,const QPoint &))); + // KviDynamicToolTip * tip = new KviDynamicToolTip(m_pListWidget); + // connect(tip,SIGNAL(tipRequest(KviDynamicToolTip *,const QPoint &)),this,SLOT(tipRequest(KviDynamicToolTip *,const QPoint &))); - QPushButton * b = new QPushButton(__tr2qs("Close"),this); - b->setMaximumSize(b->sizeHint().width(),b->sizeHint().height()); - connect(b,SIGNAL(clicked()),this,SLOT(closeClicked())); -// g->addWidget(b,5,0); + QPushButton * b = new QPushButton(__tr2qs("Close"), this); + b->setMaximumSize(b->sizeHint().width(), b->sizeHint().height()); + connect(b, SIGNAL(clicked()), this, SLOT(closeClicked())); + // g->addWidget(b,5,0); pVBox->addWidget(b); -// g->setMargin(1); -// g->setSpacing(1); - pVBox->setAlignment(b,Qt::AlignRight); + // g->setMargin(1); + // g->setSpacing(1); + pVBox->setAlignment(b, Qt::AlignRight); fillThemeBox(); m_pContextPopup = new QMenu(this); @@ -241,18 +239,19 @@ ThemeManagementDialog::ThemeManagementDialog(QWidget * parent) g_rectManagementDialogGeometry.setY(5); } resize(g_rectManagementDialogGeometry.width(), - g_rectManagementDialogGeometry.height()); + g_rectManagementDialogGeometry.height()); QRect rect = g_pApp->desktop()->screenGeometry(g_pMainWindow); - move(rect.x() + ((rect.width() - g_rectManagementDialogGeometry.width())/2),rect.y() + ((rect.height() - g_rectManagementDialogGeometry.height())/2)); + move(rect.x() + ((rect.width() - g_rectManagementDialogGeometry.width()) / 2), rect.y() + ((rect.height() - g_rectManagementDialogGeometry.height()) / 2)); new QShortcut(Qt::Key_Escape, this, SLOT(closeClicked())); } ThemeManagementDialog::~ThemeManagementDialog() { - if (m_pItemDelegate) delete m_pItemDelegate; - g_rectManagementDialogGeometry = QRect(pos().x(),pos().y(),size().width(),size().height()); + if(m_pItemDelegate) + delete m_pItemDelegate; + g_rectManagementDialogGeometry = QRect(pos().x(), pos().y(), size().width(), size().height()); m_pInstance = 0; #ifdef COMPILE_WEBKIT_SUPPORT if(m_pWebThemeInterfaceDialog) @@ -279,17 +278,23 @@ void ThemeManagementDialog::display(bool bTopLevel) { m_pInstance->setParent(0); } - } else { + } + else + { if(m_pInstance->parent() != g_pMainWindow->splitter()) { m_pInstance->setParent(g_pMainWindow->splitter()); } } - } else { + } + else + { if(bTopLevel) { m_pInstance = new ThemeManagementDialog(0); - } else { + } + else + { m_pInstance = new ThemeManagementDialog(g_pMainWindow->splitter()); } } @@ -300,7 +305,8 @@ void ThemeManagementDialog::display(bool bTopLevel) void ThemeManagementDialog::cleanup() { - if(!m_pInstance)return; + if(!m_pInstance) + return; delete m_pInstance; m_pInstance = 0; } @@ -309,12 +315,13 @@ void ThemeManagementDialog::packTheme() { KviPointerList dl; dl.setAutoDelete(false); - QList itemsSelected = m_pListWidget->selectedItems (); - for(int i=0;i itemsSelected = m_pListWidget->selectedItems(); + for(int i = 0; i < itemsSelected.count(); i++) dl.append(((ThemeListWidgetItem *)itemsSelected.at(i))->themeInfo()); - if(dl.isEmpty())return; + if(dl.isEmpty()) + return; - PackThemeDialog * pDialog = new PackThemeDialog(this,&dl); + PackThemeDialog * pDialog = new PackThemeDialog(this, &dl); pDialog->exec(); pDialog->deleteLater(); } @@ -332,9 +339,9 @@ void ThemeManagementDialog::contextMenuRequested(const QPoint & pos) return; if(!pInfo->isBuiltin()) - m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Discard)),__tr2qs_ctx("&Remove Theme","theme"),this,SLOT(deleteTheme())); + m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Discard)), __tr2qs_ctx("&Remove Theme", "theme"), this, SLOT(deleteTheme())); - m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Accept)),__tr2qs_ctx("&Apply Theme","theme"),this,SLOT(applyCurrentTheme())); + m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Accept)), __tr2qs_ctx("&Apply Theme", "theme"), this, SLOT(applyCurrentTheme())); m_pContextPopup->popup(m_pListWidget->viewport()->mapToGlobal(pos)); } } @@ -352,32 +359,32 @@ void ThemeManagementDialog::applyCurrentTheme() if(!it) return; - if(!KviMessageBox::yesNo(__tr2qs_ctx("Apply Theme - KVIrc","theme"), - __tr2qs_ctx("Do you wish to apply theme \"%Q\" (version %Q)?","theme"), - &(it->themeInfo()->name()),&(it->themeInfo()->version()))) + if(!KviMessageBox::yesNo(__tr2qs_ctx("Apply Theme - KVIrc", "theme"), + __tr2qs_ctx("Do you wish to apply theme \"%Q\" (version %Q)?", "theme"), + &(it->themeInfo()->name()), &(it->themeInfo()->version()))) return; KviThemeInfo out; //qDebug("Apply theme item %x, info %x, %s : %s at location %d",(long)it,(long)it->themeInfo(),it->themeInfo()->directory().toUtf8().data(),it->themeInfo()->subdirectory().toUtf8().data(),it->themeInfo()->location()); - if(!KviTheme::apply(it->themeInfo()->subdirectory(),it->themeInfo()->location(),out)) + if(!KviTheme::apply(it->themeInfo()->subdirectory(), it->themeInfo()->location(), out)) { QString szErr = out.lastError(); - QString szMsg = QString(__tr2qs_ctx("Failed to apply the specified theme: %1","theme")).arg(szErr); - QMessageBox::critical(this,__tr2qs_ctx("Apply Theme - KVIrc","theme"),szMsg, - QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); + QString szMsg = QString(__tr2qs_ctx("Failed to apply the specified theme: %1", "theme")).arg(szErr); + QMessageBox::critical(this, __tr2qs_ctx("Apply Theme - KVIrc", "theme"), szMsg, + QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); return; } - m_pCurrentInstalledThemeLabel->setText(QString(__tr2qs_ctx("Current Installed Theme: %1","theme")).arg(KVI_OPTION_STRING(KviOption_stringIconThemeSubdir))); - m_pItemDelegate->setDefaultIcon(g_pIconManager->getBigIcon(QString(KVI_BIGICON_THEME))->scaled(64,64,Qt::KeepAspectRatio)); + m_pCurrentInstalledThemeLabel->setText(QString(__tr2qs_ctx("Current Installed Theme: %1", "theme")).arg(KVI_OPTION_STRING(KviOption_stringIconThemeSubdir))); + m_pItemDelegate->setDefaultIcon(g_pIconManager->getBigIcon(QString(KVI_BIGICON_THEME))->scaled(64, 64, Qt::KeepAspectRatio)); } void ThemeManagementDialog::deleteTheme() { QList itemsSelected = m_pListWidget->selectedItems(); - for(int i=0; i < itemsSelected.count(); i++) + for(int i = 0; i < itemsSelected.count(); i++) { ThemeListWidgetItem * pItem = dynamic_cast(itemsSelected.at(i)); if(!pItem) @@ -387,10 +394,9 @@ void ThemeManagementDialog::deleteTheme() continue; if(!KviMessageBox::yesNo( - __tr2qs_ctx("Delete Selected Theme - KVIrc","theme"), - __tr2qs_ctx("Do you really wish to delete theme \"%Q\" (version %Q)?","theme"), - &(pInfo->name()), &(pInfo->version())) - ) + __tr2qs_ctx("Delete Selected Theme - KVIrc", "theme"), + __tr2qs_ctx("Do you really wish to delete theme \"%Q\" (version %Q)?", "theme"), + &(pInfo->name()), &(pInfo->version()))) goto jump_out; QString szThemePath = ((ThemeListWidgetItem *)itemsSelected.at(i))->themeInfo()->directory(); @@ -406,17 +412,16 @@ void ThemeManagementDialog::installFromFile() QString szError; if(!KviFileDialog::askForOpenFileName( - szFileName, - __tr2qs_ctx("Select a Installation File - KVIrc","theme"), - QString(), - KVI_FILTER_THEME, - false, - true, - this) - ) + szFileName, + __tr2qs_ctx("Select a Installation File - KVIrc", "theme"), + QString(), + KVI_FILTER_THEME, + false, + true, + this)) return; - if(!ThemeFunctions::installThemePackage(szFileName,szError,this)) + if(!ThemeFunctions::installThemePackage(szFileName, szError, this)) { KviMessageBox::information(szError); return; @@ -431,9 +436,11 @@ void ThemeManagementDialog::getMoreThemes() if(m_pWebThemeInterfaceDialog) { m_pWebThemeInterfaceDialog->show(); - } else { + } + else + { m_pWebThemeInterfaceDialog = new WebThemeInterfaceDialog(); - QObject::connect(m_pWebThemeInterfaceDialog,SIGNAL(destroyed()),this,SLOT(webThemeInterfaceDialogDestroyed())); + QObject::connect(m_pWebThemeInterfaceDialog, SIGNAL(destroyed()), this, SLOT(webThemeInterfaceDialogDestroyed())); m_pWebThemeInterfaceDialog->show(); } #else @@ -462,23 +469,25 @@ void ThemeManagementDialog::saveCurrentTheme() void ThemeManagementDialog::fillThemeBox(bool bBuiltin) { QStringList slThemes; - KviTheme::installedThemeDirectories(slThemes,bBuiltin ? KviThemeInfo::Builtin : KviThemeInfo::User); + KviTheme::installedThemeDirectories(slThemes, bBuiltin ? KviThemeInfo::Builtin : KviThemeInfo::User); - for(int i=0;iload(slThemes.at(i),bBuiltin ? KviThemeInfo::Builtin : KviThemeInfo::User)) + if(inf->load(slThemes.at(i), bBuiltin ? KviThemeInfo::Builtin : KviThemeInfo::User)) { - ThemeListWidgetItem *it=new ThemeListWidgetItem(m_pListWidget,inf); + ThemeListWidgetItem * it = new ThemeListWidgetItem(m_pListWidget, inf); //qDebug("Item %x, info %x, info2 %x, %s : %s at location %d",(long)it,(long)inf,(long)it->themeInfo(),it->themeInfo()->directory().toUtf8().data(),it->themeInfo()->subdirectory().toUtf8().data(),it->themeInfo()->location()); - QPixmap pixmap=inf->smallScreenshot(); + QPixmap pixmap = inf->smallScreenshot(); if(!pixmap.isNull()) - it->setIcon(pixmap.scaled(300,280,Qt::KeepAspectRatio)); - } else { + it->setIcon(pixmap.scaled(300, 280, Qt::KeepAspectRatio)); + } + else + { delete inf; } } @@ -522,7 +531,7 @@ void ThemeManagementDialog::closeEvent(QCloseEvent * e) deleteLater(); } -void ThemeManagementDialog::tipRequest(QListWidgetItem *,const QPoint &) +void ThemeManagementDialog::tipRequest(QListWidgetItem *, const QPoint &) { // FIXME /* diff --git a/src/modules/theme/ThemeManagementDialog.h b/src/modules/theme/ThemeManagementDialog.h index b991c76c0..b09b4b2c8 100644 --- a/src/modules/theme/ThemeManagementDialog.h +++ b/src/modules/theme/ThemeManagementDialog.h @@ -40,7 +40,7 @@ #include "kvi_settings.h" #if defined(COMPILE_WEBKIT_SUPPORT) || defined(Q_MOC_RUN) - #include "WebThemeInterfaceDialog.h" +#include "WebThemeInterfaceDialog.h" #endif class QLineEdit; @@ -51,36 +51,39 @@ class KviDynamicToolTip; class ThemeListWidgetItem : public KviTalListWidgetItem { public: - ThemeListWidgetItem(KviTalListWidget * pBox,KviThemeInfo * pInfo); + ThemeListWidgetItem(KviTalListWidget * pBox, KviThemeInfo * pInfo); virtual ~ThemeListWidgetItem(); + public: KviThemeInfo * m_pThemeInfo; + public: - KviThemeInfo * themeInfo(){ return m_pThemeInfo; } + KviThemeInfo * themeInfo() { return m_pThemeInfo; } }; - class ThemeManagementDialog : public QWidget { Q_OBJECT public: ThemeManagementDialog(QWidget * parent); virtual ~ThemeManagementDialog(); + protected: - static ThemeManagementDialog * m_pInstance; + static ThemeManagementDialog * m_pInstance; KviTalIconAndRichTextItemDelegate * m_pItemDelegate; - KviTalListWidget * m_pListWidget; - QLabel * m_pCurrentInstalledThemeLabel; - QMenu * m_pContextPopup; - QToolButton * m_pDeleteThemeButton; - QToolButton * m_pPackThemeButton; + KviTalListWidget * m_pListWidget; + QLabel * m_pCurrentInstalledThemeLabel; + QMenu * m_pContextPopup; + QToolButton * m_pDeleteThemeButton; + QToolButton * m_pPackThemeButton; #if defined(COMPILE_WEBKIT_SUPPORT) || defined(Q_MOC_RUN) - WebThemeInterfaceDialog * m_pWebThemeInterfaceDialog; + WebThemeInterfaceDialog * m_pWebThemeInterfaceDialog; #endif public: - static ThemeManagementDialog * instance(){ return m_pInstance; } + static ThemeManagementDialog * instance() { return m_pInstance; } static void display(bool bTopLevel); static void cleanup(); + protected: void fillThemeBox(bool bBuiltin); virtual void closeEvent(QCloseEvent * e); diff --git a/src/modules/theme/WebThemeInterfaceDialog.cpp b/src/modules/theme/WebThemeInterfaceDialog.cpp index 7ba7c8a27..a1bf456f2 100644 --- a/src/modules/theme/WebThemeInterfaceDialog.cpp +++ b/src/modules/theme/WebThemeInterfaceDialog.cpp @@ -24,7 +24,6 @@ #include "kvi_settings.h" - #ifdef COMPILE_WEBKIT_SUPPORT #include "WebThemeInterfaceDialog.h" @@ -35,44 +34,38 @@ #include "KviIconManager.h" #include "KviLocale.h" - WebThemeInterfaceDialog::WebThemeInterfaceDialog(QWidget * par) -: KviWebPackageManagementDialog(par) + : KviWebPackageManagementDialog(par) { - setWindowTitle(__tr2qs_ctx("Download Themes - KVIrc","theme")); + setWindowTitle(__tr2qs_ctx("Download Themes - KVIrc", "theme")); // local dir for user defined themes - g_pApp->getLocalKvircDirectory(m_szLocalThemesPath,KviApplication::Themes); + g_pApp->getLocalKvircDirectory(m_szLocalThemesPath, KviApplication::Themes); m_szLocalThemesPath += KVI_PATH_SEPARATOR_CHAR; // global dir for builtin themes - g_pApp->getGlobalKvircDirectory(m_szGlobalThemesPath,KviApplication::Themes); + g_pApp->getGlobalKvircDirectory(m_szGlobalThemesPath, KviApplication::Themes); m_szGlobalThemesPath += KVI_PATH_SEPARATOR_CHAR; setPackagePageUrl( - QString::fromLatin1("http://www.kvirc.de/app/themes.php?version=" KVI_VERSION "&lang=%1") - .arg(QString::fromUtf8(KviLocale::instance()->localeName().ptr())) - ); + QString::fromLatin1("http://www.kvirc.de/app/themes.php?version=" KVI_VERSION "&lang=%1") + .arg(QString::fromUtf8(KviLocale::instance()->localeName().ptr()))); } WebThemeInterfaceDialog::~WebThemeInterfaceDialog() { } -bool WebThemeInterfaceDialog::installPackage(const QString &szPath,QString &szError) +bool WebThemeInterfaceDialog::installPackage(const QString & szPath, QString & szError) { - return ThemeFunctions::installThemePackage(szPath,szError,this); + return ThemeFunctions::installThemePackage(szPath, szError, this); } -bool WebThemeInterfaceDialog::packageIsInstalled(const QString &szId,const QString &szVersion) +bool WebThemeInterfaceDialog::packageIsInstalled(const QString & szId, const QString & szVersion) { QString szSubdir = szId + QString("-") + szVersion; - szSubdir.replace(QRegExp("[^a-zA-Z0-9_\\-.][^a-zA-Z0-9_\\-.]*"),"_"); + szSubdir.replace(QRegExp("[^a-zA-Z0-9_\\-.][^a-zA-Z0-9_\\-.]*"), "_"); - return \ - KviFileUtils::fileExists(m_szGlobalThemesPath+szSubdir) || \ - KviFileUtils::fileExists(m_szLocalThemesPath+szSubdir); + return KviFileUtils::fileExists(m_szGlobalThemesPath + szSubdir) || KviFileUtils::fileExists(m_szLocalThemesPath + szSubdir); } - - #endif //COMPILE_WEBKIT_SUPPORT diff --git a/src/modules/theme/WebThemeInterfaceDialog.h b/src/modules/theme/WebThemeInterfaceDialog.h index 7b2569391..cc517027c 100644 --- a/src/modules/theme/WebThemeInterfaceDialog.h +++ b/src/modules/theme/WebThemeInterfaceDialog.h @@ -24,19 +24,17 @@ // //============================================================================= - #include "kvi_settings.h" #ifdef COMPILE_WEBKIT_SUPPORT #include "KviWebPackageManagementDialog.h" - class WebThemeInterfaceDialog : public KviWebPackageManagementDialog { Q_OBJECT public: - WebThemeInterfaceDialog(QWidget *par=0); + WebThemeInterfaceDialog(QWidget * par = 0); ~WebThemeInterfaceDialog(); private: @@ -44,12 +42,10 @@ private: QString m_szGlobalThemesPath; protected: - virtual bool packageIsInstalled(const QString &szId,const QString &szVersion); - virtual bool installPackage(const QString &szPath,QString &szError); - + virtual bool packageIsInstalled(const QString & szId, const QString & szVersion); + virtual bool installPackage(const QString & szPath, QString & szError); }; #endif //COMPILE_WEBKIT_SUPPORT - #endif //_WEBTHEMEINTERFACEDIALOG_H_ diff --git a/src/modules/theme/libkvitheme.cpp b/src/modules/theme/libkvitheme.cpp index 9a8cfce2d..da6cca6ef 100644 --- a/src/modules/theme/libkvitheme.cpp +++ b/src/modules/theme/libkvitheme.cpp @@ -45,8 +45,7 @@ #include #include -QRect g_rectManagementDialogGeometry(0,0,0,0); - +QRect g_rectManagementDialogGeometry(0, 0, 0, 0); /* @doc: theme.install @@ -67,13 +66,13 @@ static bool theme_kvs_cmd_install(KviKvsModuleCommandCall * c) QString szThemePackFile; KVSM_PARAMETERS_BEGIN(c) - KVSM_PARAMETER("package_path",KVS_PT_STRING,0,szThemePackFile) + KVSM_PARAMETER("package_path", KVS_PT_STRING, 0, szThemePackFile) KVSM_PARAMETERS_END(c) QString szError; - if(!ThemeFunctions::installThemePackage(szThemePackFile,szError)) + if(!ThemeFunctions::installThemePackage(szThemePackFile, szError)) { - c->error(__tr2qs_ctx("Error installing theme package: %Q","theme"),&szError); + c->error(__tr2qs_ctx("Error installing theme package: %Q", "theme"), &szError); return false; } @@ -113,23 +112,23 @@ static bool theme_kvs_cmd_apply(KviKvsModuleCommandCall * c) QString szTheme; KVSM_PARAMETERS_BEGIN(c) - KVSM_PARAMETER("theme",KVS_PT_STRING,0,szTheme) + KVSM_PARAMETER("theme", KVS_PT_STRING, 0, szTheme) KVSM_PARAMETERS_END(c) KviThemeInfo out; KviThemeInfo::Location eLocation = KviThemeInfo::Auto; - if(c->switches()->find('b',"builtin")) + if(c->switches()->find('b', "builtin")) eLocation = KviThemeInfo::Builtin; - else if(c->switches()->find('e',"external")) + else if(c->switches()->find('e', "external")) eLocation = KviThemeInfo::External; - else if(c->switches()->find('u',"user")) + else if(c->switches()->find('u', "user")) eLocation = KviThemeInfo::User; - if(!KviTheme::apply(szTheme,eLocation,out)) + if(!KviTheme::apply(szTheme, eLocation, out)) { QString szErr = out.lastError(); - c->error(__tr2qs_ctx("Failed to apply theme: %Q","theme"),&szErr); + c->error(__tr2qs_ctx("Failed to apply theme: %Q", "theme"), &szErr); return false; } @@ -152,23 +151,23 @@ static bool theme_kvs_fnc_info(KviKvsModuleFunctionCall * c) QString szTheme; KVSM_PARAMETERS_BEGIN(c) - KVSM_PARAMETER("theme",KVS_PT_STRING,0,szTheme) + KVSM_PARAMETER("theme", KVS_PT_STRING, 0, szTheme) KVSM_PARAMETERS_END(c) - KviKvsHash *pHash = new KviKvsHash(); + KviKvsHash * pHash = new KviKvsHash(); c->returnValue()->setHash(pHash); KviThemeInfo theme; - if(!theme.load(szTheme,KviThemeInfo::Auto)) + if(!theme.load(szTheme, KviThemeInfo::Auto)) { - c->warning(__tr2qs_ctx("The theme package '%Q' doesn't exist","theme"),&szTheme); + c->warning(__tr2qs_ctx("The theme package '%Q' doesn't exist", "theme"), &szTheme); return true; } - pHash->set("name",new KviKvsVariant(theme.name())); - pHash->set("version",new KviKvsVariant(theme.version())); - pHash->set("author",new KviKvsVariant(theme.author())); - pHash->set("description",new KviKvsVariant(theme.description())); + pHash->set("name", new KviKvsVariant(theme.name())); + pHash->set("version", new KviKvsVariant(theme.version())); + pHash->set("author", new KviKvsVariant(theme.author())); + pHash->set("description", new KviKvsVariant(theme.description())); return true; } @@ -193,7 +192,7 @@ static bool theme_kvs_cmd_screenshot(KviKvsModuleCommandCall * c) QString szFileName; KVSM_PARAMETERS_BEGIN(c) - KVSM_PARAMETER("file_name_path",KVS_PT_STRING,KVS_PF_OPTIONAL,szFileName) + KVSM_PARAMETER("file_name_path", KVS_PT_STRING, KVS_PF_OPTIONAL, szFileName) KVSM_PARAMETERS_END(c) KviFileUtils::adjustFilePath(szFileName); @@ -202,15 +201,14 @@ static bool theme_kvs_cmd_screenshot(KviKvsModuleCommandCall * c) c->enterBlockingSection(); bool bResult = KviFileDialog::askForSaveFileName( - szTmp, - __tr2qs_ctx("Enter a Filename - KVIrc","theme"), //dialog header title - szFileName, - "*.png", - false, - false, - true, - g_pMainWindow - ); + szTmp, + __tr2qs_ctx("Enter a Filename - KVIrc", "theme"), //dialog header title + szFileName, + "*.png", + false, + false, + true, + g_pMainWindow); if(!c->leaveBlockingSection()) return false; // need to stop immediately @@ -224,13 +222,13 @@ static bool theme_kvs_cmd_screenshot(KviKvsModuleCommandCall * c) return true; // done KviFileUtils::adjustFilePath(szFileName); - if(QFileInfo(szFileName).suffix()!="png") - szFileName+=".png"; + if(QFileInfo(szFileName).suffix() != "png") + szFileName += ".png"; QString szError; if(!ThemeFunctions::makeKVIrcScreenshot(szFileName)) { - c->error(__tr2qs_ctx("Error capturing and saving screenshot!","theme")); + c->error(__tr2qs_ctx("Error capturing and saving screenshot!", "theme")); return false; } @@ -253,9 +251,9 @@ static bool theme_kvs_cmd_screenshot(KviKvsModuleCommandCall * c) otherwise it is opened as part of the current frame window.[br] */ -static bool theme_kvs_cmd_dialog(KviKvsModuleCommandCall *c) +static bool theme_kvs_cmd_dialog(KviKvsModuleCommandCall * c) { - ThemeManagementDialog::display(c->hasSwitch('t',"toplevel")); + ThemeManagementDialog::display(c->hasSwitch('t', "toplevel")); return true; } @@ -284,31 +282,31 @@ static bool theme_kvs_cmd_dialog(KviKvsModuleCommandCall *c) */ static bool theme_kvs_cmd_pack(KviKvsModuleCommandCall * c) { - QString szPath,szName,szVersion,szDescription,szAuthor,szImage; + QString szPath, szName, szVersion, szDescription, szAuthor, szImage; KviKvsArrayCast aCast; KVSM_PARAMETERS_BEGIN(c) - KVSM_PARAMETER("package_path",KVS_PT_NONEMPTYSTRING,0,szPath) - KVSM_PARAMETER("package_name",KVS_PT_NONEMPTYSTRING,0,szName) - KVSM_PARAMETER("package_version",KVS_PT_NONEMPTYSTRING,0,szVersion) - KVSM_PARAMETER("package_description",KVS_PT_STRING,0,szDescription) - KVSM_PARAMETER("package_author",KVS_PT_NONEMPTYSTRING,0,szAuthor) - KVSM_PARAMETER("package_image",KVS_PT_STRING,0,szImage) - KVSM_PARAMETER("theme",KVS_PT_ARRAYCAST,0,aCast) + KVSM_PARAMETER("package_path", KVS_PT_NONEMPTYSTRING, 0, szPath) + KVSM_PARAMETER("package_name", KVS_PT_NONEMPTYSTRING, 0, szName) + KVSM_PARAMETER("package_version", KVS_PT_NONEMPTYSTRING, 0, szVersion) + KVSM_PARAMETER("package_description", KVS_PT_STRING, 0, szDescription) + KVSM_PARAMETER("package_author", KVS_PT_NONEMPTYSTRING, 0, szAuthor) + KVSM_PARAMETER("package_image", KVS_PT_STRING, 0, szImage) + KVSM_PARAMETER("theme", KVS_PT_ARRAYCAST, 0, aCast) KVSM_PARAMETERS_END(c) KviKvsArray * pArray = aCast.array(); if((!pArray) || (pArray->size() < 1)) { - c->error(__tr2qs_ctx("No themes specified","theme")); + c->error(__tr2qs_ctx("No themes specified", "theme")); return false; } kvs_uint_t s = pArray->size(); QStringList lThemeList; - for(kvs_uint_t i=0;iat(i); if(!v) @@ -323,14 +321,13 @@ static bool theme_kvs_cmd_pack(KviKvsModuleCommandCall * c) KviPointerList lThemeInfoList; lThemeInfoList.setAutoDelete(true); - - Q_FOREACH(QString szTheme,lThemeList) + Q_FOREACH(QString szTheme, lThemeList) { KviThemeInfo * pInfo = new KviThemeInfo(); - if(!pInfo->load(szTheme,KviThemeInfo::External)) + if(!pInfo->load(szTheme, KviThemeInfo::External)) { QString szErr = pInfo->lastError(); - c->error(__tr2qs_ctx("Failed to load theme from directory %Q: %Q","theme"),&szTheme,&szErr); + c->error(__tr2qs_ctx("Failed to load theme from directory %Q: %Q", "theme"), &szTheme, &szErr); delete pInfo; return false; } @@ -340,56 +337,54 @@ static bool theme_kvs_cmd_pack(KviKvsModuleCommandCall * c) if(lThemeInfoList.isEmpty()) { - c->error(__tr2qs_ctx("No themes specified: refusing to create an empty theme package","theme")); + c->error(__tr2qs_ctx("No themes specified: refusing to create an empty theme package", "theme")); return false; } QString szError; if( - ThemeFunctions::packageThemes( - szPath, - szName, - szVersion, - szDescription, - szAuthor, - szImage, - lThemeInfoList, - szError - ) - ) + ThemeFunctions::packageThemes( + szPath, + szName, + szVersion, + szDescription, + szAuthor, + szImage, + lThemeInfoList, + szError)) return true; c->error(szError); return false; } -static bool theme_module_init(KviModule *m) +static bool theme_module_init(KviModule * m) { - KVSM_REGISTER_SIMPLE_COMMAND(m,"dialog",theme_kvs_cmd_dialog); - KVSM_REGISTER_SIMPLE_COMMAND(m,"install",theme_kvs_cmd_install); - KVSM_REGISTER_SIMPLE_COMMAND(m,"apply",theme_kvs_cmd_apply); - KVSM_REGISTER_SIMPLE_COMMAND(m,"screenshot",theme_kvs_cmd_screenshot); - KVSM_REGISTER_SIMPLE_COMMAND(m,"pack",theme_kvs_cmd_pack); + KVSM_REGISTER_SIMPLE_COMMAND(m, "dialog", theme_kvs_cmd_dialog); + KVSM_REGISTER_SIMPLE_COMMAND(m, "install", theme_kvs_cmd_install); + KVSM_REGISTER_SIMPLE_COMMAND(m, "apply", theme_kvs_cmd_apply); + KVSM_REGISTER_SIMPLE_COMMAND(m, "screenshot", theme_kvs_cmd_screenshot); + KVSM_REGISTER_SIMPLE_COMMAND(m, "pack", theme_kvs_cmd_pack); - KVSM_REGISTER_FUNCTION(m,"info",theme_kvs_fnc_info); + KVSM_REGISTER_FUNCTION(m, "info", theme_kvs_fnc_info); QString szBuf; m->getDefaultConfigFileName(szBuf); - KviConfigurationFile cfg(szBuf,KviConfigurationFile::Read); - g_rectManagementDialogGeometry = cfg.readRectEntry("EditorGeometry",QRect(10,10,390,440)); + KviConfigurationFile cfg(szBuf, KviConfigurationFile::Read); + g_rectManagementDialogGeometry = cfg.readRectEntry("EditorGeometry", QRect(10, 10, 390, 440)); return true; } -static bool theme_module_cleanup(KviModule *m) +static bool theme_module_cleanup(KviModule * m) { ThemeManagementDialog::cleanup(); QString szBuf; m->getDefaultConfigFileName(szBuf); - KviConfigurationFile cfg(szBuf,KviConfigurationFile::Write); - cfg.writeEntry("EditorGeometry",g_rectManagementDialogGeometry); + KviConfigurationFile cfg(szBuf, KviConfigurationFile::Write); + cfg.writeEntry("EditorGeometry", g_rectManagementDialogGeometry); return true; } @@ -399,15 +394,13 @@ static bool theme_module_can_unload(KviModule *) return (!ThemeManagementDialog::instance()); } - KVIRC_MODULE( - "Theme", // module name - "4.0.0", // module version - "Copyright (C) 2006 Szymon Stefanek (pragma at kvirc dot net)", // author & (C) - "Theme management functions", - theme_module_init, - theme_module_can_unload, - 0, - theme_module_cleanup, - "theme" -) + "Theme", // module name + "4.0.0", // module version + "Copyright (C) 2006 Szymon Stefanek (pragma at kvirc dot net)", // author & (C) + "Theme management functions", + theme_module_init, + theme_module_can_unload, + 0, + theme_module_cleanup, + "theme") -- cgit v1.3.1-10-gc9f91