Skip to content

Commit

Permalink
Add Factory Reset
Browse files Browse the repository at this point in the history
Fixes #226
  • Loading branch information
Cuperino committed Sep 28, 2024
1 parent d58fc8c commit 8948fd0
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 22 deletions.
25 changes: 18 additions & 7 deletions src/kirigami_ui/+android/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -348,13 +348,13 @@ Kirigami.ApplicationWindow {
onTriggered: root.pageStack.currentItem.document.autoReload = checked
}
}
// Kirigami.Action {
// text: i18nc("Main menu actions", "Restore factory defaults")
// icon.name: "edit-clear-history"
// onTriggered: {
// showPassiveNotification(i18n("Feature not yet implemented"))
// }
// }
Kirigami.Action {
text: i18nc("Main menu actions", "Restore factory defaults")
icon.name: "edit-clear-history"
onTriggered: {
factoryResetDialog.open();
}
}
},
Kirigami.Action {
text: i18nc("Main menu actions. Load about page.", "Abou&t %1", aboutData.displayName)
Expand Down Expand Up @@ -569,6 +569,17 @@ Kirigami.ApplicationWindow {
TelemetryPage {}
}

Labs.MessageDialog {
id: factoryResetDialog
title: i18n("Factory Reset")
text: i18n("Restore all configurations to factory defaults? QPrompt will close if you click Yes and all unsaved document changes will be lost.")
buttons: Labs.MessageDialog.Yes | Labs.MessageDialog.No
modality: Qt.WindowModal
onYesClicked: {
qmlutil.factoryReset()
}
}

// Dialogues
Labs.MessageDialog {
id : closeDialog
Expand Down
25 changes: 18 additions & 7 deletions src/kirigami_ui/+windows/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -409,13 +409,13 @@ Kirigami.ApplicationWindow {
onTriggered: root.__fakeFullscreen = checked
}
}
// Kirigami.Action {
// text: i18nc("Main menu actions", "Restore factory defaults")
// icon.name: "edit-clear-history"
// onTriggered: {
// showPassiveNotification(i18n("Feature not yet implemented"))
// }
// }
Kirigami.Action {
text: i18nc("Main menu actions", "Restore factory defaults")
icon.name: "edit-clear-history"
onTriggered: {
factoryResetDialog.open();
}
}
},
Kirigami.Action {
text: i18nc("Main menu actions. Load about page.", "Abou&t %1", aboutData.displayName)
Expand Down Expand Up @@ -684,6 +684,17 @@ Kirigami.ApplicationWindow {
}
}

Labs.MessageDialog {
id: factoryResetDialog
title: i18n("Factory Reset")
text: i18n("Restore all configurations to factory defaults? QPrompt will close if you click Yes and all unsaved document changes will be lost.")
buttons: Labs.MessageDialog.Yes | Labs.MessageDialog.No
modality: Qt.WindowModal
onYesClicked: {
qmlutil.factoryReset()
}
}

Labs.MessageDialog {
id : closeDialog
title: i18nc("Title for save before closing dialog", "Save Document")
Expand Down
26 changes: 18 additions & 8 deletions src/kirigami_ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -422,14 +422,13 @@ Kirigami.ApplicationWindow {
onTriggered: root.__fakeFullscreen = checked
}
}
// Kirigami.Action {
// text: i18nc("Main menu actions", "Restore factory defaults")
// //icon.name: "edit-clear-history"
// icon.source: "qrc:/qt/qml/com/cuperino/qprompt/icons/edit-clear-history.svg"
// onTriggered: {
// showPassiveNotification(i18n("Feature not yet implemented"))
// }
// }
Kirigami.Action {
text: i18nc("Main menu actions", "Restore factory defaults")
icon.source: "qrc:/qt/qml/com/cuperino/qprompt/icons/edit-clear-history.svg"
onTriggered: {
factoryResetDialog.open();
}
}
},
Kirigami.Action {
text: i18nc("Main menu actions. Load about page.", "Abou&t %1", aboutData.displayName)
Expand Down Expand Up @@ -1003,6 +1002,17 @@ Kirigami.ApplicationWindow {
}
}

Labs.MessageDialog {
id: factoryResetDialog
title: i18n("Factory Reset")
text: i18n("Restore all configurations to factory defaults? QPrompt will close if you click Yes and all unsaved document changes will be lost.")
buttons: Labs.MessageDialog.Yes | Labs.MessageDialog.No
modality: Qt.WindowModal
onYesClicked: {
qmlutil.factoryReset()
}
}

Labs.MessageDialog {
id : closeDialog
title: i18nc("Title for save before closing dialog", "Save Document")
Expand Down
7 changes: 7 additions & 0 deletions src/qmlutil.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <QPixmap>
#include <QProcess>
#include <QQmlEngine>
#include <QSettings>

// A singleton object to implement C++ functions that can be called from QML
class QmlUtil : public QObject
Expand Down Expand Up @@ -97,5 +98,11 @@ class QmlUtil : public QObject
return database.families();
#endif
}
Q_INVOKABLE void factoryReset()
{
QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName().toLower());
settings.clear();
restartApplication();
}
};
#endif // QMLUTIL_H

0 comments on commit 8948fd0

Please sign in to comment.