count child terminals, qt.quit when none left

This commit is contained in:
Adam Mathes 2019-02-09 19:30:29 -08:00
parent 10fd2a11ee
commit 52140c4c45
2 changed files with 13 additions and 2 deletions

View File

@ -173,6 +173,7 @@ ApplicationWindow{
} }
} }
onClosing: { onClosing: {
root.closeWindow()
// OSX Since we are currently supporting only one window // OSX Since we are currently supporting only one window
// quit the application when it is closed. // quit the application when it is closed.
//if (Qt.platform.os === "osx") //if (Qt.platform.os === "osx")

View File

@ -22,12 +22,22 @@ import QtQuick.Window 2.1
QtObject { QtObject {
id: root id: root
property int terminalCount
function newWindow() { function newWindow() {
var component = Qt.createComponent("main.qml") var component = Qt.createComponent("main.qml")
var window = component.createObject() var window = component.createObject()
window.show() window.show()
terminalCount = terminalCount + 1
}
function closeWindow() {
terminalCount = terminalCount - 1
if (terminalCount == 0) {
Qt.quit()
}
} }
Component.onCompleted: { Component.onCompleted: {
terminalCount = 0
root.newWindow() root.newWindow()
} }
} }