2021-07-11 15:27:03 +03:00
|
|
|
import QtQuick 2.6
|
2019-12-01 22:27:00 +03:00
|
|
|
import Sailfish.Silica 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 {
|
2021-03-21 16:01:19 +03:00
|
|
|
property var choices: parent.getChoices(name)
|
2021-06-21 22:31:36 +03:00
|
|
|
property var preferred_choices: []
|
|
|
|
property string preferred_choice_suffix: ""
|
2020-06-04 22:31:46 +03:00
|
|
|
|
2023-01-29 15:47:43 +03:00
|
|
|
property var actual_choices: Utils.fixupChoices(name, choices, parent.selectedFileType, parent.printer)
|
2019-12-01 22:27:00 +03:00
|
|
|
|
2020-06-07 12:06:14 +03:00
|
|
|
property int num_large_choices: 8
|
|
|
|
|
2022-01-15 00:14:06 +03:00
|
|
|
displayValue: Utils.ippName(name, choice != undefined ? choice : default_choice, strings)
|
2019-12-01 22:27:00 +03:00
|
|
|
|
2020-06-07 12:06:14 +03:00
|
|
|
onClicked: {
|
2022-05-02 22:30:02 +03:00
|
|
|
if(hasMenu)
|
|
|
|
{
|
|
|
|
menu.open(this)
|
|
|
|
}
|
|
|
|
else if(actual_choices.length != 0)
|
2020-06-07 12:06:14 +03:00
|
|
|
{
|
|
|
|
var dialog = pageStack.push("LargeChoiceDialog.qml",
|
2021-07-31 13:18:41 +03:00
|
|
|
{name:name, choice: choice != undefined ? choice : default_choice, choices: actual_choices,
|
2022-01-15 00:14:06 +03:00
|
|
|
preferred_choices: preferred_choices, preferred_choice_suffix: preferred_choice_suffix,
|
|
|
|
strings: strings})
|
2020-06-07 12:06:14 +03:00
|
|
|
dialog.accepted.connect(function() {
|
|
|
|
choice = dialog.choice
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-23 22:29:59 +03:00
|
|
|
menu: ContextMenu {
|
2019-12-01 22:27:00 +03:00
|
|
|
Repeater {
|
2021-07-31 13:18:41 +03:00
|
|
|
model: actual_choices.length>num_large_choices ? 0 : actual_choices
|
2019-12-01 22:27:00 +03:00
|
|
|
MenuItem {
|
2022-01-15 00:14:06 +03:00
|
|
|
text: Utils.ippName(name, actual_choices[index], strings)
|
2021-07-31 13:18:41 +03:00
|
|
|
+ (Utils.has(preferred_choices, actual_choices[index]) ? " "+preferred_choice_suffix : "")
|
2019-12-01 22:27:00 +03:00
|
|
|
onClicked:
|
|
|
|
{
|
2021-07-31 13:18:41 +03:00
|
|
|
choice = actual_choices[index];
|
2019-12-01 22:27:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-05-02 22:30:02 +03:00
|
|
|
hasMenu: actual_choices.length != 0 && (actual_choices.length <= num_large_choices)
|
2019-12-01 22:27:00 +03:00
|
|
|
}
|