mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-14 23:15:52 +08:00
Add reusable messagebox based on QML MessageDialog
Contributes to CURA-1730 and CURA-1850
This commit is contained in:
parent
2f3ffe2a18
commit
6eb502730c
@ -47,6 +47,7 @@ import cura.Settings
|
|||||||
|
|
||||||
from PyQt5.QtCore import pyqtSlot, QUrl, pyqtSignal, pyqtProperty, QEvent, Q_ENUMS
|
from PyQt5.QtCore import pyqtSlot, QUrl, pyqtSignal, pyqtProperty, QEvent, Q_ENUMS
|
||||||
from PyQt5.QtGui import QColor, QIcon
|
from PyQt5.QtGui import QColor, QIcon
|
||||||
|
from PyQt5.QtWidgets import QMessageBox
|
||||||
from PyQt5.QtQml import qmlRegisterUncreatableType, qmlRegisterSingletonType, qmlRegisterType
|
from PyQt5.QtQml import qmlRegisterUncreatableType, qmlRegisterSingletonType, qmlRegisterType
|
||||||
|
|
||||||
import platform
|
import platform
|
||||||
@ -155,6 +156,8 @@ class CuraApplication(QtApplication):
|
|||||||
self._cura_actions = None
|
self._cura_actions = None
|
||||||
self._started = False
|
self._started = False
|
||||||
|
|
||||||
|
self._message_box_callback = None
|
||||||
|
|
||||||
self._i18n_catalog = i18nCatalog("cura")
|
self._i18n_catalog = i18nCatalog("cura")
|
||||||
|
|
||||||
self.getController().getScene().sceneChanged.connect(self.updatePlatformActivity)
|
self.getController().getScene().sceneChanged.connect(self.updatePlatformActivity)
|
||||||
@ -251,6 +254,19 @@ class CuraApplication(QtApplication):
|
|||||||
def _onEngineCreated(self):
|
def _onEngineCreated(self):
|
||||||
self._engine.addImageProvider("camera", CameraImageProvider.CameraImageProvider())
|
self._engine.addImageProvider("camera", CameraImageProvider.CameraImageProvider())
|
||||||
|
|
||||||
|
## A reusable dialogbox
|
||||||
|
#
|
||||||
|
showMessageBox = pyqtSignal(str, str, str, str, int, int, arguments = ["title", "text", "informativeText", "detailedText", "buttons", "icon"])
|
||||||
|
def messageBox(self, title, text, informativeText = "", detailedText = "", buttons = QMessageBox.Ok, icon = QMessageBox.NoIcon, callback = None):
|
||||||
|
self._message_box_callback = callback
|
||||||
|
self.showMessageBox.emit(title, text, informativeText, detailedText, buttons, icon)
|
||||||
|
|
||||||
|
@pyqtSlot(int)
|
||||||
|
def messageBoxClosed(self, button):
|
||||||
|
if self._message_box_callback:
|
||||||
|
self._message_box_callback(button)
|
||||||
|
self._message_box_callback = None
|
||||||
|
|
||||||
showPrintMonitor = pyqtSignal(bool, arguments = ["show"])
|
showPrintMonitor = pyqtSignal(bool, arguments = ["show"])
|
||||||
|
|
||||||
## Cura has multiple locations where instance containers need to be saved, so we need to handle this differently.
|
## Cura has multiple locations where instance containers need to be saved, so we need to handle this differently.
|
||||||
|
@ -683,6 +683,35 @@ UM.MainWindow
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MessageDialog
|
||||||
|
{
|
||||||
|
id: messageDialog
|
||||||
|
modality: Qt.ApplicationModal
|
||||||
|
onAccepted: Printer.messageBoxClosed(clickedButton)
|
||||||
|
onApply: Printer.messageBoxClosed(clickedButton)
|
||||||
|
onDiscard: Printer.messageBoxClosed(clickedButton)
|
||||||
|
onHelp: Printer.messageBoxClosed(clickedButton)
|
||||||
|
onNo: Printer.messageBoxClosed(clickedButton)
|
||||||
|
onRejected: Printer.messageBoxClosed(clickedButton)
|
||||||
|
onReset: Printer.messageBoxClosed(clickedButton)
|
||||||
|
onYes: Printer.messageBoxClosed(clickedButton)
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections
|
||||||
|
{
|
||||||
|
target: Printer
|
||||||
|
onShowMessageBox:
|
||||||
|
{
|
||||||
|
messageDialog.title = title
|
||||||
|
messageDialog.text = text
|
||||||
|
messageDialog.informativeText = informativeText
|
||||||
|
messageDialog.detailedText = detailedText
|
||||||
|
messageDialog.standardButtons = buttons
|
||||||
|
messageDialog.icon = icon
|
||||||
|
messageDialog.visible = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Connections
|
Connections
|
||||||
{
|
{
|
||||||
target: Cura.Actions.addMachine
|
target: Cura.Actions.addMachine
|
||||||
|
Loading…
x
Reference in New Issue
Block a user