123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- import QtQuick 2.7
- import QtQuick.Controls 2.4
- import QtQuick.Layouts 1.3
- import UM 1.5 as UM
- import Cura 1.0 as Cura
- Column
- {
- id: widget
- spacing: UM.Theme.getSize("thin_margin").height
- UM.I18nCatalog
- {
- id: catalog
- name: "cura"
- }
- property real progress: UM.Backend.progress
- property int backendState: UM.Backend.state
-
-
- property bool waitingForSliceToStart: false
- onBackendStateChanged: waitingForSliceToStart = false
- function sliceOrStopSlicing()
- {
- if (widget.backendState == UM.Backend.NotStarted)
- {
- widget.waitingForSliceToStart = true
- CuraApplication.backend.forceSlice()
- }
- else
- {
- widget.waitingForSliceToStart = false
- CuraApplication.backend.stopSlicing()
- }
- }
- UM.Label
- {
- id: autoSlicingLabel
- width: parent.width
- visible: progressBar.visible
- text: catalog.i18nc("@label:PrintjobStatus", "Slicing...")
- }
- Item
- {
- id: unableToSliceMessage
- width: parent.width
- visible: widget.backendState == UM.Backend.Error
- height: warningIcon.height
- UM.StatusIcon
- {
- id: warningIcon
- anchors.verticalCenter: parent.verticalCenter
- width: visible ? UM.Theme.getSize("section_icon").width : 0
- height: width
- status: UM.StatusIcon.Status.WARNING
- }
- UM.Label
- {
- id: label
- anchors.left: warningIcon.right
- anchors.right: parent.right
- anchors.verticalCenter: parent.verticalCenter
- anchors.leftMargin: UM.Theme.getSize("default_margin").width
- text: catalog.i18nc("@label:PrintjobStatus", "Unable to slice")
- wrapMode: Text.WordWrap
- }
- }
-
- UM.ProgressBar
- {
- id: progressBar
- width: parent.width
- height: UM.Theme.getSize("progressbar").height
- value: progress
- indeterminate: widget.backendState == UM.Backend.NotStarted
- visible: (widget.backendState == UM.Backend.Processing || (prepareButtons.autoSlice && widget.backendState == UM.Backend.NotStarted))
- }
- Item
- {
- id: prepareButtons
-
- property bool autoSlice: UM.Preferences.getValue("general/auto_slice")
-
- width: parent.width
- height: UM.Theme.getSize("action_button").height
- visible: !autoSlice
- Cura.PrimaryButton
- {
- id: sliceButton
- fixedWidthMode: true
- height: parent.height
- anchors.right: parent.right
- anchors.left: parent.left
- text: widget.waitingForSliceToStart ? catalog.i18nc("@button", "Processing"): catalog.i18nc("@button", "Slice")
- tooltip: catalog.i18nc("@label", "Start the slicing process")
- hoverEnabled: !widget.waitingForSliceToStart
- enabled: widget.backendState != UM.Backend.Error && !widget.waitingForSliceToStart
- visible: widget.backendState == UM.Backend.NotStarted || widget.backendState == UM.Backend.Error
- onClicked: {
- sliceOrStopSlicing()
- }
- }
- Cura.SecondaryButton
- {
- id: cancelButton
- fixedWidthMode: true
- height: parent.height
- anchors.left: parent.left
- anchors.right: parent.right
- text: catalog.i18nc("@button", "Cancel")
- enabled: sliceButton.enabled
- visible: !sliceButton.visible
- onClicked: {
- sliceOrStopSlicing()
- }
- }
- }
-
- Connections
- {
- target: UM.Preferences
- function onPreferenceChanged(preference)
- {
- if (preference !== "general/auto_slice")
- {
- return;
- }
- var autoSlice = UM.Preferences.getValue("general/auto_slice")
- if(prepareButtons.autoSlice != autoSlice)
- {
- prepareButtons.autoSlice = autoSlice
- if(autoSlice)
- {
- CuraApplication.backend.forceSlice()
- }
- }
- }
- }
-
- Action
- {
- shortcut: "Ctrl+P"
- onTriggered:
- {
- if (sliceButton.enabled)
- {
- sliceOrStopSlicing()
- }
- }
- }
- }
|