Exemple #1
0
class Ui_Form(object):
    def setupUi(self, audioOp):
        if not audioOp.objectName():
            audioOp.setObjectName(u"audioOp")
        self.formLayout_8 = QFormLayout(audioOp)
        self.formLayout_8.setObjectName(u"formLayout_8")
        self.comboBox = QComboBox(audioOp)
        self.comboBox.addItem("")
        self.comboBox.addItem("")
        self.comboBox.addItem("")
        self.comboBox.setObjectName(u"comboBox")

        self.formLayout_8.setWidget(0, QFormLayout.FieldRole, self.comboBox)

        self.label_8 = QLabel(audioOp)
        self.label_8.setObjectName(u"label_8")

        self.formLayout_8.setWidget(0, QFormLayout.LabelRole, self.label_8)


        self.retranslateUi(audioOp)

        QMetaObject.connectSlotsByName(audioOp)
    # setupUi

    def retranslateUi(self, audioOp):
        self.comboBox.setItemText(0, QCoreApplication.translate("Form", u"Mixed section and step audio", None))
        self.comboBox.setItemText(1, QCoreApplication.translate("Form", u"Section audio only", None))
        self.comboBox.setItemText(2, QCoreApplication.translate("Form", u"Step audio only", None))

        self.label_8.setText(QCoreApplication.translate("Form", u"Audio attachment behavior", None))
        pass
    def __init__(self, editor: PresetEditor):
        super().__init__(editor)
        self.setupUi(self)

        self.translators_layout.setAlignment(QtCore.Qt.AlignTop)
        self.translator_randomize_all_button.clicked.connect(
            self._on_randomize_all_gates_pressed)
        self.translator_randomize_all_with_unlocked_button.clicked.connect(
            self._on_randomize_all_gates_with_unlocked_pressed)
        self.translator_vanilla_actual_button.clicked.connect(
            self._on_vanilla_actual_gates_pressed)
        self.translator_vanilla_colors_button.clicked.connect(
            self._on_vanilla_colors_gates_pressed)

        self._combo_for_gate = {}

        gate_index_to_name, identifier_to_gate = gate_data()

        for i, (identifier, gate_index) in enumerate(
                sorted(identifier_to_gate.items(), key=lambda it: it[1])):
            label = QtWidgets.QLabel(self.translators_scroll_contents)
            label.setText(gate_index_to_name[gate_index])
            self.translators_layout.addWidget(label, 3 + i, 0, 1, 1)

            combo = QComboBox(self.translators_scroll_contents)
            combo.identifier = identifier
            for item in iterate_enum(LayoutTranslatorRequirement):
                combo.addItem(item.long_name, item)
            combo.currentIndexChanged.connect(
                functools.partial(self._on_gate_combo_box_changed, combo))

            self.translators_layout.addWidget(combo, 3 + i, 1, 1, 2)
            self._combo_for_gate[combo.identifier] = combo
Exemple #3
0
    def initUI(self):
        self.setWindowTitle("QTableWidget 例子")
        self.resize(430, 300);
        conLayout = QHBoxLayout()
        tableWidget = QTableWidget()
        tableWidget.setRowCount(4)
        tableWidget.setColumnCount(3)
        conLayout.addWidget(tableWidget)

        tableWidget.setHorizontalHeaderLabels(['姓名', '性别', '体重(kg)'])

        newItem = QTableWidgetItem("张三")
        tableWidget.setItem(0, 0, newItem)

        comBox = QComboBox()
        comBox.addItem("男")
        comBox.addItem("女")
        comBox.setStyleSheet("QComboBox{margin:3px};")
        tableWidget.setCellWidget(0, 1, comBox)

        searchBtn = QPushButton("修改")
        searchBtn.setDown(True)
        searchBtn.setStyleSheet("QPushButton{margin:3px};")
        tableWidget.setCellWidget(0, 2, searchBtn)

        self.setLayout(conLayout)
Exemple #4
0
 def getParts4Combo(self, combo: QComboBox):
     combo.clear()
     combo.clearEditText()
     sql = "SELECT num_part FROM part;"
     out = self.db.get(sql)
     for supplier in out:
         combo.addItem(supplier[0])
     combo.setEnabled(True)
Exemple #5
0
def _fill_combo(item_database: ItemDatabase, combo: QtWidgets.QComboBox):
    items = []
    items.extend(item.name for item in item_database.major_items.values())
    items.extend(item.name for item in item_database.ammo.values())
    items.extend(f"Energy Cell {i}" for i in range(1, 10))

    for item in sorted(items):
        combo.addItem(item, item)
 def _create_ammo_combo():
     combo = QComboBox(self.beam_configuration_group)
     combo.addItem("None", -1)
     combo.addItem("Power Bomb", 43)
     combo.addItem("Missile", 44)
     combo.addItem("Dark Ammo", 45)
     combo.addItem("Light Ammo", 46)
     return combo
Exemple #7
0
 def add_supplier_list_to_combo(self, combo: QComboBox):
     # clear QComboBox
     combo.clear()
     combo.clearEditText()
     # DB Query and update QConboBox
     sql = "SELECT name_supplier_short FROM supplier;"
     out = self.db.get(sql)
     for supplier in out:
         combo.addItem(supplier[0])
class MainWindow(QMainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()

        centralWidget = QWidget()
        self.setCentralWidget(centralWidget)
        layout = QFormLayout(centralWidget)

        textLayout = QHBoxLayout()
        self.text = QLineEdit('Hello, PySide6')
        self.text.setClearButtonEnabled(True)
        textLayout.addWidget(self.text)
        self.sayButton = QPushButton('Say')
        textLayout.addWidget(self.sayButton)
        self.text.returnPressed.connect(self.sayButton.animateClick)
        self.sayButton.clicked.connect(self.say)
        layout.addRow('Text:', textLayout)

        self.voiceCombo = QComboBox()
        layout.addRow('Voice:', self.voiceCombo)

        self.volumeSlider = QSlider(Qt.Horizontal)
        self.volumeSlider.setMinimum(0)
        self.volumeSlider.setMaximum(100)
        self.volumeSlider.setValue(100)
        layout.addRow('Volume:', self.volumeSlider)

        self.engine = None
        engineNames = QTextToSpeech.availableEngines()
        if len(engineNames) > 0:
            engineName = engineNames[0]
            self.engine = QTextToSpeech(engineName)
            self.engine.stateChanged.connect(self.stateChanged)
            self.setWindowTitle(
                'QTextToSpeech Example ({})'.format(engineName))
            self.voices = []
            for voice in self.engine.availableVoices():
                self.voices.append(voice)
                self.voiceCombo.addItem(voice.name())
        else:
            self.setWindowTitle('QTextToSpeech Example (no engines available)')
            self.sayButton.setEnabled(False)

    def say(self):
        self.sayButton.setEnabled(False)
        self.engine.setVoice(self.voices[self.voiceCombo.currentIndex()])
        self.engine.setVolume(float(self.volumeSlider.value()) / 100)
        self.engine.say(self.text.text())

    def stateChanged(self, state):
        if (state == QTextToSpeech.State.Ready):
            self.sayButton.setEnabled(True)
Exemple #9
0
    def setup_ui(self):
        super(FontUI, self).setup_ui()

        sys_radio = QRadioButton("系统字体")
        sys_radio.setChecked(True)
        font_combo = QComboBox()
        for item in self.system_fonts:
            font_combo.addItem(item[1])
        font_combo.setCurrentIndex(0)
        font_combo.currentIndexChanged.connect(self.refresh_font)

        custom_radio = QRadioButton("自选字体")
        custom_radio.setCheckable(True)
        custom_radio.setChecked(False)
        custom_radio.toggled.connect(self.on_custom_radio_toggled)
        custom_edit = QLineEdit()
        custom_edit.setPlaceholderText("自定义字体(*.ttf, *.otf)")
        custom_edit.setReadOnly(True)
        custom_edit.setEnabled(False)
        custom_btn = QPushButton(text="浏览")
        custom_btn.setEnabled(False)
        custom_btn.clicked.connect(self.on_custom_clicked)

        font_group = QButtonGroup(self)
        font_group.addButton(sys_radio, 0)
        font_group.addButton(custom_radio, 1)
        font_group.setExclusive(True)

        input_label = QLabel("输出字符")
        input_edit = MLineEdit()
        import_btn = QPushButton(text="从文本文件导入")
        import_btn.clicked.connect(self.on_import_btn_clicked)

        self.main_layout.setColumnStretch(1, 1)
        self.main_layout.addWidget(sys_radio, 1, 0, 1, 1)
        self.main_layout.addWidget(font_combo, 1, 1, 1, 2)
        self.main_layout.addWidget(custom_radio, 2, 0, 1, 1)
        self.main_layout.addWidget(custom_edit, 2, 1, 1, 1)
        self.main_layout.addWidget(custom_btn, 2, 2, 1, 1)

        self.main_layout.addWidget(input_label, 3, 0, 1, 1)
        self.main_layout.addWidget(import_btn, 3, 2, 1, 1)
        self.main_layout.addWidget(input_edit, 4, 0, 1, 3)

        self.input_edit = input_edit
        self.font_combo = font_combo
        self.custom_btn = custom_btn
        self.custom_edit = custom_edit

        self.refresh_font()
Exemple #10
0
 def getPartsOptionCombo(self, label: QLabel, combo: QComboBox,
                         check: QCheckBox):
     combo.clear()
     combo.clearEditText()
     if check.checkState() == Qt.Checked:
         sql = "SELECT num_part FROM part;"
         out = self.db.get(sql)
         for supplier in out:
             combo.addItem(supplier[0])
         label.setStyleSheet(
             "QLabel {font-size:10pt; padding: 0 2px;color: black;}")
         combo.setEnabled(True)
     else:
         label.setStyleSheet(
             "QLabel {font-size:10pt; padding: 0 2px;color: gray;}")
         combo.setEnabled(False)
    def createOptionsGroupBox(self):
        self.optionsGroupBox = QGroupBox("Options")

        buttonsOrientationLabel = QLabel("Orientation of buttons:")

        buttonsOrientationComboBox = QComboBox()
        buttonsOrientationComboBox.addItem("Horizontal", Qt.Horizontal)
        buttonsOrientationComboBox.addItem("Vertical", Qt.Vertical)
        buttonsOrientationComboBox.currentIndexChanged[int].connect(
            self.buttonsOrientationChanged)

        self.buttonsOrientationComboBox = buttonsOrientationComboBox

        optionsLayout = QGridLayout()
        optionsLayout.addWidget(buttonsOrientationLabel, 0, 0)
        optionsLayout.addWidget(self.buttonsOrientationComboBox, 0, 1)
        optionsLayout.setColumnStretch(2, 1)
        self.optionsGroupBox.setLayout(optionsLayout)
Exemple #12
0
def _create_resource_type_combo(current_resource_type: ResourceType,
                                parent: QWidget) -> QComboBox:
    """

    :param current_resource_type:
    :param parent:
    :return:
    """
    resource_type_combo = QComboBox(parent)

    for resource_type in ResourceType:
        if not resource_type.is_usable_for_requirement:
            continue

        resource_type_combo.addItem(resource_type.name, resource_type)
        if resource_type is current_resource_type:
            resource_type_combo.setCurrentIndex(resource_type_combo.count() -
                                                1)

    return resource_type_combo
Exemple #13
0
 def createEditor(self, aParent, option, index):
     if index.column() == self._key:
         editor = QComboBox(aParent)
         for idx in self.types:
             editor.addItem(self.types[idx][0], userData=idx)
     elif index.column() == self._value:
         type_idx = index.model().data(index.sibling(
             index.row(), self._key),
                                       role=Qt.EditRole)
         if self.types[type_idx][1] == "str" or self.types[type_idx][
                 1] == "float":
             editor = QLineEdit(aParent)
         elif self.types[type_idx][1] == "date":
             editor = DateTimeEditWithReset(aParent)
             editor.setTimeSpec(Qt.UTC)
             editor.setDisplayFormat("dd/MM/yyyy")
         else:
             assert False, f"Unknown data type '{self.types[type_idx][1]}' in DataDelegate.createEditor()"
     else:
         assert False, f"Delegate DataDelegate.createEditor() called for not-initialized column {index.column()}"
     return editor
Exemple #14
0
    def __init__(
        self,
        parent: QWidget,
        layout: QHBoxLayout,
        resource_database: ResourceDatabase,
        item: RequirementTemplate,
    ):
        self.parent = parent
        self.layout = layout
        self.resource_database = resource_database

        template_name_combo = QComboBox(parent)

        for template_name in sorted(
                resource_database.requirement_template.keys()):
            template_name_combo.addItem(template_name)
            if template_name == item.template_name:
                template_name_combo.setCurrentIndex(
                    template_name_combo.count() - 1)

        self.template_name_combo = template_name_combo
        self.layout.addWidget(self.template_name_combo)
Exemple #15
0
def _create_resource_name_combo(
    resource_database: ResourceDatabase,
    resource_type: ResourceType,
    current_resource: Optional[ResourceInfo],
    parent: QWidget,
) -> QComboBox:
    """

    :param resource_database:
    :param current_resource:
    :param parent:
    :return:
    """

    resource_name_combo = QComboBox(parent)

    for resource in sorted(resource_database.get_by_type(resource_type),
                           key=lambda x: x.long_name):
        resource_name_combo.addItem(resource.long_name, resource)
        if resource is current_resource:
            resource_name_combo.setCurrentIndex(resource_name_combo.count() -
                                                1)

    return resource_name_combo
Exemple #16
0
class Page1Widget(QWidget):
    
    def __init__(self):
        super().__init__()

        # Create Widgets
        self.dropdown_quest = QComboBox()
        self.dropdown_quest.addItems(MODES)
        self.dropdown_quest.setCurrentText("Romaji")
        self.dropdown_ans = QComboBox()
        self.dropdown_ans.addItems(MODES)
        self.dropdown_also = QComboBox()
        self.dropdown_also.addItem("----")
        self.dropdown_also.addItems(MODES)
        self.spinbox_level = QSpinBox(Minimum=1, Maximum=2)

        self.list_groups = QListWidget(FixedWidth=W * .6)
        for group_name in GROUPS:
            item = QListWidgetItem(group_name)
            item.setCheckState(QtCore.Qt.Unchecked)
            self.list_groups.addItem(item)

        # Make Layout
        self.sub_layout = QVBoxLayout()
        self.sub_layout.addWidget(QLabel('Question:'))
        self.sub_layout.addWidget(self.dropdown_quest)
        self.sub_layout.addWidget(QLabel('Answer:'))
        self.sub_layout.addWidget(self.dropdown_ans)
        self.sub_layout.addWidget(QLabel('Also:'))
        self.sub_layout.addWidget(self.dropdown_also)
        self.sub_layout.addWidget(QLabel('Level:'))
        self.sub_layout.addWidget(self.spinbox_level)

        self.layout = QHBoxLayout(self)
        self.layout.addLayout(self.sub_layout)
        self.layout.addWidget(self.list_groups)
Exemple #17
0
class Pryme2(QWidget):

    notify_request = Signal(str)

    def __init__(self, parent=None):

        super(Pryme2, self).__init__(parent)

        self.timer_instances = (SimpleTimer(), AlarmClock(), PomoTimer())
        self.timer_selection = QComboBox(self)
        for t in self.timer_instances:
            self.timer_selection.addItem(t.name)
        self.timer = self.timer_instances[0]
        self.commitment_textbox = QLineEdit(self)
        self.commitment_textbox.setPlaceholderText(
            'What do you want to commit?')
        self.commitment_textbox.setClearButtonEnabled(True)
        self.commit_done_btn = QPushButton('&Done', self)
        self.start_btn = QPushButton('&Start', self)
        self.abort_btn = QPushButton('&Abort', self)
        self.abort_btn.hide()
        self.pause_btn = QPushButton('&Pause', self)
        self.pause_btn.hide()
        self.resume_btn = QPushButton('&Resume', self)
        self.resume_btn.hide()

        self.tray = QSystemTrayIcon(self)
        self.tray.setIcon(QIcon('pryme-logo.svg'))
        self.tray.show()

        self.set_ui()
        self.set_connection()
        self.show()

    def set_ui(self):
        self.hlayout = QHBoxLayout()
        self.hlayout.addWidget(self.commitment_textbox)
        self.hlayout.addWidget(self.commit_done_btn)
        self.commit_group = QGroupBox('Commitment')
        self.commit_group.setLayout(self.hlayout)

        self.vlayout = QVBoxLayout()
        self.vlayout.addWidget(self.commit_group)
        self.vlayout.addWidget(self.timer_selection)
        self.vlayout.addWidget(self.timer)

        self.bottom_hlayout = QHBoxLayout()
        self.bottom_hlayout.addWidget(self.start_btn)
        self.bottom_hlayout.addWidget(self.abort_btn)
        self.bottom_hlayout.addWidget(self.pause_btn)
        self.bottom_hlayout.addWidget(self.resume_btn)

        self.vlayout.addLayout(self.bottom_hlayout)
        self.setLayout(self.vlayout)

    def set_connection(self):
        self.timer_selection.currentIndexChanged.connect(self.change_timer)
        self.connect_timer()

    def connect_timer(self):
        self.start_btn.clicked.connect(self.timer.start)
        self.abort_btn.clicked.connect(self.timer.abort)
        self.timer.finished.connect(self.notify)
        self.timer.started.connect(self.set_timer_active_ui)
        self.timer.aborted.connect(self.set_timer_deactive_ui)
        self.timer.finished.connect(self.set_timer_deactive_ui)
        if hasattr(self.timer, 'pause'):
            self.pause_btn.clicked.connect(self.timer.pause)
            self.resume_btn.clicked.connect(self.timer.resume)
            self.timer.paused.connect(self.activate_resume_button)

    def disconnect_timer(self):
        self.timer.disconnect(self)
        self.start_btn.disconnect(self.timer)
        self.abort_btn.disconnect(self.timer)
        self.resume_btn.disconnect(self.timer)

    def notify(self):
        title = self.commitment_textbox.text()
        if not title:
            title = 'Time up!'
        message = self.timer.get_notify_message()
        if not message:
            print(message)
            message = 'Time up!'
        self.tray.showMessage(title, message)
        subprocess.Popen(cmd.split())

    def set_ui_enabled(self, enable: bool):
        self.timer_selection.setEnabled(enable)
        self.commitment_textbox.setEnabled(enable)

    def set_timer_active_ui(self):
        self.activate_start_button(False)
        self.set_ui_enabled(False)

    def set_timer_deactive_ui(self):
        self.activate_start_button(True)
        self.set_ui_enabled(True)

    def activate_start_button(self, activate: bool):
        if activate:
            # active start button
            self.start_btn.show()
            self.abort_btn.hide()
            self.pause_btn.hide()
            self.resume_btn.hide()
        else:
            self.abort_btn.show()
            self.start_btn.hide()
            if hasattr(self.timer, 'pause'):
                self.pause_btn.show()
                self.resume_btn.hide()

    def activate_resume_button(self):
        self.pause_btn.hide()
        self.resume_btn.show()

    @Slot(int)
    def change_timer(self, index):
        self.disconnect_timer()
        self.timer.hide()
        self.vlayout.replaceWidget(self.timer, self.timer_instances[index])
        self.timer = self.timer_instances[index]
        self.connect_timer()
        self.timer.show()
Exemple #18
0
class App(QWidget):
    def __init__(self):

        #init
        super(App, self).__init__()

        #▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
        #parameters for the resume generation.
        self.params = {
            "White": 1.0,
            "Black": 1.0,
            "Hispanic": 1.0,
            "Asian": 1.0,
            "GenderRatio": 0.5,
            "TestSection": '',
            "TestMode": 2,
            "WorkPath": "",
            "BeginYear": "",
            "EndYear": "",
            "BeginMonth": "",
            "EndMonth": "",
            "BeginYearEdu": "",
            "EndYearEdu": "",
            "BeginMonthEdu": "",
            "EndMonthEdu": ""
        }
        #▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒

        #Dictionaries for UI buttons

        self.testModes = {"Before": 1, "After": 2, "Replace": 3}

        self.testSections = {
            "Address": 1,
            "Education": 2,
            "Work History": 3,
            "Skills": 4
        }
        #▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
        #Window sizing for application
        self.title = "COEHP Resume Generator"
        self.left = 10
        self.top = 10
        self.width = 100
        self.height = 300

        #▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
        #Window is created here
        self.makeUI()

    #▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
    #Function creates window and adds widgets

    def makeUI(self):

        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)
        self.createLayout()

        windowLayout = QGridLayout()

        windowLayout.addWidget(self.box0, 1, 1, 1, 1)
        windowLayout.addWidget(self.box4, 0, 0, 1, 1)
        windowLayout.addWidget(self.box6, 1, 0, 1, 1)
        windowLayout.addWidget(self.box7, 0, 1, 1, 1)
        windowLayout.addWidget(self.box5, 3, 0, 1, 2)
        windowLayout.addWidget(self.box8, 2, 0, 1, 2)

        windowLayout.setAlignment(QtCore.Qt.AlignTop)

        self.setLayout(windowLayout)
        self.show()

    #▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
    #All QGroupBoxes for features are added here.
    def createLayout(self):
        self.box0 = QGroupBox("Timeframe")
        self.box4 = QGroupBox("Test Data")
        self.box6 = QGroupBox("Output Directory")
        self.box5 = QGroupBox("")
        self.box7 = QGroupBox("Demographic Settings")
        self.box8 = QGroupBox("Resume Layout")

        #Demographic Settings

        self.wPercent = QTextEdit("0.25")
        self.bPercent = QTextEdit("0.25")
        self.aPercent = QTextEdit("0.25")
        self.hPercent = QTextEdit("0.25")
        self.gPercent = QTextEdit("0.5")
        self.wLabel = QLabel("White %")
        self.bLabel = QLabel("Black %")
        self.aLabel = QLabel("Asian %")
        self.hLabel = QLabel("Hispanic %")
        self.gLabel = QLabel("       Gender Ratio")

        self.wPercent.setFixedSize(100, 30)
        self.bPercent.setFixedSize(100, 30)
        self.aPercent.setFixedSize(100, 30)
        self.hPercent.setFixedSize(100, 30)
        self.gPercent.setFixedSize(100, 30)

        #Resume Layout Settings

        self.testSectionLabel1 = QLabel("Test Location")
        self.testSectionLabel2 = QLabel("Section")
        self.testSectionLabel3 = QLabel("Location of Content")
        self.sectionSelect = QComboBox()
        self.sectionSelect.addItems(
            ["Address", "Education", "Work History", "Skills"])
        self.sectionSelect.setFixedSize(300, 30)

        self.modeSelect = QComboBox()
        self.modeSelect.addItems(["Before", "After", "Replace"])
        self.modeSelect.setFixedSize(300, 30)

        #Academic Year

        #First Semester
        self.monthBegin = QComboBox()
        self.monthBegin.addItems([
            "January", "February", "March", "April", "May", "June", "July",
            "August", "September", "November", "December"
        ])
        self.monthBegin.setFixedSize(100, 30)

        self.yearBeginLabel = QLabel("First Semester")
        self.yearBegin = QComboBox()
        self.yearBegin.setFixedSize(100, 30)

        for year in range(1970, 2050):
            self.yearBegin.addItem(str(year))

        #Last Semester
        self.monthEnd = QComboBox()
        self.monthEnd.addItems([
            "January", "February", "March", "April", "May", "June", "July",
            "August", "September", "November", "December"
        ])
        self.monthEnd.setFixedSize(100, 30)

        self.yearEnd = QComboBox()
        self.yearEndLabel = QLabel("Semester of Graduation")
        for year in range(1970, 2050):
            self.yearEnd.addItem(str(year))
        self.yearEnd.setFixedSize(100, 30)

        #Earliest relevant employment
        self.monthWorkBegin = QComboBox()
        self.monthWorkBegin.addItems([
            "January", "February", "March", "April", "May", "June", "July",
            "August", "September", "November", "December"
        ])
        self.monthBegin.setFixedSize(100, 30)

        self.yearWorkBeginLabel = QLabel(
            "Earliest Possible Date of Employment")
        self.yearWorkBegin = QComboBox()
        self.yearWorkBegin.setFixedSize(100, 30)

        for year in range(1970, 2050):
            self.yearWorkBegin.addItem(str(year))

        #Latest relevant employment
        self.monthWorkEnd = QComboBox()
        self.monthWorkEnd.addItems([
            "January", "February", "March", "April", "May", "June", "July",
            "August", "September", "November", "December"
        ])
        self.monthWorkEnd.setFixedSize(100, 30)

        self.yearWorkEnd = QComboBox()
        self.yearWorkEndLabel = QLabel("Latest Possible Date of Employment")
        for year in range(1970, 2050):
            self.yearWorkEnd.addItem(str(year))
        self.yearWorkEnd.setFixedSize(100, 30)

        currentYear = date.today().year
        index = currentYear - 1970
        self.yearEnd.setCurrentIndex(index)
        self.yearBegin.setCurrentIndex(index)
        self.yearWorkBegin.setCurrentIndex(index)
        self.yearWorkEnd.setCurrentIndex(index)

        #Output Directory
        self.dirLabel = QLabel("Output Directory")
        self.currentDir = QTextEdit()
        self.currentDir.setText("Not Selected")
        self.currentDir.layout()
        self.currentDir.setFixedSize(300, 30)
        self.currentDir.setReadOnly(True)
        self.outputName = QTextEdit()

        self.outputLabel = QLabel("Output Folder Name")
        self.outputName.setText("None written")
        self.outputName.setToolTip(
            "Type in the name of the new Folder you would like to make for your Resume batch. \n Otherwise, this will use the current timestamp."
        )
        self.outputName.setFixedSize(300, 30)
        #Select ouput folder button

        self.outputButton = QPushButton('Select Output Directory')
        self.outputButton.setToolTip(
            "Click here to tell the generator where to put this batch of Resumes when it is finished."
        )
        self.outputButton.clicked.connect(
            lambda: self.openDir(self.currentDir))
        self.currentTest = QTextEdit()
        self.currentTest.setText("SportsCollegeList.csv")

        #Output Directory
        self.workLabel = QLabel("Output Directory")
        self.currentWork = QTextEdit()
        self.currentWork.setText("SportsCollegeList.csv")
        self.currentWork.layout()
        self.currentWork.setFixedSize(300, 30)
        self.currentWork.setReadOnly(True)

        #Select work datafolder button
        self.workButton = QPushButton('Select Work Data (.CSV)')
        self.workButton.setToolTip(
            "Click here to select a source file for the employment information in this Resume Batch."
        )
        self.workButton.clicked.connect(lambda: self.openDir(self.currentWork))

        #Select School Data

        self.workLabel = QLabel("Output Directory")
        self.currentSchool = QTextEdit()
        self.currentSchool.setText("Not Selected")
        self.currentSchool.layout()
        self.currentSchool.setFixedSize(300, 30)
        self.currentSchool.setReadOnly(True)

        #Select work datafolder button
        self.schoolButton = QPushButton('Select Work Data (.CSV)')
        self.schoolButton.clicked.connect(
            lambda: self.openDir(self.currentWork))

        #Select test data

        self.testLabel = QLabel("Output Directory")
        self.currentTest = QTextEdit()
        self.currentTest.setText("SportsCollegeList.csv")
        self.currentTest.layout()
        self.currentTest.setFixedSize(300, 30)
        self.currentTest.setReadOnly(True)
        self.testButton = QPushButton('Select Test Data (.CSV)')
        self.testButton.clicked.connect(lambda: self.openDir(self.currentTest))

        #Generate Resumes button
        self.begin = QPushButton('Generate Resumes')
        self.begin.clicked.connect(
            lambda: self.beginTask(self.currentTest.toPlainText()))

        layout = QGridLayout()
        self.box0.setLayout(layout)
        layout.addWidget(self.yearBeginLabel, 0, 0, 1, 2)
        layout.addWidget(self.monthBegin, 1, 0, 1, 1)
        layout.addWidget(self.yearBegin, 1, 1, 1, 1)
        layout.addWidget(self.yearEndLabel, 2, 0, 1, 2)
        layout.addWidget(self.monthEnd, 3, 0, 1, 1)
        layout.addWidget(self.yearEnd, 3, 1, 1, 1)

        layout.addWidget(self.yearWorkBeginLabel, 4, 0, 1, 2)
        layout.addWidget(self.monthWorkBegin, 5, 0, 1, 1)
        layout.addWidget(self.yearWorkBegin, 5, 1, 1, 1)
        layout.addWidget(self.yearWorkEndLabel, 6, 0, 1, 2)
        layout.addWidget(self.monthWorkEnd, 7, 0, 1, 1)
        layout.addWidget(self.yearWorkEnd, 7, 1, 1, 1)

        layout1 = QGridLayout()
        self.box8.setLayout(layout1)
        layout1.addWidget(self.testSectionLabel1, 0, 0, 1, 1)
        layout1.addWidget(self.testSectionLabel3, 1, 0, 1, 1)
        layout1.addWidget(self.sectionSelect, 0, 1, 1, 1)
        layout1.addWidget(self.modeSelect, 1, 1, 1, 1)

        layout2 = QGridLayout()
        self.box7.setLayout(layout2)
        layout2.addWidget(self.wLabel, 0, 0, 1, 1)
        layout2.addWidget(self.bLabel, 1, 0, 1, 1)
        layout2.addWidget(self.hLabel, 0, 2, 1, 1)
        layout2.addWidget(self.aLabel, 2, 0, 1, 1)
        layout2.addWidget(self.wPercent, 0, 1, 1, 1)
        layout2.addWidget(self.bPercent, 1, 1, 1, 1)
        layout2.addWidget(self.hPercent, 0, 3, 1, 1)
        layout2.addWidget(self.aPercent, 2, 1, 1, 1)
        layout2.addWidget(self.gLabel, 3, 1, 1, 1)
        layout2.addWidget(self.gPercent, 3, 2, 1, 2)

        layout = QGridLayout()
        self.box5.setLayout(layout)
        layout.addWidget(self.begin, 0, 0, 1, 2)

        layout3 = QGridLayout()
        layout3.addWidget(self.testButton, 0, 0, 1, 2)
        layout3.addWidget(self.currentTest, 1, 0, 1, 2)
        self.box4.setLayout(layout3)

        layout4 = QGridLayout()

        layout4.addWidget(self.outputButton, 0, 0, 1, 2)
        layout4.addWidget(self.currentDir, 1, 0, 1, 2)
        layout4.addWidget(self.outputLabel, 2, 0, 1, 2)
        layout4.addWidget(self.outputName, 3, 0, 1, 2)
        self.box6.setLayout(layout4)

    #▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
    #
    def openDir(self, target):
        fileName = QFileDialog()
        filenames = list()
        if fileName.exec_():
            fileNames = fileName.selectedFiles()
            target.setText(fileNames[0])

    #▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
    #
    def beginTask(self, path):
        self.beginGen(path)

    def beginGen(self, path):

        self.params["White"] = self.wPercent.toPlainText()
        self.params["Black"] = self.bPercent.toPlainText()
        self.params["Hispanic"] = self.hPercent.toPlainText()
        self.params["Asian"] = self.aPercent.toPlainText()
        self.params["GenderRatio"] = self.gPercent.toPlainText()
        self.params["TestMode"] = str(self.modeSelect.currentText())
        self.params["TestSection"] = str(self.sectionSelect.currentText())
        self.params["BeginYear"] = str(self.yearWorkBegin.currentText())
        self.params["EndYear"] = str(self.yearWorkEnd.currentText())
        self.params["BeginMonth"] = str(self.monthWorkBegin.currentText())
        self.params["EndMonth"] = str(self.monthWorkEnd.currentText())
        self.params["workPath"] = "work.csv"
        self.params["BeginYearEdu"] = str(self.yearBegin.currentText())
        self.params["EndYearEdu"] = str(self.yearEnd.currentText())
        self.params["BeginMonthEdu"] = str(self.monthBegin.currentText())
        self.params["EndMonthEdu"] = str(self.monthEnd.currentText())

        print(self.params)
        Printer.begin(self.currentDir.toPlainText(), path,
                      self.outputName.toPlainText(), self.params)
Exemple #19
0
class MainWindow_Ui(QMainWindow):
    def __init__(self, persepolis_setting):
        super().__init__()
        # MainWindow
        self.persepolis_setting = persepolis_setting

        # add support for other languages
        locale = str(self.persepolis_setting.value('settings/locale'))
        QLocale.setDefault(QLocale(locale))
        self.translator = QTranslator()
        if self.translator.load(':/translations/locales/ui_' + locale, 'ts'):
            QCoreApplication.installTranslator(self.translator)

        # set ui direction
        ui_direction = self.persepolis_setting.value('ui_direction')

        if ui_direction == 'rtl':
            self.setLayoutDirection(Qt.RightToLeft)

        elif ui_direction in 'ltr':
            self.setLayoutDirection(Qt.LeftToRight)

        icons = ':/' + \
            str(self.persepolis_setting.value('settings/icons')) + '/'

        self.setWindowTitle(
            QCoreApplication.translate("mainwindow_ui_tr",
                                       "Persepolis Download Manager"))
        self.setWindowIcon(
            QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg')))

        self.centralwidget = QWidget(self)
        self.verticalLayout = QVBoxLayout(self.centralwidget)

        # enable drag and drop
        self.setAcceptDrops(True)

        # frame
        self.frame = QFrame(self.centralwidget)

        # download_table_horizontalLayout
        download_table_horizontalLayout = QHBoxLayout()
        horizontal_splitter = QSplitter(Qt.Horizontal)

        vertical_splitter = QSplitter(Qt.Vertical)

        # category_tree
        self.category_tree_qwidget = QWidget(self)
        category_tree_verticalLayout = QVBoxLayout()
        self.category_tree = CategoryTreeView(self)
        category_tree_verticalLayout.addWidget(self.category_tree)

        self.category_tree_model = QStandardItemModel()
        self.category_tree.setModel(self.category_tree_model)
        category_table_header = [
            QCoreApplication.translate("mainwindow_ui_tr", 'Category')
        ]

        self.category_tree_model.setHorizontalHeaderLabels(
            category_table_header)
        self.category_tree.header().setStretchLastSection(True)

        self.category_tree.header().setDefaultAlignment(Qt.AlignCenter)

        # queue_panel
        self.queue_panel_widget = QWidget(self)

        queue_panel_verticalLayout_main = QVBoxLayout(self.queue_panel_widget)

        # queue_panel_show_button
        self.queue_panel_show_button = QPushButton(self)

        queue_panel_verticalLayout_main.addWidget(self.queue_panel_show_button)

        # queue_panel_widget_frame
        self.queue_panel_widget_frame = QFrame(self)
        self.queue_panel_widget_frame.setFrameShape(QFrame.StyledPanel)
        self.queue_panel_widget_frame.setFrameShadow(QFrame.Raised)

        queue_panel_verticalLayout_main.addWidget(
            self.queue_panel_widget_frame)

        queue_panel_verticalLayout = QVBoxLayout(self.queue_panel_widget_frame)
        queue_panel_verticalLayout_main.setContentsMargins(50, -1, 50, -1)

        # start_end_frame
        self.start_end_frame = QFrame(self)

        # start time
        start_verticalLayout = QVBoxLayout(self.start_end_frame)
        self.start_checkBox = QCheckBox(self)
        start_verticalLayout.addWidget(self.start_checkBox)

        self.start_frame = QFrame(self)
        self.start_frame.setFrameShape(QFrame.StyledPanel)
        self.start_frame.setFrameShadow(QFrame.Raised)

        start_frame_verticalLayout = QVBoxLayout(self.start_frame)

        self.start_time_qDataTimeEdit = MyQDateTimeEdit(self.start_frame)
        self.start_time_qDataTimeEdit.setDisplayFormat('H:mm')
        start_frame_verticalLayout.addWidget(self.start_time_qDataTimeEdit)

        start_verticalLayout.addWidget(self.start_frame)

        # end time
        self.end_checkBox = QCheckBox(self)
        start_verticalLayout.addWidget(self.end_checkBox)

        self.end_frame = QFrame(self)
        self.end_frame.setFrameShape(QFrame.StyledPanel)
        self.end_frame.setFrameShadow(QFrame.Raised)

        end_frame_verticalLayout = QVBoxLayout(self.end_frame)

        self.end_time_qDateTimeEdit = MyQDateTimeEdit(self.end_frame)
        self.end_time_qDateTimeEdit.setDisplayFormat('H:mm')
        end_frame_verticalLayout.addWidget(self.end_time_qDateTimeEdit)

        start_verticalLayout.addWidget(self.end_frame)

        self.reverse_checkBox = QCheckBox(self)
        start_verticalLayout.addWidget(self.reverse_checkBox)

        queue_panel_verticalLayout.addWidget(self.start_end_frame)

        # limit_after_frame
        self.limit_after_frame = QFrame(self)

        # limit_checkBox
        limit_verticalLayout = QVBoxLayout(self.limit_after_frame)
        self.limit_checkBox = QCheckBox(self)
        limit_verticalLayout.addWidget(self.limit_checkBox)

        # limit_frame
        self.limit_frame = QFrame(self)
        self.limit_frame.setFrameShape(QFrame.StyledPanel)
        self.limit_frame.setFrameShadow(QFrame.Raised)
        limit_verticalLayout.addWidget(self.limit_frame)

        limit_frame_verticalLayout = QVBoxLayout(self.limit_frame)

        # limit_spinBox
        limit_frame_horizontalLayout = QHBoxLayout()
        self.limit_spinBox = QDoubleSpinBox(self)
        self.limit_spinBox.setMinimum(1)
        self.limit_spinBox.setMaximum(1023)
        limit_frame_horizontalLayout.addWidget(self.limit_spinBox)

        # limit_comboBox
        self.limit_comboBox = QComboBox(self)
        self.limit_comboBox.addItem("")
        self.limit_comboBox.addItem("")
        limit_frame_horizontalLayout.addWidget(self.limit_comboBox)
        limit_frame_verticalLayout.addLayout(limit_frame_horizontalLayout)

        # limit_pushButton
        self.limit_pushButton = QPushButton(self)
        limit_frame_verticalLayout.addWidget(self.limit_pushButton)

        # after_checkBox
        self.after_checkBox = QCheckBox(self)
        limit_verticalLayout.addWidget(self.after_checkBox)

        # after_frame
        self.after_frame = QFrame(self)
        self.after_frame.setFrameShape(QFrame.StyledPanel)
        self.after_frame.setFrameShadow(QFrame.Raised)
        limit_verticalLayout.addWidget(self.after_frame)

        after_frame_verticalLayout = QVBoxLayout(self.after_frame)

        # after_comboBox
        self.after_comboBox = QComboBox(self)
        self.after_comboBox.addItem("")

        after_frame_verticalLayout.addWidget(self.after_comboBox)

        # after_pushButton
        self.after_pushButton = QPushButton(self)
        after_frame_verticalLayout.addWidget(self.after_pushButton)

        queue_panel_verticalLayout.addWidget(self.limit_after_frame)
        category_tree_verticalLayout.addWidget(self.queue_panel_widget)

        # keep_awake_checkBox
        self.keep_awake_checkBox = QCheckBox(self)
        queue_panel_verticalLayout.addWidget(self.keep_awake_checkBox)

        self.category_tree_qwidget.setLayout(category_tree_verticalLayout)
        horizontal_splitter.addWidget(self.category_tree_qwidget)

        # download table widget
        self.download_table_content_widget = QWidget(self)
        download_table_content_widget_verticalLayout = QVBoxLayout(
            self.download_table_content_widget)

        # download_table
        self.download_table = DownloadTableWidget(self)
        vertical_splitter.addWidget(self.download_table)

        horizontal_splitter.addWidget(self.download_table_content_widget)

        self.download_table.setColumnCount(13)
        self.download_table.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.download_table.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.download_table.verticalHeader().hide()

        # hide column of GID and column of link.
        self.download_table.setColumnHidden(8, True)
        self.download_table.setColumnHidden(9, True)

        download_table_header = [
            QCoreApplication.translate("mainwindow_ui_tr", 'File Name'),
            QCoreApplication.translate("mainwindow_ui_tr", 'Status'),
            QCoreApplication.translate("mainwindow_ui_tr", 'Size'),
            QCoreApplication.translate("mainwindow_ui_tr", 'Downloaded'),
            QCoreApplication.translate("mainwindow_ui_tr", 'Percentage'),
            QCoreApplication.translate("mainwindow_ui_tr", 'Connections'),
            QCoreApplication.translate("mainwindow_ui_tr", 'Transfer Rate'),
            QCoreApplication.translate("mainwindow_ui_tr",
                                       'Estimated Time Left'), 'Gid',
            QCoreApplication.translate("mainwindow_ui_tr", 'Link'),
            QCoreApplication.translate("mainwindow_ui_tr", 'First Try Date'),
            QCoreApplication.translate("mainwindow_ui_tr", 'Last Try Date'),
            QCoreApplication.translate("mainwindow_ui_tr", 'Category')
        ]

        self.download_table.setHorizontalHeaderLabels(download_table_header)

        # fixing the size of download_table when window is Maximized!
        self.download_table.horizontalHeader().setSectionResizeMode(
            QHeaderView.ResizeMode.Interactive)
        self.download_table.horizontalHeader().setStretchLastSection(True)

        horizontal_splitter.setStretchFactor(0, 3)  # category_tree width
        horizontal_splitter.setStretchFactor(1, 10)  # ratio of tables's width

        # video_finder_widget
        self.video_finder_widget = QWidget(self)
        video_finder_horizontalLayout = QHBoxLayout(self.video_finder_widget)

        self.muxing_pushButton = QPushButton(self)
        self.muxing_pushButton.setIcon(QIcon(icons + 'video_finder'))
        video_finder_horizontalLayout.addWidget(self.muxing_pushButton)
        video_finder_horizontalLayout.addSpacing(20)

        video_audio_verticalLayout = QVBoxLayout()

        self.video_label = QLabel(self)
        video_audio_verticalLayout.addWidget(self.video_label)

        self.audio_label = QLabel(self)
        video_audio_verticalLayout.addWidget(self.audio_label)
        video_finder_horizontalLayout.addLayout(video_audio_verticalLayout)

        status_muxing_verticalLayout = QVBoxLayout()

        self.video_finder_status_label = QLabel(self)
        status_muxing_verticalLayout.addWidget(self.video_finder_status_label)

        self.muxing_status_label = QLabel(self)
        status_muxing_verticalLayout.addWidget(self.muxing_status_label)
        video_finder_horizontalLayout.addLayout(status_muxing_verticalLayout)

        vertical_splitter.addWidget(self.video_finder_widget)

        download_table_content_widget_verticalLayout.addWidget(
            vertical_splitter)

        download_table_horizontalLayout.addWidget(horizontal_splitter)

        self.frame.setLayout(download_table_horizontalLayout)

        self.verticalLayout.addWidget(self.frame)

        self.setCentralWidget(self.centralwidget)

        # menubar
        self.menubar = QMenuBar(self)
        self.menubar.setGeometry(QRect(0, 0, 600, 24))
        self.setMenuBar(self.menubar)
        fileMenu = self.menubar.addMenu(
            QCoreApplication.translate("mainwindow_ui_tr", '&File'))
        editMenu = self.menubar.addMenu(
            QCoreApplication.translate("mainwindow_ui_tr", '&Edit'))
        viewMenu = self.menubar.addMenu(
            QCoreApplication.translate("mainwindow_ui_tr", '&View'))
        downloadMenu = self.menubar.addMenu(
            QCoreApplication.translate("mainwindow_ui_tr", '&Download'))
        queueMenu = self.menubar.addMenu(
            QCoreApplication.translate("mainwindow_ui_tr", '&Queue'))
        videoFinderMenu = self.menubar.addMenu(
            QCoreApplication.translate("mainwindow_ui_tr", 'V&ideo Finder'))
        helpMenu = self.menubar.addMenu(
            QCoreApplication.translate("mainwindow_ui_tr", '&Help'))

        # viewMenu submenus
        sortMenu = viewMenu.addMenu(
            QCoreApplication.translate("mainwindow_ui_tr", 'Sort by'))

        # statusbar
        self.statusbar = QStatusBar(self)
        self.setStatusBar(self.statusbar)
        self.statusbar.showMessage(
            QCoreApplication.translate("mainwindow_ui_tr",
                                       "Persepolis Download Manager"))

        # toolBar
        self.toolBar2 = QToolBar(self)
        self.addToolBar(Qt.TopToolBarArea, self.toolBar2)
        self.toolBar2.setWindowTitle(
            QCoreApplication.translate("mainwindow_ui_tr", 'Menu'))
        self.toolBar2.setFloatable(False)
        self.toolBar2.setMovable(False)

        self.toolBar = QToolBar(self)
        self.addToolBar(Qt.TopToolBarArea, self.toolBar)
        self.toolBar.setWindowTitle(
            QCoreApplication.translate("mainwindow_ui_tr", 'Toolbar'))
        self.toolBar.setFloatable(False)
        self.toolBar.setMovable(False)

        #toolBar and menubar and actions
        self.persepolis_setting.beginGroup('settings/shortcuts')

        # videoFinderAddLinkAction
        self.videoFinderAddLinkAction = QAction(
            QIcon(icons + 'video_finder'),
            QCoreApplication.translate("mainwindow_ui_tr",
                                       'Find Video Links...'),
            self,
            statusTip=QCoreApplication.translate(
                "mainwindow_ui_tr",
                'Download video or audio from Youtube, Vimeo, etc.'),
            triggered=self.showVideoFinderAddLinkWindow)

        self.videoFinderAddLinkAction_shortcut = QShortcut(
            self.persepolis_setting.value('video_finder_shortcut'), self,
            self.showVideoFinderAddLinkWindow)

        videoFinderMenu.addAction(self.videoFinderAddLinkAction)

        # stopAllAction
        self.stopAllAction = QAction(QIcon(icons + 'stop_all'),
                                     QCoreApplication.translate(
                                         "mainwindow_ui_tr",
                                         'Stop All Active Downloads'),
                                     self,
                                     statusTip='Stop All Active Downloads',
                                     triggered=self.stopAllDownloads)
        downloadMenu.addAction(self.stopAllAction)

        # sort_file_name_Action
        self.sort_file_name_Action = QAction(QCoreApplication.translate(
            "mainwindow_ui_tr", 'File Name'),
                                             self,
                                             triggered=self.sortByName)
        sortMenu.addAction(self.sort_file_name_Action)

        # sort_file_size_Action
        self.sort_file_size_Action = QAction(QCoreApplication.translate(
            "mainwindow_ui_tr", 'File Size'),
                                             self,
                                             triggered=self.sortBySize)
        sortMenu.addAction(self.sort_file_size_Action)

        # sort_first_try_date_Action
        self.sort_first_try_date_Action = QAction(
            QCoreApplication.translate("mainwindow_ui_tr", 'First Try Date'),
            self,
            triggered=self.sortByFirstTry)
        sortMenu.addAction(self.sort_first_try_date_Action)

        # sort_last_try_date_Action
        self.sort_last_try_date_Action = QAction(QCoreApplication.translate(
            "mainwindow_ui_tr", 'Last Try Date'),
                                                 self,
                                                 triggered=self.sortByLastTry)
        sortMenu.addAction(self.sort_last_try_date_Action)

        # sort_download_status_Action
        self.sort_download_status_Action = QAction(QCoreApplication.translate(
            "mainwindow_ui_tr", 'Download Status'),
                                                   self,
                                                   triggered=self.sortByStatus)
        sortMenu.addAction(self.sort_download_status_Action)

        # trayAction
        self.trayAction = QAction(
            QCoreApplication.translate("mainwindow_ui_tr",
                                       'Show System Tray Icon'),
            self,
            statusTip=QCoreApplication.translate("mainwindow_ui_tr",
                                                 "Show/Hide system tray icon"),
            triggered=self.showTray)
        self.trayAction.setCheckable(True)
        viewMenu.addAction(self.trayAction)

        # showMenuBarAction
        self.showMenuBarAction = QAction(
            QCoreApplication.translate("mainwindow_ui_tr", 'Show Menubar'),
            self,
            statusTip=QCoreApplication.translate("mainwindow_ui_tr",
                                                 'Show Menubar'),
            triggered=self.showMenuBar)
        self.showMenuBarAction.setCheckable(True)
        viewMenu.addAction(self.showMenuBarAction)

        # showSidePanelAction
        self.showSidePanelAction = QAction(
            QCoreApplication.translate("mainwindow_ui_tr", 'Show Side Panel'),
            self,
            statusTip=QCoreApplication.translate("mainwindow_ui_tr",
                                                 'Show Side Panel'),
            triggered=self.showSidePanel)
        self.showSidePanelAction.setCheckable(True)
        viewMenu.addAction(self.showSidePanelAction)

        # minimizeAction
        self.minimizeAction = QAction(
            QIcon(icons + 'minimize'),
            QCoreApplication.translate("mainwindow_ui_tr",
                                       'Minimize to System Tray'),
            self,
            statusTip=QCoreApplication.translate("mainwindow_ui_tr",
                                                 "Minimize to System Tray"),
            triggered=self.minMaxTray)

        self.minimizeAction_shortcut = QShortcut(
            self.persepolis_setting.value('hide_window_shortcut'), self,
            self.minMaxTray)
        viewMenu.addAction(self.minimizeAction)

        # addlinkAction
        self.addlinkAction = QAction(
            QIcon(icons + 'add'),
            QCoreApplication.translate("mainwindow_ui_tr",
                                       'Add New Download Link...'),
            self,
            statusTip=QCoreApplication.translate("mainwindow_ui_tr",
                                                 "Add New Download Link"),
            triggered=self.addLinkButtonPressed)

        self.addlinkAction_shortcut = QShortcut(
            self.persepolis_setting.value('add_new_download_shortcut'), self,
            self.addLinkButtonPressed)
        fileMenu.addAction(self.addlinkAction)

        # importText
        self.addtextfileAction = QAction(
            QIcon(icons + 'file'),
            QCoreApplication.translate("mainwindow_ui_tr",
                                       'Import Links from Text File...'),
            self,
            statusTip=QCoreApplication.translate(
                "mainwindow_ui_tr",
                'Create a text file and put links in it, line by line!'),
            triggered=self.importText)

        self.addtextfileAction_shortcut = QShortcut(
            self.persepolis_setting.value('import_text_shortcut'), self,
            self.importText)

        fileMenu.addAction(self.addtextfileAction)

        # resumeAction
        self.resumeAction = QAction(
            QIcon(icons + 'play'),
            QCoreApplication.translate("mainwindow_ui_tr", 'Resume Download'),
            self,
            statusTip=QCoreApplication.translate("mainwindow_ui_tr",
                                                 "Resume Download"),
            triggered=self.resumeButtonPressed)

        downloadMenu.addAction(self.resumeAction)

        # pauseAction
        self.pauseAction = QAction(
            QIcon(icons + 'pause'),
            QCoreApplication.translate("mainwindow_ui_tr", 'Pause Download'),
            self,
            statusTip=QCoreApplication.translate("mainwindow_ui_tr",
                                                 "Pause Download"),
            triggered=self.pauseButtonPressed)

        downloadMenu.addAction(self.pauseAction)

        # stopAction
        self.stopAction = QAction(
            QIcon(icons + 'stop'),
            QCoreApplication.translate("mainwindow_ui_tr", 'Stop Download'),
            self,
            statusTip=QCoreApplication.translate("mainwindow_ui_tr",
                                                 "Stop/Cancel Download"),
            triggered=self.stopButtonPressed)

        downloadMenu.addAction(self.stopAction)

        # propertiesAction
        self.propertiesAction = QAction(
            QIcon(icons + 'setting'),
            QCoreApplication.translate("mainwindow_ui_tr", 'Properties'),
            self,
            statusTip=QCoreApplication.translate("mainwindow_ui_tr",
                                                 "Properties"),
            triggered=self.propertiesButtonPressed)

        downloadMenu.addAction(self.propertiesAction)

        # progressAction
        self.progressAction = QAction(
            QIcon(icons + 'window'),
            QCoreApplication.translate("mainwindow_ui_tr", 'Progress'),
            self,
            statusTip=QCoreApplication.translate("mainwindow_ui_tr",
                                                 "Progress"),
            triggered=self.progressButtonPressed)

        downloadMenu.addAction(self.progressAction)

        # openFileAction
        self.openFileAction = QAction(
            QIcon(icons + 'file'),
            QCoreApplication.translate("mainwindow_ui_tr", 'Open File...'),
            self,
            statusTip=QCoreApplication.translate("mainwindow_ui_tr",
                                                 'Open File...'),
            triggered=self.openFile)
        fileMenu.addAction(self.openFileAction)

        # openDownloadFolderAction
        self.openDownloadFolderAction = QAction(
            QIcon(icons + 'folder'),
            QCoreApplication.translate("mainwindow_ui_tr",
                                       'Open Download Folder'),
            self,
            statusTip=QCoreApplication.translate("mainwindow_ui_tr",
                                                 'Open Download Folder'),
            triggered=self.openDownloadFolder)

        fileMenu.addAction(self.openDownloadFolderAction)

        # openDefaultDownloadFolderAction
        self.openDefaultDownloadFolderAction = QAction(
            QIcon(icons + 'folder'),
            QCoreApplication.translate("mainwindow_ui_tr",
                                       'Open Default Download Folder'),
            self,
            statusTip=QCoreApplication.translate(
                "mainwindow_ui_tr", 'Open Default Download Folder'),
            triggered=self.openDefaultDownloadFolder)

        fileMenu.addAction(self.openDefaultDownloadFolderAction)

        # exitAction
        self.exitAction = QAction(
            QIcon(icons + 'exit'),
            QCoreApplication.translate("mainwindow_ui_tr", 'Exit'),
            self,
            statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Exit"),
            triggered=self.closeAction)

        self.exitAction_shortcut = QShortcut(
            self.persepolis_setting.value('quit_shortcut'), self,
            self.closeAction)

        fileMenu.addAction(self.exitAction)

        # clearAction
        self.clearAction = QAction(QIcon(icons + 'multi_remove'),
                                   QCoreApplication.translate(
                                       "mainwindow_ui_tr",
                                       'Clear Download List'),
                                   self,
                                   statusTip=QCoreApplication.translate(
                                       "mainwindow_ui_tr",
                                       'Clear all items in download list'),
                                   triggered=self.clearDownloadList)
        editMenu.addAction(self.clearAction)

        # removeSelectedAction
        self.removeSelectedAction = QAction(
            QIcon(icons + 'remove'),
            QCoreApplication.translate("mainwindow_ui_tr",
                                       'Remove Selected Downloads from List'),
            self,
            statusTip=QCoreApplication.translate(
                "mainwindow_ui_tr", 'Remove Selected Downloads from List'),
            triggered=self.removeSelected)

        self.removeSelectedAction_shortcut = QShortcut(
            self.persepolis_setting.value('remove_shortcut'), self,
            self.removeSelected)

        editMenu.addAction(self.removeSelectedAction)
        self.removeSelectedAction.setEnabled(False)

        # deleteSelectedAction
        self.deleteSelectedAction = QAction(
            QIcon(icons + 'trash'),
            QCoreApplication.translate("mainwindow_ui_tr",
                                       'Delete Selected Download Files'),
            self,
            statusTip=QCoreApplication.translate(
                "mainwindow_ui_tr", 'Delete Selected Download Files'),
            triggered=self.deleteSelected)

        self.deleteSelectedAction_shortcut = QShortcut(
            self.persepolis_setting.value('delete_shortcut'), self,
            self.deleteSelected)

        editMenu.addAction(self.deleteSelectedAction)
        self.deleteSelectedAction.setEnabled(False)

        # moveSelectedDownloadsAction
        self.moveSelectedDownloadsAction = QAction(
            QIcon(icons + 'folder'),
            QCoreApplication.translate(
                "mainwindow_ui_tr",
                'Move Selected Download Files to Another Folder...'),
            self,
            statusTip=QCoreApplication.translate(
                "mainwindow_ui_tr",
                'Move Selected Download Files to Another Folder'),
            triggered=self.moveSelectedDownloads)

        editMenu.addAction(self.moveSelectedDownloadsAction)
        self.moveSelectedDownloadsAction.setEnabled(False)

        # createQueueAction
        self.createQueueAction = QAction(
            QIcon(icons + 'add_queue'),
            QCoreApplication.translate("mainwindow_ui_tr",
                                       'Create New Queue...'),
            self,
            statusTip=QCoreApplication.translate("mainwindow_ui_tr",
                                                 'Create new download queue'),
            triggered=self.createQueue)
        queueMenu.addAction(self.createQueueAction)

        # removeQueueAction
        self.removeQueueAction = QAction(
            QIcon(icons + 'remove_queue'),
            QCoreApplication.translate("mainwindow_ui_tr", 'Remove Queue'),
            self,
            statusTip=QCoreApplication.translate("mainwindow_ui_tr",
                                                 'Remove this queue'),
            triggered=self.removeQueue)
        queueMenu.addAction(self.removeQueueAction)

        # startQueueAction
        self.startQueueAction = QAction(
            QIcon(icons + 'start_queue'),
            QCoreApplication.translate("mainwindow_ui_tr", 'Start this queue'),
            self,
            statusTip=QCoreApplication.translate("mainwindow_ui_tr",
                                                 'Start Queue'),
            triggered=self.startQueue)

        queueMenu.addAction(self.startQueueAction)

        # stopQueueAction
        self.stopQueueAction = QAction(
            QIcon(icons + 'stop_queue'),
            QCoreApplication.translate("mainwindow_ui_tr", 'Stop this queue'),
            self,
            statusTip=QCoreApplication.translate("mainwindow_ui_tr",
                                                 'Stop Queue'),
            triggered=self.stopQueue)

        queueMenu.addAction(self.stopQueueAction)

        # moveUpSelectedAction
        self.moveUpSelectedAction = QAction(
            QIcon(icons + 'multi_up'),
            QCoreApplication.translate("mainwindow_ui_tr",
                                       'Move Selected Items Up'),
            self,
            statusTip=QCoreApplication.translate(
                "mainwindow_ui_tr",
                'Move currently selected items up by one row'),
            triggered=self.moveUpSelected)

        self.moveUpSelectedAction_shortcut = QShortcut(
            self.persepolis_setting.value('move_up_selection_shortcut'), self,
            self.moveUpSelected)

        queueMenu.addAction(self.moveUpSelectedAction)

        # moveDownSelectedAction
        self.moveDownSelectedAction = QAction(
            QIcon(icons + 'multi_down'),
            QCoreApplication.translate("mainwindow_ui_tr",
                                       'Move Selected Items Down'),
            self,
            statusTip=QCoreApplication.translate(
                "mainwindow_ui_tr",
                'Move currently selected items down by one row'),
            triggered=self.moveDownSelected)
        self.moveDownSelectedAction_shortcut = QShortcut(
            self.persepolis_setting.value('move_down_selection_shortcut'),
            self, self.moveDownSelected)

        queueMenu.addAction(self.moveDownSelectedAction)

        # preferencesAction
        self.preferencesAction = QAction(
            QIcon(icons + 'preferences'),
            QCoreApplication.translate("mainwindow_ui_tr", 'Preferences'),
            self,
            statusTip=QCoreApplication.translate("mainwindow_ui_tr",
                                                 'Preferences'),
            triggered=self.openPreferences,
            menuRole=QAction.MenuRole.PreferencesRole)
        editMenu.addAction(self.preferencesAction)

        # aboutAction
        self.aboutAction = QAction(
            QIcon(icons + 'about'),
            QCoreApplication.translate("mainwindow_ui_tr", 'About'),
            self,
            statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'About'),
            triggered=self.openAbout,
            menuRole=QAction.MenuRole.AboutRole)
        helpMenu.addAction(self.aboutAction)

        # issueAction
        self.issueAction = QAction(
            QIcon(icons + 'about'),
            QCoreApplication.translate("mainwindow_ui_tr", 'Report an Issue'),
            self,
            statusTip=QCoreApplication.translate("mainwindow_ui_tr",
                                                 'Report an issue'),
            triggered=self.reportIssue)
        helpMenu.addAction(self.issueAction)

        # updateAction
        self.updateAction = QAction(
            QIcon(icons + 'about'),
            QCoreApplication.translate("mainwindow_ui_tr",
                                       'Check for Newer Version'),
            self,
            statusTip=QCoreApplication.translate("mainwindow_ui_tr",
                                                 'Check for newer release'),
            triggered=self.newUpdate)
        helpMenu.addAction(self.updateAction)

        # logAction
        self.logAction = QAction(
            QIcon(icons + 'about'),
            QCoreApplication.translate("mainwindow_ui_tr", 'Show Log File'),
            self,
            statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Help'),
            triggered=self.showLog)
        helpMenu.addAction(self.logAction)

        # helpAction
        self.helpAction = QAction(
            QIcon(icons + 'about'),
            QCoreApplication.translate("mainwindow_ui_tr", 'Help'),
            self,
            statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Help'),
            triggered=self.persepolisHelp)
        helpMenu.addAction(self.helpAction)

        self.persepolis_setting.endGroup()

        self.qmenu = MenuWidget(self)

        self.toolBar2.addWidget(self.qmenu)

        # labels
        self.queue_panel_show_button.setText(
            QCoreApplication.translate("mainwindow_ui_tr", "Hide Options"))
        self.start_checkBox.setText(
            QCoreApplication.translate("mainwindow_ui_tr", "Start Time"))

        self.end_checkBox.setText(
            QCoreApplication.translate("mainwindow_ui_tr", "End Time"))

        self.reverse_checkBox.setText(
            QCoreApplication.translate("mainwindow_ui_tr",
                                       "Download bottom of\n the list first"))

        self.limit_checkBox.setText(
            QCoreApplication.translate("mainwindow_ui_tr", "Limit Speed"))
        self.limit_comboBox.setItemText(0, "KiB/s")
        self.limit_comboBox.setItemText(1, "MiB/s")
        self.limit_pushButton.setText(
            QCoreApplication.translate("mainwindow_ui_tr", "Apply"))

        self.after_checkBox.setText(
            QCoreApplication.translate("mainwindow_ui_tr", "After download"))
        self.after_comboBox.setItemText(
            0, QCoreApplication.translate("mainwindow_ui_tr", "Shut Down"))

        self.keep_awake_checkBox.setText(
            QCoreApplication.translate("mainwindow_ui_tr",
                                       "Keep System Awake!"))
        self.keep_awake_checkBox.setToolTip(
            QCoreApplication.translate(
                "mainwindow_ui_tr",
                "<html><head/><body><p>This option will prevent the system from going to sleep.\
            It is necessary if your power manager is suspending the system automatically. </p></body></html>"
            ))

        self.after_pushButton.setText(
            QCoreApplication.translate("mainwindow_ui_tr", "Apply"))

        self.muxing_pushButton.setText(
            QCoreApplication.translate("mainwindow_ui_tr", "Start Mixing"))

        self.video_label.setText(
            QCoreApplication.translate("mainwindow_ui_tr",
                                       "<b>Video File Status: </b>"))
        self.audio_label.setText(
            QCoreApplication.translate("mainwindow_ui_tr",
                                       "<b>Audio File Status: </b>"))

        self.video_finder_status_label.setText(
            QCoreApplication.translate("mainwindow_ui_tr", "<b>Status: </b>"))
        self.muxing_status_label.setText(
            QCoreApplication.translate("mainwindow_ui_tr",
                                       "<b>Mixing status: </b>"))
