def check_extracted_game(input_file_edit: QLineEdit, input_file_button: QPushButton, contents_file_path: Path) -> bool: prompt_input_file = not has_internal_copy(contents_file_path) input_file_edit.setEnabled(prompt_input_file) if prompt_input_file: input_file_button.setText("Select File") else: input_file_button.setText("Delete internal copy") input_file_edit.setText(_VALID_GAME_TEXT) return prompt_input_file
def setup_ui(self): super(FontUI, self).setup_ui() sys_radio = QRadioButton("系统字体") sys_radio.setChecked(True) font_combo = QComboBox() for item in self.system_fonts: font_combo.addItem(item[1]) font_combo.setCurrentIndex(0) font_combo.currentIndexChanged.connect(self.refresh_font) custom_radio = QRadioButton("自选字体") custom_radio.setCheckable(True) custom_radio.setChecked(False) custom_radio.toggled.connect(self.on_custom_radio_toggled) custom_edit = QLineEdit() custom_edit.setPlaceholderText("自定义字体(*.ttf, *.otf)") custom_edit.setReadOnly(True) custom_edit.setEnabled(False) custom_btn = QPushButton(text="浏览") custom_btn.setEnabled(False) custom_btn.clicked.connect(self.on_custom_clicked) font_group = QButtonGroup(self) font_group.addButton(sys_radio, 0) font_group.addButton(custom_radio, 1) font_group.setExclusive(True) input_label = QLabel("输出字符") input_edit = MLineEdit() import_btn = QPushButton(text="从文本文件导入") import_btn.clicked.connect(self.on_import_btn_clicked) self.main_layout.setColumnStretch(1, 1) self.main_layout.addWidget(sys_radio, 1, 0, 1, 1) self.main_layout.addWidget(font_combo, 1, 1, 1, 2) self.main_layout.addWidget(custom_radio, 2, 0, 1, 1) self.main_layout.addWidget(custom_edit, 2, 1, 1, 1) self.main_layout.addWidget(custom_btn, 2, 2, 1, 1) self.main_layout.addWidget(input_label, 3, 0, 1, 1) self.main_layout.addWidget(import_btn, 3, 2, 1, 1) self.main_layout.addWidget(input_edit, 4, 0, 1, 3) self.input_edit = input_edit self.font_combo = font_combo self.custom_btn = custom_btn self.custom_edit = custom_edit self.refresh_font()
class FileField(BaseFieldMixin, QHBoxLayout): def __init__(self, tab, config_path): self.name_field = QLineEdit() self.name_field.setEnabled(False) self.file_button = QPushButton("Select") self.file_button.clicked.connect(self.on_select_clicked) super().__init__(tab, config_path) self.addWidget(self.name_field) self.addWidget(self.file_button) def on_select_clicked(self): if self.main_window.config.path: config_dir = os.path.dirname(self.main_window.config.path) else: config_dir = os.getcwd() file_path = QFileDialog.getSaveFileName( self.tab, caption="Select a file...", dir=config_dir, options=QFileDialog.DontConfirmOverwrite, )[0] if file_path: self.name_field.setText(os.path.relpath(file_path, config_dir)) @property def change_signal(self): return self.name_field.textChanged def on_change(self, t): self.main_window.set_working_value(self.config_path, t) def update_ui_from_config(self, config): new_value = config.get_template_resolved_value(self.config_path, "") if new_value != self.name_field.text: self.name_field.setText(new_value) def show(self): self.file_button.show() self.name_field.show() def hide(self): self.file_button.hide() self.name_field.hide()
class ReferenceDialog(QDialog): def __init__(self, parent): super().__init__(parent) self.setWindowTitle("Set reference") vbox = QVBoxLayout(self) grid = QGridLayout() self.average = QRadioButton("Average") self.channels = QRadioButton("Channel(s):") self.average.toggled.connect(self.toggle) self.channellist = QLineEdit() self.channellist.setEnabled(False) self.average.setChecked(True) grid.addWidget(self.average, 0, 0) grid.addWidget(self.channels, 1, 0) grid.addWidget(self.channellist, 1, 1) vbox.addLayout(grid) buttonbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) vbox.addWidget(buttonbox) buttonbox.accepted.connect(self.accept) buttonbox.rejected.connect(self.reject) vbox.setSizeConstraint(QVBoxLayout.SetFixedSize) def toggle(self): if self.average.isChecked(): self.channellist.setEnabled(False) else: self.channellist.setEnabled(True)
class AdapterSettingsDialog(QDialog): def __init__(self, parent, data): assert type(data) == BinaryView self.bv = data QDialog.__init__(self, parent) debug_state = binjaplug.get_state(self.bv) self.setWindowTitle("Debug Adapter Settings") self.setMinimumSize(UIContext.getScaledWindowSize(400, 130)) self.setAttribute(Qt.WA_DeleteOnClose) layout = QVBoxLayout() layout.setSpacing(0) titleLabel = QLabel("Adapter Settings") titleLayout = QHBoxLayout() titleLayout.setContentsMargins(0, 0, 0, 0) titleLayout.addWidget(titleLabel) self.adapterEntry = QPushButton(self) self.adapterMenu = QMenu(self) for adapter in DebugAdapter.ADAPTER_TYPE: if not DebugAdapter.ADAPTER_TYPE.can_use(adapter): continue def select_adapter(adapter): return lambda: self.selectAdapter(adapter) self.adapterMenu.addAction(adapter.name, select_adapter(adapter)) if adapter == debug_state.adapter_type: self.adapterEntry.setText(adapter.name) self.adapterEntry.setMenu(self.adapterMenu) self.argumentsEntry = QLineEdit(self) self.addressEntry = QLineEdit(self) self.portEntry = QLineEdit(self) self.requestTerminalEmulator = QCheckBox(self) self.formLayout = QFormLayout() self.formLayout.addRow("Adapter Type", self.adapterEntry) self.formLayout.addRow("Command Line Arguments", self.argumentsEntry) self.formLayout.addRow("Address", self.addressEntry) self.formLayout.addRow("Port", self.portEntry) self.formLayout.addRow("Request Terminal Emulator", self.requestTerminalEmulator) buttonLayout = QHBoxLayout() buttonLayout.setContentsMargins(0, 0, 0, 0) self.cancelButton = QPushButton("Cancel") self.cancelButton.clicked.connect(lambda: self.reject()) self.acceptButton = QPushButton("Accept") self.acceptButton.clicked.connect(lambda: self.accept()) self.acceptButton.setDefault(True) buttonLayout.addStretch(1) buttonLayout.addWidget(self.cancelButton) buttonLayout.addWidget(self.acceptButton) layout.addLayout(titleLayout) layout.addSpacing(10) layout.addLayout(self.formLayout) layout.addStretch(1) layout.addSpacing(10) layout.addLayout(buttonLayout) self.setLayout(layout) self.addressEntry.setText(debug_state.remote_host) self.portEntry.setText(str(debug_state.remote_port)) self.addressEntry.textEdited.connect(lambda: self.apply()) self.portEntry.textEdited.connect(lambda: self.apply()) self.argumentsEntry.setText(' '.join( shlex.quote(arg) for arg in debug_state.command_line_args)) self.argumentsEntry.textEdited.connect(lambda: self.updateArguments()) self.requestTerminalEmulator.setChecked( debug_state.request_terminal_emulator) self.requestTerminalEmulator.stateChanged.connect(lambda: self.apply()) self.accepted.connect(lambda: self.apply()) def selectAdapter(self, adapter): self.bv.store_metadata('debugger.adapter_type', adapter.value) debug_state = binjaplug.get_state(self.bv) debug_state.adapter_type = adapter self.adapterEntry.setText(adapter.name) if DebugAdapter.ADAPTER_TYPE.use_exec(adapter): self.argumentsEntry.setEnabled(True) self.addressEntry.setEnabled(False) self.portEntry.setEnabled(False) elif DebugAdapter.ADAPTER_TYPE.use_connect(adapter): self.argumentsEntry.setEnabled(False) self.addressEntry.setEnabled(True) self.portEntry.setEnabled(True) def apply(self): debug_state = binjaplug.get_state(self.bv) arguments = shlex.split(self.argumentsEntry.text()) debug_state.command_line_args = arguments self.bv.store_metadata('debugger.command_line_args', arguments) address = self.addressEntry.text() port = int(self.portEntry.text()) debug_state.remote_host = address debug_state.remote_port = port self.bv.store_metadata('debugger.remote_host', address) self.bv.store_metadata('debugger.remote_port', port) request_terminal_emulator = self.requestTerminalEmulator.isChecked() debug_state.request_terminal_emulator = request_terminal_emulator self.bv.store_metadata('debugger.request_terminal_emulator', request_terminal_emulator) def updateArguments(self): try: arguments = shlex.split(self.argumentsEntry.text()) self.acceptButton.setEnabled(True) except: self.acceptButton.setEnabled(False)
class Ui_ProjectSettings_UI(object): def setupUi(self, ProjectSettings_UI): if not ProjectSettings_UI.objectName(): ProjectSettings_UI.setObjectName(u"ProjectSettings_UI") ProjectSettings_UI.resize(575, 685) self.gridLayout_3 = QGridLayout(ProjectSettings_UI) self.gridLayout_3.setObjectName(u"gridLayout_3") self.buttonBox = QDialogButtonBox(ProjectSettings_UI) self.buttonBox.setObjectName(u"buttonBox") self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) self.gridLayout_3.addWidget(self.buttonBox, 2, 0, 1, 1) self.tabWidget = QTabWidget(ProjectSettings_UI) self.tabWidget.setObjectName(u"tabWidget") self.tabWidget.setDocumentMode(True) self.tab = QWidget() self.tab.setObjectName(u"tab") self.gridLayout = QGridLayout(self.tab) self.gridLayout.setObjectName(u"gridLayout") self.previewparams = QPlainTextEdit(self.tab) self.previewparams.setObjectName(u"previewparams") sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.previewparams.sizePolicy().hasHeightForWidth()) self.previewparams.setSizePolicy(sizePolicy) self.previewparams.setReadOnly(True) self.gridLayout.addWidget(self.previewparams, 7, 0, 1, 4) self.label_2 = QLabel(self.tab) self.label_2.setObjectName(u"label_2") self.gridLayout.addWidget(self.label_2, 5, 0, 1, 1) self.audio_thumbs = QCheckBox(self.tab) self.audio_thumbs.setObjectName(u"audio_thumbs") self.gridLayout.addWidget(self.audio_thumbs, 5, 2, 1, 1) self.horizontalLayout_2 = QHBoxLayout() self.horizontalLayout_2.setObjectName(u"horizontalLayout_2") self.label_7 = QLabel(self.tab) self.label_7.setObjectName(u"label_7") self.horizontalLayout_2.addWidget(self.label_7) self.video_tracks = QSpinBox(self.tab) self.video_tracks.setObjectName(u"video_tracks") self.horizontalLayout_2.addWidget(self.video_tracks) self.label_8 = QLabel(self.tab) self.label_8.setObjectName(u"label_8") self.horizontalLayout_2.addWidget(self.label_8) self.audio_tracks = QSpinBox(self.tab) self.audio_tracks.setObjectName(u"audio_tracks") self.horizontalLayout_2.addWidget(self.audio_tracks) self.label = QLabel(self.tab) self.label.setObjectName(u"label") self.horizontalLayout_2.addWidget(self.label) self.audio_channels = QComboBox(self.tab) self.audio_channels.addItem("") self.audio_channels.addItem("") self.audio_channels.addItem("") self.audio_channels.setObjectName(u"audio_channels") sizePolicy1 = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) sizePolicy1.setHorizontalStretch(0) sizePolicy1.setVerticalStretch(0) sizePolicy1.setHeightForWidth( self.audio_channels.sizePolicy().hasHeightForWidth()) self.audio_channels.setSizePolicy(sizePolicy1) self.horizontalLayout_2.addWidget(self.audio_channels) self.gridLayout.addLayout(self.horizontalLayout_2, 4, 0, 1, 4) self.horizontalSpacer = QSpacerItem(229, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.gridLayout.addItem(self.horizontalSpacer, 5, 3, 1, 1) self.profile_box = QGroupBox(self.tab) self.profile_box.setObjectName(u"profile_box") sizePolicy2 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.MinimumExpanding) sizePolicy2.setHorizontalStretch(0) sizePolicy2.setVerticalStretch(0) sizePolicy2.setHeightForWidth( self.profile_box.sizePolicy().hasHeightForWidth()) self.profile_box.setSizePolicy(sizePolicy2) self.profile_box.setFlat(True) self.gridLayout.addWidget(self.profile_box, 3, 0, 1, 4) self.label_4 = QLabel(self.tab) self.label_4.setObjectName(u"label_4") self.gridLayout.addWidget(self.label_4, 0, 0, 1, 4) self.video_thumbs = QCheckBox(self.tab) self.video_thumbs.setObjectName(u"video_thumbs") self.gridLayout.addWidget(self.video_thumbs, 5, 1, 1, 1) self.horizontalLayout_4 = QHBoxLayout() self.horizontalLayout_4.setObjectName(u"horizontalLayout_4") self.label_25 = QLabel(self.tab) self.label_25.setObjectName(u"label_25") sizePolicy3 = QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Preferred) sizePolicy3.setHorizontalStretch(0) sizePolicy3.setVerticalStretch(0) sizePolicy3.setHeightForWidth( self.label_25.sizePolicy().hasHeightForWidth()) self.label_25.setSizePolicy(sizePolicy3) self.horizontalLayout_4.addWidget(self.label_25) self.preview_profile = KComboBox(self.tab) self.preview_profile.setObjectName(u"preview_profile") sizePolicy1.setHeightForWidth( self.preview_profile.sizePolicy().hasHeightForWidth()) self.preview_profile.setSizePolicy(sizePolicy1) self.horizontalLayout_4.addWidget(self.preview_profile) self.preview_showprofileinfo = QToolButton(self.tab) self.preview_showprofileinfo.setObjectName(u"preview_showprofileinfo") self.preview_showprofileinfo.setCheckable(True) self.horizontalLayout_4.addWidget(self.preview_showprofileinfo) self.preview_manageprofile = QToolButton(self.tab) self.preview_manageprofile.setObjectName(u"preview_manageprofile") self.horizontalLayout_4.addWidget(self.preview_manageprofile) self.gridLayout.addLayout(self.horizontalLayout_4, 6, 0, 1, 4) self.horizontalLayout = QHBoxLayout() self.horizontalLayout.setObjectName(u"horizontalLayout") self.custom_folder = QCheckBox(self.tab) self.custom_folder.setObjectName(u"custom_folder") self.horizontalLayout.addWidget(self.custom_folder) self.project_folder = KUrlRequester(self.tab) self.project_folder.setObjectName(u"project_folder") self.project_folder.setEnabled(False) self.horizontalLayout.addWidget(self.project_folder) self.gridLayout.addLayout(self.horizontalLayout, 1, 0, 1, 4) self.same_folder = QCheckBox(self.tab) self.same_folder.setObjectName(u"same_folder") self.gridLayout.addWidget(self.same_folder, 2, 0, 1, 4) self.tabWidget.addTab(self.tab, "") self.label_4.raise_() self.profile_box.raise_() self.label_2.raise_() self.video_thumbs.raise_() self.audio_thumbs.raise_() self.previewparams.raise_() self.same_folder.raise_() self.tab_4 = QWidget() self.tab_4.setObjectName(u"tab_4") self.verticalLayout = QVBoxLayout(self.tab_4) self.verticalLayout.setObjectName(u"verticalLayout") self.enable_proxy = QCheckBox(self.tab_4) self.enable_proxy.setObjectName(u"enable_proxy") self.verticalLayout.addWidget(self.enable_proxy) self.proxy_box = QGroupBox(self.tab_4) self.proxy_box.setObjectName(u"proxy_box") self.proxy_box.setEnabled(False) self.proxy_box.setFlat(True) self.proxy_box.setCheckable(False) self.proxy_box.setChecked(False) self.gridLayout_2 = QGridLayout(self.proxy_box) self.gridLayout_2.setObjectName(u"gridLayout_2") self.gridLayout_2.setHorizontalSpacing(6) self.gridLayout_2.setContentsMargins(0, 0, 0, 0) self.l_relPathProxyToOrig = QLabel(self.proxy_box) self.l_relPathProxyToOrig.setObjectName(u"l_relPathProxyToOrig") self.gridLayout_2.addWidget(self.l_relPathProxyToOrig, 10, 1, 1, 1) self.generate_imageproxy = QCheckBox(self.proxy_box) self.generate_imageproxy.setObjectName(u"generate_imageproxy") self.gridLayout_2.addWidget(self.generate_imageproxy, 3, 0, 1, 2) self.l_prefix_proxy = QLabel(self.proxy_box) self.l_prefix_proxy.setObjectName(u"l_prefix_proxy") self.gridLayout_2.addWidget(self.l_prefix_proxy, 11, 1, 1, 1) self.proxy_imagesize = QSpinBox(self.proxy_box) self.proxy_imagesize.setObjectName(u"proxy_imagesize") self.proxy_imagesize.setEnabled(False) self.proxy_imagesize.setMinimum(200) self.proxy_imagesize.setMaximum(100000) self.proxy_imagesize.setValue(800) self.gridLayout_2.addWidget(self.proxy_imagesize, 4, 2, 1, 4) self.label_24 = QLabel(self.proxy_box) self.label_24.setObjectName(u"label_24") sizePolicy3.setHeightForWidth( self.label_24.sizePolicy().hasHeightForWidth()) self.label_24.setSizePolicy(sizePolicy3) self.gridLayout_2.addWidget(self.label_24, 1, 0, 1, 1) self.proxy_minsize = QSpinBox(self.proxy_box) self.proxy_minsize.setObjectName(u"proxy_minsize") self.proxy_minsize.setMaximum(10000) self.proxy_minsize.setValue(1000) self.gridLayout_2.addWidget(self.proxy_minsize, 0, 2, 1, 4) self.l_prefix_clip = QLabel(self.proxy_box) self.l_prefix_clip.setObjectName(u"l_prefix_clip") self.gridLayout_2.addWidget(self.l_prefix_clip, 8, 1, 1, 1) self.proxy_profile = KComboBox(self.proxy_box) self.proxy_profile.setObjectName(u"proxy_profile") sizePolicy1.setHeightForWidth( self.proxy_profile.sizePolicy().hasHeightForWidth()) self.proxy_profile.setSizePolicy(sizePolicy1) self.gridLayout_2.addWidget(self.proxy_profile, 1, 1, 1, 2) self.proxy_showprofileinfo = QToolButton(self.proxy_box) self.proxy_showprofileinfo.setObjectName(u"proxy_showprofileinfo") self.proxy_showprofileinfo.setCheckable(True) self.gridLayout_2.addWidget(self.proxy_showprofileinfo, 1, 4, 1, 1) self.generate_proxy = QCheckBox(self.proxy_box) self.generate_proxy.setObjectName(u"generate_proxy") self.gridLayout_2.addWidget(self.generate_proxy, 0, 0, 1, 2) self.proxyparams = QPlainTextEdit(self.proxy_box) self.proxyparams.setObjectName(u"proxyparams") sizePolicy.setHeightForWidth( self.proxyparams.sizePolicy().hasHeightForWidth()) self.proxyparams.setSizePolicy(sizePolicy) self.proxyparams.setReadOnly(True) self.gridLayout_2.addWidget(self.proxyparams, 2, 0, 1, 6) self.image_label = QLabel(self.proxy_box) self.image_label.setObjectName(u"image_label") self.image_label.setEnabled(False) self.gridLayout_2.addWidget(self.image_label, 4, 0, 1, 2) self.le_relPathProxyToOrig = QLineEdit(self.proxy_box) self.le_relPathProxyToOrig.setObjectName(u"le_relPathProxyToOrig") self.le_relPathProxyToOrig.setEnabled(False) self.gridLayout_2.addWidget(self.le_relPathProxyToOrig, 10, 3, 1, 1) self.le_prefix_proxy = QLineEdit(self.proxy_box) self.le_prefix_proxy.setObjectName(u"le_prefix_proxy") self.le_prefix_proxy.setEnabled(False) self.gridLayout_2.addWidget(self.le_prefix_proxy, 11, 3, 1, 1) self.l_suffix_proxy = QLabel(self.proxy_box) self.l_suffix_proxy.setObjectName(u"l_suffix_proxy") self.gridLayout_2.addWidget(self.l_suffix_proxy, 12, 1, 1, 1) self.le_prefix_clip = QLineEdit(self.proxy_box) self.le_prefix_clip.setObjectName(u"le_prefix_clip") self.le_prefix_clip.setEnabled(False) self.gridLayout_2.addWidget(self.le_prefix_clip, 8, 3, 1, 1) self.le_suffix_proxy = QLineEdit(self.proxy_box) self.le_suffix_proxy.setObjectName(u"le_suffix_proxy") self.le_suffix_proxy.setEnabled(False) self.gridLayout_2.addWidget(self.le_suffix_proxy, 12, 3, 1, 1) self.proxy_imageminsize = QSpinBox(self.proxy_box) self.proxy_imageminsize.setObjectName(u"proxy_imageminsize") self.proxy_imageminsize.setMinimum(500) self.proxy_imageminsize.setMaximum(100000) self.proxy_imageminsize.setValue(2000) self.gridLayout_2.addWidget(self.proxy_imageminsize, 3, 2, 1, 4) self.l_suffix_clip = QLabel(self.proxy_box) self.l_suffix_clip.setObjectName(u"l_suffix_clip") self.gridLayout_2.addWidget(self.l_suffix_clip, 9, 1, 1, 1) self.l_relPathOrigToProxy = QLabel(self.proxy_box) self.l_relPathOrigToProxy.setObjectName(u"l_relPathOrigToProxy") self.gridLayout_2.addWidget(self.l_relPathOrigToProxy, 7, 1, 1, 1) self.le_relPathOrigToProxy = QLineEdit(self.proxy_box) self.le_relPathOrigToProxy.setObjectName(u"le_relPathOrigToProxy") self.le_relPathOrigToProxy.setEnabled(False) self.gridLayout_2.addWidget(self.le_relPathOrigToProxy, 7, 3, 1, 1) self.external_proxy_profile = QComboBox(self.proxy_box) self.external_proxy_profile.setObjectName(u"external_proxy_profile") self.gridLayout_2.addWidget(self.external_proxy_profile, 6, 1, 1, 5) self.proxy_resize = QSpinBox(self.proxy_box) self.proxy_resize.setObjectName(u"proxy_resize") self.proxy_resize.setMinimum(200) self.proxy_resize.setMaximum(100000) self.gridLayout_2.addWidget(self.proxy_resize, 5, 2, 1, 4) self.le_suffix_clip = QLineEdit(self.proxy_box) self.le_suffix_clip.setObjectName(u"le_suffix_clip") self.le_suffix_clip.setEnabled(False) self.gridLayout_2.addWidget(self.le_suffix_clip, 9, 3, 1, 1) self.external_proxy = QCheckBox(self.proxy_box) self.external_proxy.setObjectName(u"external_proxy") self.gridLayout_2.addWidget(self.external_proxy, 6, 0, 1, 1) self.checkProxy = QToolButton(self.proxy_box) self.checkProxy.setObjectName(u"checkProxy") self.gridLayout_2.addWidget(self.checkProxy, 1, 3, 1, 1) self.label_3 = QLabel(self.proxy_box) self.label_3.setObjectName(u"label_3") self.gridLayout_2.addWidget(self.label_3, 5, 0, 1, 1) self.proxy_manageprofile = QToolButton(self.proxy_box) self.proxy_manageprofile.setObjectName(u"proxy_manageprofile") self.gridLayout_2.addWidget(self.proxy_manageprofile, 1, 5, 1, 1) self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.gridLayout_2.addItem(self.verticalSpacer, 13, 1, 1, 1) self.verticalLayout.addWidget(self.proxy_box) self.tabWidget.addTab(self.tab_4, "") self.tab_3 = QWidget() self.tab_3.setObjectName(u"tab_3") self.gridLayout_6 = QGridLayout(self.tab_3) self.gridLayout_6.setObjectName(u"gridLayout_6") self.metadata_list = QTreeWidget(self.tab_3) self.metadata_list.setObjectName(u"metadata_list") self.metadata_list.setAlternatingRowColors(True) self.metadata_list.setRootIsDecorated(False) self.metadata_list.setAllColumnsShowFocus(True) self.metadata_list.setColumnCount(2) self.metadata_list.header().setVisible(False) self.gridLayout_6.addWidget(self.metadata_list, 0, 0, 1, 1) self.horizontalLayout_3 = QHBoxLayout() self.horizontalLayout_3.setObjectName(u"horizontalLayout_3") self.add_metadata = QToolButton(self.tab_3) self.add_metadata.setObjectName(u"add_metadata") self.horizontalLayout_3.addWidget(self.add_metadata) self.delete_metadata = QToolButton(self.tab_3) self.delete_metadata.setObjectName(u"delete_metadata") self.horizontalLayout_3.addWidget(self.delete_metadata) self.horizontalSpacer_3 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout_3.addItem(self.horizontalSpacer_3) self.gridLayout_6.addLayout(self.horizontalLayout_3, 1, 0, 1, 1) self.tabWidget.addTab(self.tab_3, "") self.tab_2 = QWidget() self.tab_2.setObjectName(u"tab_2") self.gridLayout_4 = QGridLayout(self.tab_2) self.gridLayout_4.setObjectName(u"gridLayout_4") self.fonts_list = QListWidget(self.tab_2) self.fonts_list.setObjectName(u"fonts_list") self.fonts_list.setAlternatingRowColors(True) self.gridLayout_4.addWidget(self.fonts_list, 5, 0, 1, 5) self.files_list = QTreeWidget(self.tab_2) __qtreewidgetitem = QTreeWidgetItem() __qtreewidgetitem.setText(0, u"1") self.files_list.setHeaderItem(__qtreewidgetitem) self.files_list.setObjectName(u"files_list") self.files_list.setAlternatingRowColors(True) self.files_list.setRootIsDecorated(False) self.files_list.setItemsExpandable(False) self.files_list.setHeaderHidden(True) self.files_list.setExpandsOnDoubleClick(False) self.gridLayout_4.addWidget(self.files_list, 3, 0, 1, 5) self.label_12 = QLabel(self.tab_2) self.label_12.setObjectName(u"label_12") self.gridLayout_4.addWidget(self.label_12, 0, 0, 1, 2) self.used_count = QLabel(self.tab_2) self.used_count.setObjectName(u"used_count") self.gridLayout_4.addWidget(self.used_count, 0, 2, 1, 1) self.used_size = QLabel(self.tab_2) self.used_size.setObjectName(u"used_size") self.gridLayout_4.addWidget(self.used_size, 0, 3, 1, 1) self.label_6 = QLabel(self.tab_2) self.label_6.setObjectName(u"label_6") self.gridLayout_4.addWidget(self.label_6, 1, 0, 1, 1) self.unused_count = QLabel(self.tab_2) self.unused_count.setObjectName(u"unused_count") self.gridLayout_4.addWidget(self.unused_count, 1, 2, 1, 1) self.unused_size = QLabel(self.tab_2) self.unused_size.setObjectName(u"unused_size") self.gridLayout_4.addWidget(self.unused_size, 1, 3, 1, 1) self.delete_unused = QPushButton(self.tab_2) self.delete_unused.setObjectName(u"delete_unused") self.gridLayout_4.addWidget(self.delete_unused, 1, 4, 1, 1) self.list_search = KTreeWidgetSearchLine(self.tab_2) self.list_search.setObjectName(u"list_search") self.gridLayout_4.addWidget(self.list_search, 2, 3, 1, 2) self.label_13 = QLabel(self.tab_2) self.label_13.setObjectName(u"label_13") self.gridLayout_4.addWidget(self.label_13, 2, 0, 1, 1) self.label_fonts = QLabel(self.tab_2) self.label_fonts.setObjectName(u"label_fonts") self.gridLayout_4.addWidget(self.label_fonts, 4, 0, 1, 1) self.button_export = QPushButton(self.tab_2) self.button_export.setObjectName(u"button_export") self.gridLayout_4.addWidget(self.button_export, 6, 0, 1, 2) self.files_count = QLabel(self.tab_2) self.files_count.setObjectName(u"files_count") self.gridLayout_4.addWidget(self.files_count, 2, 2, 1, 1) self.tabWidget.addTab(self.tab_2, "") self.gridLayout_3.addWidget(self.tabWidget, 0, 0, 1, 1) self.retranslateUi(ProjectSettings_UI) self.buttonBox.accepted.connect(ProjectSettings_UI.accept) self.buttonBox.rejected.connect(ProjectSettings_UI.reject) self.custom_folder.toggled.connect(self.project_folder.setEnabled) self.enable_proxy.toggled.connect(self.proxy_box.setEnabled) self.external_proxy.toggled.connect( self.external_proxy_profile.setEnabled) self.tabWidget.setCurrentIndex(0) QMetaObject.connectSlotsByName(ProjectSettings_UI) # setupUi def retranslateUi(self, ProjectSettings_UI): ProjectSettings_UI.setWindowTitle( QCoreApplication.translate("ProjectSettings_UI", u"Project Settings", None)) self.label_2.setText( QCoreApplication.translate("ProjectSettings_UI", u"Thumbnails:", None)) self.audio_thumbs.setText( QCoreApplication.translate("ProjectSettings_UI", u"Audio", None)) self.label_7.setText( QCoreApplication.translate("ProjectSettings_UI", u"Video tracks:", None)) self.label_8.setText( QCoreApplication.translate("ProjectSettings_UI", u"Audio tracks:", None)) self.label.setText( QCoreApplication.translate("ProjectSettings_UI", u"Audio channels:", None)) self.audio_channels.setItemText( 0, QCoreApplication.translate("ProjectSettings_UI", u"2 Channels (Stereo)", None)) self.audio_channels.setItemText( 1, QCoreApplication.translate("ProjectSettings_UI", u"4 Channels", None)) self.audio_channels.setItemText( 2, QCoreApplication.translate("ProjectSettings_UI", u"6 Channels", None)) self.label_4.setText( QCoreApplication.translate( "ProjectSettings_UI", u"Project folder to store proxy clips, thumbnails, previews", None)) self.video_thumbs.setText( QCoreApplication.translate("ProjectSettings_UI", u"Video", None)) self.label_25.setText( QCoreApplication.translate("ProjectSettings_UI", u"Preview profile:", None)) self.preview_showprofileinfo.setText( QCoreApplication.translate("ProjectSettings_UI", u"...", None)) self.preview_manageprofile.setText( QCoreApplication.translate("ProjectSettings_UI", u"...", None)) self.custom_folder.setText( QCoreApplication.translate("ProjectSettings_UI", u"Custom project folder:", None)) self.same_folder.setText( QCoreApplication.translate( "ProjectSettings_UI", u"Use parent folder of the project file as project folder", None)) self.tabWidget.setTabText( self.tabWidget.indexOf(self.tab), QCoreApplication.translate("ProjectSettings_UI", u"Settings", None)) self.enable_proxy.setText( QCoreApplication.translate("ProjectSettings_UI", u"Enable proxy clips", None)) self.l_relPathProxyToOrig.setText( QCoreApplication.translate("ProjectSettings_UI", u"Relative path from proxy to clip:", None)) self.generate_imageproxy.setText( QCoreApplication.translate("ProjectSettings_UI", u"Generate for images larger than", None)) self.l_prefix_proxy.setText( QCoreApplication.translate("ProjectSettings_UI", u"Prefix of proxy:", None)) self.proxy_imagesize.setSuffix( QCoreApplication.translate("ProjectSettings_UI", u"pixels", None)) self.label_24.setText( QCoreApplication.translate("ProjectSettings_UI", u"Encoding profile:", None)) self.proxy_minsize.setSuffix( QCoreApplication.translate("ProjectSettings_UI", u"pixels", None)) self.l_prefix_clip.setText( QCoreApplication.translate("ProjectSettings_UI", u"Prefix of clip:", None)) self.proxy_showprofileinfo.setText( QCoreApplication.translate("ProjectSettings_UI", u"...", None)) self.generate_proxy.setText( QCoreApplication.translate("ProjectSettings_UI", u"Generate for videos larger than", None)) self.image_label.setText( QCoreApplication.translate("ProjectSettings_UI", u"Proxy image size", None)) self.l_suffix_proxy.setText( QCoreApplication.translate("ProjectSettings_UI", u"Suffix of proxy:", None)) self.proxy_imageminsize.setSuffix( QCoreApplication.translate("ProjectSettings_UI", u"pixels", None)) self.l_suffix_clip.setText( QCoreApplication.translate("ProjectSettings_UI", u"Suffix of clip:", None)) self.l_relPathOrigToProxy.setText( QCoreApplication.translate("ProjectSettings_UI", u"Relative path from clip to proxy:", None)) self.proxy_resize.setSuffix( QCoreApplication.translate("ProjectSettings_UI", u"pixels", None)) self.external_proxy.setText( QCoreApplication.translate("ProjectSettings_UI", u"Use external proxy clips", None)) self.checkProxy.setText( QCoreApplication.translate("ProjectSettings_UI", u"...", None)) self.label_3.setText( QCoreApplication.translate("ProjectSettings_UI", u"Proxy video resize (width)", None)) self.proxy_manageprofile.setText( QCoreApplication.translate("ProjectSettings_UI", u"...", None)) self.tabWidget.setTabText( self.tabWidget.indexOf(self.tab_4), QCoreApplication.translate("ProjectSettings_UI", u"Proxy", None)) ___qtreewidgetitem = self.metadata_list.headerItem() ___qtreewidgetitem.setText( 1, QCoreApplication.translate("ProjectSettings_UI", u"2", None)) ___qtreewidgetitem.setText( 0, QCoreApplication.translate("ProjectSettings_UI", u"1", None)) self.add_metadata.setText( QCoreApplication.translate("ProjectSettings_UI", u"...", None)) self.delete_metadata.setText( QCoreApplication.translate("ProjectSettings_UI", u"...", None)) self.tabWidget.setTabText( self.tabWidget.indexOf(self.tab_3), QCoreApplication.translate("ProjectSettings_UI", u"Metadata", None)) self.label_12.setText( QCoreApplication.translate("ProjectSettings_UI", u"Clips used in project:", None)) self.used_count.setText("") self.used_size.setText("") self.label_6.setText( QCoreApplication.translate("ProjectSettings_UI", u"Unused clips:", None)) self.unused_count.setText("") self.unused_size.setText("") self.delete_unused.setText( QCoreApplication.translate("ProjectSettings_UI", u"Delete files", None)) self.label_13.setText( QCoreApplication.translate("ProjectSettings_UI", u"Project files:", None)) self.label_fonts.setText( QCoreApplication.translate("ProjectSettings_UI", u"Fonts", None)) self.button_export.setText( QCoreApplication.translate("ProjectSettings_UI", u"Plain Text Export...", None)) self.files_count.setText("") self.tabWidget.setTabText( self.tabWidget.indexOf(self.tab_2), QCoreApplication.translate("ProjectSettings_UI", u"Project Files", None))
class Ui_MainWindow(object): def setupUi(self, MainWindow): if not MainWindow.objectName(): MainWindow.setObjectName(u"MainWindow") MainWindow.resize(1020, 588) self.actionSave = QAction(MainWindow) self.actionSave.setObjectName(u"actionSave") self.actionExit = QAction(MainWindow) self.actionExit.setObjectName(u"actionExit") self.actionExit_2 = QAction(MainWindow) self.actionExit_2.setObjectName(u"actionExit_2") self.openini = QAction(MainWindow) self.openini.setObjectName(u"openini") self.openjson = QAction(MainWindow) self.openjson.setObjectName(u"openjson") self.main_widget = QWidget(MainWindow) self.main_widget.setObjectName(u"main_widget") self.ini_widget = QWidget(self.main_widget) self.ini_widget.setObjectName(u"ini_widget") self.ini_widget.setGeometry(QRect(670, 10, 341, 551)) self.initable = QTableWidget(self.ini_widget) if (self.initable.columnCount() < 2): self.initable.setColumnCount(2) self.initable.setObjectName(u"initable") self.initable.setEnabled(True) self.initable.setGeometry(QRect(10, 60, 321, 451)) font = QFont() self.initable.setFont(font) self.initable.setEditTriggers(QAbstractItemView.DoubleClicked) self.initable.setDragEnabled(False) self.initable.setSelectionMode(QAbstractItemView.ExtendedSelection) self.initable.setSelectionBehavior(QAbstractItemView.SelectRows) self.initable.setWordWrap(False) self.initable.setRowCount(0) self.initable.setColumnCount(2) self.initable.horizontalHeader().setDefaultSectionSize(110) self.initable.horizontalHeader().setProperty("showSortIndicator", False) self.initable.horizontalHeader().setStretchLastSection(True) self.initable.verticalHeader().setDefaultSectionSize(21) self.inilabel = QLabel(self.ini_widget) self.inilabel.setObjectName(u"inilabel") self.inilabel.setGeometry(QRect(10, 10, 181, 16)) self.inipath = QTextBrowser(self.ini_widget) self.inipath.setObjectName(u"inipath") self.inipath.setEnabled(True) self.inipath.setGeometry(QRect(10, 30, 321, 22)) self.inipath.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.iniapply = QPushButton(self.ini_widget) self.iniapply.setObjectName(u"iniapply") self.iniapply.setEnabled(True) self.iniapply.setGeometry(QRect(250, 520, 80, 21)) self.inidel = QPushButton(self.ini_widget) self.inidel.setObjectName(u"inidel") self.inidel.setEnabled(False) self.inidel.setGeometry(QRect(10, 520, 80, 21)) self.iniadd = QPushButton(self.ini_widget) self.iniadd.setObjectName(u"iniadd") self.iniadd.setEnabled(False) self.iniadd.setGeometry(QRect(100, 520, 80, 21)) self.json_widget = QWidget(self.main_widget) self.json_widget.setObjectName(u"json_widget") self.json_widget.setGeometry(QRect(0, 10, 661, 551)) self.checkBox = QCheckBox(self.json_widget) self.checkBox.setObjectName(u"checkBox") self.checkBox.setEnabled(True) self.checkBox.setGeometry(QRect(20, 100, 131, 20)) self.checkBox.setChecked(True) self.delentry = QPushButton(self.json_widget) self.delentry.setObjectName(u"delentry") self.delentry.setEnabled(False) self.delentry.setGeometry(QRect(10, 520, 80, 21)) self.remote = QLineEdit(self.json_widget) self.remote.setObjectName(u"remote") self.remote.setEnabled(True) self.remote.setGeometry(QRect(20, 130, 601, 22)) self.textBrowser = QTextBrowser(self.json_widget) self.textBrowser.setObjectName(u"textBrowser") self.textBrowser.setEnabled(True) self.textBrowser.setGeometry(QRect(20, 30, 601, 22)) self.textBrowser.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.addButton = QPushButton(self.json_widget) self.addButton.setObjectName(u"addButton") self.addButton.setEnabled(True) self.addButton.setGeometry(QRect(280, 160, 61, 22)) self.table = QTableWidget(self.json_widget) if (self.table.columnCount() < 2): self.table.setColumnCount(2) self.table.setObjectName(u"table") self.table.setEnabled(True) self.table.setGeometry(QRect(10, 200, 641, 311)) self.table.setFont(font) self.table.setEditTriggers(QAbstractItemView.DoubleClicked) self.table.setDragEnabled(False) self.table.setSelectionMode(QAbstractItemView.ExtendedSelection) self.table.setSelectionBehavior(QAbstractItemView.SelectRows) self.table.setWordWrap(False) self.table.setRowCount(0) self.table.setColumnCount(2) self.table.horizontalHeader().setDefaultSectionSize(80) self.table.horizontalHeader().setProperty("showSortIndicator", False) self.table.horizontalHeader().setStretchLastSection(True) self.table.verticalHeader().setDefaultSectionSize(21) self.path = QLineEdit(self.json_widget) self.path.setObjectName(u"path") self.path.setEnabled(True) self.path.setGeometry(QRect(20, 70, 531, 22)) self.apply = QPushButton(self.json_widget) self.apply.setObjectName(u"apply") self.apply.setEnabled(True) self.apply.setGeometry(QRect(570, 520, 80, 21)) self.label = QLabel(self.json_widget) self.label.setObjectName(u"label") self.label.setGeometry(QRect(20, 10, 181, 16)) self.browse = QPushButton(self.json_widget) self.browse.setObjectName(u"browse") self.browse.setGeometry(QRect(560, 70, 61, 22)) MainWindow.setCentralWidget(self.main_widget) self.menubar = QMenuBar(MainWindow) self.menubar.setObjectName(u"menubar") self.menubar.setGeometry(QRect(0, 0, 1020, 19)) self.File = QMenu(self.menubar) self.File.setObjectName(u"File") self.menuOpen = QMenu(self.File) self.menuOpen.setObjectName(u"menuOpen") MainWindow.setMenuBar(self.menubar) self.menubar.addAction(self.File.menuAction()) self.File.addAction(self.menuOpen.menuAction()) self.File.addAction(self.actionSave) self.File.addSeparator() self.File.addAction(self.actionExit_2) self.menuOpen.addAction(self.openini) self.menuOpen.addAction(self.openjson) self.retranslateUi(MainWindow) QMetaObject.connectSlotsByName(MainWindow) # setupUi def retranslateUi(self, MainWindow): MainWindow.setWindowTitle( QCoreApplication.translate("MainWindow", u"frii-config", None)) self.actionSave.setText( QCoreApplication.translate("MainWindow", u"Save", None)) self.actionExit.setText( QCoreApplication.translate("MainWindow", u"Exit", None)) self.actionExit_2.setText( QCoreApplication.translate("MainWindow", u"Exit", None)) self.openini.setText( QCoreApplication.translate("MainWindow", u"Main config (frii_update.ini)", None)) self.openjson.setText( QCoreApplication.translate("MainWindow", u"Repository information (info.json)", None)) self.inilabel.setText( QCoreApplication.translate("MainWindow", u"Configuration (frii_update.ini)", None)) self.iniapply.setText( QCoreApplication.translate("MainWindow", u"Save", None)) self.inidel.setText( QCoreApplication.translate("MainWindow", u"Delete", None)) self.iniadd.setText( QCoreApplication.translate("MainWindow", u"Insert", None)) self.checkBox.setText( QCoreApplication.translate("MainWindow", u"Clone repository", None)) self.delentry.setText( QCoreApplication.translate("MainWindow", u"Delete", None)) self.remote.setText( QCoreApplication.translate("MainWindow", u"Enter repository URL here", None)) self.addButton.setText( QCoreApplication.translate("MainWindow", u"Next", None)) self.path.setText( QCoreApplication.translate("MainWindow", u"Enter repository path here", None)) self.apply.setText( QCoreApplication.translate("MainWindow", u"Save", None)) self.label.setText( QCoreApplication.translate("MainWindow", u"Saved Information (info.json)", None)) self.browse.setText( QCoreApplication.translate("MainWindow", u"Browse", None)) self.File.setTitle( QCoreApplication.translate("MainWindow", u"File", None)) self.menuOpen.setTitle( QCoreApplication.translate("MainWindow", u"Open", None))
class Snippets(QDialog): def __init__(self, context, parent=None): super(Snippets, self).__init__(parent) # Create widgets self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) self.title = QLabel(self.tr("Snippet Editor")) self.saveButton = QPushButton(self.tr("&Save")) self.saveButton.setShortcut(QKeySequence(self.tr("Ctrl+S"))) self.runButton = QPushButton(self.tr("&Run")) self.runButton.setShortcut(QKeySequence(self.tr("Ctrl+R"))) self.closeButton = QPushButton(self.tr("Close")) self.clearHotkeyButton = QPushButton(self.tr("Clear Hotkey")) self.setWindowTitle(self.title.text()) #self.newFolderButton = QPushButton("New Folder") self.browseButton = QPushButton("Browse Snippets") self.browseButton.setIcon(QIcon.fromTheme("edit-undo")) self.deleteSnippetButton = QPushButton("Delete") self.newSnippetButton = QPushButton("New Snippet") indentation = Settings().get_string("snippets.indentation") if Settings().get_bool("snippets.syntaxHighlight"): self.edit = QCodeEditor(SyntaxHighlighter=Pylighter, delimeter=indentation) else: self.edit = QCodeEditor(SyntaxHighlighter=None, delimeter=indentation) self.edit.setPlaceholderText("python code") self.resetting = False self.columns = 3 self.context = context self.keySequenceEdit = QKeySequenceEdit(self) self.currentHotkey = QKeySequence() self.currentHotkeyLabel = QLabel("") self.currentFileLabel = QLabel() self.currentFile = "" self.snippetDescription = QLineEdit() self.snippetDescription.setPlaceholderText("optional description") #Set Editbox Size font = getMonospaceFont(self) self.edit.setFont(font) font = QFontMetrics(font) self.edit.setTabStopDistance( 4 * font.horizontalAdvance(' ')) #TODO, replace with settings API #Files self.files = QFileSystemModel() self.files.setRootPath(snippetPath) self.files.setNameFilters(["*.py"]) #Tree self.tree = QTreeView() self.tree.setModel(self.files) self.tree.setSortingEnabled(True) self.tree.hideColumn(2) self.tree.sortByColumn(0, Qt.AscendingOrder) self.tree.setRootIndex(self.files.index(snippetPath)) for x in range(self.columns): #self.tree.resizeColumnToContents(x) self.tree.header().setSectionResizeMode( x, QHeaderView.ResizeToContents) treeLayout = QVBoxLayout() treeLayout.addWidget(self.tree) treeButtons = QHBoxLayout() #treeButtons.addWidget(self.newFolderButton) treeButtons.addWidget(self.browseButton) treeButtons.addWidget(self.newSnippetButton) treeButtons.addWidget(self.deleteSnippetButton) treeLayout.addLayout(treeButtons) treeWidget = QWidget() treeWidget.setLayout(treeLayout) # Create layout and add widgets buttons = QHBoxLayout() buttons.addWidget(self.clearHotkeyButton) buttons.addWidget(self.keySequenceEdit) buttons.addWidget(self.currentHotkeyLabel) buttons.addWidget(self.closeButton) buttons.addWidget(self.runButton) buttons.addWidget(self.saveButton) description = QHBoxLayout() description.addWidget(QLabel(self.tr("Description: "))) description.addWidget(self.snippetDescription) vlayoutWidget = QWidget() vlayout = QVBoxLayout() vlayout.addLayout(description) vlayout.addWidget(self.edit) vlayout.addLayout(buttons) vlayoutWidget.setLayout(vlayout) hsplitter = QSplitter() hsplitter.addWidget(treeWidget) hsplitter.addWidget(vlayoutWidget) hlayout = QHBoxLayout() hlayout.addWidget(hsplitter) self.showNormal() #Fixes bug that maximized windows are "stuck" #Because you can't trust QT to do the right thing here if (sys.platform == "darwin"): self.settings = QSettings("Vector35", "Snippet Editor") else: self.settings = QSettings("Vector 35", "Snippet Editor") if self.settings.contains("ui/snippeteditor/geometry"): self.restoreGeometry( self.settings.value("ui/snippeteditor/geometry")) else: self.edit.setMinimumWidth(80 * font.averageCharWidth()) self.edit.setMinimumHeight(30 * font.lineSpacing()) # Set dialog layout self.setLayout(hlayout) # Add signals self.saveButton.clicked.connect(self.save) self.closeButton.clicked.connect(self.close) self.runButton.clicked.connect(self.run) self.clearHotkeyButton.clicked.connect(self.clearHotkey) self.tree.selectionModel().selectionChanged.connect(self.selectFile) self.newSnippetButton.clicked.connect(self.newFileDialog) self.deleteSnippetButton.clicked.connect(self.deleteSnippet) #self.newFolderButton.clicked.connect(self.newFolder) self.browseButton.clicked.connect(self.browseSnippets) if self.settings.contains("ui/snippeteditor/selected"): selectedName = self.settings.value("ui/snippeteditor/selected") self.tree.selectionModel().select( self.files.index(selectedName), QItemSelectionModel.ClearAndSelect | QItemSelectionModel.Rows) if self.tree.selectionModel().hasSelection(): self.selectFile(self.tree.selectionModel().selection(), None) self.edit.setFocus() cursor = self.edit.textCursor() cursor.setPosition(self.edit.document().characterCount() - 1) self.edit.setTextCursor(cursor) else: self.readOnly(True) else: self.readOnly(True) @staticmethod def registerAllSnippets(): for action in list( filter(lambda x: x.startswith("Snippets\\"), UIAction.getAllRegisteredActions())): if action == "Snippets\\Snippet Editor...": continue UIActionHandler.globalActions().unbindAction(action) Menu.mainMenu("Tools").removeAction(action) UIAction.unregisterAction(action) for snippet in includeWalk(snippetPath, ".py"): snippetKeys = None (snippetDescription, snippetKeys, snippetCode) = loadSnippetFromFile(snippet) actionText = actionFromSnippet(snippet, snippetDescription) if snippetCode: if snippetKeys == None: UIAction.registerAction(actionText) else: UIAction.registerAction(actionText, snippetKeys) UIActionHandler.globalActions().bindAction( actionText, UIAction(makeSnippetFunction(snippetCode, actionText))) Menu.mainMenu("Tools").addAction(actionText, "Snippets") def clearSelection(self): self.keySequenceEdit.clear() self.currentHotkey = QKeySequence() self.currentHotkeyLabel.setText("") self.currentFileLabel.setText("") self.snippetDescription.setText("") self.edit.clear() self.tree.clearSelection() self.currentFile = "" def askSave(self): return QMessageBox.question( self, self.tr("Save?"), self.tr("Do you want to save changes to {}?").format( self.currentFileLabel.text()), QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel) def reject(self): self.settings.setValue("ui/snippeteditor/geometry", self.saveGeometry()) if self.snippetChanged(): save = self.askSave() if save == QMessageBox.Yes: self.save() elif save == QMessageBox.No: self.loadSnippet() elif save == QMessageBox.Cancel: return self.accept() def browseSnippets(self): url = QUrl.fromLocalFile(snippetPath) QDesktopServices.openUrl(url) def newFolder(self): (folderName, ok) = QInputDialog.getText(self, self.tr("Folder Name"), self.tr("Folder Name: ")) if ok and folderName: index = self.tree.selectionModel().currentIndex() selection = self.files.filePath(index) if QFileInfo(selection).isDir(): QDir(selection).mkdir(folderName) else: QDir(snippetPath).mkdir(folderName) def selectFile(self, new, old): if (self.resetting): self.resetting = False return if len(new.indexes()) == 0: self.clearSelection() self.currentFile = "" self.readOnly(True) return newSelection = self.files.filePath(new.indexes()[0]) self.settings.setValue("ui/snippeteditor/selected", newSelection) if QFileInfo(newSelection).isDir(): self.readOnly(True) self.clearSelection() self.currentFile = "" return if old and old.length() > 0: oldSelection = self.files.filePath(old.indexes()[0]) if not QFileInfo(oldSelection).isDir() and self.snippetChanged(): save = self.askSave() if save == QMessageBox.Yes: self.save() elif save == QMessageBox.No: pass elif save == QMessageBox.Cancel: self.resetting = True self.tree.selectionModel().select( old, QItemSelectionModel.ClearAndSelect | QItemSelectionModel.Rows) return False self.currentFile = newSelection self.loadSnippet() def loadSnippet(self): self.currentFileLabel.setText(QFileInfo(self.currentFile).baseName()) (snippetDescription, snippetKeys, snippetCode) = loadSnippetFromFile(self.currentFile) self.snippetDescription.setText( snippetDescription ) if snippetDescription else self.snippetDescription.setText("") self.keySequenceEdit.setKeySequence( snippetKeys ) if snippetKeys else self.keySequenceEdit.setKeySequence( QKeySequence("")) self.edit.setPlainText( snippetCode) if snippetCode else self.edit.setPlainText("") self.readOnly(False) def newFileDialog(self): (snippetName, ok) = QInputDialog.getText(self, self.tr("Snippet Name"), self.tr("Snippet Name: "), flags=self.windowFlags()) if ok and snippetName: if not snippetName.endswith(".py"): snippetName += ".py" index = self.tree.selectionModel().currentIndex() selection = self.files.filePath(index) if QFileInfo(selection).isDir(): path = os.path.join(selection, snippetName) else: path = os.path.join(snippetPath, snippetName) self.readOnly(False) open(path, "w").close() self.tree.setCurrentIndex(self.files.index(path)) log_debug("Snippet %s created." % snippetName) def readOnly(self, flag): self.keySequenceEdit.setEnabled(not flag) self.snippetDescription.setReadOnly(flag) self.edit.setReadOnly(flag) if flag: self.snippetDescription.setDisabled(True) self.edit.setDisabled(True) else: self.snippetDescription.setEnabled(True) self.edit.setEnabled(True) def deleteSnippet(self): selection = self.tree.selectedIndexes()[::self.columns][ 0] #treeview returns each selected element in the row snippetName = self.files.fileName(selection) question = QMessageBox.question( self, self.tr("Confirm"), self.tr("Confirm deletion: ") + snippetName) if (question == QMessageBox.StandardButton.Yes): log_debug("Deleting snippet %s." % snippetName) self.clearSelection() self.files.remove(selection) self.registerAllSnippets() def snippetChanged(self): if (self.currentFile == "" or QFileInfo(self.currentFile).isDir()): return False (snippetDescription, snippetKeys, snippetCode) = loadSnippetFromFile(self.currentFile) if snippetKeys == None and not self.keySequenceEdit.keySequence( ).isEmpty(): return True if snippetKeys != None and snippetKeys != self.keySequenceEdit.keySequence( ).toString(): return True return self.edit.toPlainText() != snippetCode or \ self.snippetDescription.text() != snippetDescription def save(self): log_debug("Saving snippet %s" % self.currentFile) outputSnippet = codecs.open(self.currentFile, "w", "utf-8") outputSnippet.write("#" + self.snippetDescription.text() + "\n") outputSnippet.write("#" + self.keySequenceEdit.keySequence().toString() + "\n") outputSnippet.write(self.edit.toPlainText()) outputSnippet.close() self.registerAllSnippets() def run(self): if self.context == None: log_warn("Cannot run snippets outside of the UI at this time.") return if self.snippetChanged(): self.save() actionText = actionFromSnippet(self.currentFile, self.snippetDescription.text()) UIActionHandler.globalActions().executeAction(actionText, self.context) log_debug("Saving snippet %s" % self.currentFile) outputSnippet = codecs.open(self.currentFile, "w", "utf-8") outputSnippet.write("#" + self.snippetDescription.text() + "\n") outputSnippet.write("#" + self.keySequenceEdit.keySequence().toString() + "\n") outputSnippet.write(self.edit.toPlainText()) outputSnippet.close() self.registerAllSnippets() def clearHotkey(self): self.keySequenceEdit.clear()
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
class UIDrawROIWindow: def setup_ui(self, draw_roi_window_instance, rois, dataset_rtss, signal_roi_drawn): """ this function is responsible for setting up the UI for DrawROIWindow param draw_roi_window_instance: the current drawing window instance. :param rois: the rois to be drawn :param dataset_rtss: the rtss to be written to :param signal_roi_drawn: the signal to be triggered when roi is drawn """ self.patient_dict_container = PatientDictContainer() self.rois = rois self.dataset_rtss = dataset_rtss self.signal_roi_drawn = signal_roi_drawn self.drawn_roi_list = {} self.standard_organ_names = [] self.standard_volume_names = [] self.standard_names = [] # Combination of organ and volume self.ROI_name = None # Selected ROI name self.target_pixel_coords = [] # This will contain the new pixel # coordinates specified by the min and max self.drawingROI = None self.slice_changed = False self.drawing_tool_radius = INITIAL_DRAWING_TOOL_RADIUS self.keep_empty_pixel = False # pixel density self.target_pixel_coords_single_array = [] # 1D array self.draw_roi_window_instance = draw_roi_window_instance self.colour = None self.ds = None self.zoom = 1.0 self.upper_limit = None self.lower_limit = None # is_four_view is set to True to stop the SUV2ROI button from appearing self.dicom_view = DicomAxialView(is_four_view=True) self.current_slice = self.dicom_view.slider.value() self.dicom_view.slider.valueChanged.connect(self.slider_value_changed) self.init_layout() QtCore.QMetaObject.connectSlotsByName(draw_roi_window_instance) def retranslate_ui(self, draw_roi_window_instance): """ this function retranslate the ui for draw roi window :param draw_roi_window_instance: the current drawing window instance. """ _translate = QtCore.QCoreApplication.translate draw_roi_window_instance.setWindowTitle( _translate("DrawRoiWindowInstance", "OnkoDICOM - Draw Region Of Interest")) self.roi_name_label.setText( _translate("ROINameLabel", "Region of Interest: ")) self.roi_name_line_edit.setText(_translate("ROINameLineEdit", "")) self.image_slice_number_label.setText( _translate("ImageSliceNumberLabel", "Slice Number: ")) self.image_slice_number_line_edit.setText( _translate("ImageSliceNumberLineEdit", str(self.dicom_view.current_slice_number))) self.image_slice_number_transect_button.setText( _translate("ImageSliceNumberTransectButton", "Transect")) self.image_slice_number_box_draw_button.setText( _translate("ImageSliceNumberBoxDrawButton", "Set Bounds")) self.image_slice_number_draw_button.setText( _translate("ImageSliceNumberDrawButton", "Draw")) self.image_slice_number_move_forward_button.setText( _translate("ImageSliceNumberMoveForwardButton", "")) self.image_slice_number_move_backward_button.setText( _translate("ImageSliceNumberMoveBackwardButton", "")) self.draw_roi_window_instance_save_button.setText( _translate("DrawRoiWindowInstanceSaveButton", "Save")) self.draw_roi_window_instance_cancel_button.setText( _translate("DrawRoiWindowInstanceCancelButton", "Cancel")) self.internal_hole_max_label.setText( _translate("InternalHoleLabel", "Maximum internal hole size (pixels): ")) self.internal_hole_max_line_edit.setText( _translate("InternalHoleInput", "9")) self.isthmus_width_max_label.setText( _translate("IsthmusWidthLabel", "Maximum isthmus width size (pixels): ")) self.isthmus_width_max_line_edit.setText( _translate("IsthmusWidthInput", "5")) self.min_pixel_density_label.setText( _translate("MinPixelDensityLabel", "Minimum density (pixels): ")) self.min_pixel_density_line_edit.setText( _translate("MinPixelDensityInput", "")) self.max_pixel_density_label.setText( _translate("MaxPixelDensityLabel", "Maximum density (pixels): ")) self.max_pixel_density_line_edit.setText( _translate("MaxPixelDensityInput", "")) self.toggle_keep_empty_pixel_label.setText( _translate("ToggleKeepEmptyPixelLabel", "Keep empty pixel: ")) self.draw_roi_window_viewport_zoom_label.setText( _translate("DrawRoiWindowViewportZoomLabel", "Zoom: ")) self.draw_roi_window_cursor_radius_change_label.setText( _translate("DrawRoiWindowCursorRadiusChangeLabel", "Cursor Radius: ")) self.draw_roi_window_instance_action_reset_button.setText( _translate("DrawRoiWindowInstanceActionClearButton", "Reset")) def init_layout(self): """ Initialize the layout for the DICOM View tab. Add the view widget and the slider in the layout. Add the whole container 'tab2_view' as a tab in the main page. """ # Initialise a DrawROIWindow if platform.system() == 'Darwin': self.stylesheet_path = "res/stylesheet.qss" else: self.stylesheet_path = "res/stylesheet-win-linux.qss" stylesheet = open(resource_path(self.stylesheet_path)).read() window_icon = QIcon() window_icon.addPixmap(QPixmap(resource_path("res/images/icon.ico")), QIcon.Normal, QIcon.Off) self.draw_roi_window_instance.setObjectName("DrawRoiWindowInstance") self.draw_roi_window_instance.setWindowIcon(window_icon) # Creating a form box to hold all buttons and input fields self.draw_roi_window_input_container_box = QFormLayout() self.draw_roi_window_input_container_box. \ setObjectName("DrawRoiWindowInputContainerBox") self.draw_roi_window_input_container_box. \ setLabelAlignment(Qt.AlignLeft) # Create a label for denoting the ROI name self.roi_name_label = QLabel() self.roi_name_label.setObjectName("ROINameLabel") self.roi_name_line_edit = QLineEdit() # Create an input box for ROI name self.roi_name_line_edit.setObjectName("ROINameLineEdit") self.roi_name_line_edit.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) self.roi_name_line_edit.resize( self.roi_name_line_edit.sizeHint().width(), self.roi_name_line_edit.sizeHint().height()) self.roi_name_line_edit.setEnabled(False) self.draw_roi_window_input_container_box. \ addRow(self.roi_name_label, self.roi_name_line_edit) # Create horizontal box to store image slice number and backward, # forward buttons self.image_slice_number_box = QHBoxLayout() self.image_slice_number_box.setObjectName("ImageSliceNumberBox") # Create a label for denoting the Image Slice Number self.image_slice_number_label = QLabel() self.image_slice_number_label.setObjectName("ImageSliceNumberLabel") self.image_slice_number_box.addWidget(self.image_slice_number_label) # Create a line edit for containing the image slice number self.image_slice_number_line_edit = QLineEdit() self.image_slice_number_line_edit. \ setObjectName("ImageSliceNumberLineEdit") self.image_slice_number_line_edit. \ setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) self.image_slice_number_line_edit.resize( self.image_slice_number_line_edit.sizeHint().width(), self.image_slice_number_line_edit.sizeHint().height()) self.image_slice_number_line_edit.setCursorPosition(0) self.image_slice_number_line_edit.setEnabled(False) self.image_slice_number_box. \ addWidget(self.image_slice_number_line_edit) # Create a button to move backward to the previous image self.image_slice_number_move_backward_button = QPushButton() self.image_slice_number_move_backward_button. \ setObjectName("ImageSliceNumberMoveBackwardButton") self.image_slice_number_move_backward_button.setSizePolicy( QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) self.image_slice_number_move_backward_button.resize(QSize(24, 24)) self.image_slice_number_move_backward_button.clicked. \ connect(self.onBackwardClicked) icon_move_backward = QtGui.QIcon() icon_move_backward.addPixmap( QtGui.QPixmap( resource_path('res/images/btn-icons/backward_slide_icon.png'))) self.image_slice_number_move_backward_button.setIcon( icon_move_backward) self.image_slice_number_box. \ addWidget(self.image_slice_number_move_backward_button) # Create a button to move forward to the next image self.image_slice_number_move_forward_button = QPushButton() self.image_slice_number_move_forward_button. \ setObjectName("ImageSliceNumberMoveForwardButton") self.image_slice_number_move_forward_button.setSizePolicy( QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) self.image_slice_number_move_forward_button.resize(QSize(24, 24)) self.image_slice_number_move_forward_button.clicked. \ connect(self.onForwardClicked) icon_move_forward = QtGui.QIcon() icon_move_forward.addPixmap( QtGui.QPixmap( resource_path('res/images/btn-icons/forward_slide_icon.png'))) self.image_slice_number_move_forward_button.setIcon(icon_move_forward) self.image_slice_number_box. \ addWidget(self.image_slice_number_move_forward_button) self.draw_roi_window_input_container_box. \ addRow(self.image_slice_number_box) # Create a horizontal box for containing the zoom function self.draw_roi_window_viewport_zoom_box = QHBoxLayout() self.draw_roi_window_viewport_zoom_box.setObjectName( "DrawRoiWindowViewportZoomBox") # Create a label for zooming self.draw_roi_window_viewport_zoom_label = QLabel() self.draw_roi_window_viewport_zoom_label. \ setObjectName("DrawRoiWindowViewportZoomLabel") # Create an input box for zoom factor self.draw_roi_window_viewport_zoom_input = QLineEdit() self.draw_roi_window_viewport_zoom_input. \ setObjectName("DrawRoiWindowViewportZoomInput") self.draw_roi_window_viewport_zoom_input. \ setText("{:.2f}".format(self.zoom * 100) + "%") self.draw_roi_window_viewport_zoom_input.setCursorPosition(0) self.draw_roi_window_viewport_zoom_input.setEnabled(False) self.draw_roi_window_viewport_zoom_input. \ setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) self.draw_roi_window_viewport_zoom_input.resize( self.draw_roi_window_viewport_zoom_input.sizeHint().width(), self.draw_roi_window_viewport_zoom_input.sizeHint().height()) # Create 2 buttons for zooming in and out # Zoom In Button self.draw_roi_window_viewport_zoom_in_button = QPushButton() self.draw_roi_window_viewport_zoom_in_button. \ setObjectName("DrawRoiWindowViewportZoomInButton") self.draw_roi_window_viewport_zoom_in_button.setSizePolicy( QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) self.draw_roi_window_viewport_zoom_in_button.resize(QSize(24, 24)) self.draw_roi_window_viewport_zoom_in_button. \ setProperty("QPushButtonClass", "zoom-button") icon_zoom_in = QtGui.QIcon() icon_zoom_in.addPixmap( QtGui.QPixmap( resource_path('res/images/btn-icons/zoom_in_icon.png'))) self.draw_roi_window_viewport_zoom_in_button.setIcon(icon_zoom_in) self.draw_roi_window_viewport_zoom_in_button.clicked. \ connect(self.onZoomInClicked) # Zoom Out Button self.draw_roi_window_viewport_zoom_out_button = QPushButton() self.draw_roi_window_viewport_zoom_out_button. \ setObjectName("DrawRoiWindowViewportZoomOutButton") self.draw_roi_window_viewport_zoom_out_button.setSizePolicy( QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) self.draw_roi_window_viewport_zoom_out_button.resize(QSize(24, 24)) self.draw_roi_window_viewport_zoom_out_button. \ setProperty("QPushButtonClass", "zoom-button") icon_zoom_out = QtGui.QIcon() icon_zoom_out.addPixmap( QtGui.QPixmap( resource_path('res/images/btn-icons/zoom_out_icon.png'))) self.draw_roi_window_viewport_zoom_out_button.setIcon(icon_zoom_out) self.draw_roi_window_viewport_zoom_out_button.clicked. \ connect(self.onZoomOutClicked) self.draw_roi_window_viewport_zoom_box. \ addWidget(self.draw_roi_window_viewport_zoom_label) self.draw_roi_window_viewport_zoom_box. \ addWidget(self.draw_roi_window_viewport_zoom_input) self.draw_roi_window_viewport_zoom_box. \ addWidget(self.draw_roi_window_viewport_zoom_out_button) self.draw_roi_window_viewport_zoom_box. \ addWidget(self.draw_roi_window_viewport_zoom_in_button) self.draw_roi_window_input_container_box. \ addRow(self.draw_roi_window_viewport_zoom_box) self.init_cursor_radius_change_box() # Create field to toggle two options: Keep empty pixel or fill empty # pixel when using draw cursor self.toggle_keep_empty_pixel_box = QHBoxLayout() self.toggle_keep_empty_pixel_label = QLabel() self.toggle_keep_empty_pixel_label. \ setObjectName("ToggleKeepEmptyPixelLabel") # Create input for min pixel size self.toggle_keep_empty_pixel_combo_box = QComboBox() self.toggle_keep_empty_pixel_combo_box.addItems(["Off", "On"]) self.toggle_keep_empty_pixel_combo_box.setCurrentIndex(0) self.toggle_keep_empty_pixel_combo_box.setEnabled(False) self.toggle_keep_empty_pixel_combo_box. \ setObjectName("ToggleKeepEmptyPixelComboBox") self.toggle_keep_empty_pixel_combo_box. \ setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) self.toggle_keep_empty_pixel_combo_box.resize( self.toggle_keep_empty_pixel_combo_box.sizeHint().width(), self.toggle_keep_empty_pixel_combo_box.sizeHint().height()) self.toggle_keep_empty_pixel_combo_box.currentIndexChanged.connect( self.toggle_keep_empty_pixel_box_index_changed) self.toggle_keep_empty_pixel_box. \ addWidget(self.toggle_keep_empty_pixel_label) self.toggle_keep_empty_pixel_box. \ addWidget(self.toggle_keep_empty_pixel_combo_box) self.draw_roi_window_input_container_box. \ addRow(self.toggle_keep_empty_pixel_box) # Create a horizontal box for transect and draw button self.draw_roi_window_transect_draw_box = QHBoxLayout() self.draw_roi_window_transect_draw_box. \ setObjectName("DrawRoiWindowTransectDrawBox") # Create a transect button self.image_slice_number_transect_button = QPushButton() self.image_slice_number_transect_button. \ setObjectName("ImageSliceNumberTransectButton") self.image_slice_number_transect_button.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Minimum)) self.image_slice_number_transect_button.resize( self.image_slice_number_transect_button.sizeHint().width(), self.image_slice_number_transect_button.sizeHint().height()) self.image_slice_number_transect_button.clicked. \ connect(self.transect_handler) icon_transect = QtGui.QIcon() icon_transect.addPixmap( QtGui.QPixmap( resource_path('res/images/btn-icons/transect_icon.png'))) self.image_slice_number_transect_button.setIcon(icon_transect) self.draw_roi_window_transect_draw_box. \ addWidget(self.image_slice_number_transect_button) # Create a bounding box button self.image_slice_number_box_draw_button = QPushButton() self.image_slice_number_box_draw_button. \ setObjectName("ImageSliceNumberBoxDrawButton") self.image_slice_number_box_draw_button.setSizePolicy( QSizePolicy.MinimumExpanding, QSizePolicy.Minimum) self.image_slice_number_box_draw_button.resize( self.image_slice_number_box_draw_button.sizeHint().width(), self.image_slice_number_box_draw_button.sizeHint().height()) self.image_slice_number_box_draw_button.clicked. \ connect(self.onBoxDrawClicked) icon_box_draw = QtGui.QIcon() icon_box_draw.addPixmap( QtGui.QPixmap( resource_path('res/images/btn-icons/draw_bound_icon.png'))) self.image_slice_number_box_draw_button.setIcon(icon_box_draw) self.draw_roi_window_transect_draw_box. \ addWidget(self.image_slice_number_box_draw_button) # Create a draw button self.image_slice_number_draw_button = QPushButton() self.image_slice_number_draw_button. \ setObjectName("ImageSliceNumberDrawButton") self.image_slice_number_draw_button.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Minimum)) self.image_slice_number_draw_button.resize( self.image_slice_number_draw_button.sizeHint().width(), self.image_slice_number_draw_button.sizeHint().height()) self.image_slice_number_draw_button.clicked.connect(self.onDrawClicked) icon_draw = QtGui.QIcon() icon_draw.addPixmap( QtGui.QPixmap(resource_path('res/images/btn-icons/draw_icon.png'))) self.image_slice_number_draw_button.setIcon(icon_draw) self.draw_roi_window_transect_draw_box. \ addWidget(self.image_slice_number_draw_button) self.draw_roi_window_input_container_box. \ addRow(self.draw_roi_window_transect_draw_box) # Create a contour preview button self.row_preview_layout = QtWidgets.QHBoxLayout() self.button_contour_preview = QtWidgets.QPushButton("Preview contour") self.button_contour_preview.clicked.connect(self.onPreviewClicked) self.row_preview_layout.addWidget(self.button_contour_preview) self.draw_roi_window_input_container_box. \ addRow(self.row_preview_layout) icon_preview = QtGui.QIcon() icon_preview.addPixmap( QtGui.QPixmap( resource_path('res/images/btn-icons/preview_icon.png'))) self.button_contour_preview.setIcon(icon_preview) # Create input line edit for alpha value self.label_alpha_value = QtWidgets.QLabel("Alpha value:") self.input_alpha_value = QtWidgets.QLineEdit("0.2") self.input_alpha_value. \ setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Minimum) self.input_alpha_value.resize( self.input_alpha_value.sizeHint().width(), self.input_alpha_value.sizeHint().height()) self.input_alpha_value.setValidator( QRegularExpressionValidator( QRegularExpression("^[0-9]*[.]?[0-9]*$"))) self.draw_roi_window_input_container_box. \ addRow(self.label_alpha_value, self.input_alpha_value) # Create a label for denoting the max internal hole size self.internal_hole_max_label = QLabel() self.internal_hole_max_label.setObjectName("InternalHoleLabel") # Create input for max internal hole size self.internal_hole_max_line_edit = QLineEdit() self.internal_hole_max_line_edit.setObjectName("InternalHoleInput") self.internal_hole_max_line_edit. \ setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Minimum) self.internal_hole_max_line_edit.resize( self.internal_hole_max_line_edit.sizeHint().width(), self.internal_hole_max_line_edit.sizeHint().height()) self.internal_hole_max_line_edit.setValidator( QRegularExpressionValidator( QRegularExpression("^[0-9]*[.]?[0-9]*$"))) self.draw_roi_window_input_container_box.addRow( self.internal_hole_max_label, self.internal_hole_max_line_edit) # Create a label for denoting the isthmus width size self.isthmus_width_max_label = QLabel() self.isthmus_width_max_label.setObjectName("IsthmusWidthLabel") # Create input for max isthmus width size self.isthmus_width_max_line_edit = QLineEdit() self.isthmus_width_max_line_edit.setObjectName("IsthmusWidthInput") self.isthmus_width_max_line_edit.setSizePolicy( QSizePolicy.MinimumExpanding, QSizePolicy.Minimum) self.isthmus_width_max_line_edit.resize( self.isthmus_width_max_line_edit.sizeHint().width(), self.isthmus_width_max_line_edit.sizeHint().height()) self.isthmus_width_max_line_edit.setValidator( QRegularExpressionValidator( QRegularExpression("^[0-9]*[.]?[0-9]*$"))) self.draw_roi_window_input_container_box.addRow( self.isthmus_width_max_label, self.isthmus_width_max_line_edit) # Create a label for denoting the minimum pixel density self.min_pixel_density_label = QLabel() self.min_pixel_density_label.setObjectName("MinPixelDensityLabel") # Create input for min pixel size self.min_pixel_density_line_edit = QLineEdit() self.min_pixel_density_line_edit.setObjectName("MinPixelDensityInput") self.min_pixel_density_line_edit.setSizePolicy( QSizePolicy.MinimumExpanding, QSizePolicy.Minimum) self.min_pixel_density_line_edit.resize( self.min_pixel_density_line_edit.sizeHint().width(), self.min_pixel_density_line_edit.sizeHint().height()) self.min_pixel_density_line_edit.setValidator( QRegularExpressionValidator( QRegularExpression("^[0-9]*[.]?[0-9]*$"))) self.draw_roi_window_input_container_box.addRow( self.min_pixel_density_label, self.min_pixel_density_line_edit) # Create a label for denoting the minimum pixel density self.max_pixel_density_label = QLabel() self.max_pixel_density_label.setObjectName("MaxPixelDensityLabel") # Create input for min pixel size self.max_pixel_density_line_edit = QLineEdit() self.max_pixel_density_line_edit.setObjectName("MaxPixelDensityInput") self.max_pixel_density_line_edit. \ setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Minimum) self.max_pixel_density_line_edit.resize( self.max_pixel_density_line_edit.sizeHint().width(), self.max_pixel_density_line_edit.sizeHint().height()) self.max_pixel_density_line_edit.setValidator( QRegularExpressionValidator( QRegularExpression("^[0-9]*[.]?[0-9]*$"))) self.draw_roi_window_input_container_box.addRow( self.max_pixel_density_label, self.max_pixel_density_line_edit) # Create a button to clear the draw self.draw_roi_window_instance_action_reset_button = QPushButton() self.draw_roi_window_instance_action_reset_button. \ setObjectName("DrawRoiWindowInstanceActionClearButton") self.draw_roi_window_instance_action_reset_button.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Minimum)) reset_button = self.draw_roi_window_instance_action_reset_button self.draw_roi_window_instance_action_reset_button.resize( reset_button.sizeHint().width(), reset_button.sizeHint().height()) self.draw_roi_window_instance_action_reset_button.clicked. \ connect(self.onResetClicked) self.draw_roi_window_instance_action_reset_button. \ setProperty("QPushButtonClass", "fail-button") icon_clear_roi_draw = QtGui.QIcon() icon_clear_roi_draw.addPixmap( QtGui.QPixmap( resource_path('res/images/btn-icons/reset_roi_draw_icon.png'))) self.draw_roi_window_instance_action_reset_button. \ setIcon(icon_clear_roi_draw) self.draw_roi_window_input_container_box. \ addRow(self.draw_roi_window_instance_action_reset_button) # Create a horizontal box for saving and cancel the drawing self.draw_roi_window_cancel_save_box = QHBoxLayout() self.draw_roi_window_cancel_save_box. \ setObjectName("DrawRoiWindowCancelSaveBox") # Create an exit button to cancel the drawing # Add a button to go back/exit from the application self.draw_roi_window_instance_cancel_button = QPushButton() self.draw_roi_window_instance_cancel_button. \ setObjectName("DrawRoiWindowInstanceCancelButton") self.draw_roi_window_instance_cancel_button.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Minimum)) self.draw_roi_window_instance_cancel_button.resize( self.draw_roi_window_instance_cancel_button.sizeHint().width(), self.draw_roi_window_instance_cancel_button.sizeHint().height()) self.draw_roi_window_instance_cancel_button. \ setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor)) self.draw_roi_window_instance_cancel_button.clicked. \ connect(self.onCancelButtonClicked) self.draw_roi_window_instance_cancel_button. \ setProperty("QPushButtonClass", "fail-button") icon_cancel = QtGui.QIcon() icon_cancel.addPixmap( QtGui.QPixmap( resource_path('res/images/btn-icons/cancel_icon.png'))) self.draw_roi_window_instance_cancel_button.setIcon(icon_cancel) self.draw_roi_window_cancel_save_box. \ addWidget(self.draw_roi_window_instance_cancel_button) # Create a save button to save all the changes self.draw_roi_window_instance_save_button = QPushButton() self.draw_roi_window_instance_save_button. \ setObjectName("DrawRoiWindowInstanceSaveButton") self.draw_roi_window_instance_save_button.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Minimum)) self.draw_roi_window_instance_save_button.resize( self.draw_roi_window_instance_save_button.sizeHint().width(), self.draw_roi_window_instance_save_button.sizeHint().height()) self.draw_roi_window_instance_save_button. \ setProperty("QPushButtonClass", "success-button") icon_save = QtGui.QIcon() icon_save.addPixmap( QtGui.QPixmap(resource_path('res/images/btn-icons/save_icon.png'))) self.draw_roi_window_instance_save_button.setIcon(icon_save) self.draw_roi_window_instance_save_button.clicked. \ connect(self.onSaveClicked) self.draw_roi_window_cancel_save_box. \ addWidget(self.draw_roi_window_instance_save_button) self.draw_roi_window_input_container_box. \ addRow(self.draw_roi_window_cancel_save_box) # Creating a horizontal box to hold the ROI view and slider self.draw_roi_window_instance_view_box = QHBoxLayout() self.draw_roi_window_instance_view_box. \ setObjectName("DrawRoiWindowInstanceViewBox") # Add View and Slider into horizontal box self.draw_roi_window_instance_view_box.addWidget(self.dicom_view) # Create a widget to hold the image slice box self.draw_roi_window_instance_view_widget = QWidget() self.draw_roi_window_instance_view_widget.setObjectName( "DrawRoiWindowInstanceActionWidget") self.draw_roi_window_instance_view_widget.setLayout( self.draw_roi_window_instance_view_box) # Create a horizontal box for containing the input fields and the # viewport self.draw_roi_window_main_box = QHBoxLayout() self.draw_roi_window_main_box.setObjectName("DrawRoiWindowMainBox") self.draw_roi_window_main_box. \ addLayout(self.draw_roi_window_input_container_box, 1) self.draw_roi_window_main_box. \ addWidget(self.draw_roi_window_instance_view_widget, 11) # Create a new central widget to hold the vertical box layout self.draw_roi_window_instance_central_widget = QWidget() self.draw_roi_window_instance_central_widget. \ setObjectName("DrawRoiWindowInstanceCentralWidget") self.draw_roi_window_instance_central_widget.setLayout( self.draw_roi_window_main_box) self.retranslate_ui(self.draw_roi_window_instance) self.draw_roi_window_instance.setStyleSheet(stylesheet) self.draw_roi_window_instance. \ setCentralWidget(self.draw_roi_window_instance_central_widget) QtCore.QMetaObject.connectSlotsByName(self.draw_roi_window_instance) def slider_value_changed(self): """ actions to be taken when slider value changes """ image_slice_number = self.current_slice # save progress self.save_drawing_progress(image_slice_number) self.set_current_slice(self.dicom_view.slider.value()) def set_current_slice(self, slice_number): """ set the current slice :param slice_number: the slice number to be set """ self.image_slice_number_line_edit.setText(str(slice_number + 1)) self.current_slice = slice_number self.dicom_view.update_view() # check if this slice has any drawings before if self.drawn_roi_list.get(self.current_slice) is not None: self.drawingROI = self.drawn_roi_list[ self.current_slice]['drawingROI'] self.ds = self.drawn_roi_list[self.current_slice]['ds'] self.dicom_view.view.setScene(self.drawingROI) self.enable_cursor_radius_change_box() self.drawingROI.clear_cursor(self.drawing_tool_radius) else: self.disable_cursor_radius_change_box() self.ds = None def onZoomInClicked(self): """ This function is used for zooming in button """ self.dicom_view.zoom *= 1.05 self.dicom_view.update_view(zoom_change=True) if self.drawingROI \ and self.drawingROI.current_slice == self.current_slice: self.dicom_view.view.setScene(self.drawingROI) self.draw_roi_window_viewport_zoom_input.setText( "{:.2f}".format(self.dicom_view.zoom * 100) + "%") self.draw_roi_window_viewport_zoom_input.setCursorPosition(0) def onZoomOutClicked(self): """ This function is used for zooming out button """ self.dicom_view.zoom /= 1.05 self.dicom_view.update_view(zoom_change=True) if self.drawingROI \ and self.drawingROI.current_slice == self.current_slice: self.dicom_view.view.setScene(self.drawingROI) self.draw_roi_window_viewport_zoom_input. \ setText("{:.2f}".format(self.dicom_view.zoom * 100) + "%") self.draw_roi_window_viewport_zoom_input.setCursorPosition(0) def toggle_keep_empty_pixel_box_index_changed(self): self.keep_empty_pixel = self.toggle_keep_empty_pixel_combo_box. \ currentText() == "On" self.drawingROI.keep_empty_pixel = self.keep_empty_pixel def onCancelButtonClicked(self): """ This function is used for canceling the drawing """ self.closeWindow() def onBackwardClicked(self): """ This function is used when backward button is clicked """ image_slice_number = self.current_slice # save progress if self.save_drawing_progress(image_slice_number): # Backward will only execute if current image slice is above 0. if int(image_slice_number) > 0: # decrements slice by 1 and update slider to move to correct # position self.dicom_view.slider.setValue(image_slice_number - 1) def onForwardClicked(self): """ This function is used when forward button is clicked """ image_slice_number = self.current_slice # save progress if self.save_drawing_progress(image_slice_number): pixmaps = self.patient_dict_container.get("pixmaps_axial") total_slices = len(pixmaps) # Forward will only execute if current image slice is below the # total number of slices. if int(image_slice_number) < total_slices: # increments slice by 1 and update slider to move to correct # position self.dicom_view.slider.setValue(image_slice_number + 1) def onResetClicked(self): """ This function is used when reset button is clicked """ self.dicom_view.image_display() self.dicom_view.update_view() self.isthmus_width_max_line_edit.setText("5") self.internal_hole_max_line_edit.setText("9") self.min_pixel_density_line_edit.setText("") self.max_pixel_density_line_edit.setText("") if hasattr(self, 'bounds_box_draw'): delattr(self, 'bounds_box_draw') if hasattr(self, 'drawingROI'): delattr(self, 'drawingROI') self.ds = None def transect_handler(self): """ Function triggered when the Transect button is pressed from the menu. """ pixmaps = self.patient_dict_container.get("pixmaps_axial") id = self.current_slice dt = self.patient_dict_container.dataset[id] rowS = dt.PixelSpacing[0] colS = dt.PixelSpacing[1] dt.convert_pixel_data() MainPageCallClass().run_transect( self.draw_roi_window_instance, self.dicom_view.view, pixmaps[id], dt._pixel_array.transpose(), rowS, colS, is_roi_draw=True, ) def save_drawing_progress(self, image_slice_number): """ this function saves the drawing progress on current slice :param image_slice_number: the slice number to be saved """ if self.slice_changed: if hasattr(self, 'drawingROI') and self.drawingROI \ and self.ds is not None \ and len(self.drawingROI.target_pixel_coords) != 0: alpha = float(self.input_alpha_value.text()) pixel_hull_list = calculate_concave_hull_of_points( self.drawingROI.target_pixel_coords, alpha) coord_list = [] for pixel_hull in pixel_hull_list: coord_list.append(pixel_hull) self.drawn_roi_list[image_slice_number] = { 'coords': coord_list, 'ds': self.ds, 'drawingROI': self.drawingROI } self.slice_changed = False return True else: return True return True def on_transect_close(self): """ Function triggered when transect is closed """ if self.upper_limit and self.lower_limit: self.min_pixel_density_line_edit.setText(str(self.lower_limit)) self.max_pixel_density_line_edit.setText(str(self.upper_limit)) self.dicom_view.update_view() def onDrawClicked(self): """ Function triggered when the Draw button is pressed from the menu. """ pixmaps = self.patient_dict_container.get("pixmaps_axial") if self.min_pixel_density_line_edit.text() == "" \ or self.max_pixel_density_line_edit.text() == "": QMessageBox.about(self.draw_roi_window_instance, "Not Enough Data", "Not all values are specified or correct.") else: # Getting most updated selected slice id = self.current_slice dt = self.patient_dict_container.dataset[id] dt.convert_pixel_data() # Path to the selected .dcm file location = self.patient_dict_container.filepaths[id] self.ds = pydicom.dcmread(location) min_pixel = self.min_pixel_density_line_edit.text() max_pixel = self.max_pixel_density_line_edit.text() # If they are number inputs if min_pixel.isdecimal() and max_pixel.isdecimal(): min_pixel = int(min_pixel) max_pixel = int(max_pixel) if min_pixel >= max_pixel: QMessageBox.about( self.draw_roi_window_instance, "Incorrect Input", "Please ensure maximum density is " "atleast higher than minimum density.") self.drawingROI = Drawing( pixmaps[id], dt._pixel_array.transpose(), min_pixel, max_pixel, self.patient_dict_container.dataset[id], self.draw_roi_window_instance, self.slice_changed, self.current_slice, self.drawing_tool_radius, self.keep_empty_pixel, set()) self.slice_changed = True self.dicom_view.view.setScene(self.drawingROI) self.enable_cursor_radius_change_box() else: QMessageBox.about(self.draw_roi_window_instance, "Not Enough Data", "Not all values are specified or correct.") def onBoxDrawClicked(self): """ Function triggered when bounding box button is pressed """ id = self.current_slice dt = self.patient_dict_container.dataset[id] dt.convert_pixel_data() pixmaps = self.patient_dict_container.get("pixmaps_axial") self.bounds_box_draw = DrawBoundingBox(pixmaps[id], dt) self.dicom_view.view.setScene(self.bounds_box_draw) self.disable_cursor_radius_change_box() def onSaveClicked(self): """ Function triggered when Save button is clicked """ # Make sure the user has clicked Draw first if self.save_drawing_progress(image_slice_number=self.current_slice): self.saveROIList() def saveROIList(self): """ Function triggered when saving ROI list """ roi_list = ROI.convert_hull_list_to_contours_data( self.drawn_roi_list, self.patient_dict_container) if len(roi_list) == 0: QMessageBox.about(self.draw_roi_window_instance, "No ROI Detected", "Please ensure you have drawn your ROI first.") return # The list of points will need to be converted into a # single-dimensional array, as RTSTRUCT contour data is stored in # such a way. i.e. [x, y, z, x, y, z, x, y, z, ..., ...] Create a # popup window that modifies the RTSTRUCT and tells the user that # processing is happening. connectSaveROIProgress(self, roi_list, self.dataset_rtss, self.ROI_name, self.roi_saved) def roi_saved(self, new_rtss): """ Function to call save ROI and display progress """ self.signal_roi_drawn.emit((new_rtss, {"draw": self.ROI_name})) QMessageBox.about(self.draw_roi_window_instance, "Saved", "New contour successfully created!") self.closeWindow() def onPreviewClicked(self): """ function triggered when Preview button is clicked """ if hasattr(self, 'drawingROI') and self.drawingROI and len( self.drawingROI.target_pixel_coords) > 0: alpha = float(self.input_alpha_value.text()) polygon_list = calculate_concave_hull_of_points( self.drawingROI.target_pixel_coords, alpha) self.drawingROI.draw_contour_preview(polygon_list) else: QMessageBox.about(self.draw_roi_window_instance, "Not Enough Data", "Please ensure you have drawn your ROI first.") def set_selected_roi_name(self, roi_name): """ function to set selected roi name :param roi_name: roi name selected """ roi_exists = False patient_dict_container = PatientDictContainer() existing_rois = patient_dict_container.get("rois") number_of_rois = len(existing_rois) # Check to see if the ROI already exists for key, value in existing_rois.items(): if roi_name in value['name']: roi_exists = True if roi_exists: QMessageBox.about(self.draw_roi_window_instance, "ROI already exists in RTSS", "Would you like to continue?") self.ROI_name = roi_name self.roi_name_line_edit.setText(self.ROI_name) def onRadiusReduceClicked(self): """ function triggered when user reduce cursor radius """ self.drawing_tool_radius = max(self.drawing_tool_radius - 1, 4) self.draw_roi_window_cursor_radius_change_input.setText( str(self.drawing_tool_radius)) self.draw_roi_window_cursor_radius_change_input.setCursorPosition(0) self.draw_cursor_when_radius_changed() def onRadiusIncreaseClicked(self): """ function triggered when user increase cursor radius """ self.drawing_tool_radius = min(self.drawing_tool_radius + 1, 25) self.draw_roi_window_cursor_radius_change_input.setText( str(self.drawing_tool_radius)) self.draw_cursor_when_radius_changed() def draw_cursor_when_radius_changed(self): """ function to update drawing cursor when radius changed """ if self.drawingROI.cursor: self.drawingROI.draw_cursor( self.drawingROI.current_cursor_x + self.drawing_tool_radius, self.drawingROI.current_cursor_y + self.drawing_tool_radius, self.drawing_tool_radius) else: self.drawingROI.draw_cursor( (self.drawingROI.min_x + self.drawingROI.max_x) / 2, (self.drawingROI.min_y + self.drawingROI.max_y) / 2, self.drawing_tool_radius, True) def init_cursor_radius_change_box(self): """ function to init cursor radius change box """ # Create a horizontal box for containing the cursor radius changing # function self.draw_roi_window_cursor_radius_change_box = QHBoxLayout() self.draw_roi_window_cursor_radius_change_box.setObjectName( "DrawRoiWindowCursorRadiusChangeBox") # Create a label for cursor radius change self.draw_roi_window_cursor_radius_change_label = QLabel() self.draw_roi_window_cursor_radius_change_label.setObjectName( "DrawRoiWindowCursorRadiusChangeLabel") # Create an input box for cursor radius self.draw_roi_window_cursor_radius_change_input = QLineEdit() self.draw_roi_window_cursor_radius_change_input.setObjectName( "DrawRoiWindowCursorRadiusChangeInput") self.draw_roi_window_cursor_radius_change_input.setText(str(19)) self.draw_roi_window_cursor_radius_change_input.setCursorPosition(0) self.draw_roi_window_cursor_radius_change_input.setEnabled(False) self.draw_roi_window_cursor_radius_change_input.setSizePolicy( QSizePolicy.Minimum, QSizePolicy.Minimum) self.draw_roi_window_cursor_radius_change_input.resize( self.draw_roi_window_cursor_radius_change_input.sizeHint().width(), self.draw_roi_window_cursor_radius_change_input.sizeHint().height( )) # Create 2 buttons for increasing and reducing cursor radius # Increase Button self.draw_roi_window_cursor_radius_change_increase_button = \ QPushButton() self.draw_roi_window_cursor_radius_change_increase_button. \ setObjectName("DrawRoiWindowCursorRadiusIncreaseButton") self.draw_roi_window_cursor_radius_change_increase_button. \ setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) self.draw_roi_window_cursor_radius_change_increase_button.resize( QSize(24, 24)) self.draw_roi_window_cursor_radius_change_increase_button.setProperty( "QPushButtonClass", "zoom-button") icon_zoom_in = QtGui.QIcon() icon_zoom_in.addPixmap( QtGui.QPixmap( resource_path('res/images/btn-icons/zoom_in_icon.png'))) self.draw_roi_window_cursor_radius_change_increase_button.setIcon( icon_zoom_in) self.draw_roi_window_cursor_radius_change_increase_button.clicked. \ connect(self.onRadiusIncreaseClicked) # Reduce Button self.draw_roi_window_cursor_radius_change_reduce_button = QPushButton() self.draw_roi_window_cursor_radius_change_reduce_button.setObjectName( "DrawRoiWindowCursorRadiusReduceButton") self.draw_roi_window_cursor_radius_change_reduce_button.setSizePolicy( QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) self.draw_roi_window_cursor_radius_change_reduce_button.resize( QSize(24, 24)) self.draw_roi_window_cursor_radius_change_reduce_button.setProperty( "QPushButtonClass", "zoom-button") icon_zoom_out = QtGui.QIcon() icon_zoom_out.addPixmap( QtGui.QPixmap( resource_path('res/images/btn-icons/zoom_out_icon.png'))) self.draw_roi_window_cursor_radius_change_reduce_button.setIcon( icon_zoom_out) self.draw_roi_window_cursor_radius_change_reduce_button.clicked. \ connect(self.onRadiusReduceClicked) self.draw_roi_window_cursor_radius_change_box.addWidget( self.draw_roi_window_cursor_radius_change_label) self.draw_roi_window_cursor_radius_change_box.addWidget( self.draw_roi_window_cursor_radius_change_input) self.draw_roi_window_cursor_radius_change_box.addWidget( self.draw_roi_window_cursor_radius_change_reduce_button) self.draw_roi_window_cursor_radius_change_box.addWidget( self.draw_roi_window_cursor_radius_change_increase_button) self.draw_roi_window_input_container_box.addRow( self.draw_roi_window_cursor_radius_change_box) self.draw_roi_window_cursor_radius_change_increase_button.setEnabled( False) self.draw_roi_window_cursor_radius_change_reduce_button.setEnabled( False) def disable_cursor_radius_change_box(self): """ function to disable cursor radius change box """ self.draw_roi_window_cursor_radius_change_reduce_button.setEnabled( False) self.draw_roi_window_cursor_radius_change_increase_button.setEnabled( False) self.toggle_keep_empty_pixel_combo_box.setEnabled(False) def enable_cursor_radius_change_box(self): """ function to enable cursor radius change box """ self.draw_roi_window_cursor_radius_change_reduce_button.setEnabled( True) self.draw_roi_window_cursor_radius_change_increase_button.setEnabled( True) self.toggle_keep_empty_pixel_combo_box.setEnabled(True) def closeWindow(self): """ function to close draw roi window """ self.drawn_roi_list = {} if hasattr(self, 'bounds_box_draw'): delattr(self, 'bounds_box_draw') if hasattr(self, 'drawingROI'): delattr(self, 'drawingROI') self.ds = None self.close()
class Ui_ImportSlipDlg(object): def setupUi(self, ImportSlipDlg): if not ImportSlipDlg.objectName(): ImportSlipDlg.setObjectName(u"ImportSlipDlg") ImportSlipDlg.resize(850, 587) self.verticalLayout = QVBoxLayout(ImportSlipDlg) self.verticalLayout.setSpacing(6) self.verticalLayout.setObjectName(u"verticalLayout") self.verticalLayout.setContentsMargins(2, 2, 2, 2) self.InputFrame = QFrame(ImportSlipDlg) self.InputFrame.setObjectName(u"InputFrame") sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.InputFrame.sizePolicy().hasHeightForWidth()) self.InputFrame.setSizePolicy(sizePolicy) self.InputFrame.setFrameShape(QFrame.NoFrame) self.InputFrame.setFrameShadow(QFrame.Plain) self.horizontalLayout_3 = QHBoxLayout(self.InputFrame) self.horizontalLayout_3.setSpacing(2) self.horizontalLayout_3.setObjectName(u"horizontalLayout_3") self.horizontalLayout_3.setContentsMargins(0, 0, 0, 0) self.QRGroup = QGroupBox(self.InputFrame) self.QRGroup.setObjectName(u"QRGroup") sizePolicy1 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy1.setHorizontalStretch(0) sizePolicy1.setVerticalStretch(0) sizePolicy1.setHeightForWidth( self.QRGroup.sizePolicy().hasHeightForWidth()) self.QRGroup.setSizePolicy(sizePolicy1) self.QRGroup.setAlignment(Qt.AlignLeading | Qt.AlignLeft | Qt.AlignVCenter) self.verticalLayout_3 = QVBoxLayout(self.QRGroup) self.verticalLayout_3.setSpacing(6) self.verticalLayout_3.setObjectName(u"verticalLayout_3") self.verticalLayout_3.setContentsMargins(2, 2, 2, 2) self.GetQRfromCameraBtn = QPushButton(self.QRGroup) self.GetQRfromCameraBtn.setObjectName(u"GetQRfromCameraBtn") self.verticalLayout_3.addWidget(self.GetQRfromCameraBtn) self.LoadQRfromFileBtn = QPushButton(self.QRGroup) self.LoadQRfromFileBtn.setObjectName(u"LoadQRfromFileBtn") self.verticalLayout_3.addWidget(self.LoadQRfromFileBtn) self.GetQRfromClipboardBtn = QPushButton(self.QRGroup) self.GetQRfromClipboardBtn.setObjectName(u"GetQRfromClipboardBtn") self.verticalLayout_3.addWidget(self.GetQRfromClipboardBtn) self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout_3.addItem(self.verticalSpacer) self.horizontalLayout_3.addWidget(self.QRGroup) self.SlipDataGroup = QGroupBox(self.InputFrame) self.SlipDataGroup.setObjectName(u"SlipDataGroup") sizePolicy1.setHeightForWidth( self.SlipDataGroup.sizePolicy().hasHeightForWidth()) self.SlipDataGroup.setSizePolicy(sizePolicy1) self.gridLayout_2 = QGridLayout(self.SlipDataGroup) self.gridLayout_2.setObjectName(u"gridLayout_2") self.gridLayout_2.setContentsMargins(2, 2, 2, 2) self.GetSlipBtn = QPushButton(self.SlipDataGroup) self.GetSlipBtn.setObjectName(u"GetSlipBtn") self.gridLayout_2.addWidget(self.GetSlipBtn, 7, 1, 1, 1) self.AmountLbl = QLabel(self.SlipDataGroup) self.AmountLbl.setObjectName(u"AmountLbl") self.gridLayout_2.addWidget(self.AmountLbl, 0, 2, 1, 1) self.SlipTimstamp = QDateTimeEdit(self.SlipDataGroup) self.SlipTimstamp.setObjectName(u"SlipTimstamp") self.SlipTimstamp.setTimeSpec(Qt.UTC) self.gridLayout_2.addWidget(self.SlipTimstamp, 0, 1, 1, 1) self.TimestampLbl = QLabel(self.SlipDataGroup) self.TimestampLbl.setObjectName(u"TimestampLbl") self.gridLayout_2.addWidget(self.TimestampLbl, 0, 0, 1, 1) self.FDlbl = QLabel(self.SlipDataGroup) self.FDlbl.setObjectName(u"FDlbl") self.gridLayout_2.addWidget(self.FDlbl, 2, 0, 1, 1) self.SlipAmount = QLineEdit(self.SlipDataGroup) self.SlipAmount.setObjectName(u"SlipAmount") self.gridLayout_2.addWidget(self.SlipAmount, 0, 3, 1, 1) self.FP = QLineEdit(self.SlipDataGroup) self.FP.setObjectName(u"FP") self.gridLayout_2.addWidget(self.FP, 2, 3, 1, 1) self.FD = QLineEdit(self.SlipDataGroup) self.FD.setObjectName(u"FD") self.gridLayout_2.addWidget(self.FD, 2, 1, 1, 1) self.FNlbl = QLabel(self.SlipDataGroup) self.FNlbl.setObjectName(u"FNlbl") self.gridLayout_2.addWidget(self.FNlbl, 4, 0, 1, 1) self.DummyLbl = QLabel(self.SlipDataGroup) self.DummyLbl.setObjectName(u"DummyLbl") self.gridLayout_2.addWidget(self.DummyLbl, 7, 0, 1, 1) self.SlipTypeLbl = QLabel(self.SlipDataGroup) self.SlipTypeLbl.setObjectName(u"SlipTypeLbl") self.gridLayout_2.addWidget(self.SlipTypeLbl, 4, 2, 1, 1) self.FN = QLineEdit(self.SlipDataGroup) self.FN.setObjectName(u"FN") self.gridLayout_2.addWidget(self.FN, 4, 1, 1, 1) self.LoadJSONfromFileBtn = QPushButton(self.SlipDataGroup) self.LoadJSONfromFileBtn.setObjectName(u"LoadJSONfromFileBtn") self.gridLayout_2.addWidget(self.LoadJSONfromFileBtn, 7, 3, 1, 1) self.FPlbl = QLabel(self.SlipDataGroup) self.FPlbl.setObjectName(u"FPlbl") self.gridLayout_2.addWidget(self.FPlbl, 2, 2, 1, 1) self.line = QFrame(self.SlipDataGroup) self.line.setObjectName(u"line") self.line.setFrameShape(QFrame.HLine) self.line.setFrameShadow(QFrame.Sunken) self.gridLayout_2.addWidget(self.line, 5, 0, 1, 4) self.SlipType = QComboBox(self.SlipDataGroup) self.SlipType.addItem("") self.SlipType.addItem("") self.SlipType.setObjectName(u"SlipType") self.gridLayout_2.addWidget(self.SlipType, 4, 3, 1, 1) self.horizontalLayout_3.addWidget(self.SlipDataGroup) self.CameraGroup = QGroupBox(self.InputFrame) self.CameraGroup.setObjectName(u"CameraGroup") self.verticalLayout_2 = QVBoxLayout(self.CameraGroup) self.verticalLayout_2.setSpacing(2) self.verticalLayout_2.setObjectName(u"verticalLayout_2") self.verticalLayout_2.setContentsMargins(2, 2, 2, 2) self.ScannerQR = QRScanner(self.CameraGroup) self.ScannerQR.setObjectName(u"ScannerQR") sizePolicy2 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding) sizePolicy2.setHorizontalStretch(0) sizePolicy2.setVerticalStretch(0) sizePolicy2.setHeightForWidth( self.ScannerQR.sizePolicy().hasHeightForWidth()) self.ScannerQR.setSizePolicy(sizePolicy2) self.verticalLayout_2.addWidget(self.ScannerQR) self.CameraBtnFrame = QFrame(self.CameraGroup) self.CameraBtnFrame.setObjectName(u"CameraBtnFrame") self.CameraBtnFrame.setFrameShape(QFrame.NoFrame) self.CameraBtnFrame.setFrameShadow(QFrame.Plain) self.horizontalLayout_5 = QHBoxLayout(self.CameraBtnFrame) self.horizontalLayout_5.setSpacing(2) self.horizontalLayout_5.setObjectName(u"horizontalLayout_5") self.horizontalLayout_5.setContentsMargins(0, 0, 0, 0) self.StopCameraBtn = QPushButton(self.CameraBtnFrame) self.StopCameraBtn.setObjectName(u"StopCameraBtn") self.horizontalLayout_5.addWidget(self.StopCameraBtn) self.verticalLayout_2.addWidget(self.CameraBtnFrame) self.horizontalLayout_3.addWidget(self.CameraGroup) self.verticalLayout.addWidget(self.InputFrame) self.SlipGroup = QGroupBox(ImportSlipDlg) self.SlipGroup.setObjectName(u"SlipGroup") sizePolicy2.setHeightForWidth( self.SlipGroup.sizePolicy().hasHeightForWidth()) self.SlipGroup.setSizePolicy(sizePolicy2) self.gridLayout = QGridLayout(self.SlipGroup) self.gridLayout.setObjectName(u"gridLayout") self.gridLayout.setContentsMargins(2, 2, 2, 2) self.SlipDateTime = QDateTimeEdit(self.SlipGroup) self.SlipDateTime.setObjectName(u"SlipDateTime") self.SlipDateTime.setTimeSpec(Qt.UTC) self.gridLayout.addWidget(self.SlipDateTime, 2, 1, 1, 1) self.DateTimeLbl = QLabel(self.SlipGroup) self.DateTimeLbl.setObjectName(u"DateTimeLbl") self.gridLayout.addWidget(self.DateTimeLbl, 1, 1, 1, 1) self.CorrespondenceLbl = QLabel(self.SlipGroup) self.CorrespondenceLbl.setObjectName(u"CorrespondenceLbl") self.gridLayout.addWidget(self.CorrespondenceLbl, 3, 2, 1, 1) self.PeerEdit = PeerSelector(self.SlipGroup) self.PeerEdit.setObjectName(u"PeerEdit") self.gridLayout.addWidget(self.PeerEdit, 3, 3, 1, 1) self.PeerLbl = QLabel(self.SlipGroup) self.PeerLbl.setObjectName(u"PeerLbl") self.gridLayout.addWidget(self.PeerLbl, 3, 0, 1, 1) self.SlipShopName = QLineEdit(self.SlipGroup) self.SlipShopName.setObjectName(u"SlipShopName") self.SlipShopName.setEnabled(False) self.gridLayout.addWidget(self.SlipShopName, 3, 1, 1, 1) self.LinesLbl = QLabel(self.SlipGroup) self.LinesLbl.setObjectName(u"LinesLbl") self.LinesLbl.setAlignment(Qt.AlignLeading | Qt.AlignLeft | Qt.AlignTop) self.gridLayout.addWidget(self.LinesLbl, 4, 0, 1, 1) self.AccountLbl = QLabel(self.SlipGroup) self.AccountLbl.setObjectName(u"AccountLbl") self.gridLayout.addWidget(self.AccountLbl, 1, 3, 1, 1) self.AccountEdit = AccountSelector(self.SlipGroup) self.AccountEdit.setObjectName(u"AccountEdit") self.gridLayout.addWidget(self.AccountEdit, 2, 3, 1, 1) self.LinesTableView = QTableView(self.SlipGroup) self.LinesTableView.setObjectName(u"LinesTableView") self.LinesTableView.verticalHeader().setVisible(False) self.LinesTableView.verticalHeader().setMinimumSectionSize(20) self.LinesTableView.verticalHeader().setDefaultSectionSize(20) self.gridLayout.addWidget(self.LinesTableView, 4, 1, 1, 4) self.AssignCategoryBtn = QPushButton(self.SlipGroup) self.AssignCategoryBtn.setObjectName(u"AssignCategoryBtn") self.gridLayout.addWidget(self.AssignCategoryBtn, 2, 4, 1, 1) self.AssignTagBtn = QPushButton(self.SlipGroup) self.AssignTagBtn.setObjectName(u"AssignTagBtn") self.gridLayout.addWidget(self.AssignTagBtn, 3, 4, 1, 1) self.verticalLayout.addWidget(self.SlipGroup) self.DialogButtonsFrame = QFrame(ImportSlipDlg) self.DialogButtonsFrame.setObjectName(u"DialogButtonsFrame") self.DialogButtonsFrame.setFrameShape(QFrame.NoFrame) self.DialogButtonsFrame.setFrameShadow(QFrame.Plain) self.horizontalLayout_4 = QHBoxLayout(self.DialogButtonsFrame) self.horizontalLayout_4.setObjectName(u"horizontalLayout_4") self.horizontalLayout_4.setContentsMargins(2, 2, 2, 2) self.ClearBtn = QPushButton(self.DialogButtonsFrame) self.ClearBtn.setObjectName(u"ClearBtn") self.ClearBtn.setEnabled(True) self.horizontalLayout_4.addWidget(self.ClearBtn) self.AddOperationBtn = QPushButton(self.DialogButtonsFrame) self.AddOperationBtn.setObjectName(u"AddOperationBtn") self.AddOperationBtn.setEnabled(True) self.horizontalLayout_4.addWidget(self.AddOperationBtn) self.CloseBtn = QPushButton(self.DialogButtonsFrame) self.CloseBtn.setObjectName(u"CloseBtn") self.horizontalLayout_4.addWidget(self.CloseBtn) self.verticalLayout.addWidget(self.DialogButtonsFrame) self.retranslateUi(ImportSlipDlg) self.CloseBtn.clicked.connect(ImportSlipDlg.close) QMetaObject.connectSlotsByName(ImportSlipDlg) # setupUi def retranslateUi(self, ImportSlipDlg): ImportSlipDlg.setWindowTitle( QCoreApplication.translate("ImportSlipDlg", u"Import Slip", None)) self.QRGroup.setTitle( QCoreApplication.translate("ImportSlipDlg", u"QR-code", None)) self.GetQRfromCameraBtn.setText( QCoreApplication.translate("ImportSlipDlg", u"Get from camera", None)) self.LoadQRfromFileBtn.setText( QCoreApplication.translate("ImportSlipDlg", u"Load from file", None)) self.GetQRfromClipboardBtn.setText( QCoreApplication.translate("ImportSlipDlg", u"Get from clipboard", None)) self.SlipDataGroup.setTitle( QCoreApplication.translate("ImportSlipDlg", u"Slip data", None)) self.GetSlipBtn.setText( QCoreApplication.translate("ImportSlipDlg", u"Get slip from internet", None)) self.AmountLbl.setText( QCoreApplication.translate("ImportSlipDlg", u"Amount:", None)) self.SlipTimstamp.setDisplayFormat( QCoreApplication.translate("ImportSlipDlg", u"dd/MM/yyyy hh:mm:ss", None)) self.TimestampLbl.setText( QCoreApplication.translate("ImportSlipDlg", u"Date/Time:", None)) self.FDlbl.setText( QCoreApplication.translate("ImportSlipDlg", u"FD:", None)) self.FNlbl.setText( QCoreApplication.translate("ImportSlipDlg", u"FN:", None)) self.DummyLbl.setText("") self.SlipTypeLbl.setText( QCoreApplication.translate("ImportSlipDlg", u"Type:", None)) self.LoadJSONfromFileBtn.setText( QCoreApplication.translate("ImportSlipDlg", u"Load slip from JSON file", None)) self.FPlbl.setText( QCoreApplication.translate("ImportSlipDlg", u"FP:", None)) self.SlipType.setItemText( 0, QCoreApplication.translate("ImportSlipDlg", u"Purchase", None)) self.SlipType.setItemText( 1, QCoreApplication.translate("ImportSlipDlg", u"Return", None)) self.CameraGroup.setTitle( QCoreApplication.translate("ImportSlipDlg", u"Camera", None)) self.StopCameraBtn.setText( QCoreApplication.translate("ImportSlipDlg", u"Stop camera", None)) self.SlipGroup.setTitle( QCoreApplication.translate("ImportSlipDlg", u"Slip", None)) self.SlipDateTime.setDisplayFormat( QCoreApplication.translate("ImportSlipDlg", u"dd/MM/yyyy hh:mm:ss", None)) self.DateTimeLbl.setText( QCoreApplication.translate("ImportSlipDlg", u"Date / Time:", None)) self.CorrespondenceLbl.setText( QCoreApplication.translate("ImportSlipDlg", u"-->", None)) self.PeerLbl.setText( QCoreApplication.translate("ImportSlipDlg", u"Peer:", None)) self.LinesLbl.setText( QCoreApplication.translate("ImportSlipDlg", u"Lines:", None)) self.AccountLbl.setText( QCoreApplication.translate("ImportSlipDlg", u"Account:", None)) self.AssignCategoryBtn.setText( QCoreApplication.translate("ImportSlipDlg", u"Auto-assign categories", None)) self.AssignTagBtn.setText( QCoreApplication.translate("ImportSlipDlg", u"Set Tag for all lines", None)) self.ClearBtn.setText( QCoreApplication.translate("ImportSlipDlg", u"Clear", None)) self.AddOperationBtn.setText( QCoreApplication.translate("ImportSlipDlg", u"Add", None)) self.CloseBtn.setText( QCoreApplication.translate("ImportSlipDlg", u"Close", None))
class AddSteamWidget(TritonWidget): def __init__(self, base, *args, **kwargs): TritonWidget.__init__(self, base, *args, **kwargs) self.sharedSecret = None self.identitySecret = None self.steamId = None self.type = Globals.SteamAuth self.setWindowTitle('Add Steam') self.setBackgroundColor(self, Qt.white) self.boxLayout = QVBoxLayout(self) self.boxLayout.setContentsMargins(20, 20, 20, 20) self.nameWidget = TextboxWidget(base, 'Name:') self.steamIdWidget = TextboxWidget(base, 'Steam ID:') self.sharedWidget = TextboxWidget(base, 'Shared Secret:') self.identityWidget = TextboxWidget(base, 'Identity Secret:') self.verifyLabel = QLabel() self.verifyLabel.setText('Click the Verify button to check the first code.') self.verifyLabel.setFont(QFont('Helvetica', 10)) self.verifyBox = QLineEdit() self.verifyBox.setFixedWidth(150) self.verifyBox.setFont(QFont('Helvetica', 10)) self.verifyBox.setEnabled(False) palette = QPalette() palette.setColor(QPalette.Text, Qt.black) self.verifyBox.setPalette(palette) self.verifyBox.setAlignment(Qt.AlignCenter) self.verifyButton = QPushButton('Verify') self.verifyButton.clicked.connect(self.checkVerify) self.verifyButton.setFixedWidth(150) self.addButton = QPushButton('OK') self.addButton.clicked.connect(self.add) self.boxLayout.addWidget(self.nameWidget) self.boxLayout.addWidget(self.steamIdWidget) self.boxLayout.addWidget(self.sharedWidget) self.boxLayout.addWidget(self.identityWidget) self.boxLayout.addSpacing(10) self.boxLayout.addWidget(self.verifyLabel) self.boxLayout.addWidget(self.verifyBox, 0, Qt.AlignCenter) self.boxLayout.addWidget(self.verifyButton, 0, Qt.AlignCenter) self.boxLayout.addSpacing(10) self.boxLayout.addWidget(self.addButton, 0, Qt.AlignRight) self.setFixedSize(self.sizeHint()) self.center() self.show() def getName(self): return self.nameWidget.box.text() def getAccount(self): return {'name': self.getName(), 'type': self.type, 'sharedSecret': self.sharedSecret, 'identitySecret': self.identitySecret, 'steamId': self.steamId, 'icon': 'icons/SteamIcon.png'} def invalidateSecret(self, text=''): self.sharedSecret = None self.identitySecret = None self.steamId = None self.verifyBox.setText(text) def checkVerify(self): self.sharedSecret = self.sharedWidget.box.text() self.identitySecret = self.identityWidget.box.text() self.steamId = self.steamIdWidget.box.text() if not self.sharedSecret or not self.identitySecret or not self.steamId: self.invalidateSecret('Invalid') return try: self.verifyBox.setText(self.base.getAuthCode(self.getAccount())) except: self.invalidateSecret('Invalid') def add(self): if not self.sharedSecret or not self.getName(): return self.base.addAccount(self.getAccount()) self.close()
class TableClothGenerator(QMainWindow): def __init__(self, parent=None): super().__init__(parent) # Main UI settings self.setWindowTitle('Tablecloth Generator') self.setWindowIcon(QIcon('icon.ico')) self.centralWidget = QWidget() self.setCentralWidget(self.centralWidget) self.resize(350, 350) self.center() self._createMenuBar() self.MainUI() def MainUI(self): # Obtain the configs fp_config = open(THISDIR + "\\config\\config.json", "r", encoding="utf-8") self.config = json.loads(fp_config.read()) fp_config.close() # Obtain and List the teams fp_teams = open(THISDIR + "\\config\\teams.json", "r", encoding="utf-8") conf_teams = json.loads(fp_teams.read()) fp_teams.close() self.teams = conf_teams["teams"] self.players = conf_teams["players"] # Obtain all images needed to create the tablecloth self.background = Image.open(THISDIR + "\\images\\mat.png") self.table_border = Image.open(THISDIR + "\\images\\table_border.png") self.tech_lines = Image.open(THISDIR + "\\images\\technical_lines.png") # Check if there's no configuration set up # and prompt to create/import one if self.config["total_teams"] == 0: self.no_config = QMessageBox.question(self, "No configuration", "No configuration has been found. Do you wish to set up a new one?", QMessageBox.Yes | QMessageBox.No) if self.no_config == QMessageBox.Yes: self.CreateTeamsWindow() self.bg_image = self.config["image_route"] self.players_combobox = QComboBox() self.UpdatePlayersList() self.players_combobox.setEditable(True) self.players_combobox.completer()\ .setCompletionMode(QCompleter.PopupCompletion) self.players_combobox.setInsertPolicy(QComboBox.NoInsert) # Set up the GUI self.statusBar().showMessage("Remember: Rig responsibly.") # Bottom (EAST) self.label_east = QLabel(self) self.label_east.setText("<h1>East Seat</h1>") self.label_east.setAlignment(QtCore.Qt.AlignCenter) self.image_east = QLabel(self) self.image_east.setPixmap(QPixmap("images/logos/team1.png")\ .scaled(100,100)) self.image_east.setAlignment(QtCore.Qt.AlignCenter) self.search_east = QLineEdit() self.search_east.setAlignment(QtCore.Qt.AlignCenter) self.search_east.editingFinished.connect( lambda: self.searchPlayer(self.search_east.text(), self.cloth_east)) self.cloth_east = QComboBox() self.cloth_east.setModel(self.players_combobox.model()) self.cloth_east.currentIndexChanged.connect( lambda: self.SwitchImage(self.cloth_east, self.image_east)) # Right (SOUTH) self.label_south = QLabel(self) self.label_south.setText("<h1>South Seat</h1>") self.label_south.setAlignment(QtCore.Qt.AlignCenter) self.image_south = QLabel(self) self.image_south.setPixmap(QPixmap("images/logos/team1.png")\ .scaled(100,100)) self.image_south.setAlignment(QtCore.Qt.AlignCenter) self.image_south.show() self.search_south = QLineEdit() self.search_south.setAlignment(QtCore.Qt.AlignCenter) self.search_south.editingFinished.connect( lambda: self.searchPlayer(self.search_south.text(), self.cloth_south)) self.cloth_south = QComboBox() self.cloth_south.setModel(self.players_combobox.model()) self.cloth_south.currentIndexChanged.connect( lambda: self.SwitchImage(self.cloth_south, self.image_south)) # Top (WEST) self.label_west = QLabel(self) self.label_west.setText("<h1>West Seat</h1>") self.label_west.setAlignment(QtCore.Qt.AlignCenter) self.image_west = QLabel(self) self.image_west.setPixmap(QPixmap("images/logos/team1.png")\ .scaled(100,100)) self.image_west.setAlignment(QtCore.Qt.AlignCenter) self.image_west.show() self.cloth_west = QComboBox() self.search_west = QLineEdit() self.search_west.setAlignment(QtCore.Qt.AlignCenter) self.search_west.editingFinished.connect( lambda: self.searchPlayer(self.search_west.text(), self.cloth_west)) self.cloth_west.setModel(self.players_combobox.model()) self.cloth_west.currentIndexChanged.connect( lambda: self.SwitchImage(self.cloth_west, self.image_west)) # Left (NORTH) self.label_north = QLabel(self) self.label_north.setText("<h1>North Seat</h1>") self.label_north.setAlignment(QtCore.Qt.AlignCenter) self.image_north = QLabel(self) self.image_north.setPixmap(QPixmap("images/logos/team1.png")\ .scaled(100,100)) self.image_north.setAlignment(QtCore.Qt.AlignCenter) self.image_north.show() self.cloth_north = QComboBox() self.search_north = QLineEdit() self.search_north.setAlignment(QtCore.Qt.AlignCenter) self.search_north.editingFinished.connect( lambda: self.searchPlayer(self.search_north.text(), self.cloth_north)) self.cloth_north.setModel(self.players_combobox.model()) self.cloth_north.currentIndexChanged.connect( lambda: self.SwitchImage(self.cloth_north, self.image_north)) # Technical lines self.technical_lines = QCheckBox("Show Technical lines", self) # Generate button self.generate = QPushButton(self) self.generate.setText("Generate Tablecloth") self.generate.clicked.connect(self.GeneratePreview) # Add custom mat self.custom_mat = QPushButton(self) self.custom_mat.setText("Add Mat") self.custom_mat.clicked.connect(self.MatDialog) # Create the layout grid_layout = QGridLayout() grid_layout.setAlignment(QtCore.Qt.AlignCenter) grid_layout.setAlignment(QtCore.Qt.AlignTop) # Labels East, West grid_layout.addWidget(self.label_east, 1, 1) grid_layout.addWidget(self.label_west, 1, 2) # Image preview East, West grid_layout.addWidget(self.image_east, 2, 1) grid_layout.addWidget(self.image_west, 2, 2) # Search player East, West grid_layout.addWidget(self.search_east, 3, 1) grid_layout.addWidget(self.search_west, 3, 2) # Player combobox East, West grid_layout.addWidget(self.cloth_east, 4, 1) grid_layout.addWidget(self.cloth_west, 4, 2) # Labes South, North grid_layout.addWidget(self.label_south, 5, 1) grid_layout.addWidget(self.label_north, 5, 2) # Image preview South, North grid_layout.addWidget(self.image_south, 6, 1) grid_layout.addWidget(self.image_north, 6, 2) # Search player South, North grid_layout.addWidget(self.search_south, 7, 1) grid_layout.addWidget(self.search_north, 7, 2) # Player combobox South, North grid_layout.addWidget(self.cloth_south, 8, 1) grid_layout.addWidget(self.cloth_north, 8, 2) # Technical lines grid_layout.addWidget(self.technical_lines, 9, 1) # Custom mat/bg grid_layout.addWidget(self.custom_mat, 10, 1) # Generate grid_layout.addWidget(self.generate, 10, 2) self.centralWidget.setLayout(grid_layout) # Create the window self.show() def _createMenuBar(self): # Settings and stuff for the toolbar menubar = QMenuBar(self) file_menu = QMenu("&File", self) file_menu.addAction("Create Team(s)", self.CreateTeamsWindow) file_menu.addAction("Edit Team(s)", self.EditTeamsWindow) file_menu.addAction("Exit", self.close) settings_menu = QMenu("&Settings", self) settings_menu.addAction("Version", self.SeeVersion) settings_menu.addAction("Help", self.GetHelp) menubar.addMenu(file_menu) menubar.addMenu(settings_menu) self.setMenuBar(menubar) def _createProgressBar(self): self.progress_bar = QProgressBar() self.progress_bar.minimum = 0 self.progress_bar.maximum = 100 self.progress_bar.setValue(0) self.progress_bar.setTextVisible(False) self.progress_bar.setGeometry(50, 50, 10, 10) self.progress_bar.setAlignment(QtCore.Qt.AlignRight) self.progress_bar.adjustSize() self.statusBar().addPermanentWidget(self.progress_bar) self.ChangeAppStatus(False) def SwitchImage(self, cloth, image): # It shows you the team logo. No way you can miss those, right? team_id = self.SearchTeamID(cloth, True) image.setPixmap(QPixmap( "images/logos/team%d.png" % team_id).scaled(100,100)) def searchPlayer(self, text, combobox): # It even searches the player for you. What more could you want? search_index = combobox.findText(text, QtCore.Qt.MatchContains) if search_index == -1: QMessageBox.warning(self, "Error", "No player found") else: combobox.setCurrentIndex(search_index) def CreateTeamsWindow(self): self.teamcreation_wid = EditionWidget() self.teamcreation_wid.resize(400, 200) self.teamcreation_wid.setWindowTitle("Teams configuration") self.new_config = {} id_label = QLabel(self) id_label.setText("Team ID: ") self.num_id = QLabel(self) current_id = str(self.config["total_teams"] + 1) self.num_id.setText(current_id) name_label = QLabel(self) name_label.setText("Team Name:") name_label.setFocus() self.name_input = QLineEdit(self) members_label = QLabel(self) members_label.setText("Members (write and press enter):") members_input = QLineEdit(self) members_input.editingFinished.connect( lambda: self.AddMember(members_input)) self.members_list = QListWidget(self) import_image = QPushButton(self) import_image.setText("Import Team Image") import_image.clicked.connect(self.ImportTeamImage) add_team = QPushButton(self) add_team.setText("Add Team") add_team.clicked.connect( lambda: self.addTeamFunction(self.name_input.text(), self.members_list)) import_config = QPushButton(self) import_config.setText("Import configuration") import_config.clicked.connect(self.importTeamFunction) config_lay = QGridLayout() config_lay.addWidget(id_label, 1, 0) config_lay.addWidget(self.num_id, 1, 1) config_lay.addWidget(name_label, 2, 0) config_lay.addWidget(self.name_input, 2, 1) config_lay.addWidget(members_label, 3, 0) config_lay.addWidget(members_input, 3, 1) config_lay.addWidget(self.members_list, 4, 0, 2, 2) config_lay.addWidget(add_team, 6, 0) config_lay.addWidget(import_image, 6, 1) config_lay.addWidget(import_config, 7, 0, 1, 2) self.teamcreation_wid.setLayout(config_lay) self.teamcreation_wid.setWindowModality(QtCore.Qt.ApplicationModal) self.teamcreation_wid.activateWindow() self.teamcreation_wid.raise_() self.teamcreation_wid.show() def addTeamFunction(self, name, members): fp_teams = open(THISDIR + "\\config\\teams.json", "r", encoding="utf-8") current_teams = json.loads(fp_teams.read()) fp_teams.close() team = {} current_teams["teams"].append(name) current_teams["players"][name] = [str(self.members_list.item(i).text())\ for i in range(self.members_list.count())] new_team = open(THISDIR + "\\config\\teams.json", "w+", encoding="utf-8") add_config = open(THISDIR + "\\config\\config.json", "w+", encoding="utf-8") self.teams = current_teams["teams"] self.players = current_teams["players"] self.config["total_teams"] += 1 new_id = self.config["total_teams"] + 1 self.num_id.setText(str(new_id)) add_config.write(json.dumps(self.config, indent=4)) new_team.write(json.dumps(current_teams, indent=4)) new_team.close() self.name_input.clear() self.members_list.clear() self.UpdatePlayersList() def ImportTeamImage(self): image_dialog = QFileDialog(self) image_dialog = QFileDialog.getOpenFileName(filter="Images (*.png)", selectedFilter="Images (*.png)") if image_dialog[0] != "": new_team_logo = Image.open(image_dialog[0]).convert("RGBA") if new_team_logo.size != (250, 250): new_team_logo.resize((250, 250)) new_team_logo.save(THISDIR+"\\images\\logos\\team%s.png"\ % self.num_id.text()) QMessageBox.information(self, "Team Image", "Team image added.") def importTeamFunction(self): file_dialog = QFileDialog(self) file_dialog = QFileDialog.getOpenFileName( filter="Team Files (*.json *.zip)", selectedFilter="Team Files (*.json *.zip)") if file_dialog[0] != "": if is_zipfile(file_dialog[0]): with ZipFile(file_dialog[0]) as zip_import: list_of_files = zip_import.namelist() for fimp in list_of_files: if fimp.startswith('logos'): zip_import.extract(fimp, path=THISDIR+'\\images\\') imported_teams = zip_import.read('teams.json') imported_teams = imported_teams.decode('utf-8') else: imported_teams = open(file_dialog[0], "r", encoding="utf-8").read() json_teams = json.loads(imported_teams) self.teams = json_teams["teams"] self.players = json_teams["players"] new_teams = open(THISDIR + "\\config\\teams.json", "w+", encoding="utf-8") new_teams.write(json.dumps(json_teams, indent=4)) new_teams.close() old_config = open(THISDIR + "\\config\\config.json", "r", encoding="utf-8").read() old_config = json.loads(old_config) old_config["total_teams"] = len(json_teams["teams"]) self.config = old_config new_config = open(THISDIR + "\\config\\config.json", "w+", encoding="utf-8") new_config.write(json.dumps(self.config, indent=4)) new_config.close() self.UpdatePlayersList() self.image_east.setPixmap(QPixmap("images/logos/team1.png")\ .scaled(100,100)) self.cloth_east.setModel(self.players_combobox.model()) self.image_south.setPixmap(QPixmap("images/logos/team1.png")\ .scaled(100,100)) self.cloth_south.setModel(self.players_combobox.model()) self.image_west.setPixmap(QPixmap("images/logos/team1.png")\ .scaled(100,100)) self.cloth_west.setModel(self.players_combobox.model()) self.image_north.setPixmap(QPixmap("images/logos/team1.png")\ .scaled(100,100)) self.cloth_north.setModel(self.players_combobox.model()) self.statusBar().showMessage("Teams imported successfully.") self.teamcreation_wid.close() def AddMember(self, member): self.members_list.addItem(member.text()) member.clear() def EditTeamsWindow(self): self.teamedit_wid = EditionWidget() self.teamedit_wid.resize(400, 320) self.teamedit_wid.setWindowTitle("Edit Teams") self.teams_list = QComboBox(self) self.teams_list.addItem("--- Select a team ---") for team in self.teams: self.teams_list.addItem(team) self.teams_list.currentIndexChanged.connect(self.UpdateTeamInfo) team_id_label = QLabel(self) team_id_label.setText("Team ID: ") self.config_team_id = QLabel(self) team_name_label = QLabel(self) team_name_label.setText("Team name: ") self.config_team_name = QLabel(self) team_members_label = QLabel(self) team_members_label.setText("Team members: ") self.config_team_members = QListWidget(self) add_member_label = QLabel(self) add_member_label.setText("Add new member: ") add_member_input = QLineEdit(self) add_member_input.editingFinished.connect(self.AddNewMember) delete_member = QPushButton(self) delete_member.setText("Delete member") delete_member.clicked.connect(self.DeleteMember) delete_team = QPushButton(self) delete_team.setText("Delete Team") delete_team.clicked.connect(self.DeleteTeam) save_changes = QPushButton(self) save_changes.setText("Save changes") save_changes.clicked.connect(self.SaveEdits) export_config = QPushButton(self) export_config.setText("Export Configuration") export_config.clicked.connect(self.ExportTeams) config_lay = QGridLayout() config_lay.addWidget(self.teams_list, 1, 0) config_lay.addWidget(team_id_label, 2, 0) config_lay.addWidget(self.config_team_id, 2, 1) config_lay.addWidget(team_name_label, 3, 0) config_lay.addWidget(self.config_team_name, 3, 1, 1, 2) config_lay.addWidget(team_members_label, 4, 0) config_lay.addWidget(self.config_team_members, 5, 0) config_lay.addWidget(add_member_label, 6, 0) config_lay.addWidget(add_member_input, 6, 1, 1, 2) config_lay.addWidget(delete_member, 7, 0) config_lay.addWidget(delete_team, 7, 1) config_lay.addWidget(save_changes, 8, 0) config_lay.addWidget(export_config, 8, 1) self.teamedit_wid.setLayout(config_lay) self.teamedit_wid.setWindowModality(QtCore.Qt.ApplicationModal) self.teamedit_wid.activateWindow() self.teamedit_wid.raise_() self.teamedit_wid.show() def UpdateTeamInfo(self): sender = self.sender() if sender.currentIndex() > 0: team_id = sender.currentIndex() self.config_team_id.setText(str(team_id)) self.config_team_name.setText(sender.currentText()) if self.config_team_members.count() > 0: self.config_team_members.clear() self.config_team_members.addItems( self.players[sender.currentText()]) def AddNewMember(self): sender = self.sender() self.config_team_members.addItem(sender.text()) sender.clear() def DeleteMember(self): list_members = self.config_team_members.selectedItems() if len(list_members) == 0: QMessageBox.warning(self, "Error", "No player selected") else: for member in list_members: self.config_team_members.takeItem( self.config_team_members.row(member)) def DeleteTeam(self): team_id = int(self.config_team_id.text()) is_last_item = self.teams[self.teams.index( self.config_team_name.text())] == (self.teams[len(self.teams)-1]) self.teams.pop(self.teams.index(self.config_team_name.text())) self.players.pop(self.config_team_name.text()) new_teamlist = {} new_teamlist["teams"] = self.teams new_teamlist["players"] = self.players current_teams = open(THISDIR + "\\config\\teams.json", "w+", encoding="utf-8") current_teams.write(json.dumps(new_teamlist, indent=4)) current_teams.close() if is_last_item == True: self.teams_list.setCurrentIndex(1) else: self.teams_list.setCurrentIndex(team_id+1) self.teams_list.removeItem(team_id) self.UpdatePlayersList() self.cloth_east.setModel(self.players_combobox.model()) self.cloth_south.setModel(self.players_combobox.model()) self.cloth_west.setModel(self.players_combobox.model()) self.cloth_north.setModel(self.players_combobox.model()) def ExportTeams(self): export_dir = self.config["save_route"] if self.config["save_route"] \ is not None else THISDIR exported_file = QFileDialog.getSaveFileName(self, "Save File", export_dir, "Save files (*.zip)") if exported_file[0] != "": export_filename = exported_file[0] if export_filename.endswith(".zip") is False: export_filename += ".zip" files_to_export = [] files_to_export.append("config\\teams.json") for root, directories, files in os.walk(THISDIR+"\\images\\logos"): for filename in files: filepath = os.path.join(root, filename) files_to_export.append(filepath) with ZipFile(export_filename, "w") as export_zip: for exp_file in files_to_export: export_name = exp_file if exp_file.endswith(".json"): split_name = exp_file.split("\\") export_name = split_name[-1] if exp_file.endswith(".png"): split_name = exp_file.split("\\") export_name = "\\logos\\" + split_name[-1] export_zip.write(exp_file, arcname=export_name) export_zip.close() if os.path.exists(export_filename): QMessageBox.information(self, "Export", "The export was successful") def SaveEdits(self): list_members = [str(self.config_team_members.item(i).text()) for i in \ range(self.config_team_members.count())] self.players[self.config_team_name.text()] = list_members new_teamlist = {} new_teamlist["teams"] = self.teams new_teamlist["players"] = self.players current_teams = open(THISDIR + "\\config\\teams.json", "w+", encoding="utf-8") current_teams.write(json.dumps(new_teamlist, indent=4)) current_teams.close() self.teamedit_wid.close() self.statusBar().showMessage("Settings saved.") def MatDialog(self): mat_dialog = QFileDialog(self) mat_dialog = QFileDialog.getOpenFileName(filter="Images (*.png *.jpg)", selectedFilter="Images (*.png *.jpg)") if mat_dialog[0] != "": self.GenerateMat(mat_dialog[0]) def GenerateMat(self, image): self.background = image background = Image.open(self.background).resize((2048,2048))\ .convert("RGBA") self.mat_thread = QThread() east_id = self.SearchTeamID(self.cloth_east, True) south_id = self.SearchTeamID(self.cloth_south, True) west_id = self.SearchTeamID(self.cloth_west, True) north_id = self.SearchTeamID(self.cloth_north, True) if self.config["save_route"] is None: save_to_route = THISDIR else: save_to_route = self.config["save_route"] self._createProgressBar() self.mat_worker = GenerateImageThread(background, self.table_border, east_id, south_id, west_id, north_id, self.technical_lines.isChecked(), save_to_route, self.bg_image, True) self.mat_worker.moveToThread(self.mat_thread) self.mat_thread.started.connect(self.mat_worker.run) self.mat_worker.update_progress.connect(self.UpdateStatus) self.mat_worker.finished.connect(self.mat_thread.quit) self.mat_worker.finished.connect(self.mat_worker.deleteLater) self.mat_thread.finished.connect(self.mat_thread.deleteLater) self.mat_thread.finished.connect(self.MatPreviewWindow) self.mat_thread.start() def MatPreviewWindow(self): self.statusBar().showMessage('Mat preview generated.') self.statusBar().removeWidget(self.progress_bar) # Now you can go back to rigging self.ChangeAppStatus(True) self.mat_wid = QWidget() self.mat_wid.resize(600, 600) self.mat_wid.setWindowTitle("Background preview") mat_preview_title = QLabel(self) mat_preview_title.setText("Selected image (1/4 scale)") mat_preview = QLabel(self) mat_preview.setPixmap(QPixmap(tempfile.gettempdir()+"\\Table_Dif.jpg")\ .scaled(512,512)) confirm = QPushButton(self) confirm.setText("Confirm") confirm.clicked.connect( lambda: self.ChangeMatImage(self.background)) vbox = QVBoxLayout() vbox.setAlignment(QtCore.Qt.AlignCenter) vbox.addWidget(mat_preview_title) vbox.addWidget(mat_preview) vbox.addWidget(confirm) self.mat_wid.setLayout(vbox) self.mat_wid.setWindowModality(QtCore.Qt.ApplicationModal) self.mat_wid.activateWindow() self.mat_wid.raise_() self.mat_wid.show() def ChangeMatImage(self, image): new_bg = Image.open(image) if new_bg.size != (2048, 2048): new_bg = new_bg.resize((2048, 2048)) if new_bg.mode != "RGBA": new_bg = new_bg.convert("RGBA") if self.config["save_route"] is not None: new_bg.save(self.config["save_route"]+"\\images\\mat.png") self.bg_image = self.config["save_route"]+"\\images\\mat.png" else: new_bg.save(THISDIR+"\\images\\mat.png") self.bg_image = THISDIR+"\\images\\mat.png" self.background = new_bg self.config["image_route"] = self.bg_image new_file = open(THISDIR + "\\config\\config.json", "w+", encoding="utf-8") new_file.write(json.dumps(self.config, indent=4)) new_file.close() self.statusBar().showMessage('New background added.') self.statusBar().removeWidget(self.progress_bar) self.ChangeAppStatus(True) self.mat_wid.close() def GeneratePreview(self): self.preview_thread = QThread() east_id = self.SearchTeamID(self.cloth_east, True) south_id = self.SearchTeamID(self.cloth_south, True) west_id = self.SearchTeamID(self.cloth_west, True) north_id = self.SearchTeamID(self.cloth_north, True) if self.config["save_route"] is None: save_to_route = THISDIR else: save_to_route = self.config["save_route"] self._createProgressBar() self.preview_worker = GenerateImageThread(self.background, self.table_border, east_id, south_id, west_id, north_id, self.technical_lines.isChecked(), save_to_route, self.bg_image, True) self.preview_worker.moveToThread(self.preview_thread) self.preview_thread.started.connect(self.preview_worker.run) self.preview_worker.update_progress.connect(self.UpdateStatus) self.preview_worker.finished.connect(self.preview_thread.quit) self.preview_worker.finished.connect(self.preview_worker.deleteLater) self.preview_thread.finished.connect(self.preview_thread.deleteLater) self.preview_thread.finished.connect(self.PreviewWindow) self.preview_thread.start() def PreviewWindow(self): self.statusBar().showMessage('Tablecloth preview generated.') self.statusBar().removeWidget(self.progress_bar) # Now you can go back to rigging self.ChangeAppStatus(True) self.preview_wid = QWidget() self.preview_wid.resize(600, 600) self.preview_wid.setWindowTitle("Tablecloth preview") tablecloth = QPixmap(tempfile.gettempdir()+"\\Table_Dif.jpg") tablecloth_preview_title = QLabel(self) tablecloth_preview_title.setText("Tablecloth preview (1/4 scale)") tablecloth_preview = QLabel(self) tablecloth_preview.setPixmap(tablecloth.scaled(512,512)) confirm = QPushButton(self) confirm.setText("Confirm") confirm.clicked.connect(self.GenerateImage) confirm.clicked.connect(self.preview_wid.close) vbox = QVBoxLayout() vbox.setAlignment(QtCore.Qt.AlignCenter) vbox.addWidget(tablecloth_preview_title) vbox.addWidget(tablecloth_preview) vbox.addWidget(confirm) self.preview_wid.setLayout(vbox) self.preview_wid.setWindowModality(QtCore.Qt.ApplicationModal) self.preview_wid.activateWindow() self.preview_wid.raise_() self.preview_wid.show() def GeneratedDialog(self): self.statusBar().showMessage('Tablecloth generated. Happy rigging!') self.statusBar().removeWidget(self.progress_bar) # Now you can go back to rigging self.ChangeAppStatus(True) mbox = QMessageBox() mbox.setWindowTitle("Tablecloth Generator") mbox.setText("Tablecloth Generated!") mbox.setStandardButtons(QMessageBox.Ok) mbox.exec() def UpdateStatus(self, status): self.progress_bar.setValue(status) def GenerateImage(self): self.statusBar().showMessage('Generating image...') self._createProgressBar() if self.config["save_route"] is None: self.config["save_route"] = THISDIR save_to_route = QFileDialog.getExistingDirectory(self, "Where to save the image", self.config["save_route"], QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks) if self.config["save_route"] != save_to_route: temp_file = open(THISDIR + "\\config\\config.json", "r", encoding="utf-8") fp_teams = json.loads(temp_file.read()) fp_teams["save_route"] = save_to_route fp_teams["image_route"] = self.bg_image new_file = open(THISDIR + "\\config\\config.json", "w+", encoding="utf-8") new_file.write(json.dumps(fp_teams, indent=4)) new_file.close() self.background = Image.open(THISDIR + "\\images\\mat.png") self.table_border = Image.open(THISDIR + "\\images\\table_border.png") self.tech_lines = Image.open(THISDIR + "\\images\\technical_lines.png") self.thread = QThread() east_id = self.SearchTeamID(self.cloth_east, True) south_id = self.SearchTeamID(self.cloth_south, True) west_id = self.SearchTeamID(self.cloth_west, True) north_id = self.SearchTeamID(self.cloth_north, True) self.worker = GenerateImageThread(self.background, self.table_border, east_id, south_id, west_id, north_id, self.technical_lines.isChecked(), save_to_route, self.bg_image) self.worker.moveToThread(self.thread) self.thread.started.connect(self.worker.run) self.worker.update_progress.connect(self.UpdateStatus) self.worker.finished.connect(self.thread.quit) self.worker.finished.connect(self.worker.deleteLater) self.thread.finished.connect(self.thread.deleteLater) self.thread.finished.connect(self.GeneratedDialog) self.thread.start() def ChangeAppStatus(self, status): # True for enable, False for disable. self.cloth_east.setEnabled(status) self.search_east.setEnabled(status) self.cloth_south.setEnabled(status) self.search_south.setEnabled(status) self.cloth_west.setEnabled(status) self.search_west.setEnabled(status) self.cloth_north.setEnabled(status) self.search_north.setEnabled(status) self.generate.setEnabled(status) def SearchTeamID(self, cloth, plus_one=False): team_id = self.teams.index(cloth.itemData(cloth.currentIndex())) if plus_one: team_id += 1 return team_id def UpdatePlayersList(self): for team, members in self.players.items(): for member in members: self.players_combobox.addItem(member, team) def center(self): qr = self.frameGeometry() cp = QScreen().availableGeometry().center() qr.moveCenter(cp) def SeeVersion(self): git_url = "https://raw.githubusercontent.com/vg-mjg/tablecloth-" git_url += "generator/main/version.txt" with urllib.request.urlopen(git_url) as response: url_version = response.read().decode("utf-8") version = "Your version is up to date!" if url_version != VERSION: version = "Your version is outdated." version += "Please check the <a href='https://github.com/vg-mjg/" version += "tablecloth-generator/releases'>Github page</a>" version +=" for updates." version_message = QMessageBox(self) version_message.setWindowTitle("Checking version") version_message.setText("""<h1>Tablecloth generator</h1> <br> <b>Current Version:</b> %s<br> <b>Your Version:</b> %s<br> <i>%s</i> """ % (url_version, VERSION, version)) version_message.exec() def GetHelp(self): webbrowser.open("https://github.com/vg-mjg/tablecloth-generator/wiki")
class Ui_opsWidget(object): def setupUi(self, opsWidget): if not opsWidget.objectName(): opsWidget.setObjectName(u"opsWidget") opsWidget.resize(484, 788) self.opLayout = QVBoxLayout(opsWidget) self.opLayout.setObjectName(u"opLayout") self.operationSelect = QGroupBox(opsWidget) self.operationSelect.setObjectName(u"operationSelect") self.operationSelect.setEnabled(True) self.operationSelect.setFlat(True) self.verticalLayout_3 = QVBoxLayout(self.operationSelect) self.verticalLayout_3.setSpacing(10) self.verticalLayout_3.setObjectName(u"verticalLayout_3") self.verticalLayout_3.setContentsMargins(4, 4, 4, 4) self.formLayout = QFormLayout() self.formLayout.setObjectName(u"formLayout") self.formLayout.setVerticalSpacing(10) self.formLayout.setContentsMargins(5, 20, 5, 20) self.applyOpLabel = QLabel(self.operationSelect) self.applyOpLabel.setObjectName(u"applyOpLabel") self.formLayout.setWidget(1, QFormLayout.LabelRole, self.applyOpLabel) self.opCombo = QComboBox(self.operationSelect) self.opCombo.addItem("") self.opCombo.addItem("") self.opCombo.addItem("") self.opCombo.addItem("") self.opCombo.addItem("") self.opCombo.addItem("") self.opCombo.addItem("") self.opCombo.addItem("") self.opCombo.addItem("") self.opCombo.addItem("") self.opCombo.setObjectName(u"opCombo") self.opCombo.setEnabled(True) self.formLayout.setWidget(1, QFormLayout.FieldRole, self.opCombo) self.applyToLabel = QLabel(self.operationSelect) self.applyToLabel.setObjectName(u"applyToLabel") self.formLayout.setWidget(2, QFormLayout.LabelRole, self.applyToLabel) self.horizontalLayout = QHBoxLayout() self.horizontalLayout.setObjectName(u"horizontalLayout") self.verticalLayout_18 = QVBoxLayout() self.verticalLayout_18.setObjectName(u"verticalLayout_18") self.horizontalLayout_2 = QHBoxLayout() self.horizontalLayout_2.setObjectName(u"horizontalLayout_2") self.allDemoCheck = QCheckBox(self.operationSelect) self.allDemoCheck.setObjectName(u"allDemoCheck") self.allDemoCheck.setMaximumSize(QSize(10000, 16777215)) self.horizontalLayout_2.addWidget(self.allDemoCheck) self.allStepsCheck = QCheckBox(self.operationSelect) self.allStepsCheck.setObjectName(u"allStepsCheck") sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.allStepsCheck.sizePolicy().hasHeightForWidth()) self.allStepsCheck.setSizePolicy(sizePolicy) self.allStepsCheck.setMinimumSize(QSize(180, 0)) self.allStepsCheck.setLayoutDirection(Qt.LeftToRight) self.horizontalLayout_2.addWidget(self.allStepsCheck) self.verticalLayout_18.addLayout(self.horizontalLayout_2) self.matchSubstringCheck = QCheckBox(self.operationSelect) self.matchSubstringCheck.setObjectName(u"matchSubstringCheck") self.verticalLayout_18.addWidget(self.matchSubstringCheck) self.horizontalLayout_13 = QHBoxLayout() self.horizontalLayout_13.setObjectName(u"horizontalLayout_13") self.label_16 = QLabel(self.operationSelect) self.label_16.setObjectName(u"label_16") self.label_16.setEnabled(False) self.horizontalLayout_13.addWidget(self.label_16) self.matchSubstringText = QLineEdit(self.operationSelect) self.matchSubstringText.setObjectName(u"matchSubstringText") self.matchSubstringText.setEnabled(False) self.horizontalLayout_13.addWidget(self.matchSubstringText) self.verticalLayout_18.addLayout(self.horizontalLayout_13) self.horizontalLayout.addLayout(self.verticalLayout_18) self.formLayout.setLayout(2, QFormLayout.FieldRole, self.horizontalLayout) self.applyDemoLabel = QLabel(self.operationSelect) self.applyDemoLabel.setObjectName(u"applyDemoLabel") self.formLayout.setWidget(0, QFormLayout.LabelRole, self.applyDemoLabel) self.demoTargetCombo = QComboBox(self.operationSelect) self.demoTargetCombo.setObjectName(u"demoTargetCombo") self.formLayout.setWidget(0, QFormLayout.FieldRole, self.demoTargetCombo) self.verticalLayout_3.addLayout(self.formLayout) self.opLayout.addWidget(self.operationSelect) self.groupBox_6 = QGroupBox(opsWidget) self.groupBox_6.setObjectName(u"groupBox_6") self.groupBox_6.setEnabled(True) self.groupBox_6.setFlat(True) self.verticalLayout = QVBoxLayout(self.groupBox_6) self.verticalLayout.setObjectName(u"verticalLayout") self.verticalLayout.setContentsMargins(4, 4, 4, 4) self.opsParamsStack = QStackedWidget(self.groupBox_6) self.opsParamsStack.setObjectName(u"opsParamsStack") self.opsParamsStack.setAutoFillBackground(False) self.shellTab = QWidget() self.shellTab.setObjectName(u"shellTab") self.shellTab.setAutoFillBackground(False) self.formLayout_2 = QFormLayout(self.shellTab) self.formLayout_2.setObjectName(u"formLayout_2") self.formLayout_2.setLabelAlignment(Qt.AlignLeading | Qt.AlignLeft | Qt.AlignVCenter) self.formLayout_2.setFormAlignment(Qt.AlignLeading | Qt.AlignLeft | Qt.AlignVCenter) self.formLayout_2.setVerticalSpacing(40) self.formLayout_2.setContentsMargins(-1, 11, -1, -1) self.label = QLabel(self.shellTab) self.label.setObjectName(u"label") self.formLayout_2.setWidget(0, QFormLayout.LabelRole, self.label) self.horizontalLayout_4 = QHBoxLayout() self.horizontalLayout_4.setObjectName(u"horizontalLayout_4") self.shellImgPath = QLineEdit(self.shellTab) self.shellImgPath.setObjectName(u"shellImgPath") self.horizontalLayout_4.addWidget(self.shellImgPath) self.shellBrowseImgBtn = QPushButton(self.shellTab) self.shellBrowseImgBtn.setObjectName(u"shellBrowseImgBtn") self.horizontalLayout_4.addWidget(self.shellBrowseImgBtn) self.formLayout_2.setLayout(0, QFormLayout.FieldRole, self.horizontalLayout_4) self.label_2 = QLabel(self.shellTab) self.label_2.setObjectName(u"label_2") self.formLayout_2.setWidget(1, QFormLayout.LabelRole, self.label_2) self.horizontalLayout_7 = QHBoxLayout() self.horizontalLayout_7.setObjectName(u"horizontalLayout_7") self.label_3 = QLabel(self.shellTab) self.label_3.setObjectName(u"label_3") self.label_3.setAlignment(Qt.AlignCenter) self.horizontalLayout_7.addWidget(self.label_3) self.shellFgX = QSpinBox(self.shellTab) self.shellFgX.setObjectName(u"shellFgX") self.shellFgX.setMaximum(100000000) self.horizontalLayout_7.addWidget(self.shellFgX) self.label_4 = QLabel(self.shellTab) self.label_4.setObjectName(u"label_4") self.label_4.setAlignment(Qt.AlignCenter) self.horizontalLayout_7.addWidget(self.label_4) self.shellFgY = QSpinBox(self.shellTab) self.shellFgY.setObjectName(u"shellFgY") self.shellFgY.setMaximum(100000000) self.horizontalLayout_7.addWidget(self.shellFgY) self.formLayout_2.setLayout(1, QFormLayout.FieldRole, self.horizontalLayout_7) self.label_5 = QLabel(self.shellTab) self.label_5.setObjectName(u"label_5") self.formLayout_2.setWidget(2, QFormLayout.LabelRole, self.label_5) self.horizontalLayout_8 = QHBoxLayout() self.horizontalLayout_8.setObjectName(u"horizontalLayout_8") self.label_7 = QLabel(self.shellTab) self.label_7.setObjectName(u"label_7") self.label_7.setAlignment(Qt.AlignCenter) self.horizontalLayout_8.addWidget(self.label_7) self.shellFgW = QSpinBox(self.shellTab) self.shellFgW.setObjectName(u"shellFgW") self.shellFgW.setMaximum(100000000) self.horizontalLayout_8.addWidget(self.shellFgW) self.label_6 = QLabel(self.shellTab) self.label_6.setObjectName(u"label_6") self.label_6.setAlignment(Qt.AlignCenter) self.horizontalLayout_8.addWidget(self.label_6) self.shellFgH = QSpinBox(self.shellTab) self.shellFgH.setObjectName(u"shellFgH") self.shellFgH.setMaximum(10000000) self.horizontalLayout_8.addWidget(self.shellFgH) self.formLayout_2.setLayout(2, QFormLayout.FieldRole, self.horizontalLayout_8) self.opsParamsStack.addWidget(self.shellTab) self.insertTab = QWidget() self.insertTab.setObjectName(u"insertTab") self.formLayout_3 = QFormLayout(self.insertTab) self.formLayout_3.setObjectName(u"formLayout_3") self.formLayout_3.setVerticalSpacing(40) self.formLayout_3.setContentsMargins(-1, 40, -1, -1) self.label_32 = QLabel(self.insertTab) self.label_32.setObjectName(u"label_32") self.formLayout_3.setWidget(0, QFormLayout.LabelRole, self.label_32) self.horizontalLayout_20 = QHBoxLayout() self.horizontalLayout_20.setObjectName(u"horizontalLayout_20") self.insertImgPath = QLineEdit(self.insertTab) self.insertImgPath.setObjectName(u"insertImgPath") self.horizontalLayout_20.addWidget(self.insertImgPath) self.insertBrowseImgBtn = QPushButton(self.insertTab) self.insertBrowseImgBtn.setObjectName(u"insertBrowseImgBtn") self.horizontalLayout_20.addWidget(self.insertBrowseImgBtn) self.formLayout_3.setLayout(0, QFormLayout.FieldRole, self.horizontalLayout_20) self.label_13 = QLabel(self.insertTab) self.label_13.setObjectName(u"label_13") self.formLayout_3.setWidget(1, QFormLayout.LabelRole, self.label_13) self.horizontalLayout_18 = QHBoxLayout() self.horizontalLayout_18.setObjectName(u"horizontalLayout_18") self.label_26 = QLabel(self.insertTab) self.label_26.setObjectName(u"label_26") self.label_26.setAlignment(Qt.AlignCenter) self.horizontalLayout_18.addWidget(self.label_26) self.insertFgX = QSpinBox(self.insertTab) self.insertFgX.setObjectName(u"insertFgX") sizePolicy1 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed) sizePolicy1.setHorizontalStretch(0) sizePolicy1.setVerticalStretch(0) sizePolicy1.setHeightForWidth( self.insertFgX.sizePolicy().hasHeightForWidth()) self.insertFgX.setSizePolicy(sizePolicy1) self.insertFgX.setMaximum(10000000) self.horizontalLayout_18.addWidget(self.insertFgX) self.label_29 = QLabel(self.insertTab) self.label_29.setObjectName(u"label_29") self.label_29.setAlignment(Qt.AlignCenter) self.horizontalLayout_18.addWidget(self.label_29) self.insertFgY = QSpinBox(self.insertTab) self.insertFgY.setObjectName(u"insertFgY") self.insertFgY.setMaximum(10000000) self.horizontalLayout_18.addWidget(self.insertFgY) self.formLayout_3.setLayout(1, QFormLayout.FieldRole, self.horizontalLayout_18) self.label_12 = QLabel(self.insertTab) self.label_12.setObjectName(u"label_12") self.formLayout_3.setWidget(2, QFormLayout.LabelRole, self.label_12) self.horizontalLayout_21 = QHBoxLayout() self.horizontalLayout_21.setObjectName(u"horizontalLayout_21") self.label_33 = QLabel(self.insertTab) self.label_33.setObjectName(u"label_33") self.label_33.setAlignment(Qt.AlignCenter) self.horizontalLayout_21.addWidget(self.label_33) self.insertFgW = QSpinBox(self.insertTab) self.insertFgW.setObjectName(u"insertFgW") self.insertFgW.setBaseSize(QSize(1920, 0)) self.insertFgW.setMaximum(1000000) self.insertFgW.setValue(1920) self.horizontalLayout_21.addWidget(self.insertFgW) self.label_34 = QLabel(self.insertTab) self.label_34.setObjectName(u"label_34") self.label_34.setAlignment(Qt.AlignCenter) self.horizontalLayout_21.addWidget(self.label_34) self.insertFgH = QSpinBox(self.insertTab) self.insertFgH.setObjectName(u"insertFgH") self.insertFgH.setMaximum(1000000000) self.insertFgH.setValue(1080) self.horizontalLayout_21.addWidget(self.insertFgH) self.formLayout_3.setLayout(2, QFormLayout.FieldRole, self.horizontalLayout_21) self.opsParamsStack.addWidget(self.insertTab) self.sectionTab = QWidget() self.sectionTab.setObjectName(u"sectionTab") self.formLayout_6 = QFormLayout(self.sectionTab) self.formLayout_6.setObjectName(u"formLayout_6") self.sectionRulesListWidget = QListWidget(self.sectionTab) QListWidgetItem(self.sectionRulesListWidget) QListWidgetItem(self.sectionRulesListWidget) QListWidgetItem(self.sectionRulesListWidget) QListWidgetItem(self.sectionRulesListWidget) QListWidgetItem(self.sectionRulesListWidget) QListWidgetItem(self.sectionRulesListWidget) QListWidgetItem(self.sectionRulesListWidget) self.sectionRulesListWidget.setObjectName(u"sectionRulesListWidget") self.sectionRulesListWidget.setMaximumSize(QSize(16777215, 100)) self.formLayout_6.setWidget(1, QFormLayout.FieldRole, self.sectionRulesListWidget) self.label_10 = QLabel(self.sectionTab) self.label_10.setObjectName(u"label_10") self.label_10.setMaximumSize(QSize(16777215, 20)) self.formLayout_6.setWidget(0, QFormLayout.FieldRole, self.label_10) self.sectionCoverageLabel = QLabel(self.sectionTab) self.sectionCoverageLabel.setObjectName(u"sectionCoverageLabel") self.sectionCoverageLabel.setMaximumSize(QSize(16777215, 20)) self.formLayout_6.setWidget(2, QFormLayout.FieldRole, self.sectionCoverageLabel) self.label_11 = QLabel(self.sectionTab) self.label_11.setObjectName(u"label_11") self.label_11.setMaximumSize(QSize(16777215, 20)) self.formLayout_6.setWidget(3, QFormLayout.FieldRole, self.label_11) self.opsParamsStack.addWidget(self.sectionTab) self.audioTab = QWidget() self.audioTab.setObjectName(u"audioTab") self.formLayout_8 = QFormLayout(self.audioTab) self.formLayout_8.setObjectName(u"formLayout_8") self.comboBox = QComboBox(self.audioTab) self.comboBox.addItem("") self.comboBox.addItem("") self.comboBox.addItem("") self.comboBox.setObjectName(u"comboBox") self.formLayout_8.setWidget(0, QFormLayout.FieldRole, self.comboBox) self.label_8 = QLabel(self.audioTab) self.label_8.setObjectName(u"label_8") self.formLayout_8.setWidget(0, QFormLayout.LabelRole, self.label_8) self.opsParamsStack.addWidget(self.audioTab) self.cropTab = QWidget() self.cropTab.setObjectName(u"cropTab") self.formLayout_4 = QFormLayout(self.cropTab) self.formLayout_4.setObjectName(u"formLayout_4") self.formLayout_4.setVerticalSpacing(40) self.formLayout_4.setContentsMargins(-1, 40, -1, -1) self.label_14 = QLabel(self.cropTab) self.label_14.setObjectName(u"label_14") self.formLayout_4.setWidget(0, QFormLayout.LabelRole, self.label_14) self.horizontalLayout_19 = QHBoxLayout() self.horizontalLayout_19.setObjectName(u"horizontalLayout_19") self.label_30 = QLabel(self.cropTab) self.label_30.setObjectName(u"label_30") self.label_30.setAlignment(Qt.AlignCenter) self.horizontalLayout_19.addWidget(self.label_30) self.spinBox_21 = QSpinBox(self.cropTab) self.spinBox_21.setObjectName(u"spinBox_21") self.horizontalLayout_19.addWidget(self.spinBox_21) self.label_31 = QLabel(self.cropTab) self.label_31.setObjectName(u"label_31") self.label_31.setAlignment(Qt.AlignCenter) self.horizontalLayout_19.addWidget(self.label_31) self.spinBox_22 = QSpinBox(self.cropTab) self.spinBox_22.setObjectName(u"spinBox_22") self.horizontalLayout_19.addWidget(self.spinBox_22) self.formLayout_4.setLayout(0, QFormLayout.FieldRole, self.horizontalLayout_19) self.label_15 = QLabel(self.cropTab) self.label_15.setObjectName(u"label_15") self.formLayout_4.setWidget(1, QFormLayout.LabelRole, self.label_15) self.horizontalLayout_22 = QHBoxLayout() self.horizontalLayout_22.setObjectName(u"horizontalLayout_22") self.label_35 = QLabel(self.cropTab) self.label_35.setObjectName(u"label_35") self.label_35.setAlignment(Qt.AlignCenter) self.horizontalLayout_22.addWidget(self.label_35) self.spinBox_25 = QSpinBox(self.cropTab) self.spinBox_25.setObjectName(u"spinBox_25") self.horizontalLayout_22.addWidget(self.spinBox_25) self.label_36 = QLabel(self.cropTab) self.label_36.setObjectName(u"label_36") self.label_36.setAlignment(Qt.AlignCenter) self.horizontalLayout_22.addWidget(self.label_36) self.spinBox_26 = QSpinBox(self.cropTab) self.spinBox_26.setObjectName(u"spinBox_26") self.horizontalLayout_22.addWidget(self.spinBox_26) self.formLayout_4.setLayout(1, QFormLayout.FieldRole, self.horizontalLayout_22) self.opsParamsStack.addWidget(self.cropTab) self.composeTab = QWidget() self.composeTab.setObjectName(u"composeTab") self.verticalLayout_12 = QVBoxLayout(self.composeTab) self.verticalLayout_12.setObjectName(u"verticalLayout_12") self.verticalLayout_11 = QVBoxLayout() self.verticalLayout_11.setObjectName(u"verticalLayout_11") self.verticalLayout_12.addLayout(self.verticalLayout_11) self.opsParamsStack.addWidget(self.composeTab) self.resizeTab = QWidget() self.resizeTab.setObjectName(u"resizeTab") self.verticalLayout_10 = QVBoxLayout(self.resizeTab) self.verticalLayout_10.setObjectName(u"verticalLayout_10") self.verticalLayout_9 = QVBoxLayout() self.verticalLayout_9.setObjectName(u"verticalLayout_9") self.verticalLayout_10.addLayout(self.verticalLayout_9) self.opsParamsStack.addWidget(self.resizeTab) self.pacingTab = QWidget() self.pacingTab.setObjectName(u"pacingTab") self.verticalLayout_5 = QVBoxLayout(self.pacingTab) self.verticalLayout_5.setObjectName(u"verticalLayout_5") self.verticalLayout_5.setContentsMargins(0, 0, 0, 0) self.tabWidget = QTabWidget(self.pacingTab) self.tabWidget.setObjectName(u"tabWidget") self.tab = QWidget() self.tab.setObjectName(u"tab") self.tabWidget.addTab(self.tab, "") self.tab_2 = QWidget() self.tab_2.setObjectName(u"tab_2") self.tabWidget.addTab(self.tab_2, "") self.verticalLayout_5.addWidget(self.tabWidget) self.opsParamsStack.addWidget(self.pacingTab) self.animateTab = QWidget() self.animateTab.setObjectName(u"animateTab") self.verticalLayout_14 = QVBoxLayout(self.animateTab) self.verticalLayout_14.setObjectName(u"verticalLayout_14") self.verticalLayout_13 = QVBoxLayout() self.verticalLayout_13.setObjectName(u"verticalLayout_13") self.verticalLayout_14.addLayout(self.verticalLayout_13) self.opsParamsStack.addWidget(self.animateTab) self.renderTab = QWidget() self.renderTab.setObjectName(u"renderTab") self.verticalLayout_4 = QVBoxLayout(self.renderTab) self.verticalLayout_4.setObjectName(u"verticalLayout_4") self.verticalLayout_4.setContentsMargins(0, 0, 0, 0) self.renderTabTabs = QTabWidget(self.renderTab) self.renderTabTabs.setObjectName(u"renderTabTabs") self.renderTabVideoTab = QWidget() self.renderTabVideoTab.setObjectName(u"renderTabVideoTab") self.verticalLayout_2 = QVBoxLayout(self.renderTabVideoTab) self.verticalLayout_2.setObjectName(u"verticalLayout_2") self.verticalLayout_2.setContentsMargins(5, 5, 5, 5) self.scrollArea = QScrollArea(self.renderTabVideoTab) self.scrollArea.setObjectName(u"scrollArea") self.scrollArea.setFrameShape(QFrame.Panel) self.scrollArea.setFrameShadow(QFrame.Plain) self.scrollArea.setLineWidth(0) self.scrollArea.setWidgetResizable(True) self.scrollAreaWidgetContents = QWidget() self.scrollAreaWidgetContents.setObjectName( u"scrollAreaWidgetContents") self.scrollAreaWidgetContents.setGeometry(QRect(0, 0, 438, 412)) self.formLayout_10 = QFormLayout(self.scrollAreaWidgetContents) self.formLayout_10.setObjectName(u"formLayout_10") self.videoTitleLabel = QLabel(self.scrollAreaWidgetContents) self.videoTitleLabel.setObjectName(u"videoTitleLabel") self.formLayout_10.setWidget(0, QFormLayout.LabelRole, self.videoTitleLabel) self.renderOutputTitle = QLineEdit(self.scrollAreaWidgetContents) self.renderOutputTitle.setObjectName(u"renderOutputTitle") self.formLayout_10.setWidget(0, QFormLayout.FieldRole, self.renderOutputTitle) self.videoDirectoryLabel = QLabel(self.scrollAreaWidgetContents) self.videoDirectoryLabel.setObjectName(u"videoDirectoryLabel") self.formLayout_10.setWidget(1, QFormLayout.LabelRole, self.videoDirectoryLabel) self.renderOutputDir = QLineEdit(self.scrollAreaWidgetContents) self.renderOutputDir.setObjectName(u"renderOutputDir") self.formLayout_10.setWidget(1, QFormLayout.FieldRole, self.renderOutputDir) self.videoFormatLabel = QLabel(self.scrollAreaWidgetContents) self.videoFormatLabel.setObjectName(u"videoFormatLabel") self.formLayout_10.setWidget(2, QFormLayout.LabelRole, self.videoFormatLabel) self.renderOutputFormat = QComboBox(self.scrollAreaWidgetContents) self.renderOutputFormat.addItem("") self.renderOutputFormat.addItem("") self.renderOutputFormat.setObjectName(u"renderOutputFormat") self.formLayout_10.setWidget(2, QFormLayout.FieldRole, self.renderOutputFormat) self.scrollArea.setWidget(self.scrollAreaWidgetContents) self.verticalLayout_2.addWidget(self.scrollArea) self.renderTabTabs.addTab(self.renderTabVideoTab, "") self.renderTabAudioTab = QWidget() self.renderTabAudioTab.setObjectName(u"renderTabAudioTab") self.verticalLayout_6 = QVBoxLayout(self.renderTabAudioTab) self.verticalLayout_6.setObjectName(u"verticalLayout_6") self.scrollArea_2 = QScrollArea(self.renderTabAudioTab) self.scrollArea_2.setObjectName(u"scrollArea_2") self.scrollArea_2.setWidgetResizable(True) self.scrollAreaWidgetContents_2 = QWidget() self.scrollAreaWidgetContents_2.setObjectName( u"scrollAreaWidgetContents_2") self.scrollAreaWidgetContents_2.setGeometry(QRect(0, 0, 428, 402)) self.formLayout_11 = QFormLayout(self.scrollAreaWidgetContents_2) self.formLayout_11.setObjectName(u"formLayout_11") self.scrollArea_2.setWidget(self.scrollAreaWidgetContents_2) self.verticalLayout_6.addWidget(self.scrollArea_2) self.renderTabTabs.addTab(self.renderTabAudioTab, "") self.renderTabPacingTab = QWidget() self.renderTabPacingTab.setObjectName(u"renderTabPacingTab") self.verticalLayout_8 = QVBoxLayout(self.renderTabPacingTab) self.verticalLayout_8.setObjectName(u"verticalLayout_8") self.scrollArea_3 = QScrollArea(self.renderTabPacingTab) self.scrollArea_3.setObjectName(u"scrollArea_3") self.scrollArea_3.setWidgetResizable(True) self.scrollAreaWidgetContents_3 = QWidget() self.scrollAreaWidgetContents_3.setObjectName( u"scrollAreaWidgetContents_3") self.scrollAreaWidgetContents_3.setGeometry(QRect(0, 0, 428, 402)) self.formLayout_12 = QFormLayout(self.scrollAreaWidgetContents_3) self.formLayout_12.setObjectName(u"formLayout_12") self.scrollArea_3.setWidget(self.scrollAreaWidgetContents_3) self.verticalLayout_8.addWidget(self.scrollArea_3) self.renderTabTabs.addTab(self.renderTabPacingTab, "") self.verticalLayout_4.addWidget(self.renderTabTabs) self.opsParamsStack.addWidget(self.renderTab) self.extraTab = QWidget() self.extraTab.setObjectName(u"extraTab") self.formLayout_7 = QFormLayout(self.extraTab) self.formLayout_7.setObjectName(u"formLayout_7") self.opsParamsStack.addWidget(self.extraTab) self.verticalLayout.addWidget(self.opsParamsStack) self.opLayout.addWidget(self.groupBox_6) self.horizontalLayout_9 = QHBoxLayout() self.horizontalLayout_9.setObjectName(u"horizontalLayout_9") self.horizontalLayout_9.setContentsMargins(10, 10, 10, 10) self.resetStepParamsBtn = QPushButton(opsWidget) self.resetStepParamsBtn.setObjectName(u"resetStepParamsBtn") self.horizontalLayout_9.addWidget(self.resetStepParamsBtn) self.saveStepParamsBtn = QPushButton(opsWidget) self.saveStepParamsBtn.setObjectName(u"saveStepParamsBtn") self.horizontalLayout_9.addWidget(self.saveStepParamsBtn) self.opLayout.addLayout(self.horizontalLayout_9) self.retranslateUi(opsWidget) self.opCombo.currentIndexChanged.connect( self.opsParamsStack.setCurrentIndex) self.opsParamsStack.setCurrentIndex(9) self.renderTabTabs.setCurrentIndex(0) QMetaObject.connectSlotsByName(opsWidget) # setupUi def retranslateUi(self, opsWidget): self.operationSelect.setTitle( QCoreApplication.translate("opsWidget", u"Operation", None)) self.applyOpLabel.setText( QCoreApplication.translate("opsWidget", u"Operation", None)) self.opCombo.setItemText( 0, QCoreApplication.translate("opsWidget", u"Shell", None)) self.opCombo.setItemText( 1, QCoreApplication.translate("opsWidget", u"Insert", None)) self.opCombo.setItemText( 2, QCoreApplication.translate("opsWidget", u"Section", None)) self.opCombo.setItemText( 3, QCoreApplication.translate("opsWidget", u"Audio", None)) self.opCombo.setItemText( 4, QCoreApplication.translate("opsWidget", u"Crop", None)) self.opCombo.setItemText( 5, QCoreApplication.translate("opsWidget", u"Compose Demos", None)) self.opCombo.setItemText( 6, QCoreApplication.translate("opsWidget", u"Resize", None)) self.opCombo.setItemText( 7, QCoreApplication.translate("opsWidget", u"Add pacing", None)) self.opCombo.setItemText( 8, QCoreApplication.translate("opsWidget", u"Animate scroll steps", None)) self.opCombo.setItemText( 9, QCoreApplication.translate("opsWidget", u"Render to video", None)) self.applyToLabel.setText( QCoreApplication.translate("opsWidget", u"Apply to:", None)) self.allDemoCheck.setText( QCoreApplication.translate("opsWidget", u"Apply to all demos", None)) self.allStepsCheck.setText( QCoreApplication.translate("opsWidget", u"Apply to all steps", None)) self.matchSubstringCheck.setText( QCoreApplication.translate( "opsWidget", u"Apply to steps with matching substring:", None)) self.label_16.setText( QCoreApplication.translate("opsWidget", u"Steps containing:", None)) self.applyDemoLabel.setText( QCoreApplication.translate("opsWidget", u"Demo", None)) self.groupBox_6.setTitle( QCoreApplication.translate("opsWidget", u"Parameters", None)) self.label.setText( QCoreApplication.translate("opsWidget", u"Background", None)) #if QT_CONFIG(statustip) self.shellImgPath.setStatusTip( QCoreApplication.translate( "opsWidget", u"Filepath of image to be used as shell for demo assets", None)) #endif // QT_CONFIG(statustip) self.shellBrowseImgBtn.setText( QCoreApplication.translate("opsWidget", u"Browse", None)) self.label_2.setText( QCoreApplication.translate("opsWidget", u"Coordinates of assets on shell", None)) self.label_3.setText( QCoreApplication.translate("opsWidget", u"X", None)) self.label_4.setText( QCoreApplication.translate("opsWidget", u"Y", None)) self.label_5.setText( QCoreApplication.translate("opsWidget", u"Dimensions of assets on shell", None)) self.label_7.setText( QCoreApplication.translate("opsWidget", u"Width", None)) self.label_6.setText( QCoreApplication.translate("opsWidget", u"Height", None)) self.label_32.setText( QCoreApplication.translate("opsWidget", u"Image to paste", None)) self.insertBrowseImgBtn.setText( QCoreApplication.translate("opsWidget", u"Browse", None)) self.label_13.setText( QCoreApplication.translate("opsWidget", u"Coords of image on assets", None)) self.label_26.setText( QCoreApplication.translate("opsWidget", u"X", None)) self.label_29.setText( QCoreApplication.translate("opsWidget", u"Y", None)) self.label_12.setText( QCoreApplication.translate("opsWidget", u"Dimensions of image on assets", None)) self.label_33.setText( QCoreApplication.translate("opsWidget", u"Width", None)) self.label_34.setText( QCoreApplication.translate("opsWidget", u"Height", None)) __sortingEnabled = self.sectionRulesListWidget.isSortingEnabled() self.sectionRulesListWidget.setSortingEnabled(False) ___qlistwidgetitem = self.sectionRulesListWidget.item(0) ___qlistwidgetitem.setText( QCoreApplication.translate("opsWidget", u"Step has TP, next step without TP", None)) ___qlistwidgetitem1 = self.sectionRulesListWidget.item(1) ___qlistwidgetitem1.setText( QCoreApplication.translate("opsWidget", u"Step has TP, next step with TP", None)) ___qlistwidgetitem2 = self.sectionRulesListWidget.item(2) ___qlistwidgetitem2.setText( QCoreApplication.translate( "opsWidget", u"Step has TP, previous step without TP", None)) ___qlistwidgetitem3 = self.sectionRulesListWidget.item(3) ___qlistwidgetitem3.setText( QCoreApplication.translate("opsWidget", u"Step has TP, previous step with TP", None)) ___qlistwidgetitem4 = self.sectionRulesListWidget.item(4) ___qlistwidgetitem4.setText( QCoreApplication.translate("opsWidget", u"Step has fade-in", None)) ___qlistwidgetitem5 = self.sectionRulesListWidget.item(5) ___qlistwidgetitem5.setText( QCoreApplication.translate("opsWidget", u"Step has jump box", None)) ___qlistwidgetitem6 = self.sectionRulesListWidget.item(6) ___qlistwidgetitem6.setText( QCoreApplication.translate("opsWidget", u"Step TP contains text pattern...", None)) self.sectionRulesListWidget.setSortingEnabled(__sortingEnabled) self.label_10.setText( QCoreApplication.translate("opsWidget", u"Insert new section on...", None)) self.sectionCoverageLabel.setText( QCoreApplication.translate( "opsWidget", u"Covers 0 steps in selected sections/steps", None)) self.label_11.setText( QCoreApplication.translate( "opsWidget", u"May not match number of audio soundbites (audio not imported)", None)) self.comboBox.setItemText( 0, QCoreApplication.translate("opsWidget", u"Mixed section and step audio", None)) self.comboBox.setItemText( 1, QCoreApplication.translate("opsWidget", u"Section audio only", None)) self.comboBox.setItemText( 2, QCoreApplication.translate("opsWidget", u"Step audio only", None)) self.label_8.setText( QCoreApplication.translate("opsWidget", u"Audio attachment behavior", None)) self.label_14.setText( QCoreApplication.translate("opsWidget", u"Crop start coordinates", None)) self.label_30.setText( QCoreApplication.translate("opsWidget", u"X", None)) self.label_31.setText( QCoreApplication.translate("opsWidget", u"Y", None)) self.label_15.setText( QCoreApplication.translate("opsWidget", u"Crop dimensions", None)) self.label_35.setText( QCoreApplication.translate("opsWidget", u"Width", None)) self.label_36.setText( QCoreApplication.translate("opsWidget", u"Height", None)) self.tabWidget.setTabText( self.tabWidget.indexOf(self.tab), QCoreApplication.translate("opsWidget", u"Tab 1", None)) self.tabWidget.setTabText( self.tabWidget.indexOf(self.tab_2), QCoreApplication.translate("opsWidget", u"Tab 2", None)) self.videoTitleLabel.setText( QCoreApplication.translate("opsWidget", u"Video Title", None)) self.videoDirectoryLabel.setText( QCoreApplication.translate("opsWidget", u"Video Directory", None)) self.videoFormatLabel.setText( QCoreApplication.translate("opsWidget", u"Video Format", None)) self.renderOutputFormat.setItemText( 0, QCoreApplication.translate("opsWidget", u"avi", None)) self.renderOutputFormat.setItemText( 1, QCoreApplication.translate("opsWidget", u"mp4", None)) self.renderTabTabs.setTabText( self.renderTabTabs.indexOf(self.renderTabVideoTab), QCoreApplication.translate("opsWidget", u"Video", None)) self.renderTabTabs.setTabText( self.renderTabTabs.indexOf(self.renderTabAudioTab), QCoreApplication.translate("opsWidget", u"Audio", None)) self.renderTabTabs.setTabText( self.renderTabTabs.indexOf(self.renderTabPacingTab), QCoreApplication.translate("opsWidget", u"Pacing", None)) self.resetStepParamsBtn.setText( QCoreApplication.translate("opsWidget", u"Reset to default", None)) self.saveStepParamsBtn.setText( QCoreApplication.translate("opsWidget", u"Save step parameters", None)) pass
class Ui_MainWindow(object): def setupUi(self, MainWindow): if not MainWindow.objectName(): MainWindow.setObjectName(u"MainWindow") MainWindow.resize(534, 188) self.centralwidget = QWidget(MainWindow) self.centralwidget.setObjectName(u"centralwidget") self.verticalLayout = QVBoxLayout(self.centralwidget) self.verticalLayout.setObjectName(u"verticalLayout") self.horizontalLayout = QHBoxLayout() self.horizontalLayout.setObjectName(u"horizontalLayout") self.line_source = QLineEdit(self.centralwidget) self.line_source.setObjectName(u"line_source") self.line_source.setEnabled(True) self.line_source.setReadOnly(True) self.horizontalLayout.addWidget(self.line_source) self.button_source = QPushButton(self.centralwidget) self.button_source.setObjectName(u"button_source") self.horizontalLayout.addWidget(self.button_source) self.verticalLayout.addLayout(self.horizontalLayout) self.horizontalLayout_2 = QHBoxLayout() self.horizontalLayout_2.setObjectName(u"horizontalLayout_2") self.line_target = QLineEdit(self.centralwidget) self.line_target.setObjectName(u"line_target") self.line_target.setEnabled(True) self.line_target.setReadOnly(True) self.horizontalLayout_2.addWidget(self.line_target) self.button_target = QPushButton(self.centralwidget) self.button_target.setObjectName(u"button_target") self.horizontalLayout_2.addWidget(self.button_target) self.verticalLayout.addLayout(self.horizontalLayout_2) self.line = QFrame(self.centralwidget) self.line.setObjectName(u"line") self.line.setFrameShape(QFrame.HLine) self.line.setFrameShadow(QFrame.Sunken) self.verticalLayout.addWidget(self.line) self.horizontalLayout_3 = QHBoxLayout() self.horizontalLayout_3.setObjectName(u"horizontalLayout_3") self.label_2 = QLabel(self.centralwidget) self.label_2.setObjectName(u"label_2") self.horizontalLayout_3.addWidget(self.label_2) self.spin_memory = QSpinBox(self.centralwidget) self.spin_memory.setObjectName(u"spin_memory") self.horizontalLayout_3.addWidget(self.spin_memory) self.label_3 = QLabel(self.centralwidget) self.label_3.setObjectName(u"label_3") self.horizontalLayout_3.addWidget(self.label_3) self.spin_blur = QSpinBox(self.centralwidget) self.spin_blur.setObjectName(u"spin_blur") self.spin_blur.setValue(9) self.horizontalLayout_3.addWidget(self.spin_blur) self.label_5 = QLabel(self.centralwidget) self.label_5.setObjectName(u"label_5") self.horizontalLayout_3.addWidget(self.label_5) self.double_spin_threshold = QDoubleSpinBox(self.centralwidget) self.double_spin_threshold.setObjectName(u"double_spin_threshold") self.double_spin_threshold.setMaximum(1.000000000000000) self.double_spin_threshold.setSingleStep(0.050000000000000) self.double_spin_threshold.setValue(0.300000000000000) self.horizontalLayout_3.addWidget(self.double_spin_threshold) self.label_6 = QLabel(self.centralwidget) self.label_6.setObjectName(u"label_6") self.horizontalLayout_3.addWidget(self.label_6) self.double_spin_roimulti = QDoubleSpinBox(self.centralwidget) self.double_spin_roimulti.setObjectName(u"double_spin_roimulti") self.double_spin_roimulti.setMinimum(0.800000000000000) self.double_spin_roimulti.setMaximum(10.000000000000000) self.double_spin_roimulti.setSingleStep(0.050000000000000) self.double_spin_roimulti.setValue(1.000000000000000) self.horizontalLayout_3.addWidget(self.double_spin_roimulti) self.verticalLayout.addLayout(self.horizontalLayout_3) self.line_2 = QFrame(self.centralwidget) self.line_2.setObjectName(u"line_2") self.line_2.setFrameShape(QFrame.HLine) self.line_2.setFrameShadow(QFrame.Sunken) self.verticalLayout.addWidget(self.line_2) self.horizontalLayout_4 = QHBoxLayout() self.horizontalLayout_4.setObjectName(u"horizontalLayout_4") self.label = QLabel(self.centralwidget) self.label.setObjectName(u"label") self.horizontalLayout_4.addWidget(self.label) self.combo_box_weights = QComboBox(self.centralwidget) self.combo_box_weights.setObjectName(u"combo_box_weights") self.horizontalLayout_4.addWidget(self.combo_box_weights) self.label_4 = QLabel(self.centralwidget) self.label_4.setObjectName(u"label_4") self.horizontalLayout_4.addWidget(self.label_4) self.combo_box_scale = QComboBox(self.centralwidget) self.combo_box_scale.addItem("") self.combo_box_scale.addItem("") self.combo_box_scale.addItem("") self.combo_box_scale.setObjectName(u"combo_box_scale") self.horizontalLayout_4.addWidget(self.combo_box_scale) self.label_7 = QLabel(self.centralwidget) self.label_7.setObjectName(u"label_7") self.horizontalLayout_4.addWidget(self.label_7) self.spin_quality = QSpinBox(self.centralwidget) self.spin_quality.setObjectName(u"spin_quality") self.spin_quality.setMaximum(10) self.spin_quality.setValue(5) self.horizontalLayout_4.addWidget(self.spin_quality) self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout_4.addItem(self.horizontalSpacer) self.verticalLayout.addLayout(self.horizontalLayout_4) self.line_3 = QFrame(self.centralwidget) self.line_3.setObjectName(u"line_3") self.line_3.setFrameShape(QFrame.HLine) self.line_3.setFrameShadow(QFrame.Sunken) self.verticalLayout.addWidget(self.line_3) self.horizontalLayout_5 = QHBoxLayout() self.horizontalLayout_5.setObjectName(u"horizontalLayout_5") self.progress = QProgressBar(self.centralwidget) self.progress.setObjectName(u"progress") self.progress.setEnabled(True) self.progress.setValue(0) self.horizontalLayout_5.addWidget(self.progress) self.button_start = QPushButton(self.centralwidget) self.button_start.setObjectName(u"button_start") self.horizontalLayout_5.addWidget(self.button_start) self.button_abort = QPushButton(self.centralwidget) self.button_abort.setObjectName(u"button_abort") self.button_abort.setEnabled(False) self.horizontalLayout_5.addWidget(self.button_abort) self.verticalLayout.addLayout(self.horizontalLayout_5) MainWindow.setCentralWidget(self.centralwidget) self.retranslateUi(MainWindow) QMetaObject.connectSlotsByName(MainWindow) # setupUi def retranslateUi(self, MainWindow): MainWindow.setWindowTitle( QCoreApplication.translate("MainWindow", u"DashcamCleaner", None)) self.button_source.setText( QCoreApplication.translate("MainWindow", u"Select video", None)) self.button_target.setText( QCoreApplication.translate("MainWindow", u"Select target", None)) self.label_2.setText( QCoreApplication.translate("MainWindow", u"Frame memory:", None)) self.label_3.setText( QCoreApplication.translate("MainWindow", u"Blur size:", None)) self.label_5.setText( QCoreApplication.translate("MainWindow", u"Detection threshold:", None)) self.label_6.setText( QCoreApplication.translate("MainWindow", u"ROI enlargement", None)) self.label.setText( QCoreApplication.translate("MainWindow", u"Weights", None)) self.label_4.setText( QCoreApplication.translate("MainWindow", u"Inference size", None)) self.combo_box_scale.setItemText( 0, QCoreApplication.translate("MainWindow", u"360p", None)) self.combo_box_scale.setItemText( 1, QCoreApplication.translate("MainWindow", u"720p", None)) self.combo_box_scale.setItemText( 2, QCoreApplication.translate("MainWindow", u"1080p", None)) self.combo_box_scale.setCurrentText( QCoreApplication.translate("MainWindow", u"360p", None)) self.label_7.setText( QCoreApplication.translate("MainWindow", u"Output Quality", None)) self.button_start.setText( QCoreApplication.translate("MainWindow", u"Start", None)) self.button_abort.setText( QCoreApplication.translate("MainWindow", u"Abort", None))
class Pryme2(QWidget): notify_request = Signal(str) def __init__(self, parent=None): super(Pryme2, self).__init__(parent) self.timer_instances = (SimpleTimer(), AlarmClock(), PomoTimer()) self.timer_selection = QComboBox(self) for t in self.timer_instances: self.timer_selection.addItem(t.name) self.timer = self.timer_instances[0] self.commitment_textbox = QLineEdit(self) self.commitment_textbox.setPlaceholderText( 'What do you want to commit?') self.commitment_textbox.setClearButtonEnabled(True) self.commit_done_btn = QPushButton('&Done', self) self.start_btn = QPushButton('&Start', self) self.abort_btn = QPushButton('&Abort', self) self.abort_btn.hide() self.pause_btn = QPushButton('&Pause', self) self.pause_btn.hide() self.resume_btn = QPushButton('&Resume', self) self.resume_btn.hide() self.tray = QSystemTrayIcon(self) self.tray.setIcon(QIcon('pryme-logo.svg')) self.tray.show() self.set_ui() self.set_connection() self.show() def set_ui(self): self.hlayout = QHBoxLayout() self.hlayout.addWidget(self.commitment_textbox) self.hlayout.addWidget(self.commit_done_btn) self.commit_group = QGroupBox('Commitment') self.commit_group.setLayout(self.hlayout) self.vlayout = QVBoxLayout() self.vlayout.addWidget(self.commit_group) self.vlayout.addWidget(self.timer_selection) self.vlayout.addWidget(self.timer) self.bottom_hlayout = QHBoxLayout() self.bottom_hlayout.addWidget(self.start_btn) self.bottom_hlayout.addWidget(self.abort_btn) self.bottom_hlayout.addWidget(self.pause_btn) self.bottom_hlayout.addWidget(self.resume_btn) self.vlayout.addLayout(self.bottom_hlayout) self.setLayout(self.vlayout) def set_connection(self): self.timer_selection.currentIndexChanged.connect(self.change_timer) self.connect_timer() def connect_timer(self): self.start_btn.clicked.connect(self.timer.start) self.abort_btn.clicked.connect(self.timer.abort) self.timer.finished.connect(self.notify) self.timer.started.connect(self.set_timer_active_ui) self.timer.aborted.connect(self.set_timer_deactive_ui) self.timer.finished.connect(self.set_timer_deactive_ui) if hasattr(self.timer, 'pause'): self.pause_btn.clicked.connect(self.timer.pause) self.resume_btn.clicked.connect(self.timer.resume) self.timer.paused.connect(self.activate_resume_button) def disconnect_timer(self): self.timer.disconnect(self) self.start_btn.disconnect(self.timer) self.abort_btn.disconnect(self.timer) self.resume_btn.disconnect(self.timer) def notify(self): title = self.commitment_textbox.text() if not title: title = 'Time up!' message = self.timer.get_notify_message() if not message: print(message) message = 'Time up!' self.tray.showMessage(title, message) subprocess.Popen(cmd.split()) def set_ui_enabled(self, enable: bool): self.timer_selection.setEnabled(enable) self.commitment_textbox.setEnabled(enable) def set_timer_active_ui(self): self.activate_start_button(False) self.set_ui_enabled(False) def set_timer_deactive_ui(self): self.activate_start_button(True) self.set_ui_enabled(True) def activate_start_button(self, activate: bool): if activate: # active start button self.start_btn.show() self.abort_btn.hide() self.pause_btn.hide() self.resume_btn.hide() else: self.abort_btn.show() self.start_btn.hide() if hasattr(self.timer, 'pause'): self.pause_btn.show() self.resume_btn.hide() def activate_resume_button(self): self.pause_btn.hide() self.resume_btn.show() @Slot(int) def change_timer(self, index): self.disconnect_timer() self.timer.hide() self.vlayout.replaceWidget(self.timer, self.timer_instances[index]) self.timer = self.timer_instances[index] self.connect_timer() self.timer.show()
class Ui_Img(object): def setupUi(self, Img): if not Img.objectName(): Img.setObjectName(u"Img") Img.resize(620, 559) self.gridLayout = QGridLayout(Img) self.gridLayout.setObjectName(u"gridLayout") self.graphicsView = QGraphicsView(Img) self.graphicsView.setObjectName(u"graphicsView") self.gridLayout.addWidget(self.graphicsView, 0, 0, 1, 1) self.verticalLayout = QVBoxLayout() self.verticalLayout.setObjectName(u"verticalLayout") self.line_3 = QFrame(Img) self.line_3.setObjectName(u"line_3") self.line_3.setFrameShape(QFrame.VLine) self.line_3.setFrameShadow(QFrame.Sunken) self.verticalLayout.addWidget(self.line_3) self.verticalLayout_2 = QVBoxLayout() self.verticalLayout_2.setObjectName(u"verticalLayout_2") self.line_5 = QFrame(Img) self.line_5.setObjectName(u"line_5") self.line_5.setFrameShape(QFrame.VLine) self.line_5.setFrameShadow(QFrame.Sunken) self.verticalLayout_2.addWidget(self.line_5) self.checkBox = QCheckBox(Img) self.checkBox.setObjectName(u"checkBox") self.checkBox.setMaximumSize(QSize(100, 16777215)) self.checkBox.setChecked(True) self.verticalLayout_2.addWidget(self.checkBox) self.ttaModel = QCheckBox(Img) self.ttaModel.setObjectName(u"ttaModel") self.ttaModel.setMaximumSize(QSize(70, 16777215)) self.verticalLayout_2.addWidget(self.ttaModel) self.horizontalLayout_3 = QHBoxLayout() self.horizontalLayout_3.setObjectName(u"horizontalLayout_3") self.scaleRadio = QRadioButton(Img) self.buttonGroup_2 = QButtonGroup(Img) self.buttonGroup_2.setObjectName(u"buttonGroup_2") self.buttonGroup_2.addButton(self.scaleRadio) self.scaleRadio.setObjectName(u"scaleRadio") self.scaleRadio.setMaximumSize(QSize(80, 16777215)) self.scaleRadio.setChecked(True) self.horizontalLayout_3.addWidget(self.scaleRadio) self.scaleEdit = QLineEdit(Img) self.scaleEdit.setObjectName(u"scaleEdit") self.scaleEdit.setMaximumSize(QSize(160, 16777215)) self.scaleEdit.setAlignment(Qt.AlignCenter) self.horizontalLayout_3.addWidget(self.scaleEdit) self.verticalLayout_2.addLayout(self.horizontalLayout_3) self.horizontalLayout_4 = QHBoxLayout() self.horizontalLayout_4.setObjectName(u"horizontalLayout_4") self.heighRadio = QRadioButton(Img) self.buttonGroup_2.addButton(self.heighRadio) self.heighRadio.setObjectName(u"heighRadio") self.heighRadio.setMaximumSize(QSize(80, 16777215)) self.horizontalLayout_4.addWidget(self.heighRadio) self.widthEdit = QLineEdit(Img) self.widthEdit.setObjectName(u"widthEdit") self.widthEdit.setEnabled(False) self.widthEdit.setMaximumSize(QSize(60, 16777215)) self.widthEdit.setAlignment(Qt.AlignCenter) self.horizontalLayout_4.addWidget(self.widthEdit) self.label_2 = QLabel(Img) self.label_2.setObjectName(u"label_2") self.label_2.setMaximumSize(QSize(20, 16777215)) self.horizontalLayout_4.addWidget(self.label_2) self.heighEdit = QLineEdit(Img) self.heighEdit.setObjectName(u"heighEdit") self.heighEdit.setEnabled(False) self.heighEdit.setMaximumSize(QSize(60, 16777215)) self.heighEdit.setAlignment(Qt.AlignCenter) self.horizontalLayout_4.addWidget(self.heighEdit) self.verticalLayout_2.addLayout(self.horizontalLayout_4) self.horizontalLayout_5 = QHBoxLayout() self.horizontalLayout_5.setObjectName(u"horizontalLayout_5") self.label_4 = QLabel(Img) self.label_4.setObjectName(u"label_4") self.label_4.setMaximumSize(QSize(60, 16777215)) self.horizontalLayout_5.addWidget(self.label_4) self.noiseCombox = QComboBox(Img) self.noiseCombox.addItem("") self.noiseCombox.addItem("") self.noiseCombox.addItem("") self.noiseCombox.addItem("") self.noiseCombox.addItem("") self.noiseCombox.setObjectName(u"noiseCombox") self.noiseCombox.setMaximumSize(QSize(160, 16777215)) self.horizontalLayout_5.addWidget(self.noiseCombox) self.verticalLayout_2.addLayout(self.horizontalLayout_5) self.horizontalLayout_6 = QHBoxLayout() self.horizontalLayout_6.setObjectName(u"horizontalLayout_6") self.label_5 = QLabel(Img) self.label_5.setObjectName(u"label_5") self.label_5.setMaximumSize(QSize(60, 16777215)) self.horizontalLayout_6.addWidget(self.label_5) self.comboBox = QComboBox(Img) self.comboBox.addItem("") self.comboBox.addItem("") self.comboBox.addItem("") self.comboBox.setObjectName(u"comboBox") self.comboBox.setMaximumSize(QSize(160, 16777215)) self.horizontalLayout_6.addWidget(self.comboBox) self.verticalLayout_2.addLayout(self.horizontalLayout_6) self.horizontalLayout_7 = QHBoxLayout() self.horizontalLayout_7.setObjectName(u"horizontalLayout_7") self.changeJpg = QPushButton(Img) self.changeJpg.setObjectName(u"changeJpg") self.changeJpg.setMaximumSize(QSize(100, 16777215)) self.horizontalLayout_7.addWidget(self.changeJpg) self.changePng = QPushButton(Img) self.changePng.setObjectName(u"changePng") self.changePng.setMaximumSize(QSize(100, 16777215)) self.horizontalLayout_7.addWidget(self.changePng) self.changeLabel = QLabel(Img) self.changeLabel.setObjectName(u"changeLabel") self.changeLabel.setMaximumSize(QSize(100, 16777215)) self.changeLabel.setAlignment(Qt.AlignCenter) self.horizontalLayout_7.addWidget(self.changeLabel) self.verticalLayout_2.addLayout(self.horizontalLayout_7) self.horizontalLayout_11 = QHBoxLayout() self.horizontalLayout_11.setObjectName(u"horizontalLayout_11") self.verticalLayout_2.addLayout(self.horizontalLayout_11) self.verticalLayout.addLayout(self.verticalLayout_2) self.line = QFrame(Img) self.line.setObjectName(u"line") self.line.setFrameShape(QFrame.VLine) self.line.setFrameShadow(QFrame.Sunken) self.verticalLayout.addWidget(self.line) self.line_4 = QFrame(Img) self.line_4.setObjectName(u"line_4") self.line_4.setFrameShape(QFrame.HLine) self.line_4.setFrameShadow(QFrame.Sunken) self.verticalLayout.addWidget(self.line_4) self.verticalLayout_3 = QVBoxLayout() self.verticalLayout_3.setObjectName(u"verticalLayout_3") self.horizontalLayout_8 = QHBoxLayout() self.horizontalLayout_8.setObjectName(u"horizontalLayout_8") self.label_8 = QLabel(Img) self.label_8.setObjectName(u"label_8") self.label_8.setMaximumSize(QSize(60, 16777215)) self.horizontalLayout_8.addWidget(self.label_8) self.resolutionLabel = QLabel(Img) self.resolutionLabel.setObjectName(u"resolutionLabel") self.resolutionLabel.setMaximumSize(QSize(160, 16777215)) self.horizontalLayout_8.addWidget(self.resolutionLabel) self.verticalLayout_3.addLayout(self.horizontalLayout_8) self.horizontalLayout_9 = QHBoxLayout() self.horizontalLayout_9.setObjectName(u"horizontalLayout_9") self.label_10 = QLabel(Img) self.label_10.setObjectName(u"label_10") self.label_10.setMaximumSize(QSize(60, 16777215)) self.horizontalLayout_9.addWidget(self.label_10) self.sizeLabel = QLabel(Img) self.sizeLabel.setObjectName(u"sizeLabel") self.sizeLabel.setMaximumSize(QSize(160, 16777215)) self.horizontalLayout_9.addWidget(self.sizeLabel) self.verticalLayout_3.addLayout(self.horizontalLayout_9) self.horizontalLayout = QHBoxLayout() self.horizontalLayout.setObjectName(u"horizontalLayout") self.label = QLabel(Img) self.label.setObjectName(u"label") self.label.setMaximumSize(QSize(60, 16777215)) self.horizontalLayout.addWidget(self.label) self.gpuName = QLabel(Img) self.gpuName.setObjectName(u"gpuName") self.gpuName.setMaximumSize(QSize(160, 16777215)) self.horizontalLayout.addWidget(self.gpuName) self.verticalLayout_3.addLayout(self.horizontalLayout) self.horizontalLayout_10 = QHBoxLayout() self.horizontalLayout_10.setObjectName(u"horizontalLayout_10") self.label_6 = QLabel(Img) self.label_6.setObjectName(u"label_6") self.label_6.setMaximumSize(QSize(60, 16777215)) self.horizontalLayout_10.addWidget(self.label_6) self.tickLabel = QLabel(Img) self.tickLabel.setObjectName(u"tickLabel") self.tickLabel.setMaximumSize(QSize(160, 16777215)) self.horizontalLayout_10.addWidget(self.tickLabel) self.verticalLayout_3.addLayout(self.horizontalLayout_10) self.oepnButton = QPushButton(Img) self.oepnButton.setObjectName(u"oepnButton") self.oepnButton.setMaximumSize(QSize(100, 16777215)) self.verticalLayout_3.addWidget(self.oepnButton) self.horizontalLayout_2 = QHBoxLayout() self.horizontalLayout_2.setObjectName(u"horizontalLayout_2") self.verticalLayout_3.addLayout(self.horizontalLayout_2) self.pushButton_3 = QPushButton(Img) self.pushButton_3.setObjectName(u"pushButton_3") self.pushButton_3.setMaximumSize(QSize(100, 16777215)) self.verticalLayout_3.addWidget(self.pushButton_3) self.pushButton = QPushButton(Img) self.pushButton.setObjectName(u"pushButton") self.pushButton.setMaximumSize(QSize(100, 16777215)) self.verticalLayout_3.addWidget(self.pushButton) self.saveButton = QPushButton(Img) self.saveButton.setObjectName(u"saveButton") self.saveButton.setMaximumSize(QSize(100, 16777215)) self.verticalLayout_3.addWidget(self.saveButton) self.verticalLayout.addLayout(self.verticalLayout_3) self.line_6 = QFrame(Img) self.line_6.setObjectName(u"line_6") self.line_6.setFrameShape(QFrame.HLine) self.line_6.setFrameShadow(QFrame.Sunken) self.verticalLayout.addWidget(self.line_6) self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout.addItem(self.verticalSpacer) self.line_2 = QFrame(Img) self.line_2.setObjectName(u"line_2") self.line_2.setFrameShape(QFrame.VLine) self.line_2.setFrameShadow(QFrame.Sunken) self.verticalLayout.addWidget(self.line_2) self.gridLayout.addLayout(self.verticalLayout, 0, 1, 1, 1) self.retranslateUi(Img) self.checkBox.clicked.connect(Img.SwithPicture) self.saveButton.clicked.connect(Img.SavePicture) self.heighEdit.textChanged.connect(Img.CheckScaleRadio) self.pushButton_3.clicked.connect(Img.ReduceScalePic) self.heighRadio.clicked.connect(Img.CheckScaleRadio) self.ttaModel.clicked.connect(Img.CheckScaleRadio) self.oepnButton.clicked.connect(Img.OpenPicture) self.widthEdit.textChanged.connect(Img.CheckScaleRadio) self.pushButton.clicked.connect(Img.AddScalePic) self.scaleEdit.textChanged.connect(Img.CheckScaleRadio) self.scaleRadio.clicked.connect(Img.CheckScaleRadio) self.comboBox.currentIndexChanged.connect(Img.ChangeModel) self.changeJpg.clicked.connect(Img.StartWaifu2x) self.noiseCombox.currentIndexChanged.connect(Img.CheckScaleRadio) self.changePng.clicked.connect(Img.StartWaifu2xPng) self.changeJpg.clicked.connect(Img.StartWaifu2xJPG) QMetaObject.connectSlotsByName(Img) # setupUi def retranslateUi(self, Img): Img.setWindowTitle(QCoreApplication.translate("Img", u"Form", None)) self.checkBox.setText( QCoreApplication.translate("Img", u"waifu2x", None)) #if QT_CONFIG(tooltip) self.ttaModel.setToolTip( QCoreApplication.translate( "Img", u"\u753b\u8d28\u63d0\u5347\uff0c\u8017\u65f6\u589e\u52a0", None)) #endif // QT_CONFIG(tooltip) self.ttaModel.setText( QCoreApplication.translate("Img", u"tta\u6a21\u5f0f", None)) self.scaleRadio.setText( QCoreApplication.translate("Img", u"\u500d\u6570\u653e\u5927", None)) self.scaleEdit.setText(QCoreApplication.translate("Img", u"2", None)) self.heighRadio.setText( QCoreApplication.translate("Img", u"\u56fa\u5b9a\u957f\u5bbd", None)) self.label_2.setText(QCoreApplication.translate("Img", u"x", None)) self.label_4.setText( QCoreApplication.translate("Img", u"\u964d\u566a\uff1a", None)) self.noiseCombox.setItemText( 0, QCoreApplication.translate("Img", u"3", None)) self.noiseCombox.setItemText( 1, QCoreApplication.translate("Img", u"2", None)) self.noiseCombox.setItemText( 2, QCoreApplication.translate("Img", u"1", None)) self.noiseCombox.setItemText( 3, QCoreApplication.translate("Img", u"0", None)) self.noiseCombox.setItemText( 4, QCoreApplication.translate("Img", u"-1", None)) self.label_5.setText( QCoreApplication.translate("Img", u"\u6a21\u578b\uff1a", None)) self.comboBox.setItemText( 0, QCoreApplication.translate("Img", u"cunet", None)) self.comboBox.setItemText( 1, QCoreApplication.translate("Img", u"photo", None)) self.comboBox.setItemText( 2, QCoreApplication.translate("Img", u"anime_style_art_rgb", None)) self.changeJpg.setText( QCoreApplication.translate("Img", u"\u8f6c\u6362JPG", None)) self.changePng.setText( QCoreApplication.translate("Img", u"\u8f6c\u6362PNG", None)) self.changeLabel.setText("") self.label_8.setText( QCoreApplication.translate("Img", u"\u5206\u8fa8\u7387\uff1a", None)) self.resolutionLabel.setText( QCoreApplication.translate("Img", u"TextLabel", None)) self.label_10.setText( QCoreApplication.translate("Img", u"\u5927 \u5c0f\uff1a", None)) self.sizeLabel.setText( QCoreApplication.translate("Img", u"TextLabel", None)) self.label.setText(QCoreApplication.translate("Img", u"GPU:", None)) self.gpuName.setText( QCoreApplication.translate("Img", u"TextLabel", None)) self.label_6.setText( QCoreApplication.translate("Img", u"\u8017\u65f6\uff1a", None)) self.tickLabel.setText("") self.oepnButton.setText( QCoreApplication.translate("Img", u"\u6253\u5f00\u56fe\u7247", None)) self.pushButton_3.setText( QCoreApplication.translate("Img", u"\u7f29\u5c0f", None)) self.pushButton.setText( QCoreApplication.translate("Img", u"\u653e\u5927", None)) self.saveButton.setText( QCoreApplication.translate("Img", u"\u4fdd\u5b58\u56fe\u7247", None))
class AddOTPWidget(TritonWidget): def __init__(self, base, *args, **kwargs): TritonWidget.__init__(self, base, *args, **kwargs) self.key = None self.type = Globals.OTPAuth self.setWindowTitle('Add Authenticator') self.setBackgroundColor(self, Qt.white) self.boxLayout = QVBoxLayout(self) self.boxLayout.setContentsMargins(20, 20, 20, 20) self.nameWidget = TextboxWidget(base, 'Name:') self.secretLabel = QLabel() self.secretLabel.setText( 'Enter the Secret Code. If you have a QR code,\nyou can paste the URL of the image instead.' ) self.secretLabel.setFont(QFont('Helvetica', 10)) self.secretBox = QLineEdit() self.secretBox.setFixedWidth(300) self.secretBox.setFont(QFont('Helvetica', 10)) self.secretBox.textChanged.connect( lambda text: self.invalidateSecret()) self.verifyLabel = QLabel() self.verifyLabel.setText( 'Click the Verify button to check the first code.') self.verifyLabel.setFont(QFont('Helvetica', 10)) self.verifyBox = QLineEdit() self.verifyBox.setFixedWidth(150) self.verifyBox.setFont(QFont('Helvetica', 10)) self.verifyBox.setEnabled(False) palette = QPalette() palette.setColor(QPalette.Text, Qt.black) self.verifyBox.setPalette(palette) self.verifyBox.setAlignment(Qt.AlignCenter) self.verifyButton = QPushButton('Verify') self.verifyButton.clicked.connect(self.checkVerify) self.verifyButton.setFixedWidth(150) self.addButton = QPushButton('OK') self.addButton.clicked.connect(self.add) self.boxLayout.addWidget(self.nameWidget) self.boxLayout.addSpacing(10) self.boxLayout.addWidget(self.secretLabel) self.boxLayout.addWidget(self.secretBox) self.boxLayout.addSpacing(10) self.boxLayout.addWidget(self.verifyLabel) self.boxLayout.addWidget(self.verifyBox, 0, Qt.AlignCenter) self.boxLayout.addWidget(self.verifyButton, 0, Qt.AlignCenter) self.boxLayout.addSpacing(10) self.boxLayout.addWidget(self.addButton, 0, Qt.AlignRight) self.setFixedSize(self.sizeHint()) self.center() self.show() def getName(self): return self.nameWidget.box.text() def getAccount(self): return { 'name': self.getName(), 'type': self.type, 'key': self.key, 'icon': 'icons/WinAuthIcon.png' } def invalidateSecret(self, value=''): self.key = None self.verifyBox.setText(value) def checkVerify(self): self.key = self.secretBox.text() if not self.key: self.invalidateSecret('Invalid') return self.key = self.base.readQRLink(self.key) or self.key self.key = self.key.upper().replace(' ', '') try: self.verifyBox.setText(self.base.getAuthCode(self.getAccount())) except: self.invalidateSecret('Invalid') def add(self): if not self.key or not self.getName(): return self.base.addAccount(self.getAccount()) self.close()