示例#1
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
示例#2
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()
示例#3
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"))
示例#4
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()
示例#5
0
文件: main.py 项目: bbq12340/naver
 def handleFinished(self):
     self.ui.startButton.setEnabled(True)
     self.ui.progressBar.setValue(0)
     msgBox = QMessageBox()
     msgBox.setIcon(QMessageBox.Information)
     msgBox.setText("수집이 완료되었습니다.")
     msgBox.setDefaultButton(QMessageBox.Ok)
     ret = msgBox.exec_()
     if ret == QMessageBox.Ok:
         path = os.getcwd() + "/result"
         webbrowser.open('file:///' + path)
示例#6
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
示例#7
0
文件: utility.py 项目: tmahlburg/tfm
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
示例#8
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()
示例#9
0
文件: utility.py 项目: tmahlburg/tfm
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