Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple terminal support on MacOS #507

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ int main(int argc, char *argv[])
importPathList.prepend(QCoreApplication::applicationDirPath() + "/../../../qmltermwidget");
engine.setImportPathList(importPathList);

engine.load(QUrl(QStringLiteral ("qrc:/main.qml")));
engine.load(QUrl(QStringLiteral ("qrc:/root.qml")));

if (engine.rootObjects().isEmpty()) {
qDebug() << "Cannot load QML interface";
Expand Down
6 changes: 6 additions & 0 deletions app/qml/CRTMainMenuBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ MenuBar {
visible: defaultMenuBar.visible
MenuItem {action: quitAction}
}
Menu {
title: qsTr("Terminal")
visible: defaultMenuBar.visible
MenuItem {action: newAction}
MenuItem {action: closeAction}
}
Menu {
title: qsTr("Edit")
visible: defaultMenuBar.visible && appSettings.showMenubar
Expand Down
21 changes: 17 additions & 4 deletions app/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,22 @@ ApplicationWindow{
color: "#00000000"
title: terminalContainer.title || qsTr(appSettings.wintitle)

Action {
id: newAction
text: qsTr("New Window")
shortcut: Qt.platform.os === "osx" ? StandardKey.New : "Ctrl+Shift+N"
onTriggered: {
root.newWindow()
}
}
Action {
id: closeAction
text: qsTr("Close Window")
shortcut: Qt.platform.os === "osx" ? StandardKey.Close : "Ctrl+Shift+W"
onTriggered: {
terminalWindow.close()
}
}
Action {
id: showMenubarAction
text: qsTr("Show Menubar")
Expand Down Expand Up @@ -157,9 +173,6 @@ ApplicationWindow{
}
}
onClosing: {
// OSX Since we are currently supporting only one window
// quit the application when it is closed.
if (Qt.platform.os === "osx")
Qt.quit()
root.closeWindow()
}
}
1 change: 1 addition & 0 deletions app/qml/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<file>InsertNameDialog.qml</file>
<file>SettingsEffectsTab.qml</file>
<file>main.qml</file>
<file>root.qml</file>
<file>SettingsTerminalTab.qml</file>
<file>FontScanlines.qml</file>
<file>fonts/1977-apple2/PrintChar21.ttf</file>
Expand Down
43 changes: 43 additions & 0 deletions app/qml/root.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*******************************************************************************
* Copyright (c) 2013 "Filippo Scognamiglio"
* https://github.com/Swordfish90/cool-retro-term
*
* This file is part of cool-retro-term.
*
* cool-retro-term is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
import QtQuick 2.2
import QtQuick.Window 2.1

QtObject {
id: root
property int terminalCount

function newWindow() {
var component = Qt.createComponent("main.qml")
var window = component.createObject()
window.show()
terminalCount = terminalCount + 1
}
function closeWindow() {
terminalCount = terminalCount - 1
if (terminalCount == 0) {
Qt.quit()
}
}
Component.onCompleted: {
terminalCount = 0
root.newWindow()
}
}