Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

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