Commit 8a69730b authored by David Redondo's avatar David Redondo 🏎
Browse files

Add adbility to export a page

Adds an action to export a page. It's enabled when edit mode is not active.
CCBUG:429758
parent f45c5acd
......@@ -6,6 +6,7 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Dialogs 1.3
import QtQuick.Layouts 1.12
import QtQuick.Window 2.12
......@@ -65,6 +66,13 @@ Kirigami.ApplicationWindow {
icon.name: "handle-sort"
text: i18nc("@action", "Edit or Remove pages...")
onTriggered: pageSortDialog.open()
},
Kirigami.Action {
id: exportAction
text: i18nc("@action", "Export Current Page...")
icon.name: "document-export"
enabled: !app.pageStack.currentItem.edit
onTriggered: exportDialog.open()
},
Kirigami.Action {
id: ghnsAction
......@@ -210,6 +218,18 @@ Kirigami.ApplicationWindow {
}
}
Page.DialogLoader {
id: exportDialog
sourceComponent: FileDialog {
selectExisting: false
folder: shortcuts.home
title: i18nc("@title:window %1 is the name of the page that is being exported", "Export %1", app.pageStack.currentItem.title)
defaultSuffix: "page"
nameFilters: [i18nc("Name filter in file dialog", "System Monitor page (*.page)")]
onAccepted: page.saveAs(fileUrl)
}
}
Configuration {
id: config
property alias width: app.width
......
......@@ -10,6 +10,7 @@
#include <QDebug>
#include <QRegularExpression>
#include <QUrl>
#include <KConfig>
#include <KConfigGroup>
......@@ -186,6 +187,13 @@ bool PageDataObject::savePage()
return false;
}
void PageDataObject::saveAs(const QUrl &destination)
{
auto copiedPage = m_config->copyTo(destination.toLocalFile());
// KConfig passes the ownership of the returned config to us, the destructor of it will write it to the disk
delete copiedPage;
}
bool PageDataObject::load(const KConfigBase &config, const QString &groupName)
{
auto group = config.group(groupName);
......
......@@ -33,6 +33,7 @@ public:
Q_INVOKABLE bool resetPage();
Q_INVOKABLE bool savePage();
Q_INVOKABLE void saveAs(const QUrl &destination);
bool load(const KConfigBase &config, const QString &groupName);
Q_SIGNAL void loaded();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment