aboutsummaryrefslogtreecommitdiff
path: root/src/list
diff options
context:
space:
mode:
authorAdrian Kummerlaender2015-08-19 11:13:35 +0200
committerAdrian Kummerlaender2015-08-19 11:13:35 +0200
commit4cb435f2a7bbeafb53f067d95ec83e0b3a1a17f8 (patch)
treead308460ab5f47f498b4d2432e36c7511c5e9aab /src/list
parent90da724a56c2ff20617d3e231a6ef877928df482 (diff)
downloadMetaTerm-4cb435f2a7bbeafb53f067d95ec83e0b3a1a17f8.tar
MetaTerm-4cb435f2a7bbeafb53f067d95ec83e0b3a1a17f8.tar.gz
MetaTerm-4cb435f2a7bbeafb53f067d95ec83e0b3a1a17f8.tar.bz2
MetaTerm-4cb435f2a7bbeafb53f067d95ec83e0b3a1a17f8.tar.lz
MetaTerm-4cb435f2a7bbeafb53f067d95ec83e0b3a1a17f8.tar.xz
MetaTerm-4cb435f2a7bbeafb53f067d95ec83e0b3a1a17f8.tar.zst
MetaTerm-4cb435f2a7bbeafb53f067d95ec83e0b3a1a17f8.zip
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.
Diffstat (limited to 'src/list')
-rw-r--r--src/list/TerminalItem.qml25
-rw-r--r--src/list/TerminalList.qml14
2 files changed, 16 insertions, 23 deletions
diff --git a/src/list/TerminalItem.qml b/src/list/TerminalItem.qml
index 4c71be4..06b60b9 100644
--- a/src/list/TerminalItem.qml
+++ b/src/list/TerminalItem.qml
@@ -6,19 +6,11 @@ import Qt.labs.settings 1.0
Item {
id: item
- property int index : 0
property EmbeddedTerminal terminal : null
+ property int index : 0
signal executed (int index)
- property Settings settings : Settings {
- category: "item"
-
- property int fontSize : 18
- property string fontFamily : "Monospace"
- property string fontColor : "white"
- }
-
anchors {
left: parent.left
right: parent.right
@@ -106,6 +98,7 @@ Item {
var terminalComponent = Qt.createComponent("qrc:/EmbeddedTerminal.qml");
var instantiateTerminal = function() {
item.terminal = terminalComponent.createObject(elementList, {
+ "settings" : settings,
"program" : program,
"workingDirectory" : "$HOME",
"focus" : true
@@ -136,12 +129,12 @@ Item {
id: command
font {
- family: settings.fontFamily
- pointSize: settings.fontSize
+ family: settings.item.fontFamily
+ pointSize: settings.item.fontSize
}
- color: settings.fontColor
- selectionColor: settings.fontColor
+ color: settings.item.fontColor
+ selectionColor: settings.item.fontColor
selectedTextColor: "#161616"
selectByMouse: true
@@ -162,10 +155,10 @@ Item {
Text {
font {
- family: settings.fontFamily
- pointSize: settings.fontSize / 1.5
+ family: settings.item.fontFamily
+ pointSize: settings.item.fontSize / 1.5
}
- color: settings.fontColor
+ color: settings.item.fontColor
text: item.index
}
diff --git a/src/list/TerminalList.qml b/src/list/TerminalList.qml
index 6c6465b..9c1636f 100644
--- a/src/list/TerminalList.qml
+++ b/src/list/TerminalList.qml
@@ -4,12 +4,13 @@ import QtQuick.Layouts 1.1
Item {
id: item
- property StateHandler state : null
- property int activeItem : 0
- property int itemIndex : 0
+ property int activeItem : 0
+ property int itemIndex : 0
property alias children : column.children
+ property Component terminalItem : Component { TerminalItem { } }
+
function onItemExecuted(index) {
if ( index === (children.length - 1) ) {
createItem();
@@ -17,11 +18,10 @@ Item {
}
function createItem() {
- var terminalItem = Qt.createComponent("qrc:/TerminalItem.qml");
var instantiateTerminal = function() {
var instance = terminalItem.createObject(column, {
- "index": itemIndex,
- "width": flickable.width
+ "index" : itemIndex,
+ "width" : flickable.width
});
instance.onExecuted.connect(onItemExecuted);
@@ -67,7 +67,7 @@ Item {
if ( activeItem < (children.length - 1) ) {
selectItem(activeItem + 1);
} else {
- state.enterInsertMode();
+ mode.enterInsertMode();
}
}