aboutsummaryrefslogtreecommitdiff
path: root/MetaTerm.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 /MetaTerm.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 'MetaTerm.qml')
-rw-r--r--MetaTerm.qml168
1 files changed, 0 insertions, 168 deletions
diff --git a/MetaTerm.qml b/MetaTerm.qml
deleted file mode 100644
index 9ee41a3..0000000
--- a/MetaTerm.qml
+++ /dev/null
@@ -1,168 +0,0 @@
-import QtQuick 2.0
-import QMLTermWidget 1.0
-import QtQuick.Controls 1.2
-
-
-Rectangle {
- id: root
- anchors.fill: parent
-
- color: "#161616"
-
- Component.onCompleted: terminalList.focusCurrent()
-
- Flickable {
- id: terminalListFlickable
- anchors.fill: parent
-
- boundsBehavior: Flickable.StopAtBounds
- contentHeight: terminalList.height
- contentWidth: terminalList.width
- pixelAligned: true
-
- Column {
- id: terminalList
- spacing: 10
-
- property int activeItem : 0
-
- onHeightChanged: scrollTo(activeItem)
-
- function createItem() {
- var terminalItem = Qt.createComponent("TerminalItem.qml");
- var instantiateTerminal = function() {
- var instance = terminalItem.createObject(terminalList, {
- "width": terminalListFlickable.width
- });
- instance.onExecuted.connect(createItem);
- }
-
- if ( terminalItem.status == Component.Ready ) {
- instantiateTerminal();
- } else {
- terminalItem.statusChanged.connect(instantiateTerminal);
- }
- }
-
- function scrollTo(index) {
- if ( terminalList.height >= terminalListFlickable.height ) {
- var offset = children[index].y
- + (children[index].height / 2)
- - (terminalListFlickable.height / 2);
-
- var bound = terminalList.height
- - terminalListFlickable.height;
-
- if ( offset < 0 ) {
- terminalListFlickable.contentY = 0;
- } else if ( offset >= bound ) {
- terminalListFlickable.contentY = bound;
- } else {
- terminalListFlickable.contentY = offset;
- }
- }
- }
-
- function selectItem(index) {
- children[activeItem].deselect();
- children[index ].select();
-
- activeItem = index;
-
- scrollTo(index);
- }
-
- function selectNext() {
- if ( activeItem < (children.length - 1) ) {
- selectItem(activeItem + 1);
- } else {
- insertTerminalAction.trigger();
- }
- }
-
- function selectPrev() {
- if ( activeItem > 0 ) {
- selectItem(activeItem - 1);
- }
- }
-
- function focusCurrent() {
- children[activeItem].forceActiveFocus();
- }
-
- function unfocusCurrent() {
- children[activeItem].unfocus();
- }
-
- TerminalItem {
- width: terminalListFlickable.width
- onExecuted: terminalList.createItem()
- }
- }
- }
-
- Action {
- id: insertTerminalAction
- shortcut: "i"
- enabled: false
- onTriggered: {
- escapeTerminalAction.enabled = true;
- insertTerminalAction.enabled = false;
- nextTerminalAction.enabled = false;
- prevTerminalAction.enabled = false;
- lastTerminalAction.enabled = false;
- firstTerminalAction.enabled = false;
-
- terminalList.focusCurrent();
- }
- }
-
- Action {
- id: escapeTerminalAction
- shortcut: "Shift+ESC"
- onTriggered: {
- escapeTerminalAction.enabled = false;
- insertTerminalAction.enabled = true;
- nextTerminalAction.enabled = true;
- prevTerminalAction.enabled = true;
- lastTerminalAction.enabled = true;
- firstTerminalAction.enabled = true;
-
- root.forceActiveFocus();
- terminalList.unfocusCurrent();
- }
- }
-
- Action {
- id: nextTerminalAction
- shortcut: "j"
- enabled: false
- onTriggered: terminalList.selectNext()
- }
-
- Action {
- id: prevTerminalAction
- shortcut: "k"
- enabled: false
- onTriggered: terminalList.selectPrev()
- }
-
- Action {
- id: lastTerminalAction
- shortcut: "Shift+G"
- enabled: false
- onTriggered: terminalList.selectItem(terminalList.children.length - 1)
- }
-
- Action {
- id: firstTerminalAction
- shortcut: "g"
- enabled: false
- onTriggered: terminalList.selectItem(0)
- }
-
- ScrollBar {
- flickable: terminalListFlickable
- handleSize: 10
- }
-}