Exemple #1
0
    def msgbox(self, msgtext = "", typ = oPB.MsgEnum.MS_STAT, parent = None):
        """
        Message box function (virtual)

        **HAS TO BE RE-IMPLEMENTED**

        Valid values for ``typ``:

            * oPB.MsgEnum.MS_ERR -> Error message (status bar/ popup)
            * oPB.MsgEnum.MS_WARN -> Warning (status bar/ popup)
            * oPB.MsgEnum.MS_INFO -> Information (status bar/ popup)
            * oPB.MsgEnum.MS_STAT -> Information (only status bar)
            * oPB.MsgEnum.MS_ALWAYS -> Display this message ALWAYS, regardless of which message ``typ`` is deactivated via settings
            * oPB.MsgEnum.MS_PARSE -> just parse message text and return it
            * oPB.MsgEnum.MS_QUEST_YESNO -> return True / False
            * oPB.MsgEnum.MS_QUEST_CTC -> build question: cancel (return 0)/ rebuild return(1)/ add return (2)
            * oPB.MsgEnum.MS_QUEST_OKCANCEL -> return True / False
            * oPB.MsgEnum.MS_QUEST_PHRASE -> return text from input box

        :param msgtext: Message text
        :param typ: type of message window, see oPB.core enums
        :return variant: see descriptions for ``typ``

        """

        if parent is None:
            parent = self.ui

        # first parse text
        msgtext = Helper.parse_text(msgtext)
        pass
Exemple #2
0
    def msgbox(self, msgtext = "", typ = oPB.MsgEnum.MS_STAT, parent = None):
        """
        Message box function (virtual)

        **HAS TO BE RE-IMPLEMENTED**

        Valid values for ``typ``:

            * oPB.MsgEnum.MS_ERR -> Error message (status bar/ popup)
            * oPB.MsgEnum.MS_WARN -> Warning (status bar/ popup)
            * oPB.MsgEnum.MS_INFO -> Information (status bar/ popup)
            * oPB.MsgEnum.MS_STAT -> Information (only status bar)
            * oPB.MsgEnum.MS_ALWAYS -> Display this message ALWAYS, regardless of which message ``typ`` is deactivated via settings
            * oPB.MsgEnum.MS_PARSE -> just parse message text and return it
            * oPB.MsgEnum.MS_QUEST_YESNO -> return True / False
            * oPB.MsgEnum.MS_QUEST_CTC -> build question: cancel (return 0)/ rebuild return(1)/ add return (2)
            * oPB.MsgEnum.MS_QUEST_OKCANCEL -> return True / False
            * oPB.MsgEnum.MS_QUEST_PHRASE -> return text from input box

        :param msgtext: Message text
        :param typ: type of message window, see oPB.core enums
        :return variant: see descriptions for ``typ``

        """

        if parent is None:
            parent = self.ui

        # first parse text
        msgtext = Helper.parse_text(msgtext)
        pass
