make color selector work
This commit is contained in:
parent
68689147d6
commit
adda897eb9
|
@ -9,6 +9,7 @@ ModalPopup {
|
||||||
title: qsTr("Generate an account")
|
title: qsTr("Generate an account")
|
||||||
|
|
||||||
property int marginBetweenInputs: 38
|
property int marginBetweenInputs: 38
|
||||||
|
property string selectedColor: Constants.accountColors[0]
|
||||||
|
|
||||||
onOpened: {
|
onOpened: {
|
||||||
passwordInput.text = "";
|
passwordInput.text = "";
|
||||||
|
@ -34,8 +35,18 @@ ModalPopup {
|
||||||
id: accountColorInput
|
id: accountColorInput
|
||||||
anchors.top: accountNameInput.bottom
|
anchors.top: accountNameInput.bottom
|
||||||
anchors.topMargin: marginBetweenInputs
|
anchors.topMargin: marginBetweenInputs
|
||||||
|
bgColor: selectedColor
|
||||||
label: qsTr("Account color")
|
label: qsTr("Account color")
|
||||||
isSelect: true
|
selectOptions: Constants.accountColors.map(color => {
|
||||||
|
return {
|
||||||
|
text: "",
|
||||||
|
bgColor: color,
|
||||||
|
height: 52,
|
||||||
|
onClicked: function () {
|
||||||
|
selectedColor = color
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
footer: StyledButton {
|
footer: StyledButton {
|
||||||
|
|
|
@ -9,4 +9,14 @@ QtObject {
|
||||||
|
|
||||||
readonly property int messageType: 1
|
readonly property int messageType: 1
|
||||||
readonly property int stickerType: 2
|
readonly property int stickerType: 2
|
||||||
|
|
||||||
|
readonly property var accountColors: [
|
||||||
|
"#9B832F",
|
||||||
|
"#D37EF4",
|
||||||
|
"#1D806F",
|
||||||
|
"#FA6565",
|
||||||
|
"#7CDA00",
|
||||||
|
"#887af9",
|
||||||
|
"#8B3131"
|
||||||
|
]
|
||||||
}
|
}
|
|
@ -9,10 +9,10 @@ Item {
|
||||||
property string placeholderText: "My placeholder"
|
property string placeholderText: "My placeholder"
|
||||||
property alias text: inputValue.text
|
property alias text: inputValue.text
|
||||||
property string label: ""
|
property string label: ""
|
||||||
|
property color bgColor: Theme.grey
|
||||||
|
|
||||||
// property string label: "My Label"
|
// property string label: "My Label"
|
||||||
// property url icon: "../app/img/hash.svg"
|
// property url icon: "../app/img/hash.svg"
|
||||||
property bool isSelect: false
|
|
||||||
property url icon: ""
|
property url icon: ""
|
||||||
readonly property bool hasIcon: icon.toString() !== ""
|
readonly property bool hasIcon: icon.toString() !== ""
|
||||||
readonly property bool hasLabel: label !== ""
|
readonly property bool hasLabel: label !== ""
|
||||||
|
@ -20,6 +20,8 @@ Item {
|
||||||
inputValue.forceActiveFocus(Qt.MouseFocusReason)
|
inputValue.forceActiveFocus(Qt.MouseFocusReason)
|
||||||
}
|
}
|
||||||
readonly property int labelMargin: 7
|
readonly property int labelMargin: 7
|
||||||
|
property var selectOptions
|
||||||
|
property bool isSelect: !!selectOptions && selectOptions.length > 0
|
||||||
|
|
||||||
id: inputBox
|
id: inputBox
|
||||||
height: inputRectangle.height + (hasLabel ? inputLabel.height + labelMargin : 0)
|
height: inputRectangle.height + (hasLabel ? inputLabel.height + labelMargin : 0)
|
||||||
|
@ -41,7 +43,7 @@ Item {
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: inputRectangle
|
id: inputRectangle
|
||||||
height: 44
|
height: 44
|
||||||
color: Theme.grey
|
color: bgColor
|
||||||
radius: 8
|
radius: 8
|
||||||
anchors.top: inputBox.hasLabel ? inputLabel.bottom : parent.top
|
anchors.top: inputBox.hasLabel ? inputLabel.bottom : parent.top
|
||||||
anchors.topMargin: inputBox.hasLabel ? inputBox.labelMargin : 0
|
anchors.topMargin: inputBox.hasLabel ? inputBox.labelMargin : 0
|
||||||
|
@ -72,46 +74,32 @@ Item {
|
||||||
color: Theme.grey
|
color: Theme.grey
|
||||||
radius: Theme.radius
|
radius: Theme.radius
|
||||||
}
|
}
|
||||||
property var elements: [
|
|
||||||
{
|
|
||||||
text: "Element 1",
|
|
||||||
onTriggered: function () {
|
|
||||||
console.log("Allo 1")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: "Element 2",
|
|
||||||
onTriggered: function () {
|
|
||||||
console.log("Allo 2")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
elements.forEach(element => {
|
if (!selectOptions) {
|
||||||
addItem(menuItem.createObject(selectMenu, element))
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
selectOptions.forEach(function (element) {
|
||||||
|
var item = menuItem.createObject(undefined, element)
|
||||||
|
selectMenu.addItem(item)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: menuItem
|
id: menuItem
|
||||||
MenuItem {
|
MenuItem {
|
||||||
|
property var onClicked: console.log("Default click function. Override me please")
|
||||||
|
property color bgColor: Theme.white
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
|
onTriggered: function () {
|
||||||
|
onClicked()
|
||||||
|
}
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
color: Theme.white
|
color: bgColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MenuItem {
|
|
||||||
// text: "New..."
|
|
||||||
// anchors.right: parent.right
|
|
||||||
// anchors.left: parent.left
|
|
||||||
//// onTriggered: document.reset()
|
|
||||||
// background: Rectangle {
|
|
||||||
// color: Theme.white
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
|
|
Loading…
Reference in New Issue