Ejemplo n.º 1
0
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 {}
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
class Ui_MainWindow(object):
    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)
    # setupUi

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"Contour ShuttleXpress", None))
        self.action_Quit.setText(QCoreApplication.translate("MainWindow", u"&Quit", None))
#if QT_CONFIG(tooltip)
        self.log_button.setToolTip("")
#endif // QT_CONFIG(tooltip)
#if QT_CONFIG(statustip)
        self.log_button.setStatusTip(QCoreApplication.translate("MainWindow", u"Log", None))
#endif // QT_CONFIG(statustip)
        self.log_button.setText(QCoreApplication.translate("MainWindow", u"//", None))
#if QT_CONFIG(statustip)
        self.button_1.setStatusTip(QCoreApplication.translate("MainWindow", u"Button 1", None))
#endif // QT_CONFIG(statustip)
        self.button_1.setText("")
#if QT_CONFIG(tooltip)
        self.usb_status.setToolTip("")
#endif // QT_CONFIG(tooltip)
#if QT_CONFIG(statustip)
        self.usb_status.setStatusTip(QCoreApplication.translate("MainWindow", u"USB connection status", None))
#endif // QT_CONFIG(statustip)
#if QT_CONFIG(whatsthis)
        self.usb_status.setWhatsThis(QCoreApplication.translate("MainWindow", u"USB Status", None))
#endif // QT_CONFIG(whatsthis)
#if QT_CONFIG(statustip)
        self.button_5.setStatusTip(QCoreApplication.translate("MainWindow", u"Button 5", None))
#endif // QT_CONFIG(statustip)
        self.button_5.setText("")
#if QT_CONFIG(statustip)
        self.wheel_pos4.setStatusTip(QCoreApplication.translate("MainWindow", u"Wheel position: right 4", None))
#endif // QT_CONFIG(statustip)
        self.wheel_pos4.setText("")
#if QT_CONFIG(statustip)
        self.wheel_cent0.setStatusTip(QCoreApplication.translate("MainWindow", u"Wheel position: center", None))
#endif // QT_CONFIG(statustip)
        self.wheel_cent0.setText("")
#if QT_CONFIG(statustip)
        self.wheel_pos1.setStatusTip(QCoreApplication.translate("MainWindow", u"Wheel position: right 1", None))
#endif // QT_CONFIG(statustip)
        self.wheel_pos1.setText("")
#if QT_CONFIG(statustip)
        self.wheel_pos2.setStatusTip(QCoreApplication.translate("MainWindow", u"Wheel position: right 2", None))
#endif // QT_CONFIG(statustip)
        self.wheel_pos2.setText("")
#if QT_CONFIG(statustip)
        self.dial.setStatusTip(QCoreApplication.translate("MainWindow", u"Dial", None))
#endif // QT_CONFIG(statustip)
#if QT_CONFIG(statustip)
        self.wheel_neg6.setStatusTip(QCoreApplication.translate("MainWindow", u"Wheel position: left 6", None))
#endif // QT_CONFIG(statustip)
        self.wheel_neg6.setText("")
#if QT_CONFIG(statustip)
        self.wheel_pos5.setStatusTip(QCoreApplication.translate("MainWindow", u"Wheel position: right 5", None))
#endif // QT_CONFIG(statustip)
        self.wheel_pos5.setText("")
#if QT_CONFIG(statustip)
        self.button_2.setStatusTip(QCoreApplication.translate("MainWindow", u"Button 2", None))
#endif // QT_CONFIG(statustip)
        self.button_2.setText("")
#if QT_CONFIG(statustip)
        self.wheel_neg5.setStatusTip(QCoreApplication.translate("MainWindow", u"Wheel position: left 5", None))
#endif // QT_CONFIG(statustip)
        self.wheel_neg5.setText("")
#if QT_CONFIG(statustip)
        self.wheel_pos6.setStatusTip(QCoreApplication.translate("MainWindow", u"Wheel position: right 6", None))
#endif // QT_CONFIG(statustip)
        self.wheel_pos6.setText("")
#if QT_CONFIG(statustip)
        self.wheel_neg1.setStatusTip(QCoreApplication.translate("MainWindow", u"Wheel position: left 1", None))
#endif // QT_CONFIG(statustip)
        self.wheel_neg1.setText("")
#if QT_CONFIG(statustip)
        self.button_4.setStatusTip(QCoreApplication.translate("MainWindow", u"Button 4", None))
#endif // QT_CONFIG(statustip)
        self.button_4.setText("")
#if QT_CONFIG(statustip)
        self.wheel_pos7.setStatusTip(QCoreApplication.translate("MainWindow", u"Wheel position: right 7", None))
#endif // QT_CONFIG(statustip)
        self.wheel_pos7.setText("")
#if QT_CONFIG(statustip)
        self.button_3.setStatusTip(QCoreApplication.translate("MainWindow", u"Button 3", None))