Exemple #3
0
    def msgbox(self, msgtext = "", typ = oPB.MsgEnum.MS_STAT, parent = None):
        """ Messagebox function

        Valid values for typ:
            * oPB.MsgEnum.MS_ERR -> Error message (status bar/ popup)
            * oPB.MsgEnum.MS_WARN -> Warning (status bar/ popup)
            * oPB.MsgEnum.MS_INFO -> Information (status bar/ popup)
            * oPB.MsgEnum.MS_STAT -> Information (only status bar)
            * oPB.MsgEnum.MS_ALWAYS -> Display this message ALWAYS, regardless of which message **typ** is deactivated via settings
            * oPB.MsgEnum.MS_PARSE -> just parse message text and return it
            * oPB.MsgEnum.MS_QUEST_YESNO
            * oPB.MsgEnum.MS_QUEST_CTC
            * oPB.MsgEnum.MS_QUEST_OKCANCEL

        :param msgtext: Message text
        :param typ: type of message window, see oPB.core enums
        """
        if parent is None:
            parent = self.ui

        # first parse text
        msgtext = Helper.parse_text(msgtext)

        if typ == oPB.MsgEnum.MS_ERR:
            self.msgSend.emit(msgtext)
            if ConfigHandler.cfg.no_error_msg == "False":
                QMessageBox.critical(parent, translate("mainController", "Error"), msgtext, QMessageBox.Ok)

        elif typ == oPB.MsgEnum.MS_WARN:
            self.msgSend.emit(msgtext)
            if ConfigHandler.cfg.no_warning_msg == "False":
                QMessageBox.warning(parent, translate("mainController", "Warning"), msgtext, QMessageBox.Ok)

        elif typ == oPB.MsgEnum.MS_INFO:
            self.msgSend.emit(msgtext)
            if ConfigHandler.cfg.no_info_msg == "False":
                QMessageBox.information(parent, translate("mainController", "Message"), msgtext, QMessageBox.Ok)

        elif typ == oPB.MsgEnum.MS_STAT:
            self.msgSend.emit(msgtext)

        elif typ == oPB.MsgEnum.MS_ALWAYS:
            QMessageBox.information(parent, translate("mainController", "Message"), msgtext, QMessageBox.Ok)

        elif typ == oPB.MsgEnum.MS_PARSE:
            return msgtext

        elif typ == oPB.MsgEnum.MS_QUEST_YESNO:
            retval = QMessageBox.question(parent, translate("mainController", "Question"), msgtext, QMessageBox.Yes, QMessageBox.No)
            if retval == QMessageBox.No:
                return False
            else:
                return True

        elif typ == oPB.MsgEnum.MS_QUEST_CTC:
            msgBox = QMessageBox(parent)
            msgBox.setWindowTitle(translate("mainController", "Question"))
            msgBox.setText(msgtext)
            msgBox.setIcon(QMessageBox.Question)
            cancelBtn = QPushButton(translate("mainController", "Cancel"))
            rebuildBtn = QPushButton(translate("mainController", "Rebuild"))
            addBtn = QPushButton(translate("mainController", "Add version"))
            msgBox.addButton(cancelBtn, QMessageBox.RejectRole)
            msgBox.addButton(rebuildBtn, QMessageBox.AcceptRole)
            msgBox.addButton(addBtn, QMessageBox.AcceptRole)
            msgBox.exec_()
            if msgBox.clickedButton() == cancelBtn:
                return 0
            elif msgBox.clickedButton() == rebuildBtn:
                return 1
            else:
                return 2

        elif typ == oPB.MsgEnum.MS_QUEST_OKCANCEL:
            retval = QMessageBox.question(parent, translate("mainController", "Question"), msgtext, QMessageBox.Ok, QMessageBox.Cancel)
            if retval == QMessageBox.Cancel:
                return False
            else:
                return True

        elif typ == oPB.MsgEnum.MS_QUEST_PHRASE:
            text = QInputDialog.getText(parent, translate("mainController", "Additional information"),
                                          msgtext, QLineEdit.Normal,"")
            return text
