Ejemplo n.º 1
0
    def __init__(self, IMC, parent=None):
        super(QDialog, self).__init__(parent)
        self.IMC = IMC
        self.setModal(True)
        self.setSizeGripEnabled(True)
        bookinfo = QFileInfo(IMC.bookPath)
        self.setWindowTitle("Properties of {0}".format(bookinfo.fileName()))
        # Our layout is a vertical stack of widgets and hboxes
        vlayout = QVBoxLayout()
        # Add the path information field
        fplb = QLabel("Path: {0}".format(unicode(bookinfo.path())))
        fplb.setFrameStyle(QFrame.Sunken)
        fplb.setToolTip(QString("Full path to document"))
        vlayout.addWidget(fplb)
        # Add the write-encoding choice, setting the buttons to reflect
        # the current value. We build this up from the inside out.
        # Two radio buttons. As they will be exclusive we need connect
        # the toggled() signal from only one of them.
        self.saveEncoding = self.IMC.bookSaveEncoding
        rb_enc_utf = QRadioButton(QString("UTF-8"))
        rb_enc_utf.setChecked(self.saveEncoding == rb_enc_utf.text())
        rb_enc_utf.toggled.connect(self.encodingChange)
        rb_enc_ltn = QRadioButton(QString("Latin-1"))
        rb_enc_ltn.setChecked(self.saveEncoding != rb_enc_utf.text())
        # put the buttons in a layout because groupbox doesn't act as one
        hb_enc_btns = QHBoxLayout()
        hb_enc_btns.addWidget(rb_enc_utf)
        hb_enc_btns.addWidget(rb_enc_ltn)
        # add to groupbox to get exclusivity on the buttons
        gb_enc = QGroupBox()
        gb_enc.setLayout(hb_enc_btns)
        # put in horizontal box with descriptive label, and add to the dialog
        hb_enc = QHBoxLayout()
        lb_enc = QLabel("Write Encoding")
        lb_enc.setToolTip("Character encoding when writing the document")
        hb_enc.addWidget(lb_enc)
        hb_enc.addWidget(gb_enc)
        vlayout.addLayout(hb_enc)

        # Next get a QStringList of available dicts from pqSpell
        # and create a combobox with that content.
        dictlist = IMC.spellCheck.dictList()
        dictlist.sort()
        self.maintag = self.IMC.bookMainDict
        if self.maintag.isEmpty():
            self.maintag = self.IMC.spellCheck.mainTag
        current = dictlist.indexOf(QString(self.maintag))  # index of current dict or -1
        self.cb_dic = QComboBox()
        self.cb_dic.addItems(dictlist)
        if current >= 0:
            self.cb_dic.setCurrentIndex(current)
        self.cb_dic.activated.connect(self.dictChange)

        hb_dic = QHBoxLayout()
        hb_dic.addWidget(QLabel("Main Dictionary"))
        hb_dic.addStretch()
        hb_dic.addWidget(self.cb_dic)
        vlayout.addLayout(hb_dic)

        # create the [ apply cancel ] buttons, but apply == accept
        apply_button = QPushButton("Apply")
        cancel_button = QPushButton("Cancel")
        cancel_button.setDefault(True)
        bbox = QDialogButtonBox()
        bbox.addButton(cancel_button, QDialogButtonBox.RejectRole)
        bbox.addButton(apply_button, QDialogButtonBox.AcceptRole)
        bbox.accepted.connect(self.applyButtonHit)
        bbox.rejected.connect(self.cancelButtonHit)
        vlayout.addWidget(bbox)

        self.setLayout(vlayout)
Ejemplo n.º 2
0
class AudioVideoTab(QWidget):
    def __init__(self, parent):
        super(AudioVideoTab, self).__init__(parent)
        self.parent = parent
        self.name = 'AudioVideo'
        self.formats = [
            '3gp', 'aac', 'ac3', 'afc', 'aiff', 'amr', 'asf', 'au', 'avi',
            'dvd', 'flac', 'flv', 'mka', 'mkv', 'mmf', 'mov', 'mp3', 'mp4',
            'mpg', 'ogg', 'ogv', 'psp', 'rm', 'spx', 'vob', 'wav', 'webm',
            'wma', 'wmv'
        ]
        self.extra_formats = [
            'aifc', 'm2t', 'm4a', 'm4v', 'mp2', 'mpeg', 'ra', 'ts'
        ]

        nochange = self.tr('No Change')
        frequency_values = [nochange, '22050', '44100', '48000']
        bitrate_values = [
            nochange, '32', '96', '112', '128', '160', '192', '256', '320'
        ]
        pattern = QRegExp(r'^[1-9]\d*')
        validator = QRegExpValidator(pattern, self)

        converttoLabel = QLabel(self.tr('Convert to:'))
        self.extComboBox = QComboBox()
        self.extComboBox.addItems(self.formats + [self.tr('Other')])
        self.extComboBox.setMinimumWidth(130)
        self.extLineEdit = QLineEdit()
        self.extLineEdit.setMaximumWidth(85)
        self.extLineEdit.setEnabled(False)
        hlayout1 = pyqttools.add_to_layout(QHBoxLayout(), converttoLabel, None,
                                           self.extComboBox, self.extLineEdit)
        commandLabel = QLabel(self.tr('Command:'))
        self.commandLineEdit = QLineEdit()
        self.presetButton = QPushButton(self.tr('Preset'))
        self.defaultButton = QPushButton(self.tr('Default'))
        hlayout2 = pyqttools.add_to_layout(QHBoxLayout(), commandLabel,
                                           self.commandLineEdit,
                                           self.presetButton,
                                           self.defaultButton)

        sizeLabel = QLabel(self.tr('Video Size:'))
        aspectLabel = QLabel(self.tr('Aspect:'))
        frameLabel = QLabel(self.tr('Frame Rate (fps):'))
        bitrateLabel = QLabel(self.tr('Video Bitrate (kbps):'))

        self.widthLineEdit = pyqttools.create_LineEdit((50, 16777215),
                                                       validator, 4)
        self.heightLineEdit = pyqttools.create_LineEdit((50, 16777215),
                                                        validator, 4)
        label = QLabel('x')
        layout1 = pyqttools.add_to_layout(QHBoxLayout(), self.widthLineEdit,
                                          label, self.heightLineEdit)
        self.aspect1LineEdit = pyqttools.create_LineEdit((35, 16777215),
                                                         validator, 2)
        self.aspect2LineEdit = pyqttools.create_LineEdit((35, 16777215),
                                                         validator, 2)
        label = QLabel(':')
        layout2 = pyqttools.add_to_layout(QHBoxLayout(), self.aspect1LineEdit,
                                          label, self.aspect2LineEdit)
        self.frameLineEdit = pyqttools.create_LineEdit(None, validator, 4)
        self.bitrateLineEdit = pyqttools.create_LineEdit(None, validator, 6)

        labels = [sizeLabel, aspectLabel, frameLabel, bitrateLabel]
        widgets = [layout1, layout2, self.frameLineEdit, self.bitrateLineEdit]

        videosettings_layout = QHBoxLayout()
        for a, b in zip(labels, widgets):
            text = a.text()
            a.setText('<html><p align="center">{0}</p></html>'.format(text))
            layout = pyqttools.add_to_layout(QVBoxLayout(), a, b)
            videosettings_layout.addLayout(layout)

        freqLabel = QLabel(self.tr('Frequency (Hz):'))
        chanLabel = QLabel(self.tr('Channels:'))
        bitrateLabel = QLabel(self.tr('Audio Bitrate (kbps):'))

        self.freqComboBox = QComboBox()
        self.freqComboBox.addItems(frequency_values)
        self.chan1RadioButton = QRadioButton('1')
        self.chan1RadioButton.setMaximumSize(QSize(51, 16777215))
        self.chan2RadioButton = QRadioButton('2')
        self.chan2RadioButton.setMaximumSize(QSize(51, 16777215))
        self.group = QButtonGroup()
        self.group.addButton(self.chan1RadioButton)
        self.group.addButton(self.chan2RadioButton)
        spcr1 = QSpacerItem(40, 20, QSizePolicy.Preferred, QSizePolicy.Minimum)
        spcr2 = QSpacerItem(40, 20, QSizePolicy.Preferred, QSizePolicy.Minimum)
        chanlayout = pyqttools.add_to_layout(QHBoxLayout(), spcr1,
                                             self.chan1RadioButton,
                                             self.chan2RadioButton, spcr2)
        self.audio_bitrateComboBox = QComboBox()
        self.audio_bitrateComboBox.addItems(bitrate_values)

        labels = [freqLabel, chanLabel, bitrateLabel]
        widgets = [self.freqComboBox, chanlayout, self.audio_bitrateComboBox]

        audiosettings_layout = QHBoxLayout()
        for a, b in zip(labels, widgets):
            text = a.text()
            a.setText('<html><p align="center">{0}</p></html>'.format(text))
            layout = pyqttools.add_to_layout(QVBoxLayout(), a, b)
            audiosettings_layout.addLayout(layout)

        hidden_layout = pyqttools.add_to_layout(QVBoxLayout(),
                                                videosettings_layout,
                                                audiosettings_layout)

        line = QFrame()
        line.setFrameShape(QFrame.HLine)
        line.setFrameShadow(QFrame.Sunken)
        self.moreButton = QPushButton(QApplication.translate('Tab', 'More'))
        self.moreButton.setSizePolicy(QSizePolicy(QSizePolicy.Fixed))
        self.moreButton.setCheckable(True)
        hlayout3 = pyqttools.add_to_layout(QHBoxLayout(), line,
                                           self.moreButton)

        self.frame = QFrame()
        self.frame.setLayout(hidden_layout)
        self.frame.hide()

        final_layout = pyqttools.add_to_layout(QVBoxLayout(), hlayout1,
                                               hlayout2, hlayout3, self.frame)
        self.setLayout(final_layout)

        self.presetButton.clicked.connect(self.choose_preset)
        self.defaultButton.clicked.connect(self.set_default_command)
        self.moreButton.toggled.connect(self.frame.setVisible)
        self.moreButton.toggled.connect(self.resize_parent)
        self.extComboBox.currentIndexChanged.connect(
            lambda: self.extLineEdit.setEnabled(self.extComboBox.currentIndex(
            ) == len(self.formats)))
        self.widthLineEdit.textChanged.connect(
            lambda: self.command_elements_change('size'))
        self.heightLineEdit.textChanged.connect(
            lambda: self.command_elements_change('size'))
        self.aspect1LineEdit.textChanged.connect(
            lambda: self.command_elements_change('aspect'))
        self.aspect2LineEdit.textChanged.connect(
            lambda: self.command_elements_change('aspect'))
        self.frameLineEdit.textChanged.connect(
            lambda: self.command_elements_change('frames'))
        self.bitrateLineEdit.textChanged.connect(
            lambda: self.command_elements_change('video_bitrate'))
        self.freqComboBox.currentIndexChanged.connect(
            lambda: self.command_elements_change('frequency'))
        self.audio_bitrateComboBox.currentIndexChanged.connect(
            lambda: self.command_elements_change('audio_bitrate'))
        self.chan1RadioButton.clicked.connect(
            lambda: self.command_elements_change('channels1'))
        self.chan2RadioButton.clicked.connect(
            lambda: self.command_elements_change('channels2'))

    def resize_parent(self):
        """Resize MainWindow."""
        height = MAIN_FIXED_HEIGHT if self.frame.isVisible() else MAIN_HEIGHT
        self.parent.setMinimumSize(MAIN_WIDTH, height)
        self.parent.resize(MAIN_WIDTH, height)

    def clear(self):
        """Clear all values of graphical widgets."""
        lines = [
            self.commandLineEdit, self.widthLineEdit, self.heightLineEdit,
            self.aspect1LineEdit, self.aspect2LineEdit, self.frameLineEdit,
            self.bitrateLineEdit, self.extLineEdit
        ]
        for i in lines:
            i.clear()

        self.freqComboBox.setCurrentIndex(0)
        self.audio_bitrateComboBox.setCurrentIndex(0)
        self.group.setExclusive(False)
        self.chan1RadioButton.setChecked(False)
        self.chan2RadioButton.setChecked(False)
        self.group.setExclusive(True)
        # setExclusive(False) in order to be able to uncheck checkboxes and
        # then setExclusive(True) so only one radio button can be set

    def ok_to_continue(self):
        """
        Check if everything is ok with audiovideotab to continue conversion.

        Check if:
        - Either ffmpeg or avconv are installed.
        - Desired extension is valid.
        - self.commandLineEdit is empty.

        Return True if all tests pass, else False.
        """
        if not self.parent.ffmpeg and not self.parent.avconv:
            QMessageBox.warning(
                self, 'FF Multi Converter - ' + self.tr('Error!'),
                self.
                tr('Neither ffmpeg nor avconv are installed.'
                   '\nYou will not be able to convert audio/video files until you'
                   ' install one of them.'))
            return False
        if self.extLineEdit.isEnabled():
            text = str(self.extLineEdit.text()).strip()
            if len(text.split()) != 1 or text[0] == '.':
                QMessageBox.warning(
                    self, 'FF Multi Converter - ' + self.tr('Error!'),
                    self.tr('Extension must be one word and must '
                            'not start with a dot.'))
                self.extLineEdit.selectAll()
                self.extLineEdit.setFocus()
                return False
        if not self.commandLineEdit.text():
            QMessageBox.warning(
                self, 'FF Multi Converter - ' + self.tr('Error!'),
                self.tr('The command LineEdit may not be empty.'))
            self.commandLineEdit.setFocus()
            return False
        return True

    def set_default_command(self):
        """Set the default value to self.commandLineEdit."""
        self.clear()
        self.commandLineEdit.setText(self.parent.default_command)

    def choose_preset(self):
        """
        Open the presets dialog and update self.commandLineEdit,
        self.extComboBox and self.extLineEdit with the appropriate values.
        """
        dialog = presets_dlgs.ShowPresets()
        if dialog.exec_() and dialog.the_command is not None:
            self.commandLineEdit.setText(dialog.the_command)
            self.commandLineEdit.home(False)
            find = self.extComboBox.findText(dialog.the_extension)
            if find >= 0:
                self.extComboBox.setCurrentIndex(find)
            else:
                self.extComboBox.setCurrentIndex(len(self.formats))
                self.extLineEdit.setText(dialog.the_extension)

    def remove_consecutive_spaces(self, string):
        """Remove any consecutive spaces from a string and return it."""
        temp = string
        string = ''
        for i in temp.split():
            if i:
                string += i + ' '
        return string[:-1]

    def command_elements_change(self, widget):
        """Fill self.commandLineEdit with the appropriate command parameters."""
        command = str(self.commandLineEdit.text())

        if widget == 'size':
            text1 = self.widthLineEdit.text()
            text2 = self.heightLineEdit.text()

            if (text1 or text2) and not (text1 and text2):
                return
            f = re.sub(r'^.*(-s\s+\d+x\d+).*$', r'\1', command)
            if re.match(r'^.*(-s\s+\d+x\d+).*$', f):
                command = command.replace(f, '').strip()
            if text1 and text2:
                command += ' -s {0}x{1}'.format(text1, text2)

        elif widget == 'aspect':
            text1 = self.aspect1LineEdit.text()
            text2 = self.aspect2LineEdit.text()

            if (text1 or text2) and not (text1 and text2):
                return
            f = re.sub(r'^.*(-aspect\s+\d+:\d+).*$', r'\1', command)
            if re.match(r'^.*(-aspect\s+\d+:\d+).*$', f):
                command = command.replace(f, '').strip()
            if text1 and text2:
                command += ' -aspect {0}:{1}'.format(text1, text2)

        elif widget == 'frames':
            text = self.frameLineEdit.text()
            f = re.sub(r'^.*(-r\s+\d+).*$', r'\1', command)
            if re.match(r'^.*(-r\s+\d+).*$', f):
                command = command.replace(f, '').strip()
            if text:
                command += ' -r {0}'.format(text)

        elif widget == 'video_bitrate':
            text = self.bitrateLineEdit.text()
            f = re.sub(r'^.*(-b\s+\d+k).*$', r'\1', command)
            if re.match(r'^.*(-b\s+\d+k).*$', f):
                command = command.replace(f, '')
            if text:
                command += ' -b {0}k'.format(text)
            command = command.replace('-sameq', '').strip()

        elif widget == 'frequency':
            text = self.freqComboBox.currentText()
            f = re.sub(r'^.*(-ar\s+\d+).*$', r'\1', command)
            if re.match(r'^.*(-ar\s+\d+).*$', f):
                command = command.replace(f, '').strip()
            if text != 'No Change':
                command += ' -ar {0}'.format(text)

        elif widget == 'audio_bitrate':
            text = self.audio_bitrateComboBox.currentText()
            f = re.sub(r'^.*(-ab\s+\d+k).*$', r'\1', command)
            if re.match(r'^.*(-ab\s+\d+k).*$', f):
                command = command.replace(f, '').strip()
            if text != 'No Change':
                command += ' -ab {0}k'.format(text)

        elif widget in ('channels1', 'channels2'):
            text = self.chan1RadioButton.text() if widget == 'channels1' \
                                            else self.chan2RadioButton.text()
            f = re.sub(r'^.*(-ac\s+\d+).*$', r'\1', command)
            if re.match(r'^.*(-ac\s+\d+).*$', f):
                command = command.replace(f, '').strip()
            command += ' -ac {0}'.format(text)

        self.commandLineEdit.clear()
        self.commandLineEdit.setText(self.remove_consecutive_spaces(command))
Ejemplo n.º 3
0
class AudioVideoTab(QWidget):
    def __init__(self, parent):
        super(AudioVideoTab, self).__init__(parent)
        self.parent = parent
        self.name = 'AudioVideo'
        self.formats = ['3gp', 'aac', 'ac3', 'afc', 'aiff', 'amr', 'asf', 'au',
                        'avi', 'dvd', 'flac', 'flv', 'mka', 'mkv', 'mmf',
                        'mov', 'mp3', 'mp4', 'mpg', 'ogg', 'ogv', 'psp', 'rm',
                        'spx', 'vob', 'wav', 'webm', 'wma', 'wmv']
        self.extra_formats = ['aifc', 'm2t', 'm4a', 'm4v', 'mp2', 'mpeg',
                              'ra', 'ts']

        nochange = self.tr('No Change')
        frequency_values = [nochange, '22050', '44100', '48000']
        bitrate_values = [nochange, '32', '96', '112', '128', '160', '192',
                          '256', '320']
        pattern = QRegExp(r'^[1-9]\d*')
        validator = QRegExpValidator(pattern, self)

        converttoLabel = QLabel(self.tr('Convert to:'))
        self.extComboBox = QComboBox()
        self.extComboBox.addItems(self.formats + [self.tr('Other')])
        self.extComboBox.setMinimumWidth(130)
        self.extLineEdit = QLineEdit()
        self.extLineEdit.setMaximumWidth(85)
        self.extLineEdit.setEnabled(False)
        hlayout1 = pyqttools.add_to_layout(QHBoxLayout(), converttoLabel,
                                           None, self.extComboBox,
                                           self.extLineEdit)
        commandLabel = QLabel(self.tr('Command:'))
        self.commandLineEdit = QLineEdit()
        self.presetButton = QPushButton(self.tr('Preset'))
        self.defaultButton = QPushButton(self.tr('Default'))
        hlayout2 = pyqttools.add_to_layout(QHBoxLayout(), commandLabel,
                                       self.commandLineEdit, self.presetButton,
                                       self.defaultButton)

        sizeLabel = QLabel(self.tr('Video Size:'))
        aspectLabel = QLabel(self.tr('Aspect:'))
        frameLabel = QLabel(self.tr('Frame Rate (fps):'))
        bitrateLabel = QLabel(self.tr('Video Bitrate (kbps):'))

        self.widthLineEdit = pyqttools.create_LineEdit((50, 16777215),
                                                       validator, 4)
        self.heightLineEdit = pyqttools.create_LineEdit((50, 16777215),
                                                        validator,4)
        label = QLabel('x')
        layout1 = pyqttools.add_to_layout(QHBoxLayout(), self.widthLineEdit,
                                          label, self.heightLineEdit)
        self.aspect1LineEdit = pyqttools.create_LineEdit((35, 16777215),
                                                         validator,2)
        self.aspect2LineEdit = pyqttools.create_LineEdit((35, 16777215),
                                                         validator,2)
        label = QLabel(':')
        layout2 = pyqttools.add_to_layout(QHBoxLayout(), self.aspect1LineEdit,
                                          label, self.aspect2LineEdit)
        self.frameLineEdit = pyqttools.create_LineEdit(None, validator, 4)
        self.bitrateLineEdit = pyqttools.create_LineEdit(None, validator, 6)

        labels = [sizeLabel, aspectLabel, frameLabel, bitrateLabel]
        widgets = [layout1, layout2, self.frameLineEdit, self.bitrateLineEdit]

        videosettings_layout = QHBoxLayout()
        for a, b in zip(labels, widgets):
            text = a.text()
            a.setText('<html><p align="center">{0}</p></html>'.format(text))
            layout = pyqttools.add_to_layout(QVBoxLayout(), a, b)
            videosettings_layout.addLayout(layout)

        freqLabel = QLabel(self.tr('Frequency (Hz):'))
        chanLabel = QLabel(self.tr('Channels:'))
        bitrateLabel = QLabel(self.tr('Audio Bitrate (kbps):'))

        self.freqComboBox = QComboBox()
        self.freqComboBox.addItems(frequency_values)
        self.chan1RadioButton = QRadioButton('1')
        self.chan1RadioButton.setMaximumSize(QSize(51, 16777215))
        self.chan2RadioButton = QRadioButton('2')
        self.chan2RadioButton.setMaximumSize(QSize(51, 16777215))
        self.group = QButtonGroup()
        self.group.addButton(self.chan1RadioButton)
        self.group.addButton(self.chan2RadioButton)
        spcr1 = QSpacerItem(40, 20, QSizePolicy.Preferred, QSizePolicy.Minimum)
        spcr2 = QSpacerItem(40, 20, QSizePolicy.Preferred, QSizePolicy.Minimum)
        chanlayout = pyqttools.add_to_layout(QHBoxLayout(), spcr1,
                                             self.chan1RadioButton,
                                             self.chan2RadioButton, spcr2)
        self.audio_bitrateComboBox = QComboBox()
        self.audio_bitrateComboBox.addItems(bitrate_values)

        labels = [freqLabel, chanLabel, bitrateLabel]
        widgets = [self.freqComboBox, chanlayout, self.audio_bitrateComboBox]

        audiosettings_layout = QHBoxLayout()
        for a, b in zip(labels, widgets):
            text = a.text()
            a.setText('<html><p align="center">{0}</p></html>'.format(text))
            layout = pyqttools.add_to_layout(QVBoxLayout(), a, b)
            audiosettings_layout.addLayout(layout)

        hidden_layout = pyqttools.add_to_layout(QVBoxLayout(),
                                                videosettings_layout,
                                                audiosettings_layout)

        line = QFrame()
        line.setFrameShape(QFrame.HLine)
        line.setFrameShadow(QFrame.Sunken)
        self.moreButton = QPushButton(QApplication.translate('Tab', 'More'))
        self.moreButton.setSizePolicy(QSizePolicy(QSizePolicy.Fixed))
        self.moreButton.setCheckable(True)
        hlayout3 = pyqttools.add_to_layout(QHBoxLayout(), line, self.moreButton)

        self.frame = QFrame()
        self.frame.setLayout(hidden_layout)
        self.frame.hide()

        final_layout = pyqttools.add_to_layout(QVBoxLayout(), hlayout1,
                                               hlayout2, hlayout3, self.frame)
        self.setLayout(final_layout)


        self.presetButton.clicked.connect(self.choose_preset)
        self.defaultButton.clicked.connect(self.set_default_command)
        self.moreButton.toggled.connect(self.frame.setVisible)
        self.moreButton.toggled.connect(self.resize_parent)
        self.extComboBox.currentIndexChanged.connect(
                lambda: self.extLineEdit.setEnabled(
                self.extComboBox.currentIndex() == len(self.formats)))
        self.widthLineEdit.textChanged.connect(
                lambda: self.command_elements_change('size'))
        self.heightLineEdit.textChanged.connect(
                lambda: self.command_elements_change('size'))
        self.aspect1LineEdit.textChanged.connect(
                lambda: self.command_elements_change('aspect'))
        self.aspect2LineEdit.textChanged.connect(
                lambda: self.command_elements_change('aspect'))
        self.frameLineEdit.textChanged.connect(
                lambda: self.command_elements_change('frames'))
        self.bitrateLineEdit.textChanged.connect(
                lambda: self.command_elements_change('video_bitrate'))
        self.freqComboBox.currentIndexChanged.connect(
                lambda: self.command_elements_change('frequency'))
        self.audio_bitrateComboBox.currentIndexChanged.connect(
                lambda: self.command_elements_change('audio_bitrate'))
        self.chan1RadioButton.clicked.connect(
                lambda: self.command_elements_change('channels1'))
        self.chan2RadioButton.clicked.connect(
                lambda: self.command_elements_change('channels2'))

    def resize_parent(self):
        """Resize MainWindow."""
        height = MAIN_FIXED_HEIGHT if self.frame.isVisible() else MAIN_HEIGHT
        self.parent.setMinimumSize(MAIN_WIDTH, height)
        self.parent.resize(MAIN_WIDTH, height)

    def clear(self):
        """Clear all values of graphical widgets."""
        lines = [self.commandLineEdit, self.widthLineEdit, self.heightLineEdit,
                 self.aspect1LineEdit, self.aspect2LineEdit, self.frameLineEdit,
                 self.bitrateLineEdit, self.extLineEdit]
        for i in lines:
            i.clear()

        self.freqComboBox.setCurrentIndex(0)
        self.audio_bitrateComboBox.setCurrentIndex(0)
        self.group.setExclusive(False)
        self.chan1RadioButton.setChecked(False)
        self.chan2RadioButton.setChecked(False)
        self.group.setExclusive(True)
        # setExclusive(False) in order to be able to uncheck checkboxes and
        # then setExclusive(True) so only one radio button can be set

    def ok_to_continue(self):
        """
        Check if everything is ok with audiovideotab to continue conversion.

        Check if:
        - Either ffmpeg or avconv are installed.
        - Desired extension is valid.
        - self.commandLineEdit is empty.

        Return True if all tests pass, else False.
        """
        if not self.parent.ffmpeg and not self.parent.avconv:
            QMessageBox.warning(self, 'FF Multi Converter - ' + self.tr(
                'Error!'), self.tr('Neither ffmpeg nor avconv are installed.'
                '\nYou will not be able to convert audio/video files until you'
                ' install one of them.'))
            return False
        if self.extLineEdit.isEnabled():
            text = str(self.extLineEdit.text()).strip()
            if len(text.split()) != 1 or text[0] == '.':
                QMessageBox.warning(self, 'FF Multi Converter - ' + self.tr(
                    'Error!'), self.tr('Extension must be one word and must '
                    'not start with a dot.'))
                self.extLineEdit.selectAll()
                self.extLineEdit.setFocus()
                return False
        if not self.commandLineEdit.text():
            QMessageBox.warning(self, 'FF Multi Converter - ' + self.tr(
                  'Error!'), self.tr('The command LineEdit may not be empty.'))
            self.commandLineEdit.setFocus()
            return False
        return True

    def set_default_command(self):
        """Set the default value to self.commandLineEdit."""
        self.clear()
        self.commandLineEdit.setText(self.parent.default_command)

    def choose_preset(self):
        """
        Open the presets dialog and update self.commandLineEdit,
        self.extComboBox and self.extLineEdit with the appropriate values.
        """
        dialog = presets_dlgs.ShowPresets()
        if dialog.exec_() and dialog.the_command is not None:
            self.commandLineEdit.setText(dialog.the_command)
            self.commandLineEdit.home(False)
            find = self.extComboBox.findText(dialog.the_extension)
            if find >= 0:
                self.extComboBox.setCurrentIndex(find)
            else:
                self.extComboBox.setCurrentIndex(len(self.formats))
                self.extLineEdit.setText(dialog.the_extension)

    def remove_consecutive_spaces(self, string):
        """Remove any consecutive spaces from a string and return it."""
        temp = string
        string = ''
        for i in temp.split():
            if i:
                string += i + ' '
        return string[:-1]

    def command_elements_change(self, widget):
        """Fill self.commandLineEdit with the appropriate command parameters."""
        command = str(self.commandLineEdit.text())

        if widget == 'size':
            text1 = self.widthLineEdit.text()
            text2 = self.heightLineEdit.text()

            if (text1 or text2) and not (text1 and text2):
                return
            f = re.sub(r'^.*(-s\s+\d+x\d+).*$', r'\1', command)
            if re.match(r'^.*(-s\s+\d+x\d+).*$', f):
                command = command.replace(f, '').strip()
            if text1 and text2:
                command += ' -s {0}x{1}'.format(text1, text2)

        elif widget == 'aspect':
            text1 = self.aspect1LineEdit.text()
            text2 = self.aspect2LineEdit.text()

            if (text1 or text2) and not (text1 and text2):
                return
            f = re.sub(r'^.*(-aspect\s+\d+:\d+).*$', r'\1', command)
            if re.match(r'^.*(-aspect\s+\d+:\d+).*$', f):
                command = command.replace(f, '').strip()
            if text1 and text2:
                command += ' -aspect {0}:{1}'.format(text1, text2)

        elif widget == 'frames':
            text = self.frameLineEdit.text()
            f = re.sub(r'^.*(-r\s+\d+).*$', r'\1', command)
            if re.match(r'^.*(-r\s+\d+).*$', f):
                command = command.replace(f, '').strip()
            if text:
                command += ' -r {0}'.format(text)

        elif widget == 'video_bitrate':
            text = self.bitrateLineEdit.text()
            f = re.sub(r'^.*(-b\s+\d+k).*$', r'\1', command)
            if re.match(r'^.*(-b\s+\d+k).*$', f):
                command = command.replace(f, '')
            if text:
                command += ' -b {0}k'.format(text)
            command = command.replace('-sameq', '').strip()

        elif widget == 'frequency':
            text = self.freqComboBox.currentText()
            f = re.sub(r'^.*(-ar\s+\d+).*$', r'\1', command)
            if re.match(r'^.*(-ar\s+\d+).*$', f):
                command = command.replace(f, '').strip()
            if text != 'No Change':
                command += ' -ar {0}'.format(text)

        elif widget == 'audio_bitrate':
            text = self.audio_bitrateComboBox.currentText()
            f = re.sub(r'^.*(-ab\s+\d+k).*$', r'\1', command)
            if re.match(r'^.*(-ab\s+\d+k).*$', f):
                command = command.replace(f, '').strip()
            if text != 'No Change':
                command += ' -ab {0}k'.format(text)

        elif widget in ('channels1', 'channels2'):
            text = self.chan1RadioButton.text() if widget == 'channels1' \
                                            else self.chan2RadioButton.text()
            f = re.sub(r'^.*(-ac\s+\d+).*$', r'\1', command)
            if re.match(r'^.*(-ac\s+\d+).*$', f):
                command = command.replace(f, '').strip()
            command += ' -ac {0}'.format(text)

        self.commandLineEdit.clear()
        self.commandLineEdit.setText(self.remove_consecutive_spaces(command))
