Convert PrintSetupSelector to an ExpandableComponent

CURA-5785
This commit is contained in:
Jaime van Kessel 2018-11-12 11:14:39 +01:00
parent e641584021
commit b60977e435
2 changed files with 125 additions and 157 deletions

View File

@ -66,6 +66,7 @@ Item
Cura.PrintSetupSelector Cura.PrintSetupSelector
{ {
width: UM.Theme.getSize("print_setup_widget").width width: UM.Theme.getSize("print_setup_widget").width
height: prepareMenu.height
onShowTooltip: prepareMenu.showTooltip(item, location, text) onShowTooltip: prepareMenu.showTooltip(item, location, text)
onHideTooltip: prepareMenu.hideTooltip() onHideTooltip: prepareMenu.hideTooltip()
} }

View File

@ -10,22 +10,14 @@ import Cura 1.0 as Cura
import "Menus" import "Menus"
import "Menus/ConfigurationMenu" import "Menus/ConfigurationMenu"
Rectangle Cura.ExpandableComponent
{ {
id: base id: base
height: childrenRect.height height: childrenRect.height
property int currentModeIndex: -1 property int currentModeIndex: -1
property bool hideSettings: PrintInformation.preSliced property bool hideSettings: PrintInformation.preSliced
property variant printDuration: PrintInformation.currentPrintTime
property variant printMaterialLengths: PrintInformation.materialLengths
property variant printMaterialWeights: PrintInformation.materialWeights
property variant printMaterialCosts: PrintInformation.materialCosts
property variant printMaterialNames: PrintInformation.materialNames
color: UM.Theme.getColor("main_background")
UM.I18nCatalog { id: catalog; name: "cura"} UM.I18nCatalog { id: catalog; name: "cura"}
// This widget doesn't show tooltips by itself. Instead it emits signals so others can do something with it. // This widget doesn't show tooltips by itself. Instead it emits signals so others can do something with it.
@ -46,40 +38,12 @@ Rectangle
} }
} }
function strPadLeft(string, pad, length)
{
return (new Array(length + 1).join(pad) + string).slice(-length);
}
function getPrettyTime(time)
{
var hours = Math.floor(time / 3600)
time -= hours * 3600
var minutes = Math.floor(time / 60);
time -= minutes * 60
var seconds = Math.floor(time);
var finalTime = strPadLeft(hours, "0", 2) + ":" + strPadLeft(minutes, "0", 2) + ":" + strPadLeft(seconds, "0", 2);
return finalTime;
}
MouseArea
{
anchors.fill: parent
acceptedButtons: Qt.AllButtons
onWheel:
{
wheel.accepted = true;
}
}
onCurrentModeIndexChanged: onCurrentModeIndexChanged:
{ {
UM.Preferences.setValue("cura/active_mode", currentModeIndex); UM.Preferences.setValue("cura/active_mode", currentModeIndex);
} }
Label headerItem: Label
{ {
id: settingsModeLabel id: settingsModeLabel
text: !hideSettings ? catalog.i18nc("@label:listbox", "Print Setup") : catalog.i18nc("@label:listbox", "Print Setup disabled\nG-code files cannot be modified") text: !hideSettings ? catalog.i18nc("@label:listbox", "Print Setup") : catalog.i18nc("@label:listbox", "Print Setup disabled\nG-code files cannot be modified")
@ -98,7 +62,10 @@ Rectangle
color: UM.Theme.getColor("text") color: UM.Theme.getColor("text")
} }
popupItem: Item
{
height: settingsModeSelection.height + sidebarContents.height
width: UM.Theme.getSize("print_setup_widget").width
ListView ListView
{ {
// Settings mode selection toggle // Settings mode selection toggle
@ -110,7 +77,6 @@ Rectangle
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: UM.Theme.getSize("thick_margin").width anchors.rightMargin: UM.Theme.getSize("thick_margin").width
anchors.top: settingsModeLabel.top
ButtonGroup ButtonGroup
{ {
@ -241,3 +207,4 @@ Rectangle
} }
} }
} }
}