diff --git a/app/ShaderSettings.qml b/app/ShaderSettings.qml index fff5a4f..938184b 100644 --- a/app/ShaderSettings.qml +++ b/app/ShaderSettings.qml @@ -27,6 +27,8 @@ Item{ property real contrast: 0.85 property real brightness: 0.75 + property bool show_terminal_size: true + //Scaling of the preprocessed terminal with respect to the window. property real terminal_scaling: 1.0 onTerminal_scalingChanged: handleFontChanged(); @@ -167,6 +169,8 @@ Item{ console.log(profilename + settings); settings = JSON.parse(settings); + show_terminal_size = settings.show_terminal_size ? settings.show_terminal_size : show_terminal_size + fps = settings.fps !== undefined ? settings.fps: fps contrast = settings.contrast !== undefined ? settings.contrast : contrast; @@ -197,9 +201,10 @@ Item{ function storeCurrentSettings(){ var settings = { fps: fps, - ambient_light : ambient_light, - brightness : brightness, - contrast : contrast, + show_terminal_size: show_terminal_size, + ambient_light: ambient_light, + brightness: brightness, + contrast: contrast, background_color: _background_color, font_color: _font_color, brightness_flickering: brightness_flickering, diff --git a/app/SizeOverlay.qml b/app/SizeOverlay.qml new file mode 100644 index 0000000..3bcedc2 --- /dev/null +++ b/app/SizeOverlay.qml @@ -0,0 +1,29 @@ +import QtQuick 2.0 + +Rectangle{ + property size terminalSize + property real topOpacity: 0.6 + width: textSize.width * 2 + height: textSize.height * 2 + radius: 5 + border.width: 2 + border.color: "white" + color: "black" + opacity: sizetimer.running ? 0.6 : 0.0 + + Behavior on opacity{NumberAnimation{duration: 200}} + + onTerminalSizeChanged: sizetimer.restart() + + Text{ + id: textSize + anchors.centerIn: parent + color: "white" + text: terminalSize.width + "x" + terminalSize.height + } + Timer{ + id: sizetimer + interval: 1000 + running: false + } +} diff --git a/app/Terminal.qml b/app/Terminal.qml index 1501a32..80af85e 100644 --- a/app/Terminal.qml +++ b/app/Terminal.qml @@ -35,6 +35,8 @@ Item{ property real mBloom: shadersettings.bloom_strength + property size terminalSize + //Force reload of the blursource when settings change onMBloomChanged: restartBlurredSource() @@ -69,6 +71,8 @@ Item{ colorScheme: "MyWhiteOnBlack" + onTerminalSizeChanged: terminalContainer.terminalSize = ktermitem.terminalSize + session: KSession { id: ksession kbScheme: "linux" diff --git a/app/app.qmlproject.user b/app/app.qmlproject.user index 6ffb93c..a93d337 100644 --- a/app/app.qmlproject.user +++ b/app/app.qmlproject.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/app/main.qml b/app/main.qml index c633595..bc766aa 100644 --- a/app/main.qml +++ b/app/main.qml @@ -126,8 +126,8 @@ ApplicationWindow{ Terminal{ id: terminal anchors.centerIn: parent - property int frameOffsetX: frame.item.addedWidth - frame.item.borderLeft - frame.item.borderRight - property int frameOffsetY: frame.item.addedHeight -frame.item.borderTop - frame.item.borderBottom + property int frameOffsetX: frame.item.addedWidth - frame.item.borderLeft - frame.item.borderRight + property int frameOffsetY: frame.item.addedHeight - frame.item.borderTop - frame.item.borderBottom width: (parent.width + frameOffsetX) * shadersettings.terminal_scaling height: (parent.height + frameOffsetY) * shadersettings.terminal_scaling } @@ -139,7 +139,6 @@ ApplicationWindow{ ShaderManager{ id: shadercontainer anchors.fill: parent - blending: true z: 1.9 } RadialGradient{ @@ -153,10 +152,21 @@ ApplicationWindow{ GradientStop{position: 0.7; color: "#00000000"} } } + Loader{ + id: sizeoverlayloader + z: 3 + anchors.centerIn: parent + active: shadersettings.show_terminal_size + sourceComponent: SizeOverlay{ + terminalSize: terminal.terminalSize + } + } } ShaderSettings{ id: shadersettings - Component.onCompleted: terminal.loadKTerminal(); + Component.onCompleted: { + terminal.loadKTerminal(); + } } Loader{ id: settingswindowloader diff --git a/konsole-qml-plugin/src/TerminalDisplay.cpp b/konsole-qml-plugin/src/TerminalDisplay.cpp index c583fdb..1e7ee37 100644 --- a/konsole-qml-plugin/src/TerminalDisplay.cpp +++ b/konsole-qml-plugin/src/TerminalDisplay.cpp @@ -1058,6 +1058,8 @@ void KTerminalDisplay::updateImageSize() int lines = qMin(oldlin,_lines); int columns = qMin(oldcol,_columns); + emit terminalSizeChanged(); + if (oldimg) { for (int line = 0; line < lines; line++) diff --git a/konsole-qml-plugin/src/TerminalDisplay.h b/konsole-qml-plugin/src/TerminalDisplay.h index 384a6fc..8a71ec1 100644 --- a/konsole-qml-plugin/src/TerminalDisplay.h +++ b/konsole-qml-plugin/src/TerminalDisplay.h @@ -68,6 +68,7 @@ class KONSOLEPRIVATE_EXPORT KTerminalDisplay : public QQuickPaintedItem Q_PROPERTY(QFont font READ getVTFont WRITE setVTFont ) Q_PROPERTY(bool activeFocusOnClick READ autoFocus WRITE setAutoFocus NOTIFY changedAutoFocus) Q_PROPERTY(bool ShowIMEOnClick READ autoVKB WRITE setAutoVKB NOTIFY changedAutoVKB) + Q_PROPERTY(QSize terminalSize READ getTerminalSize NOTIFY terminalSizeChanged) @@ -190,7 +191,12 @@ public: */ int fontWidth() { return _fontWidth; } - + /** + * Return size of the terminal as columns lines. + */ + QSize getTerminalSize(){ + return QSize(columns(), lines()); + } /** * Sets which characters, in addition to letters and numbers, @@ -410,6 +416,8 @@ signals: void updatedImage(); void clicked(); + void terminalSizeChanged(); + ///////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////// /** diff --git a/konsole-qml-plugin/src/plugins.qmltypes b/konsole-qml-plugin/src/plugins.qmltypes index 3639ade..735abdb 100644 --- a/konsole-qml-plugin/src/plugins.qmltypes +++ b/konsole-qml-plugin/src/plugins.qmltypes @@ -60,6 +60,7 @@ Module { Property { name: "font"; type: "QFont" } Property { name: "activeFocusOnClick"; type: "bool" } Property { name: "ShowIMEOnClick"; type: "bool" } + Property { name: "terminalSize"; type: "QSize" } Signal { name: "changedScheme" Parameter { name: "scheme"; type: "string" } @@ -110,6 +111,7 @@ Module { name: "changedSession" Parameter { name: "session"; type: "KSession"; isPointer: true } } + Signal { name: "terminalSizeChanged" } Signal { name: "updatedImage" } Method { name: "forcedFocus" } Method {