harbour-seaprint/qml/components/ChoiceSetting.qml

71 lines
1.7 KiB
QML
Raw Normal View History

2019-12-01 22:27:00 +03:00
import QtQuick 2.0
import Sailfish.Silica 1.0
Setting {
property var choices
function prettifyChoice(name, value)
{
switch(name) {
case "print-quality":
switch(value) {
case 3:
2019-12-07 12:36:36 +03:00
return qsTr("draft");
2019-12-01 22:27:00 +03:00
case 4:
2019-12-07 12:36:36 +03:00
return qsTr("normal");
2019-12-01 22:27:00 +03:00
case 5:
2019-12-07 12:36:36 +03:00
return qsTr("high");
2019-12-01 22:27:00 +03:00
default:
2019-12-07 12:36:36 +03:00
return qsTr("unknown quality ")+value
2019-12-01 22:27:00 +03:00
}
case "orientation-requested":
switch(value) {
case 3:
2019-12-07 12:36:36 +03:00
return qsTr("portrait");
2019-12-01 22:27:00 +03:00
case 4:
2019-12-07 12:36:36 +03:00
return qsTr("landscape");
2019-12-01 22:27:00 +03:00
case 5:
2019-12-07 12:36:36 +03:00
return qsTr("reverse landscape");
2019-12-01 22:27:00 +03:00
case 6:
2019-12-07 12:36:36 +03:00
return qsTr("reverse portrait");
2019-12-01 22:27:00 +03:00
default:
2019-12-07 12:36:36 +03:00
return qsTr("unknown orientation ")+value
2019-12-01 22:27:00 +03:00
}
case "printer-resolution":
var units = "";
if(value.units==3) {
2019-12-07 12:36:36 +03:00
units=qsTr("dpi");
2019-12-01 22:27:00 +03:00
} else if (units==4){
2019-12-07 12:36:36 +03:00
units=qsTr("dots/cm")
2019-12-01 22:27:00 +03:00
}
return ""+value.x+"x"+value.y+units;
}
return value;
}
ValueButton {
enabled: valid
anchors.verticalCenter: parent.verticalCenter
label: prettyName
value: prettifyChoice(name, choice ? choice : default_choice)
onClicked: parent.clicked()
}
property var menu: ContextMenu {
id: menu
Repeater {
model: choices
MenuItem {
text: prettifyChoice(name, choices[index])
onClicked:
{
choice = choices[index];
}
}
}
}
}