class AddDialogWidget(QDialog):
    """ A dialog to add a new address to the addressbook. """
    def __init__(self, parent=None):
        super(AddDialogWidget, self).__init__(parent)

        nameLabel = QLabel("Name")
        addressLabel = QLabel("Address")
        buttonBox = QDialogButtonBox(QDialogButtonBox.Ok
                                     | QDialogButtonBox.Cancel)

        self.nameText = QLineEdit()
        self.addressText = QTextEdit()

        grid = QGridLayout()
        grid.setColumnStretch(1, 2)
        grid.addWidget(nameLabel, 0, 0)
        grid.addWidget(self.nameText, 0, 1)
        grid.addWidget(addressLabel, 1, 0, Qt.AlignLeft | Qt.AlignTop)
        grid.addWidget(self.addressText, 1, 1, Qt.AlignLeft)

        layout = QVBoxLayout()
        layout.addLayout(grid)
        layout.addWidget(buttonBox)

        self.setLayout(layout)

        self.setWindowTitle("Add a Contact")

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

    # These properties make using this dialog a little cleaner. It's much
    # nicer to type "addDialog.address" to retrieve the address as compared
    # to "addDialog.addressText.toPlainText()"
    @property
    def name(self):
        return self.nameText.text()

    @property
    def address(self):
        return self.addressText.toPlainText()
Example #2
0
    def _init_UI(self):
        self.setGeometry(300, 300, 250, 150)
        self.setWindowTitle('Example 7')


        self.label_name = QLabel("form name", self)
        self.text = QTextEdit("kek", self)

        # self.kek_btn = QLabel("kek", self)
        self.kek_btn = QPushButton("kek", self)
        self.form_name = QLineEdit(self.windowTitle(), self)


        self.layout = QFormLayout(self)
        self.layout.addRow(self.label_name, self.form_name)
        self.layout.addRow(self.kek_btn, self.text)

        self.form_name.textChanged.connect(self.set_title)
        self.kek_btn.clicked.connect(self.set_text)
        # self.layout.addWidget(self.kek_btn, 0, 0)
        # self.layout.addWidget(self.text, 0, 1)

        self.setLayout(self.layout)
        self.show()
Example #3
0
    def setupUi(self, Dialog):
        if not Dialog.objectName():
            Dialog.setObjectName(u"Dialog")
        Dialog.resize(1136, 733)
        self.formLayout = QFormLayout(Dialog)
        self.formLayout.setObjectName(u"formLayout")
        self.tableWidget = QTableWidget(Dialog)
        if (self.tableWidget.columnCount() < 4):
            self.tableWidget.setColumnCount(4)
        __qtablewidgetitem = QTableWidgetItem()
        self.tableWidget.setHorizontalHeaderItem(0, __qtablewidgetitem)
        __qtablewidgetitem1 = QTableWidgetItem()
        self.tableWidget.setHorizontalHeaderItem(1, __qtablewidgetitem1)
        __qtablewidgetitem2 = QTableWidgetItem()
        self.tableWidget.setHorizontalHeaderItem(2, __qtablewidgetitem2)
        __qtablewidgetitem3 = QTableWidgetItem()
        self.tableWidget.setHorizontalHeaderItem(3, __qtablewidgetitem3)
        self.tableWidget.setObjectName(u"tableWidget")
        self.tableWidget.setMinimumSize(QSize(0, 450))
        self.tableWidget.verticalHeader().setVisible(False)

        self.formLayout.setWidget(1, QFormLayout.SpanningRole, self.tableWidget)

        self.horizontalLayout = QHBoxLayout()
        self.horizontalLayout.setObjectName(u"horizontalLayout")
        self.textEdit = QTextEdit(Dialog)
        self.textEdit.setObjectName(u"textEdit")
        self.textEdit.setReadOnly(True)

        self.horizontalLayout.addWidget(self.textEdit)

        self.verticalLayout = QVBoxLayout()
        self.verticalLayout.setObjectName(u"verticalLayout")
        self.pushButton = QPushButton(Dialog)
        self.pushButton.setObjectName(u"pushButton")
        sizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.pushButton.sizePolicy().hasHeightForWidth())
        self.pushButton.setSizePolicy(sizePolicy)
        self.pushButton.setCursor(QCursor(Qt.PointingHandCursor))

        self.verticalLayout.addWidget(self.pushButton)

        self.pushButton_2 = QPushButton(Dialog)
        self.pushButton_2.setObjectName(u"pushButton_2")
        sizePolicy.setHeightForWidth(self.pushButton_2.sizePolicy().hasHeightForWidth())
        self.pushButton_2.setSizePolicy(sizePolicy)
        self.pushButton_2.setCursor(QCursor(Qt.PointingHandCursor))

        self.verticalLayout.addWidget(self.pushButton_2)


        self.horizontalLayout.addLayout(self.verticalLayout)


        self.formLayout.setLayout(0, QFormLayout.SpanningRole, self.horizontalLayout)

        self.buttonBox = QDialogButtonBox(Dialog)
        self.buttonBox.setObjectName(u"buttonBox")
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Ok)

        self.formLayout.setWidget(2, QFormLayout.FieldRole, self.buttonBox)


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

        QMetaObject.connectSlotsByName(Dialog)
Example #4
0
    def setupUi(self, MainWindow):
        if not MainWindow.objectName():
            MainWindow.setObjectName(u"MainWindow")
        MainWindow.resize(671, 496)
        self.help = QAction(MainWindow)
        self.help.setObjectName(u"help")
        self.centralwidget = QWidget(MainWindow)
        self.centralwidget.setObjectName(u"centralwidget")
        self.log_text = QTextEdit(self.centralwidget)
        self.log_text.setObjectName(u"log_text")
        self.log_text.setGeometry(QRect(0, 190, 671, 291))
        self.labe = QLabel(self.centralwidget)
        self.labe.setObjectName(u"labe")
        self.labe.setGeometry(QRect(30, 20, 54, 12))
        self.ssid = QLineEdit(self.centralwidget)
        self.ssid.setObjectName(u"ssid")
        self.ssid.setGeometry(QRect(70, 20, 131, 20))
        self.time = QLineEdit(self.centralwidget)
        self.time.setObjectName(u"time")
        self.time.setGeometry(QRect(540, 20, 91, 20))
        self.label_2 = QLabel(self.centralwidget)
        self.label_2.setObjectName(u"label_2")
        self.label_2.setGeometry(QRect(470, 20, 54, 12))
        self.password = QLineEdit(self.centralwidget)
        self.password.setObjectName(u"password")
        self.password.setGeometry(QRect(310, 20, 131, 20))
        self.label_3 = QLabel(self.centralwidget)
        self.label_3.setObjectName(u"label_3")
        self.label_3.setGeometry(QRect(240, 20, 54, 12))
        self.connect = QPushButton(self.centralwidget)
        self.connect.setObjectName(u"connect")
        self.connect.setGeometry(QRect(140, 60, 75, 23))
        self.disconnect = QPushButton(self.centralwidget)
        self.disconnect.setObjectName(u"disconnect")
        self.disconnect.setGeometry(QRect(250, 60, 75, 23))
        self.labe_2 = QLabel(self.centralwidget)
        self.labe_2.setObjectName(u"labe_2")
        self.labe_2.setGeometry(QRect(30, 120, 91, 16))
        self.cur_ssid = QTextEdit(self.centralwidget)
        self.cur_ssid.setObjectName(u"cur_ssid")
        self.cur_ssid.setGeometry(QRect(140, 110, 241, 31))
        self.label = QLabel(self.centralwidget)
        self.label.setObjectName(u"label")
        self.label.setGeometry(QRect(30, 160, 101, 16))
        self.interface_name = QTextEdit(self.centralwidget)
        self.interface_name.setObjectName(u"interface_name")
        self.interface_name.setGeometry(QRect(140, 150, 241, 31))
        self.label_4 = QLabel(self.centralwidget)
        self.label_4.setObjectName(u"label_4")
        self.label_4.setGeometry(QRect(450, 70, 54, 12))
        self.frequency = QLineEdit(self.centralwidget)
        self.frequency.setObjectName(u"frequency")
        self.frequency.setGeometry(QRect(540, 70, 91, 20))
        self.test = QPushButton(self.centralwidget)
        self.test.setObjectName(u"test")
        self.test.setGeometry(QRect(550, 110, 75, 23))
        self.label_5 = QLabel(self.centralwidget)
        self.label_5.setObjectName(u"label_5")
        self.label_5.setGeometry(QRect(470, 70, 61, 16))
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QMenuBar(MainWindow)
        self.menubar.setObjectName(u"menubar")
        self.menubar.setGeometry(QRect(0, 0, 671, 22))
        self.menuFile = QMenu(self.menubar)
        self.menuFile.setObjectName(u"menuFile")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QStatusBar(MainWindow)
        self.statusbar.setObjectName(u"statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.menubar.addAction(self.menuFile.menuAction())
        self.menuFile.addAction(self.help)
        self.menuFile.addSeparator()

        self.retranslateUi(MainWindow)

        QMetaObject.connectSlotsByName(MainWindow)
Example #5
0
    def setupUi(self, MainWindow):
        if not MainWindow.objectName():
            MainWindow.setObjectName(u"MainWindow")
        MainWindow.resize(400, 300)
        MainWindow.setWindowTitle(u"\u0421\u0442\u0435\u0433\u0430\u043d\u043e\u0433\u0440\u0430\u0444\u0438\u044f")
        MainWindow.setStyleSheet(u
                                "QMainWindow {\n"
                                "background-color: #f8f9fa;\n"
                                "}\n"
                                "QPushButton:hover {\n"
                                "color: rgb(70, 126, 163);\n"
                                "font: bold 11pt;\n"
                                "}\n"
                                "QPushButton {\n"
                                "color: white;\n"
                                "border:1px solid rgb(82, 108, 125);\n"
                                "border-radius: 6px;\n"
                                "background-color: rgb(82, 108, 125)\n";
                                "}")

        self.centralwidget = QWidget(MainWindow)
        self.centralwidget.setObjectName(u"centralwidget")
        self.verticalLayout = QVBoxLayout(self.centralwidget)
        self.verticalLayout.setObjectName(u"verticalLayout")
        self.horizontalLayout = QHBoxLayout()
        self.horizontalLayout.setObjectName(u"horizontalLayout")
        self.load_button = QPushButton(self.centralwidget)
        self.load_button.setObjectName(u"load_button")
        font = QFont()
        font.setPointSize(9)
        self.load_button.setFont(font)
        self.load_button.setStyleSheet(u"")
        self.load_button.setText(u"\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435")

        self.horizontalLayout.addWidget(self.load_button)

        self.save_button = QPushButton(self.centralwidget)
        self.save_button.setObjectName(u"save_button")
        self.save_button.setFont(font)
        self.save_button.setStyleSheet(u"")
        self.save_button.setText(u"\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435")

        self.horizontalLayout.addWidget(self.save_button)


        self.verticalLayout.addLayout(self.horizontalLayout)

        self.message_frame = QTextEdit(self.centralwidget)
        self.message_frame.setObjectName(u"message_frame")
        sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(1)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.message_frame.sizePolicy().hasHeightForWidth())
        self.message_frame.setSizePolicy(sizePolicy)
        font.setPointSize(10)
        self.message_frame.setFont(font)
        font.setPointSize(9)        
        self.message_frame.setStyleSheet(u"")
        self.message_frame.setFrameShape(QFrame.StyledPanel)
        self.message_frame.setMarkdown(u"")
        self.message_frame.setHtml(u"")
        self.message_frame.setPlaceholderText(u"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435")

        self.verticalLayout.addWidget(self.message_frame)

        self.output_label = QLabel(self.centralwidget)
        self.output_label.setObjectName(u"output_label")
        sizePolicy1 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        sizePolicy1.setHorizontalStretch(1)
        sizePolicy1.setVerticalStretch(0)
        sizePolicy1.setHeightForWidth(self.output_label.sizePolicy().hasHeightForWidth())
        self.output_label.setSizePolicy(sizePolicy1)
        font1 = QFont()
        self.output_label.setFont(font1)
        self.output_label.setText(u"")
        self.output_label.setScaledContents(False)
        self.output_label.setAlignment(Qt.AlignLeading|Qt.AlignLeft|Qt.AlignTop)
        self.output_label.setWordWrap(True)

        self.verticalLayout.addWidget(self.output_label)

        self.horizontalLayout_2 = QHBoxLayout()
        self.horizontalLayout_2.setObjectName(u"horizontalLayout_2")
        self.decode_button = QPushButton(self.centralwidget)
        self.decode_button.setObjectName(u"decode_button")
        palette = QPalette()
        brush = QBrush(QColor(255, 255, 255, 255))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.WindowText, brush)
        brush1 = QBrush(QColor(13, 110, 253, 255))
        brush1.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Button, brush1)
        palette.setBrush(QPalette.Active, QPalette.Text, brush)
        palette.setBrush(QPalette.Active, QPalette.ButtonText, brush)
        palette.setBrush(QPalette.Active, QPalette.Base, brush1)
        palette.setBrush(QPalette.Active, QPalette.Window, brush1)
        palette.setBrush(QPalette.Active, QPalette.PlaceholderText, brush)
        palette.setBrush(QPalette.Inactive, QPalette.WindowText, brush)
        palette.setBrush(QPalette.Inactive, QPalette.Button, brush1)
        palette.setBrush(QPalette.Inactive, QPalette.Text, brush)
        palette.setBrush(QPalette.Inactive, QPalette.ButtonText, brush)
        palette.setBrush(QPalette.Inactive, QPalette.Base, brush1)
        palette.setBrush(QPalette.Inactive, QPalette.Window, brush1)
        palette.setBrush(QPalette.Inactive, QPalette.PlaceholderText, brush)
        palette.setBrush(QPalette.Disabled, QPalette.WindowText, brush)
        palette.setBrush(QPalette.Disabled, QPalette.Button, brush1)
        palette.setBrush(QPalette.Disabled, QPalette.Text, brush)
        palette.setBrush(QPalette.Disabled, QPalette.ButtonText, brush)
        palette.setBrush(QPalette.Disabled, QPalette.Base, brush1)
        palette.setBrush(QPalette.Disabled, QPalette.Window, brush1)
        palette.setBrush(QPalette.Disabled, QPalette.PlaceholderText, brush)
        self.decode_button.setPalette(palette)
        self.decode_button.setFont(font)
        self.decode_button.setStyleSheet(u"")
        self.decode_button.setText(u"\u0414\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442")

        self.horizontalLayout_2.addWidget(self.decode_button)

        self.encode_button = QPushButton(self.centralwidget)
        self.encode_button.setObjectName(u"encode_button")
        self.encode_button.setFont(font)
        self.encode_button.setStyleSheet(u"")
        self.encode_button.setText(u"\u0417\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442")

        self.horizontalLayout_2.addWidget(self.encode_button)


        self.verticalLayout.addLayout(self.horizontalLayout_2)

        MainWindow.setCentralWidget(self.centralwidget)
        QWidget.setTabOrder(self.load_button, self.save_button)
        QWidget.setTabOrder(self.save_button, self.encode_button)
        QWidget.setTabOrder(self.encode_button, self.decode_button)

        self.retranslateUi(MainWindow)

        QMetaObject.connectSlotsByName(MainWindow)
Example #6
0
    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)
Example #7
0
    def __init__(self, parent: QWidget, model: Model) -> None:
        super().__init__(parent)

        logger.add(self.log)

        settings = QSettings()
        self.mainlayout = QVBoxLayout()
        self.mainlayout.setContentsMargins(5, 5, 5, 5)
        self.setLayout(self.mainlayout)

        # summary

        summarylayout = FlowLayout()
        summarylayout.setContentsMargins(0, 0, 0, 0)
        self.summary = QWidget()
        self.summary.setLayout(summarylayout)
        self.mainlayout.addWidget(self.summary)
        self.summary.setVisible(
            settings.value('showSummary', 'True') == 'True')

        detailslayout = QHBoxLayout()
        detailslayout.setContentsMargins(1, 0, 0, 0)
        detailslayout.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
        detailslayout.setSpacing(15)
        details = QWidget()
        details.setLayout(detailslayout)
        summarylayout.addWidget(details)

        self.modstotal = QLabel()
        detailslayout.addWidget(self.modstotal)
        self.modsenabled = QLabel()
        detailslayout.addWidget(self.modsenabled)
        self.overridden = QLabel()
        detailslayout.addWidget(self.overridden)
        self.conflicts = QLabel()
        detailslayout.addWidget(self.conflicts)

        buttonslayout = QHBoxLayout()
        buttonslayout.setContentsMargins(0, 0, 0, 0)
        buttonslayout.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
        buttons = QWidget()
        buttons.setLayout(buttonslayout)
        summarylayout.addWidget(buttons)

        self.startscriptmerger = QPushButton('Start Script Merger')
        self.startscriptmerger.setContentsMargins(0, 0, 0, 0)
        self.startscriptmerger.setMinimumWidth(140)
        self.startscriptmerger.setIcon(
            QIcon(str(getRuntimePath('resources/icons/script.ico'))))
        self.startscriptmerger.clicked.connect(lambda: [
            openExecutable(Path(str(settings.value('scriptMergerPath'))), True)
        ])
        self.startscriptmerger.setEnabled(
            verifyScriptMergerPath(
                Path(str(settings.value('scriptMergerPath')))) is not None)
        buttonslayout.addWidget(self.startscriptmerger)

        self.startgame = QPushButton('Start Game')
        self.startgame.setContentsMargins(0, 0, 0, 0)
        self.startgame.setMinimumWidth(100)
        self.startgame.setIcon(
            QIcon(str(getRuntimePath('resources/icons/w3b.ico'))))
        buttonslayout.addWidget(self.startgame)

        # splitter

        self.splitter = QSplitter(Qt.Vertical)

        self.stack = QStackedWidget()
        self.splitter.addWidget(self.stack)

        # mod list widget

        self.modlistwidget = QWidget()
        self.modlistlayout = QVBoxLayout()
        self.modlistlayout.setContentsMargins(0, 0, 0, 0)
        self.modlistwidget.setLayout(self.modlistlayout)
        self.stack.addWidget(self.modlistwidget)

        # search bar

        self.searchbar = QLineEdit()
        self.searchbar.setPlaceholderText('Search...')
        self.modlistlayout.addWidget(self.searchbar)

        # mod list

        self.modlist = ModList(self, model)
        self.modlistlayout.addWidget(self.modlist)

        self.searchbar.textChanged.connect(lambda e: self.modlist.setFilter(e))

        # welcome message

        welcomelayout = QVBoxLayout()
        welcomelayout.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        welcomewidget = QWidget()
        welcomewidget.setLayout(welcomelayout)
        welcomewidget.dragEnterEvent = self.modlist.dragEnterEvent  # type: ignore
        welcomewidget.dragMoveEvent = self.modlist.dragMoveEvent  # type: ignore
        welcomewidget.dragLeaveEvent = self.modlist.dragLeaveEvent  # type: ignore
        welcomewidget.dropEvent = self.modlist.dropEvent  # type: ignore
        welcomewidget.setAcceptDrops(True)

        icon = QIcon(str(getRuntimePath('resources/icons/open-folder.ico')))
        iconpixmap = icon.pixmap(32, 32)
        icon = QLabel()
        icon.setPixmap(iconpixmap)
        icon.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        icon.setContentsMargins(4, 4, 4, 4)
        welcomelayout.addWidget(icon)

        welcome = QLabel('''<p><font>
            No mod installed yet.
            Drag a mod into this area to get started!
            </font></p>''')
        welcome.setAttribute(Qt.WA_TransparentForMouseEvents)
        welcome.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        welcomelayout.addWidget(welcome)

        self.stack.addWidget(welcomewidget)

        # output log

        self.output = QTextEdit(self)
        self.output.setTextInteractionFlags(Qt.NoTextInteraction)
        self.output.setReadOnly(True)
        self.output.setContextMenuPolicy(Qt.NoContextMenu)
        self.output.setPlaceholderText('Program output...')
        self.splitter.addWidget(self.output)

        # TODO: enhancement: show indicator if scripts have to be merged

        self.splitter.setStretchFactor(0, 1)
        self.splitter.setStretchFactor(1, 0)
        self.mainlayout.addWidget(self.splitter)

        # TODO: incomplete: make start game button functional

        if len(model):
            self.stack.setCurrentIndex(0)
            self.splitter.setSizes([self.splitter.size().height(), 50])
        else:
            self.stack.setCurrentIndex(1)
            self.splitter.setSizes([self.splitter.size().height(), 0])
        model.updateCallbacks.append(self.modelUpdateEvent)

        asyncio.create_task(model.loadInstalled())
Example #8
0
File: edit.py Project: clpi/isutils
    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)
