From 311dd6e4e885ff5833756fd9cfa6e8c9c4a8668a Mon Sep 17 00:00:00 2001
From: Adrian Kummerlaender
Date: Sat, 25 Jul 2015 21:53:01 +0200
Subject: Extracted highlighter rectangles into separate component
---
qml/EmbeddedTerminal.qml | 19 +++----------------
qml/Highlighter.qml | 24 ++++++++++++++++++++++++
qml/TerminalItem.qml | 17 +----------------
qml/ui.qrc | 1 +
4 files changed, 29 insertions(+), 32 deletions(-)
create mode 100644 qml/Highlighter.qml
diff --git a/qml/EmbeddedTerminal.qml b/qml/EmbeddedTerminal.qml
index 2e58fa9..aa22328 100644
--- a/qml/EmbeddedTerminal.qml
+++ b/qml/EmbeddedTerminal.qml
@@ -26,25 +26,11 @@ Item {
spacing: 0
- Rectangle {
+ Highlighter {
id: highlighter
width: item.frameWidth
Layout.fillHeight: true
-
- 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" }
}
QMLTermWidget {
@@ -73,7 +59,7 @@ Item {
}
}
- onTermGetFocus: highlighter.focus()
+ onTermGetFocus: highlighter.focus()
onTermLostFocus: highlighter.unfocus()
MouseArea {
@@ -84,6 +70,7 @@ Item {
Component.onCompleted: {
forceActiveFocus();
+ highlighter.select();
session.startShellProgram();
}
}
diff --git a/qml/Highlighter.qml b/qml/Highlighter.qml
new file mode 100644
index 0000000..8d42054
--- /dev/null
+++ b/qml/Highlighter.qml
@@ -0,0 +1,24 @@
+import QtQuick 2.0
+
+Item {
+ function select() { bar.opacity = 1 }
+ function deselect() { bar.opacity = 0 }
+ function focus() { bar.color = "#352F6A" }
+ function unfocus() { bar.color = "#909636" }
+
+ Rectangle {
+ id: bar
+
+ anchors.fill: parent
+
+ opacity: 0
+ color: "#909636"
+
+ Behavior on opacity {
+ NumberAnimation {
+ duration: 300
+ easing.type: Easing.OutCubic
+ }
+ }
+ }
+}
diff --git a/qml/TerminalItem.qml b/qml/TerminalItem.qml
index 26793da..48fb9f7 100644
--- a/qml/TerminalItem.qml
+++ b/qml/TerminalItem.qml
@@ -116,26 +116,11 @@ Item {
right: parent.right
}
- Rectangle {
+ Highlighter {
id: highlighter
width: 10
height: command.height
- opacity: 0
-
- 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" }
}
TextInput {
diff --git a/qml/ui.qrc b/qml/ui.qrc
index 2705e7e..1bc4c62 100644
--- a/qml/ui.qrc
+++ b/qml/ui.qrc
@@ -4,5 +4,6 @@
StateHandler.qml
TerminalItem.qml
EmbeddedTerminal.qml
+ Highlighter.qml
--
cgit v1.2.3