Ejemplo n.º 4
0
    def __init__(self, template, character, parent=None):
        super(ItemWidget, self).__init__(parent)

        self.ui = Ui_ItemWidget()
        self.ui.setupUi(self)

        self.__character = character
        self.__storage = template

        ## Weapons
        weaponStore = AbstractStoreWidget(template, character)
        weaponStore.setEnhancedItemTraitsVisible(True)
        weaponStore.setMagicalItemTraitsVisible(False)
        weaponStore.setAddCustomVisible(False)
        self.ui.layout_weapons.addWidget(weaponStore)

        for category in self.__storage.weapons:
            for weapon in self.__storage.weapons[category]:
                weaponStore.addItemToStore(
                    weapon, category, QIcon(Config.ICONS_WEAPONS[category]))

        weaponStore.itemBought.connect(self.__character.addWeapon)
        weaponStore.itemSold.connect(self.__character.deleteWeapon)
        self.__character.weaponAdded.connect(weaponStore.moveItemToInventory)
        self.__character.weaponRemoved.connect(weaponStore.moveItemToStore)

        ## Equipment
        equipmentStore = AbstractStoreWidget(template, character)
        equipmentStore.setEnhancedItemTraitsVisible(False)
        equipmentStore.setMagicalItemTraitsVisible(False)
        equipmentStore.setAddCustomVisible(True)
        self.ui.layout_equipment.addWidget(equipmentStore)

        for equipment in self.__storage.equipment:
            equipmentStore.addItemToStore(equipment)

        equipmentStore.itemBought.connect(self.__character.addEquipment)
        equipmentStore.itemSold.connect(self.__character.deleteEquipment)
        self.__character.equipmentAdded.connect(
            equipmentStore.moveItemToInventory)
        self.__character.equipmentRemoved.connect(
            equipmentStore.moveItemToStore)

        ## Automobiles
        automobileStore = AbstractStoreWidget(template, character)
        automobileStore.setEnhancedItemTraitsVisible(False)
        automobileStore.setMagicalItemTraitsVisible(False)
        automobileStore.setAddCustomVisible(False)
        self.ui.layout_automobiles.addWidget(automobileStore)

        for category in self.__storage.automobiles:
            for automobile in self.__storage.automobiles[category]:
                automobileStore.addItemToStore(
                    automobile, category,
                    QIcon(Config.ICONS_AUTOMOBILES[category]))

        automobileStore.itemBought.connect(self.__character.addAutomobile)
        automobileStore.itemSold.connect(self.__character.deleteAutomobile)
        self.__character.automobileAdded.connect(
            automobileStore.moveItemToInventory)
        self.__character.automobileRemoved.connect(
            automobileStore.moveItemToStore)

        ## ExtraordinaryItems
        extraordinaryItemStore = AbstractStoreWidget(template, character)
        extraordinaryItemStore.setEnhancedItemTraitsVisible(False)
        extraordinaryItemStore.setMagicalItemTraitsVisible(True)
        extraordinaryItemStore.setAddCustomVisible(False)
        self.ui.layout_extraordinaryItems.addWidget(extraordinaryItemStore)

        for category in self.__storage.extraordinaryItems:
            for extraordinaryItem in self.__storage.extraordinaryItems[
                    category]:
                extraordinaryItemStore.addItemToStore(
                    extraordinaryItem, category,
                    QIcon(Config.ICONS_ITEMS_EXTRAORDINARY[category]))

        extraordinaryItemStore.itemBought.connect(
            self.__character.addExtraordinaryItem)
        extraordinaryItemStore.itemSold.connect(
            self.__character.deleteExtraordinaryItem)
        self.__character.extraordinaryItemAdded.connect(
            extraordinaryItemStore.moveItemToInventory)
        self.__character.extraordinaryItemRemoved.connect(
            extraordinaryItemStore.moveItemToStore)

        ## \todo Sollte nicht vom Betriebssystem, sondern vom verwendeten Style abhängen.
        self.ui.tabWidget_items.setObjectName("transparentWidget")
        if os.name == "nt":
            self.ui.tabWidget_items.setStyleSheet(
                "QWidget#transparentWidget { background: transparent; }")

        self.ui.tabWidget_items.setCurrentIndex(0)

        ## Resources
        self.ui.traitDots_armorResources.valueChanged.connect(
            self.__character.traits["Merit"]["Social"]["Resources"].setValue)
        #self.ui.traitDots_equipmentResources.valueChanged.connect(self.__character.traits["Merit"]["Social"]["Resources"].setValue)
        self.__character.traits["Merit"]["Social"][
            "Resources"].valueChanged.connect(
                self.ui.traitDots_armorResources.setValue)
        #self.__character.traits["Merit"]["Social"]["Resources"].valueChanged.connect(self.ui.traitDots_equipmentResources.setValue)
        self.ui.traitDots_armorEnhancedItem.valueChanged.connect(
            self.__character.traits["Merit"]["Item"]["Enhanced Item"].setValue)
        #self.ui.traitDots_equipmentEnhancedItem.valueChanged.connect(self.__character.traits["Merit"]["Item"]["Enhanced Item"].setValue)
        self.__character.traits["Merit"]["Item"][
            "Enhanced Item"].valueChanged.connect(
                self.ui.traitDots_armorEnhancedItem.setValue)
        #self.__character.traits["Merit"]["Item"]["Enhanced Item"].valueChanged.connect(self.ui.traitDots_equipmentEnhancedItem.setValue)

        ## Armor

        self.__noArmorText = "None"
        self.__buttonArmorDict = {}
        self.__buttonGroup_armor = QButtonGroup(self)
        ## Natürlich muß auch die Wahl bestehen, keine Rüstung zu tragen. Dies ist zu Anfang gewählt.
        radioButton = QRadioButton(self.__noArmorText)
        self.ui.layout_armor.addWidget(radioButton)
        self.__buttonGroup_armor.addButton(radioButton)
        radioButton.setChecked(True)
        self.__buttonArmorDict[radioButton.text()] = radioButton
        for armor in self.__storage.armor:
            radioButton = QRadioButton(armor)
            self.ui.layout_armor.addWidget(radioButton)
            self.__buttonGroup_armor.addButton(radioButton)
            self.__buttonArmorDict[radioButton.text()] = radioButton

        self.__buttonGroup_armor.buttonClicked.connect(self.takeArmor)
        self.ui.checkBox_armorDedicated.toggled.connect(self.takeArmor)

        self.__character.armorChanged.connect(self.selectArmor)
        self.__character.speciesChanged.connect(self.hideShowDedicated)

        ### Equipment

        #self.ui.pushButton_equipmentAdd.setIcon(QIcon(":/icons/images/actions/1leftarrow.png"))
        #self.ui.pushButton_equipmentRemove.setIcon(QIcon(":/icons/images/actions/1rightarrow.png"))

        #for item in self.__storage.equipment:
        #listItem = QListWidgetItem()
        #listItem.setText(item)
        ##listItem.setIcon(QIcon(Config.ICONS_WEAPONS[category]))
        ##listItem.setData(Qt.BackgroundRole, QColor(Config.weaponsColor[category]))
        #self.ui.listWidget_equipmentStore.addItem(listItem)

        #self.ui.pushButton_equipmentAdd.clicked.connect(self.addEquipment)
        #self.ui.listWidget_equipmentStore.itemDoubleClicked.connect(self.addEquipment)
        #self.ui.pushButton_equipmentRemove.clicked.connect(self.removeEquipment)
        #self.ui.listWidget_equipmentInventory.itemDoubleClicked.connect(self.removeEquipment)
        #self.ui.pushButton_equipmentAddCustom.clicked.connect(self.addCustomEquipment)
        #self.__character.equipmentChanged.connect(self.refillEquipmentInventory)
        #self.__character.equipmentChanged.connect(self.refillEquipmentStore)
        #self.__character.equipmentChanged.connect(self.checkButtonEnabledEquipment)

        ## Magical Tool
        self.__character.speciesChanged.connect(self.hideShowMagicalTool)
        self.ui.lineEdit_magicalTool.textEdited.connect(
            self.__character.setMagicalTool)
        self.__character.magicalToolChanged.connect(
            self.ui.lineEdit_magicalTool.setText)
