From ab333ea4174d3f053ee8d83005346ba005454a43 Mon Sep 17 00:00:00 2001 From: Bhaskar Divya Date: Sun, 26 Apr 2020 13:46:21 +0530 Subject: [PATCH] Fixed text selection + Minor cleanups + Added "show background" option --- .gitignore | 6 ++ .kdev4/termoid.kdev4 | 68 ------------- package/contents/config/main.xml | 5 +- package/contents/ui/config/ConfigGeneral.qml | 19 +++- package/contents/ui/main.qml | 95 +++++++++++++++++-- package/metadata.desktop | 12 +-- termoid-v0.3.plasmoid | Bin 6170 -> 0 bytes termoid.kdev4 | 4 - upgrade | 4 - 9 files changed, 119 insertions(+), 94 deletions(-) create mode 100644 .gitignore delete mode 100644 .kdev4/termoid.kdev4 delete mode 100644 termoid-v0.3.plasmoid delete mode 100644 termoid.kdev4 delete mode 100755 upgrade diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..38b7644 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +*.plasmoid +*.qmlc +*.jsc +*.mo +/dist +*/.kdev4/* \ No newline at end of file diff --git a/.kdev4/termoid.kdev4 b/.kdev4/termoid.kdev4 deleted file mode 100644 index 1bf8c80..0000000 --- a/.kdev4/termoid.kdev4 +++ /dev/null @@ -1,68 +0,0 @@ -[Buildset] -BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x0e\x00t\x00e\x00r\x00m\x00o\x00i\x00d) - -[CustomBuildSystem] -CurrentConfiguration=BuildConfig0 - -[CustomBuildSystem][BuildConfig0] -BuildDir= -Title=Custom - -[CustomBuildSystem][BuildConfig0][ToolBuild] -Arguments= -Enabled=true -Environment= -Executable=file:./build -Type=0 - -[CustomBuildSystem][BuildConfig0][ToolClean] -Arguments= -Enabled=false -Environment= -Executable= -Type=3 - -[CustomBuildSystem][BuildConfig0][ToolConfigure] -Arguments= -Enabled=false -Environment= -Executable= -Type=1 - -[CustomBuildSystem][BuildConfig0][ToolInstall] -Arguments= -Enabled=true -Environment= -Executable=file:./install -Type=2 - -[CustomBuildSystem][BuildConfig0][ToolPrune] -Arguments= -Enabled=false -Environment= -Executable= -Type=4 - -[Launch] -Launch Configurations=Launch Configuration 0 - -[Launch][Launch Configuration 0] -Configured Launch Modes=execute -Configured Launchers=nativeAppLauncher -Name=Plasmoid -Type=Native Application - -[Launch][Launch Configuration 0][Data] -Arguments= -Dependencies=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x00) -Dependency Action=Install -EnvironmentGroup= -Executable=file:///run/media/koldbyte/Data/Bhaskar_Data/Project/kde-works/plasmoid/termoid/run -External Terminal=konsole --noclose --workdir %workdir -e %exe -Project Target= -Use External Terminal=true -Working Directory=file:///run/media/koldbyte/Data/Bhaskar_Data/Project/kde-works/plasmoid/termoid/ -isExecutable=true - -[Project] -VersionControlSupport=kdevgit diff --git a/package/contents/config/main.xml b/package/contents/config/main.xml index a3c5c0e..13a9729 100644 --- a/package/contents/config/main.xml +++ b/package/contents/config/main.xml @@ -44,6 +44,9 @@ 640 10 - + + + true + diff --git a/package/contents/ui/config/ConfigGeneral.qml b/package/contents/ui/config/ConfigGeneral.qml index 919d084..fc83cb4 100644 --- a/package/contents/ui/config/ConfigGeneral.qml +++ b/package/contents/ui/config/ConfigGeneral.qml @@ -5,7 +5,6 @@ import QtQuick.Dialogs 1.2 import org.kde.plasma.components 2.0 as PlasmaComponents import ".." -// import "../../code/utils.js" as Utils ConfigPage { id: page @@ -16,6 +15,7 @@ ConfigPage { property alias cfg_colorschemeInt: colorscheme.currentIndex property string cfg_colorschemetextString: cbItems.get(colorscheme.currentIndex).text property alias cfg_opacityInt: opacity_spin.value + property alias cfg_showBackgroundBool: show_background_switch.checked width: 500 height: 250 @@ -25,6 +25,7 @@ ConfigPage { cfg_colorschemeInt = plasmoid.configuration.colorscheme; colorscheme.currentIndex = cfg_colorschemeInt; cfg_opacityInt = plasmoid.configuration.opacity; + cfg_showBackgroundBool = plasmoid.configuration.showBackground console.log("ConfigPage loaded"); } @@ -54,6 +55,11 @@ ConfigPage { plasmoid.configuration.opacity = opacity_spin.value; console.log("Opacity Widget Updated " + opacity_spin.value); } + + onCfg_showBackgroundBoolChanged: { + plasmoid.configuration.showBackground = show_background_switch.checked; + console.log("Show Background Updated " + show_background_switch.checked); + } GroupBox { Layout.fillWidth: true @@ -126,6 +132,15 @@ ConfigPage { maximumValue: 100 stepSize: 1 } + + PlasmaComponents.Label { + text: i18n("Show Background") + } + + CheckBox { + id: show_background_switch + checked: plasmoid.configuration.showBackground + } } } } @@ -143,7 +158,7 @@ ConfigPage { Layout.fillWidth: true } - PlasmaComponents.TextField { + TextField { id: command placeholderText: cfg_commandString Layout.fillWidth: true diff --git a/package/contents/ui/main.qml b/package/contents/ui/main.qml index 183bfc1..1609ac4 100644 --- a/package/contents/ui/main.qml +++ b/package/contents/ui/main.qml @@ -23,7 +23,7 @@ import QtQuick.Controls 1.2 import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.plasma.components 2.0 as PlasmaComponentss +import org.kde.plasma.components 2.0 as PlasmaComponents import QMLTermWidget 1.0 @@ -38,9 +38,10 @@ Item{ Layout.minimumWidth: units.gridUnit * 10 Layout.minimumHeight: units.gridUnit * 10 - + Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation - + Plasmoid.backgroundHints: plasmoid.configuration.showBackground ? PlasmaCore.Types.DefaultBackground : PlasmaCore.Types.NoBackground + PlasmaCore.DataSource { id: executeSource engine: "executable" @@ -68,30 +69,73 @@ Item{ QMLTermWidget { id: terminal anchors.fill: parent + font.family: plasmoid.configuration.fontfamily === "" ? "Monospace" : plasmoid.configuration.fontfamily || theme.defaultFont.family font.pointSize: plasmoid.configuration.fontsize === "" ? "12" : plasmoid.configuration.fontsize - colorScheme: plasmoid.configuration.colorschemetext === null ? "Linux" : plasmoid.configuration.colorschemetext + antialiasText:true + colorScheme: plasmoid.configuration.colorschemetext === null ? "Linux" : plasmoid.configuration.colorschemetext opacity: plasmoid.configuration.opacity / 100 + fullCursorHeight: true session: QMLTermSession{ id: mainsession initialWorkingDirectory: "$HOME" + //shellProgram: plasmoid.configuration.command === "" ? "$SHELL" : Utils.prog(plasmoid.configuration.command) + //shellProgramArgs: Utils.arg(plasmoid.configuration.command) || [] } Component.onCompleted: { mainsession.setShellProgram(plasmoid.configuration.command === "" ? "$SHELL" : Utils.prog(plasmoid.configuration.command)); mainsession.setArgs(Utils.arg(plasmoid.configuration.command) || []); - + console.log("Running with session shellProgram: " + JSON.stringify(mainsession)) mainsession.startShellProgram(); + forceActiveFocus(); } - + + // Switch focus properly to terminal to allow text selection + onFocusChanged: + { + mouse_area.enabled = !terminal.focus + } + // Enable keyboard input on mouse click over the plasmoid window MouseArea { + id: mouse_area anchors.fill: parent - - onClicked: { - forceActiveFocus(Qt.MouseFocusReason); + propagateComposedEvents: false + cursorShape: terminal.terminalUsesMouse ? Qt.ArrowCursor : Qt.IBeamCursor + acceptedButtons: Qt.RightButton | Qt.LeftButton + + // Pass on the events to terminal object to enable text selection + onDoubleClicked: + { + var coord = correctDistortion(mouse.x, mouse.y); + terminal.simulateMouseDoubleClick(coord.x, coord.y, mouse.button, mouse.buttons, mouse.modifiers); + } + + onPressed: + { + var coord = correctDistortion(mouse.x, mouse.y); + terminal.simulateMousePress(coord.x, coord.y, mouse.button, mouse.buttons, mouse.modifiers) + } + + onReleased: + { + var coord = correctDistortion(mouse.x, mouse.y); + terminal.simulateMouseRelease(coord.x, coord.y, mouse.button, mouse.buttons, mouse.modifiers); + } + + onPositionChanged: + { + var coord = correctDistortion(mouse.x, mouse.y); + terminal.simulateMouseMove(coord.x, coord.y, mouse.button, mouse.buttons, mouse.modifiers); + } + + onClicked: + { + if(mouse.button === Qt.LeftButton) + terminal.forceActiveFocus() } } @@ -105,5 +149,38 @@ Item{ anchors.fill: parent } } + + // Manage copy and paste + Connections{ + target: copyAction + onTriggered: terminal.copyClipboard(); + } + Connections{ + target: pasteAction + onTriggered: terminal.pasteClipboard() + } + } + + Action{ + id: copyAction + text: qsTr("Copy") + shortcut: "Ctrl+Shift+C" + } + Action{ + id: pasteAction + text: qsTr("Paste") + shortcut: "Ctrl+Shift+V" + } + + function correctDistortion(x, y) + { + x = x / width; + y = y / height; + + var cc = Qt.size(0.5 - x, 0.5 - y); + var distortion = 0; + + return Qt.point((x - cc.width * (1+distortion) * distortion) * terminal.width, + (y - cc.height * (1+distortion) * distortion) * terminal.height) } } diff --git a/package/metadata.desktop b/package/metadata.desktop index 404de58..f6e4b5a 100644 --- a/package/metadata.desktop +++ b/package/metadata.desktop @@ -1,19 +1,19 @@ [Desktop Entry] +Encoding=UTF-8 Name=Termoid Comment=Terminal in a plasmoid - Type=Service Icon=utilities-terminal -X-KDE-ServiceTypes=Plasma/Applet - -X-Plasma-API=declarativeappletscript -X-Plasma-MainScript=ui/main.qml X-KDE-PluginInfo-Author=Bhaskar Divya X-KDE-PluginInfo-Email= X-KDE-PluginInfo-Name=com.koldbyte.kde.termoid -X-KDE-PluginInfo-Version=0.3 +X-KDE-PluginInfo-Version=0.4 X-KDE-PluginInfo-Website=https://github.com/koldbyte/termoid X-KDE-PluginInfo-Category=Utilities X-KDE-PluginInfo-Depends=qtermwidget X-KDE-PluginInfo-License=GPL v2+ +X-KDE-ServiceTypes=Plasma/Applet +X-Plasma-API=declarativeappletscript +X-Plasma-MainScript=ui/main.qml +X-KDE-PluginInfo-KdeStoreId=1169451 \ No newline at end of file diff --git a/termoid-v0.3.plasmoid b/termoid-v0.3.plasmoid deleted file mode 100644 index 1e53eaebfc7aaa214be8a95718fdc2ffae1b8c12..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6170 zcmai&bzGEb7lwzF4hIlv5D5oi=nY^t0(}#&xhKd2p>@omCFd6%Lq4{3kq#ovOxl3{39h*`mYq= z-zbQnEN!eVV1)(A2G0tA3nM~Af&n;(l{Bs;+(iWd)PVp1{qJFtKbf)?ju!W!_N*=r z_CFVVPCp-i3$<3q&~8S6z;E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IT%lJ6F0xfBYM-kYvubWY}~aO z)Eo+fvYK1C+QFQhe+DOlP<8dI%I+4YY!@Vkcs)-*FK^V=)VEWOkVbOdl^DTi5>|qh z1f3+$4u5Q^)RV*?S$uiW&$;`+oK&xlb?W9($5T)A=>2db{gTcx+vw00I8ITx5^6kz zV7ZnL5APF_pX%+%mo+l(N|BGjoiAs?zZ|nqcVTlIqUtK4%kd5}o3meU5r4^iUl&^3 ziUNrR??|ro?ol72n&Y`L2r7K$yKPn8x&KtnP?>?(m}d?)qr5G+FWZ{ zz6%~3!{7fjvX$2RHn%uXNHxW&#CD0hhWdmT>62tt?6-8#9-_xYLZ(9bCmW9xaSzTv z1b{8^^IwDt{@>I?yD;^xT&G{StCrqnoaANPPlFFZJa3f#g?QE8yG)Gu8}ZLnj{yJ1 zio00(KUsYjV8k5*6auO|4*^cK9UF<*p!k?s-v^K}2)=r3NJs}g*9Py7h~!v87A2-7E xa?D*XnGm5O)axz(IUP5k7er!Y2m+{s-Wt&DQ_` diff --git a/termoid.kdev4 b/termoid.kdev4 deleted file mode 100644 index 2c5cd3c..0000000 --- a/termoid.kdev4 +++ /dev/null @@ -1,4 +0,0 @@ -[Project] -CreatedFrom=termoid -Manager=KDevCustomBuildSystem -Name=termoid diff --git a/upgrade b/upgrade deleted file mode 100755 index 49f5971..0000000 --- a/upgrade +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -# Version 1 - -plasmapkg2 -u package