Git commit 250f981586351072f95232ed0e5020a6de46f56c by Giorgos Tsiapaliwkas. Committed on 29/05/2012 at 18:51. Pushed by tsiapaliwkas into branch 'master'. port Publisher to a ui file and add an install action M +2 -1 CMakeLists.txt M +14 -1 mainwindow.cpp M +1 -0 mainwindow.h M +1 -0 plasmateui.rc M +60 -82 publisher/publisher.cpp M +11 -15 publisher/publisher.h http://commits.kde.org/plasmate/250f981586351072f95232ed0e5020a6de46f56c diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e1bf4b..12f8a3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,12 +69,13 @@ endif (DEBUG_MODEL) kde4_add_ui_files (PlasMate_SRC startpage.ui editors/metadata/metadata.ui + publisher/publisher.ui ) = include_directories(${KDE4_INCLUDES} ${QT_QTWEBKIT_INCLUDE_DIR} ${QGPGME_INCLUDE_DIR} - ${GPGME_INCLUDES} + ${GPGME_INCLUDES} ) = add_subdirectory( editors ) diff --git a/mainwindow.cpp b/mainwindow.cpp index f9924e1..6f72624 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -223,9 +223,10 @@ void MainWindow::setupActions() KAction *refresh =3D KStandardAction::redisplay(this, SLOT(saveAndRefr= esh()), actionCollection()); refresh->setShortcut(Qt::CTRL + Qt::Key_F5); refresh->setText(i18n("Refresh Preview")); + + addAction(i18n("Install Project"), "plasmagik", SLOT(installPackage())= , "installproject", KShortcut(Qt::META + Qt::Key_I)); addAction(i18n("Create Save Point"), "document-save", SLOT(selectSaveP= oint()), "savepoint", KStandardShortcut::save()); addAction(i18n("Publish"), "krfb", SLOT(selectPublish()), "publish"); - addAction(i18n("Preview"), "user-desktop", SLOT(togglePreview()), "pre= view")->setCheckable(true); addAction(i18n("Notes"), "accessories-text-editor", SLOT(toggleNotes()= ), "notes")->setCheckable(true); addAction(i18n("Files"), "system-file-manager", SLOT(toggleFileList())= , "file_list")->setCheckable(true); @@ -242,6 +243,18 @@ void MainWindow::updateActions() actionCollection()->action("documentation")->setChecked(m_browser && m= _browser->isVisible()); } = +void MainWindow::installPackage() +{ + if (!m_publisher) { + m_publisher =3D new Publisher(this, m_model->package(), m_model->p= ackageType()); + } + + saveEditorData(); + + m_publisher->setProjectName(m_currentProject); + m_publisher->doPlasmaPkg(); +} + void MainWindow::closeProject() { saveEditorData(); diff --git a/mainwindow.h b/mainwindow.h index be111fc..520c26c 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -106,6 +106,7 @@ private Q_SLOTS: void togglePreview(); void toggleNotes(); void toggleFileList(); + void installPackage(); = // refreshes editor, killing all local changes void editorDestructiveRefresh(); diff --git a/plasmateui.rc b/plasmateui.rc index 9123298..b51884d 100644 --- a/plasmateui.rc +++ b/plasmateui.rc @@ -15,6 +15,7 @@ + diff --git a/publisher/publisher.cpp b/publisher/publisher.cpp index 11ddf36..fd87364 100644 --- a/publisher/publisher.cpp +++ b/publisher/publisher.cpp @@ -8,11 +8,7 @@ */ = #include -#include -#include #include -#include -#include = #include #include @@ -33,83 +29,51 @@ Publisher::Publisher(QWidget *parent, const KUrl &path, const QString& typ= e) : QDialog(parent), m_projectPath(path), - m_projectType(type) + m_projectType(type), + m_comboBoxIndex(0), + m_signingWidget(0) { - // These should probably be refined at some point - QString exportLabel =3D i18n("Export project"); - QString exportText =3D i18n("Choose a target file to export the curren= t project to an installable package file on your system."); - QString installLabel =3D i18n("Install project"); - QString installText =3D i18n("Select the method with which you want to= install the current project directly " - "onto your computer."); - QString publishLabel =3D i18n("Publish project"); - QString publishText =3D i18n("Click to publish the current project onl= ine, so that other people can find and install it using the Internet."); + QWidget *uiWidget =3D new QWidget(); + m_ui.setupUi(uiWidget); = - m_extension =3D (type =3D=3D "Plasma/Applet" || type =3D=3D "Plasma/Po= pupApplet") ? "plasmoid" : "zip"; - - m_exporterUrl =3D new KUrlRequester(this); - m_exporterUrl->setFilter(QString("*.") + m_extension); - m_exporterUrl->setMode(KFile::File | KFile::LocalOnly); - - m_exporterButton =3D new QPushButton(i18n("Export current project"), t= his); - m_installerButton =3D new QComboBox(this); - m_installerButton->addItem(""); - m_installerButton->addItem("Use PlasmaPkg"); - m_installerButton->addItem("Use cmake"); - m_publisherButton =3D new QPushButton(i18n("Publish current project"),= this); - - connect(m_exporterUrl, SIGNAL(urlSelected(const KUrl&)), this, SLOT(ad= dSuffix())); - connect(m_exporterButton, SIGNAL(clicked()), this, SLOT(doExport())); - connect(m_installerButton, SIGNAL(currentIndexChanged(int)), this, SLO= T(doPlasmaPkg(int))); - connect(m_installerButton, SIGNAL(currentIndexChanged(int)), this, SLO= T(doCMake(int))); - connect(m_publisherButton, SIGNAL(clicked()), this, SLOT(doPublish())); - - // Publish only works right for Plasmoid now afaik. Disabling for othe= r project types. - m_publisherButton->setEnabled(type =3D=3D "Plasma/Applet" || type =3D= =3D "Plasma/PopupApplet"); + m_signingWidget =3D new SigningWidget(); = + //merge the ui file with the SigningWidget QVBoxLayout *layout =3D new QVBoxLayout(); - layout->addWidget(new QLabel("

