Example #1
0
    def showAboutDialog(self: Any) -> QMessageBox:
        messagebox = QMessageBox(self)
        messagebox.setWindowTitle('About' if self else getTitleString('About'))
        messagebox.setText(f'''
            <p style="margin:0 15px 0 0;">
            <b>{w3modmanager.TITLE} {w3modmanager.VERSION}</b>
            <small>{f'({w3modmanager.VERSION_HASH})' if w3modmanager.VERSION_HASH else ''}</small><br>
            {w3modmanager.SUBTITLE}<br>
            <br>
            For updates and information visit <br>
            <a href="{w3modmanager.URL_WEB}" style="text-decoration:none;">\
                {removeUrlScheme(w3modmanager.URL_WEB)}\
            </a><br>
            <br>
            Thank you for using {w3modmanager.TITLE}!
            </p>
            ''')
        # TODO: enhancement: check if new version is available
        messagebox.setTextFormat(Qt.RichText)
        messagebox.setIconPixmap(messagebox.windowIcon().pixmap(
            messagebox.windowIcon().actualSize(QSize(64, 64))))
        messagebox.setMinimumSize(QSize(500, 500))
        messagebox.setStandardButtons(QMessageBox.Ok)
        messagebox.setAttribute(Qt.WA_DeleteOnClose)
        messagebox.layout().setContentsMargins(5, 5, 5, 5)

        messagebox.setModal(True)
        messagebox.open()
        return messagebox
Example #2
0
File: ui.py Project: roadroot/chess
 def showDialog(self, text: str, title: str, buttons, callback):
     dialog = QMessageBox(self.window)
     dialog.setWindowTitle(title)
     dialog.setText(text)
     dialog.setStandardButtons(buttons)
     dialog.buttonClicked.connect(callback)
     dialog.exec_()
Example #3
0
 def aboutButton(self):
     aboutMessageBox = QMessageBox(self)
     aboutMessageBox.setWindowModality(Qt.NonModal)
     aboutMessageBox.setWindowTitle("About this program")
     aboutMessageBox.setText("<h5>About content</h5>")
     aboutMessageBox.setIcon(QMessageBox.Information)
     aboutMessageBox.open()
Example #4
0
    def showCritcalErrorDialog(self: Any,
                               error: str = '',
                               details: str = '') -> QMessageBox:
        import traceback
        messagebox = QMessageBox(self)
        messagebox.setWindowTitle(
            'Critical Error' if self else getTitleString('Critical Error'))
        messagebox.setText(f'''
            <p><strong>\
                Something unexpected happened. {'Detailed error message:' if error else ''}\
            </strong></p>
            {f'<p><code>{error}</code></p>' if error else ''}
            <p><small>
                Please check if this is a known issue or create a report \
                detailing the conditions of this error here:<br>
                <a href="{w3modmanager.URL_ISSUES}" style="text-decoration:none;">
                    {removeUrlScheme(w3modmanager.URL_ISSUES)}
                </a>
            </small></p>
            ''')
        if error:
            messagebox.setDetailedText(
                details if details else traceback.format_exc())
        messagebox.setIconPixmap(messagebox.windowIcon().pixmap(
            messagebox.windowIcon().actualSize(QSize(64, 64))))
        messagebox.layout().setContentsMargins(5, 5, 5, 5)

        messagebox.setModal(True)
        messagebox.open()
        return messagebox
Example #5
0
def main():
    sys.excepthook = exception_logger
    os.environ['QT_MAC_WANTS_LAYER'] = '1'    # Workaround for https://bugreports.qt.io/browse/QTBUG-87014

    error = init_and_check_db(get_app_path())

    if error.code == LedgerInitError.EmptyDbInitialized:  # If DB was just created from SQL - initialize it again
        error = init_and_check_db(get_app_path())

    app = QApplication([])
    language = JalDB().get_language_code(JalSettings().getValue('Language', default=1))
    translator = QTranslator(app)
    language_file = get_app_path() + Setup.LANG_PATH + os.sep + language + '.qm'
    translator.load(language_file)
    app.installTranslator(translator)

    if error.code == LedgerInitError.OutdatedDbSchema:
        error = update_db_schema(get_app_path())
        if error.code == LedgerInitError.DbInitSuccess:
            error = init_and_check_db(get_app_path())

    if error.code != LedgerInitError.DbInitSuccess:
        window = QMessageBox()
        window.setAttribute(Qt.WA_DeleteOnClose)
        window.setWindowTitle("JAL: Start-up aborted")
        window.setIcon(QMessageBox.Critical)
        window.setText(error.message)
        window.setInformativeText(error.details)
    else:
        window = MainWindow(language)
    window.show()

    app.exec()
    app.removeTranslator(translator)