class JobsWindow(QWidget):
    def __init__(self):
        super().__init__()
        self.quit_button = QPushButton("Quit", self)
        self.update_button = QPushButton("Update Data", self)
        self.enter_data = QPushButton("Enter Data", self)
        self.data_button = QPushButton("Run Data Visualization", self)
        self.back_button = QPushButton("Back", self)
        self.text_visualization_button = QPushButton("Text Visualization", self)
        self.map_visualization = QPushButton("Map Visualization", self)
        self.order_selector_text = QComboBox(self)
        self.data_selector_map = QComboBox(self)
        self.data_visualization_label = QLabel("Welcome to data visualization!", self)
        self.welcome_label = QLabel("Welcome to Jobs data Visualization.", self)
        self.list_control = None
        self.update_label_01 = QLabel("", self)
        self.update_label_02 = QLabel("", self)
        self.update_label_03 = QLabel("", self)
        self.update_label_04 = QLabel("", self)
        self.update_label_05 = QLabel("", self)
        self.update_label_06 = QLabel("", self)
        self.update_label_07 = QLabel("", self)
        self.update_label_08 = QLabel("", self)
        self.excel_label = QLabel("Excel Spreadsheet:", self)
        self.update_information = QLabel(
            "If you would like to update a single entry please select the table and enter all of its information.\n"
            "If you would like to import from a spreadsheet type it into the box on the right and select the table.\n"
            "When you are ready with which ever function press Enter Data.\n"
            "For any data you want to append make sure the id is None.\n"
            "Also only work from one method at a time and make sure he other is empty.", self)
        self.table_selection = QComboBox(self)
        self.update_box_01 = QLineEdit(self)
        self.update_box_02 = QLineEdit(self)
        self.update_box_03 = QLineEdit(self)
        self.update_box_04 = QLineEdit(self)
        self.update_box_05 = QLineEdit(self)
        self.update_box_06 = QLineEdit(self)
        self.update_box_07 = QLineEdit(self)
        self.update_box_08 = QLineEdit(self)
        self.update_excel_selection = QLineEdit(self)
        self.list_control = None
        self.setup_window()

    def setup_window(self):
        self.setWindowTitle("Jobs Window")
        display_list = QListWidget(self)
        self.list_control = display_list
        display_list.resize(500, 350)
        self.setGeometry(50, 50, 500, 500)
        self.quit_button.clicked.connect(QApplication.instance().quit)
        self.quit_button.resize(self.quit_button.sizeHint())
        self.quit_button.move(415, 450)
        self.update_button.clicked.connect(self.update_data)
        self.update_button.move(200, 200)
        self.data_button.clicked.connect(self.run_data_visualization)
        self.data_button.move(175, 250)
        self.back_button.clicked.connect(self.go_back)
        self.back_button.move(25, 450)
        self.data_visualization_label.move(20, 400)
        self.text_visualization_button.move(400 - self.text_visualization_button.width(), 600)
        self.order_selector_text.move(self.text_visualization_button.x(),
                                      self.text_visualization_button.y()+self.text_visualization_button.height()+10)
        self.text_visualization_button.clicked.connect(self.text_visualization)
        self.map_visualization.move(self.text_visualization_button.x() + self.text_visualization_button.width(),
                                    self.text_visualization_button.y())
        self.data_selector_map.move(self.map_visualization.x(),
                                    self.map_visualization.y()+self.map_visualization.height()+10)
        self.map_visualization.clicked.connect(self.run_map_visualization)
        self.welcome_label.move(150, 150)
        self.update_box_01.move(150, 30)
        self.update_box_02.move(150, 60)
        self.update_box_03.move(150, 90)
        self.update_box_04.move(150, 120)
        self.update_box_05.move(150, 150)
        self.update_box_06.move(150, 180)
        self.update_box_07.move(150, 210)
        self.update_box_08.move(150, 240)
        self.excel_label.move(340, 70)
        self.update_excel_selection.move(340, 90)
        self.update_information.move(25, 325)
        self.update_label_01.setGeometry(5, 30, 145, 20)
        self.update_label_02.setGeometry(5, 60, 145, 20)
        self.update_label_03.setGeometry(5, 90, 145, 20)
        self.update_label_04.setGeometry(5, 120, 145, 20)
        self.update_label_05.setGeometry(5, 150, 145, 20)
        self.update_label_06.setGeometry(5, 180, 145, 20)
        self.update_label_07.setGeometry(5, 210, 145, 20)
        self.update_label_08.setGeometry(5, 240, 145, 20)
        self.table_selection.setGeometry(10, 10, 145, 20)
        self.enter_data.move(10, 260)
        self.enter_data.clicked.connect(self.import_data)
        self.table_selection.addItem("---")
        self.table_selection.addItem("Schools")
        self.table_selection.addItem("Jobs")
        self.order_selector_text.addItem("---")
        self.order_selector_text.addItem("ASC")
        self.order_selector_text.addItem("DESC")
        self.data_selector_map.addItem("---")
        self.data_selector_map.addItem("Employment to Graduates")
        self.data_selector_map.addItem("Average Salary to Average Declining Balance Percent")
        self.table_selection.currentIndexChanged.connect(self.update_selection)
        self.hidden_at_start()

        self.show()

    def hidden_at_start(self):
        self.hide_update_boxes()
        self.list_control.hide()
        self.update_information.hide()
        self.map_visualization.hide()
        self.text_visualization_button.hide()
        self.data_visualization_label.hide()
        self.back_button.hide()
        self.table_selection.hide()
        self.enter_data.hide()
        self.update_excel_selection.hide()
        self.excel_label.hide()
        self.data_selector_map.hide()
        self.order_selector_text.hide()

    def hide_update_boxes(self):
        self.update_box_01.hide()
        self.update_box_02.hide()
        self.update_box_03.hide()
        self.update_box_04.hide()
        self.update_box_05.hide()
        self.update_box_06.hide()
        self.update_box_07.hide()
        self.update_box_08.hide()
        self.update_label_01.setText("")
        self.update_label_02.setText("")
        self.update_label_03.setText("")
        self.update_label_04.setText("")
        self.update_label_05.setText("")
        self.update_label_06.setText("")
        self.update_label_07.setText("")
        self.update_label_08.setText("")

    def update_data(self):
        self.update_button.hide()
        self.data_button.hide()
        self.back_button.show()
        self.welcome_label.hide()
        self.table_selection.show()
        self.enter_data.show()
        self.update_information.show()
        self.update_excel_selection.show()
        self.excel_label.show()

    def update_selection(self):
        self.hide_update_boxes()
        if self.table_selection.currentText() == "Jobs":
            self.update_box_01.show()
            self.update_label_01.setText("jobs_id")
            self.update_box_02.show()
            self.update_label_02.setText("state_name")
            self.update_box_03.show()
            self.update_label_03.setText("occupation_code")
            self.update_box_04.show()
            self.update_label_04.setText("tittle")
            self.update_box_05.show()
            self.update_label_05.setText("employment")
            self.update_box_06.show()
            self.update_label_06.setText("salary_25th_percentile")
        elif self.table_selection.currentText() == "Schools":
            self.update_box_01.show()
            self.update_label_01.setText("school_id")
            self.update_box_02.show()
            self.update_label_02.setText("name")
            self.update_box_03.show()
            self.update_label_03.setText("state_abrev")
            self.update_box_04.show()
            self.update_label_04.setText("size_2017")
            self.update_box_05.show()
            self.update_label_05.setText("size_2018")
            self.update_box_06.show()
            self.update_label_06.setText("earnings")
            self.update_box_07.show()
            self.update_label_07.setText("repayment_overall")
            self.update_box_08.show()
            self.update_label_08.setText("repayment_cohort")

    def import_data(self):
        if self.update_excel_selection.text() == "":
            if self.table_selection.currentText() == "Jobs":
                information_to_update = [self.update_box_01.text(), self.update_box_02.text(),
                                         self.update_box_03.text(), self.update_box_04.text(),
                                         self.update_box_05.text(), self.update_box_06.text()]
                jobs.update_data_from_list(information_to_update, "Jobs", "jobs_db.sqlite")
            elif self.table_selection.currentText() == "Schools":
                information_to_update = [self.update_box_01.text(), self.update_box_02.text(),
                                         self.update_box_03.text(), self.update_box_04.text(),
                                         self.update_box_05.text(), self.update_box_06.text(),
                                         self.update_box_07.text(), self.update_box_08.text()]
                jobs.update_data_from_list(information_to_update, "Schools", "jobs_db.sqlite")
        else:
            if self.table_selection.currentText() == "Jobs":
                jobs.update_data_from_excel(self.update_excel_selection.text(), "Jobs", "jobs_db.sqlite")
            elif self.table_selection.currentText() == "Schools":
                jobs.update_data_from_excel(self.update_excel_selection.text(), "Jobs", "jobs_db.sqlite")

    def run_data_visualization(self):
        self.update_button.hide()
        self.data_button.hide()
        self.data_visualization_label.show()
        self.back_button.show()
        self.setGeometry(50, 50, 800, 800)
        self.back_button.move(25, 750)
        self.quit_button.move(715, 750)
        self.welcome_label.hide()
        self.map_visualization.show()
        self.text_visualization_button.show()
        self.data_selector_map.show()
        self.order_selector_text.show()

    def go_back(self):
        self.back_button.hide()
        self.update_button.show()
        self.data_button.show()
        self.data_visualization_label.hide()
        self.setGeometry(50, 50, 500, 500)
        self.back_button.move(25, 450)
        self.quit_button.move(415, 450)
        self.welcome_label.show()
        self.hidden_at_start()

    def text_visualization(self):
        self.list_control.clear()
        conn, cursor = jobs.open_db("jobs_db.sqlite")
        if self.order_selector_text.currentText() == "ASC":
            data_visualization_per_state = jobs.query_run('''SELECT state_abrev, state_name, ''' + '''
            total(jobs.employment) as employment,
            total(school.size_2018/4),
            round(avg(school.repayment_cohort),3) as repayment_cohort,
            round(avg(jobs.salary_25th_percentile)) as averge_entry_salary
            FROM school
            JOIN states using(state_abrev)
            JOIN jobs using(state_name)
            GROUP BY state_name
            ORDER BY employment ASC;''', cursor)
        elif self.order_selector_text.currentText() == "DESC":
            data_visualization_per_state = jobs.query_run('''SELECT state_abrev, state_name, ''' + '''
                        total(jobs.employment) as employment,
                        total(school.size_2018/4),
                        round(avg(school.repayment_cohort),3) as repayment_cohort,
                        round(avg(jobs.salary_25th_percentile)) as averge_entry_salary
                        FROM school
                        JOIN states using(state_abrev)
                        JOIN jobs using(state_name)
                        GROUP BY state_name
                        ORDER BY employment DESC;''', cursor)
        else:
            data_visualization_per_state = jobs.query_run('''SELECT state_abrev, state_name, ''' + '''
                                    total(jobs.employment) as employment,
                                    total(school.size_2018/4),
                                    round(avg(school.repayment_cohort),3) as repayment_cohort,
                                    round(avg(jobs.salary_25th_percentile)) as averge_entry_salary
                                    FROM school
                                    JOIN states using(state_abrev)
                                    JOIN jobs using(state_name)
                                    GROUP BY state_name
                                    ;''', cursor)
        QListWidgetItem("State", listview=self.list_control)
        for state in data_visualization_per_state:
            state_display_data = f"{state[0]}, {state[1]}"
            grad_employ_data = f"Employment/Graduates: {state[2]/state[3]}"
            repayment_data = f"Average Entry Salary/Average Declining Balance Percent: {state[5]/state[4]}"
            state_item = QListWidgetItem(state_display_data, listview=self.list_control)
            grad_item = QListWidgetItem(grad_employ_data, listview=self.list_control)
            repayment_item = QListWidgetItem(repayment_data, listview=self.list_control)
            grad_item.setForeground(Qt.darkGreen)
            repayment_item.setForeground(Qt.blue)
            state_item.setForeground(Qt.white)
            state_item.setBackground(Qt.black)
        self.list_control.show()
        jobs.close_db(conn)

    def run_map_visualization(self):
        conn, cursor = jobs.open_db("jobs_db.sqlite")
        data_visualization_per_state = jobs.query_run('''SELECT state_abrev, state_name, ''' + '''
                total(jobs.employment) as employment,
                total(school.size_2018/4),
                round(avg(school.repayment_cohort),3) as repayment_cohort,
                round(avg(jobs.salary_25th_percentile)) as averge_entry_salary
                FROM school
                JOIN states using(state_abrev)
                JOIN jobs using(state_name)
                GROUP BY state_name
                ;''', cursor)
        state_abrev = []
        state_grads = []
        state_repayment = []

        for state in data_visualization_per_state:
            state_abrev.append(state[0])
            state_grads.append(state[2]/state[3])
            state_repayment.append(state[5]/state[4])

        if self.data_selector_map.currentText() == "Graduates to Employment":
            us_map = px.Figure(data=px.Choropleth(locations=state_abrev, z=state_grads,
                                                  locationmode='USA-states', colorbar_title="Employment/Graduates"
                                                  ))
            us_map.update_layout(geo_scope='usa', title_text='Employment VS Graduates By State')
            us_map.show()
        elif self.data_selector_map.currentText() == "Average Declining Balance Percent":
            us_map = px.Figure(data=px.Choropleth(locations=state_abrev, z=state_repayment,
                                                  locationmode='USA-states', colorbar_title="Salary/Average Percent"
                                                  ))
            us_map.update_layout(geo_scope='usa', title_text='Average Salary VS Average '
                                                             'Percent of People with Declining Loans')
            us_map.show()
        else:
            us_map = px.Figure(data=px.Choropleth(locations=state_abrev, z=state_grads,
                                                  locationmode='USA-states', colorbar_title="Graduates"
                                                  ))
            us_map.update_layout(geo_scope='usa', title_text='Graduates By State')
            us_map.show()
        jobs.close_db(conn)
        self.list_control.hide()
Exemple #21
0
class Ui_ConfigCapture_UI(object):
    def setupUi(self, ConfigCapture_UI):
        if not ConfigCapture_UI.objectName():
            ConfigCapture_UI.setObjectName(u"ConfigCapture_UI")
        ConfigCapture_UI.resize(525, 520)
        self.gridLayout_8 = QGridLayout(ConfigCapture_UI)
        self.gridLayout_8.setObjectName(u"gridLayout_8")
        self.gridLayout_8.setContentsMargins(0, 0, -1, -1)
        self.label = QLabel(ConfigCapture_UI)
        self.label.setObjectName(u"label")

        self.gridLayout_8.addWidget(self.label, 0, 0, 1, 1)

        self.kcfg_defaultcapture = QComboBox(ConfigCapture_UI)
        self.kcfg_defaultcapture.addItem("")
        self.kcfg_defaultcapture.addItem("")
        self.kcfg_defaultcapture.setObjectName(u"kcfg_defaultcapture")
        sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.kcfg_defaultcapture.sizePolicy().hasHeightForWidth())
        self.kcfg_defaultcapture.setSizePolicy(sizePolicy)

        self.gridLayout_8.addWidget(self.kcfg_defaultcapture, 0, 1, 1, 1)

        self.tabWidget = QTabWidget(ConfigCapture_UI)
        self.tabWidget.setObjectName(u"tabWidget")
        self.tabWidget.setMinimumSize(QSize(401, 0))
        self.ffmpeg_tab = QWidget()
        self.ffmpeg_tab.setObjectName(u"ffmpeg_tab")
        self.gridLayout = QGridLayout(self.ffmpeg_tab)
        self.gridLayout.setObjectName(u"gridLayout")
        self.line = QFrame(self.ffmpeg_tab)
        self.line.setObjectName(u"line")
        self.line.setFrameShape(QFrame.HLine)
        self.line.setFrameShadow(QFrame.Sunken)

        self.gridLayout.addWidget(self.line, 10, 0, 4, 8)

        self.label_9 = QLabel(self.ffmpeg_tab)
        self.label_9.setObjectName(u"label_9")

        self.gridLayout.addWidget(self.label_9, 3, 0, 1, 2)

        self.kcfg_alsachannels = QSpinBox(self.ffmpeg_tab)
        self.kcfg_alsachannels.setObjectName(u"kcfg_alsachannels")

        self.gridLayout.addWidget(self.kcfg_alsachannels, 15, 6, 1, 2)

        self.label_24 = QLabel(self.ffmpeg_tab)
        self.label_24.setObjectName(u"label_24")
        sizePolicy1 = QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Preferred)
        sizePolicy1.setHorizontalStretch(0)
        sizePolicy1.setVerticalStretch(0)
        sizePolicy1.setHeightForWidth(
            self.label_24.sizePolicy().hasHeightForWidth())
        self.label_24.setSizePolicy(sizePolicy1)

        self.gridLayout.addWidget(self.label_24, 18, 0, 1, 2)

        self.label_4 = QLabel(self.ffmpeg_tab)
        self.label_4.setObjectName(u"label_4")

        self.gridLayout.addWidget(self.label_4, 5, 0, 1, 2)

        self.kcfg_v4l_format = QComboBox(self.ffmpeg_tab)
        self.kcfg_v4l_format.setObjectName(u"kcfg_v4l_format")

        self.gridLayout.addWidget(self.kcfg_v4l_format, 3, 3, 1, 5)

        self.label_11 = QLabel(self.ffmpeg_tab)
        self.label_11.setObjectName(u"label_11")

        self.gridLayout.addWidget(self.label_11, 15, 5, 1, 1)

        self.horizontalSpacer_5 = QSpacerItem(127, 21, QSizePolicy.Expanding,
                                              QSizePolicy.Minimum)

        self.gridLayout.addItem(self.horizontalSpacer_5, 9, 3, 1, 2)

        self.config_v4l = QPushButton(self.ffmpeg_tab)
        self.config_v4l.setObjectName(u"config_v4l")

        self.gridLayout.addWidget(self.config_v4l, 9, 5, 1, 3)

        self.kcfg_v4l_alsadevice = QComboBox(self.ffmpeg_tab)
        self.kcfg_v4l_alsadevice.setObjectName(u"kcfg_v4l_alsadevice")
        sizePolicy2 = QSizePolicy(QSizePolicy.MinimumExpanding,
                                  QSizePolicy.Fixed)
        sizePolicy2.setHorizontalStretch(0)
        sizePolicy2.setVerticalStretch(0)
        sizePolicy2.setHeightForWidth(
            self.kcfg_v4l_alsadevice.sizePolicy().hasHeightForWidth())
        self.kcfg_v4l_alsadevice.setSizePolicy(sizePolicy2)

        self.gridLayout.addWidget(self.kcfg_v4l_alsadevice, 15, 0, 1, 5)

        self.label_31 = QLabel(self.ffmpeg_tab)
        self.label_31.setObjectName(u"label_31")

        self.gridLayout.addWidget(self.label_31, 7, 0, 1, 3)

        self.p_progressive = QLabel(self.ffmpeg_tab)
        self.p_progressive.setObjectName(u"p_progressive")

        self.gridLayout.addWidget(self.p_progressive, 9, 0, 1, 2)

        self.label_30 = QLabel(self.ffmpeg_tab)
        self.label_30.setObjectName(u"label_30")

        self.gridLayout.addWidget(self.label_30, 1, 0, 1, 2)

        self.label_14 = QLabel(self.ffmpeg_tab)
        self.label_14.setObjectName(u"label_14")

        self.gridLayout.addWidget(self.label_14, 2, 0, 1, 2)

        self.v4l_profile_box = QHBoxLayout()
        self.v4l_profile_box.setObjectName(u"v4l_profile_box")

        self.gridLayout.addLayout(self.v4l_profile_box, 18, 3, 1, 5)

        self.kcfg_detectedv4ldevices = QComboBox(self.ffmpeg_tab)
        self.kcfg_detectedv4ldevices.setObjectName(u"kcfg_detectedv4ldevices")

        self.gridLayout.addWidget(self.kcfg_detectedv4ldevices, 1, 3, 1, 5)

        self.p_aspect = QLabel(self.ffmpeg_tab)
        self.p_aspect.setObjectName(u"p_aspect")

        self.gridLayout.addWidget(self.p_aspect, 6, 3, 1, 5)

        self.label_23 = QLabel(self.ffmpeg_tab)
        self.label_23.setObjectName(u"label_23")

        self.gridLayout.addWidget(self.label_23, 6, 0, 1, 2)

        self.kcfg_v4l_captureaudio = QCheckBox(self.ffmpeg_tab)
        self.kcfg_v4l_captureaudio.setObjectName(u"kcfg_v4l_captureaudio")

        self.gridLayout.addWidget(self.kcfg_v4l_captureaudio, 14, 0, 1, 8)

        self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Minimum,
                                          QSizePolicy.Expanding)

        self.gridLayout.addItem(self.verticalSpacer, 20, 1, 1, 3)

        self.kcfg_v4l_capturevideo = QCheckBox(self.ffmpeg_tab)
        self.kcfg_v4l_capturevideo.setObjectName(u"kcfg_v4l_capturevideo")

        self.gridLayout.addWidget(self.kcfg_v4l_capturevideo, 0, 0, 1, 8)

        self.label_6 = QLabel(self.ffmpeg_tab)
        self.label_6.setObjectName(u"label_6")

        self.gridLayout.addWidget(self.label_6, 4, 0, 1, 1)

        self.line_2 = QFrame(self.ffmpeg_tab)
        self.line_2.setObjectName(u"line_2")
        self.line_2.setFrameShape(QFrame.HLine)
        self.line_2.setFrameShadow(QFrame.Sunken)

        self.gridLayout.addWidget(self.line_2, 17, 0, 1, 8)

        self.label_32 = QLabel(self.ffmpeg_tab)
        self.label_32.setObjectName(u"label_32")

        self.gridLayout.addWidget(self.label_32, 8, 0, 1, 2)

        self.p_size = QLabel(self.ffmpeg_tab)
        self.p_size.setObjectName(u"p_size")

        self.gridLayout.addWidget(self.p_size, 4, 3, 1, 5)

        self.p_display = QLabel(self.ffmpeg_tab)
        self.p_display.setObjectName(u"p_display")

        self.gridLayout.addWidget(self.p_display, 7, 3, 1, 5)

        self.kcfg_video4vdevice = QLineEdit(self.ffmpeg_tab)
        self.kcfg_video4vdevice.setObjectName(u"kcfg_video4vdevice")

        self.gridLayout.addWidget(self.kcfg_video4vdevice, 2, 3, 1, 5)

        self.p_colorspace = QLabel(self.ffmpeg_tab)
        self.p_colorspace.setObjectName(u"p_colorspace")

        self.gridLayout.addWidget(self.p_colorspace, 8, 3, 1, 5)

        self.p_fps = QLabel(self.ffmpeg_tab)
        self.p_fps.setObjectName(u"p_fps")

        self.gridLayout.addWidget(self.p_fps, 5, 3, 1, 5)

        self.tabWidget.addTab(self.ffmpeg_tab, "")
        self.screen_grab_tab = QWidget()
        self.screen_grab_tab.setObjectName(u"screen_grab_tab")
        self.gridLayout_5 = QGridLayout(self.screen_grab_tab)
        self.gridLayout_5.setObjectName(u"gridLayout_5")
        self.kcfg_grab_hide_mouse = QCheckBox(self.screen_grab_tab)
        self.kcfg_grab_hide_mouse.setObjectName(u"kcfg_grab_hide_mouse")

        self.gridLayout_5.addWidget(self.kcfg_grab_hide_mouse, 3, 0, 1, 4)

        self.horizontalSpacer_2 = QSpacerItem(237, 20, QSizePolicy.Expanding,
                                              QSizePolicy.Minimum)

        self.gridLayout_5.addItem(self.horizontalSpacer_2, 2, 2, 1, 1)

        self.verticalSpacer_3 = QSpacerItem(383, 160, QSizePolicy.Minimum,
                                            QSizePolicy.Expanding)

        self.gridLayout_5.addItem(self.verticalSpacer_3, 8, 0, 1, 3)

        self.label_screengrab = QLabel(self.screen_grab_tab)
        self.label_screengrab.setObjectName(u"label_screengrab")
        sizePolicy1.setHeightForWidth(
            self.label_screengrab.sizePolicy().hasHeightForWidth())
        self.label_screengrab.setSizePolicy(sizePolicy1)

        self.gridLayout_5.addWidget(self.label_screengrab, 5, 0, 1, 1)

        self.kcfg_grab_capture_type = QComboBox(self.screen_grab_tab)
        self.kcfg_grab_capture_type.addItem("")
        self.kcfg_grab_capture_type.addItem("")
        self.kcfg_grab_capture_type.setObjectName(u"kcfg_grab_capture_type")

        self.gridLayout_5.addWidget(self.kcfg_grab_capture_type, 0, 0, 1, 3)

        self.screen_grab_profile_box = QHBoxLayout()
        self.screen_grab_profile_box.setObjectName(u"screen_grab_profile_box")

        self.gridLayout_5.addLayout(self.screen_grab_profile_box, 5, 1, 1, 2)

        self.label_18 = QLabel(self.screen_grab_tab)
        self.label_18.setObjectName(u"label_18")

        self.gridLayout_5.addWidget(self.label_18, 2, 0, 1, 1)

        self.region_group = QFrame(self.screen_grab_tab)
        self.region_group.setObjectName(u"region_group")
        self.region_group.setFrameShape(QFrame.StyledPanel)
        self.region_group.setFrameShadow(QFrame.Raised)
        self.gridLayout_3 = QGridLayout(self.region_group)
        self.gridLayout_3.setObjectName(u"gridLayout_3")
        self.horizontalLayout = QHBoxLayout()
        self.horizontalLayout.setObjectName(u"horizontalLayout")
        self.kcfg_grab_follow_mouse = QCheckBox(self.region_group)
        self.kcfg_grab_follow_mouse.setObjectName(u"kcfg_grab_follow_mouse")

        self.horizontalLayout.addWidget(self.kcfg_grab_follow_mouse)

        self.kcfg_grab_hide_frame = QCheckBox(self.region_group)
        self.kcfg_grab_hide_frame.setObjectName(u"kcfg_grab_hide_frame")

        self.horizontalLayout.addWidget(self.kcfg_grab_hide_frame)

        self.horizontalSpacer_4 = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                              QSizePolicy.Minimum)

        self.horizontalLayout.addItem(self.horizontalSpacer_4)

        self.gridLayout_3.addLayout(self.horizontalLayout, 0, 0, 1, 3)

        self.label_19 = QLabel(self.region_group)
        self.label_19.setObjectName(u"label_19")

        self.gridLayout_3.addWidget(self.label_19, 1, 0, 1, 1)

        self.kcfg_grab_offsetx = QSpinBox(self.region_group)
        self.kcfg_grab_offsetx.setObjectName(u"kcfg_grab_offsetx")
        sizePolicy.setHeightForWidth(
            self.kcfg_grab_offsetx.sizePolicy().hasHeightForWidth())
        self.kcfg_grab_offsetx.setSizePolicy(sizePolicy)
        self.kcfg_grab_offsetx.setMaximum(5000)
        self.kcfg_grab_offsetx.setValue(0)

        self.gridLayout_3.addWidget(self.kcfg_grab_offsetx, 1, 1, 1, 1)

        self.kcfg_grab_offsety = QSpinBox(self.region_group)
        self.kcfg_grab_offsety.setObjectName(u"kcfg_grab_offsety")
        sizePolicy.setHeightForWidth(
            self.kcfg_grab_offsety.sizePolicy().hasHeightForWidth())
        self.kcfg_grab_offsety.setSizePolicy(sizePolicy)
        self.kcfg_grab_offsety.setMaximum(5000)
        self.kcfg_grab_offsety.setValue(0)

        self.gridLayout_3.addWidget(self.kcfg_grab_offsety, 1, 2, 1, 1)

        self.label_20 = QLabel(self.region_group)
        self.label_20.setObjectName(u"label_20")

        self.gridLayout_3.addWidget(self.label_20, 2, 0, 1, 1)

        self.kcfg_grab_width = QSpinBox(self.region_group)
        self.kcfg_grab_width.setObjectName(u"kcfg_grab_width")
        self.kcfg_grab_width.setMinimum(1)
        self.kcfg_grab_width.setMaximum(5000)
        self.kcfg_grab_width.setValue(1280)

        self.gridLayout_3.addWidget(self.kcfg_grab_width, 2, 1, 1, 1)

        self.kcfg_grab_height = QSpinBox(self.region_group)
        self.kcfg_grab_height.setObjectName(u"kcfg_grab_height")
        self.kcfg_grab_height.setMinimum(1)
        self.kcfg_grab_height.setMaximum(5000)
        self.kcfg_grab_height.setValue(720)

        self.gridLayout_3.addWidget(self.kcfg_grab_height, 2, 2, 1, 1)

        self.gridLayout_5.addWidget(self.region_group, 1, 0, 1, 3)

        self.kcfg_grab_fps = QDoubleSpinBox(self.screen_grab_tab)
        self.kcfg_grab_fps.setObjectName(u"kcfg_grab_fps")
        self.kcfg_grab_fps.setMinimum(1.000000000000000)
        self.kcfg_grab_fps.setMaximum(1000.000000000000000)

        self.gridLayout_5.addWidget(self.kcfg_grab_fps, 2, 1, 1, 1)

        self.tabWidget.addTab(self.screen_grab_tab, "")
        self.decklink_tab = QWidget()
        self.decklink_tab.setObjectName(u"decklink_tab")
        self.gridLayout_6 = QGridLayout(self.decklink_tab)
        self.gridLayout_6.setObjectName(u"gridLayout_6")
        self.kcfg_decklink_capturedevice = QComboBox(self.decklink_tab)
        self.kcfg_decklink_capturedevice.setObjectName(
            u"kcfg_decklink_capturedevice")
        sizePolicy.setHeightForWidth(
            self.kcfg_decklink_capturedevice.sizePolicy().hasHeightForWidth())
        self.kcfg_decklink_capturedevice.setSizePolicy(sizePolicy)

        self.gridLayout_6.addWidget(self.kcfg_decklink_capturedevice, 0, 1, 1,
                                    1)

        self.kcfg_decklink_filename = QLineEdit(self.decklink_tab)
        self.kcfg_decklink_filename.setObjectName(u"kcfg_decklink_filename")

        self.gridLayout_6.addWidget(self.kcfg_decklink_filename, 5, 1, 1, 1)

        self.label_16 = QLabel(self.decklink_tab)
        self.label_16.setObjectName(u"label_16")
        sizePolicy1.setHeightForWidth(
            self.label_16.sizePolicy().hasHeightForWidth())
        self.label_16.setSizePolicy(sizePolicy1)

        self.gridLayout_6.addWidget(self.label_16, 2, 0, 1, 1)

        self.label_29 = QLabel(self.decklink_tab)
        self.label_29.setObjectName(u"label_29")

        self.gridLayout_6.addWidget(self.label_29, 5, 0, 1, 1)

        self.verticalSpacer_4 = QSpacerItem(20, 327, QSizePolicy.Minimum,
                                            QSizePolicy.Expanding)

        self.gridLayout_6.addItem(self.verticalSpacer_4, 6, 1, 1, 1)

        self.label_27 = QLabel(self.decklink_tab)
        self.label_27.setObjectName(u"label_27")

        self.gridLayout_6.addWidget(self.label_27, 0, 0, 1, 1)

        self.decklink_profile_box = QHBoxLayout()
        self.decklink_profile_box.setSpacing(0)
        self.decklink_profile_box.setObjectName(u"decklink_profile_box")

        self.gridLayout_6.addLayout(self.decklink_profile_box, 2, 1, 1, 1)

        self.tabWidget.addTab(self.decklink_tab, "")
        self.audio_tab = QWidget()
        self.audio_tab.setObjectName(u"audio_tab")
        self.gridLayout_2 = QGridLayout(self.audio_tab)
        self.gridLayout_2.setObjectName(u"gridLayout_2")
        self.label_5 = QLabel(self.audio_tab)
        self.label_5.setObjectName(u"label_5")

        self.gridLayout_2.addWidget(self.label_5, 5, 0, 1, 1)

        self.label_2 = QLabel(self.audio_tab)
        self.label_2.setObjectName(u"label_2")

        self.gridLayout_2.addWidget(self.label_2, 3, 0, 1, 1)

        self.verticalSpacer_2 = QSpacerItem(20, 661, QSizePolicy.Minimum,
                                            QSizePolicy.Expanding)

        self.gridLayout_2.addItem(self.verticalSpacer_2, 6, 1, 1, 1)

        self.label_3 = QLabel(self.audio_tab)
        self.label_3.setObjectName(u"label_3")

        self.gridLayout_2.addWidget(self.label_3, 4, 0, 1, 1)

        self.audiocapturesamplerate = QComboBox(self.audio_tab)
        self.audiocapturesamplerate.setObjectName(u"audiocapturesamplerate")

        self.gridLayout_2.addWidget(self.audiocapturesamplerate, 5, 1, 1, 1)

        self.kcfg_audiocapturevolume = QSlider(self.audio_tab)
        self.kcfg_audiocapturevolume.setObjectName(u"kcfg_audiocapturevolume")
        self.kcfg_audiocapturevolume.setMaximum(100)
        self.kcfg_audiocapturevolume.setSliderPosition(100)
        self.kcfg_audiocapturevolume.setTracking(True)
        self.kcfg_audiocapturevolume.setOrientation(Qt.Horizontal)
        self.kcfg_audiocapturevolume.setInvertedAppearance(False)
        self.kcfg_audiocapturevolume.setInvertedControls(False)
        self.kcfg_audiocapturevolume.setTickPosition(QSlider.TicksAbove)

        self.gridLayout_2.addWidget(self.kcfg_audiocapturevolume, 3, 1, 1, 1)

        self.audiocapturechannels = QComboBox(self.audio_tab)
        self.audiocapturechannels.setObjectName(u"audiocapturechannels")

        self.gridLayout_2.addWidget(self.audiocapturechannels, 4, 1, 1, 1)

        self.kcfg_defaultaudiocapture = QComboBox(self.audio_tab)
        self.kcfg_defaultaudiocapture.setObjectName(
            u"kcfg_defaultaudiocapture")

        self.gridLayout_2.addWidget(self.kcfg_defaultaudiocapture, 1, 1, 1, 1)

        self.label_33 = QLabel(self.audio_tab)
        self.label_33.setObjectName(u"label_33")

        self.gridLayout_2.addWidget(self.label_33, 1, 0, 1, 1)

        self.labelNoAudioDevices = QLabel(self.audio_tab)
        self.labelNoAudioDevices.setObjectName(u"labelNoAudioDevices")
        font = QFont()
        font.setPointSize(10)
        self.labelNoAudioDevices.setFont(font)

        self.gridLayout_2.addWidget(self.labelNoAudioDevices, 2, 0, 1, 2)

        self.tabWidget.addTab(self.audio_tab, "")

        self.gridLayout_8.addWidget(self.tabWidget, 1, 0, 1, 2)

        QWidget.setTabOrder(self.kcfg_defaultcapture, self.tabWidget)
        QWidget.setTabOrder(self.tabWidget, self.kcfg_grab_capture_type)
        QWidget.setTabOrder(self.kcfg_grab_capture_type,
                            self.kcfg_grab_follow_mouse)
        QWidget.setTabOrder(self.kcfg_grab_follow_mouse,
                            self.kcfg_grab_hide_frame)
        QWidget.setTabOrder(self.kcfg_grab_hide_frame, self.kcfg_grab_offsetx)
        QWidget.setTabOrder(self.kcfg_grab_offsetx, self.kcfg_grab_offsety)
        QWidget.setTabOrder(self.kcfg_grab_offsety, self.kcfg_grab_width)
        QWidget.setTabOrder(self.kcfg_grab_width, self.kcfg_grab_height)

        self.retranslateUi(ConfigCapture_UI)

        self.tabWidget.setCurrentIndex(0)

        QMetaObject.connectSlotsByName(ConfigCapture_UI)

    # setupUi

    def retranslateUi(self, ConfigCapture_UI):
        self.label.setText(
            QCoreApplication.translate("ConfigCapture_UI",
                                       u"Default capture device", None))
        self.kcfg_defaultcapture.setItemText(
            0, QCoreApplication.translate("ConfigCapture_UI", u"FFmpeg", None))
        self.kcfg_defaultcapture.setItemText(
            1,
            QCoreApplication.translate("ConfigCapture_UI", u"Screen grab",
                                       None))

        self.label_9.setText(
            QCoreApplication.translate("ConfigCapture_UI", u"Capture format",
                                       None))
        self.label_24.setText(
            QCoreApplication.translate("ConfigCapture_UI", u"Encoding profile",
                                       None))
        self.label_4.setText(
            QCoreApplication.translate("ConfigCapture_UI", u"Frame rate:",
                                       None))
        self.label_11.setText(
            QCoreApplication.translate("ConfigCapture_UI", u"Channels", None))
        self.config_v4l.setText(
            QCoreApplication.translate("ConfigCapture_UI", u"Edit", None))
        self.label_31.setText(
            QCoreApplication.translate("ConfigCapture_UI",
                                       u"Display aspect ratio:", None))
        self.p_progressive.setText(
            QCoreApplication.translate("ConfigCapture_UI", u"Interlaced",
                                       None))
        self.label_30.setText(
            QCoreApplication.translate("ConfigCapture_UI", u"Detected devices",
                                       None))
        self.label_14.setText(
            QCoreApplication.translate("ConfigCapture_UI", u"Video device",
                                       None))
        self.p_aspect.setText(
            QCoreApplication.translate("ConfigCapture_UI", u"59/54", None))
        self.label_23.setText(
            QCoreApplication.translate("ConfigCapture_UI",
                                       u"Pixel aspect ratio:", None))
        self.kcfg_v4l_captureaudio.setText(
            QCoreApplication.translate("ConfigCapture_UI",
                                       u"Capture audio (ALSA)", None))
        self.kcfg_v4l_capturevideo.setText(
            QCoreApplication.translate("ConfigCapture_UI",
                                       u"Capture video (Video4Linux2)", None))
        self.label_6.setText(
            QCoreApplication.translate("ConfigCapture_UI", u"Size:", None))
        self.label_32.setText(
            QCoreApplication.translate("ConfigCapture_UI", u"Colorspace",
                                       None))
        self.p_size.setText(
            QCoreApplication.translate("ConfigCapture_UI", u"720x576", None))
        self.p_display.setText(
            QCoreApplication.translate("ConfigCapture_UI", u"4/3", None))
        self.kcfg_video4vdevice.setText("")
        self.p_colorspace.setText("")
        self.p_fps.setText(
            QCoreApplication.translate("ConfigCapture_UI", u"25/1", None))
        self.tabWidget.setTabText(
            self.tabWidget.indexOf(self.ffmpeg_tab),
            QCoreApplication.translate("ConfigCapture_UI", u"FFmpeg", None))
        self.kcfg_grab_hide_mouse.setText(
            QCoreApplication.translate("ConfigCapture_UI", u"Hide cursor",
                                       None))
        self.label_screengrab.setText(
            QCoreApplication.translate("ConfigCapture_UI", u"Encoding profile",
                                       None))
        self.kcfg_grab_capture_type.setItemText(
            0,
            QCoreApplication.translate("ConfigCapture_UI",
                                       u"Full Screen Capture", None))
        self.kcfg_grab_capture_type.setItemText(
            1,
            QCoreApplication.translate("ConfigCapture_UI", u"Region Capture",
                                       None))

        self.label_18.setText(
            QCoreApplication.translate("ConfigCapture_UI", u"Frame rate",
                                       None))
        self.kcfg_grab_follow_mouse.setText(
            QCoreApplication.translate("ConfigCapture_UI", u"Follow mouse",
                                       None))
        self.kcfg_grab_hide_frame.setText(
            QCoreApplication.translate("ConfigCapture_UI", u"Hide frame",
                                       None))
        self.label_19.setText(
            QCoreApplication.translate("ConfigCapture_UI", u"Offset", None))
        self.label_20.setText(
            QCoreApplication.translate("ConfigCapture_UI", u"Size", None))
        self.tabWidget.setTabText(
            self.tabWidget.indexOf(self.screen_grab_tab),
            QCoreApplication.translate("ConfigCapture_UI", u"Screen Grab",
                                       None))
        self.label_16.setText(
            QCoreApplication.translate("ConfigCapture_UI", u"Encoding profile",
                                       None))
        self.label_29.setText(
            QCoreApplication.translate("ConfigCapture_UI",
                                       u"Capture file name:", None))
        self.label_27.setText(
            QCoreApplication.translate("ConfigCapture_UI", u"Detected devices",
                                       None))
        self.tabWidget.setTabText(
            self.tabWidget.indexOf(self.decklink_tab),
            QCoreApplication.translate("ConfigCapture_UI", u"Blackmagic",
                                       None))
        self.label_5.setText(
            QCoreApplication.translate("ConfigCapture_UI", u"Sample rate:",
                                       None))
        self.label_2.setText(
            QCoreApplication.translate("ConfigCapture_UI", u"Capture volume:",
                                       None))
        self.label_3.setText(
            QCoreApplication.translate("ConfigCapture_UI", u"Channels:", None))
        self.label_33.setText(
            QCoreApplication.translate("ConfigCapture_UI", u"Device:", None))
        self.labelNoAudioDevices.setText(
            QCoreApplication.translate(
                "ConfigCapture_UI",
                u"Make sure you have audio plugins installed on your system",
                None))
        self.tabWidget.setTabText(
            self.tabWidget.indexOf(self.audio_tab),
            QCoreApplication.translate("ConfigCapture_UI", u"Audio", None))
        pass
Exemple #22
0
class RequirementEditor:
    _editor: Union[None, ResourceRequirementEditor, ArrayRequirementEditor,
                   TemplateRequirementEditor]

    def __init__(self,
                 parent: QWidget,
                 parent_layout: QVBoxLayout,
                 resource_database: ResourceDatabase,
                 *,
                 on_remove=None):

        self.parent = parent
        self.parent_layout = parent_layout
        self.resource_database = resource_database
        self._editor = None
        self._last_resource = None
        self._last_items = ()
        self._last_comment = None

        self.line_layout = QHBoxLayout()
        self.line_layout.setAlignment(Qt.AlignLeft)
        self.parent_layout.addLayout(self.line_layout)

        if on_remove is not None:
            self.remove_button = QtWidgets.QToolButton(parent)
            self.remove_button.setText("X")
            self.remove_button.setMaximumWidth(20)
            self.remove_button.clicked.connect(on_remove)
            self.line_layout.addWidget(self.remove_button)
        else:
            self.remove_button = None

        self.requirement_type_combo = QComboBox(parent)
        self.requirement_type_combo.addItem("Resource", ResourceRequirement)
        self.requirement_type_combo.addItem("Or", RequirementOr)
        self.requirement_type_combo.addItem("And", RequirementAnd)
        if resource_database.requirement_template:
            self.requirement_type_combo.addItem("Template",
                                                RequirementTemplate)
        self.requirement_type_combo.setMaximumWidth(75)
        self.requirement_type_combo.activated.connect(
            self._on_change_requirement_type)
        self.line_layout.addWidget(self.requirement_type_combo)

    def create_specialized_editor(self, requirement: Requirement):
        self.requirement_type_combo.setCurrentIndex(
            self.requirement_type_combo.findData(type(requirement)))

        if isinstance(requirement, ResourceRequirement):
            self._editor = ResourceRequirementEditor(self.parent,
                                                     self.line_layout,
                                                     self.resource_database,
                                                     requirement)

        elif isinstance(requirement, RequirementArrayBase):
            self._editor = ArrayRequirementEditor(self.parent,
                                                  self.parent_layout,
                                                  self.line_layout,
                                                  self.resource_database,
                                                  requirement)

        elif isinstance(requirement, RequirementTemplate):
            self._editor = TemplateRequirementEditor(self.parent,
                                                     self.line_layout,
                                                     self.resource_database,
                                                     requirement)

        else:
            raise RuntimeError(
                f"Unknown requirement type: {type(requirement)} - {requirement}"
            )

    def _on_change_requirement_type(self):
        current_requirement = self.current_requirement
        self._editor.deleteLater()

        if isinstance(current_requirement, ResourceRequirement):
            self._last_resource = current_requirement

        elif isinstance(current_requirement, RequirementArrayBase):
            self._last_items = current_requirement.items
            self._last_comment = current_requirement.comment

        elif isinstance(current_requirement, RequirementTemplate):
            pass

        else:
            raise RuntimeError(
                f"Unknown requirement type: {type(current_requirement)} - {current_requirement}"
            )

        new_class = self.requirement_type_combo.currentData()
        if new_class == ResourceRequirement:
            if self._last_resource is None:
                new_requirement = _create_default_resource_requirement(
                    self.resource_database)
            else:
                new_requirement = self._last_resource
        elif new_class == RequirementTemplate:
            new_requirement = _create_default_template_requirement(
                self.resource_database)
        else:
            new_requirement = new_class(self._last_items, self._last_comment)

        self.create_specialized_editor(new_requirement)

    def deleteLater(self):
        if self.remove_button is not None:
            self.remove_button.deleteLater()

        self.requirement_type_combo.deleteLater()

        if self._editor is not None:
            self._editor.deleteLater()

    @property
    def current_requirement(self) -> Requirement:
        return self._editor.current_requirement
Exemple #23
0
class PlaylistPopup(QWidget):
    def __init__(self, result, parent=None):
        # Popup when "Add song to playlist" is clicked on
        # How this works is a QWidget that encompasses the entire window area, representing an unclickable translucent background.
        # Another QWidget is then contained inside that QWidget representing the popup.
        # result: (dict) Python dict containing information of the song clicked
        QWidget.__init__(self)
        self.setParent(parent)
        self.result = result

        # Signals are used to indicate to close the window
        self.SIGNALS = self.TranslucentWidgetSignals()

        # Make the window frameless and expanding.
        self.setWindowFlags(Qt.FramelessWindowHint)
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

        # Makes the window background colour translucent
        self.setAttribute(Qt.WA_StyledBackground)
        self.setStyleSheet(
            "PlaylistPopup { background-color: rgba(255, 255, 255, 0.5)}")

        # Sets the grid settings of the "background" and the "popup"
        layout = QGridLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        playlistAdd = QWidget(self)
        playlistAdd.setFixedSize(800, 300)
        playlistAdd.setStyleSheet(
            ".QWidget { background-color: rgba(255, 255, 255, 1)}")
        innerLayout = QGridLayout()
        innerLayout.setContentsMargins(20, 20, 20, 20)
        innerLayout.setSpacing(30)

        # Heading font
        font = QFont()
        font.setPointSize(24)

        # Default label font
        font2 = QFont()
        font2.setPointSize(16)

        # Heading
        label = QLabel("添加到播放列表/Add to Playlist", self)
        label.setAlignment(Qt.AlignCenter)
        label.setFont(font)
        innerLayout.addWidget(label, 0, 0)

        # Playlist selection
        self.comboBox = QComboBox(self)
        self.comboBox.setFont(font)
        playlists = DB.getPlaylists("")
        for playlist in playlists:
            self.comboBox.addItem(playlist["playlist_name"])
        self.comboBox.setCurrentIndex(-1)
        innerLayout.addWidget(self.comboBox, 1, 0)

        # Textbox to create a new playlist
        self.textBox = QLineEdit(self)
        self.textBox.setFont(font2)
        self.textBox.setAlignment(Qt.AlignCenter)
        self.textBox.setPlaceholderText(
            "输入以创建新的播放列表/Type to create a new playlist")
        self.textBox.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed)
        # TODO: resize textbox with window
        self.textBox.setFixedWidth(760)
        innerLayout.addWidget(self.textBox, 2, 0, Qt.AlignCenter)

        # Add actions for then the QComboBox or QLineEdit is changed.
        # This is done so there is only one action between "Add to existing Playlist" or "Add to new Playlist"
        self.comboBox.currentIndexChanged.connect(self.comboBoxChanged)
        self.textBox.textEdited.connect(self.textBoxChanged)

        # Confirm button
        confirmButton = QToolButton(self)
        confirmButton.setText("确认/Confirm")
        confirmButton.setFont(font)
        confirmButton.clicked.connect(self.processPlaylistRequest)
        innerLayout.addWidget(confirmButton, 3, 0, Qt.AlignCenter)

        # Exit button
        btn = QToolButton(self)
        btn.setFixedSize(44, 44)
        btn.setText("X")
        btn.setFont(font)
        btn.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
        btn.clicked.connect(lambda: self.SIGNALS.CLOSE.emit())
        innerLayout.addWidget(btn, 0, 0, Qt.AlignRight)

        playlistAdd.setLayout(innerLayout)
        layout.addWidget(playlistAdd, 0, 0, Qt.AlignCenter)
        self.setLayout(layout)

    def comboBoxChanged(self):
        # Called when the ComboBox is changed
        # Clears the text in the "Create Playlist" TextBox
        if self.textBox.text() != "":
            self.textBox.setText("")

    def textBoxChanged(self):
        # Called when the TextBox is changed
        # Clears the selection in the "Add to Playlist" ComboBox
        if self.comboBox.currentIndex != -1:
            self.comboBox.setCurrentIndex(-1)

    def processPlaylistRequest(self):
        # Called when the Confirm button is clicked
        def addToPlaylist(self, playlistID):
            # Adds the song to the playlist
            # Get song ID
            song = self.result["song_id"]
            DB.addPlaylistSong(playlistID, song)

        if self.textBox.text() != "":
            # New playlist
            playlistName = self.textBox.text()
            counter = 1
            while DB.checkPlaylist(playlistName):
                playlistName = "{} ({})".format(self.textBox.text(), counter)
                counter += 1
            playlistID = DB.newPlaylist(playlistName)[0]["playlist_id"]
            addToPlaylist(self, playlistID)
            self.SIGNALS.CLOSE.emit()
        elif self.comboBox.currentIndex != -1:
            playlistID = DB.checkPlaylist(
                self.comboBox.currentText())[0]["playlist_id"]
            # Add to existing playlist
            addToPlaylist(self, playlistID)
            self.SIGNALS.CLOSE.emit()

    # Taken from https://stackoverflow.com/questions/44264852/pyside-pyqt-overlay-widget
    class TranslucentWidgetSignals(QtCore.QObject):
        CLOSE = QtCore.Signal()
class Window(QWidget):
    def __init__(self):
        super(Window, self).__init__()

        self.proxyModel = QSortFilterProxyModel()
        self.proxyModel.setDynamicSortFilter(True)

        self.sourceGroupBox = QGroupBox("Original Model")
        self.proxyGroupBox = QGroupBox("Sorted/Filtered Model")

        self.sourceView = QTreeView()
        self.sourceView.setRootIsDecorated(False)
        self.sourceView.setAlternatingRowColors(True)

        self.proxyView = QTreeView()
        self.proxyView.setRootIsDecorated(False)
        self.proxyView.setAlternatingRowColors(True)
        self.proxyView.setModel(self.proxyModel)
        self.proxyView.setSortingEnabled(True)

        self.sortCaseSensitivityCheckBox = QCheckBox("Case sensitive sorting")
        self.filterCaseSensitivityCheckBox = QCheckBox("Case sensitive filter")

        self.filterPatternLineEdit = QLineEdit()
        self.filterPatternLineEdit.setClearButtonEnabled(True)
        self.filterPatternLabel = QLabel("&Filter pattern:")
        self.filterPatternLabel.setBuddy(self.filterPatternLineEdit)

        self.filterSyntaxComboBox = QComboBox()
        self.filterSyntaxComboBox.addItem("Regular expression",
                                          REGULAR_EXPRESSION)
        self.filterSyntaxComboBox.addItem("Wildcard",
                                          WILDCARD)
        self.filterSyntaxComboBox.addItem("Fixed string",
                                          FIXED_STRING)
        self.filterSyntaxLabel = QLabel("Filter &syntax:")
        self.filterSyntaxLabel.setBuddy(self.filterSyntaxComboBox)

        self.filterColumnComboBox = QComboBox()
        self.filterColumnComboBox.addItem("Subject")
        self.filterColumnComboBox.addItem("Sender")
        self.filterColumnComboBox.addItem("Date")
        self.filterColumnLabel = QLabel("Filter &column:")
        self.filterColumnLabel.setBuddy(self.filterColumnComboBox)

        self.filterPatternLineEdit.textChanged.connect(self.filterRegExpChanged)
        self.filterSyntaxComboBox.currentIndexChanged.connect(self.filterRegExpChanged)
        self.filterColumnComboBox.currentIndexChanged.connect(self.filterColumnChanged)
        self.filterCaseSensitivityCheckBox.toggled.connect(self.filterRegExpChanged)
        self.sortCaseSensitivityCheckBox.toggled.connect(self.sortChanged)

        sourceLayout = QHBoxLayout()
        sourceLayout.addWidget(self.sourceView)
        self.sourceGroupBox.setLayout(sourceLayout)

        proxyLayout = QGridLayout()
        proxyLayout.addWidget(self.proxyView, 0, 0, 1, 3)
        proxyLayout.addWidget(self.filterPatternLabel, 1, 0)
        proxyLayout.addWidget(self.filterPatternLineEdit, 1, 1, 1, 2)
        proxyLayout.addWidget(self.filterSyntaxLabel, 2, 0)
        proxyLayout.addWidget(self.filterSyntaxComboBox, 2, 1, 1, 2)
        proxyLayout.addWidget(self.filterColumnLabel, 3, 0)
        proxyLayout.addWidget(self.filterColumnComboBox, 3, 1, 1, 2)
        proxyLayout.addWidget(self.filterCaseSensitivityCheckBox, 4, 0, 1, 2)
        proxyLayout.addWidget(self.sortCaseSensitivityCheckBox, 4, 2)
        self.proxyGroupBox.setLayout(proxyLayout)

        mainLayout = QVBoxLayout()
        mainLayout.addWidget(self.sourceGroupBox)
        mainLayout.addWidget(self.proxyGroupBox)
        self.setLayout(mainLayout)

        self.setWindowTitle("Basic Sort/Filter Model")
        self.resize(500, 450)

        self.proxyView.sortByColumn(1, Qt.AscendingOrder)
        self.filterColumnComboBox.setCurrentIndex(1)

        self.filterPatternLineEdit.setText("Andy|Grace")
        self.filterCaseSensitivityCheckBox.setChecked(True)
        self.sortCaseSensitivityCheckBox.setChecked(True)

    def setSourceModel(self, model):
        self.proxyModel.setSourceModel(model)
        self.sourceView.setModel(model)

    def filterRegExpChanged(self):
        syntax_nr = self.filterSyntaxComboBox.currentData()
        pattern = self.filterPatternLineEdit.text()
        if syntax_nr == WILDCARD:
            pattern = QRegularExpression.wildcardToRegularExpression(pattern)
        elif syntax_nr == FIXED_STRING:
            pattern = QRegularExpression.escape(pattern)

        regExp = QRegularExpression(pattern)
        if not self.filterCaseSensitivityCheckBox.isChecked():
            options = regExp.patternOptions()
            options |= QRegularExpression.CaseInsensitiveOption
            regExp.setPatternOptions(options)
        self.proxyModel.setFilterRegularExpression(regExp)

    def filterColumnChanged(self):
        self.proxyModel.setFilterKeyColumn(self.filterColumnComboBox.currentIndex())

    def sortChanged(self):
        if self.sortCaseSensitivityCheckBox.isChecked():
            caseSensitivity = Qt.CaseSensitive
        else:
            caseSensitivity = Qt.CaseInsensitive

        self.proxyModel.setSortCaseSensitivity(caseSensitivity)
class VideoFinderAddLink(AddLinkWindow):
    running_thread = None
    threadPool = {}

    def __init__(self, parent, receiver_slot, settings, video_dict={}):
        super().__init__(parent, receiver_slot, settings, video_dict)
        self.setWindowTitle(
            QCoreApplication.translate("ytaddlink_src_ui_tr", 'Video Finder'))
        self.size_label.hide()

        # empty lists for no_audio and no_video and video_audio files
        self.no_audio_list = []
        self.no_video_list = []
        self.video_audio_list = []

        self.media_title = ''

        # add support for other languages
        locale = str(self.persepolis_setting.value('settings/locale'))
        QLocale.setDefault(QLocale(locale))
        self.translator = QTranslator()
        if self.translator.load(':/translations/locales/ui_' + locale, 'ts'):
            QCoreApplication.installTranslator(self.translator)

        # extension_label
        self.extension_label = QLabel(self.link_frame)
        self.change_name_horizontalLayout.addWidget(self.extension_label)

        # Fetch Button
        self.url_submit_pushButtontton = QPushButton(self.link_frame)
        self.link_horizontalLayout.addWidget(self.url_submit_pushButtontton)

        # Status Box
        self.status_box_textEdit = QTextEdit(self.link_frame)
        self.status_box_textEdit.setMaximumHeight(150)
        self.link_verticalLayout.addWidget(self.status_box_textEdit)

        # Select format horizontal layout
        select_format_horizontalLayout = QHBoxLayout()

        # Selection Label
        self.select_format_label = QLabel(self.link_frame)
        select_format_horizontalLayout.addWidget(self.select_format_label)

        # Selection combobox
        self.media_comboBox = QComboBox(self.link_frame)
        self.media_comboBox.setMinimumWidth(200)
        select_format_horizontalLayout.addWidget(self.media_comboBox)

        # Duration label
        self.duration_label = QLabel(self.link_frame)
        select_format_horizontalLayout.addWidget(self.duration_label)

        self.format_selection_frame = QFrame(self)
        self.format_selection_frame.setLayout(select_format_horizontalLayout)
        self.link_verticalLayout.addWidget(self.format_selection_frame)

        # advanced_format_selection_checkBox
        self.advanced_format_selection_checkBox = QCheckBox(self)
        self.link_verticalLayout.addWidget(
            self.advanced_format_selection_checkBox)

        # advanced_format_selection_frame
        self.advanced_format_selection_frame = QFrame(self)
        self.link_verticalLayout.addWidget(
            self.advanced_format_selection_frame)

        advanced_format_selection_horizontalLayout = QHBoxLayout(
            self.advanced_format_selection_frame)

        # video_format_selection
        self.video_format_selection_label = QLabel(
            self.advanced_format_selection_frame)
        self.video_format_selection_comboBox = QComboBox(
            self.advanced_format_selection_frame)

        # audio_format_selection
        self.audio_format_selection_label = QLabel(
            self.advanced_format_selection_frame)
        self.audio_format_selection_comboBox = QComboBox(
            self.advanced_format_selection_frame)

        for widget in [
                self.video_format_selection_label,
                self.video_format_selection_comboBox,
                self.audio_format_selection_label,
                self.audio_format_selection_comboBox
        ]:
            advanced_format_selection_horizontalLayout.addWidget(widget)

        # Set Texts
        self.url_submit_pushButtontton.setText(
            QCoreApplication.translate("ytaddlink_src_ui_tr",
                                       'Fetch Media List'))
        self.select_format_label.setText(
            QCoreApplication.translate("ytaddlink_src_ui_tr",
                                       'Select a format'))

        self.video_format_selection_label.setText(
            QCoreApplication.translate("ytaddlink_src_ui_tr", 'Video format:'))
        self.audio_format_selection_label.setText(
            QCoreApplication.translate("ytaddlink_src_ui_tr", 'Audio format:'))

        self.advanced_format_selection_checkBox.setText(
            QCoreApplication.translate("ytaddlink_src_ui_tr",
                                       'Advanced options'))

        # Add Slot Connections
        self.url_submit_pushButtontton.setEnabled(False)
        self.change_name_lineEdit.setEnabled(False)
        self.ok_pushButton.setEnabled(False)
        self.download_later_pushButton.setEnabled(False)

        self.format_selection_frame.setEnabled(True)
        self.advanced_format_selection_frame.setEnabled(False)
        self.advanced_format_selection_checkBox.toggled.connect(
            self.advancedFormatFrame)

        self.url_submit_pushButtontton.clicked.connect(self.submitClicked)

        self.media_comboBox.activated.connect(
            partial(self.mediaSelectionChanged, 'video_audio'))

        self.video_format_selection_comboBox.activated.connect(
            partial(self.mediaSelectionChanged, 'video'))

        self.audio_format_selection_comboBox.activated.connect(
            partial(self.mediaSelectionChanged, 'audio'))

        self.link_lineEdit.textChanged.disconnect(
            super().linkLineChanged)  # Should be disconnected.
        self.link_lineEdit.textChanged.connect(self.linkLineChangedHere)

        self.setMinimumSize(650, 480)

        self.status_box_textEdit.hide()
        self.format_selection_frame.hide()
        self.advanced_format_selection_frame.hide()
        self.advanced_format_selection_checkBox.hide()

        if 'link' in video_dict.keys() and video_dict['link']:
            self.link_lineEdit.setText(video_dict['link'])
            self.url_submit_pushButtontton.setEnabled(True)
        else:
            # check clipboard
            clipboard = QApplication.clipboard()
            text = clipboard.text()
            if (("tp:/" in text[2:6]) or ("tps:/" in text[2:7])):
                self.link_lineEdit.setText(str(text))

            self.url_submit_pushButtontton.setEnabled(True)

    def advancedFormatFrame(self, button):
        if self.advanced_format_selection_checkBox.isChecked():

            self.advanced_format_selection_frame.setEnabled(True)
            self.format_selection_frame.setEnabled(False)
            self.mediaSelectionChanged(
                'video',
                int(self.video_format_selection_comboBox.currentIndex()))

        else:
            self.advanced_format_selection_frame.setEnabled(False)
            self.format_selection_frame.setEnabled(True)
            self.mediaSelectionChanged('video_audio',
                                       int(self.media_comboBox.currentIndex()))

    def getReadableSize(self, size):
        try:
            return '{:1.2f} MB'.format(int(size) / 1048576)
        except:
            return str(size)

    def getReadableDuration(self, seconds):
        try:
            seconds = int(seconds)
            hours = seconds // 3600
            seconds = seconds % 3600
            minutes = seconds // 60
            seconds = seconds % 60
            return '{:02d}:{:02d}:{:02d}'.format(hours, minutes, seconds)
        except:
            return str(seconds)

    # Define native slots

    def urlChanged(self, value):
        if ' ' in value or value == '':
            self.url_submit_pushButtontton.setEnabled(False)
            self.url_submit_pushButtontton.setToolTip(
                QCoreApplication.translate("ytaddlink_src_ui_tr",
                                           'Please enter a valid video link'))
        else:
            self.url_submit_pushButtontton.setEnabled(True)
            self.url_submit_pushButtontton.setToolTip('')

    def submitClicked(self, button=None):
        # Clear media list
        self.media_comboBox.clear()
        self.format_selection_frame.hide()
        self.advanced_format_selection_checkBox.hide()
        self.advanced_format_selection_frame.hide()
        self.video_format_selection_comboBox.clear()
        self.audio_format_selection_comboBox.clear()
        self.change_name_lineEdit.clear()
        self.threadPool.clear()
        self.change_name_checkBox.setChecked(False)
        self.video_audio_list.clear()
        self.no_video_list.clear()
        self.no_audio_list.clear()
        self.url_submit_pushButtontton.setEnabled(False)
        self.status_box_textEdit.setText(
            QCoreApplication.translate("ytaddlink_src_ui_tr",
                                       'Fetching Media Info...'))
        self.status_box_textEdit.show()
        self.ok_pushButton.setEnabled(False)
        self.download_later_pushButton.setEnabled(False)

        dictionary_to_send = deepcopy(self.plugin_add_link_dictionary)
        # More options
        more_options = self.collectMoreOptions()
        for k in more_options.keys():
            dictionary_to_send[k] = more_options[k]
        dictionary_to_send['link'] = self.link_lineEdit.text()

        fetcher_thread = MediaListFetcherThread(self.fetchedResult,
                                                dictionary_to_send, self)
        self.parent.threadPool.append(fetcher_thread)
        self.parent.threadPool[len(self.parent.threadPool) - 1].start()

    def fileNameChanged(self, value):
        if value.strip() == '':
            self.ok_pushButton.setEnabled(False)

    def mediaSelectionChanged(self, combobox, index):
        try:
            if combobox == 'video_audio':
                if self.media_comboBox.currentText() == 'Best quality':
                    self.change_name_lineEdit.setText(self.media_title)
                    self.extension_label.setText('.' +
                                                 self.no_audio_list[-1]['ext'])

                else:
                    self.change_name_lineEdit.setText(self.media_title)
                    self.extension_label.setText(
                        '.' + self.video_audio_list[index]['ext'])

                self.change_name_checkBox.setChecked(True)

            elif combobox == 'video':
                if self.video_format_selection_comboBox.currentText(
                ) != 'No video':
                    self.change_name_lineEdit.setText(self.media_title)
                    self.extension_label.setText('.' +
                                                 self.no_audio_list[index -
                                                                    1]['ext'])
                    self.change_name_checkBox.setChecked(True)

                else:

                    if self.audio_format_selection_comboBox.currentText(
                    ) != 'No audio':
                        self.change_name_lineEdit.setText(self.media_title)
                        self.extension_label.setText('.' + self.no_video_list[
                            int(self.audio_format_selection_comboBox.
                                currentIndex()) - 1]['ext'])

                        self.change_name_checkBox.setChecked(True)
                    else:
                        self.change_name_lineEdit.setChecked(False)

            elif combobox == 'audio':
                if self.audio_format_selection_comboBox.currentText(
                ) != 'No audio' and self.video_format_selection_comboBox.currentText(
                ) == 'No video':
                    self.change_name_lineEdit.setText(self.media_title)
                    self.extension_label.setText('.' +
                                                 self.no_video_list[index -
                                                                    1]['ext'])

                    self.change_name_checkBox.setChecked(True)

                elif (self.audio_format_selection_comboBox.currentText()
                      == 'No audio'
                      and self.video_format_selection_comboBox.currentText() !=
                      'No video') or (
                          self.audio_format_selection_comboBox.currentText() !=
                          'No audio' and
                          self.video_format_selection_comboBox.currentText() !=
                          'No video'):
                    self.change_name_lineEdit.setText(self.media_title)
                    self.extension_label.setText('.' + self.no_audio_list[
                        int(self.video_format_selection_comboBox.currentIndex(
                        )) - 1]['ext'])

                    self.change_name_checkBox.setChecked(True)

                elif self.audio_format_selection_comboBox.currentText(
                ) == 'No audio' and self.video_format_selection_comboBox.currentText(
                ) == 'No video':
                    self.change_name_checkBox.setChecked(False)

        except Exception as ex:
            logger.sendToLog(ex, "ERROR")

    def fetchedResult(self, media_dict):

        self.url_submit_pushButtontton.setEnabled(True)
        if 'error' in media_dict.keys():

            self.status_box_textEdit.setText('<font color="#f11">' +
                                             str(media_dict['error']) +
                                             '</font>')
            self.status_box_textEdit.show()
        else:  # Show the media list

            # add no audio and no video options to the comboboxes
            self.video_format_selection_comboBox.addItem('No video')
            self.audio_format_selection_comboBox.addItem('No audio')

            self.media_title = media_dict['title']
            if 'formats' not in media_dict.keys(
            ) and 'entries' in media_dict.keys():
                formats = media_dict['entries']
                formats = formats[0]
                media_dict['formats'] = formats['formats']
            elif 'formats' not in media_dict.keys(
            ) and 'format' in media_dict.keys():
                media_dict['formats'] = [media_dict.copy()]

            try:
                i = 0
                for f in media_dict['formats']:
                    no_audio = False
                    no_video = False
                    text = ''
                    if 'acodec' in f.keys():
                        # only video, no audio
                        if f['acodec'] == 'none':
                            no_audio = True

                        # resolution
                        if 'height' in f.keys():
                            text = text + ' ' + '{}p'.format(f['height'])

                    if 'vcodec' in f.keys():
                        #                         if f['vcodec'] == 'none' and f['acodec'] != 'none':
                        #                             continue

                        # No video, show audio bit rate
                        if f['vcodec'] == 'none':
                            text = text + '{}kbps'.format(f['abr'])
                            no_video = True

                    if 'ext' in f.keys():
                        text = text + ' ' + '.{}'.format(f['ext'])

                    if 'filesize' in f.keys() and f['filesize']:
                        # Youtube api does not supply file size for some formats, so check it.
                        text = text + ' ' + '{}'.format(
                            self.getReadableSize(f['filesize']))

                    else:  # Start spider to find file size
                        input_dict = deepcopy(self.plugin_add_link_dictionary)

                        input_dict['link'] = f['url']
                        more_options = self.collectMoreOptions()

                        for key in more_options.keys():
                            input_dict[key] = more_options[key]

                        size_fetcher = FileSizeFetcherThread(input_dict, i)
                        self.threadPool[str(i)] = {
                            'thread': size_fetcher,
                            'item_id': i
                        }
                        self.parent.threadPool.append(size_fetcher)
                        self.parent.threadPool[len(self.parent.threadPool) -
                                               1].start()
                        self.parent.threadPool[len(self.parent.threadPool) -
                                               1].FOUND.connect(
                                                   self.findFileSize)

                    # Add current format to the related comboboxes
                    if no_audio:
                        self.no_audio_list.append(f)
                        self.video_format_selection_comboBox.addItem(text)

                    elif no_video:
                        self.no_video_list.append(f)
                        self.audio_format_selection_comboBox.addItem(text)

                    else:
                        self.video_audio_list.append(f)
                        self.media_comboBox.addItem(text)

                    i = i + 1

                self.status_box_textEdit.hide()

                if 'duration' in media_dict.keys():
                    self.duration_label.setText(
                        'Duration ' +
                        self.getReadableDuration(media_dict['duration']))

                self.format_selection_frame.show()
                self.advanced_format_selection_checkBox.show()
                self.advanced_format_selection_frame.show()
                self.ok_pushButton.setEnabled(True)
                self.download_later_pushButton.setEnabled(True)

                # if we have no options for separate audio and video, then hide advanced_format_selection...
                if len(self.no_audio_list) == 0 and len(
                        self.no_video_list) == 0:
                    self.advanced_format_selection_checkBox.hide()
                    self.advanced_format_selection_frame.hide()

                # set index of comboboxes on best available quality.
                # we have both audio and video
                if len(self.no_audio_list) != 0 and len(
                        self.no_video_list) != 0:
                    self.media_comboBox.addItem('Best quality')
                    self.media_comboBox.setCurrentIndex(
                        len(self.video_audio_list))
                    self.change_name_lineEdit.setText(self.media_title)
                    self.extension_label.setText('.' +
                                                 self.no_audio_list[-1]['ext'])
                    self.change_name_checkBox.setChecked(True)

                # video and audio are not separate
                elif len(self.video_audio_list) != 0:
                    self.media_comboBox.setCurrentIndex(
                        len(self.video_audio_list) - 1)

                if len(self.no_audio_list) != 0:
                    self.video_format_selection_comboBox.setCurrentIndex(
                        len(self.no_audio_list))

                if len(self.no_video_list) != 0:
                    self.audio_format_selection_comboBox.setCurrentIndex(
                        len(self.no_video_list))

                # if we have only audio or we have only video then hide media_comboBox
                if len(self.video_audio_list) == 0:
                    self.media_comboBox.hide()
                    self.select_format_label.hide()

                    # only video
                    if len(self.no_video_list) != 0 and len(
                            self.no_audio_list) == 0:
                        self.mediaSelectionChanged(
                            'video',
                            int(self.video_format_selection_comboBox.
                                currentIndex()))
                        self.advanced_format_selection_checkBox.setChecked(
                            True)
                        self.advanced_format_selection_checkBox.hide()

                    # only audio
                    elif len(self.no_video_list) == 0 and len(
                            self.no_audio_list) != 0:
                        self.mediaSelectionChanged(
                            'audio',
                            int(self.audio_format_selection_comboBox.
                                currentIndex()))
                        self.advanced_format_selection_checkBox.setChecked(
                            True)
                        self.advanced_format_selection_checkBox.hide()

                    # audio and video
                    else:
                        self.mediaSelectionChanged(
                            'video_audio',
                            int(self.media_comboBox.currentIndex()))

            except Exception as ex:
                logger.sendToLog(ex, "ERROR")

    def findFileSize(self, result):
        try:
            item_id = self.threadPool[str(result['thread_key'])]['item_id']
            if result['file_size'] and result['file_size'] != '0':
                text = self.media_comboBox.itemText(item_id)
                self.media_comboBox.setItemText(
                    item_id, '{} - {}'.format(text, result['file_size']))
        except Exception as ex:
            logger.sendToLog(ex, "ERROR")

    def linkLineChangedHere(self, lineEdit):
        if str(lineEdit) == '':
            self.url_submit_pushButtontton.setEnabled(False)
        else:
            self.url_submit_pushButtontton.setEnabled(True)

    # This method collects additional information like proxy ip, user, password etc.
    def collectMoreOptions(self):
        options = {
            'ip': None,
            'port': None,
            'proxy_user': None,
            'proxy_passwd': None,
            'download_user': None,
            'download_passwd': None
        }
        if self.proxy_checkBox.isChecked():
            options['ip'] = self.ip_lineEdit.text()
            options['port'] = self.port_spinBox.value()
            options['proxy_user'] = self.proxy_user_lineEdit.text()
            options['proxy_passwd'] = self.proxy_pass_lineEdit.text()
        if self.download_checkBox.isChecked():
            options['download_user'] = self.download_user_lineEdit.text()
            options['download_passwd'] = self.download_pass_lineEdit.text()

        # These info (keys) are required for spider to find file size, because spider() does not check if key exists.
        additional_info = [
            'header', 'load_cookies', 'user_agent', 'referer', 'out'
        ]
        for i in additional_info:
            if i not in self.plugin_add_link_dictionary.keys():
                options[i] = None
        return options

    # user submitted information by pressing ok_pushButton, so get information
    # from VideoFinderAddLink window and return them to the mainwindow with callback!
    def okButtonPressed(self, download_later, button=None):

        link_list = []
        # separate audio format and video format is selected.
        if self.advanced_format_selection_checkBox.isChecked():

            if self.video_format_selection_comboBox.currentText(
            ) == 'No video' and self.audio_format_selection_comboBox.currentText(
            ) != 'No audio':

                # only audio link must be added to the link_list
                audio_link = self.no_video_list[
                    self.audio_format_selection_comboBox.currentIndex() -
                    1]['url']
                link_list.append(audio_link)

            elif self.video_format_selection_comboBox.currentText(
            ) != 'No video' and self.audio_format_selection_comboBox.currentText(
            ) == 'No audio':

                # only video link must be added to the link_list
                video_link = self.no_audio_list[
                    self.video_format_selection_comboBox.currentIndex() -
                    1]['url']
                link_list.append(video_link)

            elif self.video_format_selection_comboBox.currentText(
            ) != 'No video' and self.audio_format_selection_comboBox.currentText(
            ) != 'No audio':

                # video and audio links must be added to the link_list
                audio_link = self.no_video_list[
                    self.audio_format_selection_comboBox.currentIndex() -
                    1]['url']
                video_link = self.no_audio_list[
                    self.video_format_selection_comboBox.currentIndex() -
                    1]['url']
                link_list = [video_link, audio_link]

            elif self.video_format_selection_comboBox.currentText(
            ) == 'No video' and self.audio_format_selection_comboBox.currentText(
            ) == 'No audio':

                # no video and audio is selected! REALLY?!. user is DRUNK! close the window! :))
                self.close()
        else:
            if self.media_comboBox.currentText() == 'Best quality':

                # the last item in no_video_list and no_audio_list are the best.
                video_link = self.no_audio_list[-1]['url']
                audio_link = self.no_video_list[-1]['url']

                link_list = [video_link, audio_link]

            else:
                audio_and_video_link = self.video_audio_list[
                    self.media_comboBox.currentIndex()]['url']
                link_list.append(audio_and_video_link)

        # write user's new inputs in persepolis_setting for next time :)
        self.persepolis_setting.setValue('add_link_initialization/ip',
                                         self.ip_lineEdit.text())
        self.persepolis_setting.setValue('add_link_initialization/port',
                                         self.port_spinBox.value())
        self.persepolis_setting.setValue('add_link_initialization/proxy_user',
                                         self.proxy_user_lineEdit.text())
        self.persepolis_setting.setValue(
            'add_link_initialization/download_user',
            self.download_user_lineEdit.text())

        # get proxy information
        if not (self.proxy_checkBox.isChecked()):
            ip = None
            port = None
            proxy_user = None
            proxy_passwd = None
        else:
            ip = self.ip_lineEdit.text()
            if not (ip):
                ip = None
            port = self.port_spinBox.value()
            if not (port):
                port = None
            proxy_user = self.proxy_user_lineEdit.text()
            if not (proxy_user):
                proxy_user = None
            proxy_passwd = self.proxy_pass_lineEdit.text()
            if not (proxy_passwd):
                proxy_passwd = None

        # get download username and password information
        if not (self.download_checkBox.isChecked()):
            download_user = None
            download_passwd = None
        else:
            download_user = self.download_user_lineEdit.text()
            if not (download_user):
                download_user = None
            download_passwd = self.download_pass_lineEdit.text()
            if not (download_passwd):
                download_passwd = None

        # check that if user limits download speed.
        if not (self.limit_checkBox.isChecked()):
            limit = 0
        else:
            if self.limit_comboBox.currentText() == "KiB/s":
                limit = str(self.limit_spinBox.value()) + str("K")
            else:
                limit = str(self.limit_spinBox.value()) + str("M")

        # get start time for download if user set that.
        if not (self.start_checkBox.isChecked()):
            start_time = None
        else:
            start_time = self.start_time_qDataTimeEdit.text()

        # get end time for download if user set that.
        if not (self.end_checkBox.isChecked()):
            end_time = None
        else:
            end_time = self.end_time_qDateTimeEdit.text()

        # set name for file(s)
        if self.change_name_checkBox.isChecked():
            name = str(self.change_name_lineEdit.text())
            if name == '':
                name = 'video_finder_file'
        else:
            name = 'video_finder_file'

        # video finder always finds extension
        # but if it can't find file extension
        # use mp4 for extension.
        if str(self.extension_label.text()) == '':
            extension = '.mp4'
        else:
            extension = str(self.extension_label.text())

        # did user select separate audio and video?
        if len(link_list) == 2:
            video_name = name + extension
            audio_name = name + '.' + \
                str(self.no_video_list[self.audio_format_selection_comboBox.currentIndex() - 1]['ext'])

            name_list = [video_name, audio_name]
        else:
            name_list = [name + extension]

        # get number of connections
        connections = self.connections_spinBox.value()

        # get download_path
        download_path = self.download_folder_lineEdit.text()

        # referer
        if self.referer_lineEdit.text() != '':
            referer = self.referer_lineEdit.text()
        else:
            referer = None

        # header
        if self.header_lineEdit.text() != '':
            header = self.header_lineEdit.text()
        else:
            header = None

        # user_agent
        if self.user_agent_lineEdit.text() != '':
            user_agent = self.user_agent_lineEdit.text()
        else:
            user_agent = None

        # load_cookies
        if self.load_cookies_lineEdit.text() != '':
            load_cookies = self.load_cookies_lineEdit.text()
        else:
            load_cookies = None

        add_link_dictionary_list = []
        if len(link_list) == 1:
            # save information in a dictionary(add_link_dictionary).
            add_link_dictionary = {
                'referer': referer,
                'header': header,
                'user_agent': user_agent,
                'load_cookies': load_cookies,
                'out': name_list[0],
                'start_time': start_time,
                'end_time': end_time,
                'link': link_list[0],
                'ip': ip,
                'port': port,
                'proxy_user': proxy_user,
                'proxy_passwd': proxy_passwd,
                'download_user': download_user,
                'download_passwd': download_passwd,
                'connections': connections,
                'limit_value': limit,
                'download_path': download_path
            }

            add_link_dictionary_list.append(add_link_dictionary)

        else:
            video_add_link_dictionary = {
                'referer': referer,
                'header': header,
                'user_agent': user_agent,
                'load_cookies': load_cookies,
                'out': name_list[0],
                'start_time': start_time,
                'end_time': end_time,
                'link': link_list[0],
                'ip': ip,
                'port': port,
                'proxy_user': proxy_user,
                'proxy_passwd': proxy_passwd,
                'download_user': download_user,
                'download_passwd': download_passwd,
                'connections': connections,
                'limit_value': limit,
                'download_path': download_path
            }

            audio_add_link_dictionary = {
                'referer': referer,
                'header': header,
                'user_agent': user_agent,
                'load_cookies': load_cookies,
                'out': name_list[1],
                'start_time': None,
                'end_time': end_time,
                'link': link_list[1],
                'ip': ip,
                'port': port,
                'proxy_user': proxy_user,
                'proxy_passwd': proxy_passwd,
                'download_user': download_user,
                'download_passwd': download_passwd,
                'connections': connections,
                'limit_value': limit,
                'download_path': download_path
            }

            add_link_dictionary_list = [
                video_add_link_dictionary, audio_add_link_dictionary
            ]

        # get category of download
        category = str(self.add_queue_comboBox.currentText())

        del self.plugin_add_link_dictionary

        # return information to mainwindow
        self.callback(add_link_dictionary_list, download_later, category)

        # close window
        self.close()
