Merge pull request #2543

bc40942 StandardDropdown: implement automatic closing (xiphon)
This commit is contained in:
luigi1111 2019-12-03 22:32:10 -06:00
commit c2dbda63c6
No known key found for this signature in database
GPG key ID: F4ACA0183641E010

View file

@ -27,6 +27,7 @@
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtGraphicalEffects 1.0
import "../components" as MoneroComponents
@ -42,7 +43,7 @@ Item {
property string releasedColor: MoneroComponents.Style.titleBarButtonHoverColor
property string textColor: MoneroComponents.Style.defaultFontColor
property alias currentIndex: columnid.currentIndex
property bool expanded: false
readonly property alias expanded: popup.visible
property int dropdownHeight: 42
property int fontHeaderSize: 16
property int fontItemSize: 14
@ -56,18 +57,6 @@ Item {
signal changed();
onExpandedChanged: if(expanded) appWindow.currentItem = dropdown
function hide() { dropdown.expanded = false }
function containsPoint(px, py) {
if(px < 0)
return false
if(px > width)
return false
if(py < 0)
return false
if(py > height + droplist.height)
return false
return true
}
// Workaroud for suspected memory leak in 5.8 causing malloc crash on app exit
function update() {
@ -128,17 +117,21 @@ Item {
MouseArea {
id: dropArea
anchors.fill: parent
onClicked: dropdown.expanded = !dropdown.expanded
onClicked: dropdown.expanded ? popup.close() : popup.open()
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
}
}
Popup {
id: popup
padding: 0
Rectangle {
id: droplist
anchors.left: parent.left
anchors.right: parent.right
anchors.top: head.bottom
x: dropdown.x
width: dropdown.width
y: head.y + head.height
clip: true
height: dropdown.expanded ? columnid.height : 0
color: dropdown.pressedColor
@ -172,16 +165,11 @@ Item {
id: repeater
// Workaround for translations in listElements. All translated strings needs to be listed in this file.
property string stringLow: qsTr("Low (x1 fee)") + translationManager.emptyString
property string stringMedium: qsTr("Medium (x20 fee)") + translationManager.emptyString
property string stringHigh: qsTr("High (x166 fee)") + translationManager.emptyString
property string stringSlow: qsTr("Slow (x0.25 fee)") + translationManager.emptyString
property string stringDefault: qsTr("Default (x1 fee)") + translationManager.emptyString
property string stringAutomatic: qsTr("Automatic") + translationManager.emptyString
property string stringSlow: qsTr("Slow (x0.2 fee)") + translationManager.emptyString
property string stringNormal: qsTr("Normal (x1 fee)") + translationManager.emptyString
property string stringFast: qsTr("Fast (x5 fee)") + translationManager.emptyString
property string stringFastest: qsTr("Fastest (x41.5 fee)") + translationManager.emptyString
property string stringAll: qsTr("All") + translationManager.emptyString
property string stringSent: qsTr("Sent") + translationManager.emptyString
property string stringReceived: qsTr("Received") + translationManager.emptyString
property string stringFastest: qsTr("Fastest (x200 fee)") + translationManager.emptyString
delegate: Rectangle {
anchors.left: parent.left
@ -236,7 +224,7 @@ Item {
cursorShape: Qt.PointingHandCursor
onClicked: {
dropdown.expanded = false
popup.close()
columnid.currentIndex = index
changed();
dropdown.update()
@ -246,4 +234,5 @@ Item {
}
}
}
}
}