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: {
root.closeWindow()
// OSX Since we are currently supporting only one window
// quit the application when it is closed.
//if (Qt.platform.os === "osx")

View File

@ -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()
}
}