summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-09-29 06:10:47 (GMT)
committerMontel Laurent <montel@kde.org>2016-09-29 06:10:47 (GMT)
commit04412532d5093fe127ffe7fbb7f34badc70c2026 (patch)
treeaee49fba37efcde2eeeafbf673cd824849d14e1b
parentd7f87431534b140667e410df3d5401fb51982ddb (diff)
Allow to save external script
-rw-r--r--plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.cpp b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.cpp
index 9337109..530a5ee 100644
--- a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.cpp
+++ b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.cpp
@@ -30,6 +30,7 @@
#include <QFile>
#include <QDebug>
#include <KDesktopFile>
+#include <KConfigGroup>
class ViewerPluginExternalScriptItem : public QListWidgetItem
{
@@ -160,7 +161,6 @@ void ViewerPluginExternalConfigureWidget::fillScriptInfo(const QVector<ViewerPlu
void ViewerPluginExternalConfigureWidget::save()
{
- //TODO delete filename first
Q_FOREACH (const QString &path, mFilesToRemove) {
QFile f(path);
if (!f.remove()) {
@@ -171,7 +171,17 @@ void ViewerPluginExternalConfigureWidget::save()
//TODO create or adapt desktop file.
for (int i = 0; i < mListExternal->count(); ++i) {
ViewerPluginExternalScriptItem *item = static_cast<ViewerPluginExternalScriptItem *>(mListExternal->item(i));
- //TODO
+ const ViewerPluginExternalScriptInfo &scriptInfo = item->scriptInfo();
+ QString filenamepath = scriptInfo.fileName();
+ if (filenamepath.isEmpty()) {
+ //TODO add correct filenamepath
+ }
+ KDesktopFile desktopFile(filenamepath);
+ desktopFile.desktopGroup().writeEntry(QStringLiteral("Name"), scriptInfo.name());
+ desktopFile.desktopGroup().writeEntry(QStringLiteral("Description"), scriptInfo.description());
+ desktopFile.desktopGroup().writeEntry(QStringLiteral("Executable"), scriptInfo.executable());
+ desktopFile.desktopGroup().writeEntry(QStringLiteral("CommandLine"), scriptInfo.commandLine());
+ desktopFile.desktopGroup().sync();
}
}