Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions app/qml/PreprocessedTerminal.qml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@

import QtQuick 2.2
import QtQuick.Controls 2.0
import QtQml

import QMLTermWidget 2.0

import "menus"
import "utils.js" as Utils

Item {
id: preprocessedTerminal
Item{
id: terminalContainer
signal sessionFinished()

property size virtualResolution: Qt.size(kterminal.totalWidth, kterminal.totalHeight)
Expand All @@ -48,14 +47,14 @@ Item {
// Manage copy and paste
Connections {
target: copyAction
enabled: terminalContainer.hasFocus

onTriggered: {
kterminal.copyClipboard()
}
}
Connections {
target: pasteAction
enabled: terminalContainer.hasFocus

onTriggered: {
kterminal.pasteClipboard()
}
Expand All @@ -66,22 +65,22 @@ Item {
target: appSettings

onFontScalingChanged: {
preprocessedTerminal.updateSources()
terminalContainer.updateSources()
}

onFontWidthChanged: {
preprocessedTerminal.updateSources()
terminalContainer.updateSources()
}
}
Connections {
target: preprocessedTerminal
target: terminalContainer

onWidthChanged: {
preprocessedTerminal.updateSources()
terminalContainer.updateSources()
}

onHeightChanged: {
preprocessedTerminal.updateSources()
terminalContainer.updateSources()
}
}

Expand Down Expand Up @@ -119,7 +118,7 @@ Item {
id: ksession

onFinished: {
preprocessedTerminal.sessionFinished()
terminalContainer.sessionFinished()
}
}

Expand Down Expand Up @@ -149,16 +148,16 @@ Item {
pixelSize: pixelSize
});

preprocessedTerminal.fontWidth = fontWidth;
preprocessedTerminal.screenScaling = screenScaling;
terminalContainer.fontWidth = fontWidth;
terminalContainer.screenScaling = screenScaling;
scaleTexture = Math.max(1.0, Math.floor(screenScaling * appSettings.windowScaling));
}

Connections {
target: appSettings

onWindowScalingChanged: {
scaleTexture = Math.max(1.0, Math.floor(preprocessedTerminal.screenScaling * appSettings.windowScaling));
scaleTexture = Math.max(1.0, Math.floor(terminalContainer.screenScaling * appSettings.windowScaling));
}
}

Expand Down Expand Up @@ -187,6 +186,9 @@ Item {
appSettings.fontManager.refresh()
startSession();
}
Component.onDestruction: {
appSettings.fontManager.terminalFontChanged.disconnect(handleFontChanged);
}
}

Component {
Expand Down Expand Up @@ -214,7 +216,7 @@ Item {
cursorShape: kterminal.terminalUsesMouse ? Qt.ArrowCursor : Qt.IBeamCursor
onWheel: function(wheel) {
if (wheel.modifiers & Qt.ControlModifier) {
wheel.angleDelta.y > 0 ? zoomInAction.trigger() : zoomOutAction.trigger();
wheel.angleDelta.y > 0 ? zoomIn.trigger() : zoomOut.trigger();
} else {
var coord = correctDistortion(wheel.x, wheel.y);
kterminal.simulateWheel(coord.x, coord.y, wheel.buttons, wheel.modifiers, wheel.angleDelta);
Expand Down
7 changes: 0 additions & 7 deletions app/qml/TerminalContainer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ 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
Expand Down
12 changes: 7 additions & 5 deletions app/qml/TerminalTabs.qml
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,17 @@ Item {
Repeater {
model: tabsModel
TerminalContainer {
id: terminalContainer
hasFocus: terminalWindow.active && StackLayout.isCurrentItem

onTerminalSizeChanged: updateTerminalSize()

property bool shouldHaveFocus: terminalWindow.active && StackLayout.isCurrentItem
onShouldHaveFocusChanged: {
if (shouldHaveFocus) {
activate()
}
}
onTitleChanged: tabsModel.setProperty(index, "title", normalizeTitle(title))
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.
Expand Down
88 changes: 68 additions & 20 deletions app/qml/TerminalWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import QtQuick 2.2
import QtQuick.Window 2.1
import QtQuick.Controls 2.3
import QtQml

import "menus"

Expand All @@ -43,32 +42,81 @@ 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 { }
}

Connections {
target: newTabAction
enabled: terminalWindow.active
onTriggered: terminalTabs.addTab()
}

Connections {
target: fullscreenAction
enabled: terminalWindow.active
onTriggered: terminalWindow.fullscreen = !terminalWindow.fullscreen
}
menuBar: WindowMenu { }

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

color: "#00000000"

title: terminalTabs.currentTitle

Action {
id: fullscreenAction
text: qsTr("Fullscreen")
enabled: !appSettings.isMacOS
shortcut: StandardKey.FullScreen
onTriggered: fullscreen = !fullscreen
checkable: true
checked: fullscreen
}
Action {
id: newWindowAction
text: qsTr("New Window")
shortcut: appSettings.isMacOS ? "Meta+N" : "Ctrl+Shift+N"
onTriggered: appRoot.createWindow()
}
Action {
id: quitAction
text: qsTr("Quit")
shortcut: appSettings.isMacOS ? StandardKey.Close : "Ctrl+Shift+Q"
onTriggered: terminalWindow.close()
}
Action {
id: showsettingsAction
text: qsTr("Settings")
onTriggered: {
settingsWindow.show()
settingsWindow.requestActivate()
settingsWindow.raise()
}
}
Action {
id: copyAction
text: qsTr("Copy")
shortcut: appSettings.isMacOS ? StandardKey.Copy : "Ctrl+Shift+C"
}
Action {
id: pasteAction
text: qsTr("Paste")
shortcut: appSettings.isMacOS ? StandardKey.Paste : "Ctrl+Shift+V"
}
Action {
id: zoomIn
text: qsTr("Zoom In")
shortcut: StandardKey.ZoomIn
onTriggered: appSettings.incrementScaling()
}
Action {
id: zoomOut
text: qsTr("Zoom Out")
shortcut: StandardKey.ZoomOut
onTriggered: appSettings.decrementScaling()
}
Action {
id: showAboutAction
text: qsTr("About")
onTriggered: {
aboutDialog.show()
aboutDialog.requestActivate()
aboutDialog.raise()
}
}
Action {
id: newTabAction
text: qsTr("New Tab")
shortcut: appSettings.isMacOS ? StandardKey.AddTab : "Ctrl+Shift+T"
onTriggered: terminalTabs.addTab()
}
TerminalTabs {
id: terminalTabs
width: parent.width
Expand Down
74 changes: 1 addition & 73 deletions app/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
import QtQuick 2.2
import QtQuick.Controls 2.3

import "menus"

Expand Down Expand Up @@ -47,83 +46,12 @@ QtObject {

property ListModel windowsModel: ListModel { }

property Loader globalMenuLoader: Loader {
active: appSettings.isMacOS
sourceComponent: OSXMenu { }
}

property Action fullscreenAction: Action {
text: qsTr("Fullscreen")
enabled: !appSettings.isMacOS
shortcut: "Alt+F11"
}

property bool initialFullscreenRequested: Qt.application.arguments.indexOf("--fullscreen") !== -1

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 useFullscreen = initialFullscreenRequested
var window = windowComponent.createObject(null, { fullscreen: useFullscreen })
var window = windowComponent.createObject(null)
if (!window)
return

windowsModel.append({ window: window })
initialFullscreenRequested = false
window.show()
window.requestActivate()
}
Expand Down
4 changes: 2 additions & 2 deletions app/qml/menus/FullContextMenu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ Menu {
visible: fullscreenAction.enabled
}
MenuItem {
action: zoomInAction
action: zoomIn
}
MenuItem {
action: zoomOutAction
action: zoomOut
}
}
Menu {
Expand Down
Loading
Loading