Example #6
0
    def show_update_info(info: dict):
        print(info)

        html_url = info.get('html_url', '')
        content = [
            f'New v{info.get("version")} (Now v{VERSION})',
            info.get('name', ''),
            html_url,
        ]
        title = 'Update available, download now?'

        msg = QMessageBox()
        msg.setIcon(QMessageBox.Information)

        msg.setText(title)
        msg.setInformativeText('\n\n'.join(content))
        msg.setWindowTitle(title)
        msg.setDetailedText(info.get('desc', ''))
        msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No)

        btn_ret = msg.exec_()

        if btn_ret == QMessageBox.Yes:
            print('Yes clicked.')
            open_url(html_url)
        elif btn_ret == QMessageBox.Ok:
            print('Ok clicked.')
        elif btn_ret == QMessageBox.No:
            print('No clicked.')
        elif btn_ret == QMessageBox.Cancel:
            print('Cancel')
Example #7
0
    def showOtherInstanceDialog(self: Any) -> QMessageBox:
        messagebox = QMessageBox(self)
        messagebox.setWindowTitle(
            'Other instance' if self else getTitleString('Other instance'))
        messagebox.setText(f'''
            <p style="margin:10px 15px 10px 5px;">
                <b>Another instance of the application is currently running.</b>
            </p>
            <p style="margin:10px 15px 10px 5px;">
                Only one instance should be opened at the same time<br>
                to prevent data corruption.
            </p>
            <p style="margin:10px 15px 10px 5px;">
                Continue anyway?
            </p>
        ''')
        messagebox.setTextFormat(Qt.RichText)
        messagebox.setIconPixmap(messagebox.windowIcon().pixmap(
            messagebox.windowIcon().actualSize(QSize(64, 64))))
        messagebox.setStandardButtons(QMessageBox.Yes | QMessageBox.Cancel)
        messagebox.setDefaultButton(QMessageBox.Cancel)
        messagebox.layout().setContentsMargins(5, 5, 5, 5)

        messagebox.setModal(True)
        messagebox.open()
        return messagebox
Example #8
0
    def showInvalidPermissionsDialog(self: Any, path: Path) -> QMessageBox:
        messagebox = QMessageBox(self)
        messagebox.setWindowTitle('Invalid permissions' if self else
                                  getTitleString('Invalid permissions'))
        messagebox.setText(f'''
            <p style="margin:10px 15px 10px 5px;">
                <b>Invalid permissions for directory:</b>
            </p>
            <p style="margin:10px 15px 10px 5px;">
                <code>{path}</code>
            </p>
            <p style="margin:10px 15px 10px 5px;">
                Write permissions to this directory are required for mod management.<br>
                Automatically set the correct permissions?
            </p>
        ''')
        messagebox.setTextFormat(Qt.RichText)
        messagebox.setIconPixmap(messagebox.windowIcon().pixmap(
            messagebox.windowIcon().actualSize(QSize(64, 64))))
        messagebox.setStandardButtons(QMessageBox.Yes | QMessageBox.Cancel)
        messagebox.layout().setContentsMargins(5, 5, 5, 5)

        messagebox.setModal(True)
        messagebox.open()
        return messagebox
