summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-09-27 11:19:37 (GMT)
committerMontel Laurent <montel@kde.org>2016-09-27 12:01:27 (GMT)
commit345d55e169a77e71de58541a40636ec1926f2fe3 (patch)
tree51e35cf9001c880e4dde009bd9e29189c76ed09a
parent9f58d3d0574148998d3def97c5972d445fd89adc (diff)
improve configure dialog
-rw-r--r--plugins/messageviewerplugins/externalscriptplugin/autotests/viewerpluginexternalconfigurewidgettest.cpp1
-rw-r--r--plugins/messageviewerplugins/externalscriptplugin/autotests/viewerpluginexternalscriptinfotest.cpp1
-rw-r--r--plugins/messageviewerplugins/externalscriptplugin/autotests/viewerpluginexternalscriptsloadjobtest.cpp1
-rw-r--r--plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.cpp18
-rw-r--r--plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.h11
-rw-r--r--plugins/messageviewerplugins/externalscriptplugin/viewerpluginexternalscriptinfo.cpp11
-rw-r--r--plugins/messageviewerplugins/externalscriptplugin/viewerpluginexternalscriptinfo.h5
-rw-r--r--plugins/messageviewerplugins/externalscriptplugin/viewerpluginexternalscriptsloadjob.cpp7
8 files changed, 51 insertions, 4 deletions
diff --git a/plugins/messageviewerplugins/externalscriptplugin/autotests/viewerpluginexternalconfigurewidgettest.cpp b/plugins/messageviewerplugins/externalscriptplugin/autotests/viewerpluginexternalconfigurewidgettest.cpp
index 9e99b39..425c210 100644
--- a/plugins/messageviewerplugins/externalscriptplugin/autotests/viewerpluginexternalconfigurewidgettest.cpp
+++ b/plugins/messageviewerplugins/externalscriptplugin/autotests/viewerpluginexternalconfigurewidgettest.cpp
@@ -49,6 +49,7 @@ void ViewerPluginExternalConfigureWidgetTest::shouldHaveDefaultValue()
QListWidget *mListExternal = w.findChild<QListWidget *>(QStringLiteral("listexternal"));
QVERIFY(mListExternal);
+ QCOMPARE(mListExternal->selectionMode(), QAbstractItemView::SingleSelection);
QPushButton *mAddScript = w.findChild<QPushButton *>(QStringLiteral("addscript"));
QVERIFY(mAddScript);
diff --git a/plugins/messageviewerplugins/externalscriptplugin/autotests/viewerpluginexternalscriptinfotest.cpp b/plugins/messageviewerplugins/externalscriptplugin/autotests/viewerpluginexternalscriptinfotest.cpp
index 8432850..98f7600 100644
--- a/plugins/messageviewerplugins/externalscriptplugin/autotests/viewerpluginexternalscriptinfotest.cpp
+++ b/plugins/messageviewerplugins/externalscriptplugin/autotests/viewerpluginexternalscriptinfotest.cpp
@@ -42,6 +42,7 @@ void ViewerPluginExternalScriptInfoTest::shouldHaveDefaultValue()
QVERIFY(info.description().isEmpty());
QVERIFY(info.icon().isEmpty());
QVERIFY(!info.isValid());
+ QVERIFY(!info.isReadOnly());
}
void ViewerPluginExternalScriptInfoTest::shouldHaveValid()
diff --git a/plugins/messageviewerplugins/externalscriptplugin/autotests/viewerpluginexternalscriptsloadjobtest.cpp b/plugins/messageviewerplugins/externalscriptplugin/autotests/viewerpluginexternalscriptsloadjobtest.cpp
index 08dc35d..bebfa69 100644
--- a/plugins/messageviewerplugins/externalscriptplugin/autotests/viewerpluginexternalscriptsloadjobtest.cpp
+++ b/plugins/messageviewerplugins/externalscriptplugin/autotests/viewerpluginexternalscriptsloadjobtest.cpp
@@ -62,6 +62,7 @@ void ViewerPluginExternalScriptsLoadJobTest::shouldLoadDataInfo()
QCOMPARE(info.description(), QStringLiteral("description"));
QCOMPARE(info.executable(), QStringLiteral("bla"));
QCOMPARE(info.icon(), QStringLiteral("blo"));
+ QVERIFY(!info.isReadOnly());
}
void ViewerPluginExternalScriptsLoadJobTest::shouldNotLoadEmptyDesktop()
diff --git a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.cpp b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.cpp
index c44dbc1..a24145f 100644
--- a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.cpp
+++ b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.cpp
@@ -21,10 +21,10 @@
#include <QVBoxLayout>
#include <QStandardPaths>
#include <KLocalizedString>
-#include "../viewerpluginexternalscriptsloadjob.h"
#include <QLabel>
#include <QListWidget>
#include <QPushButton>
+#include <KMessageBox>
ViewerPluginExternalConfigureWidget::ViewerPluginExternalConfigureWidget(QWidget *parent)
: QWidget(parent)
@@ -41,6 +41,7 @@ ViewerPluginExternalConfigureWidget::ViewerPluginExternalConfigureWidget(QWidget
mListExternal = new QListWidget(this);
mListExternal->setObjectName(QStringLiteral("listexternal"));
+ mListExternal->setSelectionMode(QAbstractItemView::SingleSelection);
listLayout->addWidget(mListExternal);
QVBoxLayout *buttonLayout = new QVBoxLayout;
@@ -84,13 +85,21 @@ void ViewerPluginExternalConfigureWidget::slotAddScript()
void ViewerPluginExternalConfigureWidget::load()
{
-
ViewerPluginExternalScriptsLoadJob job;
const QStringList lst = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("messageviewerplugins/"), QStandardPaths::LocateDirectory);
job.setExternalScriptsDirectories(lst);
job.start();
const QVector<ViewerPluginExternalScriptInfo> scriptInfos = job.scriptInfos();
+ fillScriptInfo(scriptInfos);
+}
+
+void ViewerPluginExternalConfigureWidget::fillScriptInfo(const QVector<ViewerPluginExternalScriptInfo> &scriptInfos)
+{
+ Q_FOREACH (const ViewerPluginExternalScriptInfo &script, scriptInfos) {
+
+ }
+ //TODO
}
void ViewerPluginExternalConfigureWidget::save()
@@ -102,3 +111,8 @@ void ViewerPluginExternalConfigureWidget::reset()
{
}
+
+void ViewerPluginExternalConfigureWidget::updateButtons()
+{
+
+}
diff --git a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.h b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.h
index dfaa1f0..657a10c 100644
--- a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.h
+++ b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.h
@@ -21,6 +21,7 @@
#define VIEWERPLUGINEXTERNALCONFIGUREWIDGET_H
#include <QWidget>
+#include "../viewerpluginexternalscriptsloadjob.h"
class QListWidget;
class QPushButton;
class ViewerPluginExternalConfigureWidget : public QWidget
@@ -33,8 +34,18 @@ public:
void save();
void reset();
private:
+ enum ItemScriptInfo {
+ FileName = Qt::UserRole + 1,
+ ReadOnly = Qt::UserRole + 2,
+ CommandName = Qt::UserRole + 3,
+ Executable = Qt::UserRole + 4,
+ IconName = Qt::UserRole + 5,
+ };
+
+ void fillScriptInfo(const QVector<ViewerPluginExternalScriptInfo> &scriptInfos);
void slotAddScript();
void slotModifyScript();
+ void updateButtons();
void slotRemoveScript();
QListWidget *mListExternal;
QPushButton *mAddScript;
diff --git a/plugins/messageviewerplugins/externalscriptplugin/viewerpluginexternalscriptinfo.cpp b/plugins/messageviewerplugins/externalscriptplugin/viewerpluginexternalscriptinfo.cpp
index ca2f39f..ee17a6e 100644
--- a/plugins/messageviewerplugins/externalscriptplugin/viewerpluginexternalscriptinfo.cpp
+++ b/plugins/messageviewerplugins/externalscriptplugin/viewerpluginexternalscriptinfo.cpp
@@ -20,6 +20,7 @@
#include "viewerpluginexternalscriptinfo.h"
ViewerPluginExternalScriptInfo::ViewerPluginExternalScriptInfo()
+ : mIsReadOnly(false)
{
}
@@ -79,3 +80,13 @@ bool ViewerPluginExternalScriptInfo::isValid() const
return !mName.trimmed().isEmpty() &&
!mExecutable.trimmed().isEmpty();
}
+
+bool ViewerPluginExternalScriptInfo::isReadOnly() const
+{
+ return mIsReadOnly;
+}
+
+void ViewerPluginExternalScriptInfo::setIsReadOnly(bool isReadOnly)
+{
+ mIsReadOnly = isReadOnly;
+}
diff --git a/plugins/messageviewerplugins/externalscriptplugin/viewerpluginexternalscriptinfo.h b/plugins/messageviewerplugins/externalscriptplugin/viewerpluginexternalscriptinfo.h
index 16a1de3..29bf07b 100644
--- a/plugins/messageviewerplugins/externalscriptplugin/viewerpluginexternalscriptinfo.h
+++ b/plugins/messageviewerplugins/externalscriptplugin/viewerpluginexternalscriptinfo.h
@@ -42,12 +42,17 @@ public:
void setIcon(const QString &icon);
bool isValid() const;
+
+ bool isReadOnly() const;
+ void setIsReadOnly(bool isReadOnly);
+
private:
QString mCommandLine;
QString mName;
QString mExecutable;
QString mDescription;
QString mIcon;
+ bool mIsReadOnly;
};
Q_DECLARE_TYPEINFO(ViewerPluginExternalScriptInfo, Q_MOVABLE_TYPE);
Q_DECLARE_METATYPE(ViewerPluginExternalScriptInfo)
diff --git a/plugins/messageviewerplugins/externalscriptplugin/viewerpluginexternalscriptsloadjob.cpp b/plugins/messageviewerplugins/externalscriptplugin/viewerpluginexternalscriptsloadjob.cpp
index dd0eb80..4dee4b6 100644
--- a/plugins/messageviewerplugins/externalscriptplugin/viewerpluginexternalscriptsloadjob.cpp
+++ b/plugins/messageviewerplugins/externalscriptplugin/viewerpluginexternalscriptsloadjob.cpp
@@ -48,8 +48,10 @@ void ViewerPluginExternalScriptsLoadJob::start()
const int listSize(list.size());
QStringList scriptNames;
for (int i = 0; i < listSize; ++i) {
- KConfig config(list.at(i).filePath());
- qCDebug(EXTERNALSCRIPTPLUGIN_LOG) << "load file " << list.at(i).filePath();
+ const QString filePath = list.at(i).filePath();
+
+ KConfig config(filePath);
+ qCDebug(EXTERNALSCRIPTPLUGIN_LOG) << "load file " << filePath;
KConfigGroup group(&config, QStringLiteral("Desktop Entry"));
if (group.isValid()) {
@@ -60,6 +62,7 @@ void ViewerPluginExternalScriptsLoadJob::start()
info.setCommandLine(group.readEntry("CommandLine", QString()));
info.setDescription(group.readEntry("Description", QString()));
info.setIcon(group.readEntry("Icon", QString()));
+ info.setIsReadOnly(!list.at(i).isWritable());
if (info.isValid() && !scriptNames.contains(name)) {
mScriptInfos.append(info);
scriptNames.append(name);