Exemple #26
0
class App(QWidget):
    def __init__(self):
        super(App, self).__init__()
        self.combo = None
        self.MainProcess = MainProcess()
        self.MainProcess.get_image_functions()
        self.fps_label = QLabel('FPS: XXX')
        self.initUI()
        self._thread = QThread(self)
        self.video_worker = VideoThread(self.MainProcess.list_of_filters)
        #self.combo.currentIndexChanged.connect(self.video_worker.new_filter_slot)
        self.combo.currentIndexChanged.connect(self._new_ind)

        self.video_worker.change_pixmap_signal.connect(self.update_image)
        self.video_worker.update_fps_signal.connect(self._new_fps)
        self.video_worker.moveToThread(self._thread)
        self.combo.setCurrentIndex(self.MainProcess.blank_index)
        # connect the buttons
        self.start_button.clicked.connect(self.video_worker.start)
        self.quit_button.clicked.connect(
            self.close)  # force this to run on current thread

        self._thread.start()

    @Slot()
    def _new_ind(self, ind):
        self.video_worker.new_filter_slot(ind)

    @Slot(int)
    def _new_fps(self, fps):
        self.fps_label.setText(f'FPS: {fps:.1f}')

    def initUI(self):

        self.cam = CamImage()
        self.start_button = QPushButton("Start")
        self.quit_button = QPushButton("Quit")
        controls = ControlWidget()
        self.combo = QComboBox(self)
        for it in self.MainProcess.list_of_filters:
            self.combo.addItem(it[0])

        hbox = QHBoxLayout()
        hbox.addWidget(controls)
        hbox.addStretch(1)
        hbuttons = QHBoxLayout()
        hbuttons.addWidget(self.combo)
        hbuttons.addWidget(self.start_button)
        hbuttons.addWidget(self.quit_button)
        vbutton = QVBoxLayout()
        vbutton.addLayout(hbuttons)
        vbutton.addWidget(self.fps_label)
        hbox.addLayout(vbutton)
        vbox = QVBoxLayout()
        vbox.addWidget(self.cam)
        vbox.addStretch(1)
        vbox.addLayout(hbox)

        self.setLayout(vbox)

        self.setGeometry(300, 300, 300, 150)
        self.setWindowTitle('Buttons')

        self.show()

    def closeEvent(self, event):
        logger.debug('Got Close Event')
        self.video_worker.stop()
        self._thread.wait()
        event.accept()

    @Slot(np.ndarray)
    def update_image(self, cv_img):
        """Updates the image_label with a new opencv image"""
        qt_img = self.convert_cv_qt(cv_img)
        self.cam.setPixmap(qt_img)

    def convert_cv_qt(self, cv_img):
        """Convert from an opencv image to QPixmap"""
        rgb_image = cv2.cvtColor(cv_img, cv2.COLOR_BGR2RGB)
        h, w, ch = rgb_image.shape
        bytes_per_line = ch * w
        convert_to_Qt_format = QImage(rgb_image.data, w, h, bytes_per_line,
                                      QImage.Format_RGB888)
        p = convert_to_Qt_format.scaled(self.cam.width(), self.cam.height(),
                                        Qt.KeepAspectRatio)
        return QPixmap.fromImage(p)
