diff --git a/app/qml/PreprocessedTerminal.qml b/app/qml/PreprocessedTerminal.qml index 697e42b..3b084b3 100644 --- a/app/qml/PreprocessedTerminal.qml +++ b/app/qml/PreprocessedTerminal.qml @@ -20,6 +20,7 @@ import QtQuick 2.2 import QtQuick.Controls 2.0 +import QtQml import QMLTermWidget 1.0 @@ -27,7 +28,7 @@ import "menus" import "utils.js" as Utils Item{ - id: terminalContainer + id: preprocessedTerminal signal sessionFinished() property size virtualResolution: Qt.size(kterminal.totalWidth, kterminal.totalHeight) @@ -47,14 +48,14 @@ Item{ // Manage copy and paste Connections { target: copyAction - + enabled: terminalContainer.hasFocus onTriggered: { kterminal.copyClipboard() } } Connections { target: pasteAction - + enabled: terminalContainer.hasFocus onTriggered: { kterminal.pasteClipboard() } @@ -65,22 +66,22 @@ Item{ target: appSettings onFontScalingChanged: { - terminalContainer.updateSources() + preprocessedTerminal.updateSources() } onFontWidthChanged: { - terminalContainer.updateSources() + preprocessedTerminal.updateSources() } } Connections { - target: terminalContainer + target: preprocessedTerminal onWidthChanged: { - terminalContainer.updateSources() + preprocessedTerminal.updateSources() } onHeightChanged: { - terminalContainer.updateSources() + preprocessedTerminal.updateSources() } } @@ -118,7 +119,7 @@ Item{ id: ksession onFinished: { - terminalContainer.sessionFinished() + preprocessedTerminal.sessionFinished() } } @@ -148,8 +149,8 @@ Item{ pixelSize: pixelSize }); - terminalContainer.fontWidth = fontWidth; - terminalContainer.screenScaling = screenScaling; + preprocessedTerminal.fontWidth = fontWidth; + preprocessedTerminal.screenScaling = screenScaling; scaleTexture = Math.max(1.0, Math.floor(screenScaling * appSettings.windowScaling)); } @@ -157,7 +158,7 @@ Item{ target: appSettings onWindowScalingChanged: { - scaleTexture = Math.max(1.0, Math.floor(terminalContainer.screenScaling * appSettings.windowScaling)); + scaleTexture = Math.max(1.0, Math.floor(preprocessedTerminal.screenScaling * appSettings.windowScaling)); } } @@ -213,7 +214,7 @@ Item{ cursorShape: kterminal.terminalUsesMouse ? Qt.ArrowCursor : Qt.IBeamCursor onWheel: function(wheel) { if (wheel.modifiers & Qt.ControlModifier) { - wheel.angleDelta.y > 0 ? zoomIn.trigger() : zoomOut.trigger(); + wheel.angleDelta.y > 0 ? zoomInAction.trigger() : zoomOutAction.trigger(); } else { var coord = correctDistortion(wheel.x, wheel.y); kterminal.simulateWheel(coord.x, coord.y, wheel.buttons, wheel.modifiers, wheel.angleDelta); diff --git a/app/qml/TerminalContainer.qml b/app/qml/TerminalContainer.qml index 657cdc7..9074893 100644 --- a/app/qml/TerminalContainer.qml +++ b/app/qml/TerminalContainer.qml @@ -28,6 +28,13 @@ ShaderTerminal { signal sessionFinished() property bool loadBloomEffect: appSettings.bloom > 0 || appSettings._frameShininess > 0 + property bool hasFocus + + onHasFocusChanged: { + if (hasFocus) { + activate() + } + } id: mainShader opacity: appSettings.windowOpacity * 0.3 + 0.7 diff --git a/app/qml/TerminalTabs.qml b/app/qml/TerminalTabs.qml index 361a172..3ea20b5 100644 --- a/app/qml/TerminalTabs.qml +++ b/app/qml/TerminalTabs.qml @@ -130,12 +130,8 @@ Item { Repeater { model: tabsModel TerminalContainer { - property bool shouldHaveFocus: terminalWindow.active && StackLayout.isCurrentItem - onShouldHaveFocusChanged: { - if (shouldHaveFocus) { - activate() - } - } + id: terminalContainer + hasFocus: terminalWindow.active && StackLayout.isCurrentItem onTitleChanged: tabsModel.setProperty(index, "title", normalizeTitle(title)) Layout.fillWidth: true Layout.fillHeight: true diff --git a/app/qml/TerminalWindow.qml b/app/qml/TerminalWindow.qml index 462aab4..8cc1c31 100644 --- a/app/qml/TerminalWindow.qml +++ b/app/qml/TerminalWindow.qml @@ -20,6 +20,7 @@ import QtQuick 2.2 import QtQuick.Window 2.1 import QtQuick.Controls 2.3 +import QtQml import "menus" @@ -50,87 +51,18 @@ ApplicationWindow { sourceComponent: WindowMenu { } } + Connections { + target: newTabAction + enabled: terminalWindow.active + onTriggered: terminalTabs.addTab() + } + property real normalizedWindowScale: 1024 / ((0.5 * width + 0.5 * height)) color: "#00000000" title: terminalTabs.currentTitle - Action { - id: showMenubarAction - text: qsTr("Show Menubar") - enabled: !appSettings.isMacOS - shortcut: "Ctrl+Shift+M" - checkable: true - checked: appSettings.showMenubar - onTriggered: appSettings.showMenubar = !appSettings.showMenubar - } - Action { - id: fullscreenAction - text: qsTr("Fullscreen") - enabled: !appSettings.isMacOS - shortcut: "Alt+F11" - onTriggered: appSettings.fullscreen = !appSettings.fullscreen - checkable: true - checked: appSettings.fullscreen - } - Action { - id: newWindowAction - text: qsTr("New Window") - shortcut: "Ctrl+Shift+N" - onTriggered: appRoot.createWindow() - } - Action { - id: quitAction - text: qsTr("Quit") - shortcut: "Ctrl+Shift+Q" - onTriggered: appSettings.close() - } - Action { - id: showsettingsAction - text: qsTr("Settings") - onTriggered: { - settingsWindow.show() - settingsWindow.requestActivate() - settingsWindow.raise() - } - } - Action { - id: copyAction - text: qsTr("Copy") - shortcut: "Ctrl+Shift+C" - } - Action { - id: pasteAction - text: qsTr("Paste") - shortcut: "Ctrl+Shift+V" - } - Action { - id: zoomIn - text: qsTr("Zoom In") - shortcut: "Ctrl++" - onTriggered: appSettings.incrementScaling() - } - Action { - id: zoomOut - text: qsTr("Zoom Out") - shortcut: "Ctrl+-" - onTriggered: appSettings.decrementScaling() - } - Action { - id: showAboutAction - text: qsTr("About") - onTriggered: { - aboutDialog.show() - aboutDialog.requestActivate() - aboutDialog.raise() - } - } - Action { - id: newTabAction - text: qsTr("New Tab") - onTriggered: terminalTabs.addTab() - } TerminalTabs { id: terminalTabs width: parent.width diff --git a/app/qml/main.qml b/app/qml/main.qml index c82f8f1..db0be61 100644 --- a/app/qml/main.qml +++ b/app/qml/main.qml @@ -18,6 +18,7 @@ * along with this program. If not, see . *******************************************************************************/ import QtQuick 2.2 +import QtQuick.Controls 2.3 import "menus" @@ -51,6 +52,80 @@ QtObject { sourceComponent: OSXMenu { } } + property Action showMenubarAction: Action { + text: qsTr("Show Menubar") + enabled: !appSettings.isMacOS + shortcut: "Ctrl+Shift+M" + checkable: true + checked: appSettings.showMenubar + onTriggered: appSettings.showMenubar = !appSettings.showMenubar + } + + property Action fullscreenAction: Action { + text: qsTr("Fullscreen") + enabled: !appSettings.isMacOS + shortcut: "Alt+F11" + onTriggered: appSettings.fullscreen = !appSettings.fullscreen + checkable: true + checked: appSettings.fullscreen + } + + property Action newWindowAction: Action { + text: qsTr("New Window") + shortcut: "Ctrl+Shift+N" + onTriggered: appRoot.createWindow() + } + + property Action quitAction: Action { + text: qsTr("Quit") + shortcut: "Ctrl+Shift+Q" + onTriggered: appSettings.close() + } + + property Action showsettingsAction: Action { + text: qsTr("Settings") + onTriggered: { + settingsWindow.show() + settingsWindow.requestActivate() + settingsWindow.raise() + } + } + + property Action copyAction: Action { + text: qsTr("Copy") + shortcut: "Ctrl+Shift+C" + } + + property Action pasteAction: Action { + text: qsTr("Paste") + shortcut: "Ctrl+Shift+V" + } + + property Action zoomInAction: Action { + text: qsTr("Zoom In") + shortcut: "Ctrl++" + onTriggered: appSettings.incrementScaling() + } + + property Action zoomOutAction: Action { + text: qsTr("Zoom Out") + shortcut: "Ctrl+-" + onTriggered: appSettings.decrementScaling() + } + + property Action showAboutAction: Action { + text: qsTr("About") + onTriggered: { + aboutDialog.show() + aboutDialog.requestActivate() + aboutDialog.raise() + } + } + + property Action newTabAction: Action { + text: qsTr("New Tab") + } + function createWindow() { var window = windowComponent.createObject(null) if (!window) diff --git a/app/qml/menus/FullContextMenu.qml b/app/qml/menus/FullContextMenu.qml index 3cb3aa8..75fb8bc 100644 --- a/app/qml/menus/FullContextMenu.qml +++ b/app/qml/menus/FullContextMenu.qml @@ -69,10 +69,10 @@ Menu { visible: showMenubarAction.enabled } MenuItem { - action: zoomIn + action: zoomInAction } MenuItem { - action: zoomOut + action: zoomOutAction } } Menu { diff --git a/app/qml/menus/OSXMenu.qml b/app/qml/menus/OSXMenu.qml index 0cd2b05..7f0926a 100644 --- a/app/qml/menus/OSXMenu.qml +++ b/app/qml/menus/OSXMenu.qml @@ -64,14 +64,14 @@ MenuBar { Menu { title: qsTr("View") MenuItem { - text: zoomIn.text + text: zoomInAction.text shortcut: "Meta++" - onTriggered: zoomIn.trigger() + onTriggered: zoomInAction.trigger() } MenuItem { - text: zoomOut.text + text: zoomOutAction.text shortcut: "Meta+-" - onTriggered: zoomOut.trigger() + onTriggered: zoomOutAction.trigger() } } Menu { diff --git a/app/qml/menus/WindowMenu.qml b/app/qml/menus/WindowMenu.qml index e3b9377..3c7825b 100644 --- a/app/qml/menus/WindowMenu.qml +++ b/app/qml/menus/WindowMenu.qml @@ -61,10 +61,10 @@ MenuBar { visible: showMenubarAction.enabled } MenuItem { - action: zoomIn + action: zoomInAction } MenuItem { - action: zoomOut + action: zoomOutAction } } Menu {