mirror of
https://github.com/monero-project/monero-gui.git
synced 2025-01-22 10:44:46 +00:00
Merge pull request #2543
bc40942
StandardDropdown: implement automatic closing (xiphon)
This commit is contained in:
commit
c2dbda63c6
1 changed files with 93 additions and 104 deletions
|
@ -27,6 +27,7 @@
|
||||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
import QtQuick 2.9
|
import QtQuick 2.9
|
||||||
|
import QtQuick.Controls 2.2
|
||||||
import QtGraphicalEffects 1.0
|
import QtGraphicalEffects 1.0
|
||||||
|
|
||||||
import "../components" as MoneroComponents
|
import "../components" as MoneroComponents
|
||||||
|
@ -42,7 +43,7 @@ Item {
|
||||||
property string releasedColor: MoneroComponents.Style.titleBarButtonHoverColor
|
property string releasedColor: MoneroComponents.Style.titleBarButtonHoverColor
|
||||||
property string textColor: MoneroComponents.Style.defaultFontColor
|
property string textColor: MoneroComponents.Style.defaultFontColor
|
||||||
property alias currentIndex: columnid.currentIndex
|
property alias currentIndex: columnid.currentIndex
|
||||||
property bool expanded: false
|
readonly property alias expanded: popup.visible
|
||||||
property int dropdownHeight: 42
|
property int dropdownHeight: 42
|
||||||
property int fontHeaderSize: 16
|
property int fontHeaderSize: 16
|
||||||
property int fontItemSize: 14
|
property int fontItemSize: 14
|
||||||
|
@ -56,18 +57,6 @@ Item {
|
||||||
signal changed();
|
signal changed();
|
||||||
|
|
||||||
onExpandedChanged: if(expanded) appWindow.currentItem = dropdown
|
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
|
// Workaroud for suspected memory leak in 5.8 causing malloc crash on app exit
|
||||||
function update() {
|
function update() {
|
||||||
|
@ -128,17 +117,21 @@ Item {
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: dropArea
|
id: dropArea
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: dropdown.expanded = !dropdown.expanded
|
onClicked: dropdown.expanded ? popup.close() : popup.open()
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Popup {
|
||||||
|
id: popup
|
||||||
|
padding: 0
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: droplist
|
id: droplist
|
||||||
anchors.left: parent.left
|
x: dropdown.x
|
||||||
anchors.right: parent.right
|
width: dropdown.width
|
||||||
anchors.top: head.bottom
|
y: head.y + head.height
|
||||||
clip: true
|
clip: true
|
||||||
height: dropdown.expanded ? columnid.height : 0
|
height: dropdown.expanded ? columnid.height : 0
|
||||||
color: dropdown.pressedColor
|
color: dropdown.pressedColor
|
||||||
|
@ -172,16 +165,11 @@ Item {
|
||||||
id: repeater
|
id: repeater
|
||||||
|
|
||||||
// Workaround for translations in listElements. All translated strings needs to be listed in this file.
|
// 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 stringAutomatic: qsTr("Automatic") + translationManager.emptyString
|
||||||
property string stringMedium: qsTr("Medium (x20 fee)") + translationManager.emptyString
|
property string stringSlow: qsTr("Slow (x0.2 fee)") + translationManager.emptyString
|
||||||
property string stringHigh: qsTr("High (x166 fee)") + translationManager.emptyString
|
property string stringNormal: qsTr("Normal (x1 fee)") + translationManager.emptyString
|
||||||
property string stringSlow: qsTr("Slow (x0.25 fee)") + translationManager.emptyString
|
|
||||||
property string stringDefault: qsTr("Default (x1 fee)") + translationManager.emptyString
|
|
||||||
property string stringFast: qsTr("Fast (x5 fee)") + translationManager.emptyString
|
property string stringFast: qsTr("Fast (x5 fee)") + translationManager.emptyString
|
||||||
property string stringFastest: qsTr("Fastest (x41.5 fee)") + translationManager.emptyString
|
property string stringFastest: qsTr("Fastest (x200 fee)") + translationManager.emptyString
|
||||||
property string stringAll: qsTr("All") + translationManager.emptyString
|
|
||||||
property string stringSent: qsTr("Sent") + translationManager.emptyString
|
|
||||||
property string stringReceived: qsTr("Received") + translationManager.emptyString
|
|
||||||
|
|
||||||
delegate: Rectangle {
|
delegate: Rectangle {
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
|
@ -236,7 +224,7 @@ Item {
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
dropdown.expanded = false
|
popup.close()
|
||||||
columnid.currentIndex = index
|
columnid.currentIndex = index
|
||||||
changed();
|
changed();
|
||||||
dropdown.update()
|
dropdown.update()
|
||||||
|
@ -247,3 +235,4 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue