harbour-seaprint/qml/components/ChoiceSetting.qml

51 lines
1.4 KiB
QML
Raw Normal View History

2019-12-01 22:27:00 +03:00
import QtQuick 2.0
import Sailfish.Silica 1.0
import seaprint.convertchecker 1.0
2020-01-03 15:37:51 +03:00
import "../pages/utils.js" as Utils
2019-12-01 22:27:00 +03:00
Setting {
property var choices
2020-06-04 22:31:46 +03:00
property string mime_type
property var limited_choices: Utils.limitChoices(name, choices, mime_type, ConvertChecker)
2019-12-01 22:27:00 +03:00
property int num_large_choices: 8
2019-12-01 22:27:00 +03:00
ValueButton {
enabled: valid
anchors.verticalCenter: parent.verticalCenter
label: prettyName
2020-01-03 15:37:51 +03:00
value: Utils.ippName(name, choice ? choice : default_choice)
2019-12-01 22:27:00 +03:00
onClicked: parent.clicked()
}
onClicked: {
if(limited_choices.length>num_large_choices)
{
var dialog = pageStack.push("LargeChoiceDialog.qml",
{name:name, choice: choice ? choice : default_choice, choices: limited_choices})
dialog.accepted.connect(function() {
choice = dialog.choice
})
}
}
2019-12-01 22:27:00 +03:00
property var menu: ContextMenu {
id: menu
enabled: valid && limited_choices.length <= num_large_choices
2019-12-01 22:27:00 +03:00
Repeater {
2020-06-04 22:31:46 +03:00
model: limited_choices
2019-12-01 22:27:00 +03:00
MenuItem {
2020-06-04 22:31:46 +03:00
text: Utils.ippName(name, limited_choices[index])
2019-12-01 22:27:00 +03:00
onClicked:
{
2020-06-04 22:31:46 +03:00
choice = limited_choices[index];
2019-12-01 22:27:00 +03:00
}
}
}
}
}