Commit 526efc1b authored by Matthieu Gallien's avatar Matthieu Gallien

use a qml singleton type for the c++ backend of configuration dialog

parent 42004039
...@@ -174,7 +174,14 @@ void ElisaQmlTestPlugin::registerTypes(const char *uri) ...@@ -174,7 +174,14 @@ void ElisaQmlTestPlugin::registerTypes(const char *uri)
qRegisterMetaType<TracksListener::TrackDataType>("TracksListener::TrackDataType"); qRegisterMetaType<TracksListener::TrackDataType>("TracksListener::TrackDataType");
qRegisterMetaType<ViewManager::IsTreeModelType>("ViewManager::IsTreeModelType"); qRegisterMetaType<ViewManager::IsTreeModelType>("ViewManager::IsTreeModelType");
qRegisterMetaType<DataTypes::DataType>("DataTypes::DataType"); qRegisterMetaType<DataTypes::DataType>("DataTypes::DataType");
qmlRegisterUncreatableType<ElisaConfigurationDialog>(uri, 1, 0, "ElisaConfigurationDialog", QStringLiteral("only one and done in c++"));
qmlRegisterSingletonType<ElisaConfigurationDialog>(uri, 1, 0, "ElisaConfigurationDialog",
[](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject* {
Q_UNUSED(engine)
Q_UNUSED(scriptEngine)
return new ElisaConfigurationDialog;
});
qmlRegisterUncreatableType<ElisaApplication>(uri, 1, 0, "ElisaApplication", QStringLiteral("only one and done in c++")); qmlRegisterUncreatableType<ElisaApplication>(uri, 1, 0, "ElisaApplication", QStringLiteral("only one and done in c++"));
qmlRegisterUncreatableMetaObject(ElisaUtils::staticMetaObject, uri, 1, 0, "ElisaUtils", QStringLiteral("Namespace ElisaUtils")); qmlRegisterUncreatableMetaObject(ElisaUtils::staticMetaObject, uri, 1, 0, "ElisaUtils", QStringLiteral("Namespace ElisaUtils"));
......
...@@ -166,7 +166,6 @@ int main(int argc, char *argv[]) ...@@ -166,7 +166,6 @@ int main(int argc, char *argv[])
myApp->setArguments(arguments); myApp->setArguments(arguments);
engine.rootContext()->setContextProperty(QStringLiteral("elisa"), myApp.release()); engine.rootContext()->setContextProperty(QStringLiteral("elisa"), myApp.release());
engine.rootContext()->setContextProperty(QStringLiteral("config"), new ElisaConfigurationDialog);
engine.load(QUrl(QStringLiteral("qrc:/qml/ElisaMainWindow.qml"))); engine.load(QUrl(QStringLiteral("qrc:/qml/ElisaMainWindow.qml")));
......
...@@ -11,6 +11,8 @@ import QtQuick.Window 2.12 ...@@ -11,6 +11,8 @@ import QtQuick.Window 2.12
import QtQml.Models 2.3 import QtQml.Models 2.3
import org.kde.kirigami 2.5 as Kirigami import org.kde.kirigami 2.5 as Kirigami
import org.kde.elisa 1.0
Window { Window {
id: dialog id: dialog
...@@ -98,7 +100,7 @@ Window { ...@@ -98,7 +100,7 @@ Window {
icon.name: 'dialog-ok-apply' icon.name: 'dialog-ok-apply'
DialogButtonBox.buttonRole: DialogButtonBox.ApplyRole DialogButtonBox.buttonRole: DialogButtonBox.ApplyRole
enabled: config.isDirty enabled: ElisaConfigurationDialog.isDirty
} }
Button { Button {
...@@ -108,11 +110,11 @@ Window { ...@@ -108,11 +110,11 @@ Window {
} }
onAccepted: { onAccepted: {
config.save() ElisaConfigurationDialog.save()
close() close()
} }
onApplied: config.save() onApplied: ElisaConfigurationDialog.save()
onRejected: close() onRejected: close()
} }
......
...@@ -10,6 +10,8 @@ import QtQuick.Layouts 1.3 ...@@ -10,6 +10,8 @@ import QtQuick.Layouts 1.3
import QtQml.Models 2.3 import QtQml.Models 2.3
import QtQuick.Dialogs 1.2 as Dialogs import QtQuick.Dialogs 1.2 as Dialogs
import org.kde.elisa 1.0
ColumnLayout { ColumnLayout {
spacing: 0 spacing: 0
...@@ -18,9 +20,9 @@ ColumnLayout { ...@@ -18,9 +20,9 @@ ColumnLayout {
text: i18n("Force filesystem indexing") text: i18n("Force filesystem indexing")
checked: !config.forceUsageOfFastFileSearch checked: !ElisaConfigurationDialog.forceUsageOfFastFileSearch
onCheckedChanged: config.forceUsageOfFastFileSearch = !checked onCheckedChanged: ElisaConfigurationDialog.forceUsageOfFastFileSearch = !checked
} }
Label { Label {
...@@ -88,9 +90,9 @@ ColumnLayout { ...@@ -88,9 +90,9 @@ ColumnLayout {
onClicked: onClicked:
{ {
var oldPaths = config.rootPath var oldPaths = ElisaConfigurationDialog.rootPath
oldPaths.splice(delegateItem.DelegateModel.itemsIndex, 1) oldPaths.splice(delegateItem.DelegateModel.itemsIndex, 1)
config.rootPath = oldPaths ElisaConfigurationDialog.rootPath = oldPaths
} }
} }
} }
...@@ -108,7 +110,7 @@ ColumnLayout { ...@@ -108,7 +110,7 @@ ColumnLayout {
clip: true clip: true
model: DelegateModel { model: DelegateModel {
model: config.rootPath model: ElisaConfigurationDialog.rootPath
delegate: pathDelegate delegate: pathDelegate
} }
...@@ -142,9 +144,9 @@ ColumnLayout { ...@@ -142,9 +144,9 @@ ColumnLayout {
visible: false visible: false
onAccepted: { onAccepted: {
var oldPaths = config.rootPath var oldPaths = ElisaConfigurationDialog.rootPath
oldPaths.push(fileDialog.fileUrls) oldPaths.push(fileDialog.fileUrls)
config.rootPath = oldPaths ElisaConfigurationDialog.rootPath = oldPaths
} }
} }
} }
......
...@@ -8,6 +8,8 @@ import QtQuick 2.11 ...@@ -8,6 +8,8 @@ import QtQuick 2.11
import QtQuick.Controls 2.4 import QtQuick.Controls 2.4
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import org.kde.elisa 1.0
ColumnLayout { ColumnLayout {
spacing: 0 spacing: 0
...@@ -17,18 +19,18 @@ ColumnLayout { ...@@ -17,18 +19,18 @@ ColumnLayout {
} }
CheckBox { CheckBox {
checked: config.showProgressInTaskBar checked: ElisaConfigurationDialog.showProgressInTaskBar
text: i18n("Show progress on Task Manager entries") text: i18n("Show progress on Task Manager entries")
onCheckedChanged: config.showProgressInTaskBar = checked onCheckedChanged: ElisaConfigurationDialog.showProgressInTaskBar = checked
} }
CheckBox { CheckBox {
checked: config.showSystemTrayIcon checked: ElisaConfigurationDialog.showSystemTrayIcon
text: i18n("Keep running in System Tray when main window is closed") text: i18n("Keep running in System Tray when main window is closed")
onToggled: config.showSystemTrayIcon = checked onToggled: ElisaConfigurationDialog.showSystemTrayIcon = checked
} }
} }
Markdown is supported
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