mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-20 01:29:04 +08:00

The QML property was not updated when you change the printer. By not caching it, it gets the current printer's firmware file upon clicking the button. Simple and effective, and not that tough on computational power that it needs caching. Contributes to issue CURA-5749.
92 lines
3.1 KiB
QML
92 lines
3.1 KiB
QML
// Copyright (c) 2018 Ultimaker B.V.
|
|
// Cura is released under the terms of the LGPLv3 or higher.
|
|
|
|
import QtQuick 2.2
|
|
import QtQuick.Controls 1.1
|
|
import QtQuick.Layouts 1.1
|
|
import QtQuick.Window 2.1
|
|
import QtQuick.Dialogs 1.2 // For filedialog
|
|
|
|
import UM 1.2 as UM
|
|
import Cura 1.0 as Cura
|
|
|
|
|
|
Cura.MachineAction
|
|
{
|
|
anchors.fill: parent;
|
|
property bool printerConnected: Cura.MachineManager.printerConnected
|
|
property var activeOutputDevice: printerConnected ? Cura.MachineManager.printerOutputDevices[0] : null
|
|
|
|
Item
|
|
{
|
|
id: upgradeFirmwareMachineAction
|
|
anchors.fill: parent;
|
|
UM.I18nCatalog { id: catalog; name:"cura"}
|
|
|
|
Label
|
|
{
|
|
id: pageTitle
|
|
width: parent.width
|
|
text: catalog.i18nc("@title", "Upgrade Firmware")
|
|
wrapMode: Text.WordWrap
|
|
font.pointSize: 18
|
|
}
|
|
Label
|
|
{
|
|
id: pageDescription
|
|
anchors.top: pageTitle.bottom
|
|
anchors.topMargin: UM.Theme.getSize("default_margin").height
|
|
width: parent.width
|
|
wrapMode: Text.WordWrap
|
|
text: catalog.i18nc("@label", "Firmware is the piece of software running directly on your 3D printer. This firmware controls the step motors, regulates the temperature and ultimately makes your printer work.")
|
|
}
|
|
|
|
Label
|
|
{
|
|
id: upgradeText1
|
|
anchors.top: pageDescription.bottom
|
|
anchors.topMargin: UM.Theme.getSize("default_margin").height
|
|
width: parent.width
|
|
wrapMode: Text.WordWrap
|
|
text: catalog.i18nc("@label", "The firmware shipping with new printers works, but new versions tend to have more features and improvements.");
|
|
}
|
|
|
|
Row
|
|
{
|
|
anchors.top: upgradeText1.bottom
|
|
anchors.topMargin: UM.Theme.getSize("default_margin").height
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
width: childrenRect.width
|
|
spacing: UM.Theme.getSize("default_margin").width
|
|
Button
|
|
{
|
|
id: autoUpgradeButton
|
|
text: catalog.i18nc("@action:button", "Automatically upgrade Firmware");
|
|
enabled: parent.firmwareName != "" && activeOutputDevice
|
|
onClicked:
|
|
{
|
|
activeOutputDevice.updateFirmware(Cura.USBPrinterManager.getDefaultFirmwareName())
|
|
}
|
|
}
|
|
Button
|
|
{
|
|
id: manualUpgradeButton
|
|
text: catalog.i18nc("@action:button", "Upload custom Firmware");
|
|
enabled: activeOutputDevice != null
|
|
onClicked:
|
|
{
|
|
customFirmwareDialog.open()
|
|
}
|
|
}
|
|
}
|
|
|
|
FileDialog
|
|
{
|
|
id: customFirmwareDialog
|
|
title: catalog.i18nc("@title:window", "Select custom firmware")
|
|
nameFilters: "Firmware image files (*.hex)"
|
|
selectExisting: true
|
|
onAccepted: activeOutputDevice.updateFirmware(fileUrl)
|
|
}
|
|
}
|
|
} |