Example #9
0
    def showInvalidConfigErrorDialog(self: Any) -> QMessageBox:
        messagebox = QMessageBox(self)
        messagebox.setWindowTitle('Invalid game path' if self else
                                  getTitleString('Invalid game path'))
        messagebox.setText(f'''
            <p style="margin:10px 15px 10px 5px;"><b>Invalid game or config path.</b><br>
                Please restart w3modmanager and enter the paths of<br>
                your The Witcher 3 installation and the game config folder<br>
                (usually <code>User/Documents/The Witcher 3</code>).
            </p>
            <p style="margin:10px 15px 10px 5px;"><small>
                For updates and information visit <br>
                <a href="{w3modmanager.URL_WEB}" style="text-decoration:none;">\
                    {removeUrlScheme(w3modmanager.URL_WEB)}\
                </a>
            </small></p>
            ''')
        messagebox.setTextFormat(Qt.RichText)
        messagebox.setIconPixmap(messagebox.windowIcon().pixmap(
            messagebox.windowIcon().actualSize(QSize(64, 64))))
        messagebox.setStandardButtons(QMessageBox.Ok)
        messagebox.setAttribute(Qt.WA_DeleteOnClose)
        messagebox.layout().setContentsMargins(5, 5, 5, 5)

        messagebox.setModal(True)
        messagebox.open()
        return messagebox
Example #10
0
    def safeClose(self):
        check_folder = False
        for i in range(self.tab_folders.count()):
            if len(self.tab_folders.widget(i).model()) > 0:
                check_folder = True
                break

        if not (check_folder or self._executing):
            self.close()
            return

        msgbox = QMessageBox(self)
        msgbox.setWindowTitle("Close")
        msgbox.setIcon(QMessageBox.Warning)
        if self._executing:
            msgbox.setText(
                "There are pending jobs. Do you really want to close?")
        else:
            msgbox.setText("Do you really want to close?")
        msgbox.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
        msgbox.setDefaultButton(QMessageBox.No)

        if msgbox.exec_() == QMessageBox.Yes:
            if self._task is not None:
                self._task.cancel()
            self.close()
Example #11
0
 def message_box_error(self, title, text, error=None):
     message = QMessageBox(self, title, text)
     message.setIcon(QMessageBox.Warning)
     message.setWindowTitle(title)
     message.setText(text)
     if error is not None:
         message.setDetailedText(str(error))
     message.exec_()
Example #12
0
 def show_success(self):
     box = QMessageBox()
     box.setWindowTitle('Export Complete')
     box.setWindowIcon(self.icon)
     box.setText(
         'Success. The file has been exported and should show up in the same folder as this program.\n\nDCC by Gideon Tong v1.0'
     )
     box.exec_()
Example #13
0
def gui_exception_hook(exc_type, value, traceback):
    msg = QMessageBox()
    msg.setIcon(QMessageBox.Critical)
    msg.setText(str(value))
    msg.setInformativeText(''.join(
        tb.format_exception(exc_type, value, traceback)))
    msg.setWindowTitle(exc_type.__name__)
    msg.exec()
Example #14
0
def showErrorDialog(message):
    box = QMessageBox()
    box.setIcon(QMessageBox.Critical)
    box.setText(message)
    box.setWindowTitle("puya-dl")
    box.setStandardButtons(QMessageBox.Ok)

    return box.exec_()
Example #15
0
def showSimpleDialog(message):
    box = QMessageBox()
    box.setIcon(QMessageBox.Question)

    box.setText(message)
    box.setWindowTitle("puya-dl")
    box.setStandardButtons(QMessageBox.Cancel | QMessageBox.Ok)

    return box.exec_()
    def prompt_calc_dvh(self):
        """
        Windows displays buttons in a different order from Linux. A check for
        platform is performed to ensure consistency of button positioning across
        platforms.
        """
        message = "DVHs not present in RTDOSE or do not correspond to ROIs. "
        message += "Would you like to calculate DVHs? (This may take up to "
        message += "several minutes on some systems.)"
        if platform.system() == "Linux":
            choice = QMessageBox.question(self, "Calculate DVHs?", message,
                                          QMessageBox.Yes | QMessageBox.No)

            if choice == QMessageBox.Yes:
                self.signal_advise_calc_dvh.emit(True)
            else:
                self.signal_advise_calc_dvh.emit(False)
        else:
            stylesheet_path = ""

            # Select appropriate style sheet
            if platform.system() == 'Darwin':
                stylesheet_path = Path.cwd().joinpath('res', 'stylesheet.qss')
            else:
                stylesheet_path = Path.cwd().joinpath(
                    'res', 'stylesheet-win-linux.qss')

            # Create a message box and add attributes
            mb = QMessageBox()
            mb.setIcon(QMessageBox.Question)
            mb.setWindowTitle("Calculate DVHs?")
            mb.setText(message)
            button_no = QtWidgets.QPushButton("No")
            button_yes = QtWidgets.QPushButton("Yes")

            # We want the buttons 'No' & 'Yes' to be displayed in that
            # exact order. QMessageBox displays buttons in respect to
            # their assigned roles. (0 first, then 1 and so on)
            # 'AcceptRole' is 0 and 'RejectRole' is 1 thus by assigning
            # 'No' to 'AcceptRole' and 'Yes' to 'RejectRole' the buttons
            # are positioned as desired.
            mb.addButton(button_no, QtWidgets.QMessageBox.AcceptRole)
            mb.addButton(button_yes, QtWidgets.QMessageBox.RejectRole)

            # Apply stylesheet to the message box and add icon to the window
            mb.setStyleSheet(open(stylesheet_path).read())
            mb.setWindowIcon(
                QtGui.QIcon(
                    resource_path(Path.cwd().joinpath('res', 'images',
                                                      'btn-icons',
                                                      'onkodicom_icon.png'))))
            mb.exec_()

            if mb.clickedButton() == button_yes:
                self.signal_advise_calc_dvh.emit(True)
            else:
                self.signal_advise_calc_dvh.emit(False)
Example #17
0
 def helpButton(self):
     helpMessageBox = QMessageBox(self)
     helpMessageBox.setWindowTitle("Help")
     helpMessageBox.setText(
         '<h5>Please open this link for help</h5>'
         '<a href="https://github.com/pirlite2/EEE231-group-A/blob/main/README.md">'
         'link')
     helpMessageBox.setIcon(QMessageBox.Information)
     helpMessageBox.open()
Example #18
0
def information_message_box(win_title: str, msg: str):
    msg_box = QMessageBox()
    msg_box.setIcon(QMessageBox.Information)
    msg_box.setWindowIcon(QIcon(str(pkg_data.LOGO)))

    msg_box.setText(msg)
    msg_box.setWindowTitle(win_title)
    msg_box.setStandardButtons(QMessageBox.Ok)
    msg_box.exec()
Example #19
0
 def alert_message(self, header: str, text: str):
     msg = QMessageBox()
     msg.setIcon(QMessageBox.Information)
     msg.setWindowTitle("Alert")
     msg.setText(header)
     msg.setInformativeText(text)
     msg.setStandardButtons(QMessageBox.Ok)
     msg.setDefaultButton(QMessageBox.Ok)
     msg.exec()
Example #20
0
def error_msg(error_message):
    message = QMessageBox()
    message.setText(
        "There was a problem processing your file. Please click more details for more information."
    )
    message.setInformativeText(error_message)
    message.setWindowTitle("Error processing file")
    message.setDetailedText(error_message)
    message.setStandardButtons(QMessageBox.Ok)
    QApplication.setOverrideCursor(QCursor(Qt.ArrowCursor))
    message.exec_()
Example #21
0
def question_message_box(win_title: str, msg: str):
    msg_box = QMessageBox()
    msg_box.setIcon(QMessageBox.Question)
    msg_box.setWindowIcon(QIcon(str(pkg_data.LOGO)))

    msg_box.setText(msg)
    msg_box.setWindowTitle(win_title)
    msg_box.setStandardButtons(QMessageBox.Yes | QMessageBox.No
                               | QMessageBox.Cancel)
    reply = msg_box.exec()
    return reply
Example #22
0
    def closeEvent(self, event):
        close_dialog = QMessageBox(self)
        close_dialog.setWindowTitle("Team Editor")
        close_dialog.setText("Do you wish to close the editor?")
        close_dialog.setStandardButtons(QMessageBox.Yes | QMessageBox.No)

        response = close_dialog.exec()

        if response == QMessageBox.Yes:
            event.accept()
        else:
            event.ignore()
Example #23
0
 def showAboutWindow(self):
     about_box = QMessageBox(self)
     about_box.setAttribute(Qt.WA_DeleteOnClose)
     about_box.setWindowTitle(self.tr("About"))
     title = self.tr("<h3>JAL</h3><p>Just Another Ledger, version {version}</p>".format(version=__version__))
     about_box.setText(title)
     about = self.tr("<p>More information, manuals and problem reports are at "
                     "<a href=https://github.com/titov-vv/jal>github home page</a></p>"
                     "<p>Questions, comments, help or donations:</p>"
                     "<p><a href=mailto:[email protected]>[email protected]</a></p>"
                     "<p><a href=https://t.me/jal_support>Telegram</a></p>")
     about_box.setInformativeText(about)
     about_box.show()