Example #9
0
    def __init__(self, persepolis_setting):
        super().__init__()

        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')) + '/'

        # finding windows_size
        self.setMinimumSize(QtCore.QSize(620, 300))
        self.setWindowIcon(
            QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg')))

        verticalLayout = QVBoxLayout(self)
        horizontalLayout = QHBoxLayout()
        horizontalLayout.addStretch(1)

        # text_edit
        self.text_edit = QTextEdit(self)
        self.text_edit.setReadOnly(True)

        verticalLayout.addWidget(self.text_edit)

        # clear_log_pushButton
        self.clear_log_pushButton = QPushButton(self)
        horizontalLayout.addWidget(self.clear_log_pushButton)

        # refresh_log_pushButton
        self.refresh_log_pushButton = QPushButton(self)
        self.refresh_log_pushButton.setIcon(QIcon(icons + 'refresh'))
        horizontalLayout.addWidget(self.refresh_log_pushButton)

        # report_pushButton
        self.report_pushButton = QPushButton(self)
        self.report_pushButton.setIcon(QIcon(icons + 'about'))
        horizontalLayout.addWidget(self.report_pushButton)

        self.copy_log_pushButton = QPushButton(self)

        # copy_log_pushButton
        self.copy_log_pushButton.setIcon(QIcon(icons + 'clipboard'))
        horizontalLayout.addWidget(self.copy_log_pushButton)

        # close_pushButton
        self.close_pushButton = QPushButton(self)
        self.close_pushButton.setIcon(QIcon(icons + 'remove'))
        horizontalLayout.addWidget(self.close_pushButton)

        verticalLayout.addLayout(horizontalLayout)

        # set labels

        self.setWindowTitle(
            QCoreApplication.translate("log_window_ui_tr", 'Persepolis Log'))
        self.close_pushButton.setText(
            QCoreApplication.translate("log_window_ui_tr", 'Close'))
        self.copy_log_pushButton.setText(
            QCoreApplication.translate("log_window_ui_tr",
                                       'Copy Selected to Clipboard'))
        self.report_pushButton.setText(
            QCoreApplication.translate("log_window_ui_tr", "Report Issue"))
        self.refresh_log_pushButton.setText(
            QCoreApplication.translate("log_window_ui_tr",
                                       'Refresh Log Messages'))
        self.clear_log_pushButton.setText(
            QCoreApplication.translate("log_window_ui_tr",
                                       'Clear Log Messages'))
class RenameFilesGUI(QWidget):
    def __init__(self):
        super().__init__()
        self.init_ui()

    def init_ui(self):
        self.setMinimumSize(600, 250)
        self.setWindowTitle("Change File Names GUI")
        self.directory = ""
        self.cb_value = ""
        self.setupWidgets()
        self.show()

    def setupWidgets(self):
        """
        Set up the widgets and layouts for interface.
        """
        dir_label = QLabel("Choose Directory:")
        self.dir_line_edit = QLineEdit()

        dir_button = QPushButton('...')
        dir_button.setToolTip("Select file directory.")
        dir_button.clicked.connect(self.setDirectory)

        self.change_name_edit = QLineEdit()
        self.change_name_edit.setToolTip(
            "Files will be appended with numerical values.For example: filename <b> 01 </b >.jpg")
        self.change_name_edit.setPlaceholderText("Change file names to...")

        rename_button = QPushButton("Rename Files")
        rename_button.setToolTip("Begin renaming files in directory.")
        rename_button.clicked.connect(self.renameFiles)

        file_exts = [".jpg", ".jpeg", ".png", ".gif", ".txt"]

        # Create combo box for selecting file extensions.
        ext_cb = QComboBox()
        self.cb_value = file_exts[0]
        ext_cb.setToolTip("Only files with this extension will be changed.")
        ext_cb.addItems(file_exts)
        ext_cb.currentTextChanged.connect(self.updateCbValue)

        # Text edit is for displaying the file names as they are updated.
        self.display_files_edit = QTextEdit()
        self.display_files_edit.setReadOnly(True)
        self.progress_bar = QProgressBar()
        self.progress_bar.setValue(0)

        # Set layout and widgets.
        grid = QGridLayout()
        grid.addWidget(dir_label, 0, 0)
        grid.addWidget(self.dir_line_edit, 1, 0, 1, 2)
        grid.addWidget(dir_button, 1, 2)
        grid.addWidget(self.change_name_edit, 2, 0)
        grid.addWidget(ext_cb, 2, 1)
        grid.addWidget(rename_button, 2, 2)
        grid.addWidget(self.display_files_edit, 3, 0, 1, 3)
        grid.addWidget(self.progress_bar, 4, 0, 1, 3)
        self.setLayout(grid)

    def setDirectory(self):
        """
        Choose the directory.
        """
        file_dialog = QFileDialog(self)
        file_dialog.setFileMode(QFileDialog.Directory)
        self.directory = file_dialog.getExistingDirectory(self, "Open Directory", "", QFileDialog.ShowDirsOnly)
        if self.directory:
            self.dir_line_edit.setText(self.directory)
            # Set the max value of progress bar equal to max number of  files in the directory.
            num_of_files = len([name for name in os.listdir(self.directory)])
            self.progress_bar.setRange(0, num_of_files)

    def updateCbValue(self, text):
        """
        Change the combo box value. Values represent the different file extensions.
        """
        self.cb_value = text

    def renameFiles(self):
        """
        Create instance of worker thread to handle the file renaming process.
        """
        prefix_text = self.change_name_edit.text()
        if self.directory != "" and prefix_text != "":
            self.worker = Worker(self.directory, self.cb_value, prefix_text)
            self.worker.updateValueSignal.connect(self.updateProgressBar)
            self.worker.updateTextEditSignal.connect(self.updateTextEdit)
            self.worker.start()
        else:
            pass

    def updateProgressBar(self, value):
        self.progress_bar.setValue(value)

    def updateTextEdit(self, old_text, new_text):
        self.display_files_edit.append("[INFO] {} changed to{}.".format(old_text, new_text))
Example #11
0
class ErrorWindow(QWidget):
    def __init__(self, text):
        super().__init__()
        # finding windows_size
        self.setMinimumSize(QSize(363, 300))
        self.setWindowIcon(
            QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg')))
        self.setWindowTitle('Persepolis Download Manager')

        verticalLayout = QVBoxLayout(self)
        horizontalLayout = QHBoxLayout()
        horizontalLayout.addStretch(1)

        self.text_edit = QTextEdit(self)
        self.text_edit.setReadOnly(True)
        self.text_edit.insertPlainText(text)

        verticalLayout.addWidget(self.text_edit)

        self.label2 = QLabel(self)
        self.label2.setText(
            'Reseting persepolis may solving problem.\nDo not panic!If you add your download links again,\npersepolis will resume your downloads\nPlease copy this error message and press "Report Issue" button\nand open a new issue in Github for it.\nWe answer you as soon as possible. \nreporting this issue help us to improve persepolis.\nThank you!'
        )
        verticalLayout.addWidget(self.label2)

        self.report_pushButton = QPushButton(self)
        self.report_pushButton.setText("Report Issue")
        horizontalLayout.addWidget(self.report_pushButton)

        self.reset_persepolis_pushButton = QPushButton(self)
        self.reset_persepolis_pushButton.clicked.connect(
            self.resetPushButtonPressed)
        self.reset_persepolis_pushButton.setText('Reset Persepolis')
        horizontalLayout.addWidget(self.reset_persepolis_pushButton)

        self.close_pushButton = QPushButton(self)
        self.close_pushButton.setText('close')
        horizontalLayout.addWidget(self.close_pushButton)

        verticalLayout.addLayout(horizontalLayout)

        self.report_pushButton.clicked.connect(self.reportPushButtonPressed)
        self.close_pushButton.clicked.connect(self.closePushButtonPressed)

    def reportPushButtonPressed(self, button):
        osCommands.xdgOpen('https://github.com/persepolisdm/persepolis/issues')

    # close window with ESC key
    def keyPressEvent(self, event):
        if event.key() == Qt.Key_Escape:
            self.close()

    def closePushButtonPressed(self, button):
        self.close()

    def resetPushButtonPressed(self, button):
        # create an object for PersepolisDB
        persepolis_db = PersepolisDB()

        # Reset data base
        persepolis_db.resetDataBase()

        # close connections
        persepolis_db.closeConnections()

        # Reset persepolis_setting
        persepolis_setting = QSettings('persepolis_download_manager',
                                       'persepolis')
        persepolis_setting.clear()
        persepolis_setting.sync()
Example #12
0
class Window(QDialog):
    def __init__(self, parent=None):
        super(Window, self).__init__(parent)

        self.iconGroupBox = QGroupBox()
        self.iconLabel = QLabel()
        self.iconComboBox = QComboBox()
        self.showIconCheckBox = QCheckBox()

        self.messageGroupBox = QGroupBox()
        self.typeLabel = QLabel()
        self.durationLabel = QLabel()
        self.durationWarningLabel = QLabel()
        self.titleLabel = QLabel()
        self.bodyLabel = QLabel()

        self.typeComboBox = QComboBox()
        self.durationSpinBox = QSpinBox()
        self.titleEdit = QLineEdit()
        self.bodyEdit = QTextEdit()
        self.showMessageButton = QPushButton()

        self.minimizeAction = QAction()
        self.maximizeAction = QAction()
        self.restoreAction = QAction()
        self.quitAction = QAction()

        self.trayIcon = QSystemTrayIcon()
        self.trayIconMenu = QMenu()

        self.createIconGroupBox()
        self.createMessageGroupBox()

        self.iconLabel.setMinimumWidth(self.durationLabel.sizeHint().width())

        self.createActions()
        self.createTrayIcon()

        self.showMessageButton.clicked.connect(self.showMessage)
        self.showIconCheckBox.toggled.connect(self.trayIcon.setVisible)
        self.iconComboBox.currentIndexChanged.connect(self.setIcon)
        self.trayIcon.messageClicked.connect(self.messageClicked)
        self.trayIcon.activated.connect(self.iconActivated)

        self.mainLayout = QVBoxLayout()
        self.mainLayout.addWidget(self.iconGroupBox)
        self.mainLayout.addWidget(self.messageGroupBox)
        self.setLayout(self.mainLayout)

        self.iconComboBox.setCurrentIndex(1)
        self.trayIcon.show()

        self.setWindowTitle("Systray")
        self.resize(400, 300)

    def setVisible(self, visible):
        self.minimizeAction.setEnabled(visible)
        self.maximizeAction.setEnabled(not self.isMaximized())
        self.restoreAction.setEnabled(self.isMaximized() or not visible)
        super().setVisible(visible)

    def closeEvent(self, event):
        if not event.spontaneous() or not self.isVisible():
            return
        if self.trayIcon.isVisible():
            QMessageBox.information(
                self, "Systray",
                "The program will keep running in the system tray. "
                "To terminate the program, choose <b>Quit</b> in the context "
                "menu of the system tray entry.")
            self.hide()
            event.ignore()

    @Slot(int)
    def setIcon(self, index):
        icon = self.iconComboBox.itemIcon(index)
        self.trayIcon.setIcon(icon)
        self.setWindowIcon(icon)
        self.trayIcon.setToolTip(self.iconComboBox.itemText(index))

    @Slot(str)
    def iconActivated(self, reason):
        if reason == QSystemTrayIcon.Trigger:
            pass
        if reason == QSystemTrayIcon.DoubleClick:
            self.iconComboBox.setCurrentIndex(
                (self.iconComboBox.currentIndex() + 1) %
                self.iconComboBox.count())
        if reason == QSystemTrayIcon.MiddleClick:
            self.showMessage()

    @Slot()
    def showMessage(self):
        self.showIconCheckBox.setChecked(True)
        selectedIcon = self.typeComboBox.itemData(
            self.typeComboBox.currentIndex())
        msgIcon = QSystemTrayIcon.MessageIcon(selectedIcon)

        if selectedIcon == -1:  # custom icon
            icon = QIcon(
                self.iconComboBox.itemIcon(self.iconComboBox.currentIndex()))
            self.trayIcon.showMessage(
                self.titleEdit.text(),
                self.bodyEdit.toPlainText(),
                icon,
                self.durationSpinBox.value() * 1000,
            )
        else:
            self.trayIcon.showMessage(
                self.titleEdit.text(),
                self.bodyEdit.toPlainText(),
                msgIcon,
                self.durationSpinBox.value() * 1000,
            )

    @Slot()
    def messageClicked(self):
        QMessageBox.information(
            None, "Systray", "Sorry, I already gave what help I could.\n"
            "Maybe you should try asking a human?")

    def createIconGroupBox(self):
        self.iconGroupBox = QGroupBox("Tray Icon")

        self.iconLabel = QLabel("Icon:")

        self.iconComboBox = QComboBox()
        self.iconComboBox.addItem(QIcon(":/images/bad.png"), "Bad")
        self.iconComboBox.addItem(QIcon(":/images/heart.png"), "Heart")
        self.iconComboBox.addItem(QIcon(":/images/trash.png"), "Trash")

        self.showIconCheckBox = QCheckBox("Show icon")
        self.showIconCheckBox.setChecked(True)

        iconLayout = QHBoxLayout()
        iconLayout.addWidget(self.iconLabel)
        iconLayout.addWidget(self.iconComboBox)
        iconLayout.addStretch()
        iconLayout.addWidget(self.showIconCheckBox)
        self.iconGroupBox.setLayout(iconLayout)

    def createMessageGroupBox(self):
        self.messageGroupBox = QGroupBox("Balloon Message")

        self.typeLabel = QLabel("Type:")

        self.typeComboBox = QComboBox()
        self.typeComboBox.addItem("None", QSystemTrayIcon.NoIcon)
        self.typeComboBox.addItem(
            self.style().standardIcon(QStyle.SP_MessageBoxInformation),
            "Information",
            QSystemTrayIcon.Information,
        )
        self.typeComboBox.addItem(
            self.style().standardIcon(QStyle.SP_MessageBoxWarning),
            "Warning",
            QSystemTrayIcon.Warning,
        )
        self.typeComboBox.addItem(
            self.style().standardIcon(QStyle.SP_MessageBoxCritical),
            "Critical",
            QSystemTrayIcon.Critical,
        )
        self.typeComboBox.addItem(QIcon(), "Custom icon", -1)
        self.typeComboBox.setCurrentIndex(1)

        self.durationLabel = QLabel("Duration:")

        self.durationSpinBox = QSpinBox()
        self.durationSpinBox.setRange(5, 60)
        self.durationSpinBox.setSuffix(" s")
        self.durationSpinBox.setValue(15)

        self.durationWarningLabel = QLabel(
            "(some systems might ignore this hint)")
        self.durationWarningLabel.setIndent(10)

        self.titleLabel = QLabel("Title:")
        self.titleEdit = QLineEdit("Cannot connect to network")
        self.bodyLabel = QLabel("Body:")

        self.bodyEdit = QTextEdit()
        self.bodyEdit.setPlainText(
            "Don't believe me. Honestly, I don't have a clue."
            "\nClick this balloon for details.")

        self.showMessageButton = QPushButton("Show Message")
        self.showMessageButton.setDefault(True)

        messageLayout = QGridLayout()
        messageLayout.addWidget(self.typeLabel, 0, 0)
        messageLayout.addWidget(self.typeComboBox, 0, 1, 1, 2)
        messageLayout.addWidget(self.durationLabel, 1, 0)
        messageLayout.addWidget(self.durationSpinBox, 1, 1)
        messageLayout.addWidget(self.durationWarningLabel, 1, 2, 1, 3)
        messageLayout.addWidget(self.titleLabel, 2, 0)
        messageLayout.addWidget(self.titleEdit, 2, 1, 1, 4)
        messageLayout.addWidget(self.bodyLabel, 3, 0)
        messageLayout.addWidget(self.bodyEdit, 3, 1, 2, 4)
        messageLayout.addWidget(self.showMessageButton, 5, 4)
        messageLayout.setColumnStretch(3, 1)
        messageLayout.setRowStretch(4, 1)
        self.messageGroupBox.setLayout(messageLayout)

    def createActions(self):
        self.minimizeAction = QAction("Minimize", self)
        self.minimizeAction.triggered.connect(self.hide)

        self.maximizeAction = QAction("Maximize", self)
        self.maximizeAction.triggered.connect(self.showMaximized)

        self.restoreAction = QAction("Restore", self)
        self.restoreAction.triggered.connect(self.showNormal)

        self.quitAction = QAction("Quit", self)
        self.quitAction.triggered.connect(qApp.quit)

    def createTrayIcon(self):
        self.trayIconMenu = QMenu(self)
        self.trayIconMenu.addAction(self.minimizeAction)
        self.trayIconMenu.addAction(self.maximizeAction)
        self.trayIconMenu.addAction(self.restoreAction)
        self.trayIconMenu.addSeparator()
        self.trayIconMenu.addAction(self.quitAction)

        self.trayIcon = QSystemTrayIcon(self)
        self.trayIcon.setContextMenu(self.trayIconMenu)
Example #13
0
    def createMessageGroupBox(self):
        self.messageGroupBox = QGroupBox("Balloon Message")

        self.typeLabel = QLabel("Type:")

        self.typeComboBox = QComboBox()
        self.typeComboBox.addItem("None", QSystemTrayIcon.NoIcon)
        self.typeComboBox.addItem(
            self.style().standardIcon(QStyle.SP_MessageBoxInformation),
            "Information",
            QSystemTrayIcon.Information,
        )
        self.typeComboBox.addItem(
            self.style().standardIcon(QStyle.SP_MessageBoxWarning),
            "Warning",
            QSystemTrayIcon.Warning,
        )
        self.typeComboBox.addItem(
            self.style().standardIcon(QStyle.SP_MessageBoxCritical),
            "Critical",
            QSystemTrayIcon.Critical,
        )
        self.typeComboBox.addItem(QIcon(), "Custom icon", -1)
        self.typeComboBox.setCurrentIndex(1)

        self.durationLabel = QLabel("Duration:")

        self.durationSpinBox = QSpinBox()
        self.durationSpinBox.setRange(5, 60)
        self.durationSpinBox.setSuffix(" s")
        self.durationSpinBox.setValue(15)

        self.durationWarningLabel = QLabel(
            "(some systems might ignore this hint)")
        self.durationWarningLabel.setIndent(10)

        self.titleLabel = QLabel("Title:")
        self.titleEdit = QLineEdit("Cannot connect to network")
        self.bodyLabel = QLabel("Body:")

        self.bodyEdit = QTextEdit()
        self.bodyEdit.setPlainText(
            "Don't believe me. Honestly, I don't have a clue."
            "\nClick this balloon for details.")

        self.showMessageButton = QPushButton("Show Message")
        self.showMessageButton.setDefault(True)

        messageLayout = QGridLayout()
        messageLayout.addWidget(self.typeLabel, 0, 0)
        messageLayout.addWidget(self.typeComboBox, 0, 1, 1, 2)
        messageLayout.addWidget(self.durationLabel, 1, 0)
        messageLayout.addWidget(self.durationSpinBox, 1, 1)
        messageLayout.addWidget(self.durationWarningLabel, 1, 2, 1, 3)
        messageLayout.addWidget(self.titleLabel, 2, 0)
        messageLayout.addWidget(self.titleEdit, 2, 1, 1, 4)
        messageLayout.addWidget(self.bodyLabel, 3, 0)
        messageLayout.addWidget(self.bodyEdit, 3, 1, 2, 4)
        messageLayout.addWidget(self.showMessageButton, 5, 4)
        messageLayout.setColumnStretch(3, 1)
        messageLayout.setRowStretch(4, 1)
        self.messageGroupBox.setLayout(messageLayout)
Example #14
0
    def __init__(self, persepolis_setting):
        super().__init__()

        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.setMinimumSize(QSize(545, 375))
        self.setWindowIcon(QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg')))

        verticalLayout = QVBoxLayout(self)

        self.about_tabWidget = QTabWidget(self)

        # about tab
        self.about_tab = QWidget(self)

        about_tab_horizontalLayout = QHBoxLayout(self.about_tab)

        about_tab_verticalLayout = QVBoxLayout()

        # persepolis icon
        if qtsvg_available:
            persepolis_icon_verticalLayout = QVBoxLayout()
            self.persepolis_icon = QtSvgWidget.QSvgWidget(':/persepolis.svg')
            self.persepolis_icon.setFixedSize(QSize(64, 64))

            persepolis_icon_verticalLayout.addWidget(self.persepolis_icon)
            persepolis_icon_verticalLayout.addStretch(1)

            about_tab_horizontalLayout.addLayout(persepolis_icon_verticalLayout)

        self.title_label = QLabel(self.about_tab)
        font = QFont()
        font.setBold(True)
        font.setWeight(QFont.Weight.Bold)
        self.title_label.setFont(font)
        self.title_label.setAlignment(Qt.AlignCenter)
        about_tab_verticalLayout.addWidget(self.title_label)

        self.version_label = QLabel(self.about_tab)
        self.version_label.setAlignment(Qt.AlignCenter)

        about_tab_verticalLayout.addWidget(self.version_label)

        self.site2_label = QLabel(self.about_tab)
        self.site2_label.setTextFormat(Qt.RichText)
        self.site2_label.setAlignment(Qt.AlignCenter)
        self.site2_label.setOpenExternalLinks(True)
        self.site2_label.setTextInteractionFlags(
            Qt.TextBrowserInteraction)
        about_tab_verticalLayout.addWidget(self.site2_label)

        self.telegram_label = QLabel(self.about_tab)
        self.telegram_label.setTextFormat(Qt.RichText)
        self.telegram_label.setAlignment(Qt.AlignCenter)
        self.telegram_label.setOpenExternalLinks(True)
        self.telegram_label.setTextInteractionFlags(
            Qt.TextBrowserInteraction)
        about_tab_verticalLayout.addWidget(self.telegram_label)

        self.twitter_label = QLabel(self.about_tab)
        self.twitter_label.setTextFormat(Qt.RichText)
        self.twitter_label.setAlignment(Qt.AlignCenter)
        self.twitter_label.setOpenExternalLinks(True)
        self.twitter_label.setTextInteractionFlags(
            Qt.TextBrowserInteraction)
        about_tab_verticalLayout.addWidget(self.twitter_label)

        about_tab_verticalLayout.addStretch(1)

        about_tab_horizontalLayout.addLayout(about_tab_verticalLayout)

        # developers_tab
        # developers
        self.developers_tab = QWidget(self)
        developers_verticalLayout = QVBoxLayout(self.developers_tab)

        self.developers_title_label = QLabel(self.developers_tab)
        font.setBold(True)
        font.setWeight(QFont.Weight.Bold)
        self.developers_title_label.setFont(font)
        self.developers_title_label.setAlignment(Qt.AlignCenter)
        developers_verticalLayout.addWidget(self.developers_title_label)

        self.name_label = QLabel(self.developers_tab)
        self.name_label.setAlignment(Qt.AlignCenter)

        developers_verticalLayout.addWidget(self.name_label)

        # contributors
        self.contributors_thank_label = QLabel(self.developers_tab)
        self.contributors_thank_label.setFont(font)
        self.contributors_thank_label.setAlignment(Qt.AlignCenter)

        developers_verticalLayout.addWidget(self.contributors_thank_label)

        self.contributors_link_label = QLabel(self.developers_tab)
        self.contributors_link_label.setTextFormat(Qt.RichText)
        self.contributors_link_label.setAlignment(Qt.AlignCenter)
        self.contributors_link_label.setOpenExternalLinks(True)
        self.contributors_link_label.setTextInteractionFlags(
            Qt.TextBrowserInteraction)
        developers_verticalLayout.addWidget(self.contributors_link_label)

        developers_verticalLayout.addStretch(1)

        # translators tab
        self.translators_tab = QWidget(self)
        translators_tab_verticalLayout = QVBoxLayout(self.translators_tab)

        # translators
        self.translators_textEdit = QTextEdit(self.translators_tab)
        self.translators_textEdit.setReadOnly(True)
        translators_tab_verticalLayout.addWidget(self.translators_textEdit)

        # License tab
        self.license_tab = QWidget(self)
        license_tab_verticalLayout = QVBoxLayout(self.license_tab)

        self.license_text = QTextEdit(self.license_tab)
        self.license_text.setReadOnly(True)

        license_tab_verticalLayout.addWidget(self.license_text)

        verticalLayout.addWidget(self.about_tabWidget)

        # buttons
        button_horizontalLayout = QHBoxLayout()
        button_horizontalLayout.addStretch(1)

        self.pushButton = QPushButton(self)
        self.pushButton.setIcon(QIcon(icons + 'ok'))
        self.pushButton.clicked.connect(self.close)

        button_horizontalLayout.addWidget(self.pushButton)

        verticalLayout.addLayout(button_horizontalLayout)

        self.setWindowTitle(QCoreApplication.translate("about_ui_tr", "About Persepolis"))

        # about_tab
        self.title_label.setText(QCoreApplication.translate("about_ui_tr", "Persepolis Download Manager"))
        self.version_label.setText(QCoreApplication.translate("about_ui_tr", "Version 3.2.0"))
        self.site2_label.setText(QCoreApplication.translate("about_ui_tr",
                                                            "<a href=https://persepolisdm.github.io>https://persepolisdm.github.io</a>",
                                                            "TRANSLATORS NOTE: YOU REALLY DON'T NEED TO TRANSLATE THIS PART!"))

        self.telegram_label.setText(QCoreApplication.translate("about_ui_tr",
                                                               "<a href=https://telegram.me/persepolisdm>https://telegram.me/persepolisdm</a>",
                                                               "TRANSLATORS NOTE: YOU REALLY DON'T NEED TO TRANSLATE THIS PART!"))

        self.twitter_label.setText(QCoreApplication.translate("about_ui_tr",
                                                              "<a href=https://twitter.com/persepolisdm>https://twitter.com/persepolisdm</a>",
                                                              "TRANSLATORS NOTE: YOU REALLY DON'T NEED TO TRANSLATE THIS PART!"))

        # developers_tab
        self.developers_title_label.setText(QCoreApplication.translate('about_ui_tr', 'Developers:'))

        self.name_label.setText(QCoreApplication.translate("about_ui_tr",
                                                           "\nAliReza AmirSamimi\nMohammadreza Abdollahzadeh\nSadegh Alirezaie\nMostafa Asadi\nMohammadAmin Vahedinia\nJafar Akhondali\nH.Rostami\nEhsan Titish",
                                                           "TRANSLATORS NOTE: YOU REALLY DON'T NEED TO TRANSLATE THIS PART!"))

        self.contributors_thank_label.setText(QCoreApplication.translate('about_ui_tr', 'Special thanks to:'))
        self.contributors_link_label.setText(
            "<a href=https://github.com/persepolisdm/persepolis/graphs/contributors>our contributors</a>")

        # License
        self.license_text.setPlainText("""
            This program is free software: you can redistribute it and/or modify
            it under the terms of the GNU General Public License as published by
            the Free Software Foundation, either version 3 of the License, or
            (at your option) any later version.

            This program is distributed in the hope that it will be useful,
            but WITHOUT ANY WARRANTY; without even the implied warranty of
            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
            GNU General Public License for more details.

            You should have received a copy of the GNU General Public License
            along with this program.  If not, see http://www.gnu.org/licenses/.
            """)

        # tabs
        self.about_tabWidget.addTab(self.about_tab, QCoreApplication.translate("about_ui_tr", "About Persepolis"))
        self.about_tabWidget.addTab(self.developers_tab, QCoreApplication.translate("about_ui_tr", "Developers"))
        self.about_tabWidget.addTab(self.translators_tab, QCoreApplication.translate("about_ui_tr", "Translators"))
        self.about_tabWidget.addTab(self.license_tab, QCoreApplication.translate("about_ui_tr", "License"))

        # button
        self.pushButton.setText(QCoreApplication.translate("about_ui_tr", "OK"))
Example #15
0
class SecondWidget1(QtWidgets.QWidget):
    def __init__(self, parent=None):
        super().__init__(parent=parent)

        layout = QtWidgets.QVBoxLayout(self)
        label1 = QLabel('입력', self)
        label1.setAlignment(Qt.AlignVCenter)
        label1.move(200, 30)

        label2 = QLabel('결과', self)
        label2.setAlignment(Qt.AlignVCenter)
        label2.move(710, 30)

        self.text_box1 = QTextEdit(self)
        self.text_box1.resize(350, 350)
        self.text_box1.move(50, 60)

        self.text_box2 = QTextBrowser(self)
        self.text_box2.append('')
        self.text_box2.setGeometry(550, 60, 350, 350) 

        self.ok_base64 = QPushButton("OK", self)	
        self.ok_base64.setGeometry(50, 420, 850, 45) 
        self.ok_base64.clicked.connect(self.base64_conversion)

        self.back = QPushButton(self)
        self.back.setStyleSheet(
            '''
            QPushButton{image:url(./img/back_img.png); border:0px;}
            QPushButton:hover{image:url(./img/back_img_ev_1.png); border:0px;}
            ''') 
        self.back.setGeometry(0, 0, 50, 50) 
        self.back.clicked.connect(self.change_stack1)

    def base64_conversion(self):
        '''
        QTextEdit 사용 경우 .toPlainText() 사용 바람
        https://doc.qt.io/qt-5/qplaintextedit.html#plainText-prop 참조
        '''
        # print(self.text_box1.toPlainText())

        # Base64 변환 과정
        inpututf = self.text_box1.toPlainText().encode('utf-8') # ascii 사용시 오류발생 utf-8으로 사용하세요
        finalvalue = base64.b64encode(inpututf)
        print(finalvalue)

        '''
        내용 수정또는 추가시 내용 초기화
        https://study-code.gitbook.io/python-basic/qtpy/pyqt-widget/application-make/widget-2#undefined-1 참조
        '''
        self.text_box2.clear()
        self.text_box2.repaint()

        '''
        "b"와 따옴표없이 출력 .decode("utf-8")
        https://stackoverflow.com/a/45151048 참조
        '''
        self.text_box2.append(str(finalvalue.decode("utf-8")))

        
    def change_stack(self):
        self.parent().stack.setCurrentIndex(0)

    def change_stack1(self):
        self.parent().stack.setCurrentIndex(1)
Example #16
0
class NovoCliente(QWidget):
    status_signal = Signal(str)

    def __init__(self):
        self.db = ClientesDB()
        QWidget.__init__(self)
        font = QFont()
        font.setBold(True)  # Labels em Negrito

        # Labels:
        self.label_title = QLabel("Novo Cliente")
        self.label_title.setFont(font)
        self.label_nome = QLabel("Nome Completo:")
        self.label_nome.setFont(font)
        self.label_endereco = QLabel("Endereço:")
        self.label_endereco.setFont(font)
        self.label_numero = QLabel("Número:")
        self.label_numero.setFont(font)
        self.label_cpf = QLabel("CPF:")
        self.label_cpf.setFont(font)

        # Entries:
        self.entry_nome = QLineEdit()
        self.entry_endereco = QTextEdit()
        self.entry_numero = QLineEdit()
        self.entry_cpf = QLineEdit()

        # Botões;
        self.button_salvar = QPushButton("&Salvar")
        self.button_salvar.clicked.connect(self.salvar_cliente)
        self.button_salvar.setShortcut("Ctrl+S")
        self.button_cancelar = QPushButton("Cancelar")
        self.button_cancelar.clicked.connect(self.limpar)
        self.button_cancelar.setShortcut("ESC")

        # Linha
        self.line = QFrame()
        self.line.setFrameShape(QFrame.HLine)
        self.line.setFrameShadow(QFrame.Sunken)
        self.line.setLineWidth(0)
        self.line.setMidLineWidth(1)

        # Leiaute:
        self.layout = QVBoxLayout()
        self.layout_buttons = QHBoxLayout()
        self.layout.addWidget(self.label_title)
        self.layout.addWidget(self.line)
        self.layout.addWidget(self.label_nome)
        self.layout.addWidget(self.entry_nome)
        self.layout.addWidget(self.label_numero)
        self.layout.addWidget(self.entry_numero)
        self.layout.addWidget(self.label_cpf)
        self.layout.addWidget(self.entry_cpf)
        self.layout.addWidget(self.label_endereco)
        self.layout.addWidget(self.entry_endereco)
        self.layout_buttons.addWidget(self.button_salvar)
        self.layout_buttons.addWidget(self.button_cancelar)
        self.layout.addStretch(2)
        self.layout.addLayout(self.layout_buttons)
        self.setLayout(self.layout)

    @Slot()
    def salvar_cliente(self):
        nome = self.entry_nome.text()
        cpf = self.entry_cpf.text()
        numero = self.entry_numero.text()
        endereco = self.entry_endereco.toPlainText()
        data = {
            'nome': nome,
            'cpf': cpf,
            'numero': numero,
            'endereco': endereco
        }
        try:
            self.db.novo_cliente(data)
            self.status_signal.emit("Salvo")
            self.limpar()
        except ValueError as e:
            popup = QMessageBox(QMessageBox.Critical, "Erro", "Campo Inválido")
            popup.setInformativeText(str(e))
            popup.addButton(QMessageBox.Ok)
            popup.exec()

    @Slot()
    def limpar(self):
        self.entry_nome.setText('')
        self.entry_endereco.setText('')
        self.entry_numero.setText('')
        self.entry_cpf.setText('')
Example #17
0
class MainWindow(QMainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()

        self.textEdit = QTextEdit()
        self.setCentralWidget(self.textEdit)

        self.createActions()
        self.createMenus()
        self.createToolBars()
        self.createStatusBar()
        self.createDockWindows()

        self.setWindowTitle("Dock Widgets")

        self.newLetter()

    def newLetter(self):
        self.textEdit.clear()

        cursor = self.textEdit.textCursor()
        cursor.movePosition(QTextCursor.Start)
        topFrame = cursor.currentFrame()
        topFrameFormat = topFrame.frameFormat()
        topFrameFormat.setPadding(16)
        topFrame.setFrameFormat(topFrameFormat)

        textFormat = QTextCharFormat()
        boldFormat = QTextCharFormat()
        boldFormat.setFontWeight(QFont.Bold)
        italicFormat = QTextCharFormat()
        italicFormat.setFontItalic(True)

        tableFormat = QTextTableFormat()
        tableFormat.setBorder(1)
        tableFormat.setCellPadding(16)
        tableFormat.setAlignment(Qt.AlignRight)
        cursor.insertTable(1, 1, tableFormat)
        cursor.insertText("The Firm", boldFormat)
        cursor.insertBlock()
        cursor.insertText("321 City Street", textFormat)
        cursor.insertBlock()
        cursor.insertText("Industry Park")
        cursor.insertBlock()
        cursor.insertText("Some Country")
        cursor.setPosition(topFrame.lastPosition())
        cursor.insertText(QDate.currentDate().toString("d MMMM yyyy"),
                          textFormat)
        cursor.insertBlock()
        cursor.insertBlock()
        cursor.insertText("Dear ", textFormat)
        cursor.insertText("NAME", italicFormat)
        cursor.insertText(",", textFormat)
        for i in range(3):
            cursor.insertBlock()
        cursor.insertText("Yours sincerely,", textFormat)
        for i in range(3):
            cursor.insertBlock()
        cursor.insertText("The Boss", textFormat)
        cursor.insertBlock()
        cursor.insertText("ADDRESS", italicFormat)

    def print_(self):
        document = self.textEdit.document()
        printer = QPrinter()

        dlg = QPrintDialog(printer, self)
        if dlg.exec_() != QDialog.Accepted:
            return

        document.print_(printer)

        self.statusBar().showMessage("Ready", 2000)

    def save(self):
        filename, _ = QFileDialog.getSaveFileName(self, "Choose a file name",
                                                  '.', "HTML (*.html *.htm)")
        if not filename:
            return

        file = QFile(filename)
        if not file.open(QFile.WriteOnly | QFile.Text):
            QMessageBox.warning(
                self, "Dock Widgets",
                "Cannot write file %s:\n%s." % (filename, file.errorString()))
            return

        out = QTextStream(file)
        QApplication.setOverrideCursor(Qt.WaitCursor)
        out << self.textEdit.toHtml()
        QApplication.restoreOverrideCursor()

        self.statusBar().showMessage("Saved '%s'" % filename, 2000)

    def undo(self):
        document = self.textEdit.document()
        document.undo()

    def insertCustomer(self, customer):
        if not customer:
            return
        customerList = customer.split(', ')
        document = self.textEdit.document()
        cursor = document.find('NAME')
        if not cursor.isNull():
            cursor.beginEditBlock()
            cursor.insertText(customerList[0])
            oldcursor = cursor
            cursor = document.find('ADDRESS')
            if not cursor.isNull():
                for i in customerList[1:]:
                    cursor.insertBlock()
                    cursor.insertText(i)
                cursor.endEditBlock()
            else:
                oldcursor.endEditBlock()

    def addParagraph(self, paragraph):
        if not paragraph:
            return
        document = self.textEdit.document()
        cursor = document.find("Yours sincerely,")
        if cursor.isNull():
            return
        cursor.beginEditBlock()
        cursor.movePosition(QTextCursor.PreviousBlock, QTextCursor.MoveAnchor,
                            2)
        cursor.insertBlock()
        cursor.insertText(paragraph)
        cursor.insertBlock()
        cursor.endEditBlock()

    def about(self):
        QMessageBox.about(
            self, "About Dock Widgets",
            "The <b>Dock Widgets</b> example demonstrates how to use "
            "Qt's dock widgets. You can enter your own text, click a "
            "customer to add a customer name and address, and click "
            "standard paragraphs to add them.")

    def createActions(self):
        self.newLetterAct = QAction(QIcon.fromTheme('document-new',
                                                    QIcon(':/images/new.png')),
                                    "&New Letter",
                                    self,
                                    shortcut=QKeySequence.New,
                                    statusTip="Create a new form letter",
                                    triggered=self.newLetter)

        self.saveAct = QAction(QIcon.fromTheme('document-save',
                                               QIcon(':/images/save.png')),
                               "&Save...",
                               self,
                               shortcut=QKeySequence.Save,
                               statusTip="Save the current form letter",
                               triggered=self.save)

        self.printAct = QAction(QIcon.fromTheme('document-print',
                                                QIcon(':/images/print.png')),
                                "&Print...",
                                self,
                                shortcut=QKeySequence.Print,
                                statusTip="Print the current form letter",
                                triggered=self.print_)

        self.undoAct = QAction(QIcon.fromTheme('edit-undo',
                                               QIcon(':/images/undo.png')),
                               "&Undo",
                               self,
                               shortcut=QKeySequence.Undo,
                               statusTip="Undo the last editing action",
                               triggered=self.undo)

        self.quitAct = QAction("&Quit",
                               self,
                               shortcut="Ctrl+Q",
                               statusTip="Quit the application",
                               triggered=self.close)

        self.aboutAct = QAction("&About",
                                self,
                                statusTip="Show the application's About box",
                                triggered=self.about)

        self.aboutQtAct = QAction("About &Qt",
                                  self,
                                  statusTip="Show the Qt library's About box",
                                  triggered=QApplication.instance().aboutQt)

    def createMenus(self):
        self.fileMenu = self.menuBar().addMenu("&File")
        self.fileMenu.addAction(self.newLetterAct)
        self.fileMenu.addAction(self.saveAct)
        self.fileMenu.addAction(self.printAct)
        self.fileMenu.addSeparator()
        self.fileMenu.addAction(self.quitAct)

        self.editMenu = self.menuBar().addMenu("&Edit")
        self.editMenu.addAction(self.undoAct)

        self.viewMenu = self.menuBar().addMenu("&View")

        self.menuBar().addSeparator()

        self.helpMenu = self.menuBar().addMenu("&Help")
        self.helpMenu.addAction(self.aboutAct)
        self.helpMenu.addAction(self.aboutQtAct)

    def createToolBars(self):
        self.fileToolBar = self.addToolBar("File")
        self.fileToolBar.addAction(self.newLetterAct)
        self.fileToolBar.addAction(self.saveAct)
        self.fileToolBar.addAction(self.printAct)

        self.editToolBar = self.addToolBar("Edit")
        self.editToolBar.addAction(self.undoAct)

    def createStatusBar(self):
        self.statusBar().showMessage("Ready")

    def createDockWindows(self):
        dock = QDockWidget("Customers", self)
        dock.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
        self.customerList = QListWidget(dock)
        self.customerList.addItems(
            ("John Doe, Harmony Enterprises, 12 Lakeside, Ambleton",
             "Jane Doe, Memorabilia, 23 Watersedge, Beaton",
             "Tammy Shea, Tiblanka, 38 Sea Views, Carlton",
             "Tim Sheen, Caraba Gifts, 48 Ocean Way, Deal",
             "Sol Harvey, Chicos Coffee, 53 New Springs, Eccleston",
             "Sally Hobart, Tiroli Tea, 67 Long River, Fedula"))
        dock.setWidget(self.customerList)
        self.addDockWidget(Qt.RightDockWidgetArea, dock)
        self.viewMenu.addAction(dock.toggleViewAction())

        dock = QDockWidget("Paragraphs", self)
        self.paragraphsList = QListWidget(dock)
        self.paragraphsList.addItems(
            ("Thank you for your payment which we have received today.",
             "Your order has been dispatched and should be with you within "
             "28 days.",
             "We have dispatched those items that were in stock. The rest of "
             "your order will be dispatched once all the remaining items "
             "have arrived at our warehouse. No additional shipping "
             "charges will be made.",
             "You made a small overpayment (less than $5) which we will keep "
             "on account for you, or return at your request.",
             "You made a small underpayment (less than $1), but we have sent "
             "your order anyway. We'll add this underpayment to your next "
             "bill.",
             "Unfortunately you did not send enough money. Please remit an "
             "additional $. Your order will be dispatched as soon as the "
             "complete amount has been received.",
             "You made an overpayment (more than $5). Do you wish to buy more "
             "items, or should we return the excess to you?"))
        dock.setWidget(self.paragraphsList)
        self.addDockWidget(Qt.RightDockWidgetArea, dock)
        self.viewMenu.addAction(dock.toggleViewAction())

        self.customerList.currentTextChanged.connect(self.insertCustomer)
        self.paragraphsList.currentTextChanged.connect(self.addParagraph)
Example #18
0
class BuilderWidget(QWidget):
    def __init__(self, parent=None) -> None:
        super().__init__(parent)

        self.verticalLayout = QVBoxLayout(self)

        self.compileButton = QPushButton('Compile', self)
        self.compileButton.setMinimumSize(QSize(200, 50))
        self.verticalLayout.addWidget(self.compileButton, 0, Qt.AlignHCenter)

        self.tidyButton = QPushButton('Tidy', self)
        self.verticalLayout.addWidget(self.tidyButton, 0, Qt.AlignHCenter)

        self.splitter = QSplitter(self)
        self.splitter.setOrientation(Qt.Vertical)

        self.widget = QWidget(self.splitter)
        self.widget.setObjectName(u"widget")
        self.verticalLayout2 = QVBoxLayout(self.widget)
        self.stdoutLabel = QLabel(self.widget)
        self.stdoutLabel.setText('stdout:')

        self.verticalLayout2.addWidget(self.stdoutLabel)

        self.stdoutText = QTextEdit(self.widget)
        self.stdoutText.setEnabled(False)
        self.stdoutText.setReadOnly(True)
        self.stdoutText.setPlainText("Output will appear here")

        self.verticalLayout2.addWidget(self.stdoutText)

        self.splitter.addWidget(self.widget)

        self.widget1 = QWidget(self.splitter)

        self.verticalLayout3 = QVBoxLayout(self.widget1)
        self.stderrLabel = QLabel(self.widget1)
        self.stderrLabel.setText('stderr:')

        self.verticalLayout3.addWidget(self.stderrLabel)

        self.stderrText = QTextEdit(self.widget1)
        self.stderrText.setEnabled(False)
        self.stderrText.setReadOnly(True)
        self.stderrText.setPlainText('Errors will appear here')

        self.verticalLayout3.addWidget(self.stderrText)

        self.splitter.addWidget(self.widget1)

        self.verticalLayout.addWidget(self.splitter)

        # Logic

        # Use QProcess to start a program and get its outputs https://stackoverflow.com/a/22110924
        self.process = QProcess(self)

        self.process.readyReadStandardOutput.connect(self.readStdout)
        self.process.readyReadStandardError.connect(self.readStderr)
        self.process.started.connect(self.processStarted)
        self.process.finished.connect(self.processFinished)
        self.process.errorOccurred.connect(self.errorOccurred)
        self.compileButton.clicked.connect(self.doCompile)
        self.tidyButton.clicked.connect(self.doTidy)

    def doCompile(self):
        self.cleanupUI()
        self.process.setWorkingDirectory(settings.get_repo_location())
        self.process.startCommand(settings.get_build_command())

    def doTidy(self):
        self.cleanupUI()
        self.process.setWorkingDirectory(settings.get_repo_location())
        self.process.startCommand(settings.get_tidy_command())

    def cleanupUI(self):
        self.stdoutText.setEnabled(True)
        self.stderrText.setEnabled(True)
        self.stdoutText.setPlainText('')
        self.stderrText.setPlainText('')

    def readStdout(self):
        lines = self.process.readAllStandardOutput().data().decode(
        )[:-1].split('\n')
        for line in lines:
            if line == 'tmc.gba: FAILED':
                line = 'tmc.gba: <b style="color:red">FAILED</b>'
            elif line == 'tmc.gba: OK':
                line = 'tmc.gba: <b style="color:lime">OK</b>'
            self.stdoutText.append(line)

    def readStderr(self):
        lines = self.process.readAllStandardError().data().decode()[:-1].split(
            '\n')
        for line in lines:
            if 'error' in line.lower():
                line = f'<span style="color:red">{line}</span>'
            elif 'warning' in line.lower():
                line = f'<span style="color:orange">{line}</span>'

            self.stderrText.append(line)

    def processStarted(self):
        self.compileButton.setEnabled(False)
        self.tidyButton.setEnabled(False)

    def processFinished(self):
        self.compileButton.setEnabled(True)
        self.tidyButton.setEnabled(True)

    def errorOccurred(self):
        self.stderrText.insertPlainText(self.process.errorString())
Example #19
0
File: edit.py Project: clpi/isutils
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))
Example #20
0
    def __init__(self, parent=None) -> None:
        super().__init__(parent)

        self.verticalLayout = QVBoxLayout(self)

        self.compileButton = QPushButton('Compile', self)
        self.compileButton.setMinimumSize(QSize(200, 50))
        self.verticalLayout.addWidget(self.compileButton, 0, Qt.AlignHCenter)

        self.tidyButton = QPushButton('Tidy', self)
        self.verticalLayout.addWidget(self.tidyButton, 0, Qt.AlignHCenter)

        self.splitter = QSplitter(self)
        self.splitter.setOrientation(Qt.Vertical)

        self.widget = QWidget(self.splitter)
        self.widget.setObjectName(u"widget")
        self.verticalLayout2 = QVBoxLayout(self.widget)
        self.stdoutLabel = QLabel(self.widget)
        self.stdoutLabel.setText('stdout:')

        self.verticalLayout2.addWidget(self.stdoutLabel)

        self.stdoutText = QTextEdit(self.widget)
        self.stdoutText.setEnabled(False)
        self.stdoutText.setReadOnly(True)
        self.stdoutText.setPlainText("Output will appear here")

        self.verticalLayout2.addWidget(self.stdoutText)

        self.splitter.addWidget(self.widget)

        self.widget1 = QWidget(self.splitter)

        self.verticalLayout3 = QVBoxLayout(self.widget1)
        self.stderrLabel = QLabel(self.widget1)
        self.stderrLabel.setText('stderr:')

        self.verticalLayout3.addWidget(self.stderrLabel)

        self.stderrText = QTextEdit(self.widget1)
        self.stderrText.setEnabled(False)
        self.stderrText.setReadOnly(True)
        self.stderrText.setPlainText('Errors will appear here')

        self.verticalLayout3.addWidget(self.stderrText)

        self.splitter.addWidget(self.widget1)

        self.verticalLayout.addWidget(self.splitter)

        # Logic

        # Use QProcess to start a program and get its outputs https://stackoverflow.com/a/22110924
        self.process = QProcess(self)

        self.process.readyReadStandardOutput.connect(self.readStdout)
        self.process.readyReadStandardError.connect(self.readStderr)
        self.process.started.connect(self.processStarted)
        self.process.finished.connect(self.processFinished)
        self.process.errorOccurred.connect(self.errorOccurred)
        self.compileButton.clicked.connect(self.doCompile)
        self.tidyButton.clicked.connect(self.doTidy)
Example #21
0
class MainWidget(QWidget):
    def __init__(self, parent: QWidget, model: Model) -> None:
        super().__init__(parent)

        logger.add(self.log)

        settings = QSettings()
        self.mainlayout = QVBoxLayout()
        self.mainlayout.setContentsMargins(5, 5, 5, 5)
        self.setLayout(self.mainlayout)

        # summary

        summarylayout = FlowLayout()
        summarylayout.setContentsMargins(0, 0, 0, 0)
        self.summary = QWidget()
        self.summary.setLayout(summarylayout)
        self.mainlayout.addWidget(self.summary)
        self.summary.setVisible(
            settings.value('showSummary', 'True') == 'True')

        detailslayout = QHBoxLayout()
        detailslayout.setContentsMargins(1, 0, 0, 0)
        detailslayout.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
        detailslayout.setSpacing(15)
        details = QWidget()
        details.setLayout(detailslayout)
        summarylayout.addWidget(details)

        self.modstotal = QLabel()
        detailslayout.addWidget(self.modstotal)
        self.modsenabled = QLabel()
        detailslayout.addWidget(self.modsenabled)
        self.overridden = QLabel()
        detailslayout.addWidget(self.overridden)
        self.conflicts = QLabel()
        detailslayout.addWidget(self.conflicts)

        buttonslayout = QHBoxLayout()
        buttonslayout.setContentsMargins(0, 0, 0, 0)
        buttonslayout.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
        buttons = QWidget()
        buttons.setLayout(buttonslayout)
        summarylayout.addWidget(buttons)

        self.startscriptmerger = QPushButton('Start Script Merger')
        self.startscriptmerger.setContentsMargins(0, 0, 0, 0)
        self.startscriptmerger.setMinimumWidth(140)
        self.startscriptmerger.setIcon(
            QIcon(str(getRuntimePath('resources/icons/script.ico'))))
        self.startscriptmerger.clicked.connect(lambda: [
            openExecutable(Path(str(settings.value('scriptMergerPath'))), True)
        ])
        self.startscriptmerger.setEnabled(
            verifyScriptMergerPath(
                Path(str(settings.value('scriptMergerPath')))) is not None)
        buttonslayout.addWidget(self.startscriptmerger)

        self.startgame = QPushButton('Start Game')
        self.startgame.setContentsMargins(0, 0, 0, 0)
        self.startgame.setMinimumWidth(100)
        self.startgame.setIcon(
            QIcon(str(getRuntimePath('resources/icons/w3b.ico'))))
        buttonslayout.addWidget(self.startgame)

        # splitter

        self.splitter = QSplitter(Qt.Vertical)

        self.stack = QStackedWidget()
        self.splitter.addWidget(self.stack)

        # mod list widget

        self.modlistwidget = QWidget()
        self.modlistlayout = QVBoxLayout()
        self.modlistlayout.setContentsMargins(0, 0, 0, 0)
        self.modlistwidget.setLayout(self.modlistlayout)
        self.stack.addWidget(self.modlistwidget)

        # search bar

        self.searchbar = QLineEdit()
        self.searchbar.setPlaceholderText('Search...')
        self.modlistlayout.addWidget(self.searchbar)

        # mod list

        self.modlist = ModList(self, model)
        self.modlistlayout.addWidget(self.modlist)

        self.searchbar.textChanged.connect(lambda e: self.modlist.setFilter(e))

        # welcome message

        welcomelayout = QVBoxLayout()
        welcomelayout.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        welcomewidget = QWidget()
        welcomewidget.setLayout(welcomelayout)
        welcomewidget.dragEnterEvent = self.modlist.dragEnterEvent  # type: ignore
        welcomewidget.dragMoveEvent = self.modlist.dragMoveEvent  # type: ignore
        welcomewidget.dragLeaveEvent = self.modlist.dragLeaveEvent  # type: ignore
        welcomewidget.dropEvent = self.modlist.dropEvent  # type: ignore
        welcomewidget.setAcceptDrops(True)

        icon = QIcon(str(getRuntimePath('resources/icons/open-folder.ico')))
        iconpixmap = icon.pixmap(32, 32)
        icon = QLabel()
        icon.setPixmap(iconpixmap)
        icon.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        icon.setContentsMargins(4, 4, 4, 4)
        welcomelayout.addWidget(icon)

        welcome = QLabel('''<p><font>
            No mod installed yet.
            Drag a mod into this area to get started!
            </font></p>''')
        welcome.setAttribute(Qt.WA_TransparentForMouseEvents)
        welcome.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        welcomelayout.addWidget(welcome)

        self.stack.addWidget(welcomewidget)

        # output log

        self.output = QTextEdit(self)
        self.output.setTextInteractionFlags(Qt.NoTextInteraction)
        self.output.setReadOnly(True)
        self.output.setContextMenuPolicy(Qt.NoContextMenu)
        self.output.setPlaceholderText('Program output...')
        self.splitter.addWidget(self.output)

        # TODO: enhancement: show indicator if scripts have to be merged

        self.splitter.setStretchFactor(0, 1)
        self.splitter.setStretchFactor(1, 0)
        self.mainlayout.addWidget(self.splitter)

        # TODO: incomplete: make start game button functional

        if len(model):
            self.stack.setCurrentIndex(0)
            self.splitter.setSizes([self.splitter.size().height(), 50])
        else:
            self.stack.setCurrentIndex(1)
            self.splitter.setSizes([self.splitter.size().height(), 0])
        model.updateCallbacks.append(self.modelUpdateEvent)

        asyncio.create_task(model.loadInstalled())

    def keyPressEvent(self, event: QKeyEvent) -> None:
        if event.key() == Qt.Key_Escape:
            self.modlist.setFocus()
            self.searchbar.setText('')
        elif event.matches(QKeySequence.Find):
            self.searchbar.setFocus()
        elif event.matches(QKeySequence.Paste):
            self.pasteEvent()
        # TODO: enhancement: add start game / start script merger shortcuts
        else:
            super().keyPressEvent(event)

    def pasteEvent(self) -> None:
        clipboard = QApplication.clipboard().text().splitlines()
        if len(clipboard) == 1 and isValidNexusModsUrl(clipboard[0]):
            self.parentWidget().showDownloadModDialog()
        else:
            urls = [
                url for url in QApplication.clipboard().text().splitlines()
                if len(str(url.strip()))
            ]
            if all(
                    isValidModDownloadUrl(url) or isValidFileUrl(url)
                    for url in urls):
                asyncio.create_task(self.modlist.checkInstallFromURLs(urls))

    def modelUpdateEvent(self, model: Model) -> None:
        total = len(model)
        enabled = len([mod for mod in model if model[mod].enabled])
        overridden = sum(
            len(file) for file in model.conflicts.bundled.values())
        conflicts = sum(len(file) for file in model.conflicts.scripts.values())
        self.modstotal.setText(
            f'<font color="#73b500" size="4">{total}</font> \
                <font color="#888" text-align="center">Installed Mod{"" if total == 1 else "s"}</font>'
        )
        self.modsenabled.setText(
            f'<font color="#73b500" size="4">{enabled}</font> \
                <font color="#888">Enabled Mod{"" if enabled == 1 else "s"}</font>'
        )
        self.overridden.setText(
            f'<font color="{"#b08968" if overridden > 0 else "#84C318"}" size="4">{overridden}</font> \
                <font color="#888">Overridden File{"" if overridden == 1 else "s"}</font> '
        )
        self.conflicts.setText(
            f'<font color="{"#E55934" if conflicts > 0 else "#aad576"}" size="4">{conflicts}</font> \
                <font color="#888">Unresolved Conflict{"" if conflicts == 1 else "s"}</font> '
        )

        if len(model) > 0:
            if self.stack.currentIndex() != 0:
                self.stack.setCurrentIndex(0)
                self.repaint()
        else:
            if self.stack.currentIndex() != 1:
                self.stack.setCurrentIndex(1)
                self.repaint()

    def unhideOutput(self) -> None:
        if self.splitter.sizes()[1] < 10:
            self.splitter.setSizes([self.splitter.size().height(), 50])

    def unhideModList(self) -> None:
        if self.splitter.sizes()[0] < 10:
            self.splitter.setSizes([50, self.splitter.size().height()])

    def log(self, message: Any) -> None:
        # format log messages to user readable output
        settings = QSettings()

        record = message.record
        message = record['message']
        extra = record['extra']
        level = record['level'].name.lower()

        name = str(extra['name']
                   ) if 'name' in extra and extra['name'] is not None else ''
        path = str(extra['path']
                   ) if 'path' in extra and extra['path'] is not None else ''
        dots = bool(
            extra['dots']
        ) if 'dots' in extra and extra['dots'] is not None else False
        newline = bool(
            extra['newline']
        ) if 'newline' in extra and extra['newline'] is not None else False
        output = bool(
            extra['output']
        ) if 'output' in extra and extra['output'] is not None else bool(
            message)
        modlist = bool(
            extra['modlist']
        ) if 'modlist' in extra and extra['modlist'] is not None else False

        if level in ['debug'
                     ] and settings.value('debugOutput', 'False') != 'True':
            if newline:
                self.output.append(f'')
            return

        n = '<br>' if newline else ''
        d = '...' if dots else ''
        if len(name) and len(path):
            path = f' ({path})'

        if output:
            message = html.escape(message, quote=True)

            if level in ['success', 'error', 'warning']:
                message = f'<strong>{message}</strong>'
            if level in ['success']:
                message = f'<font color="#04c45e">{message}</font>'
            if level in ['error', 'critical']:
                message = f'<font color="#ee3b3b">{message}</font>'
            if level in ['warning']:
                message = f'<font color="#ff6500">{message}</font>'
            if level in ['debug', 'trace']:
                message = f'<font color="#aaa">{message}</font>'
                path = f'<font color="#aaa">{path}</font>' if path else ''
                d = f'<font color="#aaa">{d}</font>' if d else ''

            time = record['time'].astimezone(
                tz=None).strftime('%Y-%m-%d %H:%M:%S')
            message = f'<font color="#aaa">{time}</font> {message}'
            self.output.append(
                f'{n}{message.strip()}{" " if name or path else ""}{name}{path}{d}'
            )
        else:
            self.output.append(f'')

        self.output.verticalScrollBar().setValue(
            self.output.verticalScrollBar().maximum())
        self.output.repaint()

        if modlist:
            self.unhideModList()
        if settings.value('unhideOutput', 'True') == 'True' and output:
            self.unhideOutput()
Example #22
0
class MainWindow(QMainWindow):
    def __init__(self, window_width=None, window_height=None):
        super(MainWindow, self).__init__()
        if window_width != None and window_height != None:
            self.window_width = window_width
            self.window_height = window_height
            self.resize(window_width, window_height)

        self.stack_of_widget = QStackedWidget()
        self.central_widget = QWidget()
        self.main_layout = QVBoxLayout()

        self.username = ""

        # ui widgets
        self.message_visable_field = QTextEdit()
        self.message_input_field = QTextEdit()
        self.send_message = QPushButton("Send my message!")

        self.login_screen = LoginScreen()
        self.login_screen.auth_button.clicked.connect(self.login_button_click)

        # show all widgets
        self.build_ui()

    def build_ui(self):
        self.message_visable_field.setFont(QFont("Roboto", 12))
        self.message_visable_field.setReadOnly(True)

        self.message_input_field.setFont(QFont("Roboto", 11))
        self.message_input_field.setPlaceholderText(
            "Input your message here...")
        self.message_input_field.setMinimumHeight(50)
        self.message_input_field.setMaximumHeight(50)

        self.send_message.setFont(QFont("Roboto", 11))
        self.send_message.clicked.connect(self.send_message_button_clicked)

        self.main_layout.addWidget(self.message_visable_field)
        self.main_layout.addWidget(self.message_input_field)
        self.main_layout.addWidget(self.send_message)

        self.central_widget.setLayout(self.main_layout)
        self.stack_of_widget.addWidget(self.login_screen)
        self.setMaximumSize(self.minimumSize())
        self.stack_of_widget.addWidget(self.central_widget)
        self.setCentralWidget(self.stack_of_widget)

    def send_message_button_clicked(self):
        """
        send a client message to the server, and append to the list message.
        """
        message = self.message_input_field.toPlainText()
        if message != '':
            # send message to the server
            r_type = RequestInfo(type_request="MessageRequest",
                                 request_ts=f"{datetime.now()}")
            r_data = MessageRequest(from_=self.username,
                                    to="all",
                                    message=message)
            request = Request(request=[r_type], data=[r_data])
            client_worker.send(request.json())
            self.message_visable_field.append('You: ' + message)
        self.message_input_field.clear()

    def login_button_click(self):
        self.username = self.login_screen.login_field.text()
        r_type = RequestInfo(type_request="AuthRequest",
                             request_ts=f"{datetime.now()}")
        r_data = AuthRequest(
            login=f"{self.username}",
            password=f"{self.login_screen.password_field.text()}")
        request = Request(request=[r_type], data=[r_data])
        client_worker.send(request.json())

    @Slot(str)
    def recieved_message_handler(self, message):
        msg = json.loads(message)
        print(msg)
        response = Request(**msg)
        if response.request[0].type_request == "AuthResponse":
            data = AuthResponse(**response.data[0])
            if data.access is True:
                self.show_main_screen()

        elif response.request[0].type_request == "MessageRequest":
            data = MessageRequest(**response.data[0])
            if data.to == "all":
                self.message_visable_field.append(
                    f"[{data.from_}]: {data.message}")

    def show_main_screen(self):
        self.stack_of_widget.setCurrentWidget(self.central_widget)
        self.setMinimumSize(self.window_width, self.window_height)
        self.resize(self.minimumSize())

    def closeEvent(self, event):
        client_worker.close()
        network_thread.exit()
        network_thread.wait(500)
        if network_thread.isRunning() is True:
            network_thread.terminate()
Example #23
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)
Example #24
0
    def create_GUI(self) -> None:
        self.commands_display = QTextEdit(self)
        font = self.commands_display.font()
        font.setPointSize(10)
        self.commands_display.setFont(font)

        self.commands_display.setReadOnly(True)
        place_holder: str = "1. Choose Action | 2. Pick a Key to be Bound | 3. Select a Gun/Equipment"
        self.commands_display.setPlaceholderText(place_holder)

        self.f1 = QPushButton(self.centralWidget)
        self.f2 = QPushButton(self.centralWidget)
        self.f3 = QPushButton(self.centralWidget)
        self.f4 = QPushButton(self.centralWidget)
        self.f5 = QPushButton(self.centralWidget)
        self.f6 = QPushButton(self.centralWidget)
        self.f7 = QPushButton(self.centralWidget)
        self.f8 = QPushButton(self.centralWidget)
        self.f9 = QPushButton(self.centralWidget)
        self.f10 = QPushButton(self.centralWidget)
        self.f11 = QPushButton(self.centralWidget)
        self.f12 = QPushButton(self.centralWidget)

        self.acute = QPushButton(self.centralWidget)
        self.one = QPushButton(self.centralWidget)
        self.two = QPushButton(self.centralWidget)
        self.three = QPushButton(self.centralWidget)
        self.four = QPushButton(self.centralWidget)
        self.five = QPushButton(self.centralWidget)
        self.six = QPushButton(self.centralWidget)
        self.seven = QPushButton(self.centralWidget)
        self.eight = QPushButton(self.centralWidget)
        self.nine = QPushButton(self.centralWidget)
        self.zero = QPushButton(self.centralWidget)
        self.minus = QPushButton(self.centralWidget)
        self.equal = QPushButton(self.centralWidget)
        self.backspace = QPushButton(self.centralWidget)

        self.tab = QPushButton(self.centralWidget)
        self.q = QPushButton(self.centralWidget)
        self.w = QPushButton(self.centralWidget)
        self.e = QPushButton(self.centralWidget)
        self.r = QPushButton(self.centralWidget)
        self.t = QPushButton(self.centralWidget)
        self.y = QPushButton(self.centralWidget)
        self.u = QPushButton(self.centralWidget)
        self.i = QPushButton(self.centralWidget)
        self.o = QPushButton(self.centralWidget)
        self.p = QPushButton(self.centralWidget)
        self.open_bracket = QPushButton(self.centralWidget)
        self.closed_bracket = QPushButton(self.centralWidget)
        self.backslash = QPushButton(self.centralWidget)

        self.capslock = QPushButton(self.centralWidget)
        self.a = QPushButton(self.centralWidget)
        self.s = QPushButton(self.centralWidget)
        self.d = QPushButton(self.centralWidget)
        self.f = QPushButton(self.centralWidget)
        self.g = QPushButton(self.centralWidget)
        self.h = QPushButton(self.centralWidget)
        self.j = QPushButton(self.centralWidget)
        self.k = QPushButton(self.centralWidget)
        self.l = QPushButton(self.centralWidget)
        self.semicolon = QPushButton(self.centralWidget)
        self.apostrophe = QPushButton(self.centralWidget)
        self.enter = QPushButton(self.centralWidget)

        self.left_shift = QPushButton(self.centralWidget)
        self.z = QPushButton(self.centralWidget)
        self.x = QPushButton(self.centralWidget)
        self.c = QPushButton(self.centralWidget)
        self.v = QPushButton(self.centralWidget)
        self.b = QPushButton(self.centralWidget)
        self.n = QPushButton(self.centralWidget)
        self.m = QPushButton(self.centralWidget)
        self.comma = QPushButton(self.centralWidget)
        self.dot = QPushButton(self.centralWidget)
        self.slash = QPushButton(self.centralWidget)
        self.right_shift = QPushButton(self.centralWidget)

        self.left_ctrl = QPushButton(self.centralWidget)
        self.right_alt = QPushButton(self.centralWidget)
        self.space = QPushButton(self.centralWidget)
        self.left_alt = QPushButton(self.centralWidget)
        self.right_ctrl = QPushButton(self.centralWidget)

        self.insert = QPushButton(self.centralWidget)
        self.home = QPushButton(self.centralWidget)
        self.pgup = QPushButton(self.centralWidget)
        self.delete = QPushButton(self.centralWidget)
        self.end = QPushButton(self.centralWidget)
        self.pgdn = QPushButton(self.centralWidget)
        self.uparrow = QPushButton(self.centralWidget)
        self.leftarrow = QPushButton(self.centralWidget)
        self.downarrow = QPushButton(self.centralWidget)
        self.rightarrow = QPushButton(self.centralWidget)

        self.numlock = QPushButton(self.centralWidget)
        self.kp_slash = QPushButton(self.centralWidget)
        self.kp_multiply = QPushButton(self.centralWidget)
        self.kp_minus = QPushButton(self.centralWidget)
        self.kp_home = QPushButton(self.centralWidget)
        self.kp_uparrow = QPushButton(self.centralWidget)
        self.kp_pgup = QPushButton(self.centralWidget)
        self.kp_plus = QPushButton(self.centralWidget)
        self.kp_plus.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)
        self.kp_leftarrow = QPushButton(self.centralWidget)
        self.kp_five = QPushButton(self.centralWidget)
        self.kp_rightarrow = QPushButton(self.centralWidget)
        self.kp_end = QPushButton(self.centralWidget)
        self.kp_downarrow = QPushButton(self.centralWidget)
        self.kp_pgdn = QPushButton(self.centralWidget)
        self.kp_enter = QPushButton(self.centralWidget)
        self.kp_enter.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)
        self.kp_insert = QPushButton(self.centralWidget)
        self.kp_delete = QPushButton(self.centralWidget)

        self.buy = QPushButton(self.centralWidget)
        self.buy.setStyleSheet("QPushButton" "{" "font-size: 17px;" "}")
        self.buy.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.hand_switch = QPushButton(self.centralWidget)
        self.clear_decals = QPushButton(self.centralWidget)
        self.bind_grenade = QPushButton(self.centralWidget)
        self.voice_mute = QPushButton(self.centralWidget)
        self.bomb_drop = QPushButton(self.centralWidget)
        self.copy = QPushButton(self.centralWidget)
        self.reset = QPushButton(self.centralWidget)

        self.ak47 = QPushButton(self.centralWidget)
        self.ak47.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.m4s = QPushButton(self.centralWidget)
        self.m4s.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.aug = QPushButton(self.centralWidget)
        self.sg = QPushButton(self.centralWidget)
        self.awp = QPushButton(self.centralWidget)
        self.ssg = QPushButton(self.centralWidget)
        self.famas = QPushButton(self.centralWidget)
        self.galil = QPushButton(self.centralWidget)

        self.mac10 = QPushButton(self.centralWidget)
        self.mp9 = QPushButton(self.centralWidget)
        self.mp7 = QPushButton(self.centralWidget)
        self.ump = QPushButton(self.centralWidget)
        self.bizon = QPushButton(self.centralWidget)
        self.p90 = QPushButton(self.centralWidget)
        self.mp5 = QPushButton(self.centralWidget)

        self.xm = QPushButton(self.centralWidget)
        self.sawedoff = QPushButton(self.centralWidget)
        self.mag7 = QPushButton(self.centralWidget)

        self.p250 = QPushButton(self.centralWidget)
        self.cz75 = QPushButton(self.centralWidget)
        self.tec9 = QPushButton(self.centralWidget)
        self.fiveseven = QPushButton(self.centralWidget)
        self.deagle = QPushButton(self.centralWidget)
        self.revolver = QPushButton(self.centralWidget)

        self.nade = QPushButton(self.centralWidget)
        self.flash = QPushButton(self.centralWidget)
        self.double_flash = QPushButton(self.centralWidget)
        self.smoke = QPushButton(self.centralWidget)
        self.molotov = QPushButton(self.centralWidget)
        self.inc_grenade = QPushButton(self.centralWidget)

        self.vest = QPushButton(self.centralWidget)
        self.vest.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.vest_helmet = QPushButton(self.centralWidget)
        self.vest_helmet.setSizePolicy(QSizePolicy.Expanding,
                                       QSizePolicy.Expanding)
        self.defuse_kit = QPushButton(self.centralWidget)

        self.mouse3 = QPushButton(self.centralWidget)
        self.mouse3.setStyleSheet("margin-top: 25px;" "margin-bottom: 10px;")
        self.mouse4 = QPushButton(self.centralWidget)
        self.mouse4.setStyleSheet("margin-top: 25px;" "margin-bottom: 10px;")
        self.mouse5 = QPushButton(self.centralWidget)
        self.mouse5.setStyleSheet("margin-top: 25px;" "margin-bottom: 10px;")

        self.f1.setText("F1")
        self.f2.setText("F2")
        self.f3.setText("F3")
        self.f4.setText("F4")
        self.f5.setText("F5")
        self.f6.setText("F6")
        self.f7.setText("F7")
        self.f8.setText("F8")
        self.f9.setText("F9")
        self.f10.setText("F10")
        self.f11.setText("F11")
        self.f12.setText("F12")
        self.acute.setText("`")
        self.one.setText("1")
        self.two.setText("2")
        self.three.setText("3")
        self.four.setText("4")
        self.five.setText("5")
        self.six.setText("6")
        self.seven.setText("7")
        self.eight.setText("8")
        self.nine.setText("9")
        self.zero.setText("0")
        self.minus.setText("-")
        self.equal.setText("=")
        self.backspace.setText("Backspace")
        self.tab.setText("TAB")
        self.q.setText("Q")
        self.w.setText("W")
        self.e.setText("E")
        self.r.setText("R")
        self.t.setText("T")
        self.y.setText("Y")
        self.u.setText("U")
        self.i.setText("I")
        self.o.setText("O")
        self.p.setText("P")
        self.open_bracket.setText("[")
        self.closed_bracket.setText("]")
        self.backslash.setText("\\")
        self.capslock.setText("Caps Lock")
        self.a.setText("A")
        self.s.setText("S")
        self.d.setText("D")
        self.f.setText("F")
        self.g.setText("G")
        self.h.setText("H")
        self.j.setText("J")
        self.k.setText("K")
        self.l.setText("L")
        self.semicolon.setText(";")
        self.apostrophe.setText("'")
        self.enter.setText("Enter")
        self.left_shift.setText("Shift")
        self.z.setText("Z")
        self.x.setText("X")
        self.c.setText("C")
        self.v.setText("V")
        self.b.setText("B")
        self.n.setText("N")
        self.m.setText("M")
        self.comma.setText(",")
        self.dot.setText(".")
        self.slash.setText("/")
        self.right_shift.setText("Shift")
        self.left_ctrl.setText("Ctrl")
        self.left_alt.setText("Alt")
        self.space.setText("Space")
        self.right_alt.setText("Alt")
        self.right_ctrl.setText("Ctrl")
        self.insert.setText("Insert")
        self.home.setText("Home")
        self.pgup.setText("PgUp")
        self.delete.setText("Del")
        self.end.setText("End")
        self.pgdn.setText("PgDn")
        self.uparrow.setText("↑")
        self.leftarrow.setText("←")
        self.downarrow.setText("↓")
        self.rightarrow.setText("→")
        self.numlock.setText("Num Lock")
        self.kp_slash.setText("/")
        self.kp_multiply.setText("*")
        self.kp_minus.setText("-")
        self.kp_home.setText("7")
        self.kp_uparrow.setText("8")
        self.kp_pgup.setText("9")
        self.kp_plus.setText("+")
        self.kp_leftarrow.setText("4")
        self.kp_five.setText("5")
        self.kp_rightarrow.setText("6")
        self.kp_end.setText("1")
        self.kp_downarrow.setText("2")
        self.kp_pgdn.setText("3")
        self.kp_enter.setText("Enter")
        self.kp_insert.setText("0")
        self.kp_delete.setText(".")

        self.buy.setText("BUY")
        self.bind_grenade.setText("Bind Grenades")
        self.voice_mute.setText("Mute Voice Chat")
        self.bomb_drop.setText("Bomb Drop")
        self.reset.setText("RESET")
        self.clear_decals.setText("Clear Decals")
        self.hand_switch.setText("Switch Hands")
        self.copy.setText("Copy to Clipboard")
        self.mouse3.setText("Mouse 3")
        self.mouse4.setText("Mouse 4")
        self.mouse5.setText("Mouse 5")

        self.ak47.setText("AK-47")
        self.m4s.setText("M4A4/1-S")
        self.aug.setText("AUG")
        self.sg.setText("SG 553")
        self.awp.setText("AWP")
        self.galil.setText("Galil AR")
        self.famas.setText("FAMAS")
        self.ssg.setText("SSG 08")

        self.mac10.setText("MAC-10")
        self.mp9.setText("MP9")
        self.mp7.setText("MP7")
        self.bizon.setText("PP-Bizon")
        self.p90.setText("P90")
        self.ump.setText("UMP-45")
        self.mp5.setText("MP5-SD")

        self.mag7.setText("MAG-7")
        self.sawedoff.setText("Sawed-Off")
        self.xm.setText("XM1014")

        self.p250.setText("P250")
        self.cz75.setText("CZ75-Auto")
        self.fiveseven.setText("Five-SeveN")
        self.tec9.setText("Tec-9")
        self.deagle.setText("Desert Eagle")
        self.revolver.setText("R8 Revolver")

        self.vest.setText("Kevlar Vest")
        self.vest_helmet.setText(f"Kevlar\n +\nHelmet")
        self.defuse_kit.setText("Defuse Kit")

        self.flash.setText("Flash")
        self.double_flash.setText("2x Flash")
        self.nade.setText("Grenade")
        self.smoke.setText("Smoke")
        self.inc_grenade.setText("INC-Grenade")
        self.molotov.setText("Molotov")

        self.layout.addWidget(self.commands_display, 0, 5, 5, 7)

        self.layout.addWidget(self.bind_grenade, 0, 0, 1, 2)
        self.layout.addWidget(self.bomb_drop, 1, 0, 1, 2)
        self.layout.addWidget(self.voice_mute, 2, 0, 1, 2)
        self.layout.addWidget(self.hand_switch, 3, 0, 1, 2)
        self.layout.addWidget(self.clear_decals, 4, 0, 1, 2)

        self.layout.addWidget(self.buy, 0, 3, 2, 2)
        self.layout.addWidget(self.reset, 3, 3, 1, 2)
        self.layout.addWidget(self.copy, 4, 3, 1, 2)

        self.layout.addWidget(self.ak47, 0, 12, 2, 1)
        self.layout.addWidget(self.m4s, 0, 13, 2, 1)
        self.layout.addWidget(self.vest, 2, 12, 2, 1)
        self.layout.addWidget(self.vest_helmet, 2, 13, 2, 1)
        self.layout.addWidget(self.defuse_kit, 4, 12)
        self.layout.addWidget(self.double_flash, 4, 13)

        self.layout.addWidget(self.flash, 0, 14)
        self.layout.addWidget(self.smoke, 1, 14)
        self.layout.addWidget(self.nade, 2, 14)
        self.layout.addWidget(self.inc_grenade, 3, 14)
        self.layout.addWidget(self.molotov, 4, 14)

        self.layout.addWidget(self.awp, 0, 15)
        self.layout.addWidget(self.deagle, 1, 15)

        self.layout.addWidget(self.aug, 0, 16)
        self.layout.addWidget(self.sg, 1, 16)
        self.layout.addWidget(self.famas, 3, 16)
        self.layout.addWidget(self.galil, 2, 16)
        self.layout.addWidget(self.ssg, 4, 16)

        self.layout.addWidget(self.fiveseven, 0, 17)
        self.layout.addWidget(self.tec9, 1, 17)
        self.layout.addWidget(self.cz75, 3, 17)
        self.layout.addWidget(self.p250, 2, 17)
        self.layout.addWidget(self.revolver, 4, 17)

        self.layout.addWidget(self.mac10, 0, 18)
        self.layout.addWidget(self.mp9, 1, 18)
        self.layout.addWidget(self.mp7, 2, 18)
        self.layout.addWidget(self.ump, 3, 18)
        self.layout.addWidget(self.p90, 4, 18)

        self.layout.addWidget(self.mp5, 0, 19)
        self.layout.addWidget(self.bizon, 1, 19)
        self.layout.addWidget(self.mag7, 2, 19)
        self.layout.addWidget(self.sawedoff, 3, 19)
        self.layout.addWidget(self.xm, 4, 19)

        self.layout.addWidget(self.mouse3, 5, 7)
        self.layout.addWidget(self.mouse4, 5, 8)
        self.layout.addWidget(self.mouse5, 5, 9)

        self.layout.addWidget(self.f1, 6, 0)
        self.layout.addWidget(self.f2, 6, 1)
        self.layout.addWidget(self.f3, 6, 2)
        self.layout.addWidget(self.f4, 6, 3)
        self.layout.addWidget(self.f5, 6, 4)
        self.layout.addWidget(self.f6, 6, 5)
        self.layout.addWidget(self.f7, 6, 6)
        self.layout.addWidget(self.f8, 6, 7)
        self.layout.addWidget(self.f9, 6, 8)
        self.layout.addWidget(self.f10, 6, 9)
        self.layout.addWidget(self.f11, 6, 10)
        self.layout.addWidget(self.f12, 6, 11)

        self.layout.addWidget(self.acute, 7, 0)
        self.layout.addWidget(self.one, 7, 1)
        self.layout.addWidget(self.two, 7, 2)
        self.layout.addWidget(self.three, 7, 3)
        self.layout.addWidget(self.four, 7, 4)
        self.layout.addWidget(self.five, 7, 5)
        self.layout.addWidget(self.six, 7, 6)
        self.layout.addWidget(self.seven, 7, 7)
        self.layout.addWidget(self.eight, 7, 8)
        self.layout.addWidget(self.nine, 7, 9)
        self.layout.addWidget(self.zero, 7, 10)
        self.layout.addWidget(self.minus, 7, 11)
        self.layout.addWidget(self.equal, 7, 12)
        self.layout.addWidget(self.backspace, 7, 13)
        self.layout.addWidget(self.insert, 7, 14)
        self.layout.addWidget(self.home, 7, 15)
        self.layout.addWidget(self.pgup, 7, 16)
        self.layout.addWidget(self.numlock, 7, 17)
        self.layout.addWidget(self.kp_slash, 7, 18)
        self.layout.addWidget(self.kp_multiply, 7, 19)
        self.layout.addWidget(self.kp_minus, 7, 20)

        self.layout.addWidget(self.tab, 8, 0)
        self.layout.addWidget(self.q, 8, 1)
        self.layout.addWidget(self.w, 8, 2)
        self.layout.addWidget(self.e, 8, 3)
        self.layout.addWidget(self.r, 8, 4)
        self.layout.addWidget(self.t, 8, 5)
        self.layout.addWidget(self.y, 8, 6)
        self.layout.addWidget(self.u, 8, 7)
        self.layout.addWidget(self.i, 8, 8)
        self.layout.addWidget(self.o, 8, 9)
        self.layout.addWidget(self.p, 8, 10)
        self.layout.addWidget(self.open_bracket, 8, 11)
        self.layout.addWidget(self.closed_bracket, 8, 12)
        self.layout.addWidget(self.backslash, 8, 13)
        self.layout.addWidget(self.delete, 8, 14)
        self.layout.addWidget(self.end, 8, 15)
        self.layout.addWidget(self.pgdn, 8, 16)
        self.layout.addWidget(self.kp_home, 8, 17)
        self.layout.addWidget(self.kp_uparrow, 8, 18)
        self.layout.addWidget(self.kp_pgup, 8, 19)
        self.layout.addWidget(self.kp_plus, 8, 20, 2, 1)

        self.layout.addWidget(self.capslock, 9, 0)
        self.layout.addWidget(self.a, 9, 1)
        self.layout.addWidget(self.s, 9, 2)
        self.layout.addWidget(self.d, 9, 3)
        self.layout.addWidget(self.f, 9, 4)
        self.layout.addWidget(self.g, 9, 5)
        self.layout.addWidget(self.h, 9, 6)
        self.layout.addWidget(self.j, 9, 7)
        self.layout.addWidget(self.k, 9, 8)
        self.layout.addWidget(self.l, 9, 9)
        self.layout.addWidget(self.semicolon, 9, 10)
        self.layout.addWidget(self.apostrophe, 9, 11)
        self.layout.addWidget(self.enter, 9, 12, 1, 2)
        self.layout.addWidget(self.kp_leftarrow, 9, 17)
        self.layout.addWidget(self.kp_five, 9, 18)
        self.layout.addWidget(self.kp_rightarrow, 9, 19)

        self.layout.addWidget(self.left_shift, 10, 0, 1, 2)
        self.layout.addWidget(self.z, 10, 2)
        self.layout.addWidget(self.x, 10, 3)
        self.layout.addWidget(self.c, 10, 4)
        self.layout.addWidget(self.v, 10, 5)
        self.layout.addWidget(self.b, 10, 6)
        self.layout.addWidget(self.n, 10, 7)
        self.layout.addWidget(self.m, 10, 8)
        self.layout.addWidget(self.comma, 10, 9)
        self.layout.addWidget(self.dot, 10, 10)
        self.layout.addWidget(self.slash, 10, 11)
        self.layout.addWidget(self.right_shift, 10, 12, 1, 2)
        self.layout.addWidget(self.uparrow, 10, 15)
        self.layout.addWidget(self.kp_end, 10, 17)
        self.layout.addWidget(self.kp_downarrow, 10, 18)
        self.layout.addWidget(self.kp_pgdn, 10, 19)
        self.layout.addWidget(self.kp_enter, 10, 20, 2, 1)

        self.layout.addWidget(self.left_ctrl, 11, 0)
        self.layout.addWidget(self.left_alt, 11, 2)
        self.layout.addWidget(self.space, 11, 3, 1, 7)
        self.layout.addWidget(self.right_alt, 11, 10)
        self.layout.addWidget(self.right_ctrl, 11, 13)
        self.layout.addWidget(self.leftarrow, 11, 14)
        self.layout.addWidget(self.downarrow, 11, 15)
        self.layout.addWidget(self.rightarrow, 11, 16)
        self.layout.addWidget(self.kp_insert, 11, 17, 1, 2)
        self.layout.addWidget(self.kp_delete, 11, 19)

        self.f1.clicked.connect(lambda: self.key_clicked('"f1"'))
        self.f2.clicked.connect(lambda: self.key_clicked('"f2"'))
        self.f3.clicked.connect(lambda: self.key_clicked('"f3"'))
        self.f4.clicked.connect(lambda: self.key_clicked('"f4"'))
        self.f5.clicked.connect(lambda: self.key_clicked('"f5"'))
        self.f6.clicked.connect(lambda: self.key_clicked('"f6"'))
        self.f7.clicked.connect(lambda: self.key_clicked('"f7"'))
        self.f8.clicked.connect(lambda: self.key_clicked('"f8"'))
        self.f9.clicked.connect(lambda: self.key_clicked('"f9"'))
        self.f10.clicked.connect(lambda: self.key_clicked('"f10"'))
        self.f11.clicked.connect(lambda: self.key_clicked('"f11"'))
        self.f12.clicked.connect(lambda: self.key_clicked('"f12"'))

        self.acute.clicked.connect(lambda: self.key_clicked('"`"'))
        self.one.clicked.connect(lambda: self.key_clicked('"1"'))
        self.two.clicked.connect(lambda: self.key_clicked('"2"'))
        self.three.clicked.connect(lambda: self.key_clicked('"3"'))
        self.four.clicked.connect(lambda: self.key_clicked('"4"'))
        self.five.clicked.connect(lambda: self.key_clicked('"5"'))
        self.six.clicked.connect(lambda: self.key_clicked('"6"'))
        self.seven.clicked.connect(lambda: self.key_clicked('"7"'))
        self.eight.clicked.connect(lambda: self.key_clicked('"8"'))
        self.nine.clicked.connect(lambda: self.key_clicked('"9"'))
        self.zero.clicked.connect(lambda: self.key_clicked('"0"'))
        self.minus.clicked.connect(lambda: self.key_clicked('"-"'))
        self.equal.clicked.connect(lambda: self.key_clicked('"="'))
        self.backspace.clicked.connect(lambda: self.key_clicked('"backspace"'))
        self.insert.clicked.connect(lambda: self.key_clicked('"ins"'))
        self.home.clicked.connect(lambda: self.key_clicked('"home"'))
        self.pgup.clicked.connect(lambda: self.key_clicked('"pgup"'))
        self.numlock.clicked.connect(lambda: self.key_clicked('"numlock"'))
        self.kp_slash.clicked.connect(lambda: self.key_clicked('"kp_slash"'))
        self.kp_multiply.clicked.connect(
            lambda: self.key_clicked('"kp_multiply"'))
        self.kp_minus.clicked.connect(lambda: self.key_clicked('"kp_minus"'))

        self.tab.clicked.connect(lambda: self.key_clicked('"tab"'))
        self.q.clicked.connect(lambda: self.key_clicked('"q"'))
        self.w.clicked.connect(lambda: self.key_clicked('"w"'))
        self.e.clicked.connect(lambda: self.key_clicked('"e"'))
        self.r.clicked.connect(lambda: self.key_clicked('"r"'))
        self.t.clicked.connect(lambda: self.key_clicked('"t"'))
        self.y.clicked.connect(lambda: self.key_clicked('"y"'))
        self.u.clicked.connect(lambda: self.key_clicked('"u"'))
        self.i.clicked.connect(lambda: self.key_clicked('"i"'))
        self.o.clicked.connect(lambda: self.key_clicked('"o"'))
        self.p.clicked.connect(lambda: self.key_clicked('"p"'))
        self.open_bracket.clicked.connect(lambda: self.key_clicked('"["'))
        self.closed_bracket.clicked.connect(lambda: self.key_clicked('"]"'))
        self.backspace.clicked.connect(lambda: self.key_clicked('"\\"'))
        self.delete.clicked.connect(lambda: self.key_clicked('"del"'))
        self.end.clicked.connect(lambda: self.key_clicked('"End"'))
        self.pgdn.clicked.connect(lambda: self.key_clicked('"pgdn"'))
        self.kp_home.clicked.connect(lambda: self.key_clicked('"kp_home"'))
        self.kp_uparrow.clicked.connect(
            lambda: self.key_clicked('"kp_uparrow"'))
        self.kp_pgup.clicked.connect(lambda: self.key_clicked('"kp_pgup"'))
        self.kp_plus.clicked.connect(lambda: self.key_clicked('"kp_plus"'))

        self.capslock.clicked.connect(lambda: self.key_clicked('"capslock"'))
        self.a.clicked.connect(lambda: self.key_clicked('"a"'))
        self.s.clicked.connect(lambda: self.key_clicked('"s"'))
        self.d.clicked.connect(lambda: self.key_clicked('"d"'))
        self.f.clicked.connect(lambda: self.key_clicked('"f"'))
        self.g.clicked.connect(lambda: self.key_clicked('"g"'))
        self.h.clicked.connect(lambda: self.key_clicked('"h"'))
        self.j.clicked.connect(lambda: self.key_clicked('"j"'))
        self.k.clicked.connect(lambda: self.key_clicked('"k"'))
        self.l.clicked.connect(lambda: self.key_clicked('"l"'))
        self.semicolon.clicked.connect(lambda: self.key_clicked('"semicolon"'))
        self.apostrophe.clicked.connect(lambda: self.key_clicked('"' '"'))
        self.enter.clicked.connect(lambda: self.key_clicked('"enter"'))
        self.kp_leftarrow.clicked.connect(
            lambda: self.key_clicked('"kp_leftarrow"'))
        self.kp_five.clicked.connect(lambda: self.key_clicked('"kp_5"'))
        self.kp_rightarrow.clicked.connect(
            lambda: self.key_clicked('"kp_rightarrow"'))

        self.left_shift.clicked.connect(lambda: self.key_clicked('"shift"'))
        self.z.clicked.connect(lambda: self.key_clicked('"z"'))
        self.x.clicked.connect(lambda: self.key_clicked('"x"'))
        self.c.clicked.connect(lambda: self.key_clicked('"c"'))
        self.v.clicked.connect(lambda: self.key_clicked('"v"'))
        self.b.clicked.connect(lambda: self.key_clicked('"b"'))
        self.n.clicked.connect(lambda: self.key_clicked('"n"'))
        self.m.clicked.connect(lambda: self.key_clicked('"m"'))
        self.comma.clicked.connect(lambda: self.key_clicked('","'))
        self.dot.clicked.connect(lambda: self.key_clicked('"."'))
        self.slash.clicked.connect(lambda: self.key_clicked('"/"'))
        self.right_shift.clicked.connect(lambda: self.key_clicked('"shift"'))
        self.uparrow.clicked.connect(lambda: self.key_clicked('"uparrow"'))
        self.kp_end.clicked.connect(lambda: self.key_clicked('"kp_end"'))
        self.kp_downarrow.clicked.connect(
            lambda: self.key_clicked('"kp_downarrow"'))
        self.kp_pgdn.clicked.connect(lambda: self.key_clicked('"kp_pgdn"'))
        self.kp_enter.clicked.connect(lambda: self.key_clicked('"kp_enter"'))

        self.left_ctrl.clicked.connect(lambda: self.key_clicked('"ctrl"'))
        self.left_alt.clicked.connect(lambda: self.key_clicked('"alt"'))
        self.space.clicked.connect(lambda: self.key_clicked('"space"'))
        self.right_alt.clicked.connect(lambda: self.key_clicked('"alt"'))
        self.right_ctrl.clicked.connect(lambda: self.key_clicked('"ctrl"'))
        self.leftarrow.clicked.connect(lambda: self.key_clicked('"leftarrow"'))
        self.downarrow.clicked.connect(lambda: self.key_clicked('"downarrow"'))
        self.rightarrow.clicked.connect(
            lambda: self.key_clicked('"rightarrow"'))
        self.kp_insert.clicked.connect(lambda: self.key_clicked('"kp_ins"'))
        self.kp_delete.clicked.connect(lambda: self.key_clicked('"kp_del"'))

        self.mouse3.clicked.connect(lambda: self.key_clicked('"mouse3"'))
        self.mouse4.clicked.connect(lambda: self.key_clicked('"mouse4"'))
        self.mouse5.clicked.connect(lambda: self.key_clicked('"mouse5"'))

        self.buy.clicked.connect(self.buy_clicked)
        self.reset.clicked.connect(self.reset_clicked)
        self.bomb_drop.clicked.connect(self.bomb_drop_clicked)
        self.clear_decals.clicked.connect(self.clear_decals_clicked)
        self.bind_grenade.clicked.connect(self.bind_grenade_clicked)
        self.voice_mute.clicked.connect(self.voice_mute_clicked)
        self.hand_switch.clicked.connect(self.hand_switch_clicked)
        self.copy.clicked.connect(self.copy_clicked)

        self.ak47.clicked.connect(
            lambda: self.gear_clicked('"buy ak47; buy m4a1";'))
        self.m4s.clicked.connect(
            lambda: self.gear_clicked('"buy m4a1; buy ak47";'))
        self.vest.clicked.connect(lambda: self.gear_clicked('"buy vest";'))
        self.vest_helmet.clicked.connect(
            lambda: self.gear_clicked('"buy vesthelm";'))
        self.defuse_kit.clicked.connect(
            lambda: self.gear_clicked('"buy defuser";'))
        self.double_flash.clicked.connect(
            lambda: self.gear_clicked('"buy flashbang; buy flashbang";'))

        self.flash.clicked.connect(
            lambda: self.gear_clicked('"buy flashbang";'))
        self.smoke.clicked.connect(
            lambda: self.gear_clicked('"buy smokegrenade";'))
        self.nade.clicked.connect(
            lambda: self.gear_clicked('"buy hegrenade";'))
        self.inc_grenade.clicked.connect(
            lambda: self.gear_clicked('"buy incgrenade; buy molotov";'))
        self.molotov.clicked.connect(
            lambda: self.gear_clicked('"buy molotov; buy incgrenade";'))

        self.awp.clicked.connect(lambda: self.gear_clicked('"buy awp";'))
        self.deagle.clicked.connect(
            lambda: self.gear_clicked('"buy deagle; buy revolver";'))

        self.aug.clicked.connect(
            lambda: self.gear_clicked('"buy aug; buy sg556";'))
        self.sg.clicked.connect(
            lambda: self.gear_clicked('"buy sg556; buy aug";'))
        self.galil.clicked.connect(
            lambda: self.gear_clicked('"buy galilar; buy famas";'))
        self.famas.clicked.connect(
            lambda: self.gear_clicked('"buy famas; buy galilar";'))
        self.ssg.clicked.connect(lambda: self.gear_clicked('"buy ssg08";'))

        self.fiveseven.clicked.connect(
            lambda: self.gear_clicked('"buy fiveseven; buy tec9";'))
        self.tec9.clicked.connect(
            lambda: self.gear_clicked('"buy tec9; buy fiveseven";'))
        self.p250.clicked.connect(lambda: self.gear_clicked('"buy p250";'))
        self.cz75.clicked.connect(
            lambda: self.gear_clicked('"buy fiveseven; buy tec9";'))
        self.revolver.clicked.connect(
            lambda: self.gear_clicked('"buy revolver; buy deagle";'))

        self.mac10.clicked.connect(
            lambda: self.gear_clicked('"buy mac10; buy mp9";'))
        self.mp9.clicked.connect(
            lambda: self.gear_clicked('"buy mp9; buy mac10";'))
        self.mp7.clicked.connect(lambda: self.gear_clicked('"buy mp7";'))
        self.ump.clicked.connect(lambda: self.gear_clicked('"buy ump";'))
        self.p90.clicked.connect(lambda: self.gear_clicked('"buy p90";'))

        self.mp5.clicked.connect(lambda: self.gear_clicked('"buy mp7";'))
        self.bizon.clicked.connect(lambda: self.gear_clicked('"buy bizon";'))
        self.mag7.clicked.connect(
            lambda: self.gear_clicked('"buy mag7; buy sawedoff";'))
        self.sawedoff.clicked.connect(
            lambda: self.gear_clicked('"buy sawedoff; buy mag7";'))
        self.xm.clicked.connect(lambda: self.gear_clicked('"buy xm1014"`'))

        #------------------------------------------------------------------------------------------
        #------------------------------------------------------------------------------------------
        #------------------------------------------------------------------------------------------

        self.command: str = ""
        self.bind: Union[NoneType, bool] = None
        self.action: Union[NoneType, str] = None
        self.grenade_keys: tuple = (self.flash, self.smoke, self.nade,
                                    self.inc_grenade, self.molotov)
Example #25
0
    def setupUi(self, MainWindow):
        if not MainWindow.objectName():
            MainWindow.setObjectName(u"MainWindow")
        MainWindow.setWindowModality(Qt.ApplicationModal)
        MainWindow.resize(1492, 1852)
        sizePolicy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth())
        MainWindow.setSizePolicy(sizePolicy)
        MainWindow.setMinimumSize(QSize(700, 700))
        MainWindow.setMaximumSize(QSize(16777215, 16777215))
        MainWindow.setBaseSize(QSize(600, 600))
        font = QFont()
        font.setPointSize(12)
        font.setKerning(True)
        MainWindow.setFont(font)
        MainWindow.setAutoFillBackground(False)
        MainWindow.setStyleSheet(u"")
        MainWindow.setDocumentMode(False)
        MainWindow.setTabShape(QTabWidget.Rounded)
        MainWindow.setDockOptions(QMainWindow.AllowTabbedDocks|QMainWindow.AnimatedDocks)
        MainWindow.setUnifiedTitleAndToolBarOnMac(False)
        self.action_Quit = QAction(MainWindow)
        self.action_Quit.setObjectName(u"action_Quit")
        self.main_widget = QWidget(MainWindow)
        self.main_widget.setObjectName(u"main_widget")
        self.main_widget.setEnabled(True)
        self.main_widget.setMinimumSize(QSize(650, 650))
        self.main_widget.setContextMenuPolicy(Qt.DefaultContextMenu)
        self.main_widget.setAutoFillBackground(False)
        self.main_widget.setStyleSheet(u"")
        self.main_layout = QGridLayout(self.main_widget)
        self.main_layout.setObjectName(u"main_layout")
        self.horizontalLayout_2 = QHBoxLayout()
        self.horizontalLayout_2.setObjectName(u"horizontalLayout_2")
        self.log_button = QPushButton(self.main_widget)
        self.log_button.setObjectName(u"log_button")
        sizePolicy1 = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy1.setHorizontalStretch(0)
        sizePolicy1.setVerticalStretch(0)
        sizePolicy1.setHeightForWidth(self.log_button.sizePolicy().hasHeightForWidth())
        self.log_button.setSizePolicy(sizePolicy1)
        self.log_button.setMinimumSize(QSize(24, 24))
        font1 = QFont()
        font1.setPointSize(9)
        font1.setBold(True)
        font1.setKerning(True)
        self.log_button.setFont(font1)
        self.log_button.setCursor(QCursor(Qt.PointingHandCursor))
        self.log_button.setCheckable(False)
        self.log_button.setFlat(True)

        self.horizontalLayout_2.addWidget(self.log_button)


        self.main_layout.addLayout(self.horizontalLayout_2, 5, 2, 1, 1)

        self.shuttle_widget = QWidget(self.main_widget)
        self.shuttle_widget.setObjectName(u"shuttle_widget")
        self.shuttle_widget.setMinimumSize(QSize(600, 600))
        self.shuttle_widget.setMaximumSize(QSize(600, 600))
        self.shuttle_widget.setAutoFillBackground(False)
        self.shuttle_widget.setStyleSheet(u"QWidget#shuttle_widget {background: url(images/ShuttleXpress_Black.png);\n"
"        background-repeat:no-repeat;}\n"
"       ")
        self.button_1 = QCheckBox(self.shuttle_widget)
        self.button_1.setObjectName(u"button_1")
        self.button_1.setGeometry(QRect(80, 266, 24, 24))
        sizePolicy1.setHeightForWidth(self.button_1.sizePolicy().hasHeightForWidth())
        self.button_1.setSizePolicy(sizePolicy1)
        self.button_1.setMinimumSize(QSize(24, 24))
        self.button_1.setFont(font)
        self.button_1.setStyleSheet(u"background: #000000ff;\n"
"         color: white;\n"
"        ")
        self.usb_status = QPushButton(self.shuttle_widget)
        self.usb_status.setObjectName(u"usb_status")
        self.usb_status.setEnabled(False)
        self.usb_status.setGeometry(QRect(288, 10, 24, 24))
        sizePolicy1.setHeightForWidth(self.usb_status.sizePolicy().hasHeightForWidth())
        self.usb_status.setSizePolicy(sizePolicy1)
        self.usb_status.setMinimumSize(QSize(24, 24))
        self.usb_status.setFont(font1)
        self.usb_status.setCursor(QCursor(Qt.ArrowCursor))
        self.usb_status.setAutoFillBackground(False)
        self.usb_status.setText(u"")
        icon = QIcon()
        icon.addFile(u"images/usb_black_24.png", QSize(), QIcon.Disabled, QIcon.Off)
        icon.addFile(u"images/usb_white_24.png", QSize(), QIcon.Disabled, QIcon.On)
        self.usb_status.setIcon(icon)
        self.usb_status.setIconSize(QSize(24, 24))
        self.usb_status.setCheckable(True)
        self.usb_status.setChecked(False)
        self.usb_status.setFlat(True)
        self.button_5 = QCheckBox(self.shuttle_widget)
        self.button_5.setObjectName(u"button_5")
        self.button_5.setGeometry(QRect(498, 266, 24, 24))
        sizePolicy1.setHeightForWidth(self.button_5.sizePolicy().hasHeightForWidth())
        self.button_5.setSizePolicy(sizePolicy1)
        self.button_5.setMinimumSize(QSize(24, 24))
        self.button_5.setFont(font)
        self.button_5.setLayoutDirection(Qt.RightToLeft)
        self.button_5.setStyleSheet(u"background: #000000ff;\n"
"         color: white;\n"
"        ")
        self.wheel_pos4 = QRadioButton(self.shuttle_widget)
        self.wheel_pos4.setObjectName(u"wheel_pos4")
        self.wheel_pos4.setGeometry(QRect(382, 164, 24, 24))
        sizePolicy1.setHeightForWidth(self.wheel_pos4.sizePolicy().hasHeightForWidth())
        self.wheel_pos4.setSizePolicy(sizePolicy1)
        self.wheel_pos4.setMinimumSize(QSize(24, 24))
        self.wheel_pos4.setStyleSheet(u"background: #000000ff;\n"
"         color: white;\n"
"        ")
        self.wheel_cent0 = QRadioButton(self.shuttle_widget)
        self.wheel_cent0.setObjectName(u"wheel_cent0")
        self.wheel_cent0.setGeometry(QRect(289, 130, 24, 24))
        sizePolicy1.setHeightForWidth(self.wheel_cent0.sizePolicy().hasHeightForWidth())
        self.wheel_cent0.setSizePolicy(sizePolicy1)
        self.wheel_cent0.setMinimumSize(QSize(24, 24))
        self.wheel_cent0.setStyleSheet(u"background: #000000ff;\n"
"         color: white;\n"
"        ")
        self.wheel_cent0.setChecked(True)
        self.wheel_pos1 = QRadioButton(self.shuttle_widget)
        self.wheel_pos1.setObjectName(u"wheel_pos1")
        self.wheel_pos1.setGeometry(QRect(314, 133, 24, 24))
        sizePolicy1.setHeightForWidth(self.wheel_pos1.sizePolicy().hasHeightForWidth())
        self.wheel_pos1.setSizePolicy(sizePolicy1)
        self.wheel_pos1.setMinimumSize(QSize(24, 24))
        self.wheel_pos1.setStyleSheet(u"color: white;")
        self.wheel_pos2 = QRadioButton(self.shuttle_widget)
        self.wheel_pos2.setObjectName(u"wheel_pos2")
        self.wheel_pos2.setGeometry(QRect(338, 139, 24, 24))
        sizePolicy1.setHeightForWidth(self.wheel_pos2.sizePolicy().hasHeightForWidth())
        self.wheel_pos2.setSizePolicy(sizePolicy1)
        self.wheel_pos2.setMinimumSize(QSize(24, 24))
        self.wheel_pos2.setStyleSheet(u"background: #000000ff;\n"
"         color: white;\n"
"        ")
        self.dial = QDial(self.shuttle_widget)
        self.dial.setObjectName(u"dial")
        self.dial.setGeometry(QRect(197, 178, 216, 216))
        sizePolicy2 = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred)
        sizePolicy2.setHorizontalStretch(0)
        sizePolicy2.setVerticalStretch(0)
        sizePolicy2.setHeightForWidth(self.dial.sizePolicy().hasHeightForWidth())
        self.dial.setSizePolicy(sizePolicy2)
        self.dial.setMinimumSize(QSize(24, 24))
        self.dial.setAutoFillBackground(False)
        self.dial.setStyleSheet(u"background-color: black;")
        self.dial.setMinimum(0)
        self.dial.setMaximum(10)
        self.dial.setPageStep(1)
        self.dial.setValue(5)
        self.dial.setSliderPosition(5)
        self.dial.setInvertedAppearance(False)
        self.dial.setInvertedControls(False)
        self.dial.setWrapping(True)
        self.dial.setNotchTarget(3.700000000000000)
        self.dial.setNotchesVisible(False)
        self.wheel_neg6 = QRadioButton(self.shuttle_widget)
        self.wheel_neg6.setObjectName(u"wheel_neg6")
        self.wheel_neg6.setGeometry(QRect(162, 204, 24, 24))
        sizePolicy1.setHeightForWidth(self.wheel_neg6.sizePolicy().hasHeightForWidth())
        self.wheel_neg6.setSizePolicy(sizePolicy1)
        self.wheel_neg6.setMinimumSize(QSize(24, 24))
        self.wheel_neg6.setStyleSheet(u"color: white;")
        self.wheel_pos5 = QRadioButton(self.shuttle_widget)
        self.wheel_pos5.setObjectName(u"wheel_pos5")
        self.wheel_pos5.setGeometry(QRect(400, 182, 24, 24))
        sizePolicy1.setHeightForWidth(self.wheel_pos5.sizePolicy().hasHeightForWidth())
        self.wheel_pos5.setSizePolicy(sizePolicy1)
        self.wheel_pos5.setMinimumSize(QSize(24, 24))
        self.wheel_pos5.setStyleSheet(u"background: #000000ff;\n"
"         color: white;\n"
"        ")
        self.button_2 = QCheckBox(self.shuttle_widget)
        self.button_2.setObjectName(u"button_2")
        self.button_2.setGeometry(QRect(156, 122, 24, 24))
        sizePolicy1.setHeightForWidth(self.button_2.sizePolicy().hasHeightForWidth())
        self.button_2.setSizePolicy(sizePolicy1)
        self.button_2.setMinimumSize(QSize(24, 24))
        self.button_2.setFont(font)
        self.button_2.setStyleSheet(u"background: #000000ff;\n"
"         color: white;\n"
"        ")
        self.wheel_neg5 = QRadioButton(self.shuttle_widget)
        self.wheel_neg5.setObjectName(u"wheel_neg5")
        self.wheel_neg5.setGeometry(QRect(178, 182, 24, 24))
        sizePolicy1.setHeightForWidth(self.wheel_neg5.sizePolicy().hasHeightForWidth())
        self.wheel_neg5.setSizePolicy(sizePolicy1)
        self.wheel_neg5.setMinimumSize(QSize(24, 24))
        self.wheel_neg5.setStyleSheet(u"color: white;")
        self.wheel_pos6 = QRadioButton(self.shuttle_widget)
        self.wheel_pos6.setObjectName(u"wheel_pos6")
        self.wheel_pos6.setGeometry(QRect(416, 204, 24, 24))
        sizePolicy1.setHeightForWidth(self.wheel_pos6.sizePolicy().hasHeightForWidth())
        self.wheel_pos6.setSizePolicy(sizePolicy1)
        self.wheel_pos6.setMinimumSize(QSize(24, 24))
        self.wheel_pos6.setStyleSheet(u"background: #000000ff;\n"
"         color: white;\n"
"        ")
        self.wheel_neg1 = QRadioButton(self.shuttle_widget)
        self.wheel_neg1.setObjectName(u"wheel_neg1")
        self.wheel_neg1.setGeometry(QRect(264, 133, 24, 24))
        sizePolicy1.setHeightForWidth(self.wheel_neg1.sizePolicy().hasHeightForWidth())
        self.wheel_neg1.setSizePolicy(sizePolicy1)
        self.wheel_neg1.setMinimumSize(QSize(24, 24))
        self.wheel_neg1.setStyleSheet(u"background: #000000ff;\n"
"         color: white;\n"
"        ")
        self.button_4 = QCheckBox(self.shuttle_widget)
        self.button_4.setObjectName(u"button_4")
        self.button_4.setGeometry(QRect(430, 122, 24, 24))
        sizePolicy1.setHeightForWidth(self.button_4.sizePolicy().hasHeightForWidth())
        self.button_4.setSizePolicy(sizePolicy1)
        self.button_4.setMinimumSize(QSize(24, 24))
        self.button_4.setFont(font)
        self.button_4.setLayoutDirection(Qt.RightToLeft)
        self.button_4.setAutoFillBackground(False)
        self.button_4.setStyleSheet(u"background: #000000ff;\n"
"         color: white;\n"
"        ")
        self.wheel_pos7 = QRadioButton(self.shuttle_widget)
        self.wheel_pos7.setObjectName(u"wheel_pos7")
        self.wheel_pos7.setGeometry(QRect(427, 229, 24, 24))
        sizePolicy1.setHeightForWidth(self.wheel_pos7.sizePolicy().hasHeightForWidth())
        self.wheel_pos7.setSizePolicy(sizePolicy1)
        self.wheel_pos7.setMinimumSize(QSize(24, 24))
        self.wheel_pos7.setStyleSheet(u"background: #000000ff;\n"
"         color: white;\n"
"        ")
        self.button_3 = QCheckBox(self.shuttle_widget)
        self.button_3.setObjectName(u"button_3")
        self.button_3.setGeometry(QRect(290, 72, 24, 24))
        sizePolicy1.setHeightForWidth(self.button_3.sizePolicy().hasHeightForWidth())
        self.button_3.setSizePolicy(sizePolicy1)
        self.button_3.setMinimumSize(QSize(24, 24))
        self.button_3.setFont(font)
        self.button_3.setStyleSheet(u"background: #000000ff;\n"
"         color: white;\n"
"        ")
        self.button_3.setTristate(False)
        self.wheel_neg2 = QRadioButton(self.shuttle_widget)
        self.wheel_neg2.setObjectName(u"wheel_neg2")
        self.wheel_neg2.setGeometry(QRect(240, 139, 24, 24))
        sizePolicy1.setHeightForWidth(self.wheel_neg2.sizePolicy().hasHeightForWidth())
        self.wheel_neg2.setSizePolicy(sizePolicy1)
        self.wheel_neg2.setMinimumSize(QSize(24, 24))
        self.wheel_neg2.setStyleSheet(u"background: #000000ff;\n"
"         color: white;\n"
"        ")
        self.wheel_pos3 = QRadioButton(self.shuttle_widget)
        self.wheel_pos3.setObjectName(u"wheel_pos3")
        self.wheel_pos3.setGeometry(QRect(361, 149, 24, 24))
        sizePolicy1.setHeightForWidth(self.wheel_pos3.sizePolicy().hasHeightForWidth())
        self.wheel_pos3.setSizePolicy(sizePolicy1)
        self.wheel_pos3.setMinimumSize(QSize(24, 24))
        self.wheel_pos3.setStyleSheet(u"background: #000000ff;\n"
"         color: white;\n"
"        ")
        self.wheel_neg3 = QRadioButton(self.shuttle_widget)
        self.wheel_neg3.setObjectName(u"wheel_neg3")
        self.wheel_neg3.setGeometry(QRect(217, 149, 24, 24))
        sizePolicy1.setHeightForWidth(self.wheel_neg3.sizePolicy().hasHeightForWidth())
        self.wheel_neg3.setSizePolicy(sizePolicy1)
        self.wheel_neg3.setMinimumSize(QSize(24, 24))
        self.wheel_neg3.setStyleSheet(u"color: white;")
        self.wheel_neg4 = QRadioButton(self.shuttle_widget)
        self.wheel_neg4.setObjectName(u"wheel_neg4")
        self.wheel_neg4.setGeometry(QRect(196, 164, 24, 24))
        sizePolicy1.setHeightForWidth(self.wheel_neg4.sizePolicy().hasHeightForWidth())
        self.wheel_neg4.setSizePolicy(sizePolicy1)
        self.wheel_neg4.setMinimumSize(QSize(24, 24))
        self.wheel_neg4.setStyleSheet(u"background: #000000ff;\n"
"         color: white;\n"
"        ")
        self.wheel_neg7 = QRadioButton(self.shuttle_widget)
        self.wheel_neg7.setObjectName(u"wheel_neg7")
        self.wheel_neg7.setGeometry(QRect(151, 229, 24, 24))
        sizePolicy1.setHeightForWidth(self.wheel_neg7.sizePolicy().hasHeightForWidth())
        self.wheel_neg7.setSizePolicy(sizePolicy1)
        self.wheel_neg7.setMinimumSize(QSize(24, 24))
        self.wheel_neg7.setStyleSheet(u"color: white;")
        self.dial.raise_()
        self.button_1.raise_()
        self.usb_status.raise_()
        self.button_5.raise_()
        self.wheel_pos4.raise_()
        self.wheel_cent0.raise_()
        self.wheel_pos1.raise_()
        self.wheel_pos2.raise_()
        self.wheel_neg6.raise_()
        self.wheel_pos5.raise_()
        self.button_2.raise_()
        self.wheel_neg5.raise_()
        self.wheel_pos6.raise_()
        self.wheel_neg1.raise_()
        self.button_4.raise_()
        self.wheel_pos7.raise_()
        self.button_3.raise_()
        self.wheel_neg2.raise_()
        self.wheel_pos3.raise_()
        self.wheel_neg3.raise_()
        self.wheel_neg4.raise_()
        self.wheel_neg7.raise_()

        self.main_layout.addWidget(self.shuttle_widget, 3, 2, 1, 1)

        self.horizontalLayout = QHBoxLayout()
        self.horizontalLayout.setObjectName(u"horizontalLayout")
        self.about_button = QPushButton(self.main_widget)
        self.about_button.setObjectName(u"about_button")
        sizePolicy1.setHeightForWidth(self.about_button.sizePolicy().hasHeightForWidth())
        self.about_button.setSizePolicy(sizePolicy1)
        self.about_button.setMinimumSize(QSize(24, 24))
        self.about_button.setFont(font1)
        self.about_button.setCursor(QCursor(Qt.WhatsThisCursor))
        self.about_button.setCheckable(False)
        self.about_button.setFlat(True)

        self.horizontalLayout.addWidget(self.about_button)


        self.main_layout.addLayout(self.horizontalLayout, 1, 2, 1, 1)

        self.horizontalLayout_3 = QHBoxLayout()
        self.horizontalLayout_3.setObjectName(u"horizontalLayout_3")
        self.plug_button = QPushButton(self.main_widget)
        self.plug_button.setObjectName(u"plug_button")
        sizePolicy1.setHeightForWidth(self.plug_button.sizePolicy().hasHeightForWidth())
        self.plug_button.setSizePolicy(sizePolicy1)
        self.plug_button.setMinimumSize(QSize(24, 24))
        self.plug_button.setFont(font1)
        self.plug_button.setCursor(QCursor(Qt.PointingHandCursor))
        self.plug_button.setCheckable(False)
        self.plug_button.setFlat(True)

        self.horizontalLayout_3.addWidget(self.plug_button)


        self.main_layout.addLayout(self.horizontalLayout_3, 3, 1, 1, 1)

        self.verticalLayout = QVBoxLayout()
        self.verticalLayout.setObjectName(u"verticalLayout")
        self.conf_button = QPushButton(self.main_widget)
        self.conf_button.setObjectName(u"conf_button")
        sizePolicy1.setHeightForWidth(self.conf_button.sizePolicy().hasHeightForWidth())
        self.conf_button.setSizePolicy(sizePolicy1)
        self.conf_button.setMinimumSize(QSize(24, 24))
        self.conf_button.setFont(font1)
        self.conf_button.setCursor(QCursor(Qt.PointingHandCursor))
        self.conf_button.setCheckable(False)
        self.conf_button.setFlat(True)

        self.verticalLayout.addWidget(self.conf_button)


        self.main_layout.addLayout(self.verticalLayout, 3, 4, 1, 1)

        MainWindow.setCentralWidget(self.main_widget)
        self.statusbar = QStatusBar(MainWindow)
        self.statusbar.setObjectName(u"statusbar")
        self.statusbar.setMinimumSize(QSize(600, 0))
        MainWindow.setStatusBar(self.statusbar)
        self.about_widget = QDockWidget(MainWindow)
        self.about_widget.setObjectName(u"about_widget")
        self.about_widget.setEnabled(True)
        sizePolicy3 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        sizePolicy3.setHorizontalStretch(0)
        sizePolicy3.setVerticalStretch(0)
        sizePolicy3.setHeightForWidth(self.about_widget.sizePolicy().hasHeightForWidth())
        self.about_widget.setSizePolicy(sizePolicy3)
        self.about_widget.setMinimumSize(QSize(600, 600))
        self.about_widget.setVisible(True)
        self.about_widget.setFloating(False)
        self.about_widget.setFeatures(QDockWidget.DockWidgetClosable|QDockWidget.DockWidgetMovable)
        self.about_widget.setAllowedAreas(Qt.TopDockWidgetArea)
        self.about_layout = QWidget()
        self.about_layout.setObjectName(u"about_layout")
        sizePolicy3.setHeightForWidth(self.about_layout.sizePolicy().hasHeightForWidth())
        self.about_layout.setSizePolicy(sizePolicy3)
        self.about_layout.setAutoFillBackground(False)
        self.gridLayout_3 = QGridLayout(self.about_layout)
        self.gridLayout_3.setObjectName(u"gridLayout_3")
        self.about_text = QTextEdit(self.about_layout)
        self.about_text.setObjectName(u"about_text")
        self.about_text.setFocusPolicy(Qt.WheelFocus)
        self.about_text.setAcceptDrops(False)
        self.about_text.setStyleSheet(u"color: white;")
        self.about_text.setFrameShape(QFrame.StyledPanel)
        self.about_text.setFrameShadow(QFrame.Sunken)
        self.about_text.setUndoRedoEnabled(False)
        self.about_text.setReadOnly(True)
        self.about_text.setAcceptRichText(True)

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

        self.about_widget.setWidget(self.about_layout)
        MainWindow.addDockWidget(Qt.TopDockWidgetArea, self.about_widget)
        self.log_widget = QDockWidget(MainWindow)
        self.log_widget.setObjectName(u"log_widget")
        self.log_widget.setEnabled(True)
        self.log_widget.setMinimumSize(QSize(550, 158))
        self.log_widget.setFont(font)
        self.log_widget.setVisible(True)
        self.log_widget.setFloating(False)
        self.log_widget.setFeatures(QDockWidget.DockWidgetClosable|QDockWidget.DockWidgetFloatable|QDockWidget.DockWidgetMovable)
        self.log_widget.setAllowedAreas(Qt.BottomDockWidgetArea)
        self.log_layout = QWidget()
        self.log_layout.setObjectName(u"log_layout")
        sizePolicy4 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        sizePolicy4.setHorizontalStretch(0)
        sizePolicy4.setVerticalStretch(0)
        sizePolicy4.setHeightForWidth(self.log_layout.sizePolicy().hasHeightForWidth())
        self.log_layout.setSizePolicy(sizePolicy4)
        self.gridLayout_2 = QGridLayout(self.log_layout)
        self.gridLayout_2.setObjectName(u"gridLayout_2")
        self.log_content_layout = QVBoxLayout()
        self.log_content_layout.setObjectName(u"log_content_layout")
        self.log_content_layout.setSizeConstraint(QLayout.SetDefaultConstraint)
        self.log_text = QPlainTextEdit(self.log_layout)
        self.log_text.setObjectName(u"log_text")
        sizePolicy4.setHeightForWidth(self.log_text.sizePolicy().hasHeightForWidth())
        self.log_text.setSizePolicy(sizePolicy4)
        self.log_text.setMinimumSize(QSize(0, 0))
        self.log_text.setAcceptDrops(False)
        self.log_text.setFrameShape(QFrame.StyledPanel)
        self.log_text.setFrameShadow(QFrame.Sunken)
        self.log_text.setUndoRedoEnabled(False)
        self.log_text.setReadOnly(True)

        self.log_content_layout.addWidget(self.log_text)

        self.buttons_layout = QHBoxLayout()
        self.buttons_layout.setObjectName(u"buttons_layout")
        self.buttons_layout.setSizeConstraint(QLayout.SetDefaultConstraint)
        self.log_clear_button = QToolButton(self.log_layout)
        self.log_clear_button.setObjectName(u"log_clear_button")
        icon1 = QIcon()
        icon1.addFile(u"images/delete-sweep_24.png", QSize(), QIcon.Normal, QIcon.Off)
        self.log_clear_button.setIcon(icon1)
        self.log_clear_button.setIconSize(QSize(24, 24))

        self.buttons_layout.addWidget(self.log_clear_button)


        self.log_content_layout.addLayout(self.buttons_layout)


        self.gridLayout_2.addLayout(self.log_content_layout, 0, 0, 1, 1)

        self.log_widget.setWidget(self.log_layout)
        MainWindow.addDockWidget(Qt.BottomDockWidgetArea, self.log_widget)
        self.config_widget = QDockWidget(MainWindow)
        self.config_widget.setObjectName(u"config_widget")
        self.config_widget.setEnabled(True)
        self.config_widget.setMinimumSize(QSize(250, 600))
        self.config_widget.setFloating(False)
        self.config_widget.setFeatures(QDockWidget.DockWidgetClosable|QDockWidget.DockWidgetFloatable|QDockWidget.DockWidgetMovable)
        self.config_widget.setAllowedAreas(Qt.RightDockWidgetArea)
        self.config_layout = QWidget()
        self.config_layout.setObjectName(u"config_layout")
        self.gridLayout = QGridLayout(self.config_layout)
        self.gridLayout.setObjectName(u"gridLayout")
        self.config_content_layout = QFormLayout()
        self.config_content_layout.setObjectName(u"config_content_layout")

        self.gridLayout.addLayout(self.config_content_layout, 0, 0, 1, 1)

        self.config_widget.setWidget(self.config_layout)
        MainWindow.addDockWidget(Qt.RightDockWidgetArea, self.config_widget)
        self.plugins_widget = QDockWidget(MainWindow)
        self.plugins_widget.setObjectName(u"plugins_widget")
        self.plugins_widget.setMinimumSize(QSize(250, 600))
        self.plugins_widget.setAllowedAreas(Qt.LeftDockWidgetArea)
        self.dockWidgetContents = QWidget()
        self.dockWidgetContents.setObjectName(u"dockWidgetContents")
        self.plugins_widget.setWidget(self.dockWidgetContents)
        MainWindow.addDockWidget(Qt.LeftDockWidgetArea, self.plugins_widget)
        self.about_widget.raise_()
        self.log_widget.raise_()

        self.retranslateUi(MainWindow)

        self.usb_status.setDefault(False)


        QMetaObject.connectSlotsByName(MainWindow)
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()
Example #27
0
class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        if not MainWindow.objectName():
            MainWindow.setObjectName(u"MainWindow")
        MainWindow.resize(671, 496)
        self.help = QAction(MainWindow)
        self.help.setObjectName(u"help")
        self.centralwidget = QWidget(MainWindow)
        self.centralwidget.setObjectName(u"centralwidget")
        self.log_text = QTextEdit(self.centralwidget)
        self.log_text.setObjectName(u"log_text")
        self.log_text.setGeometry(QRect(0, 190, 671, 291))
        self.labe = QLabel(self.centralwidget)
        self.labe.setObjectName(u"labe")
        self.labe.setGeometry(QRect(30, 20, 54, 12))
        self.ssid = QLineEdit(self.centralwidget)
        self.ssid.setObjectName(u"ssid")
        self.ssid.setGeometry(QRect(70, 20, 131, 20))
        self.time = QLineEdit(self.centralwidget)
        self.time.setObjectName(u"time")
        self.time.setGeometry(QRect(540, 20, 91, 20))
        self.label_2 = QLabel(self.centralwidget)
        self.label_2.setObjectName(u"label_2")
        self.label_2.setGeometry(QRect(470, 20, 54, 12))
        self.password = QLineEdit(self.centralwidget)
        self.password.setObjectName(u"password")
        self.password.setGeometry(QRect(310, 20, 131, 20))
        self.label_3 = QLabel(self.centralwidget)
        self.label_3.setObjectName(u"label_3")
        self.label_3.setGeometry(QRect(240, 20, 54, 12))
        self.connect = QPushButton(self.centralwidget)
        self.connect.setObjectName(u"connect")
        self.connect.setGeometry(QRect(140, 60, 75, 23))
        self.disconnect = QPushButton(self.centralwidget)
        self.disconnect.setObjectName(u"disconnect")
        self.disconnect.setGeometry(QRect(250, 60, 75, 23))
        self.labe_2 = QLabel(self.centralwidget)
        self.labe_2.setObjectName(u"labe_2")
        self.labe_2.setGeometry(QRect(30, 120, 91, 16))
        self.cur_ssid = QTextEdit(self.centralwidget)
        self.cur_ssid.setObjectName(u"cur_ssid")
        self.cur_ssid.setGeometry(QRect(140, 110, 241, 31))
        self.label = QLabel(self.centralwidget)
        self.label.setObjectName(u"label")
        self.label.setGeometry(QRect(30, 160, 101, 16))
        self.interface_name = QTextEdit(self.centralwidget)
        self.interface_name.setObjectName(u"interface_name")
        self.interface_name.setGeometry(QRect(140, 150, 241, 31))
        self.label_4 = QLabel(self.centralwidget)
        self.label_4.setObjectName(u"label_4")
        self.label_4.setGeometry(QRect(450, 70, 54, 12))
        self.frequency = QLineEdit(self.centralwidget)
        self.frequency.setObjectName(u"frequency")
        self.frequency.setGeometry(QRect(540, 70, 91, 20))
        self.test = QPushButton(self.centralwidget)
        self.test.setObjectName(u"test")
        self.test.setGeometry(QRect(550, 110, 75, 23))
        self.label_5 = QLabel(self.centralwidget)
        self.label_5.setObjectName(u"label_5")
        self.label_5.setGeometry(QRect(470, 70, 61, 16))
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QMenuBar(MainWindow)
        self.menubar.setObjectName(u"menubar")
        self.menubar.setGeometry(QRect(0, 0, 671, 22))
        self.menuFile = QMenu(self.menubar)
        self.menuFile.setObjectName(u"menuFile")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QStatusBar(MainWindow)
        self.statusbar.setObjectName(u"statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.menubar.addAction(self.menuFile.menuAction())
        self.menuFile.addAction(self.help)
        self.menuFile.addSeparator()

        self.retranslateUi(MainWindow)

        QMetaObject.connectSlotsByName(MainWindow)

    # setupUi

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(
            QCoreApplication.translate("MainWindow", u"WIFI-Test", None))
        self.help.setText(
            QCoreApplication.translate("MainWindow",
                                       u"\u5e2e\u52a9\u4fe1\u606f", None))
        self.labe.setText(
            QCoreApplication.translate("MainWindow", u"SSID:", None))
        self.label_2.setText(
            QCoreApplication.translate("MainWindow", u"Time(s):", None))
        self.label_3.setText(
            QCoreApplication.translate("MainWindow", u"Password:"******"MainWindow", u"Connect", None))
        self.disconnect.setText(
            QCoreApplication.translate("MainWindow", u"Disconnect", None))
        self.labe_2.setText(
            QCoreApplication.translate("MainWindow", u"Connected SSID:", None))
        self.label.setText(
            QCoreApplication.translate("MainWindow", u"Interface Name:", None))
        self.label_4.setText("")
        self.test.setText(
            QCoreApplication.translate("MainWindow", u"Test", None))
        self.label_5.setText(
            QCoreApplication.translate("MainWindow", u"Frequency:", None))
        self.menuFile.setTitle(
            QCoreApplication.translate("MainWindow", u"help", None))
    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)
class Importador(QWidget):
    """GUI class for the BGG -> Ludopedia importer"""
    enable_editables = Signal(bool)
    alternative_chosen = Signal(object)

    def __init__(self, parent=None):
        super().__init__(parent)
        self.thread = QThread()
        self.worker = None
        grid_layout = QGridLayout(self)
        login_group_box = self.create_login_group()
        data_group_box = self.create_data_group()
        self.enable_editables.connect(login_group_box.setEnabled)
        self.enable_editables.connect(data_group_box.setEnabled)
        self.import_button = QPushButton('Importar', self)
        self.import_button.setEnabled(False)
        self.enable_editables.connect(self.import_button.setEnabled)
        self.import_button.clicked.connect(self.enable_editables)
        self.import_button.clicked.connect(self.load_data)
        self.bgg_user_line_edit.textChanged.connect(self.enable_import)
        self.ludo_mail_line_edit.textChanged.connect(self.enable_import)
        self.ludo_pass_line_edit.textChanged.connect(self.enable_import)
        grid_layout.addWidget(login_group_box, 1, 1, 1, 2)
        grid_layout.addWidget(data_group_box, 2, 1, 1, 2)
        grid_layout.addWidget(self.import_button, 8, 2)
        self.log_widget = QTextEdit(self)
        self.log_widget.setReadOnly(True)
        grid_layout.addWidget(self.log_widget, 9, 1, 30, 2)

    def create_qlineedit(self, text):
        """Creates a label with the given text and an accompanying line edit"""
        line_edit = QLineEdit(self)
        line_edit_label = QLabel(text, line_edit)
        line_edit_label.setBuddy(line_edit)
        return (line_edit, line_edit_label)

    def create_login_group(self):
        """Create labels and line edits for providing BGG and ludopedia login information"""
        (self.bgg_user_line_edit,
         bgg_user_label) = self.create_qlineedit('Usuario BoardGameGeek:')
        (self.ludo_mail_line_edit,
         ludo_mail_label) = self.create_qlineedit('E-mail Ludopedia:')
        (self.ludo_pass_line_edit,
         ludo_pass_label) = self.create_qlineedit('Senha Ludopedia:')
        self.ludo_pass_line_edit.setEchoMode(QLineEdit.PasswordEchoOnEdit)
        group_box = QGroupBox('Login')
        grid_layout = QGridLayout(group_box)
        grid_layout.addWidget(bgg_user_label, 1, 1)
        grid_layout.addWidget(self.bgg_user_line_edit, 1, 2)
        grid_layout.addWidget(ludo_mail_label, 2, 1)
        grid_layout.addWidget(self.ludo_mail_line_edit, 2, 2)
        grid_layout.addWidget(ludo_pass_label, 3, 1)
        grid_layout.addWidget(self.ludo_pass_line_edit, 3, 2)
        group_box.setLayout(grid_layout)
        return group_box

    def create_data_group(self):
        """Creates group for holding specific choice data selection"""
        button_group = QButtonGroup(self)
        button_group.setExclusive(True)
        colecao_radio_button = QRadioButton('Coleção')
        self.partidas_radio_button = QRadioButton('Partidas')
        colecao_radio_button.setChecked(True)
        button_group.addButton(colecao_radio_button)
        button_group.addButton(self.partidas_radio_button)
        (self.min_date_picker,
         min_date_label) = create_date_picker('À Partir de:', self)
        (self.max_date_picker,
         max_date_label) = create_date_picker('Até:', self)
        self.min_date_picker.dateChanged.connect(
            self.max_date_picker.setMinimumDate)
        colecao_radio_button.toggled.connect(self.min_date_picker.setDisabled)
        colecao_radio_button.toggled.connect(self.max_date_picker.setDisabled)
        self.map_users_button = QPushButton(
            'Ver mapa de usuarios BGG -> Ludopedia', self)
        self.map_users_button.setEnabled(False)
        self.map_users_button.clicked.connect(self.user_map)
        colecao_radio_button.toggled.connect(self.map_users_button.setDisabled)
        group_box = QGroupBox('Dados')
        grid_layout = QGridLayout(group_box)
        grid_layout.addWidget(colecao_radio_button, 1, 1)
        grid_layout.addWidget(self.partidas_radio_button, 1, 2)
        grid_layout.addWidget(min_date_label, 2, 1)
        grid_layout.addWidget(self.min_date_picker, 2, 2)
        grid_layout.addWidget(max_date_label, 3, 1)
        grid_layout.addWidget(self.max_date_picker, 3, 2)
        grid_layout.addWidget(self.map_users_button, 4, 1, 1, 2)
        group_box.setLayout(grid_layout)
        return group_box

    def enable_import(self):
        """Slot to toggle state of the import button"""
        self.import_button.setDisabled(not self.bgg_user_line_edit.text()
                                       or not self.ludo_mail_line_edit.text()
                                       or not self.ludo_pass_line_edit.text())

    def log_text(self, message_type, text):
        """Logs the given text to the QPlainTextWidget"""
        current_time = QTime.currentTime().toString()
        if message_type == MessageType.ERROR:
            self.log_widget.insertHtml(
                f'[{current_time}] {ERROR_HTML}{text}<br>')
        elif message_type == MessageType.GENERIC:
            self.log_widget.insertHtml(f'[{current_time}] {text}<br>')
        elif message_type == MessageType.DEBUG and ENABLE_DEBUG:
            self.log_widget.insertHtml(
                f'[{current_time}] {DEBUG_HTML}{text}<br>')

        self.log_widget.moveCursor(QTextCursor.End)
        if ENABLE_DEBUG:
            print(text)

    def disconnect_thread(self):
        """Disconnect the started signal from the thread"""
        self.thread.started.disconnect()

    def configure_thread(self, worker):
        """Does basic thread startup and cleanup configuration"""
        worker.finished.connect(self.thread.quit)
        worker.moveToThread(self.thread)
        self.thread.started.connect(worker.run)
        worker.message.connect(self.log_text)
        worker.finished.connect(self.disconnect_thread)
        worker.exit_on_error.connect(self.thread.quit)
        worker.exit_on_error.connect(lambda: self.enable_editables.emit(True))

    def load_data(self):
        """Load data from bgg"""
        try:
            (session, ludo_user_id) = self.login_ludopedia()
            bgg_user = self.bgg_user_line_edit.text()

            if self.partidas_radio_button.isChecked():
                current_date = format_qdate(QDate.currentDate())
                min_date = parse_date(
                    format_qdate(self.min_date_picker.date()), current_date)
                max_date = parse_date(
                    format_qdate(self.max_date_picker.date()), min_date)
                self.worker = BGGPlayFetcher(bgg_user, min_date, max_date)
                self.configure_thread(self.worker)
                self.worker.finished.connect(lambda plays: self.post_plays(
                    session, plays, bgg_user, ludo_user_id))
            else:
                self.worker = BGGColectionFetcher(bgg_user)
                self.configure_thread(self.worker)
                self.worker.finished.connect(
                    lambda bgg_collection: self.import_collection(
                        session, bgg_collection))
            self.thread.start()
        except InputError:
            self.enable_editables.emit(True)

    def show_play_table(self, plays):
        """Shows a table with all the plays to be imported, allowing user to select some to skip"""
        tree_model = PlayTableModel(plays)
        table_widget = QTableView()
        table_widget.setModel(tree_model)
        table_widget.verticalHeader().setVisible(False)
        table_view_header = table_widget.horizontalHeader()
        table_view_header.setStretchLastSection(True)
        for column in range(tree_model.columnCount()):
            column_size = tree_model.data(tree_model.index(0, column),
                                          PlayTableModel.SIZE_ROLE)
            table_view_header.resizeSection(column, column_size)
        table_widget_dialog = QDialog(self)
        table_widget_dialog.setModal(True)
        grid_layout = QGridLayout(table_widget_dialog)
        grid_layout.addWidget(table_widget, 1, 1)
        table_widget_dialog.resize(800, 600)
        table_widget_dialog.exec_()
        skipped_plays = tree_model.get_skipped_plays()
        return [play for play in plays if play.id not in skipped_plays]

    def post_plays(self, session, plays, bgg_user, ludo_user_id):
        """Receives plays from the Play Fetched thread and start the Ludopedia Logger"""
        user_map = self.get_bgg_to_ludo_users()
        if bgg_user not in user_map:
            user_map[bgg_user] = ludo_user_id

        selected_plays = self.show_play_table(plays)

        self.worker = LudopediaPlayLogger(session, selected_plays, bgg_user,
                                          user_map)
        self.worker.request_search.connect(
            self.request_search_and_show_alternatives,
            Qt.BlockingQueuedConnection)
        self.worker.request_alternative.connect(self.request_alternative,
                                                Qt.BlockingQueuedConnection)
        self.alternative_chosen.connect(self.worker.receive_alternative,
                                        Qt.DirectConnection)
        self.configure_thread(self.worker)
        self.worker.finished.connect(lambda: self.enable_editables.emit(True))
        self.thread.start()

    def user_map(self):
        """Slot to show user map from bgg to ludopedia"""
        user_map_dialog = QDialog(self)
        user_map_dialog.setModal(True)
        bgg_to_ludo = self.get_bgg_to_ludo_users()
        user_list = [f'{key} -> {value}' for key, value in bgg_to_ludo.items()]
        list_widget = QListWidget(user_map_dialog)
        list_widget.addItems(user_list)
        list_widget.setResizeMode(QListView.Adjust)
        list_widget.sortItems()
        grid_layout = QGridLayout(user_map_dialog)
        grid_layout.addWidget(list_widget, 1, 1)
        user_map_dialog.resize(400, 400)
        user_map_dialog.show()

    def login_ludopedia(self):
        """Logins into Ludopedia manually and returns the session and user_id"""
        self.log_text(MessageType.GENERIC, 'Obtendo dados do Ludopedia')
        payload = {
            'email': self.ludo_mail_line_edit.text(),
            'pass': self.ludo_pass_line_edit.text()
        }

        session = requests.Session()
        session_request = session.post(LUDOPEDIA_LOGIN_URL, data=payload)

        if 'senha incorretos' in session_request.text:
            self.log_text(
                MessageType.ERROR,
                'Não foi possível logar na Ludopedia com as informações fornecidas'
            )
            raise InputError

        user_re = re.search(r'id_usuario=(\d+)', session_request.text)
        user_id = user_re.group(1) if user_re else None

        return (session, user_id)

    def import_collection(self, session, collection):
        """Imports a given collection into Ludopedia"""
        self.worker = LudopediaCollectionLogger(session, collection)
        self.configure_thread(self.worker)
        self.worker.finished.connect(lambda: self.enable_editables.emit(True))
        self.thread.start()

    def show_alternatives_dialog(self, bgg_play, data):
        """Show alternative games to use as the game to log a play"""
        alternatives_dialog = QInputDialog(self)
        alternatives_list = [
            f'{item["nm_jogo"]} ({item["ano_publicacao"]})' for item in data
        ]
        alternatives_dialog.setComboBoxItems(alternatives_list)
        alternatives_dialog.setOption(QInputDialog.UseListViewForComboBoxItems)
        game_str = f'{bgg_play.game_name} ({bgg_play.year_published})'
        alternatives_dialog.setLabelText(
            f'Escolha uma alternativa para o jogo "{game_str}"')
        if alternatives_dialog.exec_():
            selected_index = alternatives_list.index(
                alternatives_dialog.textValue())
            return data[selected_index]
        return None

    def request_search_and_show_alternatives(self, session, bgg_play):
        """Request a new string to use for game search and then show results to be picked"""
        new_search_dialog = QInputDialog(self)
        game_str = f'{bgg_play.game_name} ({bgg_play.year_published})'
        new_search_dialog.setLabelText(
            f'Jogo "{game_str}" não encontrado\nBuscar por:')
        new_search_dialog.setInputMode(QInputDialog.TextInput)
        if new_search_dialog.exec_():
            data = search_ludopedia_games(session,
                                          new_search_dialog.textValue())
            data = self.show_alternatives_dialog(bgg_play, data)
            self.alternative_chosen.emit(data)

    def request_alternative(self, bgg_play, data):
        """Request an alternative from user and emit choice"""
        alternative = self.show_alternatives_dialog(bgg_play, data)
        self.alternative_chosen.emit(alternative)

    def get_bgg_to_ludo_users(self):
        """Reads usuarios.txt file to map a bgg user to its corresponding ludopedia one"""
        try:
            parser = ConfigParser()
            with open("usuarios.txt") as lines:
                lines = chain(("[top]", ), lines)
                parser.read_file(lines)
                bgg_to_ludo_user = dict(parser['top'])
                bgg_to_ludo_user_id = dict()
                for bgg_user, ludo_user in bgg_to_ludo_user.items():
                    if is_invalid_bgg_user(bgg_user):
                        self.log_text(
                            MessageType.ERROR,
                            f'Usuário do BGG "{bgg_user}" inválido'
                            f' no mapa de usuários')
                        continue

                    if ludo_user.isdigit():
                        bgg_to_ludo_user_id[bgg_user] = ludo_user
                        self.log_text(
                            MessageType.DEBUG,
                            f'Usuário do BGG "{bgg_user}" já mapeado'
                            f' ao id ludopedia: {ludo_user}')
                    else:
                        ludo_user_id = get_ludo_user_id(ludo_user)
                        if ludo_user_id:
                            self.log_text(MessageType.DEBUG,
                                          f'{ludo_user_id} para {ludo_user}')
                            bgg_to_ludo_user_id[bgg_user] = ludo_user_id
                        else:
                            self.log_text(
                                MessageType.ERROR,
                                f'Falha ao buscar id de usuario da'
                                f' ludopedia para "{ludo_user}"')
                return bgg_to_ludo_user_id
        except FileNotFoundError:
            self.log_error(
                MessageType.ERROR,
                'Não foi possível encontrar o arquivo "usuarios.txt')
            return {}