Exemple #4
0
    def msgbox(self,
               msgtext="",
               typ=oPB.MsgEnum.MS_STAT,
               parent=None,
               preload=""):
        """ Messagebox function

        Valid values for typ:
            * oPB.MsgEnum.MS_ERR -> Error message (status bar/ popup)
            * oPB.MsgEnum.MS_WARN -> Warning (status bar/ popup)
            * oPB.MsgEnum.MS_INFO -> Information (status bar/ popup)
            * oPB.MsgEnum.MS_STAT -> Information (only status bar)
            * oPB.MsgEnum.MS_ALWAYS -> Display this message ALWAYS, regardless of which message **typ** is deactivated via settings
            * oPB.MsgEnum.MS_PARSE -> just parse message text and return it
            * oPB.MsgEnum.MS_QUEST_YESNO
            * oPB.MsgEnum.MS_QUEST_CTC
            * oPB.MsgEnum.MS_QUEST_OKCANCEL
            * oPB.MsgEnum.MS_QUEST_PHRASE
            * oPB.MsgEnum.MS_QUEST_PASS
            * oPB.MsgEnum.MS_QUEST_DEPOT

        :param msgtext: Message text
        :param typ: type of message window, see oPB.core enums
        :param parent: parent ui of message box
        :param preload: pre-fill input boxes with this text
        """
        if parent is None:
            parent = self.ui

        # first parse text, is argument is str
        if type(msgtext) is str:
            msgtext = Helper.parse_text(msgtext)

        if typ == oPB.MsgEnum.MS_ERR:
            self.msgSend.emit(msgtext)
            if ConfigHandler.cfg.no_error_msg == "False":
                QMessageBox.critical(parent,
                                     translate("mainController", "Error"),
                                     msgtext, QMessageBox.Ok)

        elif typ == oPB.MsgEnum.MS_WARN:
            self.msgSend.emit(msgtext)
            if ConfigHandler.cfg.no_warning_msg == "False":
                QMessageBox.warning(parent,
                                    translate("mainController", "Warning"),
                                    msgtext, QMessageBox.Ok)

        elif typ == oPB.MsgEnum.MS_INFO:
            self.msgSend.emit(msgtext)
            if ConfigHandler.cfg.no_info_msg == "False":
                QMessageBox.information(parent,
                                        translate("mainController", "Message"),
                                        msgtext, QMessageBox.Ok)

        elif typ == oPB.MsgEnum.MS_STAT:
            self.msgSend.emit(msgtext)

        elif typ == oPB.MsgEnum.MS_ALWAYS:
            QMessageBox.information(parent,
                                    translate("mainController", "Message"),
                                    msgtext, QMessageBox.Ok)

        elif typ == oPB.MsgEnum.MS_PARSE:
            return msgtext

        elif typ == oPB.MsgEnum.MS_QUEST_YESNO:
            retval = QMessageBox.question(
                parent, translate("mainController", "Question"), msgtext,
                QMessageBox.Yes, QMessageBox.No)
            if retval == QMessageBox.No:
                return False
            else:
                return True

        elif typ == oPB.MsgEnum.MS_QUEST_CTC:
            msgBox = QMessageBox(parent)
            msgBox.setWindowTitle(translate("mainController", "Question"))
            msgBox.setText(msgtext)
            msgBox.setIcon(QMessageBox.Question)
            cancelBtn = QPushButton(translate("mainController", "Cancel"))
            rebuildBtn = QPushButton(translate("mainController", "Rebuild"))
            addBtn = QPushButton(translate("mainController", "Add version"))
            msgBox.addButton(cancelBtn, QMessageBox.RejectRole)
            msgBox.addButton(rebuildBtn, QMessageBox.AcceptRole)
            msgBox.addButton(addBtn, QMessageBox.AcceptRole)
            msgBox.exec_()
            if msgBox.clickedButton() == cancelBtn:
                return 0
            elif msgBox.clickedButton() == rebuildBtn:
                return 1
            else:
                return 2

        elif typ == oPB.MsgEnum.MS_QUEST_OKCANCEL:
            retval = QMessageBox.question(
                parent, translate("mainController", "Question"), msgtext,
                QMessageBox.Ok, QMessageBox.Cancel)
            if retval == QMessageBox.Cancel:
                return False
            else:
                return True

        elif typ == oPB.MsgEnum.MS_QUEST_PHRASE:
            text = QInputDialog.getText(
                parent, translate("mainController", "Additional information"),
                msgtext, QLineEdit.Normal, preload)
            return text

        elif typ == oPB.MsgEnum.MS_QUEST_PASS:
            text = QInputDialog.getText(
                parent, translate("mainController", "Additional information"),
                msgtext, QLineEdit.Password, preload)
            return text

        elif typ == oPB.MsgEnum.MS_QUEST_DEPOT:
            preselectlist = [
                i for i, j in enumerate(msgtext)
                if ConfigHandler.cfg.opsi_server in j
            ]
            if preselectlist:
                preselect = preselectlist[0]
            else:
                preselect = -1
            item = QInputDialog.getItem(
                parent, translate("mainController", "Question"),
                translate("mainController", "Select which depot to use:"),
                msgtext, preselect, False)
            return item

        elif typ == oPB.MsgEnum.MS_ABOUTQT:
            QMessageBox.aboutQt(parent, translate("mainController",
                                                  "About Qt"))