Exemple #27
0
class MineSweeper(QMainWindow):
	def __init__(self):
		super().__init__()

		self.undiscovered_color: str = "#000000"
		self.discovered_color: str = "#d9d9d9"
		self.win_timer_color: str = "#e30e0e"
		self.lose_timer_color: str = "#0cc431"


		self.curr_time = QTime(00,00,00)
		self.timer = QTimer()
		self.timer.timeout.connect(self.time)
		self.timer_already_started = False

		self.solved: bool = False
		
		self.player_ended: bool = False

		self.theme: str = "dark"

		self.list_of_mines: list = []

		self.difficulty_slider_default_value: int = 2
		self.number_of_mines: int = mines_number(NUMBER_OF_LABELS, self.difficulty_slider_default_value)


		self.create_GUI()

	def create_GUI(self) -> None:
		self.setWindowTitle("MineSweeper 1.1")

		self.win_massage = QMessageBox(self)
		self.win_massage.setText("Gratuluji, dokázal jsi nalézt všechny miny")

		self.setMouseTracking(True)

		centralWidget = QWidget(self)
		centralWidget.setStyleSheet("background: white")
		self.setCentralWidget(centralWidget)
		self.setFixedSize(X_WINDOW_SIZE + 20, Y_WINDOW_SIZE)

		layout = QGridLayout(centralWidget)
		layout.setSpacing(0)
		layout.setContentsMargins(0, 0, 0, 0)
		centralWidget.setLayout(layout)

		self.list_of_labels: list = []

		self.list_of_mines = generate_mines(self.number_of_mines, X_SIZE, Y_SIZE)

		# RESET BUTTON
		self.reset_button = QPushButton(centralWidget)
		self.reset_button.setText("RESET")
		self.reset_button.clicked.connect(self.reset)
		self.reset_button.setStyleSheet("margin: 3px")
		self.reset_button.setMinimumSize(0, 50)

		# TIMER LABEL
		self.timer_label = QLabel(centralWidget)
		self.timer_label.setText(f"{self.curr_time.minute():0>2}:{self.curr_time.second():0>2}")
		self.timer_label.setAlignment(Qt.AlignHCenter)
		self.timer_label.setStyleSheet("font: 34px")

		# DIFFICULTY SLIDER
		self.difficulty_slider = QSlider(centralWidget)
		self.difficulty_slider.setOrientation(Qt.Horizontal)
		self.difficulty_slider.setFixedHeight(30)
		self.difficulty_slider.setRange(1, 10)
		self.difficulty_slider.setTickInterval(1)
		self.difficulty_slider.setValue(self.difficulty_slider_default_value)
		self.difficulty_slider.valueChanged.connect(self.difficulty_label_set)
		self.difficulty_slider.sliderReleased.connect(self.new_mines_set)

		# DIFFICULTY LABEL
		self.difficulty_label = QLabel(centralWidget)
		self.difficulty_label.setText(str(self.difficulty_slider_default_value))
		self.difficulty_label.setAlignment(Qt.AlignCenter)
		self.difficulty_label.setStyleSheet("font: 20px")
		
		

		for i in range(Y_SIZE):
			row = []
			for j in range(X_SIZE):
				if (i, j) in self.list_of_mines:
					mine = True
				else:
					mine = False

				label = Chunk(j, i, mine)
				label.setFixedSize(FIELD_SQUARE_SIZE, FIELD_SQUARE_SIZE)
				label.setStyleSheet(f"background: {self.undiscovered_color}; border: 1px solid grey")
				layout.addWidget(label, i, j)
				row.append(label)
			self.list_of_labels.append(row)


		self.color_theme_combobox = QComboBox(centralWidget)
		self.color_theme_combobox.addItem("Dark theme", "dark")
		self.color_theme_combobox.addItem("Light theme", "light")
		self.color_theme_combobox.addItem("Color theme", "colorful")
		self.color_theme_combobox.currentIndexChanged.connect(self.theme_change)
		self.color_theme_combobox.setMinimumHeight(FIELD_SQUARE_SIZE * 2)
		if self.theme == "dark":
			self.color_theme_combobox.setCurrentIndex(0)
		elif self.theme == "light":
			self.color_theme_combobox.setCurrentIndex(1)
		else:
			self.color_theme_combobox.setCurrentIndex(2)
		layout.addWidget(self.color_theme_combobox, Y_SIZE - 2, X_SIZE, 2, 1)

		layout.addWidget(self.timer_label, 0, X_SIZE, 3, 1)
		layout.addWidget(self.reset_button, 2, X_SIZE, 3, 1)
		layout.addWidget(self.difficulty_slider, Y_SIZE, 1, 1, X_SIZE - 2)
		layout.addWidget(self.difficulty_label, Y_SIZE, X_SIZE, 1, 1)

		self.mines_number_surroundings_calculate()

	def theme_change(self) -> None:
		if self.color_theme_combobox.currentData() == "light":
			self.undiscovered_color = LIGHT_THEME["undiscovered_color"]
			self.discovered_color = LIGHT_THEME["discovered_color"]
			self.win_timer_color = LIGHT_THEME["win_timer_color"]
			self.lose_timer_color = LIGHT_THEME["lose_timer_color"]
			self.theme = "light"
	
		if self.color_theme_combobox.currentData() == "dark":	
			self.undiscovered_color = DARK_THEME["undiscovered_color"]
			self.discovered_color = DARK_THEME["discovered_color"]
			self.win_timer_color = DARK_THEME["win_timer_color"]
			self.lose_timer_color = DARK_THEME["lose_timer_color"]
			self.theme = "dark"

		if self.color_theme_combobox.currentData() == "colorful":	
			self.undiscovered_color = COLOR_THEME["undiscovered_color"]
			self.discovered_color = COLOR_THEME["discovered_color"]
			self.win_timer_color = COLOR_THEME["win_timer_color"]
			self.lose_timer_color = COLOR_THEME["lose_timer_color"]
			self.theme = "colorful"

		for y in range(Y_SIZE):
			for x in range(X_SIZE):	 
				if self.list_of_labels[y][x].marked:
					pass

				elif not self.list_of_labels[y][x].discovered:
					self.list_of_labels[y][x].setStyleSheet(f"background: {self.undiscovered_color}; border: 1px solid grey")

				elif self.list_of_labels[y][x].discovered:
					self.list_of_labels[y][x].setStyleSheet(f"background: {self.discovered_color}; border: 1px solid grey")
		
	def difficulty_label_set(self):
		self.difficulty_label.setText(str(self.difficulty_slider.value()))

	def mousePressEvent(self, QMouseEvent) -> None:
		if not self.player_ended:

			y = QMouseEvent.pos().x()
			x = QMouseEvent.pos().y()

			if not (x > X_GRID_SIZE or y > Y_GRID_SIZE):

				x = closest_smaller_number(x, Y_POSSIBLE_VALUES)
				y = closest_smaller_number(y, X_POSSIBLE_VALUES)

				x = int(x // FIELD_SQUARE_SIZE)
				y = int(y // FIELD_SQUARE_SIZE)

				if QMouseEvent.button() == Qt.LeftButton:
					if self.list_of_labels[x][y].mine:				
						self.stop_timer()
						if not self.player_ended:
							self.list_of_labels[x][y].discovered = True
							self.list_of_labels[x][y].setStyleSheet(f"background: {self.discovered_color}; border: 1px solid grey")
							self.list_of_labels[x][y].setPixmap(QPixmap("C:/Data/python/miny/pracovní verze/pictures/bomb_small.png"))
							self.win_massage.about(self, "PROHRA", "Tentokrát se to bohužel nepovedlo, snad to vyjde příště.")
					
						self.player_ended = True
					else:
						if not self.timer_already_started:
							self.start_timer()

						self.timer_already_started = True
						self.list_of_labels[x][y].discovered = True
						self.list_of_labels[x][y].setStyleSheet(f"background: {self.discovered_color}; border: 1px solid grey")

						self.reveal_area(y, x)

					self.solved_check()

				else:
					if not self.list_of_labels[x][y].discovered:
						if self.list_of_labels[x][y].marked:
							self.list_of_labels[x][y].setStyleSheet(f"background: {self.undiscovered_color}; border: 1px solid grey")
							self.list_of_labels[x][y].marked = False

						else:
							self.list_of_labels[x][y].setStyleSheet("background: orange; border: 1px solid grey")
							self.list_of_labels[x][y].marked = True

	def mines_number_surroundings_calculate(self) -> None:
		for x in range(X_SIZE):
			for y in range(Y_SIZE):
				self.list_of_labels[x][y].mines_number_surroundings = 0
				for i in range(x - 1, x + 2):
					for j in range(y - 1, y + 2):
						try:
							if self.list_of_labels[i][j].mine and i >= 0 and j >= 0:
								if not (i == x and j == y):
									self.list_of_labels[x][y].mines_number_surroundings += 1
						except IndexError:
							pass

	def new_mines_set(self):
		self.number_of_mines = mines_number(NUMBER_OF_LABELS, self.difficulty_slider.value())
		self.list_of_mines = generate_mines(self.number_of_mines, X_SIZE, Y_SIZE)
		for y in range(Y_SIZE):
			for x in range(X_SIZE):
				if (y, x) in self.list_of_mines:
					self.list_of_labels[y][x].mine = True
				else:
					self.list_of_labels[y][x].mine = False

		self.mines_number_surroundings_calculate()
		self.label_set()

	def label_set(self) -> None:
		for y in range(Y_SIZE):
			for x in range(X_SIZE):
				if self.list_of_labels[y][x].discovered:
					if self.list_of_labels[y][x].mines_number_surroundings == 0:
						pass
					else:
						self.list_of_labels[y][x].setText(str(self.list_of_labels[y][x].mines_number_surroundings))

	def reveal_area(self, x: int, y: int) -> None:
		if self.list_of_labels[y][x].mines_number_surroundings == 0:		
			try:
				extract = self.list_of_labels[y - 1][x]

				if not extract.mine and Y_SIZE > y - 1 >= 0 and not extract.discovered:
					self.list_of_labels[y - 1][x].setStyleSheet(f"background: {self.discovered_color}; border: 1px solid grey")
					self.list_of_labels[y - 1][x].discovered = True
					if extract.mines_number_surroundings == 0:
						self.reveal_area(x, y - 1)

			except IndexError:
				pass

			try:
				extract = self.list_of_labels[y + 1][x]

				if not extract.mine and Y_SIZE > y + 1 >= 0 and not extract.discovered:
					self.list_of_labels[y + 1][x].setStyleSheet(f"background: {self.discovered_color}; border: 1px solid grey")
					self.list_of_labels[y + 1][x].discovered = True
					if extract.mines_number_surroundings == 0:
						self.reveal_area(x, y + 1)

			except IndexError:
				pass

			try:
				extract = self.list_of_labels[y][x + 1]

				if not extract.mine and X_SIZE > x + 1 >= 0 and not extract.discovered:
					self.list_of_labels[y][x + 1].setStyleSheet(f"background: {self.discovered_color}; border: 1px solid grey")
					self.list_of_labels[y][x + 1].discovered = True
					if extract.mines_number_surroundings == 0:
						self.reveal_area(x + 1, y)

			except IndexError:
				pass

			try:
				extract = self.list_of_labels[y][x - 1]

				if not extract.mine and X_SIZE - 1 > x  - 1 >= 0 and not extract.discovered:
					self.list_of_labels[y][x - 1].setStyleSheet(f"background: {self.discovered_color}; border: 1px solid grey")
					self.list_of_labels[y][x - 1].discovered = True
					if extract.mines_number_surroundings == 0:
						self.reveal_area(x - 1, y)

			except IndexError:
				pass

		self.label_set()

	def solved_check(self) -> None:
		for element in self.list_of_labels:
			for part in element:
				if not part.mine and not part.discovered:
					return

		self.solved = True
		self.stop_timer()

		if not self.player_ended:
			self.player_ended = True
			self.win_massage.about(self, "VÝHRA", f"Gratuluji, zvládl/a jsi vyřešit tento problém. Zvládl/a jsi to za {self.curr_time.minute():0>2}:{self.curr_time.second():0>2}")

	# TIMER FUNCIONS
	def start_timer(self) -> None:
		self.difficulty_slider.setDisabled(True)
		self.timer.start(1000)
		
	def stop_timer(self) -> None:
		self.timer.stop()
		if not self.solved:
			self.timer_label.setStyleSheet(f"font: 34px; color: {self.win_timer_color}")
		else:
			self.timer_label.setStyleSheet(f"font: 34px; color: {self.lose_timer_color}")

	def time(self) -> None:
		self.curr_time = self.curr_time.addSecs(1)
		self.timer_label.setText(f"{self.curr_time.minute():0>2}:{self.curr_time.second():0>2}")

	#RESET
	def reset(self) -> None:
		self.timer = QTimer()
		self.curr_time = QTime(00,00,00)
		self.timer.timeout.connect(self.time)
		self.solved = False
		self.timer_already_started = False
		self.player_ended = False
		self.difficulty_slider.setDisabled(False)
		self.difficulty_slider_default_value = self.difficulty_slider.value()
		self.create_GUI()
class AudioTest(QMainWindow):

    PUSH_MODE_LABEL = "Enable push mode"
    PULL_MODE_LABEL = "Enable pull mode"
    SUSPEND_LABEL = "Suspend playback"
    RESUME_LABEL = "Resume playback"

    DurationSeconds = 1
    ToneSampleRateHz = 600
    DataSampleRateHz = 44100

    def __init__(self):
        super(AudioTest, self).__init__()

        self.m_device = QAudioDeviceInfo.defaultOutputDevice()
        self.m_output = None

        self.initializeWindow()
        self.initializeAudio()

    def initializeWindow(self):
        layout = QVBoxLayout()

        self.m_deviceBox = QComboBox()
        self.m_deviceBox.activated[int].connect(self.deviceChanged)
        for deviceInfo in QAudioDeviceInfo.availableDevices(
                QAudio.AudioOutput):
            self.m_deviceBox.addItem(deviceInfo.deviceName(), deviceInfo)

        layout.addWidget(self.m_deviceBox)

        self.m_modeButton = QPushButton()
        self.m_modeButton.clicked.connect(self.toggleMode)
        self.m_modeButton.setText(self.PUSH_MODE_LABEL)

        layout.addWidget(self.m_modeButton)

        self.m_suspendResumeButton = QPushButton(
            clicked=self.toggleSuspendResume)
        self.m_suspendResumeButton.setText(self.SUSPEND_LABEL)

        layout.addWidget(self.m_suspendResumeButton)

        volumeBox = QHBoxLayout()
        volumeLabel = QLabel("Volume:")
        self.m_volumeSlider = QSlider(Qt.Horizontal,
                                      minimum=0,
                                      maximum=100,
                                      singleStep=10)
        self.m_volumeSlider.valueChanged.connect(self.volumeChanged)

        volumeBox.addWidget(volumeLabel)
        volumeBox.addWidget(self.m_volumeSlider)

        layout.addLayout(volumeBox)

        window = QWidget()
        window.setLayout(layout)

        self.setCentralWidget(window)

    def initializeAudio(self):
        self.m_pullTimer = QTimer(self)
        self.m_pullTimer.timeout.connect(self.pullTimerExpired)
        self.m_pullMode = True

        self.m_format = QAudioFormat()
        self.m_format.setSampleRate(self.DataSampleRateHz)
        self.m_format.setChannelCount(1)
        self.m_format.setSampleSize(16)
        self.m_format.setCodec('audio/pcm')
        self.m_format.setByteOrder(QAudioFormat.LittleEndian)
        self.m_format.setSampleType(QAudioFormat.SignedInt)

        info = QAudioDeviceInfo(QAudioDeviceInfo.defaultOutputDevice())
        if not info.isFormatSupported(self.m_format):
            qWarning("Default format not supported - trying to use nearest")
            self.m_format = info.nearestFormat(self.m_format)

        self.m_generator = Generator(self.m_format,
                                     self.DurationSeconds * 1000000,
                                     self.ToneSampleRateHz, self)

        self.createAudioOutput()

    def createAudioOutput(self):
        self.m_audioOutput = QAudioOutput(self.m_device, self.m_format)
        self.m_audioOutput.notify.connect(self.notified)
        self.m_audioOutput.stateChanged.connect(self.handleStateChanged)

        self.m_generator.start()
        self.m_audioOutput.start(self.m_generator)
        self.m_volumeSlider.setValue(self.m_audioOutput.volume() * 100)

    def deviceChanged(self, index):
        self.m_pullTimer.stop()
        self.m_generator.stop()
        self.m_audioOutput.stop()
        self.m_device = self.m_deviceBox.itemData(index)

        self.createAudioOutput()

    def volumeChanged(self, value):
        if self.m_audioOutput is not None:
            self.m_audioOutput.setVolume(value / 100.0)

    def notified(self):
        qWarning(
            "bytesFree = %d, elapsedUSecs = %d, processedUSecs = %d" %
            (self.m_audioOutput.bytesFree(), self.m_audioOutput.elapsedUSecs(),
             self.m_audioOutput.processedUSecs()))

    def pullTimerExpired(self):
        if self.m_audioOutput is not None and self.m_audioOutput.state(
        ) != QAudio.StoppedState:
            chunks = self.m_audioOutput.bytesFree(
            ) // self.m_audioOutput.periodSize()
            for _ in range(chunks):
                data = self.m_generator.read(self.m_audioOutput.periodSize())
                if data is None or len(
                        data) != self.m_audioOutput.periodSize():
                    break

                self.m_output.write(data)

    def toggleMode(self):
        self.m_pullTimer.stop()
        self.m_audioOutput.stop()

        if self.m_pullMode:
            self.m_modeButton.setText(self.PULL_MODE_LABEL)
            self.m_output = self.m_audioOutput.start()
            self.m_pullMode = False
            self.m_pullTimer.start(20)
        else:
            self.m_modeButton.setText(self.PUSH_MODE_LABEL)
            self.m_pullMode = True
            self.m_audioOutput.start(self.m_generator)

        self.m_suspendResumeButton.setText(self.SUSPEND_LABEL)

    def toggleSuspendResume(self):
        if self.m_audioOutput.state() == QAudio.SuspendedState:
            qWarning("status: Suspended, resume()")
            self.m_audioOutput.resume()
            self.m_suspendResumeButton.setText(self.SUSPEND_LABEL)
        elif self.m_audioOutput.state() == QAudio.ActiveState:
            qWarning("status: Active, suspend()")
            self.m_audioOutput.suspend()
            self.m_suspendResumeButton.setText(self.RESUME_LABEL)
        elif self.m_audioOutput.state() == QAudio.StoppedState:
            qWarning("status: Stopped, resume()")
            self.m_audioOutput.resume()
            self.m_suspendResumeButton.setText(self.SUSPEND_LABEL)
        elif self.m_audioOutput.state() == QAudio.IdleState:
            qWarning("status: IdleState")

    stateMap = {
        QAudio.ActiveState: "ActiveState",
        QAudio.SuspendedState: "SuspendedState",
        QAudio.StoppedState: "StoppedState",
        QAudio.IdleState: "IdleState"
    }

    def handleStateChanged(self, state):
        qWarning("state = " + self.stateMap.get(state, "Unknown"))
Exemple #29
0
class Ui_ProfilesDialog_UI(object):
    def setupUi(self, ProfilesDialog_UI):
        if not ProfilesDialog_UI.objectName():
            ProfilesDialog_UI.setObjectName(u"ProfilesDialog_UI")
        ProfilesDialog_UI.resize(594, 639)
        self.gridLayout_2 = QGridLayout(ProfilesDialog_UI)
        self.gridLayout_2.setObjectName(u"gridLayout_2")
        self.button_create = QToolButton(ProfilesDialog_UI)
        self.button_create.setObjectName(u"button_create")
        icon = QIcon()
        iconThemeName = u"document-new"
        if QIcon.hasThemeIcon(iconThemeName):
            icon = QIcon.fromTheme(iconThemeName)
        else:
            icon.addFile(u".", QSize(), QIcon.Normal, QIcon.Off)
        
        self.button_create.setIcon(icon)

        self.gridLayout_2.addWidget(self.button_create, 0, 4, 1, 1)

        self.label = QLabel(ProfilesDialog_UI)
        self.label.setObjectName(u"label")

        self.gridLayout_2.addWidget(self.label, 0, 0, 1, 1)

        self.button_delete = QToolButton(ProfilesDialog_UI)
        self.button_delete.setObjectName(u"button_delete")
        self.button_delete.setEnabled(False)
        icon1 = QIcon()
        iconThemeName = u"delete"
        if QIcon.hasThemeIcon(iconThemeName):
            icon1 = QIcon.fromTheme(iconThemeName)
        else:
            icon1.addFile(u".", QSize(), QIcon.Normal, QIcon.Off)
        
        self.button_delete.setIcon(icon1)

        self.gridLayout_2.addWidget(self.button_delete, 0, 6, 1, 1)

        self.properties = QGroupBox(ProfilesDialog_UI)
        self.properties.setObjectName(u"properties")
        self.gridLayout = QGridLayout(self.properties)
        self.gridLayout.setObjectName(u"gridLayout")
        self.aspect_den = QSpinBox(self.properties)
        self.aspect_den.setObjectName(u"aspect_den")
        self.aspect_den.setMinimum(1)
        self.aspect_den.setMaximum(10000)

        self.gridLayout.addWidget(self.aspect_den, 4, 3, 1, 1)

        self.size_w = QSpinBox(self.properties)
        self.size_w.setObjectName(u"size_w")
        self.size_w.setMinimum(1)
        self.size_w.setMaximum(10000)

        self.gridLayout.addWidget(self.size_w, 1, 1, 1, 1)

        self.size_h = QSpinBox(self.properties)
        self.size_h.setObjectName(u"size_h")
        self.size_h.setMinimum(1)
        self.size_h.setMaximum(10000)

        self.gridLayout.addWidget(self.size_h, 1, 3, 1, 1)

        self.fields = QLabel(self.properties)
        self.fields.setObjectName(u"fields")
        self.fields.setText(u"interl: 2*fps")

        self.gridLayout.addWidget(self.fields, 3, 3, 1, 1)

        self.label_dar = QLabel(self.properties)
        self.label_dar.setObjectName(u"label_dar")
        self.label_dar.setAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter)

        self.gridLayout.addWidget(self.label_dar, 5, 0, 1, 1)

        self.label_3 = QLabel(self.properties)
        self.label_3.setObjectName(u"label_3")
        self.label_3.setAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter)

        self.gridLayout.addWidget(self.label_3, 2, 0, 1, 1)

        self.description = QLineEdit(self.properties)
        self.description.setObjectName(u"description")

        self.gridLayout.addWidget(self.description, 0, 1, 1, 3)

        self.colorspace = KComboBox(self.properties)
        self.colorspace.setObjectName(u"colorspace")

        self.gridLayout.addWidget(self.colorspace, 7, 1, 1, 3)

        self.label_8 = QLabel(self.properties)
        self.label_8.setObjectName(u"label_8")
        sizePolicy = QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.label_8.sizePolicy().hasHeightForWidth())
        self.label_8.setSizePolicy(sizePolicy)

        self.gridLayout.addWidget(self.label_8, 5, 2, 1, 1)

        self.field_order = QComboBox(self.properties)
        self.field_order.addItem("")
        self.field_order.addItem("")
        self.field_order.setObjectName(u"field_order")

        self.gridLayout.addWidget(self.field_order, 9, 1, 1, 3)

        self.display_num = QSpinBox(self.properties)
        self.display_num.setObjectName(u"display_num")
        self.display_num.setMinimum(1)
        self.display_num.setMaximum(10000)

        self.gridLayout.addWidget(self.display_num, 5, 1, 1, 1)

        self.label_scanning = QLabel(self.properties)
        self.label_scanning.setObjectName(u"label_scanning")
        self.label_scanning.setAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter)

        self.gridLayout.addWidget(self.label_scanning, 8, 0, 1, 1)

        self.label_4 = QLabel(self.properties)
        self.label_4.setObjectName(u"label_4")
        sizePolicy.setHeightForWidth(self.label_4.sizePolicy().hasHeightForWidth())
        self.label_4.setSizePolicy(sizePolicy)

        self.gridLayout.addWidget(self.label_4, 2, 2, 1, 1)

        self.aspect_num = QSpinBox(self.properties)
        self.aspect_num.setObjectName(u"aspect_num")
        self.aspect_num.setMinimum(1)
        self.aspect_num.setMaximum(10000)

        self.gridLayout.addWidget(self.aspect_num, 4, 1, 1, 1)

        self.label_6 = QLabel(self.properties)
        self.label_6.setObjectName(u"label_6")
        sizePolicy.setHeightForWidth(self.label_6.sizePolicy().hasHeightForWidth())
        self.label_6.setSizePolicy(sizePolicy)

        self.gridLayout.addWidget(self.label_6, 1, 2, 1, 1)

        self.label_2 = QLabel(self.properties)
        self.label_2.setObjectName(u"label_2")
        self.label_2.setAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter)

        self.gridLayout.addWidget(self.label_2, 0, 0, 1, 1)

        self.scanning = QComboBox(self.properties)
        self.scanning.addItem("")
        self.scanning.addItem("")
        self.scanning.setObjectName(u"scanning")

        self.gridLayout.addWidget(self.scanning, 8, 1, 1, 3)

        self.frame_num = QSpinBox(self.properties)
        self.frame_num.setObjectName(u"frame_num")
        self.frame_num.setMinimum(1)
        self.frame_num.setMaximum(500000)

        self.gridLayout.addWidget(self.frame_num, 2, 1, 1, 1)

        self.display_den = QSpinBox(self.properties)
        self.display_den.setObjectName(u"display_den")
        self.display_den.setMinimum(1)
        self.display_den.setMaximum(10000)

        self.gridLayout.addWidget(self.display_den, 5, 3, 1, 1)

        self.verticalSpacer = QSpacerItem(105, 17, QSizePolicy.Minimum, QSizePolicy.Expanding)

        self.gridLayout.addItem(self.verticalSpacer, 11, 0, 1, 2)

        self.label_9 = QLabel(self.properties)
        self.label_9.setObjectName(u"label_9")
        self.label_9.setAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter)

        self.gridLayout.addWidget(self.label_9, 4, 0, 1, 1)

        self.label_12 = QLabel(self.properties)
        self.label_12.setObjectName(u"label_12")
        self.label_12.setAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter)

        self.gridLayout.addWidget(self.label_12, 7, 0, 1, 1)

        self.label_5 = QLabel(self.properties)
        self.label_5.setObjectName(u"label_5")
        self.label_5.setAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter)

        self.gridLayout.addWidget(self.label_5, 1, 0, 1, 1)

        self.label_field_order = QLabel(self.properties)
        self.label_field_order.setObjectName(u"label_field_order")
        self.label_field_order.setAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter)

        self.gridLayout.addWidget(self.label_field_order, 9, 0, 1, 1)

        self.label_7 = QLabel(self.properties)
        self.label_7.setObjectName(u"label_7")
        sizePolicy.setHeightForWidth(self.label_7.sizePolicy().hasHeightForWidth())
        self.label_7.setSizePolicy(sizePolicy)

        self.gridLayout.addWidget(self.label_7, 4, 2, 1, 1)

        self.frame_den = QSpinBox(self.properties)
        self.frame_den.setObjectName(u"frame_den")
        self.frame_den.setMinimum(1)
        self.frame_den.setMaximum(10000)

        self.gridLayout.addWidget(self.frame_den, 2, 3, 1, 1)

        self.label_11 = QLabel(self.properties)
        self.label_11.setObjectName(u"label_11")
        self.label_11.setAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter)

        self.gridLayout.addWidget(self.label_11, 3, 0, 1, 1)

        self.effect_warning = KMessageWidget(self.properties)
        self.effect_warning.setObjectName(u"effect_warning")
        self.effect_warning.setWordWrap(True)
        self.effect_warning.setCloseButtonVisible(False)
        self.effect_warning.setMessageType(KMessageWidget.Warning)

        self.gridLayout.addWidget(self.effect_warning, 10, 1, 1, 3)


        self.gridLayout_2.addWidget(self.properties, 1, 0, 1, 8)

        self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)

        self.gridLayout_2.addItem(self.horizontalSpacer, 0, 3, 1, 1)

        self.button_save = QToolButton(ProfilesDialog_UI)
        self.button_save.setObjectName(u"button_save")
        self.button_save.setEnabled(False)
        icon2 = QIcon()
        iconThemeName = u"document-save"
        if QIcon.hasThemeIcon(iconThemeName):
            icon2 = QIcon.fromTheme(iconThemeName)
        else:
            icon2.addFile(u".", QSize(), QIcon.Normal, QIcon.Off)
        
        self.button_save.setIcon(icon2)

        self.gridLayout_2.addWidget(self.button_save, 0, 5, 1, 1)

        self.horizontalSpacer_2 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)

        self.gridLayout_2.addItem(self.horizontalSpacer_2, 3, 3, 1, 2)

        self.buttonBox = QDialogButtonBox(ProfilesDialog_UI)
        self.buttonBox.setObjectName(u"buttonBox")
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Close)

        self.gridLayout_2.addWidget(self.buttonBox, 3, 5, 1, 3)

        self.profiles_list = QComboBox(ProfilesDialog_UI)
        self.profiles_list.setObjectName(u"profiles_list")

        self.gridLayout_2.addWidget(self.profiles_list, 0, 1, 1, 1)

        self.button_default = QPushButton(ProfilesDialog_UI)
        self.button_default.setObjectName(u"button_default")

        self.gridLayout_2.addWidget(self.button_default, 3, 0, 1, 3)

        self.info_message = KMessageWidget(ProfilesDialog_UI)
        self.info_message.setObjectName(u"info_message")
        self.info_message.setWordWrap(True)

        self.gridLayout_2.addWidget(self.info_message, 2, 0, 1, 8)


        self.retranslateUi(ProfilesDialog_UI)
        self.buttonBox.accepted.connect(ProfilesDialog_UI.accept)
        self.buttonBox.rejected.connect(ProfilesDialog_UI.reject)

        QMetaObject.connectSlotsByName(ProfilesDialog_UI)
    # setupUi

    def retranslateUi(self, ProfilesDialog_UI):
        ProfilesDialog_UI.setWindowTitle(QCoreApplication.translate("ProfilesDialog_UI", u"Profiles", None))
#if QT_CONFIG(tooltip)
        self.button_create.setToolTip(QCoreApplication.translate("ProfilesDialog_UI", u"Create  new profile", None))
#endif // QT_CONFIG(tooltip)
        self.button_create.setText(QCoreApplication.translate("ProfilesDialog_UI", u"C", None))
        self.label.setText(QCoreApplication.translate("ProfilesDialog_UI", u"Profile:", None))
#if QT_CONFIG(tooltip)
        self.button_delete.setToolTip(QCoreApplication.translate("ProfilesDialog_UI", u"Delete profile", None))
#endif // QT_CONFIG(tooltip)
        self.button_delete.setText(QCoreApplication.translate("ProfilesDialog_UI", u"D", None))
        self.properties.setTitle(QCoreApplication.translate("ProfilesDialog_UI", u"Properties", None))
        self.label_dar.setText(QCoreApplication.translate("ProfilesDialog_UI", u"Display aspect ratio:", None))
        self.label_3.setText(QCoreApplication.translate("ProfilesDialog_UI", u"Frame rate:", None))
        self.label_8.setText(QCoreApplication.translate("ProfilesDialog_UI", u"/", None))
        self.field_order.setItemText(0, QCoreApplication.translate("ProfilesDialog_UI", u"Top Field First", None))
        self.field_order.setItemText(1, QCoreApplication.translate("ProfilesDialog_UI", u"Bottom Field First", None))

        self.label_scanning.setText(QCoreApplication.translate("ProfilesDialog_UI", u"Scanning:", None))
        self.label_4.setText(QCoreApplication.translate("ProfilesDialog_UI", u"/", None))
        self.label_6.setText(QCoreApplication.translate("ProfilesDialog_UI", u"x", None))
        self.label_2.setText(QCoreApplication.translate("ProfilesDialog_UI", u"Description:", None))
        self.scanning.setItemText(0, QCoreApplication.translate("ProfilesDialog_UI", u"Interlaced", None))
        self.scanning.setItemText(1, QCoreApplication.translate("ProfilesDialog_UI", u"Progressive", None))

        self.label_9.setText(QCoreApplication.translate("ProfilesDialog_UI", u"Pixel aspect ratio:", None))
        self.label_12.setText(QCoreApplication.translate("ProfilesDialog_UI", u"Colorspace:", None))
        self.label_5.setText(QCoreApplication.translate("ProfilesDialog_UI", u"Size:", None))
        self.label_field_order.setText(QCoreApplication.translate("ProfilesDialog_UI", u"Field order:", None))
        self.label_7.setText(QCoreApplication.translate("ProfilesDialog_UI", u"/", None))
        self.label_11.setText(QCoreApplication.translate("ProfilesDialog_UI", u"Fields per second:", None))
        self.effect_warning.setText(QCoreApplication.translate("ProfilesDialog_UI", u"The \"avfilter.fieldorder\" effect is internally used to set the field order, but the effect was not found.\n"
"This feature will not work as expected.", None))
#if QT_CONFIG(tooltip)
        self.button_save.setToolTip(QCoreApplication.translate("ProfilesDialog_UI", u"Save profile", None))
#endif // QT_CONFIG(tooltip)
        self.button_save.setText(QCoreApplication.translate("ProfilesDialog_UI", u"S", None))
        self.button_default.setText(QCoreApplication.translate("ProfilesDialog_UI", u"Use as default", None))