" + exportLabel + "

", this)); - - QFrame *separator =3D new QFrame(); - separator->setFrameStyle(QFrame::HLine | QFrame::Sunken); - - layout->addWidget(separator); - layout->addWidget(new QLabel(exportText, this)); - layout->addWidget(m_exporterUrl); - layout->addWidget(m_exporterButton); - - layout->addWidget(new QLabel("

" + installLabel + "

", this)); - - separator =3D new QFrame(); - separator->setFrameStyle(QFrame::HLine | QFrame::Sunken); + layout->addWidget(uiWidget); + layout->addWidget(m_signingWidget); = - layout->addWidget(separator); - layout->addWidget(new QLabel(installText, this)); - layout->addWidget(m_installerButton); + m_extension =3D (type =3D=3D "Plasma/Applet" || type =3D=3D "Plasma/Po= pupApplet") ? "plasmoid" : "zip"; = - layout->addWidget(new QLabel("

" + publishLabel + "

", this)); + m_ui.exporterUrl->setFilter(QString("*.") + m_extension); + m_ui.exporterUrl->setMode(KFile::File | KFile::LocalOnly); = - separator =3D new QFrame(); - separator->setFrameStyle(QFrame::HLine | QFrame::Sunken); + //we want the installButton to be enabled only when the comboBox's cur= rent index is valid. + m_ui.installButton->setEnabled(false); = - layout->addWidget(separator); - layout->addWidget(new QLabel(publishText, this)); - layout->addWidget(m_publisherButton); + //populate the comboBox + m_ui.installerButton->addItem(""); + m_ui.installerButton->addItem("Use PlasmaPkg"); + m_ui.installerButton->addItem("Use cmake"); = - m_signingWidget =3D new SigningWidget(this); + connect(m_ui.exporterUrl, SIGNAL(urlSelected(const KUrl&)), this, SLOT= (addSuffix())); + connect(m_ui.exporterButton, SIGNAL(clicked()), this, SLOT(doExport())= ); + connect(m_ui.installerButton, SIGNAL(currentIndexChanged(int)), this, = SLOT(checkInstallButtonState(int))); + connect(m_ui.installButton, SIGNAL(clicked()), this, SLOT(doInstall())= ); + connect(m_ui.publisherButton, SIGNAL(clicked()), this, SLOT(doPublish(= ))); = - layout->addWidget(m_signingWidget); + // Publish only works right for Plasmoid now afaik. Disabling for othe= r project types. + m_ui.publisherButton->setEnabled(type =3D=3D "Plasma/Applet" || type = =3D=3D "Plasma/PopupApplet"); = - layout->addStretch(); setLayout(layout); - } = void Publisher::addSuffix() { - QString selected =3D m_exporterUrl->url().path(); + QString selected =3D m_ui.exporterUrl->url().path(); QString suffix =3D QFileInfo(selected).suffix(); if (suffix !=3D m_extension && suffix !=3D "zip") { - m_exporterUrl->setUrl(selected + "." + m_extension); + m_ui.exporterUrl->setUrl(selected + "." + m_extension); } } = @@ -120,34 +84,55 @@ void Publisher::setProjectName(const QString &name) = void Publisher::doExport() { - if (QFile(m_exporterUrl->url().path()).exists()) { + if (QFile(m_ui.exporterUrl->url().path()).exists()) { QString dialogText =3D i18n("A file already exists at %1. Do you w= ant to overwrite it?", - m_exporterUrl->url().path()); + m_ui.exporterUrl->url().path()); int code =3D KMessageBox::warningYesNo(0,dialogText); if (code !=3D KMessageBox::Yes) return; } - bool ok =3D exportToFile(m_exporterUrl->url()); + bool ok =3D exportToFile(m_ui.exporterUrl->url()); = // If signing is enabled, lets do that! if (m_signingWidget->signingEnabled()) { - ok =3D ok && m_signingWidget->sign(m_exporterUrl->url()); + ok =3D ok && m_signingWidget->sign(m_ui.exporterUrl->url()); } - if (QFile::exists(m_exporterUrl->url().path()) && ok) { - KMessageBox::information(this, i18n("Project has been exported to = %1.", m_exporterUrl->url().path())); + if (QFile::exists(m_ui.exporterUrl->url().path()) && ok) { + KMessageBox::information(this, i18n("Project has been exported to = %1.", m_ui.exporterUrl->url().path())); } else { KMessageBox::error(this, i18n("An error has occurred during the ex= port. Please check the write permissions " "in the target directory.")); } } = -// Plasmoid specific, for now -void Publisher::doCMake(int index) +//we want the installButton to be enabled only when comboBox's index is va= lid. +void Publisher::checkInstallButtonState(int comboBoxCurrentIndex) { - //check if this the index that we want - if (index !=3D 2) { - return; + if (comboBoxCurrentIndex =3D=3D 1) { + m_ui.installButton->setEnabled(true); + m_comboBoxIndex =3D 1; + } else if (comboBoxCurrentIndex =3D=3D 2) { + m_ui.installButton->setEnabled(true); + m_comboBoxIndex =3D 2; + } else { + m_ui.installButton->setEnabled(false); + m_comboBoxIndex =3D 0; + } +} + +//choose the method which which we will install the project +//according to comboBox's index +void Publisher::doInstall() +{ + if (m_comboBoxIndex =3D=3D 1) { + doPlasmaPkg(); + } else if (m_comboBoxIndex =3D=3D 2) { + doCMake(); } +} = +// Plasmoid specific, for now +void Publisher::doCMake() +{ if (m_projectType !=3D "Plasma/Applet") { qDebug() << "chaos"; return; @@ -263,15 +248,8 @@ bool Publisher::cmakeProcessStatus(QProcess::ProcessEr= ror error) return false; } = - -// Plasmoid specific, for now -void Publisher::doPlasmaPkg(int index) +void Publisher::doPlasmaPkg() { - //check if this the index that we want - if (index !=3D 1) { - return; - } - const KUrl tempPackage(tempPackagePath()); qDebug() << "tempPackagePath" << tempPackage.pathOrUrl(); qDebug() << "m_projectPath" << m_projectPath.pathOrUrl(); diff --git a/publisher/publisher.h b/publisher/publisher.h index ee57cf3..5f40ae0 100644 --- a/publisher/publisher.h +++ b/publisher/publisher.h @@ -14,16 +14,9 @@ #include #include = -class KUrlRequester; -class KPushButton; -class QCheckBox; -class SigningWidget; -class QComboBox; +#include "ui_publisher.h" = -namespace Ui -{ -class Publisher; -} +class SigningWidget; = class Publisher : public QDialog { @@ -32,28 +25,31 @@ public: Publisher(QWidget* parent, const KUrl &path, const QString& type); void setProjectName(const QString &name); = +public slots: + void doPlasmaPkg(); + private slots: void doExport(); void addSuffix(); void doPublish(); - void doPlasmaPkg(int index); - void doCMake(int index); + void doCMake(); + void doInstall(); + void checkInstallButtonState(int comboBoxCurrentIndex); = private: bool cmakeProcessStatus(QProcess::ProcessError error); bool exportToFile(const KUrl& url); const QString tempPackagePath(); = - KUrlRequester* m_exporterUrl; - QPushButton* m_exporterButton; - QPushButton* m_publisherButton; SigningWidget* m_signingWidget; - QComboBox *m_installerButton; = KUrl m_projectPath; QString m_projectType; QString m_extension; QString m_projectName; + int m_comboBoxIndex; + + Ui::Publisher m_ui; }; = #endif // PUBLISHER_H