Ejemplo n.º 1
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
Ejemplo n.º 2
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
Ejemplo n.º 3
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
Ejemplo n.º 4
0
    def deleteEntryini(self):
        for k in self.inicontents:
            if k in self.selected["ini"]:
                errbox = QMessageBox()
                errbox.setText("Section headers cannot be deleted.")
                errbox.exec()
                return
        confirm = QMessageBox()
        msg = "The following keys will be deleted:\n"
        for key in self.selected["ini"]:
            msg += key[0] + "\n"
        msg += "Are you sure?"
        confirm.setText(msg)
        confirm.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
        if confirm.exec() != QMessageBox.Yes:
            return

        for item in self.selected["ini"]:
            for section in reversed(self.indices):
                if (item[1] + 1) > self.indices[section]:
                    self.inicontents[section].pop(item[0])
                    break

        msgbox = QMessageBox()
        msgbox.setText(
            f"Successfully removed {len(self.selected['ini'])} entries!")
        msgbox.exec()

        self.updateTables()
Ejemplo n.º 5
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()
Ejemplo n.º 6
0
    def deleteEntry(self):
        confirm = QMessageBox()
        msg = "The following entries will be deleted:\n"
        for path in self.selected["json"]:
            msg += path + "\n"
        msg += "Are you sure?"
        confirm.setText(msg)
        confirm.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
        if confirm.exec() != QMessageBox.Yes:
            return

        delfiles = False
        confirm = QMessageBox()
        confirm.setText(
            f"Would you like to delete the folder{'s' if len(self.selected['json']) > 1 else ''} on disk as well?"
        )
        confirm.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
        if confirm.exec() == QMessageBox.Yes:
            delfiles = True

        todel = []
        for repo in enumerate(self.repos):
            if repo[1][0] in self.selected['json']:
                todel.append(repo[0])
        todel.reverse()
        for i in todel:
            self.repos.pop(i)
            if delfiles:
                os.rmdir(self.repos[i][0])

        msgbox = QMessageBox()
        msgbox.setText(f"Successfully removed {len(todel)} entries!")
        msgbox.exec()

        self.updateTables()
Ejemplo n.º 7
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')
Ejemplo n.º 8
0
Archivo: ui.py Proyecto: 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_()
Ejemplo n.º 9
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
Ejemplo n.º 10
0
    def checkAndSaveChanges(self):
        old, oldini = {}, {}
        if open(self.json_path).read() != '':
            old = json.load(open(self.json_path))
        else:
            old = {"repos": [], "sysupdates": []}

        if open(self.ini_path).read() != '':
            oldini = configparser.ConfigParser().read(self.ini_path)
        else:
            oldini = {}

        if (old["repos"] == self.repos and old["sysupdates"] == self.sysupdates) or \
                (oldini == self.inicontents):
            pass
        else:
            confirm = QMessageBox()
            confirm.setText(
                "You have unsaved changes. Would you like to save them now?")
            confirm.setStandardButtons(QMessageBox.Yes | QMessageBox.No
                                       | QMessageBox.Cancel)
            ret = confirm.exec()
            if ret == QMessageBox.Cancel:
                return 1
            elif ret == QMessageBox.Yes:
                self.apply()
Ejemplo n.º 11
0
    def inputChanged(self, content):
        path = Path(content)

        if not (content and path.exists()):
            return
        if self._input_folder == path:
            return

        self.reset()

        # read file list
        self._input_folder = path
        glob = (p for p in path.rglob("*") if p.is_file())
        files = [str(p.relative_to(path)) for p in islice(glob, 50)]
        self.list_input_files.addItems(files)
        self._network.add_nodes_from(files)

        # read more files
        remains = True
        try:
            remains = next(glob)
        except StopIteration:
            remains = False

        if remains:
            msgbox = QMessageBox(self)
            msgbox.setIcon(QMessageBox.Warning)
            msgbox.setText("There are too many files in the directory.")
            msgbox.setInformativeText("Do you still want to list them?")
            msgbox.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
            msgbox.setDefaultButton(QMessageBox.No)

            if msgbox.exec_() != QMessageBox.Yes:
                self.reset()
                return

            self.list_input_files.addItem(str(remains.relative_to(path)))
            self._network.add_node(str(remains.relative_to(path)))

            files = [str(p.relative_to(path)) for p in glob]
            self.list_input_files.addItems(files)
            self._network.add_nodes_from(files)

        # generate keywords
        keywords = set()
        keypattern = re.compile(global_config.organizer.keyword_splitter)
        keywords.update(k.strip() for k in keypattern.split(path.name)
                        if k.strip())
        if len(os.listdir(path)) == 0:
            subf = next(path.iterdir())
            if subf.is_dir():
                keywords.update(k.strip() for k in keypattern.split(subf.name)
                                if k.strip())
        # TODO: extract metadata from input audio files
        self.widget_keywords.extendKeywords(keywords)

        # default output path
        if not global_config.organizer.default_output_dir:
            self.txt_output_path.setText(str(path.parent / "organized"))