#endif // QT_CONFIG(statustip)
        self.button_3.setText("")
#if QT_CONFIG(statustip)
        self.wheel_neg2.setStatusTip(QCoreApplication.translate("MainWindow", u"Wheel position: left 2", None))
#endif // QT_CONFIG(statustip)
        self.wheel_neg2.setText("")
#if QT_CONFIG(statustip)
        self.wheel_pos3.setStatusTip(QCoreApplication.translate("MainWindow", u"Wheel position: right 3", None))
#endif // QT_CONFIG(statustip)
        self.wheel_pos3.setText("")
#if QT_CONFIG(statustip)
        self.wheel_neg3.setStatusTip(QCoreApplication.translate("MainWindow", u"Wheel position: left 3", None))
#endif // QT_CONFIG(statustip)
        self.wheel_neg3.setText("")
#if QT_CONFIG(statustip)
        self.wheel_neg4.setStatusTip(QCoreApplication.translate("MainWindow", u"Wheel position: left 4", None))
#endif // QT_CONFIG(statustip)
        self.wheel_neg4.setText(QCoreApplication.translate("MainWindow", u"-", None))
#if QT_CONFIG(statustip)
        self.wheel_neg7.setStatusTip(QCoreApplication.translate("MainWindow", u"Wheel position: left 7", None))
#endif // QT_CONFIG(statustip)
        self.wheel_neg7.setText("")
#if QT_CONFIG(tooltip)
        self.about_button.setToolTip("")
#endif // QT_CONFIG(tooltip)
#if QT_CONFIG(statustip)
        self.about_button.setStatusTip(QCoreApplication.translate("MainWindow", u"About", None))
#endif // QT_CONFIG(statustip)
        self.about_button.setText(QCoreApplication.translate("MainWindow", u"?", None))
#if QT_CONFIG(tooltip)
        self.plug_button.setToolTip("")
#endif // QT_CONFIG(tooltip)
#if QT_CONFIG(statustip)
        self.plug_button.setStatusTip(QCoreApplication.translate("MainWindow", u"Configuration", None))
#endif // QT_CONFIG(statustip)
        self.plug_button.setText(QCoreApplication.translate("MainWindow", u"#", None))
#if QT_CONFIG(tooltip)
        self.conf_button.setToolTip("")
#endif // QT_CONFIG(tooltip)
#if QT_CONFIG(statustip)
        self.conf_button.setStatusTip(QCoreApplication.translate("MainWindow", u"Configuration", None))
#endif // QT_CONFIG(statustip)
        self.conf_button.setText(QCoreApplication.translate("MainWindow", u"=", None))
        self.about_widget.setWindowTitle(QCoreApplication.translate("MainWindow", u"About", None))
        self.about_text.setDocumentTitle("")
        self.log_widget.setWindowTitle(QCoreApplication.translate("MainWindow", u"Log", None))
        self.log_clear_button.setText(QCoreApplication.translate("MainWindow", u"Clear", None))
        self.config_widget.setWindowTitle(QCoreApplication.translate("MainWindow", u"Configuration", None))
        self.plugins_widget.setWindowTitle(QCoreApplication.translate("MainWindow", u"Plugins", None))
Ejemplo n.º 4
0
Archivo: edit.py Proyecto: 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))
Ejemplo n.º 5
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()
Ejemplo n.º 6
0
class CsgoBindGenerator(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("CS:GO Bind Generator")
        self.setFixedSize(1700, 500)

        self.centralWidget = QWidget(self)
        self.setCentralWidget(self.centralWidget)
        self.layout = QGridLayout(self.centralWidget)
        self.centralWidget.setLayout(self.layout)

        self.create_GUI()

    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)
        #self.bound_keys: list = () #TODO bound keys

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

    def buy_clicked(self) -> None:
        self.action = "buy"

    def key_clicked(self, key_value: str) -> None:
        if self.action and not self.bind:
            if self.action == "buy":
                self.command += f"bind { key_value } "
                self.bind = True

            elif self.action == "bind_grenade":
                self.command += f"bind { key_value} "
                self.bind = True
                for key in self.grenade_keys:
                    key.setStyleSheet("background-color: #3f3f3f;")

            elif self.action == "bomb_drop":
                self.command += f'bind { key_value } "use weapon_knife; use weapon_c4; drop; slot1";\n'
                self.commands_display.setText(self.command)
                self.action = None

            elif self.action == "voice_mute":
                self.command += f"bindtoggle { key_value } voice_enable;\n"
                self.commands_display.setText(self.command)
                self.action = None

            elif self.action == "hand_switch":
                self.command += f'bind { key_value } "toggle cl_righthand 0 1";\n'
                self.commands_display.setText(self.command)
                self.action = None

            elif self.action == "clear_decals":
                self.command += f"bind { key_value } r_cleardecals;\n"
                self.commands_display.setText(self.command)
                self.action = None
        else:
            pass

    def gear_clicked(self, key_value: str) -> None:
        if self.action and self.bind:
            if self.action == "buy":
                self.command += f"{ key_value }\n"
                self.commands_display.setText(self.command)
                self.action = None
                self.bind = None

            elif self.action == "bind_grenade":
                new_key_value = key_value.replace("buy ", "use weapon_")
                self.command += f"{ new_key_value }\n"
                self.commands_display.setText(self.command)
                self.action = None
                self.bind = None
                for key in self.grenade_keys:
                    key.setStyleSheet("background-color: #2F2F2F;")
        else:
            pass

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

    def bind_grenade_clicked(self) -> None:
        self.action = "bind_grenade"

    def bomb_drop_clicked(self) -> None:
        self.action = "bomb_drop"

    def voice_mute_clicked(self) -> None:
        self.action = "voice_mute"

    def hand_switch_clicked(self) -> None:
        self.action = "hand_switch"

    def clear_decals_clicked(self) -> None:
        self.action = "clear_decals"

    def copy_clicked(self) -> None:
        QApplication.clipboard().setText(self.command.replace("\n", " "))

    def reset_clicked(self) -> None:
        self.commands_display.setText("")
        self.command = ""
        self.action = None
        self.bind = None
        self.action = None
        for key in self.grenade_keys:
            key.setStyleSheet("background-color: #2F2F2F;")
