Skip to content

Commit

Permalink
Merge pull request #3339 from MerginMaps/rework-combobox
Browse files Browse the repository at this point in the history
Rework MMComboboxInput
  • Loading branch information
tomasMizera authored Apr 18, 2024
2 parents d6efc81 + 54624d9 commit be2b6be
Showing 1 changed file with 12 additions and 23 deletions.
35 changes: 12 additions & 23 deletions app/qml/inputs/MMComboboxInput.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
import QtQuick

import "../components" as MMComponents
import "../components/private" as MMPrivateComponents

/*
* Common text input to use in the app.
* Disabled state can be achieved by setting `enabled: false`.
*
* See MMBaseInput for more properties.
* See MMBaseSingleLineInput for more properties.
*/

MMBaseInput {
MMPrivateComponents.MMBaseSingleLineInput {
id: root

property alias loader: drawerLoader
Expand All @@ -30,34 +31,22 @@ MMBaseInput {
property string textRole: "text"
property string valueRole: "value"

onRightActionClicked: { drawerLoader.active = true; drawerLoader.focus = true }
onContentClicked: { drawerLoader.active = true; drawerLoader.focus = true }
onTextClicked: { drawerLoader.active = true; drawerLoader.focus = true }
onRightContentClicked: { drawerLoader.active = true; drawerLoader.focus = true }

content: MMComponents.MMText {
id: textField
text: {
if ( !comboboxModel ) return "";
if ( currentIndex < 0 || currentIndex >= comboboxModel.count ) return "";

anchors.fill: parent

font: __style.p5

color: root.enabled ? __style.nightColor : __style.mediumGreenColor

text: {
if ( !comboboxModel ) return "";
if ( currentIndex < 0 || currentIndex >= comboboxModel.count ) return "";

return comboboxModel.get( currentIndex )[textRole]
}
return comboboxModel.get( currentIndex )[textRole]
}

rightAction: MMComponents.MMIcon {
rightContent: MMComponents.MMIcon {
property bool pressed: false

anchors.verticalCenter: parent.verticalCenter

size: __style.icon24
source: __style.arrowDownIcon
color: root.enabled ? __style.forestColor : __style.mediumGreenColor
source: drawerLoader.active ? __style.arrowUpIcon : __style.arrowDownIcon
color: root.editState === "enabled" ? __style.forestColor : __style.mediumGreenColor
}

Loader {
Expand Down

0 comments on commit be2b6be

Please sign in to comment.