summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-09-28 11:23:58 (GMT)
committerMontel Laurent <montel@kde.org>2016-09-28 11:59:55 (GMT)
commitd72381e7afa4a0d7de20433a5776862b82b90a6f (patch)
tree59e2ea32967ed89bda48762fc60e0fa9d2c660ba
parentf8501f7dd124f0b34ec0545becab9e90a9c46170 (diff)
improve++
-rw-r--r--plugins/messageviewerplugins/externalscriptplugin/autotests/CMakeLists.txt4
-rw-r--r--plugins/messageviewerplugins/externalscriptplugin/autotests/viewerpluginexternalconfigurewidgettest.cpp2
-rw-r--r--plugins/messageviewerplugins/externalscriptplugin/autotests/viewerpluginexternaleditwidgettest.cpp24
-rw-r--r--plugins/messageviewerplugins/externalscriptplugin/autotests/viewerpluginexternaleditwidgettest.h3
-rw-r--r--plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfiguredialog.cpp1
-rw-r--r--plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.cpp19
-rw-r--r--plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.h2
-rw-r--r--plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditdialog.cpp6
-rw-r--r--plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditdialog.h2
-rw-r--r--plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditwidget.cpp38
-rw-r--r--plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditwidget.h13
11 files changed, 96 insertions, 18 deletions
diff --git a/plugins/messageviewerplugins/externalscriptplugin/autotests/CMakeLists.txt b/plugins/messageviewerplugins/externalscriptplugin/autotests/CMakeLists.txt
index 4d14372..c9e0120 100644
--- a/plugins/messageviewerplugins/externalscriptplugin/autotests/CMakeLists.txt
+++ b/plugins/messageviewerplugins/externalscriptplugin/autotests/CMakeLists.txt
@@ -20,5 +20,5 @@ add_messageviewer_viewerplugin_external_plugin_unittest(viewerpluginexternalscri
add_messageviewer_viewerplugin_external_plugin_unittest(viewerpluginexternalscriptparseargumenttest.cpp "../viewerpluginexternalscriptparseargument.cpp" "")
add_messageviewer_viewerplugin_external_plugin_unittest(viewerpluginexternalconfigurewidgettest.cpp "../configuredialog/viewerpluginexternaleditwidget.cpp;../configuredialog/viewerpluginexternaleditdialog.cpp;../configuredialog/viewerpluginexternalconfigurewidget.cpp;../viewerpluginexternalscriptsloadjob.cpp;../viewerpluginexternalscriptinfo.cpp" "")
add_messageviewer_viewerplugin_external_plugin_unittest(viewerpluginexternalconfiguredialogtest.cpp "../configuredialog/viewerpluginexternaleditwidget.cpp;../configuredialog/viewerpluginexternaleditdialog.cpp;../configuredialog/viewerpluginexternalconfiguredialog.cpp;../configuredialog/viewerpluginexternalconfigurewidget.cpp;../viewerpluginexternalscriptsloadjob.cpp;../viewerpluginexternalscriptinfo.cpp" "")
-add_messageviewer_viewerplugin_external_plugin_unittest(viewerpluginexternaleditwidgettest.cpp "../configuredialog/viewerpluginexternaleditwidget.cpp" "")
-add_messageviewer_viewerplugin_external_plugin_unittest(viewerpluginexternaleditdialogtest.cpp "../configuredialog/viewerpluginexternaleditdialog.cpp;../configuredialog/viewerpluginexternaleditwidget.cpp" "")
+add_messageviewer_viewerplugin_external_plugin_unittest(viewerpluginexternaleditwidgettest.cpp "../viewerpluginexternalscriptinfo.cpp;../configuredialog/viewerpluginexternaleditwidget.cpp" "")
+add_messageviewer_viewerplugin_external_plugin_unittest(viewerpluginexternaleditdialogtest.cpp "../viewerpluginexternalscriptinfo.cpp;../configuredialog/viewerpluginexternaleditdialog.cpp;../configuredialog/viewerpluginexternaleditwidget.cpp" "")
diff --git a/plugins/messageviewerplugins/externalscriptplugin/autotests/viewerpluginexternalconfigurewidgettest.cpp b/plugins/messageviewerplugins/externalscriptplugin/autotests/viewerpluginexternalconfigurewidgettest.cpp
index 425c210..2b4e1d8 100644
--- a/plugins/messageviewerplugins/externalscriptplugin/autotests/viewerpluginexternalconfigurewidgettest.cpp
+++ b/plugins/messageviewerplugins/externalscriptplugin/autotests/viewerpluginexternalconfigurewidgettest.cpp
@@ -17,7 +17,6 @@
Boston, MA 02110-1301, USA.
*/
-
#include "viewerpluginexternalconfigurewidgettest.h"
#include "../configuredialog/viewerpluginexternalconfigurewidget.h"
#include <QTest>
@@ -46,7 +45,6 @@ void ViewerPluginExternalConfigureWidgetTest::shouldHaveDefaultValue()
QVERIFY(mainLayout);
QCOMPARE(mainLayout->margin(), 0);
-
QListWidget *mListExternal = w.findChild<QListWidget *>(QStringLiteral("listexternal"));
QVERIFY(mListExternal);
QCOMPARE(mListExternal->selectionMode(), QAbstractItemView::SingleSelection);
diff --git a/plugins/messageviewerplugins/externalscriptplugin/autotests/viewerpluginexternaleditwidgettest.cpp b/plugins/messageviewerplugins/externalscriptplugin/autotests/viewerpluginexternaleditwidgettest.cpp
index b9c37a7..5ec724e 100644
--- a/plugins/messageviewerplugins/externalscriptplugin/autotests/viewerpluginexternaleditwidgettest.cpp
+++ b/plugins/messageviewerplugins/externalscriptplugin/autotests/viewerpluginexternaleditwidgettest.cpp
@@ -17,9 +17,11 @@
Boston, MA 02110-1301, USA.
*/
-
#include "viewerpluginexternaleditwidgettest.h"
+#include "../configuredialog/viewerpluginexternaleditwidget.h"
+#include <QFormLayout>
+#include <QLineEdit>
#include <QTest>
ViewerPluginExternalEditWidgetTest::ViewerPluginExternalEditWidgetTest(QObject *parent)
@@ -33,4 +35,24 @@ ViewerPluginExternalEditWidgetTest::~ViewerPluginExternalEditWidgetTest()
}
+void ViewerPluginExternalEditWidgetTest::shouldHaveDefaultValue()
+{
+ ViewerPluginExternalEditWidget w;
+ QFormLayout *mainLayout = w.findChild<QFormLayout *>(QStringLiteral("mainlayout"));
+ QVERIFY(mainLayout);
+ QCOMPARE(mainLayout->margin(), 0);
+
+ QLineEdit *mName = w.findChild<QLineEdit *>(QStringLiteral("name"));
+ QVERIFY(mName);
+
+ QLineEdit *mDescription = w.findChild<QLineEdit *>(QStringLiteral("description"));
+ QVERIFY(mDescription);
+
+ QLineEdit *mCommandLine = w.findChild<QLineEdit *>(QStringLiteral("commandline"));
+ QVERIFY(mCommandLine);
+
+ QLineEdit *mExecutable = w.findChild<QLineEdit *>(QStringLiteral("executable"));
+ QVERIFY(mExecutable);
+}
+
QTEST_MAIN(ViewerPluginExternalEditWidgetTest)
diff --git a/plugins/messageviewerplugins/externalscriptplugin/autotests/viewerpluginexternaleditwidgettest.h b/plugins/messageviewerplugins/externalscriptplugin/autotests/viewerpluginexternaleditwidgettest.h
index 06f6ece..f9141db 100644
--- a/plugins/messageviewerplugins/externalscriptplugin/autotests/viewerpluginexternaleditwidgettest.h
+++ b/plugins/messageviewerplugins/externalscriptplugin/autotests/viewerpluginexternaleditwidgettest.h
@@ -17,7 +17,6 @@
Boston, MA 02110-1301, USA.
*/
-
#ifndef VIEWERPLUGINEXTERNALEDITWIDGETTEST_H
#define VIEWERPLUGINEXTERNALEDITWIDGETTEST_H
@@ -29,6 +28,8 @@ class ViewerPluginExternalEditWidgetTest : public QObject
public:
explicit ViewerPluginExternalEditWidgetTest(QObject *parent = Q_NULLPTR);
~ViewerPluginExternalEditWidgetTest();
+private Q_SLOTS:
+ void shouldHaveDefaultValue();
};
#endif // VIEWERPLUGINEXTERNALEDITWIDGETTEST_H
diff --git a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfiguredialog.cpp b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfiguredialog.cpp
index 052aa7d..532f904 100644
--- a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfiguredialog.cpp
+++ b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfiguredialog.cpp
@@ -33,7 +33,6 @@ ViewerPluginExternalConfigureDialog::~ViewerPluginExternalConfigureDialog()
}
-
QWidget *ViewerPluginExternalConfigureDialog::createLayout()
{
mConfigWidget = new ViewerPluginExternalConfigureWidget(this);
diff --git a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.cpp b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.cpp
index b9a72c8..3c7e0ae 100644
--- a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.cpp
+++ b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.cpp
@@ -48,6 +48,8 @@ ViewerPluginExternalScriptItem::ViewerPluginExternalScriptItem(QListWidget *pare
void ViewerPluginExternalScriptItem::setScriptInfo(const ViewerPluginExternalScriptInfo &scriptInfo)
{
mScriptInfo = scriptInfo;
+ setText(mScriptInfo.name());
+ setToolTip(mScriptInfo.description());
}
ViewerPluginExternalScriptInfo ViewerPluginExternalScriptItem::scriptInfo() const
@@ -103,6 +105,9 @@ void ViewerPluginExternalConfigureWidget::slotRemoveScript()
QListWidgetItem *item = mListExternal->currentItem();
if (item) {
ViewerPluginExternalScriptItem *scriptItem = static_cast<ViewerPluginExternalScriptItem *>(item);
+ if (KMessageBox::Yes == KMessageBox::warningYesNo(this, i18n("Do you want to remove this script?"), i18n("Remove External Script"))) {
+ mFilesToRemove.append(scriptItem->scriptInfo().fileName());
+ }
}
}
@@ -111,15 +116,23 @@ void ViewerPluginExternalConfigureWidget::slotModifyScript()
QListWidgetItem *item = mListExternal->currentItem();
if (item) {
ViewerPluginExternalScriptItem *scriptItem = static_cast<ViewerPluginExternalScriptItem *>(item);
+ QPointer<ViewerPluginExternalEditDialog> dlg = new ViewerPluginExternalEditDialog(this);
+ dlg->setScriptInfo(scriptItem->scriptInfo());
+ if (dlg->exec()) {
+ scriptItem->setScriptInfo(dlg->scriptInfo());
+ }
+ delete dlg;
}
}
void ViewerPluginExternalConfigureWidget::slotAddScript()
{
- QListWidgetItem *item = mListExternal->currentItem();
- if (item) {
- ViewerPluginExternalScriptItem *scriptItem = static_cast<ViewerPluginExternalScriptItem *>(item);
+ QPointer<ViewerPluginExternalEditDialog> dlg = new ViewerPluginExternalEditDialog(this);
+ if (dlg->exec()) {
+ ViewerPluginExternalScriptItem *item = new ViewerPluginExternalScriptItem(mListExternal);
+ item->setScriptInfo(dlg->scriptInfo());
}
+ delete dlg;
}
void ViewerPluginExternalConfigureWidget::load()
diff --git a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.h b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.h
index a96a481..bbaee26 100644
--- a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.h
+++ b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.h
@@ -39,6 +39,8 @@ private:
void slotModifyScript();
void updateButtons();
void slotRemoveScript();
+ QStringList mFilesToRemove;
+
QListWidget *mListExternal;
QPushButton *mAddScript;
QPushButton *mRemoveScript;
diff --git a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditdialog.cpp b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditdialog.cpp
index 5418531..86406a8 100644
--- a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditdialog.cpp
+++ b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditdialog.cpp
@@ -17,7 +17,6 @@
Boston, MA 02110-1301, USA.
*/
-
#include "viewerpluginexternaleditdialog.h"
#include "viewerpluginexternaleditwidget.h"
#include <KLocalizedString>
@@ -53,3 +52,8 @@ void ViewerPluginExternalEditDialog::setScriptInfo(const ViewerPluginExternalScr
{
mEditWidget->setScriptInfo(info);
}
+
+ViewerPluginExternalScriptInfo ViewerPluginExternalEditDialog::scriptInfo() const
+{
+ return mEditWidget->scriptInfo();
+}
diff --git a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditdialog.h b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditdialog.h
index d5d59e1..2b04bc4 100644
--- a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditdialog.h
+++ b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditdialog.h
@@ -17,7 +17,6 @@
Boston, MA 02110-1301, USA.
*/
-
#ifndef VIEWERPLUGINEXTERNALEDITDIALOG_H
#define VIEWERPLUGINEXTERNALEDITDIALOG_H
@@ -34,6 +33,7 @@ public:
~ViewerPluginExternalEditDialog();
void setScriptInfo(const ViewerPluginExternalScriptInfo &info);
+ ViewerPluginExternalScriptInfo scriptInfo() const;
private:
void slotAccepted();
diff --git a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditwidget.cpp b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditwidget.cpp
index d8af815..cfd8641 100644
--- a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditwidget.cpp
+++ b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditwidget.cpp
@@ -17,18 +17,36 @@
Boston, MA 02110-1301, USA.
*/
-
#include "viewerpluginexternaleditwidget.h"
#include <QVBoxLayout>
#include <KLocalizedString>
#include <QLabel>
#include <QLineEdit>
+#include <QFormLayout>
ViewerPluginExternalEditWidget::ViewerPluginExternalEditWidget(QWidget *parent)
: QWidget(parent)
{
- QVBoxLayout *mainLayout = new QVBoxLayout(this);
+ QFormLayout *mainLayout = new QFormLayout(this);
+ mainLayout->setObjectName(QStringLiteral("mainlayout"));
mainLayout->setMargin(0);
+
+
+ mName = new QLineEdit(this);
+ mName->setObjectName(QStringLiteral("name"));
+ mainLayout->addRow(i18n("Name:"), mName);
+
+ mDescription = new QLineEdit(this);
+ mDescription->setObjectName(QStringLiteral("description"));
+ mainLayout->addRow(i18n("Description:"), mDescription);
+
+ mCommandLine = new QLineEdit(this);
+ mCommandLine->setObjectName(QStringLiteral("commandline"));
+ mainLayout->addRow(i18n("CommandLine:"), mCommandLine);
+
+ mExecutable = new QLineEdit(this);
+ mExecutable->setObjectName(QStringLiteral("executable"));
+ mainLayout->addRow(i18n("Executable:"), mExecutable);
}
ViewerPluginExternalEditWidget::~ViewerPluginExternalEditWidget()
@@ -38,10 +56,22 @@ ViewerPluginExternalEditWidget::~ViewerPluginExternalEditWidget()
void ViewerPluginExternalEditWidget::setScriptInfo(const ViewerPluginExternalScriptInfo &info)
{
- //TODO
+ mScriptInfo = info;
+ mName->setText(mScriptInfo.name());
+ mDescription->setText(mScriptInfo.description());
+ mCommandLine->setText(mScriptInfo.commandLine());
+ mExecutable->setText(mScriptInfo.executable());
}
void ViewerPluginExternalEditWidget::save()
{
- //TODO
+ mScriptInfo.setName(mName->text());
+ mScriptInfo.setDescription(mDescription->text());
+ mScriptInfo.setCommandLine(mCommandLine->text());
+ mScriptInfo.setExecutable(mExecutable->text());
+}
+
+ViewerPluginExternalScriptInfo ViewerPluginExternalEditWidget::scriptInfo() const
+{
+ return mScriptInfo;
}
diff --git a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditwidget.h b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditwidget.h
index 073640c..a91abf0 100644
--- a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditwidget.h
+++ b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditwidget.h
@@ -17,21 +17,30 @@
Boston, MA 02110-1301, USA.
*/
-
#ifndef VIEWERPLUGINEXTERNALEDITWIDGET_H
#define VIEWERPLUGINEXTERNALEDITWIDGET_H
#include <QWidget>
#include "../viewerpluginexternalscriptinfo.h"
-
+class QLineEdit;
class ViewerPluginExternalEditWidget : public QWidget
{
Q_OBJECT
public:
explicit ViewerPluginExternalEditWidget(QWidget *parent = Q_NULLPTR);
~ViewerPluginExternalEditWidget();
+
void setScriptInfo(const ViewerPluginExternalScriptInfo &info);
+ ViewerPluginExternalScriptInfo scriptInfo() const;
+
void save();
+private:
+ ViewerPluginExternalScriptInfo mScriptInfo;
+ QLineEdit *mName;
+ QLineEdit *mDescription;
+ QLineEdit *mCommandLine;
+ QLineEdit *mExecutable;
+ //TODO add icon ?
};
#endif // VIEWERPLUGINEXTERNALEDITWIDGET_H