aboutsummaryrefslogtreecommitdiff
path: root/qml/EmbeddedTerminal.qml
diff options
context:
space:
mode:
authorAdrian Kummerlaender2015-07-05 15:11:13 +0200
committerAdrian Kummerlaender2015-07-05 15:14:00 +0200
commit78966dc00419a4f5fe5fec4725062a4a0f380228 (patch)
treeb57fd0ac94d385f72c8cfffa0f034a27459fb93e /qml/EmbeddedTerminal.qml
parent77220db5d2ef2eee22f8456527f2ae66ea457685 (diff)
downloadMetaTerm-78966dc00419a4f5fe5fec4725062a4a0f380228.tar
MetaTerm-78966dc00419a4f5fe5fec4725062a4a0f380228.tar.gz
MetaTerm-78966dc00419a4f5fe5fec4725062a4a0f380228.tar.bz2
MetaTerm-78966dc00419a4f5fe5fec4725062a4a0f380228.tar.lz
MetaTerm-78966dc00419a4f5fe5fec4725062a4a0f380228.tar.xz
MetaTerm-78966dc00419a4f5fe5fec4725062a4a0f380228.tar.zst
MetaTerm-78966dc00419a4f5fe5fec4725062a4a0f380228.zip
Embedded QML into C++ application
Diffstat (limited to 'qml/EmbeddedTerminal.qml')
-rw-r--r--qml/EmbeddedTerminal.qml88
1 files changed, 88 insertions, 0 deletions
diff --git a/qml/EmbeddedTerminal.qml b/qml/EmbeddedTerminal.qml
new file mode 100644
index 0000000..f4f104e
--- /dev/null
+++ b/qml/EmbeddedTerminal.qml
@@ -0,0 +1,88 @@
+import QtQuick 2.0
+import QMLTermWidget 1.0
+import QtQuick.Controls 1.2
+
+Item {
+ id: embeddedTerminal
+ property string program
+ property string workingDirectory
+ property int columns
+ property int lines
+
+ width: container.width
+ height: container.height
+
+ function select() { highlighter.select() }
+ function deselect() { highlighter.deselect() }
+
+ Row {
+ id: container
+
+ Rectangle {
+ id: highlighter
+
+ width: 10
+ height: terminal.height
+
+ color: "#909636"
+
+ Behavior on opacity {
+ NumberAnimation {
+ duration: 300
+ easing.type: Easing.OutCubic
+ }
+ }
+
+ function select() { opacity = 1 }
+ function deselect() { opacity = 0 }
+ function focus() { color = "#352F6A" }
+ function unfocus() { color = "#909636" }
+ }
+
+ Rectangle {
+ width: terminal.width
+ height: terminal.height
+
+ color: "#ffffff"
+
+ QMLTermWidget {
+ id: terminal
+
+ font.family: "Monospace"
+ font.pointSize: 8
+
+ width: fontMetrics.width * embeddedTerminal.columns
+ height: fontMetrics.height * embeddedTerminal.lines
+
+ session: QMLTermSession {
+ initialWorkingDirectory: embeddedTerminal.workingDirectory
+
+ shellProgram: {
+ return (embeddedTerminal.program).split(" ")[0];
+ }
+
+ shellProgramArgs: {
+ var elements = (embeddedTerminal.program).split(" ");
+ elements.shift();
+
+ return elements;
+ }
+ }
+
+ onTermGetFocus: highlighter.focus()
+ onTermLostFocus: highlighter.unfocus()
+
+ MouseArea {
+ anchors.fill: parent
+ acceptedButtons: Qt.NoButton
+ onWheel: { }
+ }
+
+ Component.onCompleted: {
+ terminal.forceActiveFocus();
+ session.startShellProgram();
+ }
+ }
+ }
+ }
+}