Example #24
0
    def GeneratedDialog(self):

        self.statusBar().showMessage('Tablecloth generated. Happy rigging!')
        self.statusBar().removeWidget(self.progress_bar)
        # Now you can go back to rigging
        self.ChangeAppStatus(True)

        mbox = QMessageBox()

        mbox.setWindowTitle("Tablecloth Generator")
        mbox.setText("Tablecloth Generated!")
        mbox.setStandardButtons(QMessageBox.Ok)

        mbox.exec()
Example #25
0
 def showContinueSearchDialog(self, searchlimit: int) -> bool:
     messagebox = QMessageBox(self)
     messagebox.setWindowTitle('Unusual search depth')
     messagebox.setText(f'''
         <p>No mod detected after searching through {searchlimit} directories.</p>
         <p>Are you sure this is a valid mod?</p>
         ''')
     messagebox.setTextFormat(Qt.RichText)
     messagebox.setStandardButtons(QMessageBox.Cancel)
     yes: QPushButton = QPushButton(' Yes, continue searching ', messagebox)
     yes.setAutoDefault(True)
     yes.setDefault(True)
     messagebox.addButton(yes, QMessageBox.YesRole)
     messagebox.exec_()
     return messagebox.clickedButton() == yes
Example #26
0
    def choose_move(self, active_player: int, game_state: GameState):
        # noinspection PyBroadException
        try:
            if self.player.player_number != active_player:
                return

            move = self.player.choose_move(game_state)
            # noinspection PyUnresolvedReferences
            self.move_chosen.emit(move)  # type: ignore
        except Exception:
            print_exc()
            message = QMessageBox()
            message.setWindowTitle('Error')
            message.setText(f'Failed to choose a move.')
            message.exec_()
Example #27
0
    def delete_timeline(self):
        # Check for user confirmation
        confirm_dialog = QMessageBox()
        confirm_dialog.setIcon(QMessageBox.Warning)
        confirm_dialog.setWindowTitle("Confirm Delete")
        confirm_dialog.setText("Are you sure?")
        confirm_dialog.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)
        confirm_dialog.setDefaultButton(QMessageBox.Cancel)

        if confirm_dialog.exec_() == QMessageBox.Cancel:
            return

        selected_timeline = self.ui.timelineList.currentItem().text()

        self.timeline_manager.delete_timeline(selected_timeline)
        self.update_timelines()
Example #28
0
def open_url(url: str):
    try:
        # QDesktopServices.openUrl(QUrl(url))
        pass
    except Exception as e:
        msg = QMessageBox()
        msg.setIcon(QMessageBox.Critical)

        title = 'Network error: No connection'
        msg.setText(title)
        msg.setInformativeText('Please check your network connection.')
        msg.setWindowTitle(title)
        msg.setDetailedText(e)
        msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No)

        msg.exec_()
Example #29
0
 def show_choice(text="",
                 confirm_text="确认",
                 deny_text="取消",
                 confirm_cb=None,
                 deny_cb=None):
     box = QMessageBox()
     box.setWindowTitle(Message.LEVEL_NAMES[Level.Info.value])
     box.setWindowIcon(QIcon(GResource.icon_window))
     box.setText(text)
     box.addButton(confirm_text, QMessageBox.AcceptRole)
     box.addButton(deny_text, QMessageBox.RejectRole)
     reply = box.exec_()
     if reply == QMessageBox.AcceptRole:
         Globals.call(confirm_cb)
     elif reply == QMessageBox.RejectRole:
         Globals.call(deny_cb)
Example #30
0
    def slot_save(self) -> None:
        save_all_databases()

        # Misuse message dialog as notification https://stackoverflow.com/a/43134238
        msgbox = QMessageBox(self)
        msgbox.setWindowTitle('Save')
        msgbox.setText('Saved pointers, constraints and annotations.')
        msgbox.setModal(False)
        msgbox.show()

        # Automatically hide dialog after half a second
        timer = QTimer(self)
        timer.timeout.connect(msgbox.close)
        timer.timeout.connect(timer.stop)
        timer.timeout.connect(timer.deleteLater)
        timer.start(500)