Ejemplo n.º 7
0
class LogWindow_Ui(QWidget):
    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'))
Ejemplo n.º 8
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())
Ejemplo n.º 9
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()
Ejemplo n.º 10
0
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))
Ejemplo n.º 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()
Ejemplo n.º 12
0
class AboutWindow_Ui(QWidget):
    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"))
Ejemplo n.º 13
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))
Ejemplo n.º 14
0
class DebugConsoleWidget(QWidget, DockContextHandler):
	def __init__(self, parent, name, data):
		if not type(data) == binaryninja.binaryview.BinaryView:
			raise Exception('expected widget data to be a BinaryView')

		self.bv = data

		QWidget.__init__(self, parent)
		DockContextHandler.__init__(self, self, name)
		self.actionHandler = UIActionHandler()
		self.actionHandler.setupActionHandler(self)

		layout = QVBoxLayout()
		self.consoleText = QTextEdit(self)
		self.consoleText.setReadOnly(True)
		self.consoleText.setFont(getMonospaceFont(self))
		layout.addWidget(self.consoleText, 1)

		inputLayout = QHBoxLayout()
		inputLayout.setContentsMargins(4, 4, 4, 4)

		promptLayout = QVBoxLayout()
		promptLayout.setContentsMargins(0, 5, 0, 5)

		inputLayout.addLayout(promptLayout)

		self.consoleEntry = QLineEdit(self)
		inputLayout.addWidget(self.consoleEntry, 1)

		self.entryLabel = QLabel("dbg>>> ", self)
		self.entryLabel.setFont(getMonospaceFont(self))
		promptLayout.addWidget(self.entryLabel)
		promptLayout.addStretch(1)

		self.consoleEntry.returnPressed.connect(lambda: self.sendLine())

		layout.addLayout(inputLayout)
		layout.setContentsMargins(0, 0, 0, 0)
		layout.setSpacing(0)
		self.setLayout(layout)

	def sizeHint(self):
		return QSize(300, 100)

	def canWrite(self):
		debug_state = binjaplug.get_state(self.bv)
		try:
			return debug_state.adapter.stdin_is_writable()
		except:
			return False

	def sendLine(self):
		if not self.canWrite():
			return

		line = self.consoleEntry.text()
		self.consoleEntry.setText("")

		debug_state = binjaplug.get_state(self.bv)
		try:
			debug_state.send_console_input(line)
		except Exception as e:
			self.notifyStdout("Error sending input: {} {}\n".format(type(e).__name__, ' '.join(e.args)))

	def notifyStdout(self, line):
		self.consoleText.insertPlainText(line)

		# Scroll down
		cursor = self.consoleText.textCursor()
		cursor.clearSelection()
		cursor.movePosition(QTextCursor.End)
		self.consoleText.setTextCursor(cursor)

		self.updateEnabled()

	def updateEnabled(self):
		enabled = self.canWrite()
		self.consoleEntry.setEnabled(enabled)
		self.entryLabel.setText("stdin>>> " if enabled else "stdin (unavailable) ")

	#--------------------------------------------------------------------------
	# callbacks to us api/ui/dockhandler.h
	#--------------------------------------------------------------------------
	def notifyOffsetChanged(self, offset):
		self.updateEnabled()

	def notifyViewChanged(self, view_frame):
		self.updateEnabled()

	def contextMenuEvent(self, event):
		self.m_contextMenuManager.show(self.m_menu, self.actionHandler)

	def shouldBeVisible(self, view_frame):
		if view_frame is None:
			return False
		else:
			return True