From 4cb435f2a7bbeafb53f067d95ec83e0b3a1a17f8 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Wed, 19 Aug 2015 11:13:35 +0200 Subject: Extract all settings into `SettingsHandler` object This enables the user to straight forwardly change all application settings via command mode. During the implementation of this change I discovered that the way I was passing around `StateHandler` and `SettingsHandler` instances using properties was unnecessary. If all object instances are created in a common hierarchy they can access each other by their `id` property - i.e. `settings` and `mode` are available to the whole application without property trickery. --- src/main.qml | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) (limited to 'src/main.qml') diff --git a/src/main.qml b/src/main.qml index 2965fa1..db17cda 100644 --- a/src/main.qml +++ b/src/main.qml @@ -2,34 +2,32 @@ import QtQuick 2.0 import QtQuick.Window 2.0 import QtQuick.Controls 1.2 import QtQuick.Layouts 1.1 -import Qt.labs.settings 1.0 ApplicationWindow { id: root visible: true - - property Settings settings : Settings { - category: "window" - - property string background : "#161616" - } - - color: settings.background + color: settings.window.background Component.onCompleted: { terminalList.createItem(); terminalList.focusCurrent(); } + SettingsHandler { + id: settings + } + + StateHandler { + id: mode + } + ColumnLayout { anchors.fill: parent TerminalList { id: terminalList - state: state - Layout.fillHeight: true Layout.fillWidth: true } @@ -39,14 +37,7 @@ ApplicationWindow { Layout.fillWidth: true - onExecuted: state.enterNormalMode() + onExecuted: mode.enterNormalMode() } } - - StateHandler { - id: state - - terminalList: terminalList - commandInput: command - } } -- cgit v1.2.3