Ejemplo n.º 5
0
    def __init__(self, IMC, parent=None):
        super(QDialog, self).__init__(parent)
        self.IMC = IMC
        self.setModal(True)
        self.setSizeGripEnabled(True)
        bookinfo = QFileInfo(IMC.bookPath)
        self.setWindowTitle(u"Properties of {0}".format(bookinfo.fileName()))
        # Our layout is a vertical stack of widgets and hboxes
        vlayout = QVBoxLayout()
        # Add the path information field
        fplb = QLabel(u"Path: {0}".format(unicode(bookinfo.path())))
        fplb.setFrameStyle(QFrame.Sunken)
        fplb.setToolTip(QString(u'Full path to document'))
        vlayout.addWidget(fplb)
        # Add the write-encoding choice, setting the buttons to reflect
        # the current value. We build this up from the inside out.
        # Two radio buttons. As they will be exclusive we need connect
        # the toggled() signal from only one of them.
        self.saveEncoding = self.IMC.bookSaveEncoding
        rb_enc_utf = QRadioButton(QString(u'UTF-8'))
        rb_enc_utf.setChecked(self.saveEncoding == rb_enc_utf.text())
        rb_enc_utf.toggled.connect(self.encodingChange)
        rb_enc_ltn = QRadioButton(QString(u'Latin-1'))
        rb_enc_ltn.setChecked(self.saveEncoding != rb_enc_utf.text())
        # put the buttons in a layout because groupbox doesn't act as one
        hb_enc_btns = QHBoxLayout()
        hb_enc_btns.addWidget(rb_enc_utf)
        hb_enc_btns.addWidget(rb_enc_ltn)
        # add to groupbox to get exclusivity on the buttons
        gb_enc = QGroupBox()
        gb_enc.setLayout(hb_enc_btns)
        # put in horizontal box with descriptive label, and add to the dialog
        hb_enc = QHBoxLayout()
        lb_enc = QLabel(u'Write Encoding')
        lb_enc.setToolTip('Character encoding when writing the document')
        hb_enc.addWidget(lb_enc)
        hb_enc.addWidget(gb_enc)
        vlayout.addLayout(hb_enc)

        # Next get a QStringList of available dicts from pqSpell
        # and create a combobox with that content.
        dictlist = IMC.spellCheck.dictList()
        dictlist.sort()
        self.maintag = self.IMC.bookMainDict
        if self.maintag.isEmpty():
            self.maintag = self.IMC.spellCheck.mainTag
        current = dictlist.indexOf(QString(
            self.maintag))  # index of current dict or -1
        self.cb_dic = QComboBox()
        self.cb_dic.addItems(dictlist)
        if current >= 0: self.cb_dic.setCurrentIndex(current)
        self.cb_dic.activated.connect(self.dictChange)

        hb_dic = QHBoxLayout()
        hb_dic.addWidget(QLabel(u'Main Dictionary'))
        hb_dic.addStretch()
        hb_dic.addWidget(self.cb_dic)
        vlayout.addLayout(hb_dic)

        # create the [ apply cancel ] buttons, but apply == accept
        apply_button = QPushButton("Apply")
        cancel_button = QPushButton("Cancel")
        cancel_button.setDefault(True)
        bbox = QDialogButtonBox()
        bbox.addButton(cancel_button, QDialogButtonBox.RejectRole)
        bbox.addButton(apply_button, QDialogButtonBox.AcceptRole)
        bbox.accepted.connect(self.applyButtonHit)
        bbox.rejected.connect(self.cancelButtonHit)
        vlayout.addWidget(bbox)

        self.setLayout(vlayout)
