|
| 1 | +from PyQt5 import QtCore, QtGui, QtWidgets |
| 2 | +from lang import * |
| 3 | + |
| 4 | +dialogStyle = """ |
| 5 | + QMessageBox { background-color: rgb(62, 62, 62); color: rgb(255, 255, 255); } |
| 6 | + QWidget{ background-color: rgb(62, 62, 62); color: rgb(255, 255, 255); } |
| 7 | + QPushButton{ height:30px; } |
| 8 | + """ |
| 9 | +dialogStyleBtnGeneric = 'background-color: rgb(90, 90, 90); color: rgb(255, 255, 255);' |
| 10 | +dialogStyleBtnRed = 'background-color: rgb(234, 86, 86); color: rgb(255, 255, 255);' |
| 11 | +dialogStyleBtnGreen = 'background-color: rgb(0, 153, 15); color: rgb(255, 255, 255);' |
| 12 | + |
| 13 | + |
| 14 | +def InfoDialog(title: str, text: str, parent: any = None): |
| 15 | + lang = Lang() |
| 16 | + msgBox = QtWidgets.QMessageBox(parent) |
| 17 | + msgBox.setStyleSheet(dialogStyle) |
| 18 | + msgBox.setWindowTitle(title) |
| 19 | + msgBox.setText(text) |
| 20 | + msgBox.setStandardButtons(QtWidgets.QMessageBox.Ok) |
| 21 | + msgBox.button(QtWidgets.QMessageBox.Ok).setText(lang['Generic']['DialogBtnOk']) |
| 22 | + msgBox.button(QtWidgets.QMessageBox.Ok).setStyleSheet(dialogStyleBtnGeneric) |
| 23 | + msgBox.button(QtWidgets.QMessageBox.Ok).setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor)) |
| 24 | + msgBox.setDefaultButton(QtWidgets.QMessageBox.Ok) |
| 25 | + msgBox.setIcon(QtWidgets.QMessageBox.Information) |
| 26 | + ret = msgBox.exec() |
| 27 | + |
| 28 | + |
| 29 | +def InfoDialogConfirm(title: str, text: str, yes: str, no: str, parent: any = None): |
| 30 | + msgBox = QtWidgets.QMessageBox(parent) |
| 31 | + msgBox.setStyleSheet(dialogStyle) |
| 32 | + msgBox.setWindowTitle(title) |
| 33 | + msgBox.setText(text) |
| 34 | + msgBox.setStandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) |
| 35 | + msgBox.button(QtWidgets.QMessageBox.Yes).setText(yes) |
| 36 | + msgBox.button(QtWidgets.QMessageBox.Yes).setStyleSheet(dialogStyleBtnGreen) |
| 37 | + msgBox.button(QtWidgets.QMessageBox.Yes).setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor)) |
| 38 | + msgBox.button(QtWidgets.QMessageBox.No).setText(no) |
| 39 | + msgBox.button(QtWidgets.QMessageBox.No).setStyleSheet(dialogStyleBtnRed) |
| 40 | + msgBox.button(QtWidgets.QMessageBox.No).setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor)) |
| 41 | + msgBox.setDefaultButton(QtWidgets.QMessageBox.No) |
| 42 | + msgBox.setIcon(QtWidgets.QMessageBox.Information) |
| 43 | + ret = msgBox.exec() |
| 44 | + if ret == QtWidgets.QMessageBox.Yes: return True |
| 45 | + else: return False |
| 46 | + |
| 47 | + |
| 48 | +def WarnDialog(title: str, text: str, parent: any = None): |
| 49 | + lang = Lang() |
| 50 | + msgBox = QtWidgets.QMessageBox(parent) |
| 51 | + msgBox.setStyleSheet(dialogStyle) |
| 52 | + msgBox.setWindowTitle(title) |
| 53 | + msgBox.setText(text) |
| 54 | + msgBox.setStandardButtons(QtWidgets.QMessageBox.Ok) |
| 55 | + msgBox.button(QtWidgets.QMessageBox.Ok).setText(lang['Generic']['DialogBtnOk']) |
| 56 | + msgBox.button(QtWidgets.QMessageBox.Ok).setStyleSheet(dialogStyleBtnGeneric) |
| 57 | + msgBox.button(QtWidgets.QMessageBox.Ok).setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor)) |
| 58 | + msgBox.setDefaultButton(QtWidgets.QMessageBox.Ok) |
| 59 | + msgBox.setIcon(QtWidgets.QMessageBox.Warning) |
| 60 | + ret = msgBox.exec() |
| 61 | + |
| 62 | + |
| 63 | +def WarnDialogConfirm(title: str, text: str, yes: str, no: str, parent: any = None): |
| 64 | + msgBox = QtWidgets.QMessageBox(parent) |
| 65 | + msgBox.setStyleSheet(dialogStyle) |
| 66 | + msgBox.setWindowTitle(title) |
| 67 | + msgBox.setText(text) |
| 68 | + msgBox.setStandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) |
| 69 | + msgBox.button(QtWidgets.QMessageBox.Yes).setText(yes) |
| 70 | + msgBox.button(QtWidgets.QMessageBox.Yes).setStyleSheet(dialogStyleBtnRed) |
| 71 | + msgBox.button(QtWidgets.QMessageBox.Yes).setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor)) |
| 72 | + msgBox.button(QtWidgets.QMessageBox.No).setText(no) |
| 73 | + msgBox.button(QtWidgets.QMessageBox.No).setStyleSheet(dialogStyleBtnGreen) |
| 74 | + msgBox.button(QtWidgets.QMessageBox.No).setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor)) |
| 75 | + msgBox.setDefaultButton(QtWidgets.QMessageBox.No) |
| 76 | + msgBox.setIcon(QtWidgets.QMessageBox.Warning) |
| 77 | + ret = msgBox.exec() |
| 78 | + if ret == QtWidgets.QMessageBox.Yes: return True |
| 79 | + else: return False |
| 80 | + |
0 commit comments