Example #30
0
class Ui_Dialog(object):
    def setupUi(self, Dialog):
        if not Dialog.objectName():
            Dialog.setObjectName(u"Dialog")
        Dialog.resize(1136, 733)
        self.formLayout = QFormLayout(Dialog)
        self.formLayout.setObjectName(u"formLayout")
        self.tableWidget = QTableWidget(Dialog)
        if (self.tableWidget.columnCount() < 4):
            self.tableWidget.setColumnCount(4)
        __qtablewidgetitem = QTableWidgetItem()
        self.tableWidget.setHorizontalHeaderItem(0, __qtablewidgetitem)
        __qtablewidgetitem1 = QTableWidgetItem()
        self.tableWidget.setHorizontalHeaderItem(1, __qtablewidgetitem1)
        __qtablewidgetitem2 = QTableWidgetItem()
        self.tableWidget.setHorizontalHeaderItem(2, __qtablewidgetitem2)
        __qtablewidgetitem3 = QTableWidgetItem()
        self.tableWidget.setHorizontalHeaderItem(3, __qtablewidgetitem3)
        self.tableWidget.setObjectName(u"tableWidget")
        self.tableWidget.setMinimumSize(QSize(0, 450))
        self.tableWidget.verticalHeader().setVisible(False)

        self.formLayout.setWidget(1, QFormLayout.SpanningRole, self.tableWidget)

        self.horizontalLayout = QHBoxLayout()
        self.horizontalLayout.setObjectName(u"horizontalLayout")
        self.textEdit = QTextEdit(Dialog)
        self.textEdit.setObjectName(u"textEdit")
        self.textEdit.setReadOnly(True)

        self.horizontalLayout.addWidget(self.textEdit)

        self.verticalLayout = QVBoxLayout()
        self.verticalLayout.setObjectName(u"verticalLayout")
        self.pushButton = QPushButton(Dialog)
        self.pushButton.setObjectName(u"pushButton")
        sizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.pushButton.sizePolicy().hasHeightForWidth())
        self.pushButton.setSizePolicy(sizePolicy)
        self.pushButton.setCursor(QCursor(Qt.PointingHandCursor))

        self.verticalLayout.addWidget(self.pushButton)

        self.pushButton_2 = QPushButton(Dialog)
        self.pushButton_2.setObjectName(u"pushButton_2")
        sizePolicy.setHeightForWidth(self.pushButton_2.sizePolicy().hasHeightForWidth())
        self.pushButton_2.setSizePolicy(sizePolicy)
        self.pushButton_2.setCursor(QCursor(Qt.PointingHandCursor))

        self.verticalLayout.addWidget(self.pushButton_2)


        self.horizontalLayout.addLayout(self.verticalLayout)


        self.formLayout.setLayout(0, QFormLayout.SpanningRole, self.horizontalLayout)

        self.buttonBox = QDialogButtonBox(Dialog)
        self.buttonBox.setObjectName(u"buttonBox")
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Ok)

        self.formLayout.setWidget(2, QFormLayout.FieldRole, self.buttonBox)


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

        QMetaObject.connectSlotsByName(Dialog)
    # setupUi

    def retranslateUi(self, Dialog):
        Dialog.setWindowTitle(QCoreApplication.translate("Dialog", u"popup_hyperv", None))
        ___qtablewidgetitem = self.tableWidget.horizontalHeaderItem(0)
        ___qtablewidgetitem.setText(QCoreApplication.translate("Dialog", u"\u529f\u80fd", None));
        ___qtablewidgetitem1 = self.tableWidget.horizontalHeaderItem(1)
        ___qtablewidgetitem1.setText(QCoreApplication.translate("Dialog", u"\u8bf4\u660e", None));
        ___qtablewidgetitem2 = self.tableWidget.horizontalHeaderItem(2)
        ___qtablewidgetitem2.setText(QCoreApplication.translate("Dialog", u"\u5f53\u524d\u503c", None));
        ___qtablewidgetitem3 = self.tableWidget.horizontalHeaderItem(3)
        ___qtablewidgetitem3.setText(QCoreApplication.translate("Dialog", u"\u4fee\u6539", None));
        self.pushButton.setText(QCoreApplication.translate("Dialog", u"\u5237\u65b0", None))
        self.pushButton_2.setText(QCoreApplication.translate("Dialog", u"\u4fee\u6539", None))