Exemple #30
0
class Ui_EditRenderPreset_UI(object):
    def setupUi(self, EditRenderPreset_UI):
        if not EditRenderPreset_UI.objectName():
            EditRenderPreset_UI.setObjectName(u"EditRenderPreset_UI")
        EditRenderPreset_UI.resize(463, 630)
        self.verticalLayout_2 = QVBoxLayout(EditRenderPreset_UI)
        self.verticalLayout_2.setObjectName(u"verticalLayout_2")
        self.mainBox = QHBoxLayout()
        self.mainBox.setObjectName(u"mainBox")
        self.formLayout_6 = QFormLayout()
        self.formLayout_6.setObjectName(u"formLayout_6")
        self.formLayout_6.setContentsMargins(-1, 20, 10, -1)
        self.groupLabel = QLabel(EditRenderPreset_UI)
        self.groupLabel.setObjectName(u"groupLabel")

        self.formLayout_6.setWidget(0, QFormLayout.LabelRole, self.groupLabel)

        self.presetNameLabel = QLabel(EditRenderPreset_UI)
        self.presetNameLabel.setObjectName(u"presetNameLabel")

        self.formLayout_6.setWidget(1, QFormLayout.LabelRole,
                                    self.presetNameLabel)

        self.preset_name = QLineEdit(EditRenderPreset_UI)
        self.preset_name.setObjectName(u"preset_name")

        self.formLayout_6.setWidget(1, QFormLayout.FieldRole, self.preset_name)

        self.label_2 = QLabel(EditRenderPreset_UI)
        self.label_2.setObjectName(u"label_2")

        self.formLayout_6.setWidget(2, QFormLayout.LabelRole, self.label_2)

        self.formatCombo = QComboBox(EditRenderPreset_UI)
        self.formatCombo.setObjectName(u"formatCombo")

        self.formLayout_6.setWidget(2, QFormLayout.FieldRole, self.formatCombo)

        self.tabWidget = QTabWidget(EditRenderPreset_UI)
        self.tabWidget.setObjectName(u"tabWidget")
        self.video_tab = QWidget()
        self.video_tab.setObjectName(u"video_tab")
        self.verticalLayout_3 = QVBoxLayout(self.video_tab)
        self.verticalLayout_3.setObjectName(u"verticalLayout_3")
        self.verticalLayout_3.setContentsMargins(0, 0, 0, 0)
        self.scrollArea = QScrollArea(self.video_tab)
        self.scrollArea.setObjectName(u"scrollArea")
        sizePolicy = QSizePolicy(QSizePolicy.MinimumExpanding,
                                 QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.scrollArea.sizePolicy().hasHeightForWidth())
        self.scrollArea.setSizePolicy(sizePolicy)
        self.scrollArea.setFrameShape(QFrame.NoFrame)
        self.scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.scrollAreaWidgetContents = QWidget()
        self.scrollAreaWidgetContents.setObjectName(
            u"scrollAreaWidgetContents")
        self.scrollAreaWidgetContents.setGeometry(QRect(0, 0, 428, 650))
        self.formLayout_3 = QFormLayout(self.scrollAreaWidgetContents)
        self.formLayout_3.setObjectName(u"formLayout_3")
        self.formLayout_3.setContentsMargins(-1, -1, 40, -1)
        self.label_4 = QLabel(self.scrollAreaWidgetContents)
        self.label_4.setObjectName(u"label_4")

        self.formLayout_3.setWidget(0, QFormLayout.LabelRole, self.label_4)

        self.horizontalLayout_3 = QHBoxLayout()
        self.horizontalLayout_3.setObjectName(u"horizontalLayout_3")
        self.resWidth = QSpinBox(self.scrollAreaWidgetContents)
        self.resWidth.setObjectName(u"resWidth")
        self.resWidth.setMinimum(1)
        self.resWidth.setMaximum(8192)
        self.resWidth.setSingleStep(2)
        self.resWidth.setValue(1)

        self.horizontalLayout_3.addWidget(self.resWidth)

        self.label_9 = QLabel(self.scrollAreaWidgetContents)
        self.label_9.setObjectName(u"label_9")
        self.label_9.setMinimumSize(QSize(10, 0))
        self.label_9.setText(u"x")
        self.label_9.setAlignment(Qt.AlignCenter)

        self.horizontalLayout_3.addWidget(self.label_9)

        self.resHeight = QSpinBox(self.scrollAreaWidgetContents)
        self.resHeight.setObjectName(u"resHeight")
        self.resHeight.setMinimum(1)
        self.resHeight.setMaximum(8192)
        self.resHeight.setSingleStep(2)

        self.horizontalLayout_3.addWidget(self.resHeight)

        self.linkResoultion = QToolButton(self.scrollAreaWidgetContents)
        self.linkResoultion.setObjectName(u"linkResoultion")
        icon = QIcon()
        iconThemeName = u"link"
        if QIcon.hasThemeIcon(iconThemeName):
            icon = QIcon.fromTheme(iconThemeName)
        else:
            icon.addFile(u".", QSize(), QIcon.Normal, QIcon.Off)

        self.linkResoultion.setIcon(icon)
        self.linkResoultion.setCheckable(True)
        self.linkResoultion.setAutoRaise(True)

        self.horizontalLayout_3.addWidget(self.linkResoultion)

        self.formLayout_3.setLayout(0, QFormLayout.FieldRole,
                                    self.horizontalLayout_3)

        self.label_6 = QLabel(self.scrollAreaWidgetContents)
        self.label_6.setObjectName(u"label_6")

        self.formLayout_3.setWidget(1, QFormLayout.LabelRole, self.label_6)

        self.parCombo = QComboBox(self.scrollAreaWidgetContents)
        self.parCombo.setObjectName(u"parCombo")
        self.parCombo.setSizeAdjustPolicy(QComboBox.AdjustToContents)

        self.formLayout_3.setWidget(1, QFormLayout.FieldRole, self.parCombo)

        self.label_16 = QLabel(self.scrollAreaWidgetContents)
        self.label_16.setObjectName(u"label_16")

        self.formLayout_3.setWidget(2, QFormLayout.LabelRole, self.label_16)

        self.horizontalLayout_4 = QHBoxLayout()
        self.horizontalLayout_4.setObjectName(u"horizontalLayout_4")
        self.displayAspectNum = QSpinBox(self.scrollAreaWidgetContents)
        self.displayAspectNum.setObjectName(u"displayAspectNum")
        self.displayAspectNum.setMinimum(1)
        self.displayAspectNum.setMaximum(8192)

        self.horizontalLayout_4.addWidget(self.displayAspectNum)

        self.label_17 = QLabel(self.scrollAreaWidgetContents)
        self.label_17.setObjectName(u"label_17")
        self.label_17.setMinimumSize(QSize(10, 0))
        self.label_17.setText(u":")
        self.label_17.setAlignment(Qt.AlignCenter)

        self.horizontalLayout_4.addWidget(self.label_17)

        self.displayAspectDen = QSpinBox(self.scrollAreaWidgetContents)
        self.displayAspectDen.setObjectName(u"displayAspectDen")
        self.displayAspectDen.setMinimum(1)
        self.displayAspectDen.setMaximum(8192)

        self.horizontalLayout_4.addWidget(self.displayAspectDen)

        self.formLayout_3.setLayout(2, QFormLayout.FieldRole,
                                    self.horizontalLayout_4)

        self.horizontalLayout = QHBoxLayout()
        self.horizontalLayout.setObjectName(u"horizontalLayout")
        self.framerateNum = QSpinBox(self.scrollAreaWidgetContents)
        self.framerateNum.setObjectName(u"framerateNum")
        self.framerateNum.setMinimum(1)
        self.framerateNum.setMaximum(1000000)

        self.horizontalLayout.addWidget(self.framerateNum)

        self.label_8 = QLabel(self.scrollAreaWidgetContents)
        self.label_8.setObjectName(u"label_8")
        sizePolicy1 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        sizePolicy1.setHorizontalStretch(0)
        sizePolicy1.setVerticalStretch(0)
        sizePolicy1.setHeightForWidth(
            self.label_8.sizePolicy().hasHeightForWidth())
        self.label_8.setSizePolicy(sizePolicy1)
        self.label_8.setMinimumSize(QSize(10, 0))
        self.label_8.setText(u"/")
        self.label_8.setAlignment(Qt.AlignCenter)

        self.horizontalLayout.addWidget(self.label_8)

        self.framerateDen = QSpinBox(self.scrollAreaWidgetContents)
        self.framerateDen.setObjectName(u"framerateDen")
        self.framerateDen.setMinimum(1)
        self.framerateDen.setMaximum(9999)

        self.horizontalLayout.addWidget(self.framerateDen)

        self.formLayout_3.setLayout(3, QFormLayout.FieldRole,
                                    self.horizontalLayout)

        self.label_3 = QLabel(self.scrollAreaWidgetContents)
        self.label_3.setObjectName(u"label_3")

        self.formLayout_3.setWidget(3, QFormLayout.LabelRole, self.label_3)

        self.label_22 = QLabel(self.scrollAreaWidgetContents)
        self.label_22.setObjectName(u"label_22")

        self.formLayout_3.setWidget(4, QFormLayout.LabelRole, self.label_22)

        self.frameRateDisplay = QLabel(self.scrollAreaWidgetContents)
        self.frameRateDisplay.setObjectName(u"frameRateDisplay")
        self.frameRateDisplay.setEnabled(True)

        self.formLayout_3.setWidget(4, QFormLayout.FieldRole,
                                    self.frameRateDisplay)

        self.label_7 = QLabel(self.scrollAreaWidgetContents)
        self.label_7.setObjectName(u"label_7")

        self.formLayout_3.setWidget(5, QFormLayout.LabelRole, self.label_7)

        self.scanningCombo = QComboBox(self.scrollAreaWidgetContents)
        self.scanningCombo.addItem("")
        self.scanningCombo.addItem("")
        self.scanningCombo.setObjectName(u"scanningCombo")

        self.formLayout_3.setWidget(5, QFormLayout.FieldRole,
                                    self.scanningCombo)

        self.fieldOrderLabel = QLabel(self.scrollAreaWidgetContents)
        self.fieldOrderLabel.setObjectName(u"fieldOrderLabel")

        self.formLayout_3.setWidget(6, QFormLayout.LabelRole,
                                    self.fieldOrderLabel)

        self.fieldOrderCombo = QComboBox(self.scrollAreaWidgetContents)
        self.fieldOrderCombo.addItem("")
        self.fieldOrderCombo.addItem("")
        self.fieldOrderCombo.setObjectName(u"fieldOrderCombo")
        self.fieldOrderCombo.setSizeAdjustPolicy(QComboBox.AdjustToContents)

        self.formLayout_3.setWidget(6, QFormLayout.FieldRole,
                                    self.fieldOrderCombo)

        self.colorspaceLabel = QLabel(self.scrollAreaWidgetContents)
        self.colorspaceLabel.setObjectName(u"colorspaceLabel")
        self.colorspaceLabel.setEnabled(False)

        self.formLayout_3.setWidget(7, QFormLayout.LabelRole,
                                    self.colorspaceLabel)

        self.colorspaceCombo = QComboBox(self.scrollAreaWidgetContents)
        self.colorspaceCombo.setObjectName(u"colorspaceCombo")
        self.colorspaceCombo.setEnabled(False)

        self.formLayout_3.setWidget(7, QFormLayout.FieldRole,
                                    self.colorspaceCombo)

        self.vCodecCombo = QComboBox(self.scrollAreaWidgetContents)
        self.vCodecCombo.setObjectName(u"vCodecCombo")
        sizePolicy2 = QSizePolicy(QSizePolicy.MinimumExpanding,
                                  QSizePolicy.Fixed)
        sizePolicy2.setHorizontalStretch(0)
        sizePolicy2.setVerticalStretch(0)
        sizePolicy2.setHeightForWidth(
            self.vCodecCombo.sizePolicy().hasHeightForWidth())
        self.vCodecCombo.setSizePolicy(sizePolicy2)

        self.formLayout_3.setWidget(8, QFormLayout.FieldRole, self.vCodecCombo)

        self.vRateControlCombo = QComboBox(self.scrollAreaWidgetContents)
        self.vRateControlCombo.setObjectName(u"vRateControlCombo")
        sizePolicy2.setHeightForWidth(
            self.vRateControlCombo.sizePolicy().hasHeightForWidth())
        self.vRateControlCombo.setSizePolicy(sizePolicy2)

        self.formLayout_3.setWidget(9, QFormLayout.FieldRole,
                                    self.vRateControlCombo)

        self.label_24 = QLabel(self.scrollAreaWidgetContents)
        self.label_24.setObjectName(u"label_24")

        self.formLayout_3.setWidget(8, QFormLayout.LabelRole, self.label_24)

        self.label_12 = QLabel(self.scrollAreaWidgetContents)
        self.label_12.setObjectName(u"label_12")

        self.formLayout_3.setWidget(9, QFormLayout.LabelRole, self.label_12)

        self.default_vbitrate_label = QLabel(self.scrollAreaWidgetContents)
        self.default_vbitrate_label.setObjectName(u"default_vbitrate_label")

        self.formLayout_3.setWidget(10, QFormLayout.LabelRole,
                                    self.default_vbitrate_label)

        self.default_vbitrate = QSpinBox(self.scrollAreaWidgetContents)
        self.default_vbitrate.setObjectName(u"default_vbitrate")
        self.default_vbitrate.setMaximum(500000)

        self.formLayout_3.setWidget(10, QFormLayout.FieldRole,
                                    self.default_vbitrate)

        self.vBuffer_label = QLabel(self.scrollAreaWidgetContents)
        self.vBuffer_label.setObjectName(u"vBuffer_label")

        self.formLayout_3.setWidget(11, QFormLayout.LabelRole,
                                    self.vBuffer_label)

        self.vBuffer = QSpinBox(self.scrollAreaWidgetContents)
        self.vBuffer.setObjectName(u"vBuffer")
        self.vBuffer.setMaximum(9999)

        self.formLayout_3.setWidget(11, QFormLayout.FieldRole, self.vBuffer)

        self.vquality_label = QLabel(self.scrollAreaWidgetContents)
        self.vquality_label.setObjectName(u"vquality_label")

        self.formLayout_3.setWidget(12, QFormLayout.LabelRole,
                                    self.vquality_label)

        self.default_vquality = QSpinBox(self.scrollAreaWidgetContents)
        self.default_vquality.setObjectName(u"default_vquality")
        self.default_vquality.setMaximum(500000)

        self.formLayout_3.setWidget(12, QFormLayout.FieldRole,
                                    self.default_vquality)

        self.label_26 = QLabel(self.scrollAreaWidgetContents)
        self.label_26.setObjectName(u"label_26")

        self.formLayout_3.setWidget(13, QFormLayout.LabelRole, self.label_26)

        self.gopSpinner = QSpinBox(self.scrollAreaWidgetContents)
        self.gopSpinner.setObjectName(u"gopSpinner")
        self.gopSpinner.setMaximum(999)
        self.gopSpinner.setSingleStep(1)

        self.formLayout_3.setWidget(13, QFormLayout.FieldRole, self.gopSpinner)

        self.fixedGop = QCheckBox(self.scrollAreaWidgetContents)
        self.fixedGop.setObjectName(u"fixedGop")
        self.fixedGop.setEnabled(False)

        self.formLayout_3.setWidget(14, QFormLayout.FieldRole, self.fixedGop)

        self.bFramesSpinner = QSpinBox(self.scrollAreaWidgetContents)
        self.bFramesSpinner.setObjectName(u"bFramesSpinner")
        self.bFramesSpinner.setEnabled(False)
        self.bFramesSpinner.setMinimum(-1)
        self.bFramesSpinner.setMaximum(8)
        self.bFramesSpinner.setValue(-1)

        self.formLayout_3.setWidget(15, QFormLayout.FieldRole,
                                    self.bFramesSpinner)

        self.bFramesLabel = QLabel(self.scrollAreaWidgetContents)
        self.bFramesLabel.setObjectName(u"bFramesLabel")

        self.formLayout_3.setWidget(15, QFormLayout.LabelRole,
                                    self.bFramesLabel)

        self.scrollArea.setWidget(self.scrollAreaWidgetContents)

        self.verticalLayout_3.addWidget(self.scrollArea)

        self.tabWidget.addTab(self.video_tab, "")
        self.audio_tab = QWidget()
        self.audio_tab.setObjectName(u"audio_tab")
        self.formLayout_2 = QFormLayout(self.audio_tab)
        self.formLayout_2.setObjectName(u"formLayout_2")
        self.label_15 = QLabel(self.audio_tab)
        self.label_15.setObjectName(u"label_15")

        self.formLayout_2.setWidget(0, QFormLayout.LabelRole, self.label_15)

        self.audioChannels = QComboBox(self.audio_tab)
        self.audioChannels.setObjectName(u"audioChannels")

        self.formLayout_2.setWidget(0, QFormLayout.FieldRole,
                                    self.audioChannels)

        self.label_13 = QLabel(self.audio_tab)
        self.label_13.setObjectName(u"label_13")

        self.formLayout_2.setWidget(1, QFormLayout.LabelRole, self.label_13)

        self.aCodecCombo = QComboBox(self.audio_tab)
        self.aCodecCombo.setObjectName(u"aCodecCombo")

        self.formLayout_2.setWidget(1, QFormLayout.FieldRole, self.aCodecCombo)

        self.label_11 = QLabel(self.audio_tab)
        self.label_11.setObjectName(u"label_11")

        self.formLayout_2.setWidget(2, QFormLayout.LabelRole, self.label_11)

        self.horizontalLayout_5 = QHBoxLayout()
        self.horizontalLayout_5.setObjectName(u"horizontalLayout_5")
        self.audioSampleRate = QComboBox(self.audio_tab)
        self.audioSampleRate.addItem("")
        self.audioSampleRate.addItem("")
        self.audioSampleRate.addItem("")
        self.audioSampleRate.addItem("")
        self.audioSampleRate.addItem("")
        self.audioSampleRate.addItem("")
        self.audioSampleRate.addItem("")
        self.audioSampleRate.addItem("")
        self.audioSampleRate.setObjectName(u"audioSampleRate")
        self.audioSampleRate.setEditable(True)

        self.horizontalLayout_5.addWidget(self.audioSampleRate)

        self.label_20 = QLabel(self.audio_tab)
        self.label_20.setObjectName(u"label_20")

        self.horizontalLayout_5.addWidget(self.label_20)

        self.formLayout_2.setLayout(2, QFormLayout.FieldRole,
                                    self.horizontalLayout_5)

        self.label_14 = QLabel(self.audio_tab)
        self.label_14.setObjectName(u"label_14")

        self.formLayout_2.setWidget(3, QFormLayout.LabelRole, self.label_14)

        self.aRateControlCombo = QComboBox(self.audio_tab)
        self.aRateControlCombo.setObjectName(u"aRateControlCombo")

        self.formLayout_2.setWidget(3, QFormLayout.FieldRole,
                                    self.aRateControlCombo)

        self.label_18 = QLabel(self.audio_tab)
        self.label_18.setObjectName(u"label_18")

        self.formLayout_2.setWidget(4, QFormLayout.LabelRole, self.label_18)

        self.aBitrate = QSpinBox(self.audio_tab)
        self.aBitrate.setObjectName(u"aBitrate")
        self.aBitrate.setMaximum(500000)

        self.formLayout_2.setWidget(4, QFormLayout.FieldRole, self.aBitrate)

        self.label_19 = QLabel(self.audio_tab)
        self.label_19.setObjectName(u"label_19")

        self.formLayout_2.setWidget(5, QFormLayout.LabelRole, self.label_19)

        self.aQuality = QSpinBox(self.audio_tab)
        self.aQuality.setObjectName(u"aQuality")
        self.aQuality.setMaximum(500000)

        self.formLayout_2.setWidget(5, QFormLayout.FieldRole, self.aQuality)

        self.tabWidget.addTab(self.audio_tab, "")
        self.tab = QWidget()
        self.tab.setObjectName(u"tab")
        self.verticalLayout = QVBoxLayout(self.tab)
        self.verticalLayout.setObjectName(u"verticalLayout")
        self.speedsLabel = QLabel(self.tab)
        self.speedsLabel.setObjectName(u"speedsLabel")

        self.verticalLayout.addWidget(self.speedsLabel)

        self.speeds_list = QTextEdit(self.tab)
        self.speeds_list.setObjectName(u"speeds_list")
        self.speeds_list.setAcceptRichText(False)

        self.verticalLayout.addWidget(self.speeds_list)

        self.label = QLabel(self.tab)
        self.label.setObjectName(u"label")

        self.verticalLayout.addWidget(self.label)

        self.overrideParamsWarning = KMessageWidget(self.tab)
        self.overrideParamsWarning.setObjectName(u"overrideParamsWarning")
        self.overrideParamsWarning.setProperty("wordWrap", True)
        self.overrideParamsWarning.setProperty("closeButtonVisible", False)

        self.verticalLayout.addWidget(self.overrideParamsWarning)

        self.additionalParams = QPlainTextEdit(self.tab)
        self.additionalParams.setObjectName(u"additionalParams")

        self.verticalLayout.addWidget(self.additionalParams)

        self.parametersLabel = QLabel(self.tab)
        self.parametersLabel.setObjectName(u"parametersLabel")
        self.parametersLabel.setTextFormat(Qt.RichText)
        self.parametersLabel.setWordWrap(True)
        self.parametersLabel.setOpenExternalLinks(True)

        self.verticalLayout.addWidget(self.parametersLabel)

        self.tabWidget.addTab(self.tab, "")

        self.formLayout_6.setWidget(4, QFormLayout.SpanningRole,
                                    self.tabWidget)

        self.parameters = QTextEdit(EditRenderPreset_UI)
        self.parameters.setObjectName(u"parameters")
        self.parameters.setReadOnly(True)
        self.parameters.setAcceptRichText(False)

        self.formLayout_6.setWidget(5, QFormLayout.SpanningRole,
                                    self.parameters)

        self.groupName = QComboBox(EditRenderPreset_UI)
        self.groupName.setObjectName(u"groupName")
        sizePolicy2.setHeightForWidth(
            self.groupName.sizePolicy().hasHeightForWidth())
        self.groupName.setSizePolicy(sizePolicy2)
        self.groupName.setEditable(True)
        self.groupName.setSizeAdjustPolicy(QComboBox.AdjustToContents)

        self.formLayout_6.setWidget(0, QFormLayout.FieldRole, self.groupName)

        self.mainBox.addLayout(self.formLayout_6)

        self.verticalLayout_2.addLayout(self.mainBox)

        self.buttonBox = QDialogButtonBox(EditRenderPreset_UI)
        self.buttonBox.setObjectName(u"buttonBox")
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel
                                          | QDialogButtonBox.Ok)

        self.verticalLayout_2.addWidget(self.buttonBox)

        self.retranslateUi(EditRenderPreset_UI)
        self.buttonBox.rejected.connect(EditRenderPreset_UI.reject)

        self.tabWidget.setCurrentIndex(0)

        QMetaObject.connectSlotsByName(EditRenderPreset_UI)

    # setupUi

    def retranslateUi(self, EditRenderPreset_UI):
        EditRenderPreset_UI.setWindowTitle(
            QCoreApplication.translate("EditRenderPreset_UI",
                                       u"Save Render Preset", None))
        self.groupLabel.setText(
            QCoreApplication.translate("EditRenderPreset_UI", u"Group:", None))
        self.presetNameLabel.setText(
            QCoreApplication.translate("EditRenderPreset_UI", u"Preset name:",
                                       None))
        self.label_2.setText(
            QCoreApplication.translate("EditRenderPreset_UI", u"Container:",
                                       None))
        self.label_4.setText(
            QCoreApplication.translate("EditRenderPreset_UI", u"Resolution:",
                                       None))
        self.linkResoultion.setText(
            QCoreApplication.translate("EditRenderPreset_UI", u"...", None))
        self.label_6.setText(
            QCoreApplication.translate("EditRenderPreset_UI",
                                       u"Pixel Aspect Ratio:", None))
        self.label_16.setText(
            QCoreApplication.translate("EditRenderPreset_UI",
                                       u"Display Aspect Ratio:", None))
        self.label_3.setText(
            QCoreApplication.translate("EditRenderPreset_UI", u"Frame Rate:",
                                       None))
        self.label_22.setText(
            QCoreApplication.translate("EditRenderPreset_UI",
                                       u"Fields per Second:", None))
        self.frameRateDisplay.setText(
            QCoreApplication.translate("EditRenderPreset_UI", u"Placeholder",
                                       None))
        self.label_7.setText(
            QCoreApplication.translate("EditRenderPreset_UI", u"Scanning:",
                                       None))
        self.scanningCombo.setItemText(
            0,
            QCoreApplication.translate("EditRenderPreset_UI", u"Interlaced",
                                       None))
        self.scanningCombo.setItemText(
            1,
            QCoreApplication.translate("EditRenderPreset_UI", u"Progressive",
                                       None))

        self.fieldOrderLabel.setText(
            QCoreApplication.translate("EditRenderPreset_UI", u"Field Order:",
                                       None))
        self.fieldOrderCombo.setItemText(
            0,
            QCoreApplication.translate("EditRenderPreset_UI",
                                       u"Bottom Field First", None))
        self.fieldOrderCombo.setItemText(
            1,
            QCoreApplication.translate("EditRenderPreset_UI",
                                       u"Top Field First", None))

        self.colorspaceLabel.setText(
            QCoreApplication.translate("EditRenderPreset_UI", u"Colorspace:",
                                       None))
        self.label_24.setText(
            QCoreApplication.translate("EditRenderPreset_UI", u"Codec:", None))
        self.label_12.setText(
            QCoreApplication.translate("EditRenderPreset_UI", u"Rate Control:",
                                       None))
        self.default_vbitrate_label.setText(
            QCoreApplication.translate("EditRenderPreset_UI", u"Bitrate:",
                                       None))
        self.default_vbitrate.setSuffix(
            QCoreApplication.translate("EditRenderPreset_UI", u"k", None))
        self.vBuffer_label.setText(
            QCoreApplication.translate("EditRenderPreset_UI", u"Buffer Size:",
                                       None))
        self.vBuffer.setSuffix(
            QCoreApplication.translate("EditRenderPreset_UI", u" KiB", None))
        self.vquality_label.setText(
            QCoreApplication.translate("EditRenderPreset_UI", u"Quality:",
                                       None))
        #if QT_CONFIG(tooltip)
        self.label_26.setToolTip(
            QCoreApplication.translate("EditRenderPreset_UI",
                                       u"GOP = Group of Pictures", None))
        #endif // QT_CONFIG(tooltip)
        self.label_26.setText(
            QCoreApplication.translate("EditRenderPreset_UI", u"GOP:", None))
        self.gopSpinner.setSpecialValueText(
            QCoreApplication.translate("EditRenderPreset_UI", u"Auto", None))
        self.gopSpinner.setSuffix(
            QCoreApplication.translate("EditRenderPreset_UI", u" frame(s)",
                                       None))
        #if QT_CONFIG(tooltip)
        self.fixedGop.setToolTip(
            QCoreApplication.translate(
                "EditRenderPreset_UI",
                u"A fixed GOP means that keyframes will not be inserted at detected scene changes.",
                None))
        #endif // QT_CONFIG(tooltip)
        self.fixedGop.setText(
            QCoreApplication.translate("EditRenderPreset_UI", u"Fixed", None))
        self.bFramesSpinner.setSpecialValueText(
            QCoreApplication.translate("EditRenderPreset_UI", u"Auto", None))
        self.bFramesSpinner.setSuffix(
            QCoreApplication.translate("EditRenderPreset_UI", u" frame(s)",
                                       None))
        self.bFramesLabel.setText(
            QCoreApplication.translate("EditRenderPreset_UI", u"B Frames:",
                                       None))
        self.tabWidget.setTabText(
            self.tabWidget.indexOf(self.video_tab),
            QCoreApplication.translate("EditRenderPreset_UI", u"Video", None))
        self.label_15.setText(
            QCoreApplication.translate("EditRenderPreset_UI", u"Channels:",
                                       None))
        self.label_13.setText(
            QCoreApplication.translate("EditRenderPreset_UI", u"Codec:", None))
        self.label_11.setText(
            QCoreApplication.translate("EditRenderPreset_UI", u"Sample Rate:",
                                       None))
        self.audioSampleRate.setItemText(
            0, QCoreApplication.translate("EditRenderPreset_UI", u"8000",
                                          None))
        self.audioSampleRate.setItemText(
            1, QCoreApplication.translate("EditRenderPreset_UI", u"12000",
                                          None))
        self.audioSampleRate.setItemText(
            2, QCoreApplication.translate("EditRenderPreset_UI", u"16000",
                                          None))
        self.audioSampleRate.setItemText(
            3, QCoreApplication.translate("EditRenderPreset_UI", u"22050",
                                          None))
        self.audioSampleRate.setItemText(
            4, QCoreApplication.translate("EditRenderPreset_UI", u"32000",
                                          None))
        self.audioSampleRate.setItemText(
            5, QCoreApplication.translate("EditRenderPreset_UI", u"44100",
                                          None))
        self.audioSampleRate.setItemText(
            6, QCoreApplication.translate("EditRenderPreset_UI", u"48000",
                                          None))
        self.audioSampleRate.setItemText(
            7, QCoreApplication.translate("EditRenderPreset_UI", u"96000",
                                          None))

        self.label_20.setText(
            QCoreApplication.translate("EditRenderPreset_UI", u"Hz", None))
        self.label_14.setText(
            QCoreApplication.translate("EditRenderPreset_UI", u"Rate Control:",
                                       None))
        self.label_18.setText(
            QCoreApplication.translate("EditRenderPreset_UI", u"Bitrate:",
                                       None))
        self.aBitrate.setSuffix(
            QCoreApplication.translate("EditRenderPreset_UI", u"k", None))
        self.label_19.setText(
            QCoreApplication.translate("EditRenderPreset_UI", u"Quality:",
                                       None))
        self.tabWidget.setTabText(
            self.tabWidget.indexOf(self.audio_tab),
            QCoreApplication.translate("EditRenderPreset_UI", u"Audio", None))
        self.speedsLabel.setText(
            QCoreApplication.translate("EditRenderPreset_UI",
                                       u"Speed options:", None))
        #if QT_CONFIG(tooltip)
        self.speeds_list.setToolTip(
            QCoreApplication.translate(
                "EditRenderPreset_UI",
                u"One line of options per speedup step, from slowest to fastest",
                None))
        #endif // QT_CONFIG(tooltip)
        self.label.setText(
            QCoreApplication.translate("EditRenderPreset_UI",
                                       u"Additional Parameters:", None))
        self.parametersLabel.setText(
            QCoreApplication.translate(
                "EditRenderPreset_UI",
                u"<html><head/><body><p>See <a href=\"https://www.mltframework.org/plugins/ConsumerAvformat/\"><span style=\" text-decoration: underline; color:#2980b9;\">MLT documentation</span></a> for reference.</p></body></html>",
                None))
        self.tabWidget.setTabText(
            self.tabWidget.indexOf(self.tab),
            QCoreApplication.translate("EditRenderPreset_UI", u"Other", None))