From 2f54bb12eb7f0965ff4861cb0faee5021c355d20 Mon Sep 17 00:00:00 2001 From: marcin Date: Tue, 22 Jul 2014 14:29:20 +0200 Subject: [PATCH] https://trello.com/c/Denq3rax/53-minimize-button-keeps-focused-after-pressed-and-then-restoring-the-window --- components/AddressBookTable.qml | 7 ++++--- components/DashboardTable.qml | 2 +- components/TitleBar.qml | 16 ++++++++++------ main.qml | 6 ++---- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/components/AddressBookTable.qml b/components/AddressBookTable.qml index 81343d4e..354ddfe2 100644 --- a/components/AddressBookTable.qml +++ b/components/AddressBookTable.qml @@ -12,7 +12,10 @@ ListView { height: 64 width: listView.width color: index % 2 ? "#F8F8F8" : "#FFFFFF" - function collapseDropdown() { dropdown.expanded = false } + function collapseDropdown() { + z = 1 + dropdown.expanded = false + } Text { id: descriptionText @@ -95,8 +98,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/DashboardTable.qml b/components/DashboardTable.qml index 0e6d73f0..f5e04deb 100644 --- a/components/DashboardTable.qml +++ b/components/DashboardTable.qml @@ -192,7 +192,7 @@ ListView { anchors.bottomMargin: 11 anchors.rightMargin: 5 dataModel: dropModel - z: 5 + z: 1 onExpandedChanged: { if(expanded) { listView.previousItem = delegate diff --git a/components/TitleBar.qml b/components/TitleBar.qml index e18d1a86..28c6d89c 100644 --- a/components/TitleBar.qml +++ b/components/TitleBar.qml @@ -7,7 +7,7 @@ Rectangle { color: "#000000" y: -height property int mouseX: 0 - property int mouseY: 0 + property bool containsMouse: false property alias maximizeButtonVisible: maximizeButton.visible signal goToBasicVersion(bool yes) @@ -57,7 +57,7 @@ Rectangle { anchors.bottom: parent.bottom Rectangle { - property bool containsMouse: titleBar.mouseX >= x + row.x && titleBar.mouseX <= x + row.x + width + property bool containsMouse: titleBar.mouseX >= x + row.x && titleBar.mouseX <= x + row.x + width && titleBar.containsMouse anchors.top: parent.top anchors.bottom: parent.bottom width: height @@ -78,7 +78,7 @@ Rectangle { } Rectangle { - property bool containsMouse: titleBar.mouseX >= x + row.x && titleBar.mouseX <= x + row.x + width + property bool containsMouse: titleBar.mouseX >= x + row.x && titleBar.mouseX <= x + row.x + width && titleBar.containsMouse anchors.top: parent.top anchors.bottom: parent.bottom width: height @@ -92,13 +92,17 @@ Rectangle { MouseArea { id: minimizeArea anchors.fill: parent - onClicked: appWindow.visibility = Window.Minimized + onClicked: { + appWindow.visibility = Window.Minimized +// parent.containsMouse = Qt.binding(function(){ return titleBar.mouseX >= x + row.x && titleBar.mouseX <= x + row.x + width && +// appWindow.visibility !== Window.Minimized }) + } } } Rectangle { id: maximizeButton - property bool containsMouse: titleBar.mouseX >= x + row.x && titleBar.mouseX <= x + row.x + width + property bool containsMouse: titleBar.mouseX >= x + row.x && titleBar.mouseX <= x + row.x + width && titleBar.containsMouse anchors.top: parent.top anchors.bottom: parent.bottom width: height @@ -122,7 +126,7 @@ Rectangle { } Rectangle { - property bool containsMouse: titleBar.mouseX >= x + row.x && titleBar.mouseX <= x + row.x + width + property bool containsMouse: titleBar.mouseX >= x + row.x && titleBar.mouseX <= x + row.x + width && titleBar.containsMouse anchors.top: parent.top anchors.bottom: parent.bottom width: height diff --git a/main.qml b/main.qml index 5a4bfb43..bae668a6 100644 --- a/main.qml +++ b/main.qml @@ -156,10 +156,8 @@ ApplicationWindow { propagateComposedEvents: true onPressed: mouse.accepted = false onReleased: mouse.accepted = false - onMouseXChanged: { - titleBar.mouseX = mouseX - titleBar.mouseY = mouseY - } + onMouseXChanged: titleBar.mouseX = mouseX + onContainsMouseChanged: titleBar.containsMouse = containsMouse } SequentialAnimation {