mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 23:46:22 -06:00
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
This commit is contained in:
parent
f0dda6553b
commit
669dcc62dd
3 changed files with 41 additions and 3 deletions
|
@ -207,6 +207,7 @@ class CuraApplication(QtApplication):
|
||||||
self._first_start_machine_actions_model = None
|
self._first_start_machine_actions_model = None
|
||||||
self._welcome_pages_model = WelcomePagesModel(self, parent = self)
|
self._welcome_pages_model = WelcomePagesModel(self, parent = self)
|
||||||
self._add_printer_pages_model = AddPrinterPagesModel(self, parent = self)
|
self._add_printer_pages_model = AddPrinterPagesModel(self, parent = self)
|
||||||
|
self._add_printer_pages_model_without_cancel = AddPrinterPagesModel(self, parent = self)
|
||||||
self._whats_new_pages_model = WhatsNewPagesModel(self, parent = self)
|
self._whats_new_pages_model = WhatsNewPagesModel(self, parent = self)
|
||||||
self._text_manager = TextManager(parent = self)
|
self._text_manager = TextManager(parent = self)
|
||||||
|
|
||||||
|
@ -647,7 +648,7 @@ class CuraApplication(QtApplication):
|
||||||
return self._global_container_stack
|
return self._global_container_stack
|
||||||
|
|
||||||
@override(Application)
|
@override(Application)
|
||||||
def setGlobalContainerStack(self, stack: "GlobalStack") -> None:
|
def setGlobalContainerStack(self, stack: Optional[GlobalStack]) -> None:
|
||||||
self._setLoadingHint(self._i18n_catalog.i18nc("@info:progress", "Initializing Active Machine..."))
|
self._setLoadingHint(self._i18n_catalog.i18nc("@info:progress", "Initializing Active Machine..."))
|
||||||
super().setGlobalContainerStack(stack)
|
super().setGlobalContainerStack(stack)
|
||||||
|
|
||||||
|
@ -812,6 +813,7 @@ class CuraApplication(QtApplication):
|
||||||
self._output_device_manager.start()
|
self._output_device_manager.start()
|
||||||
self._welcome_pages_model.initialize()
|
self._welcome_pages_model.initialize()
|
||||||
self._add_printer_pages_model.initialize()
|
self._add_printer_pages_model.initialize()
|
||||||
|
self._add_printer_pages_model_without_cancel.initialize(cancellable = False)
|
||||||
self._whats_new_pages_model.initialize()
|
self._whats_new_pages_model.initialize()
|
||||||
|
|
||||||
# Detect in which mode to run and execute that mode
|
# Detect in which mode to run and execute that mode
|
||||||
|
@ -849,6 +851,7 @@ class CuraApplication(QtApplication):
|
||||||
self.callLater(self._openFile, file_name)
|
self.callLater(self._openFile, file_name)
|
||||||
|
|
||||||
initializationFinished = pyqtSignal()
|
initializationFinished = pyqtSignal()
|
||||||
|
showAddPrintersUncancellableDialog = pyqtSignal() # Used to show the add printers dialog with a greyed background
|
||||||
|
|
||||||
def runWithoutGUI(self):
|
def runWithoutGUI(self):
|
||||||
"""Run Cura without GUI elements and interaction (server mode)."""
|
"""Run Cura without GUI elements and interaction (server mode)."""
|
||||||
|
@ -939,6 +942,10 @@ class CuraApplication(QtApplication):
|
||||||
def getAddPrinterPagesModel(self, *args) -> "AddPrinterPagesModel":
|
def getAddPrinterPagesModel(self, *args) -> "AddPrinterPagesModel":
|
||||||
return self._add_printer_pages_model
|
return self._add_printer_pages_model
|
||||||
|
|
||||||
|
@pyqtSlot(result = QObject)
|
||||||
|
def getAddPrinterPagesModelWithoutCancel(self, *args) -> "AddPrinterPagesModel":
|
||||||
|
return self._add_printer_pages_model_without_cancel
|
||||||
|
|
||||||
@pyqtSlot(result = QObject)
|
@pyqtSlot(result = QObject)
|
||||||
def getWhatsNewPagesModel(self, *args) -> "WhatsNewPagesModel":
|
def getWhatsNewPagesModel(self, *args) -> "WhatsNewPagesModel":
|
||||||
return self._whats_new_pages_model
|
return self._whats_new_pages_model
|
||||||
|
@ -1940,6 +1947,11 @@ class CuraApplication(QtApplication):
|
||||||
# Only show the complete flow if there is no printer yet.
|
# Only show the complete flow if there is no printer yet.
|
||||||
return self._machine_manager.activeMachine is None
|
return self._machine_manager.activeMachine is None
|
||||||
|
|
||||||
|
@pyqtSlot(result = bool)
|
||||||
|
def shouldShowAddPrintersUncancellableDialog(self) -> bool:
|
||||||
|
# If there is no printer and the user is logged in, show only the add printers flow in the welcome dialog.
|
||||||
|
return self._machine_manager.activeMachine is None and self.getCuraAPI().account.isLoggedIn
|
||||||
|
|
||||||
@pyqtSlot(result = bool)
|
@pyqtSlot(result = bool)
|
||||||
def shouldShowWhatsNewDialog(self) -> bool:
|
def shouldShowWhatsNewDialog(self) -> bool:
|
||||||
has_active_machine = self._machine_manager.activeMachine is not None
|
has_active_machine = self._machine_manager.activeMachine is not None
|
||||||
|
|
|
@ -10,12 +10,11 @@ from .WelcomePagesModel import WelcomePagesModel
|
||||||
#
|
#
|
||||||
class AddPrinterPagesModel(WelcomePagesModel):
|
class AddPrinterPagesModel(WelcomePagesModel):
|
||||||
|
|
||||||
def initialize(self) -> None:
|
def initialize(self, cancellable: bool = True) -> None:
|
||||||
self._pages.append({"id": "add_network_or_local_printer",
|
self._pages.append({"id": "add_network_or_local_printer",
|
||||||
"page_url": self._getBuiltinWelcomePagePath("AddNetworkOrLocalPrinterContent.qml"),
|
"page_url": self._getBuiltinWelcomePagePath("AddNetworkOrLocalPrinterContent.qml"),
|
||||||
"next_page_id": "machine_actions",
|
"next_page_id": "machine_actions",
|
||||||
"next_page_button_text": self._catalog.i18nc("@action:button", "Add"),
|
"next_page_button_text": self._catalog.i18nc("@action:button", "Add"),
|
||||||
"previous_page_button_text": self._catalog.i18nc("@action:button", "Cancel"),
|
|
||||||
})
|
})
|
||||||
self._pages.append({"id": "add_printer_by_ip",
|
self._pages.append({"id": "add_printer_by_ip",
|
||||||
"page_url": self._getBuiltinWelcomePagePath("AddPrinterByIpContent.qml"),
|
"page_url": self._getBuiltinWelcomePagePath("AddPrinterByIpContent.qml"),
|
||||||
|
@ -30,6 +29,9 @@ class AddPrinterPagesModel(WelcomePagesModel):
|
||||||
"page_url": self._getBuiltinWelcomePagePath("FirstStartMachineActionsContent.qml"),
|
"page_url": self._getBuiltinWelcomePagePath("FirstStartMachineActionsContent.qml"),
|
||||||
"should_show_function": self.shouldShowMachineActions,
|
"should_show_function": self.shouldShowMachineActions,
|
||||||
})
|
})
|
||||||
|
if cancellable:
|
||||||
|
self._pages[0]["previous_page_button_text"] = self._catalog.i18nc("@action:button", "Cancel")
|
||||||
|
|
||||||
self.setItems(self._pages)
|
self.setItems(self._pages)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,21 @@ UM.MainWindow
|
||||||
CuraApplication.purgeWindows()
|
CuraApplication.purgeWindows()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections
|
||||||
|
{
|
||||||
|
// This connection is used when there is no ActiveMachine and the user is logged in
|
||||||
|
target: CuraApplication
|
||||||
|
onShowAddPrintersUncancellableDialog:
|
||||||
|
{
|
||||||
|
Cura.Actions.parent = backgroundItem
|
||||||
|
|
||||||
|
// Reuse the welcome dialog item to show "Add a printer" only.
|
||||||
|
welcomeDialogItem.model = CuraApplication.getAddPrinterPagesModelWithoutCancel()
|
||||||
|
welcomeDialogItem.progressBarVisible = false
|
||||||
|
welcomeDialogItem.visible = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Connections
|
Connections
|
||||||
{
|
{
|
||||||
target: CuraApplication
|
target: CuraApplication
|
||||||
|
@ -117,6 +132,15 @@ UM.MainWindow
|
||||||
welcomeDialogItem.progressBarVisible = false
|
welcomeDialogItem.progressBarVisible = false
|
||||||
welcomeDialogItem.visible = true
|
welcomeDialogItem.visible = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reuse the welcome dialog item to show the "Add printers" dialog. Triggered when there is no active
|
||||||
|
// machine and the user is logged in.
|
||||||
|
if (CuraApplication.shouldShowAddPrintersUncancellableDialog())
|
||||||
|
{
|
||||||
|
welcomeDialogItem.model = CuraApplication.getAddPrinterPagesModelWithoutCancel()
|
||||||
|
welcomeDialogItem.progressBarVisible = false
|
||||||
|
welcomeDialogItem.visible = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue