From 0e5dbbc1975d0d8f297ac1e2409727f97ab1ae7c Mon Sep 17 00:00:00 2001 From: marcin Date: Tue, 22 Jul 2014 14:16:05 +0200 Subject: [PATCH] https://trello.com/c/l6O8cPIh/57-when-the-sidebar-is-hidden-the-hover-text-on-the-drop-down-buttons-eg-send-to-address-doesn-t-overflow-with-the-window changed window moving behavior --- bitmonero.pro.user | 2 +- components/DashboardTable.qml | 9 ++--- components/HistoryTable.qml | 7 ++-- components/TableDropdown.qml | 65 +++++++++++++++++++++++++++-------- components/TipItem.qml | 57 +++++++++++++++++++----------- main.qml | 31 ++++++++--------- 6 files changed, 112 insertions(+), 59 deletions(-) diff --git a/bitmonero.pro.user b/bitmonero.pro.user index ebf5df96..68b04195 100644 --- a/bitmonero.pro.user +++ b/bitmonero.pro.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/components/DashboardTable.qml b/components/DashboardTable.qml index 7afb6cb1..0e6d73f0 100644 --- a/components/DashboardTable.qml +++ b/components/DashboardTable.qml @@ -12,7 +12,10 @@ ListView { height: 90 width: listView.width color: index % 2 ? "#F8F8F8" : "#FFFFFF" - function collapseDropdown() { dropdown.expanded = false } + function collapseDropdown() { + z = 1 + dropdown.expanded = false + } Row { id: row1 @@ -189,10 +192,8 @@ ListView { anchors.bottomMargin: 11 anchors.rightMargin: 5 dataModel: dropModel - z: 1 + z: 5 onExpandedChanged: { - if(listView.previousItem !== undefined && listView.previousItem !== delegate) - listView.previousItem.collapseDropdown() if(expanded) { listView.previousItem = delegate listView.currentIndex = index diff --git a/components/HistoryTable.qml b/components/HistoryTable.qml index c07b41c2..b3a45116 100644 --- a/components/HistoryTable.qml +++ b/components/HistoryTable.qml @@ -12,7 +12,10 @@ ListView { height: 114 width: listView.width color: index % 2 ? "#F8F8F8" : "#FFFFFF" - function collapseDropdown() { dropdown.expanded = false } + function collapseDropdown() { + z = 1 + dropdown.expanded = false + } Row { id: row1 @@ -221,8 +224,6 @@ ListView { dataModel: dropModel z: 1 onExpandedChanged: { - if(listView.previousItem !== undefined && listView.previousItem !== delegate) - listView.previousItem.collapseDropdown() if(expanded) { listView.previousItem = delegate listView.currentIndex = index diff --git a/components/TableDropdown.qml b/components/TableDropdown.qml index c3152e75..f494fe81 100644 --- a/components/TableDropdown.qml +++ b/components/TableDropdown.qml @@ -86,16 +86,42 @@ Item { } } + Timer { + id: timer + interval: 50 + repeat: false + running: false + onTriggered: { + if(((tipItem.visible && !tipItem.containsMouse) || !tipItem.visible) && !mouseArea.containsMouse) { + tipItem.visible = false + dropdown.expanded = false + currentIndex = -1 + } + } + } + MouseArea { + id: mouseArea anchors.left: head.left anchors.right: head.right anchors.top: head.top height: head.height + dropArea.height hoverEnabled: true onEntered: dropdown.expanded = true - onExited: dropdown.expanded = false + + property int currentIndex: -1 + onMouseYChanged: { + if(mouseY > head.height) { + var posY = parseInt((mouseY - head.height) / 30) + currentIndex = posY + } else { + currentIndex = -1 + } + } + preventStealing: true z: 1 + onExited: timer.start() Item { id: dropArea @@ -120,10 +146,11 @@ Item { id: repeater delegate: Rectangle { id: delegate + property bool containsMouse: index === mouseArea.currentIndex anchors.left: parent.left anchors.right: parent.right height: 30 - color: delegateArea.containsMouse ? "#F0EEEE" : "#DBDBDB" + color: containsMouse ? "#F0EEEE" : "#DBDBDB" //radius: index === repeater.count - 1 ? 5 : 0 Rectangle { @@ -149,27 +176,35 @@ Item { source: icon } - MouseArea { - id: delegateArea - hoverEnabled: true - anchors.fill: parent - propagateComposedEvents: true - onEntered: { + onContainsMouseChanged: { + if(containsMouse) { var pos = rootItem.mapFromItem(delegate, 30, -20) tipItem.text = name - tipItem.x = pos.x + tipItem.x = pos.x + appWindow.x if(tipItem.height > 30) pos.y -= tipItem.height - 30 - tipItem.y = pos.y + tipItem.y = pos.y + appWindow.y tipItem.visible = true - } - onExited: tipItem.visible = false - onClicked: { - dropdown.optionClicked(index) + } else { tipItem.visible = false - dropdown.expanded = false } } + +// MouseArea { +// id: delegateArea +// hoverEnabled: true +// anchors.fill: parent +// propagateComposedEvents: true +// onEntered: { + +// } +// onExited: tipItem.visible = false +// onClicked: { +// dropdown.optionClicked(index) +// tipItem.visible = false +// dropdown.expanded = false +// } +// } } } } diff --git a/components/TipItem.qml b/components/TipItem.qml index f58fd1e6..580bd89f 100644 --- a/components/TipItem.qml +++ b/components/TipItem.qml @@ -1,27 +1,44 @@ -import QtQuick 2.0 +import QtQuick 2.2 +import QtQuick.Window 2.1 -Rectangle { +Window { property alias text: content.text - width: content.width + 12 - height: content.height + 17 - color: "#FF6C3C" - //radius: 3 + property alias containsMouse: tipArea.containsMouse + flags: Qt.ToolTip + color: "transparent" + height: rect.height + tip.height + width: rect.width - Image { - anchors.top: parent.bottom - anchors.left: parent.left - anchors.leftMargin: 5 - source: "../images/tip.png" + MouseArea { + id: tipArea + hoverEnabled: true + anchors.fill: parent } - Text { - id: content - anchors.horizontalCenter: parent.horizontalCenter - y: 6 - lineHeight: 0.7 - font.family: "Arial" - font.pixelSize: 12 - font.letterSpacing: -1 - color: "#FFFFFF" + Rectangle { + id: rect + width: content.width + 12 + height: content.height + 17 + color: "#FF6C3C" + //radius: 3 + + Image { + id: tip + anchors.top: parent.bottom + anchors.left: parent.left + anchors.leftMargin: 5 + source: "../images/tip.png" + } + + Text { + id: content + anchors.horizontalCenter: parent.horizontalCenter + y: 6 + lineHeight: 0.7 + font.family: "Arial" + font.pixelSize: 12 + font.letterSpacing: -1 + color: "#FFFFFF" + } } } diff --git a/main.qml b/main.qml index d72aec30..5a4bfb43 100644 --- a/main.qml +++ b/main.qml @@ -98,21 +98,6 @@ ApplicationWindow { anchors.fill: parent clip: true - MouseArea { - property var previousPosition - anchors.fill: parent - - onPressed: previousPosition = Qt.point(mouseX, mouseY) - onPositionChanged: { - if (pressedButtons == Qt.LeftButton) { - var dx = mouseX - previousPosition.x - var dy = mouseY - previousPosition.y - appWindow.x += dx - appWindow.y += dy - } - } - } - LeftPanel { id: leftPanel anchors.left: parent.left @@ -148,7 +133,6 @@ ApplicationWindow { id: tipItem text: "send to the same destination" visible: false - z: 100 } BasicPanel { @@ -287,6 +271,21 @@ ApplicationWindow { if(yes) goToBasicAnimation.start() else goToProAnimation.start() } + + MouseArea { + property var previousPosition + anchors.fill: parent + propagateComposedEvents: true + onPressed: previousPosition = Qt.point(mouseX, mouseY) + onPositionChanged: { + if (pressedButtons == Qt.LeftButton) { + var dx = mouseX - previousPosition.x + var dy = mouseY - previousPosition.y + appWindow.x += dx + appWindow.y += dy + } + } + } } } }