Ejemplo n.º 12
0
def showErrorDialog(message):
    box = QMessageBox()
    box.setIcon(QMessageBox.Critical)
    box.setText(message)
    box.setWindowTitle("puya-dl")
    box.setStandardButtons(QMessageBox.Ok)

    return box.exec_()
Ejemplo n.º 13
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()
Ejemplo n.º 14
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()
Ejemplo n.º 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_()
Ejemplo n.º 16
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
Ejemplo n.º 17
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_()
Ejemplo n.º 18
0
    def addNewRepo(path, remote, hexcolour, repos, quiet=False):
        if os.path.exists(path):
            if os.path.isfile(path) or os.listdir(path):
                if quiet:
                    print("Path must be an empty directory")
                else:
                    errbox = QMessageBox()
                    errbox.setText("Path must be an empty directory")
                    errbox.exec()
                return 1
        else:
            if os.path.exists(path[:path.rindex('/')]):
                if quiet:
                    print(
                        "Specified folder does not exist but is in a valid directory."
                    )
                    if input(
                            "Would you like to create the folder and clone the repository there? [Y/N]: "
                    ).lower().strip() != 'y':
                        print("Exiting.")
                        return 1
                    os.mkdir(path)
                else:
                    errbox = QMessageBox()
                    errbox.setText(
                        "Specified folder does not exist but is in a valid directory.\n"
                        "Would you like to create the folder and clone the repository there?"
                    )
                    errbox.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
                    errbox.setDefaultButton(QMessageBox.Yes)
                    if errbox.exec() == QMessageBox.No:
                        return 1
                    os.mkdir(path)
            else:
                if quiet:
                    print("Path not found")
                else:
                    errbox = QMessageBox()
                    errbox.setText("Path not found")
                    errbox.exec()
                return 1

        os.system(f"git clone '{remote}' '{path}' -v"
                  )  # forget it im not dealing with gitpythons bs
        repos.append([path, int(hexcolour, 16)])

        if quiet:
            print(f"Repository successfully cloned to {path}")
        else:
            msgbox = QMessageBox()
            msgbox.setText(f"Repository successfully cloned to {path}")
            msgbox.exec()
        return
Ejemplo n.º 19
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()
Ejemplo n.º 20
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()
Ejemplo n.º 21
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
Ejemplo n.º 22
0
def question_dialog(msg: str) -> QMessageBox:
    """
    Creates a default question dialog box.

    :param msg: The question which the user is asked.
    :type msg: str
    :return: The created dialog.
    :rtype: QMessageBox
    """
    msg_box = QMessageBox()
    msg_box.setText(msg)
    msg_box.setStandardButtons(QMessageBox.Yes | QMessageBox.Cancel)
    msg_box.setDefaultButton(QMessageBox.Yes)
    msg_box.setIcon(QMessageBox.Question)
    return msg_box
Ejemplo n.º 23
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_()
Ejemplo n.º 24
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()
Ejemplo n.º 25
0
def message_dialog(msg: str, type: QMessageBox.Icon) -> QMessageBox:
    """
    Creates a default message dialog box.

    :param msg: The message which should be communicated to the user.
    :type msg: str
    :param type: The type of the message.
    :type type: QMessageBox.Icon
    :return: The created dialog.
    :rtype: QMessageBox
    """
    msg_box = QMessageBox()
    msg_box.setText(msg)
    msg_box.setStandardButtons(QMessageBox.Ok)
    msg_box.setDefaultButton(QMessageBox.Ok)
    msg_box.setIcon(type)
    return msg_box
