def __init__(self, parent=None, **kwargs): if not parent: from artella import dcc parent = dcc.get_main_window() self._use_artella_header = kwargs.pop('use_artella_header', True) super(BaseDialog, self).__init__(parent, **kwargs) self._pos_anim = QtCore.QPropertyAnimation(self) self._pos_anim.setTargetObject(self) self._pos_anim.setEasingCurve(QtCore.QEasingCurve.OutCubic) self._pos_anim.setDuration(300) self._pos_anim.setPropertyName(b'pos') self._opacity_anim = QtCore.QPropertyAnimation() self._opacity_anim.setTargetObject(self) self._opacity_anim.setEasingCurve(QtCore.QEasingCurve.OutCubic) self._opacity_anim.setDuration(300) self._opacity_anim.setPropertyName(b'windowOpacity') self._opacity_anim.setStartValue(0.0) self._opacity_anim.setEndValue(1.0) self.setup_ui() theme.theme().apply(self) self._fade_in()
def show_error_message_box(title, text, parent=None): """ Shows an error message box that can be used to show critical text to users. :param str title: text that is displayed in the title bar of the dialog :param str text: default text which is placed n the plain text edit :param QWidget parent: optional parent widget for the input text dialog. If not given, current DCC main parent window will be used. """ if not QT_AVAILABLE: return from artella import dcc from artella.core import resource parent = parent if parent else dcc.get_main_window() window_icon = resource.icon('artella') message_box = QtWidgets.QMessageBox(parent) message_box.setWindowTitle(title) message_box.setWindowIcon(window_icon) message_box.setIcon(message_box.Icon.Critical) flags = message_box.windowFlags() ^ QtCore.Qt.WindowContextHelpButtonHint | QtCore.Qt.WindowStaysOnTopHint if text: message_box.setText(text) message_box.setStandardButtons(QtWidgets.QMessageBox.Ok) message_box.setWindowFlags(flags) message_box.exec_()
def show_comment_input_dialog(title, label, text='', parent=None): """ Shows a text string input dialog that users can use to input text. :param str title: text that is displayed in the title bar of the dialog :param str label: text which is shown to the user telling them what kind of text they need to input :param str text: default text which is placed in the comment section :param QWidget parent: optional parent widget for the input text dialog. If not given, current DCC main parent window will be used. :return: Tuple containing as the first element the text typed by the user and as the second argument a boolean that will be True if the user clicked on the Ok button or False if the user cancelled the operation :rtype: tuple(str, bool) """ if not QT_AVAILABLE: return '', False from artella import dcc parent = parent if parent else dcc.get_main_window() comment_dialog = QtWidgets.QInputDialog() flags = comment_dialog.windowFlags() ^ QtCore.Qt.WindowContextHelpButtonHint | QtCore.Qt.WindowStaysOnTopHint if hasattr(QtWidgets.QInputDialog, 'getMultiLineText'): comment, res = comment_dialog.getMultiLineText(parent, title, label, text=text, flags=flags) else: comment, res = comment_dialog.getText(parent, title, label, text, text=text, flags=flags) return comment, res
def show_info_message_box(title, text, parent=None): """ Shows an info message box that can be used to show information text to users. :param str title: text that is displayed in the title bar of the dialog :param str text: default text which is placed n the plain text edit :param QWidget parent: optional parent widget for the input text dialog. If not given, current DCC main parent window will be used. """ if not QT_AVAILABLE: return from artella import dcc parent = parent if parent else dcc.get_main_window() QtWidgets.QMessageBox.information(parent, title, text)
def show_question_message_box(title, text, cancel=True, parent=None): """ Shows a question message box that can be used to show question text to users. :param str title: text that is displayed in the title bar of the dialog :param str text: default text which is placed n the plain text edit :param bool cancel: Whether or not cancel button should appear in question message box :param QWidget parent: optional parent widget for the input text dialog. If not given, current DCC main parent window will be used. :return: True if the user presses the Ok button; False if the user presses the No button; None if the user preses the Cancel button :rtype: bool or None """ if not QT_AVAILABLE: return None from artella import dcc parent = parent if parent else dcc.get_main_window() message_box = QtWidgets.QMessageBox(parent) message_box.setWindowTitle(title) flags = message_box.windowFlags() ^ QtCore.Qt.WindowContextHelpButtonHint | QtCore.Qt.WindowStaysOnTopHint if text: message_box.setText(text) if cancel: message_box.setStandardButtons( QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No | QtWidgets.QMessageBox.Cancel) else: message_box.setStandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) message_box.setWindowFlags(flags) result = message_box.exec_() if result == QtWidgets.QMessageBox.Yes: return True elif result == QtWidgets.QMessageBox.No: return False elif result == QtWidgets.QMessageBox.Cancel: return None
def __init__(self, text='', title='', duration=None, artella_type=None, closable=False, parent=None): if parent is None: parent = dcc.get_main_window() current_type = artella_type or SnackBarTypes.ARTELLA super(SnackBarMessage, self).__init__(parent) self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.Dialog | QtCore.Qt.WA_DeleteOnClose) self.setAttribute(QtCore.Qt.WA_StyledBackground) self.setAttribute(QtCore.Qt.WA_TranslucentBackground) main_layout = QtWidgets.QVBoxLayout() main_layout.setContentsMargins(2, 2, 2, 2) main_layout.setSpacing(2) self.setLayout(main_layout) main_frame = QtWidgets.QFrame() main_frame.setObjectName('mainFrame') frame_layout = QtWidgets.QVBoxLayout() frame_layout.setContentsMargins(5, 5, 5, 5) frame_layout.setSpacing(5) main_frame.setLayout(frame_layout) main_layout.addWidget(main_frame) info_layout = QtWidgets.QHBoxLayout() artella_label_layout = QtWidgets.QHBoxLayout() artella_label = image.ArtellaImage.small() artella_label.set_artella_image(resource.pixmap('artella_white')) self._close_btn = button.ArtellaToolButton( parent=self).image('close').tiny().icon_only() self._close_btn.setVisible(closable or False) self._close_btn.clicked.connect(self.close) if closable: artella_label_layout.addSpacing(20) artella_label_layout.addStretch() artella_label_layout.addWidget(artella_label) artella_label_layout.addStretch() artella_label_layout.addWidget(self._close_btn) title_layout = QtWidgets.QHBoxLayout() self._title_label = label.ArtellaLabel(parent=self).strong() self._title_label.setText(title) self._title_label.setVisible(bool(text)) title_layout.addStretch() title_layout.addWidget(self._title_label) title_layout.addStretch() self._icon_label = image.ArtellaImage.small() self._icon_label.set_artella_image( resource.pixmap('{}'.format(current_type), color=vars(theme.theme()).get(current_type + '_color'))) self._content_label = label.ArtellaLabel(parent=self) self._content_label.setText(text) info_layout.addStretch() info_layout.addWidget(self._icon_label) info_layout.addWidget(self._content_label) info_layout.addStretch() frame_layout.addLayout(artella_label_layout) frame_layout.addWidget(divider.ArtellaDivider()) frame_layout.addLayout(title_layout) frame_layout.addLayout(info_layout) self._setup_timers(duration) self._on_fade_in()