Cura/cura/UI/AddPrinterPagesModel.py
Kostas Karmas 669dcc62dd Add extra "AddPrinterPagesModel" without the cancel button
This commit adds an additional AddPrinterPagesModel in Cura that does
not have the "Cancel" button in the "Add Printer" page. To achieve
that, the AddPrinterPagesModel is modified so that its initialize
function decides whether or not it will add the cancel button.

If Cura ends up in a state without an active machine, the AddPrinters
dialog will open up using the showAddPrintersUncancellableDialog signal
and display the new "Uncancellable" (is this a word?)
AddPrinterPagesModel, so that the dialog cannot be dismissed.

If Cura is closed at that point, the next time it is initiated, if the
user is logged in and there is no ActiveMachine, then instead of
displaying the entire WelcomePages wizard, it will show the
uncancellable AddPrinterPagesModel, forcing the user to add a printer.

CURA-7454
2020-06-09 15:20:15 +02:00

39 lines
1.8 KiB
Python

# Copyright (c) 2019 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
from .WelcomePagesModel import WelcomePagesModel
#
# This Qt ListModel is more or less the same the WelcomePagesModel, except that this model is only for adding a printer,
# so only the steps for adding a printer is included.
#
class AddPrinterPagesModel(WelcomePagesModel):
def initialize(self, cancellable: bool = True) -> None:
self._pages.append({"id": "add_network_or_local_printer",
"page_url": self._getBuiltinWelcomePagePath("AddNetworkOrLocalPrinterContent.qml"),
"next_page_id": "machine_actions",
"next_page_button_text": self._catalog.i18nc("@action:button", "Add"),
})
self._pages.append({"id": "add_printer_by_ip",
"page_url": self._getBuiltinWelcomePagePath("AddPrinterByIpContent.qml"),
"next_page_id": "machine_actions",
})
self._pages.append({"id": "add_cloud_printers",
"page_url": self._getBuiltinWelcomePagePath("AddCloudPrintersView.qml"),
"is_final_page": True,
"next_page_button_text": self._catalog.i18nc("@action:button", "Finish"),
})
self._pages.append({"id": "machine_actions",
"page_url": self._getBuiltinWelcomePagePath("FirstStartMachineActionsContent.qml"),
"should_show_function": self.shouldShowMachineActions,
})
if cancellable:
self._pages[0]["previous_page_button_text"] = self._catalog.i18nc("@action:button", "Cancel")
self.setItems(self._pages)
__all__ = ["AddPrinterPagesModel"]