[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [plasmate] /: port Publisher to a ui file and add an install action
From: Giorgos Tsiapaliwkas <terietor () gmail ! com>
Date: 2012-05-29 16:52:25
Message-ID: 20120529165225.9A3DAA60A9 () git ! kde ! org
[Download RAW message or body]
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 = KStandardAction::redisplay(this, SLOT(saveAndRefresh()), \
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(selectSavePoint()), \
"savepoint", KStandardShortcut::save());
addAction(i18n("Publish"), "krfb", SLOT(selectPublish()), "publish");
-
addAction(i18n("Preview"), "user-desktop", SLOT(togglePreview()), \
"preview")->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 = new Publisher(this, m_model->package(), \
m_model->packageType()); + }
+
+ 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 @@
<Action name="publish" />
<Separator />
<Action name="preview" />
+ <Action name="installproject" />
<Action name="notes" />
<Action name="file_list" />
<Action name="timeline" />
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 <QDBusInterface>
-#include <QPushButton>
-#include <QLabel>
#include <QVBoxLayout>
-#include <QCheckBox>
-#include <QComboBox>
#include <KConfigGroup>
#include <KIO/DeleteJob>
@@ -33,83 +29,51 @@
Publisher::Publisher(QWidget *parent, const KUrl &path, const QString& type)
: 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 = i18n("Export project");
- QString exportText = i18n("Choose a target file to export the current project to \
an installable package file on your system.");
- QString installLabel = i18n("Install project");
- QString installText = i18n("Select the method with which you want to install the \
current project directly "
- "onto your computer.");
- QString publishLabel = i18n("Publish project");
- QString publishText = i18n("Click to publish the current project online, so that \
other people can find and install it using the Internet."); + QWidget *uiWidget = \
new QWidget(); + m_ui.setupUi(uiWidget);
- m_extension = (type == "Plasma/Applet" || type == "Plasma/PopupApplet") ? \
"plasmoid" : "zip";
-
- m_exporterUrl = new KUrlRequester(this);
- m_exporterUrl->setFilter(QString("*.") + m_extension);
- m_exporterUrl->setMode(KFile::File | KFile::LocalOnly);
-
- m_exporterButton = new QPushButton(i18n("Export current project"), this);
- m_installerButton = new QComboBox(this);
- m_installerButton->addItem("");
- m_installerButton->addItem("Use PlasmaPkg");
- m_installerButton->addItem("Use cmake");
- m_publisherButton = new QPushButton(i18n("Publish current project"), this);
-
- connect(m_exporterUrl, SIGNAL(urlSelected(const KUrl&)), this, \
SLOT(addSuffix()));
- connect(m_exporterButton, SIGNAL(clicked()), this, SLOT(doExport()));
- connect(m_installerButton, SIGNAL(currentIndexChanged(int)), this, \
SLOT(doPlasmaPkg(int)));
- connect(m_installerButton, SIGNAL(currentIndexChanged(int)), this, \
SLOT(doCMake(int)));
- connect(m_publisherButton, SIGNAL(clicked()), this, SLOT(doPublish()));
-
- // Publish only works right for Plasmoid now afaik. Disabling for other project \
types.
- m_publisherButton->setEnabled(type == "Plasma/Applet" || type == \
"Plasma/PopupApplet"); + m_signingWidget = new SigningWidget();
+ //merge the ui file with the SigningWidget
QVBoxLayout *layout = new QVBoxLayout();
- layout->addWidget(new QLabel("<h1>" + exportLabel + "</h1>", this));
-
- QFrame *separator = 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("<h1>" + installLabel + "</h1>", this));
-
- separator = 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 = (type == "Plasma/Applet" || type == "Plasma/PopupApplet") ? \
"plasmoid" : "zip";
- layout->addWidget(new QLabel("<h1>" + publishLabel + "</h1>", this));
+ m_ui.exporterUrl->setFilter(QString("*.") + m_extension);
+ m_ui.exporterUrl->setMode(KFile::File | KFile::LocalOnly);
- separator = new QFrame();
- separator->setFrameStyle(QFrame::HLine | QFrame::Sunken);
+ //we want the installButton to be enabled only when the comboBox's current 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 = 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 other project \
types. + m_ui.publisherButton->setEnabled(type == "Plasma/Applet" || type == \
"Plasma/PopupApplet");
- layout->addStretch();
setLayout(layout);
-
}
void Publisher::addSuffix()
{
- QString selected = m_exporterUrl->url().path();
+ QString selected = m_ui.exporterUrl->url().path();
QString suffix = QFileInfo(selected).suffix();
if (suffix != m_extension && suffix != "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 = i18n("A file already exists at %1. Do you want to \
overwrite it?",
- m_exporterUrl->url().path());
+ m_ui.exporterUrl->url().path());
int code = KMessageBox::warningYesNo(0,dialogText);
if (code != KMessageBox::Yes) return;
}
- bool ok = exportToFile(m_exporterUrl->url());
+ bool ok = exportToFile(m_ui.exporterUrl->url());
// If signing is enabled, lets do that!
if (m_signingWidget->signingEnabled()) {
- ok = ok && m_signingWidget->sign(m_exporterUrl->url());
+ ok = 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 export. \
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 valid.
+void Publisher::checkInstallButtonState(int comboBoxCurrentIndex)
{
- //check if this the index that we want
- if (index != 2) {
- return;
+ if (comboBoxCurrentIndex == 1) {
+ m_ui.installButton->setEnabled(true);
+ m_comboBoxIndex = 1;
+ } else if (comboBoxCurrentIndex == 2) {
+ m_ui.installButton->setEnabled(true);
+ m_comboBoxIndex = 2;
+ } else {
+ m_ui.installButton->setEnabled(false);
+ m_comboBoxIndex = 0;
+ }
+}
+
+//choose the method which which we will install the project
+//according to comboBox's index
+void Publisher::doInstall()
+{
+ if (m_comboBoxIndex == 1) {
+ doPlasmaPkg();
+ } else if (m_comboBoxIndex == 2) {
+ doCMake();
}
+}
+// Plasmoid specific, for now
+void Publisher::doCMake()
+{
if (m_projectType != "Plasma/Applet") {
qDebug() << "chaos";
return;
@@ -263,15 +248,8 @@ bool Publisher::cmakeProcessStatus(QProcess::ProcessError 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 != 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 <KUrl>
#include <KProcess>
-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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic