Skip to content

Commit 403bb11

Browse files
authored
Merge pull request #912 from Swordfish90/fix/actions-regressions
Fix regressions in shortcuts on Linux
2 parents 8cf3031 + 9f05d72 commit 403bb11

10 files changed

Lines changed: 112 additions & 252 deletions

app/qml/PreprocessedTerminal.qml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,14 @@
2020

2121
import QtQuick 2.2
2222
import QtQuick.Controls 2.0
23-
import QtQml
2423

2524
import QMLTermWidget 2.0
2625

2726
import "menus"
2827
import "utils.js" as Utils
2928

30-
Item {
31-
id: preprocessedTerminal
29+
Item{
30+
id: terminalContainer
3231
signal sessionFinished()
3332

3433
property size virtualResolution: Qt.size(kterminal.totalWidth, kterminal.totalHeight)
@@ -48,14 +47,14 @@ Item {
4847
// Manage copy and paste
4948
Connections {
5049
target: copyAction
51-
enabled: terminalContainer.hasFocus
50+
5251
onTriggered: {
5352
kterminal.copyClipboard()
5453
}
5554
}
5655
Connections {
5756
target: pasteAction
58-
enabled: terminalContainer.hasFocus
57+
5958
onTriggered: {
6059
kterminal.pasteClipboard()
6160
}
@@ -66,22 +65,22 @@ Item {
6665
target: appSettings
6766

6867
onFontScalingChanged: {
69-
preprocessedTerminal.updateSources()
68+
terminalContainer.updateSources()
7069
}
7170

7271
onFontWidthChanged: {
73-
preprocessedTerminal.updateSources()
72+
terminalContainer.updateSources()
7473
}
7574
}
7675
Connections {
77-
target: preprocessedTerminal
76+
target: terminalContainer
7877

7978
onWidthChanged: {
80-
preprocessedTerminal.updateSources()
79+
terminalContainer.updateSources()
8180
}
8281

8382
onHeightChanged: {
84-
preprocessedTerminal.updateSources()
83+
terminalContainer.updateSources()
8584
}
8685
}
8786

@@ -119,7 +118,7 @@ Item {
119118
id: ksession
120119

121120
onFinished: {
122-
preprocessedTerminal.sessionFinished()
121+
terminalContainer.sessionFinished()
123122
}
124123
}
125124

@@ -149,16 +148,16 @@ Item {
149148
pixelSize: pixelSize
150149
});
151150

152-
preprocessedTerminal.fontWidth = fontWidth;
153-
preprocessedTerminal.screenScaling = screenScaling;
151+
terminalContainer.fontWidth = fontWidth;
152+
terminalContainer.screenScaling = screenScaling;
154153
scaleTexture = Math.max(1.0, Math.floor(screenScaling * appSettings.windowScaling));
155154
}
156155

157156
Connections {
158157
target: appSettings
159158

160159
onWindowScalingChanged: {
161-
scaleTexture = Math.max(1.0, Math.floor(preprocessedTerminal.screenScaling * appSettings.windowScaling));
160+
scaleTexture = Math.max(1.0, Math.floor(terminalContainer.screenScaling * appSettings.windowScaling));
162161
}
163162
}
164163

@@ -187,6 +186,9 @@ Item {
187186
appSettings.fontManager.refresh()
188187
startSession();
189188
}
189+
Component.onDestruction: {
190+
appSettings.fontManager.terminalFontChanged.disconnect(handleFontChanged);
191+
}
190192
}
191193

192194
Component {
@@ -214,7 +216,7 @@ Item {
214216
cursorShape: kterminal.terminalUsesMouse ? Qt.ArrowCursor : Qt.IBeamCursor
215217
onWheel: function(wheel) {
216218
if (wheel.modifiers & Qt.ControlModifier) {
217-
wheel.angleDelta.y > 0 ? zoomInAction.trigger() : zoomOutAction.trigger();
219+
wheel.angleDelta.y > 0 ? zoomIn.trigger() : zoomOut.trigger();
218220
} else {
219221
var coord = correctDistortion(wheel.x, wheel.y);
220222
kterminal.simulateWheel(coord.x, coord.y, wheel.buttons, wheel.modifiers, wheel.angleDelta);

app/qml/TerminalContainer.qml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ ShaderTerminal {
2828
signal sessionFinished()
2929

3030
property bool loadBloomEffect: appSettings.bloom > 0 || appSettings._frameShininess > 0
31-
property bool hasFocus
32-
33-
onHasFocusChanged: {
34-
if (hasFocus) {
35-
activate()
36-
}
37-
}
3831

3932
id: mainShader
4033
opacity: appSettings.windowOpacity * 0.3 + 0.7

app/qml/TerminalTabs.qml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,17 @@ Item {
130130
Repeater {
131131
model: tabsModel
132132
TerminalContainer {
133-
id: terminalContainer
134-
hasFocus: terminalWindow.active && StackLayout.isCurrentItem
135-
136-
onTerminalSizeChanged: updateTerminalSize()
137-
133+
property bool shouldHaveFocus: terminalWindow.active && StackLayout.isCurrentItem
134+
onShouldHaveFocusChanged: {
135+
if (shouldHaveFocus) {
136+
activate()
137+
}
138+
}
138139
onTitleChanged: tabsModel.setProperty(index, "title", normalizeTitle(title))
139140
Layout.fillWidth: true
140141
Layout.fillHeight: true
141142
onSessionFinished: tabsRoot.closeTab(index)
143+
onTerminalSizeChanged: updateTerminalSize()
142144

143145
function updateTerminalSize() {
144146
// Every tab will have the same size so we can simply take the first one.

app/qml/TerminalWindow.qml

Lines changed: 68 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import QtQuick 2.2
2121
import QtQuick.Window 2.1
2222
import QtQuick.Controls 2.3
23-
import QtQml
2423

2524
import "menus"
2625

@@ -43,32 +42,81 @@ ApplicationWindow {
4342
property bool fullscreen: false
4443
onFullscreenChanged: visibility = (fullscreen ? Window.FullScreen : Window.Windowed)
4544

46-
menuBar: qtquickMenuLoader.item
47-
48-
Loader {
49-
id: qtquickMenuLoader
50-
active: !appSettings.isMacOS && (appSettings.showMenubar && !fullscreen)
51-
sourceComponent: WindowMenu { }
52-
}
53-
54-
Connections {
55-
target: newTabAction
56-
enabled: terminalWindow.active
57-
onTriggered: terminalTabs.addTab()
58-
}
59-
60-
Connections {
61-
target: fullscreenAction
62-
enabled: terminalWindow.active
63-
onTriggered: terminalWindow.fullscreen = !terminalWindow.fullscreen
64-
}
45+
menuBar: WindowMenu { }
6546

6647
property real normalizedWindowScale: 1024 / ((0.5 * width + 0.5 * height))
6748

6849
color: "#00000000"
6950

7051
title: terminalTabs.currentTitle
7152

53+
Action {
54+
id: fullscreenAction
55+
text: qsTr("Fullscreen")
56+
enabled: !appSettings.isMacOS
57+
shortcut: StandardKey.FullScreen
58+
onTriggered: fullscreen = !fullscreen
59+
checkable: true
60+
checked: fullscreen
61+
}
62+
Action {
63+
id: newWindowAction
64+
text: qsTr("New Window")
65+
shortcut: appSettings.isMacOS ? "Meta+N" : "Ctrl+Shift+N"
66+
onTriggered: appRoot.createWindow()
67+
}
68+
Action {
69+
id: quitAction
70+
text: qsTr("Quit")
71+
shortcut: appSettings.isMacOS ? StandardKey.Close : "Ctrl+Shift+Q"
72+
onTriggered: terminalWindow.close()
73+
}
74+
Action {
75+
id: showsettingsAction
76+
text: qsTr("Settings")
77+
onTriggered: {
78+
settingsWindow.show()
79+
settingsWindow.requestActivate()
80+
settingsWindow.raise()
81+
}
82+
}
83+
Action {
84+
id: copyAction
85+
text: qsTr("Copy")
86+
shortcut: appSettings.isMacOS ? StandardKey.Copy : "Ctrl+Shift+C"
87+
}
88+
Action {
89+
id: pasteAction
90+
text: qsTr("Paste")
91+
shortcut: appSettings.isMacOS ? StandardKey.Paste : "Ctrl+Shift+V"
92+
}
93+
Action {
94+
id: zoomIn
95+
text: qsTr("Zoom In")
96+
shortcut: StandardKey.ZoomIn
97+
onTriggered: appSettings.incrementScaling()
98+
}
99+
Action {
100+
id: zoomOut
101+
text: qsTr("Zoom Out")
102+
shortcut: StandardKey.ZoomOut
103+
onTriggered: appSettings.decrementScaling()
104+
}
105+
Action {
106+
id: showAboutAction
107+
text: qsTr("About")
108+
onTriggered: {
109+
aboutDialog.show()
110+
aboutDialog.requestActivate()
111+
aboutDialog.raise()
112+
}
113+
}
114+
Action {
115+
id: newTabAction
116+
text: qsTr("New Tab")
117+
shortcut: appSettings.isMacOS ? StandardKey.AddTab : "Ctrl+Shift+T"
118+
onTriggered: terminalTabs.addTab()
119+
}
72120
TerminalTabs {
73121
id: terminalTabs
74122
width: parent.width

app/qml/main.qml

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1919
*******************************************************************************/
2020
import QtQuick 2.2
21-
import QtQuick.Controls 2.3
2221

2322
import "menus"
2423

@@ -47,83 +46,12 @@ QtObject {
4746

4847
property ListModel windowsModel: ListModel { }
4948

50-
property Loader globalMenuLoader: Loader {
51-
active: appSettings.isMacOS
52-
sourceComponent: OSXMenu { }
53-
}
54-
55-
property Action fullscreenAction: Action {
56-
text: qsTr("Fullscreen")
57-
enabled: !appSettings.isMacOS
58-
shortcut: "Alt+F11"
59-
}
60-
61-
property bool initialFullscreenRequested: Qt.application.arguments.indexOf("--fullscreen") !== -1
62-
63-
property Action newWindowAction: Action {
64-
text: qsTr("New Window")
65-
shortcut: "Ctrl+Shift+N"
66-
onTriggered: appRoot.createWindow()
67-
}
68-
69-
property Action quitAction: Action {
70-
text: qsTr("Quit")
71-
shortcut: "Ctrl+Shift+Q"
72-
onTriggered: appSettings.close()
73-
}
74-
75-
property Action showsettingsAction: Action {
76-
text: qsTr("Settings")
77-
onTriggered: {
78-
settingsWindow.show()
79-
settingsWindow.requestActivate()
80-
settingsWindow.raise()
81-
}
82-
}
83-
84-
property Action copyAction: Action {
85-
text: qsTr("Copy")
86-
shortcut: "Ctrl+Shift+C"
87-
}
88-
89-
property Action pasteAction: Action {
90-
text: qsTr("Paste")
91-
shortcut: "Ctrl+Shift+V"
92-
}
93-
94-
property Action zoomInAction: Action {
95-
text: qsTr("Zoom In")
96-
shortcut: "Ctrl++"
97-
onTriggered: appSettings.incrementScaling()
98-
}
99-
100-
property Action zoomOutAction: Action {
101-
text: qsTr("Zoom Out")
102-
shortcut: "Ctrl+-"
103-
onTriggered: appSettings.decrementScaling()
104-
}
105-
106-
property Action showAboutAction: Action {
107-
text: qsTr("About")
108-
onTriggered: {
109-
aboutDialog.show()
110-
aboutDialog.requestActivate()
111-
aboutDialog.raise()
112-
}
113-
}
114-
115-
property Action newTabAction: Action {
116-
text: qsTr("New Tab")
117-
}
118-
11949
function createWindow() {
120-
var useFullscreen = initialFullscreenRequested
121-
var window = windowComponent.createObject(null, { fullscreen: useFullscreen })
50+
var window = windowComponent.createObject(null)
12251
if (!window)
12352
return
12453

12554
windowsModel.append({ window: window })
126-
initialFullscreenRequested = false
12755
window.show()
12856
window.requestActivate()
12957
}

app/qml/menus/FullContextMenu.qml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ Menu {
6565
visible: fullscreenAction.enabled
6666
}
6767
MenuItem {
68-
action: zoomInAction
68+
action: zoomIn
6969
}
7070
MenuItem {
71-
action: zoomOutAction
71+
action: zoomOut
7272
}
7373
}
7474
Menu {

0 commit comments

Comments
 (0)