mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-10 04:14:16 +02:00
show_message refactoring | showing warnings as a unique string
This commit is contained in:
@@ -1,31 +1,26 @@
|
||||
from PyQt5.QtGui import QIcon
|
||||
from PyQt5.QtWidgets import QMessageBox
|
||||
from bauh_api.abstract.view import MessageType
|
||||
|
||||
from bauh.core import resource
|
||||
|
||||
MSG_TYPE_MAP = {
|
||||
MessageType.ERROR: QMessageBox.Critical,
|
||||
MessageType.INFO: QMessageBox.Information,
|
||||
MessageType.WARNING: QMessageBox.Warning
|
||||
}
|
||||
|
||||
def show_error(title: str, body: str, icon: QIcon = QIcon(resource.get_path('img/logo.svg'))):
|
||||
error_msg = QMessageBox()
|
||||
error_msg.setIcon(QMessageBox.Critical)
|
||||
error_msg.setWindowTitle(title)
|
||||
error_msg.setText(body)
|
||||
|
||||
def show_message(title: str, body: str, type_: MessageType, icon: QIcon = QIcon(resource.get_path('img/logo.svg'))):
|
||||
popup = QMessageBox()
|
||||
popup.setWindowTitle(title)
|
||||
popup.setText(body)
|
||||
popup.setIcon(MSG_TYPE_MAP[type_])
|
||||
|
||||
if icon:
|
||||
error_msg.setWindowIcon(icon)
|
||||
popup.setWindowIcon(icon)
|
||||
|
||||
error_msg.exec_()
|
||||
|
||||
|
||||
def show_warning(title: str, body: str, icon: QIcon = QIcon(resource.get_path('img/logo.svg'))):
|
||||
msg = QMessageBox()
|
||||
msg.setIcon(QMessageBox.Warning)
|
||||
msg.setWindowTitle(title)
|
||||
msg.setText(body)
|
||||
|
||||
if icon:
|
||||
msg.setWindowIcon(icon)
|
||||
|
||||
msg.exec_()
|
||||
popup.exec_()
|
||||
|
||||
|
||||
def ask_confirmation(title: str, body: str, locale_keys: dict, icon: QIcon = QIcon(resource.get_path('img/logo.svg'))):
|
||||
|
||||
Reference in New Issue
Block a user