Use Duration in SaveButton and SidebarSimple

This commit is contained in:
Arjen Hiemstra 2015-04-22 13:42:29 +02:00
parent 77af94527f
commit c28e3600b2
2 changed files with 12 additions and 35 deletions

View file

@ -20,7 +20,7 @@ Button {
property bool defaultAmbiguous: false; property bool defaultAmbiguous: false;
property variant printDuration: PrintInformation.currentPrintTime; property variant printDuration: PrintInformation.currentPrintTime;
property real printMaterialAmount: PrintInformation.materialAmount < 0 ? -1 : PrintInformation.materialAmount; property real printMaterialAmount: PrintInformation.materialAmount;
iconSource: UM.Theme.icons[Printer.outputDevices[base.currentDevice].icon]; iconSource: UM.Theme.icons[Printer.outputDevices[base.currentDevice].icon];
tooltip: Printer.outputDevices[base.currentDevice].description; tooltip: Printer.outputDevices[base.currentDevice].description;
@ -136,33 +136,7 @@ Button {
color: UM.Theme.colors.save_button_text; color: UM.Theme.colors.save_button_text;
font: UM.Theme.fonts.default; font: UM.Theme.fonts.default;
text: { text: (!control.printDuration || !control.printDuration.valid) ? "" : control.printDuration.getDisplayString(UM.DurationFormat.Long)
if(!control.printDuration)
{
return "";
}
var days = ""
var day_count = control.printDuration.getDate() - 1;
if(day_count > 0)
{
days = Qt.formatDateTime(control.printDuration, qsTr("d 'day(s)'", "", day_count));
}
var hours = ""
if(control.printDuration.getHours() > 0)
{
hours = Qt.formatDateTime(control.printDuration, qsTr("h 'hour(s)'", "", control.printDuration.getHours()));
}
var minutes = ""
if(control.printDuration.getMinutes() > 0)
{
minutes = Qt.formatDateTime(control.printDuration, qsTr("m 'minute(s)'", "", control.printDuration.getMinutes()));
}
return [days, hours, minutes].join(" ");
}
} }
Label { Label {
anchors.left: parent.left; anchors.left: parent.left;
@ -171,7 +145,7 @@ Button {
color: UM.Theme.colors.save_button_text; color: UM.Theme.colors.save_button_text;
font: UM.Theme.fonts.default; font: UM.Theme.fonts.default;
text: control.printMaterialAmount < 0 ? "" : "%1m material".arg(control.printMaterialAmount); text: control.printMaterialAmount < 0 ? "" : qsTr("%1m material").arg(control.printMaterialAmount);
} }
} }
} }

View file

@ -27,7 +27,7 @@ Item {
Label { Label {
anchors.left: parent.left; anchors.left: parent.left;
anchors.verticalCenter: parent.verticalCenter; anchors.verticalCenter: parent.verticalCenter;
text:Qt.formatTime(base.minimumPrintTime, "hh:mm"); text: base.minimumPrintTime.valid ? base.minimumPrintTime.getDisplayString(UM.DurationFormat.Short) : "??:??";
font: UM.Theme.fonts.timeslider_time; font: UM.Theme.fonts.timeslider_time;
color: UM.Theme.colors.primary; color: UM.Theme.colors.primary;
} }
@ -38,7 +38,7 @@ Item {
{ {
return qsTr("No Model Loaded"); return qsTr("No Model Loaded");
} }
else if (base.minimumPrintTime == null || base.maximumPrintTime == null) else if (!base.minimumPrintTime.valid || !base.maximumPrintTime.valid)
{ {
return qsTr("Calculating...") return qsTr("Calculating...")
} }
@ -53,7 +53,7 @@ Item {
Label { Label {
anchors.right: parent.right; anchors.right: parent.right;
anchors.verticalCenter: parent.verticalCenter; anchors.verticalCenter: parent.verticalCenter;
text: Qt.formatTime(base.maximumPrintTime, "hh:mm"); text: base.maximumPrintTime.valid ? base.maximumPrintTime.getDisplayString(UM.DurationFormat.Short) : "??:??";
font: UM.Theme.fonts.timeslider_time; font: UM.Theme.fonts.timeslider_time;
color: UM.Theme.colors.primary; color: UM.Theme.colors.primary;
} }
@ -79,7 +79,7 @@ Item {
Label { Label {
anchors.left: parent.left; anchors.left: parent.left;
anchors.verticalCenter: parent.verticalCenter; anchors.verticalCenter: parent.verticalCenter;
text: "Minimum\nDraft"; text: qsTr("Minimum\nDraft");
color: UM.Theme.colors.text; color: UM.Theme.colors.text;
font: UM.Theme.fonts.default; font: UM.Theme.fonts.default;
} }
@ -87,7 +87,7 @@ Item {
Label { Label {
anchors.right: parent.right; anchors.right: parent.right;
anchors.verticalCenter: parent.verticalCenter; anchors.verticalCenter: parent.verticalCenter;
text: "Maximum\nQuality"; text: qsTr("Maximum\nQuality");
horizontalAlignment: Text.AlignRight; horizontalAlignment: Text.AlignRight;
color: UM.Theme.colors.text; color: UM.Theme.colors.text;
font: UM.Theme.fonts.default; font: UM.Theme.fonts.default;
@ -98,9 +98,12 @@ Item {
Layout.fillWidth: true; Layout.fillWidth: true;
Layout.preferredHeight: UM.Theme.sizes.section.height; Layout.preferredHeight: UM.Theme.sizes.section.height;
text: "Enable Support"; text: qsTr("Enable Support");
style: UM.Theme.styles.checkbox; style: UM.Theme.styles.checkbox;
checked: Printer.getSettingValue('support_enable');
onCheckedChanged: Printer.setSettingValue('support_enable', checked);
} }
Item { Layout.fillWidth: true; Layout.fillHeight: true; } Item { Layout.fillWidth: true; Layout.fillHeight: true; }