Exemple #5
0
    def msgbox(self, msgtext = "", typ = oPB.MsgEnum.MS_STAT, parent = None, preload = ""):
        """ Messagebox function

        Valid values for typ:
            * oPB.MsgEnum.MS_ERR -> Error message (status bar/ popup)
            * oPB.MsgEnum.MS_WARN -> Warning (status bar/ popup)
            * oPB.MsgEnum.MS_INFO -> Information (status bar/ popup)
            * oPB.MsgEnum.MS_STAT -> Information (only status bar)
            * oPB.MsgEnum.MS_ALWAYS -> Display this message ALWAYS, regardless of which message **typ** is deactivated via settings
            * oPB.MsgEnum.MS_PARSE -> just parse message text and return it
            * oPB.MsgEnum.MS_QUEST_YESNO
            * oPB.MsgEnum.MS_QUEST_CTC
            * oPB.MsgEnum.MS_QUEST_OKCANCEL
            * oPB.MsgEnum.MS_QUEST_PHRASE
            * oPB.MsgEnum.MS_QUEST_PASS
            * oPB.MsgEnum.MS_QUEST_DEPOT

        :param msgtext: Message text
        :param typ: type of message window, see oPB.core enums
        :param parent: parent ui of message box
        :param preload: pre-fill input boxes with this text
        """
        if parent is None:
            parent = self.ui

        # first parse text, is argument is str
        if type(msgtext) is str:
            msgtext = Helper.parse_text(msgtext)

        if typ == oPB.MsgEnum.MS_ERR:
            self.msgSend.emit(msgtext)
            if ConfigHandler.cfg.no_error_msg == "False":
                QMessageBox.critical(parent, translate("mainController", "Error"), msgtext, QMessageBox.Ok)

        elif typ == oPB.MsgEnum.MS_WARN:
            self.msgSend.emit(msgtext)
            if ConfigHandler.cfg.no_warning_msg == "False":
                QMessageBox.warning(parent, translate("mainController", "Warning"), msgtext, QMessageBox.Ok)

        elif typ == oPB.MsgEnum.MS_INFO:
            self.msgSend.emit(msgtext)
            if ConfigHandler.cfg.no_info_msg == "False":
                QMessageBox.information(parent, translate("mainController", "Message"), msgtext, QMessageBox.Ok)

        elif typ == oPB.MsgEnum.MS_STAT:
            self.msgSend.emit(msgtext)

        elif typ == oPB.MsgEnum.MS_ALWAYS:
            QMessageBox.information(parent, translate("mainController", "Message"), msgtext, QMessageBox.Ok)

        elif typ == oPB.MsgEnum.MS_PARSE:
            return msgtext

        elif typ == oPB.MsgEnum.MS_QUEST_YESNO:
            retval = QMessageBox.question(parent, translate("mainController", "Question"), msgtext, QMessageBox.Yes, QMessageBox.No)
            if retval == QMessageBox.No:
                return False
            else:
                return True

        elif typ == oPB.MsgEnum.MS_QUEST_CTC:
            msgBox = QMessageBox(parent)
            msgBox.setWindowTitle(translate("mainController", "Question"))
            msgBox.setText(msgtext)
            msgBox.setIcon(QMessageBox.Question)
            cancelBtn = QPushButton(translate("mainController", "Cancel"))
            rebuildBtn = QPushButton(translate("mainController", "Rebuild"))
            addBtn = QPushButton(translate("mainController", "Add version"))
            msgBox.addButton(cancelBtn, QMessageBox.RejectRole)
            msgBox.addButton(rebuildBtn, QMessageBox.AcceptRole)
            msgBox.addButton(addBtn, QMessageBox.AcceptRole)
            msgBox.exec_()
            if msgBox.clickedButton() == cancelBtn:
                return 0
            elif msgBox.clickedButton() == rebuildBtn:
                return 1
            else:
                return 2

        elif typ == oPB.MsgEnum.MS_QUEST_OKCANCEL:
            retval = QMessageBox.question(parent, translate("mainController", "Question"), msgtext, QMessageBox.Ok, QMessageBox.Cancel)
            if retval == QMessageBox.Cancel:
                return False
            else:
                return True

        elif typ == oPB.MsgEnum.MS_QUEST_PHRASE:
            text = QInputDialog.getText(parent, translate("mainController", "Additional information"),
                                          msgtext, QLineEdit.Normal, preload)
            return text

        elif typ == oPB.MsgEnum.MS_QUEST_PASS:
            text = QInputDialog.getText(parent, translate("mainController", "Additional information"),
                                          msgtext, QLineEdit.Password, preload)
            return text

        elif typ == oPB.MsgEnum.MS_QUEST_DEPOT:
            preselectlist = [i for i, j in enumerate(msgtext) if ConfigHandler.cfg.opsi_server in j]
            if preselectlist:
                preselect = preselectlist[0]
            else:
                preselect = -1
            item = QInputDialog.getItem(parent, translate("mainController", "Question"),
                                        translate("mainController", "Select which depot to use:"),
                                        msgtext, preselect, False)
            return item

        elif typ == oPB.MsgEnum.MS_ABOUTQT:
            QMessageBox.aboutQt(parent, translate("mainController", "About Qt"))