From 52140c4c45654f97f79136d4d6accdcf405beb46 Mon Sep 17 00:00:00 2001 From: Adam Mathes Date: Sat, 9 Feb 2019 19:30:29 -0800 Subject: [PATCH] count child terminals, qt.quit when none left --- app/qml/main.qml | 1 + app/qml/root.qml | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/qml/main.qml b/app/qml/main.qml index 9788380..94c5caa 100644 --- a/app/qml/main.qml +++ b/app/qml/main.qml @@ -173,6 +173,7 @@ ApplicationWindow{ } } onClosing: { + root.closeWindow() // OSX Since we are currently supporting only one window // quit the application when it is closed. //if (Qt.platform.os === "osx") diff --git a/app/qml/root.qml b/app/qml/root.qml index bd279d9..56dc32f 100644 --- a/app/qml/root.qml +++ b/app/qml/root.qml @@ -21,13 +21,23 @@ import QtQuick 2.2 import QtQuick.Window 2.1 QtObject { - id: root + id: root + property int terminalCount + function newWindow() { var component = Qt.createComponent("main.qml") var window = component.createObject() window.show() + terminalCount = terminalCount + 1 } - Component.onCompleted: { + function closeWindow() { + terminalCount = terminalCount - 1 + if (terminalCount == 0) { + Qt.quit() + } + } + Component.onCompleted: { + terminalCount = 0 root.newWindow() } }