Ejemplo n.º 6
0
class ApplicationWindow(QMainWindow):
    def __init__(self):

        super(ApplicationWindow, self).__init__()

        self._init_ui()
        self._set_defaults()

    def _init_ui(self):

        # Styles
        self.setStyleSheet("""QRadioButton {
                max-width: 40px;
            }""")

        bold_font = QFont()
        bold_font.setBold(True)

        title_label = QLabel(self)
        title_label.setText("PyPass3")
        title_label.move(10, 0)
        title_label.setMinimumSize(300, 20)
        title_label.setFont(bold_font)

        length_label = QLabel(self)
        length_label.setText("Length")
        length_label.move(192, 185)
        length_label.setMinimumSize(200, 20)
        length_label.setFont(bold_font)

        main_label = QLabel(self)
        main_label.setText("Make robust secrets with random characters,\n"
                           "words, or numbers. Or choose number of dice\n"
                           "and rolls for words type passphrase. Defaults\n"
                           "to 5 dice and 5 rolls.\n")
        main_label.setMinimumSize(280, 100)
        main_label.move(10, 15)

        type_label = QLabel(self)
        type_label.setText("Secret type")
        type_label.move(10, 87)
        type_label.setFont(bold_font)

        dice_label = QLabel(self)
        dice_label.setText("Number of dice")
        dice_label.move(10, 138)
        dice_label.setMinimumSize(280, 20)
        dice_label.setFont(bold_font)

        rolls_label = QLabel(self)
        rolls_label.setText("Number of rolls")
        rolls_label.move(10, 190)
        rolls_label.setMinimumSize(280, 20)
        rolls_label.setFont(bold_font)

        self.textbox = QTextEdit(self)
        self.textbox.setMinimumSize(280, 100)
        self.textbox.move(10, 245)
        self.textbox.setFontFamily("Courier New")

        self.length_textline = QLineEdit(self)
        self.length_textline.setMinimumSize(100, 20)
        self.length_textline.move(190, 210)

        min_width = 125
        # max_width = 150

        # Add Generate button
        generate_btn = QPushButton('Generate', self)
        generate_btn.setToolTip('Click to generate secret')
        # generate_btn.clicked.connect(on_click)
        generate_btn.clicked.connect(self._on_click)
        generate_btn.move(10, 355)
        generate_btn.setMinimumWidth(min_width)

        # Add Quit button
        quit_btn = QPushButton('Quit', self)
        quit_btn.setToolTip('Quit this application')
        quit_btn.clicked.connect(exit)
        quit_btn.move(165, 355)
        quit_btn.setMinimumWidth(min_width)

        # Add Copy button
        copy_btn = QPushButton('Copy', self)
        copy_btn.setToolTip('Copy your secret')
        copy_btn.clicked.connect(self._copy_textbox)
        copy_btn.move(250, 320)
        copy_btn.setMaximumWidth(35)
        copy_btn.setMaximumHeight(20)
        copy_btn.setStyleSheet('font-size: 11px;')

        # Add Help button
        help_btn = QPushButton('Help', self)
        help_btn.setToolTip('Get help about this application')
        help_btn.clicked.connect(self._open_help)
        help_btn.move(240, 80)
        help_btn.setMaximumWidth(35)
        help_btn.setMaximumHeight(20)
        help_btn.setStyleSheet('font-size: 11px;')

        hr1 = QFrame(self)
        hr1.setFrameShape(QFrame.HLine)
        hr1.move(10, 125)
        hr1.setMinimumWidth(280)
        hr1.setStyleSheet("color: #d0d0d0;")

        hr2 = QFrame(self)
        hr2.setFrameShape(QFrame.HLine)
        hr2.move(10, 175)
        hr2.setMinimumWidth(100)
        hr2.setStyleSheet("color: #d0d0d0;")

        # Add secret type radio buttons
        self.words_radio_btn = QRadioButton('words', self)
        self.words_radio_btn.move(10, 110)
        self.words_radio_btn.clicked.connect(self._set_word_defaults)
        self.words_radio_btn.setStyleSheet('max-width: 80px;')

        self.mixed_radio_btn = QRadioButton('mixed', self)
        self.mixed_radio_btn.move(90, 110)
        self.mixed_radio_btn.clicked.connect(self._disabled_unused)
        self.mixed_radio_btn.setStyleSheet('max-width: 80px;')

        self.numbers_radio_btn = QRadioButton('numbers', self)
        self.numbers_radio_btn.move(170, 110)
        self.numbers_radio_btn.clicked.connect(self._disabled_unused)
        self.numbers_radio_btn.setStyleSheet('max-width: 100px;')

        # Add dice roll radio buttons
        self.num_dice4 = QRadioButton('4', self)
        self.num_dice4.move(10, 160)

        self.num_dice5 = QRadioButton('5', self)
        self.num_dice5.move(60, 160)

        self.num_rolls3 = QRadioButton('3', self)
        self.num_rolls3.move(10, 212)

        self.num_rolls4 = QRadioButton('4', self)
        self.num_rolls4.move(60, 212)

        self.num_rolls5 = QRadioButton('5', self)
        self.num_rolls5.move(110, 212)

        self.radio_type_group = QButtonGroup(self)
        self.radio_type_group.addButton(self.words_radio_btn)
        self.radio_type_group.addButton(self.mixed_radio_btn)
        self.radio_type_group.addButton(self.numbers_radio_btn)

        self.radio_dice_group = QButtonGroup(self)
        self.radio_dice_group.addButton(self.num_dice4)
        self.radio_dice_group.addButton(self.num_dice5)

        self.radio_rolls_group = QButtonGroup(self)
        self.radio_rolls_group.addButton(self.num_rolls3)
        self.radio_rolls_group.addButton(self.num_rolls4)
        self.radio_rolls_group.addButton(self.num_rolls5)

        self.setGeometry(100, 100, 300, 400)
        self.setWindowTitle('Password Generator')
        self.setWindowIcon(QIcon('../images/lock_icon_bkgrd.png'))

    def _set_defaults(self):

        self.words_radio_btn.setChecked(True)
        self.num_dice5.setChecked(True)
        self.num_rolls5.setChecked(True)
        self.length_textline.setText('')

    def _run_generate(self):

        logging.info('[{0}]\n{1}'.format(utils.get_timestamp(),
                                         self._get_args()))

        return generate_secret(int(self._get_args()['number_rolls']),
                               int(self._get_args()['number_dice']),
                               int(self._get_args()['how_many']),
                               str(self._get_args()['output_type']),
                               int(self._get_args()['password_length']))

        # def generate_secret(number_rolls: int = 5, number_dice: int = 5,
        #                       how_many: int = 1, output_type: str = 'words',
        #                       password_length: int = 20)

        # output_type=self._get_args()['output_type'],
        # password_length=int(self._get_args()['password_length']),
        # number_dice=int(self._get_args()['number_dice']),
        # number_rolls=int(self._get_args()['number_rolls'])

    def _on_click(self):

        self.textbox.setFontFamily("Courier New")

        return self.textbox.setText(self._run_generate())

    def _get_args(self):

        args = {'password_length': 20, 'how_many': 1}

        # Type
        if self.numbers_radio_btn.isChecked():
            args['output_type'] = self.numbers_radio_btn.text()

        elif self.mixed_radio_btn.isChecked():
            args['output_type'] = self.mixed_radio_btn.text()

        else:
            args['output_type'] = self.words_radio_btn.text()

        # Length
        if self.length_textline.text():
            args['password_length'] = self.length_textline.text()

        # Dice
        if self.num_dice4.isChecked():
            args['number_dice'] = self.num_dice4.text()

        else:
            args['number_dice'] = self.num_dice5.text()

        # Rolls
        if self.num_rolls3.isChecked():
            args['number_rolls'] = self.num_rolls3.text()

        elif self.num_rolls4.isChecked():
            args['number_rolls'] = self.num_rolls4.text()

        else:
            args['number_rolls'] = self.num_rolls5.text()

        return args

    def _disabled_unused(self):

        tmp_text = self.length_textline.text()

        if tmp_text:
            self.length_textline.setText(tmp_text)
        else:
            self.length_textline.setText('20')

        self.radio_dice_group.setExclusive(False)
        self.radio_rolls_group.setExclusive(False)

        self.num_dice4.setChecked(False)
        self.num_dice4.setCheckable(False)
        self.num_dice4.setEnabled(False)

        self.num_dice5.setChecked(False)
        self.num_dice5.setCheckable(False)
        self.num_dice5.setEnabled(False)

        self.num_rolls3.setChecked(False)
        self.num_rolls3.setCheckable(False)
        self.num_rolls3.setEnabled(False)

        self.num_rolls4.setChecked(False)
        self.num_rolls4.setCheckable(False)
        self.num_rolls4.setEnabled(False)

        self.num_rolls5.setChecked(False)
        self.num_rolls5.setCheckable(False)
        self.num_rolls5.setEnabled(False)

        self.radio_dice_group.setExclusive(True)
        self.radio_rolls_group.setExclusive(True)

    def _set_word_defaults(self):

        self.length_textline.setText('')

        self.num_dice4.setCheckable(True)
        self.num_dice4.setEnabled(True)

        self.num_dice5.setCheckable(True)
        self.num_dice5.setEnabled(True)

        self.num_rolls3.setCheckable(True)
        self.num_rolls3.setEnabled(True)

        self.num_rolls4.setCheckable(True)
        self.num_rolls4.setEnabled(True)

        self.num_rolls5.setCheckable(True)
        self.num_rolls5.setEnabled(True)

        self.num_dice5.setChecked(True)
        self.num_rolls5.setChecked(True)

    def _copy_textbox(self):

        self.textbox.selectAll()
        self.textbox.copy()

    def _open_help(self):

        message = QMessageBox(self)

        with open('../assets/help/_main.txt', 'r') as help_text:
            message.setText(help_text.read())

        message.setIcon(QMessageBox.Question)

        with open('../assets/help/_inform.txt', 'r') as help_inform:
            message.setInformativeText(help_inform.read())

        message.setWindowTitle('PyPass3 Help')
        message.setStandardButtons(QMessageBox.Close)
        message.exec_()