From b77a1b5962f6e53fbde1daaee8833b2f3657855e Mon Sep 17 00:00:00 2001 From: Filippo Scognamiglio Date: Thu, 22 Jan 2026 01:20:06 +0100 Subject: [PATCH] Fix shortcuts on macOS. --- app/qml/TerminalTabs.qml | 1 + app/qml/TerminalWindow.qml | 25 ++++----- app/qml/menus/OSXMenu.qml | 99 ------------------------------------ app/qml/menus/WindowMenu.qml | 44 ++++++---------- app/qml/resources.qrc | 1 - 5 files changed, 26 insertions(+), 144 deletions(-) delete mode 100644 app/qml/menus/OSXMenu.qml diff --git a/app/qml/TerminalTabs.qml b/app/qml/TerminalTabs.qml index ac60681..d1d5bd0 100644 --- a/app/qml/TerminalTabs.qml +++ b/app/qml/TerminalTabs.qml @@ -140,6 +140,7 @@ Item { Layout.fillWidth: true Layout.fillHeight: true onSessionFinished: tabsRoot.closeTab(index) + onTerminalSizeChanged: updateTerminalSize() function updateTerminalSize() { // Every tab will have the same size so we can simply take the first one. diff --git a/app/qml/TerminalWindow.qml b/app/qml/TerminalWindow.qml index 9a75a77..f4bb93a 100644 --- a/app/qml/TerminalWindow.qml +++ b/app/qml/TerminalWindow.qml @@ -42,13 +42,7 @@ ApplicationWindow { property bool fullscreen: false onFullscreenChanged: visibility = (fullscreen ? Window.FullScreen : Window.Windowed) - menuBar: qtquickMenuLoader.item - - Loader { - id: qtquickMenuLoader - active: appSettings.isMacOS || (appSettings.showMenubar && !fullscreen) - sourceComponent: WindowMenu { } - } + menuBar: WindowMenu { } property real normalizedWindowScale: 1024 / ((0.5 * width + 0.5 * height)) @@ -60,7 +54,7 @@ ApplicationWindow { id: fullscreenAction text: qsTr("Fullscreen") enabled: !appSettings.isMacOS - shortcut: "Alt+F11" + shortcut: StandardKey.FullScreen onTriggered: fullscreen = !fullscreen checkable: true checked: fullscreen @@ -68,14 +62,14 @@ ApplicationWindow { Action { id: newWindowAction text: qsTr("New Window") - shortcut: "Ctrl+Shift+N" + shortcut: appSettings.isMacOS ? "Meta+N" : "Ctrl+Shift+N" onTriggered: appRoot.createWindow() } Action { id: quitAction text: qsTr("Quit") - shortcut: "Ctrl+Shift+Q" - onTriggered: appSettings.close() + shortcut: appSettings.isMacOS ? StandardKey.Close : "Ctrl+Shift+Q" + onTriggered: terminalWindow.close() } Action { id: showsettingsAction @@ -89,23 +83,23 @@ ApplicationWindow { Action { id: copyAction text: qsTr("Copy") - shortcut: "Ctrl+Shift+C" + shortcut: appSettings.isMacOS ? StandardKey.Copy : "Ctrl+Shift+C" } Action { id: pasteAction text: qsTr("Paste") - shortcut: "Ctrl+Shift+V" + shortcut: appSettings.isMacOS ? StandardKey.Paste : "Ctrl+Shift+V" } Action { id: zoomIn text: qsTr("Zoom In") - shortcut: "Ctrl++" + shortcut: StandardKey.ZoomIn onTriggered: appSettings.incrementScaling() } Action { id: zoomOut text: qsTr("Zoom Out") - shortcut: "Ctrl+-" + shortcut: StandardKey.ZoomOut onTriggered: appSettings.decrementScaling() } Action { @@ -120,6 +114,7 @@ ApplicationWindow { Action { id: newTabAction text: qsTr("New Tab") + shortcut: appSettings.isMacOS ? StandardKey.AddTab : "Ctrl+Shift+T" onTriggered: terminalTabs.addTab() } TerminalTabs { diff --git a/app/qml/menus/OSXMenu.qml b/app/qml/menus/OSXMenu.qml deleted file mode 100644 index 0cd2b05..0000000 --- a/app/qml/menus/OSXMenu.qml +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2013-2021 "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 . -*******************************************************************************/ - -import QtQuick 2.3 -import Qt.labs.platform 1.1 - -MenuBar { - id: defaultMenuBar - - Menu { - title: qsTr("File") - MenuItem { - text: newWindowAction.text - shortcut: newWindowAction.shortcut - onTriggered: newWindowAction.trigger() - } - MenuItem { - text: newTabAction.text - shortcut: newTabAction.shortcut - onTriggered: newTabAction.trigger() - } - MenuSeparator {} - MenuItem { - text: quitAction.text - onTriggered: quitAction.trigger() - } - } - Menu { - title: qsTr("Edit") - MenuItem { - text: copyAction.text - shortcut: "Meta+C" - onTriggered: copyAction.trigger() - } - MenuItem { - text: pasteAction.text - shortcut: "Meta+V" - onTriggered: pasteAction.trigger() - } - MenuSeparator {} - MenuItem { - text: showsettingsAction.text - shortcut: showsettingsAction.shortcut - onTriggered: showsettingsAction.trigger() - } - } - Menu { - title: qsTr("View") - MenuItem { - text: zoomIn.text - shortcut: "Meta++" - onTriggered: zoomIn.trigger() - } - MenuItem { - text: zoomOut.text - shortcut: "Meta+-" - onTriggered: zoomOut.trigger() - } - } - Menu { - id: profilesMenu - title: qsTr("Profiles") - Instantiator { - model: appSettings.profilesList - delegate: MenuItem { - text: model.text - onTriggered: { - appSettings.loadProfileString(obj_string) - } - } - onObjectAdded: function(index, object) { profilesMenu.insertItem(index, object) } - onObjectRemoved: function(object) { profilesMenu.removeItem(object) } - } - } - Menu { - title: qsTr("Help") - MenuItem { - text: showAboutAction.text - onTriggered: showAboutAction.trigger() - } - } -} diff --git a/app/qml/menus/WindowMenu.qml b/app/qml/menus/WindowMenu.qml index df2e94b..568fda1 100644 --- a/app/qml/menus/WindowMenu.qml +++ b/app/qml/menus/WindowMenu.qml @@ -22,46 +22,32 @@ import QtQuick.Controls 2.3 MenuBar { id: defaultMenuBar - visible: appSettings.showMenubar + visible: appSettings.isMacOS || appSettings.showMenubar Menu { title: qsTr("File") - MenuItem { - action: newWindowAction - } - MenuItem { - action: newTabAction - } - MenuSeparator {} - MenuItem { - action: quitAction - } + MenuItem { action: newWindowAction } + MenuItem { action: newTabAction } + MenuSeparator { } + MenuItem { action: quitAction } } Menu { title: qsTr("Edit") - MenuItem { - action: copyAction - } - MenuItem { - action: pasteAction - } + MenuItem { action: copyAction } + MenuItem { action: pasteAction } MenuSeparator {} - MenuItem { - action: showsettingsAction - } + MenuItem { action: showsettingsAction } } Menu { title: qsTr("View") - MenuItem { - action: fullscreenAction - visible: fullscreenAction.enabled - } - MenuItem { - action: zoomIn - } - MenuItem { - action: zoomOut + Instantiator { + model: !appSettings.isMacOS ? 1 : 0 + delegate: MenuItem { action: fullscreenAction } + onObjectAdded: (index, object) => menu.insertItem(index, object) + onObjectRemoved: (index, object) => menu.removeItem(object) } + MenuItem { action: zoomIn } + MenuItem { action: zoomOut } } Menu { id: profilesMenu diff --git a/app/qml/resources.qrc b/app/qml/resources.qrc index 961600e..8afc83a 100644 --- a/app/qml/resources.qrc +++ b/app/qml/resources.qrc @@ -48,7 +48,6 @@ menus/WindowMenu.qml menus/FullContextMenu.qml menus/ShortContextMenu.qml - menus/OSXMenu.qml ../shaders/terminal_dynamic.vert.qsb ../shaders/terminal_static.vert.qsb ../shaders/terminal_frame.vert.qsb