Ejemplo n.º 26
0
 def connect_emulator(self):
     if self.hook.running:
         box = QMessageBox()
         box.setIcon(QMessageBox.Information)
         box.setWindowTitle("Already Connected")
         box.setText("Already connected. Disconnect first.")
         box.setStandardButtons(QMessageBox.Ok)
         box.exec_()
         return
     pids = hook.get_emu_process_ids()
     if len(pids) == 0:
         box = QMessageBox()
         box.setIcon(QMessageBox.Information)
         box.setWindowTitle("No Emulators Detected")
         box.setText("No emulators that can be connected to were detected.")
         box.setStandardButtons(QMessageBox.Ok)
         box.exec_()
         return
     ConnectEmuDialog(pids, self).exec_()
Ejemplo n.º 27
0
 def connect_pc(self):
     if self.hook.running:
         box = QMessageBox()
         box.setIcon(QMessageBox.Information)
         box.setWindowTitle("Already Connected")
         box.setText("Already connected. Disconnect first.")
         box.setStandardButtons(QMessageBox.Ok)
         box.exec_()
         return
     pid = hook.get_pc_process_id()
     if pid is None:
         box = QMessageBox()
         box.setIcon(QMessageBox.Information)
         box.setWindowTitle("FF7 PC Not Detected")
         box.setText("FF7 PC was not detected.")
         box.setStandardButtons(QMessageBox.Ok)
         box.exec_()
         return
     self.hook.hooked_platform = hook.Hook.PC_PLATFORM
     self.hook.hooked_process_id = pid
     self.hook.start()
Ejemplo n.º 28
0
    def showInvalidPermissionsErrorDialog(self: Any) -> 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 the game directory.</b>
            </p>
            <p style="margin:10px 15px 10px 5px;">
                Please restart w3modmanager to try to automatically fix the permissions,
                or fix the permissions manually.
            </p>
        ''')
        messagebox.setTextFormat(Qt.RichText)
        messagebox.setIconPixmap(messagebox.windowIcon().pixmap(
            messagebox.windowIcon().actualSize(QSize(64, 64))))
        messagebox.setStandardButtons(QMessageBox.Ok)
        messagebox.layout().setContentsMargins(5, 5, 5, 5)

        messagebox.setModal(True)
        messagebox.open()
        return messagebox
Ejemplo n.º 29
0
    def connectArduino(self):
        try:
            self.arduino = serial.Serial(port='COM3',
                                         baudrate=115200,
                                         timeout=1)
            self.arduino.setDTR(True)
            time.sleep(.5)
            self.run = True
            self.utimer.start(500)
            self.show()

        except:
            msg = QMessageBox()
            msg.setIcon(QMessageBox.Critical)

            msg.setText(
                "The Arduino does not appear to be connected, please ensure it is connected and powered on. Also please make sure it is associated to COM3 in device manager. Then press Ok to retry."
            )
            msg.setWindowTitle("Connection Error")
            msg.setStandardButtons(QMessageBox.Ok)
            msg.buttonClicked.connect(self.connectArduino)
            retval = msg.exec_()
Ejemplo n.º 30
0
    def debug_show_obj_data_current_frame(self):
        objs_in_frame = self.tracker.video_data.get_object_points(
            self.tracker.video_data.current_frame - 1)
        total_objs = len(objs_in_frame)

        msg = QMessageBox()
        msg.setIcon(QMessageBox.Information)
        msg.setText("Total objects in frame: " + str(total_objs) + "\n\n" +
                    "First three objects:\n" + "(" + str(objs_in_frame[0][0]) +
                    ", " + str(objs_in_frame[0][1]) + ") Width: " +
                    str(objs_in_frame[0][2]) + ", Height: " +
                    str(objs_in_frame[0][3]) + "\n" + "(" +
                    str(objs_in_frame[1][0]) + ", " +
                    str(objs_in_frame[1][1]) + ") Width: " +
                    str(objs_in_frame[1][2]) + ", Height: " +
                    str(objs_in_frame[1][3]) + "\n" + "(" +
                    str(objs_in_frame[2][0]) + ", " +
                    str(objs_in_frame[2][1]) + ") Width: " +
                    str(objs_in_frame[2][2]) + ", Height: " +
                    str(objs_in_frame[2][3]))
        msg.setWindowTitle("Objects in current frame")
        msg.setStandardButtons(QMessageBox.Ok)
        msg.exec_()