def grid_layout_creation_1(self) -> None: self.group_box_1 = QGroupBox("Image info") layout = QGridLayout() layout.addWidget(QLabel(bold("Local file?")), 0, 0) layout.addWidget(QLabel("Yes" if self.img.local_file else "No"), 0, 1) layout.addWidget(QLabel(bold("Path:")), 1, 0) text = self.img.get_absolute_path_or_url() layout.addWidget(QLabel(text), 1, 1) icon = QtGui.QIcon(str(Path(cfg.ASSETS_DIR, "clipboard.png"))) btn = QPushButton() btn.setIcon(icon) btn.setIconSize(QtCore.QSize(ICON_SIZE, ICON_SIZE)) btn.setToolTip("copy to clipboard") btn.clicked.connect(partial(self.copy_to_clipboard, text)) layout.addWidget(btn, 1, 2) layout.addWidget(QLabel(bold("Resolution:")), 2, 0) text = "{w} x {h} pixels".format(w=self.img.original_img.width(), h=self.img.original_img.height()) layout.addWidget(QLabel(text), 2, 1) layout.addWidget(QLabel(bold("Size:")), 3, 0) file_size_hr = self.img.get_file_size(human_readable=True) text = "{0} ({1} bytes)".format( file_size_hr, helper.pretty_num(self.img.get_file_size())) layout.addWidget(QLabel(text), 3, 1) layout.addWidget(QLabel(bold("Flags:")), 4, 0) text = self.img.get_flags() layout.addWidget(QLabel(text), 4, 1) self.group_box_1.setLayout(layout)
class SyncWidget(QWidget): Sg_view_changed = Signal() def __init__(self, model: SyncModel, parent=None): super(SyncWidget, self).__init__(parent) self._model = model self.watch_label = QLabel(self) self.watch_label.setAlignment(Qt.AlignCenter) self.watch_label.setText("SYNC") self.watch_label.setAccessibleName("Title") self.running_label = QLabel(self) self.running_label.setAlignment(Qt.AlignCenter) self.running_label.setText("Disattivata") self.running_label.setAccessibleName("Subtitle") self.sync_button = QPushButton(self) self.sync_button.setIcon(QIcon(resource_path('icons/reload.png'))) self.sync_button.setIconSize(QSize(50, 50)) self.sync_button.setCheckable(True) self.sync_button.setAccessibleName('HighlightButton') self.menu_label = QLabel(self) self.menu_label.setAlignment(Qt.AlignCenter) self.menu_label.setText("• • •") # create layout self.layout = QVBoxLayout() self.layout.setAlignment(Qt.AlignCenter) self.layout.addWidget(self.watch_label) self.layout.addWidget(self.running_label) self.layout.addWidget(self.sync_button) self.layout.addWidget(self.menu_label) self.setLayout(self.layout) self.sync_button.clicked.connect(self.Sl_button_clicked) self.Sl_model_changed() @Slot() def Sl_button_clicked(self): self.Sg_view_changed.emit() @Slot() def Sl_model_changed(self): self.sync_button.setChecked(self._model.get_state()) if self._model.get_state(): self.running_label.setText("Attivata") else: self.running_label.setText("Disattivata")
def __init__(self, db: SqlDB): super().__init__() self.setWidgetResizable(True) self.db = db self.icons = Icons() base = QWidget(self) base.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) self.setWidget(base) grid = QGridLayout() base.setLayout(grid) row = 0 # _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_ # TEST Label test = QLabel('TEST') test.setStyleSheet( "QLabel {font-size:14pt; padding: 0 2px; background: #ddf;}") test.setFrameStyle(QFrame.StyledPanel | QFrame.Plain) grid.addWidget(test, row, 0, 1, 2) row += 1 # --------------------------------------------------------------------- # SUPPLIER dump lab_dump_supplier = QLabel('DUMP table supplier') lab_dump_supplier.setStyleSheet( "QLabel {font-size:10pt; padding: 0 2px;}") but_dump_supplier = QPushButton() but_dump_supplier.setIcon(QIcon(self.icons.PLAY)) but_dump_supplier.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding) but_dump_supplier.clicked.connect(self.on_click_dump_supplier) grid.addWidget(lab_dump_supplier, row, 0) grid.addWidget(but_dump_supplier, row, 1) row += 1 # --------------------------------------------------------------------- # PART dump lab_dump_part = QLabel('DUMP table part') lab_dump_part.setStyleSheet("QLabel {font-size:10pt; padding: 0 2px;}") but_dump_part = QPushButton() but_dump_part.setIcon(QIcon(self.icons.PLAY)) but_dump_part.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding) but_dump_part.clicked.connect(self.on_click_dump_part) grid.addWidget(lab_dump_part, row, 0) grid.addWidget(but_dump_part, row, 1) row += 1
class MainWindow(QMainWindow): def __init__(self): super(MainWindow, self).__init__() self.setWindowTitle('PySide6 WebEngineWidgets Example') self.toolBar = QToolBar() self.addToolBar(self.toolBar) self.backButton = QPushButton() self.backButton.setIcon(QIcon(':/qt-project.org/styles/commonstyle/images/left-32.png')) self.backButton.clicked.connect(self.back) self.toolBar.addWidget(self.backButton) self.forwardButton = QPushButton() self.forwardButton.setIcon(QIcon(':/qt-project.org/styles/commonstyle/images/right-32.png')) self.forwardButton.clicked.connect(self.forward) self.toolBar.addWidget(self.forwardButton) self.addressLineEdit = QLineEdit() self.addressLineEdit.returnPressed.connect(self.load) self.toolBar.addWidget(self.addressLineEdit) self.webEngineView = QWebEngineView() self.setCentralWidget(self.webEngineView) initialUrl = 'http://qt.io' self.addressLineEdit.setText(initialUrl) self.webEngineView.load(QUrl(initialUrl)) self.webEngineView.page().titleChanged.connect(self.setWindowTitle) self.webEngineView.page().urlChanged.connect(self.urlChanged) def load(self): url = QUrl.fromUserInput(self.addressLineEdit.text()) if url.isValid(): self.webEngineView.load(url) def back(self): self.webEngineView.page().triggerAction(QWebEnginePage.Back) def forward(self): self.webEngineView.page().triggerAction(QWebEnginePage.Forward) def urlChanged(self, url): self.addressLineEdit.setText(url.toString())
def __init__(self, db: SqlDB): super().__init__() self.setWidgetResizable(True) self.db = db self.icons = Icons() base = QWidget(self) base.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) self.setWidget(base) grid = QGridLayout() base.setLayout(grid) row = 0 # _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_ # SPC Label test = QLabel('SPC data') test.setStyleSheet( "QLabel {font-size:14pt; padding: 0 2px; background: #ddf;}") test.setFrameStyle(QFrame.StyledPanel | QFrame.Plain) grid.addWidget(test, row, 0, 1, 2) row += 1 # --------------------------------------------------------------------- # Excel file read lab_dump_supplier = QLabel('Excel data uploader') lab_dump_supplier.setStyleSheet( "QLabel {font-size:10pt; padding: 0 2px;}") but_dump_supplier = QPushButton() but_dump_supplier.setIcon(QIcon(self.icons.EXCEL)) but_dump_supplier.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding) but_dump_supplier.setStatusTip('read SPC Excel file') #but_dump_supplier.clicked.connect(self.on_click_dump_supplier) grid.addWidget(lab_dump_supplier, row, 0) grid.addWidget(but_dump_supplier, row, 1) row += 1
class LogWindow_Ui(QWidget): def __init__(self, persepolis_setting): super().__init__() self.persepolis_setting = persepolis_setting # add support for other languages locale = str(self.persepolis_setting.value('settings/locale')) QLocale.setDefault(QLocale(locale)) self.translator = QTranslator() if self.translator.load(':/translations/locales/ui_' + locale, 'ts'): QCoreApplication.installTranslator(self.translator) # set ui direction ui_direction = self.persepolis_setting.value('ui_direction') if ui_direction == 'rtl': self.setLayoutDirection(Qt.RightToLeft) elif ui_direction in 'ltr': self.setLayoutDirection(Qt.LeftToRight) icons = ':/' + \ str(self.persepolis_setting.value('settings/icons')) + '/' # finding windows_size self.setMinimumSize(QtCore.QSize(620, 300)) self.setWindowIcon( QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg'))) verticalLayout = QVBoxLayout(self) horizontalLayout = QHBoxLayout() horizontalLayout.addStretch(1) # text_edit self.text_edit = QTextEdit(self) self.text_edit.setReadOnly(True) verticalLayout.addWidget(self.text_edit) # clear_log_pushButton self.clear_log_pushButton = QPushButton(self) horizontalLayout.addWidget(self.clear_log_pushButton) # refresh_log_pushButton self.refresh_log_pushButton = QPushButton(self) self.refresh_log_pushButton.setIcon(QIcon(icons + 'refresh')) horizontalLayout.addWidget(self.refresh_log_pushButton) # report_pushButton self.report_pushButton = QPushButton(self) self.report_pushButton.setIcon(QIcon(icons + 'about')) horizontalLayout.addWidget(self.report_pushButton) self.copy_log_pushButton = QPushButton(self) # copy_log_pushButton self.copy_log_pushButton.setIcon(QIcon(icons + 'clipboard')) horizontalLayout.addWidget(self.copy_log_pushButton) # close_pushButton self.close_pushButton = QPushButton(self) self.close_pushButton.setIcon(QIcon(icons + 'remove')) horizontalLayout.addWidget(self.close_pushButton) verticalLayout.addLayout(horizontalLayout) # set labels self.setWindowTitle( QCoreApplication.translate("log_window_ui_tr", 'Persepolis Log')) self.close_pushButton.setText( QCoreApplication.translate("log_window_ui_tr", 'Close')) self.copy_log_pushButton.setText( QCoreApplication.translate("log_window_ui_tr", 'Copy Selected to Clipboard')) self.report_pushButton.setText( QCoreApplication.translate("log_window_ui_tr", "Report Issue")) self.refresh_log_pushButton.setText( QCoreApplication.translate("log_window_ui_tr", 'Refresh Log Messages')) self.clear_log_pushButton.setText( QCoreApplication.translate("log_window_ui_tr", 'Clear Log Messages'))
class Ui_Dialog(object): def setupUi(self, Dialog): if not Dialog.objectName(): Dialog.setObjectName(u"Dialog") Dialog.resize(580, 501) icon = QIcon() icon.addFile(u":/openshot.svg", QSize(), QIcon.Normal, QIcon.Off) Dialog.setWindowIcon(icon) Dialog.setLocale(QLocale(QLocale.English, QLocale.UnitedStates)) self.horizontalLayout = QHBoxLayout(Dialog) self.horizontalLayout.setObjectName(u"horizontalLayout") self.vbox_parent = QVBoxLayout() self.vbox_parent.setObjectName(u"vbox_parent") self.verticalLayout = QVBoxLayout() self.verticalLayout.setObjectName(u"verticalLayout") self.horizontalLayout_2 = QHBoxLayout() self.horizontalLayout_2.setObjectName(u"horizontalLayout_2") self.vboxTreeParent = QVBoxLayout() self.vboxTreeParent.setObjectName(u"vboxTreeParent") self.horizontalLayout_6 = QHBoxLayout() self.horizontalLayout_6.setObjectName(u"horizontalLayout_6") self.btnMoveUp = QPushButton(Dialog) self.btnMoveUp.setObjectName(u"btnMoveUp") icon1 = QIcon() iconThemeName = u"go-up" if QIcon.hasThemeIcon(iconThemeName): icon1 = QIcon.fromTheme(iconThemeName) else: icon1.addFile(u"", QSize(), QIcon.Normal, QIcon.Off) self.btnMoveUp.setIcon(icon1) self.horizontalLayout_6.addWidget(self.btnMoveUp) self.btnMoveDown = QPushButton(Dialog) self.btnMoveDown.setObjectName(u"btnMoveDown") icon2 = QIcon() iconThemeName = u"go-down" if QIcon.hasThemeIcon(iconThemeName): icon2 = QIcon.fromTheme(iconThemeName) else: icon2.addFile(u"", QSize(), QIcon.Normal, QIcon.Off) self.btnMoveDown.setIcon(icon2) self.horizontalLayout_6.addWidget(self.btnMoveDown) self.btnShuffle = QPushButton(Dialog) self.btnShuffle.setObjectName(u"btnShuffle") icon3 = QIcon() iconThemeName = u"view-refresh" if QIcon.hasThemeIcon(iconThemeName): icon3 = QIcon.fromTheme(iconThemeName) else: icon3.addFile(u"", QSize(), QIcon.Normal, QIcon.Off) self.btnShuffle.setIcon(icon3) self.horizontalLayout_6.addWidget(self.btnShuffle) self.btnRemove = QPushButton(Dialog) self.btnRemove.setObjectName(u"btnRemove") icon4 = QIcon() iconThemeName = u"list-remove" if QIcon.hasThemeIcon(iconThemeName): icon4 = QIcon.fromTheme(iconThemeName) else: icon4.addFile(u"", QSize(), QIcon.Normal, QIcon.Off) self.btnRemove.setIcon(icon4) self.horizontalLayout_6.addWidget(self.btnRemove) self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout_6.addItem(self.horizontalSpacer) self.vboxTreeParent.addLayout(self.horizontalLayout_6) self.horizontalLayout_2.addLayout(self.vboxTreeParent) self.vbox_properties = QVBoxLayout() self.vbox_properties.setObjectName(u"vbox_properties") self.lblTimelineLocation = QLabel(Dialog) self.lblTimelineLocation.setObjectName(u"lblTimelineLocation") self.lblTimelineLocation.setStyleSheet(u"font-weight: bold") self.lblTimelineLocation.setMargin(0) self.vbox_properties.addWidget(self.lblTimelineLocation) self.horizontalLayout_4 = QHBoxLayout() self.horizontalLayout_4.setObjectName(u"horizontalLayout_4") self.lblStartTime = QLabel(Dialog) self.lblStartTime.setObjectName(u"lblStartTime") self.lblStartTime.setMinimumSize(QSize(100, 0)) self.lblStartTime.setStyleSheet(u"") self.horizontalLayout_4.addWidget(self.lblStartTime) self.txtStartTime = QDoubleSpinBox(Dialog) self.txtStartTime.setObjectName(u"txtStartTime") sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.txtStartTime.sizePolicy().hasHeightForWidth()) self.txtStartTime.setSizePolicy(sizePolicy) self.txtStartTime.setMinimumSize(QSize(150, 0)) self.txtStartTime.setMaximum(999999999.000000000000000) self.horizontalLayout_4.addWidget(self.txtStartTime) self.vbox_properties.addLayout(self.horizontalLayout_4) self.horizontalLayout_3 = QHBoxLayout() self.horizontalLayout_3.setObjectName(u"horizontalLayout_3") self.lblTrack = QLabel(Dialog) self.lblTrack.setObjectName(u"lblTrack") self.lblTrack.setMinimumSize(QSize(100, 0)) self.lblTrack.setStyleSheet(u"") self.horizontalLayout_3.addWidget(self.lblTrack) self.cmbTrack = QComboBox(Dialog) self.cmbTrack.setObjectName(u"cmbTrack") self.cmbTrack.setMinimumSize(QSize(150, 0)) self.horizontalLayout_3.addWidget(self.cmbTrack) self.vbox_properties.addLayout(self.horizontalLayout_3) self.horizontalLayout_11 = QHBoxLayout() self.horizontalLayout_11.setObjectName(u"horizontalLayout_11") self.horizontalLayout_11.setContentsMargins(-1, 0, -1, -1) self.label_3 = QLabel(Dialog) self.label_3.setObjectName(u"label_3") self.label_3.setMinimumSize(QSize(100, 0)) self.horizontalLayout_11.addWidget(self.label_3) self.txtImageLength = QDoubleSpinBox(Dialog) self.txtImageLength.setObjectName(u"txtImageLength") sizePolicy.setHeightForWidth( self.txtImageLength.sizePolicy().hasHeightForWidth()) self.txtImageLength.setSizePolicy(sizePolicy) self.txtImageLength.setMinimumSize(QSize(150, 0)) self.txtImageLength.setMaximum(999999999.000000000000000) self.horizontalLayout_11.addWidget(self.txtImageLength) self.vbox_properties.addLayout(self.horizontalLayout_11) self.lblFade = QLabel(Dialog) self.lblFade.setObjectName(u"lblFade") self.lblFade.setStyleSheet(u"font-weight: bold; margin-top: 15px;") self.lblFade.setMargin(0) self.vbox_properties.addWidget(self.lblFade) self.horizontalLayout_5 = QHBoxLayout() self.horizontalLayout_5.setObjectName(u"horizontalLayout_5") self.lblFade1 = QLabel(Dialog) self.lblFade1.setObjectName(u"lblFade1") self.lblFade1.setStyleSheet(u"") self.horizontalLayout_5.addWidget(self.lblFade1) self.cmbFade = QComboBox(Dialog) self.cmbFade.setObjectName(u"cmbFade") self.cmbFade.setMinimumSize(QSize(150, 0)) self.horizontalLayout_5.addWidget(self.cmbFade) self.vbox_properties.addLayout(self.horizontalLayout_5) self.horizontalLayout_8 = QHBoxLayout() self.horizontalLayout_8.setObjectName(u"horizontalLayout_8") self.lblFadeLength = QLabel(Dialog) self.lblFadeLength.setObjectName(u"lblFadeLength") self.lblFadeLength.setStyleSheet(u"") self.horizontalLayout_8.addWidget(self.lblFadeLength) self.txtFadeLength = QDoubleSpinBox(Dialog) self.txtFadeLength.setObjectName(u"txtFadeLength") self.txtFadeLength.setMinimumSize(QSize(150, 0)) self.txtFadeLength.setMaximum(999999999.000000000000000) self.txtFadeLength.setValue(2.000000000000000) self.horizontalLayout_8.addWidget(self.txtFadeLength) self.vbox_properties.addLayout(self.horizontalLayout_8) self.label = QLabel(Dialog) self.label.setObjectName(u"label") self.label.setStyleSheet(u"font-weight: bold; margin-top: 15px;") self.vbox_properties.addWidget(self.label) self.horizontalLayout_7 = QHBoxLayout() self.horizontalLayout_7.setObjectName(u"horizontalLayout_7") self.horizontalLayout_7.setContentsMargins(-1, 0, -1, -1) self.label_2 = QLabel(Dialog) self.label_2.setObjectName(u"label_2") self.horizontalLayout_7.addWidget(self.label_2) self.cmbZoom = QComboBox(Dialog) self.cmbZoom.setObjectName(u"cmbZoom") self.cmbZoom.setMinimumSize(QSize(150, 0)) self.horizontalLayout_7.addWidget(self.cmbZoom) self.vbox_properties.addLayout(self.horizontalLayout_7) self.lblTransition = QLabel(Dialog) self.lblTransition.setObjectName(u"lblTransition") self.lblTransition.setStyleSheet( u"font-weight: bold; margin-top: 15px;") self.lblTransition.setMargin(0) self.vbox_properties.addWidget(self.lblTransition) self.horizontalLayout_9 = QHBoxLayout() self.horizontalLayout_9.setObjectName(u"horizontalLayout_9") self.lblTransition1 = QLabel(Dialog) self.lblTransition1.setObjectName(u"lblTransition1") self.lblTransition1.setStyleSheet(u"") self.horizontalLayout_9.addWidget(self.lblTransition1) self.cmbTransition = QComboBox(Dialog) self.cmbTransition.setObjectName(u"cmbTransition") self.cmbTransition.setMinimumSize(QSize(150, 0)) self.cmbTransition.setMaximumSize(QSize(150, 16777215)) self.horizontalLayout_9.addWidget(self.cmbTransition) self.vbox_properties.addLayout(self.horizontalLayout_9) self.horizontalLayout_10 = QHBoxLayout() self.horizontalLayout_10.setObjectName(u"horizontalLayout_10") self.lblTransitionLength = QLabel(Dialog) self.lblTransitionLength.setObjectName(u"lblTransitionLength") self.lblTransitionLength.setStyleSheet(u"") self.horizontalLayout_10.addWidget(self.lblTransitionLength) self.txtTransitionLength = QDoubleSpinBox(Dialog) self.txtTransitionLength.setObjectName(u"txtTransitionLength") self.txtTransitionLength.setMinimumSize(QSize(150, 0)) self.txtTransitionLength.setMaximum(999999999.000000000000000) self.txtTransitionLength.setValue(2.000000000000000) self.horizontalLayout_10.addWidget(self.txtTransitionLength) self.vbox_properties.addLayout(self.horizontalLayout_10) self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.vbox_properties.addItem(self.verticalSpacer) self.horizontalLayout_2.addLayout(self.vbox_properties) self.verticalLayout.addLayout(self.horizontalLayout_2) self.vbox_parent.addLayout(self.verticalLayout) self.horizontalLayout_12 = QHBoxLayout() self.horizontalLayout_12.setObjectName(u"horizontalLayout_12") self.horizontalLayout_12.setContentsMargins(-1, 0, -1, -1) self.lblTotalLength = QLabel(Dialog) self.lblTotalLength.setObjectName(u"lblTotalLength") sizePolicy1 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) sizePolicy1.setHorizontalStretch(0) sizePolicy1.setVerticalStretch(0) sizePolicy1.setHeightForWidth( self.lblTotalLength.sizePolicy().hasHeightForWidth()) self.lblTotalLength.setSizePolicy(sizePolicy1) self.lblTotalLength.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter) self.horizontalLayout_12.addWidget(self.lblTotalLength) self.lblTotalLengthValue = QLabel(Dialog) self.lblTotalLengthValue.setObjectName(u"lblTotalLengthValue") sizePolicy2 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy2.setHorizontalStretch(0) sizePolicy2.setVerticalStretch(0) sizePolicy2.setHeightForWidth( self.lblTotalLengthValue.sizePolicy().hasHeightForWidth()) self.lblTotalLengthValue.setSizePolicy(sizePolicy2) self.lblTotalLengthValue.setMinimumSize(QSize(75, 0)) self.lblTotalLengthValue.setStyleSheet(u"font-weight:bold;") self.lblTotalLengthValue.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter) self.horizontalLayout_12.addWidget(self.lblTotalLengthValue) self.vbox_parent.addLayout(self.horizontalLayout_12) self.btnBox = QDialogButtonBox(Dialog) self.btnBox.setObjectName(u"btnBox") self.btnBox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) self.btnBox.setCenterButtons(False) self.vbox_parent.addWidget(self.btnBox) self.horizontalLayout.addLayout(self.vbox_parent) self.retranslateUi(Dialog) QMetaObject.connectSlotsByName(Dialog) # setupUi def retranslateUi(self, Dialog): Dialog.setWindowTitle( QCoreApplication.translate("Dialog", u"Add To Timeline", None)) #if QT_CONFIG(tooltip) self.btnMoveUp.setToolTip( QCoreApplication.translate("Dialog", u"Move Up", None)) #endif // QT_CONFIG(tooltip) self.btnMoveUp.setText("") #if QT_CONFIG(tooltip) self.btnMoveDown.setToolTip( QCoreApplication.translate("Dialog", u"Move Down", None)) #endif // QT_CONFIG(tooltip) self.btnMoveDown.setText("") #if QT_CONFIG(tooltip) self.btnShuffle.setToolTip( QCoreApplication.translate("Dialog", u"Shuffle", None)) #endif // QT_CONFIG(tooltip) self.btnShuffle.setText("") #if QT_CONFIG(tooltip) self.btnRemove.setToolTip( QCoreApplication.translate("Dialog", u"Remove", None)) #endif // QT_CONFIG(tooltip) self.btnRemove.setText("") self.lblTimelineLocation.setText( QCoreApplication.translate("Dialog", u"Timeline Location", None)) self.lblStartTime.setText( QCoreApplication.translate("Dialog", u"Start Time (seconds):", None)) self.lblTrack.setText( QCoreApplication.translate("Dialog", u"Track:", None)) self.label_3.setText( QCoreApplication.translate("Dialog", u"Image Length (seconds):", None)) self.lblFade.setText( QCoreApplication.translate("Dialog", u"Fade", None)) self.lblFade1.setText( QCoreApplication.translate("Dialog", u"Fade:", None)) self.lblFadeLength.setText( QCoreApplication.translate("Dialog", u"Length (seconds):", None)) self.label.setText(QCoreApplication.translate("Dialog", u"Zoom", None)) self.label_2.setText( QCoreApplication.translate("Dialog", u"Zoom:", None)) self.lblTransition.setText( QCoreApplication.translate("Dialog", u"Transition", None)) self.lblTransition1.setText( QCoreApplication.translate("Dialog", u"Transition:", None)) self.lblTransitionLength.setText( QCoreApplication.translate("Dialog", u"Length:", None)) self.lblTotalLength.setText( QCoreApplication.translate("Dialog", u"Total Length (seconds):", None)) self.lblTotalLengthValue.setText( QCoreApplication.translate("Dialog", u"0.0", None))
class TextQueue_Ui(QWidget): def __init__(self, persepolis_setting): super().__init__() self.persepolis_setting = persepolis_setting icons = ':/' + \ str(self.persepolis_setting.value('settings/icons')) + '/' # add support for other languages locale = str(self.persepolis_setting.value('settings/locale')) QLocale.setDefault(QLocale(locale)) self.translator = QTranslator() if self.translator.load(':/translations/locales/ui_' + locale, 'ts'): QCoreApplication.installTranslator(self.translator) # set ui direction ui_direction = self.persepolis_setting.value('ui_direction') if ui_direction == 'rtl': self.setLayoutDirection(Qt.RightToLeft) elif ui_direction in 'ltr': self.setLayoutDirection(Qt.LeftToRight) self.setWindowIcon( QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg'))) window_verticalLayout = QVBoxLayout() self.setLayout(window_verticalLayout) # queue_tabWidget self.queue_tabWidget = QTabWidget(self) window_verticalLayout.addWidget(self.queue_tabWidget) # links_tab self.links_tab = QWidget() links_tab_verticalLayout = QVBoxLayout(self.links_tab) # link table self.links_table = QTableWidget(self.links_tab) links_tab_verticalLayout.addWidget(self.links_table) self.links_table.setSelectionBehavior(QAbstractItemView.SelectRows) self.links_table.setEditTriggers(QAbstractItemView.NoEditTriggers) self.links_table.verticalHeader().hide() self.links_table.setColumnCount(3) links_table_header_labels = [ 'File Name', 'Download Link', 'dictionary' ] self.links_table.setHorizontalHeaderLabels(links_table_header_labels) self.links_table.setColumnHidden(2, True) self.links_table.horizontalHeader().setSectionResizeMode( QHeaderView.ResizeMode.Stretch) self.links_table.horizontalHeader().setStretchLastSection(True) # add_queue add_queue_horizontalLayout = QHBoxLayout() self.select_all_pushButton = QPushButton(self.links_tab) add_queue_horizontalLayout.addWidget(self.select_all_pushButton) self.deselect_all_pushButton = QPushButton(self.links_tab) add_queue_horizontalLayout.addWidget(self.deselect_all_pushButton) add_queue_horizontalLayout.addStretch(1) self.add_queue_label = QLabel(self.links_tab) add_queue_horizontalLayout.addWidget(self.add_queue_label) self.add_queue_comboBox = QComboBox(self.links_tab) add_queue_horizontalLayout.addWidget(self.add_queue_comboBox) links_tab_verticalLayout.addLayout(add_queue_horizontalLayout) links_tab_verticalLayout.addStretch(1) self.queue_tabWidget.addTab(self.links_tab, "") # options_tab self.options_tab = QWidget() options_tab_verticalLayout = QVBoxLayout(self.options_tab) # proxy proxy_verticalLayout = QVBoxLayout() self.proxy_checkBox = QCheckBox(self.options_tab) proxy_verticalLayout.addWidget(self.proxy_checkBox) self.proxy_frame = QFrame(self.options_tab) self.proxy_frame.setFrameShape(QFrame.StyledPanel) self.proxy_frame.setFrameShadow(QFrame.Raised) proxy_gridLayout = QGridLayout(self.proxy_frame) self.ip_lineEdit = QLineEdit(self.proxy_frame) self.ip_lineEdit.setInputMethodHints(Qt.ImhNone) proxy_gridLayout.addWidget(self.ip_lineEdit, 0, 1, 1, 1) self.proxy_pass_label = QLabel(self.proxy_frame) proxy_gridLayout.addWidget(self.proxy_pass_label, 2, 2, 1, 1) self.proxy_pass_lineEdit = QLineEdit(self.proxy_frame) self.proxy_pass_lineEdit.setEchoMode(QLineEdit.Password) proxy_gridLayout.addWidget(self.proxy_pass_lineEdit, 2, 3, 1, 1) self.ip_label = QLabel(self.proxy_frame) proxy_gridLayout.addWidget(self.ip_label, 0, 0, 1, 1) self.proxy_user_lineEdit = QLineEdit(self.proxy_frame) proxy_gridLayout.addWidget(self.proxy_user_lineEdit, 0, 3, 1, 1) self.proxy_user_label = QLabel(self.proxy_frame) proxy_gridLayout.addWidget(self.proxy_user_label, 0, 2, 1, 1) self.port_label = QLabel(self.proxy_frame) proxy_gridLayout.addWidget(self.port_label, 2, 0, 1, 1) self.port_spinBox = QSpinBox(self.proxy_frame) self.port_spinBox.setMaximum(9999) self.port_spinBox.setSingleStep(1) proxy_gridLayout.addWidget(self.port_spinBox, 2, 1, 1, 1) proxy_verticalLayout.addWidget(self.proxy_frame) options_tab_verticalLayout.addLayout(proxy_verticalLayout) # download Username & Password download_horizontalLayout = QHBoxLayout() download_horizontalLayout.setContentsMargins(-1, 10, -1, -1) download_verticalLayout = QVBoxLayout() self.download_checkBox = QCheckBox(self.options_tab) download_verticalLayout.addWidget(self.download_checkBox) self.download_frame = QFrame(self.options_tab) self.download_frame.setFrameShape(QFrame.StyledPanel) self.download_frame.setFrameShadow(QFrame.Raised) download_gridLayout = QGridLayout(self.download_frame) self.download_user_lineEdit = QLineEdit(self.download_frame) download_gridLayout.addWidget(self.download_user_lineEdit, 0, 1, 1, 1) self.download_user_label = QLabel(self.download_frame) download_gridLayout.addWidget(self.download_user_label, 0, 0, 1, 1) self.download_pass_label = QLabel(self.download_frame) download_gridLayout.addWidget(self.download_pass_label, 1, 0, 1, 1) self.download_pass_lineEdit = QLineEdit(self.download_frame) self.download_pass_lineEdit.setEchoMode(QLineEdit.Password) download_gridLayout.addWidget(self.download_pass_lineEdit, 1, 1, 1, 1) download_verticalLayout.addWidget(self.download_frame) download_horizontalLayout.addLayout(download_verticalLayout) # select folder self.folder_frame = QFrame(self.options_tab) self.folder_frame.setFrameShape(QFrame.StyledPanel) self.folder_frame.setFrameShadow(QFrame.Raised) folder_gridLayout = QGridLayout(self.folder_frame) self.download_folder_lineEdit = QLineEdit(self.folder_frame) folder_gridLayout.addWidget(self.download_folder_lineEdit, 2, 0, 1, 1) self.folder_pushButton = QPushButton(self.folder_frame) folder_gridLayout.addWidget(self.folder_pushButton, 3, 0, 1, 1) self.folder_pushButton.setIcon(QIcon(icons + 'folder')) self.folder_checkBox = QCheckBox(self.folder_frame) folder_gridLayout.addWidget(self.folder_checkBox) self.folder_label = QLabel(self.folder_frame) self.folder_label.setAlignment(Qt.AlignCenter) folder_gridLayout.addWidget(self.folder_label, 1, 0, 1, 1) download_horizontalLayout.addWidget(self.folder_frame) options_tab_verticalLayout.addLayout(download_horizontalLayout) self.queue_tabWidget.addTab(self.options_tab, '') # limit Speed limit_verticalLayout = QVBoxLayout() self.limit_checkBox = QCheckBox(self.options_tab) limit_verticalLayout.addWidget(self.limit_checkBox) self.limit_frame = QFrame(self.options_tab) self.limit_frame.setFrameShape(QFrame.StyledPanel) self.limit_frame.setFrameShadow(QFrame.Raised) limit_horizontalLayout = QHBoxLayout(self.limit_frame) self.limit_spinBox = QSpinBox(self.limit_frame) self.limit_spinBox.setMinimum(1) self.limit_spinBox.setMaximum(1023) limit_horizontalLayout.addWidget(self.limit_spinBox) self.limit_comboBox = QComboBox(self.limit_frame) self.limit_comboBox.addItem("KiB/S") self.limit_comboBox.addItem("MiB/S") limit_horizontalLayout.addWidget(self.limit_comboBox) limit_verticalLayout.addWidget(self.limit_frame) limit_connections_horizontalLayout = QHBoxLayout() limit_connections_horizontalLayout.addLayout(limit_verticalLayout) # number of connections connections_horizontalLayout = QHBoxLayout() connections_horizontalLayout.setContentsMargins(-1, 10, -1, -1) self.connections_frame = QFrame(self.options_tab) self.connections_frame.setFrameShape(QFrame.StyledPanel) self.connections_frame.setFrameShadow(QFrame.Raised) horizontalLayout_3 = QHBoxLayout(self.connections_frame) self.connections_label = QLabel(self.connections_frame) horizontalLayout_3.addWidget(self.connections_label) self.connections_spinBox = QSpinBox(self.connections_frame) self.connections_spinBox.setMinimum(1) self.connections_spinBox.setMaximum(16) self.connections_spinBox.setProperty("value", 16) horizontalLayout_3.addWidget(self.connections_spinBox) connections_horizontalLayout.addWidget(self.connections_frame) limit_connections_horizontalLayout.addLayout( connections_horizontalLayout) options_tab_verticalLayout.addLayout( limit_connections_horizontalLayout) options_tab_verticalLayout.addStretch(1) # buttons buttons_horizontalLayout = QHBoxLayout() buttons_horizontalLayout.addStretch(1) # ok_pushButton self.ok_pushButton = QPushButton(self) self.ok_pushButton.setIcon(QIcon(icons + 'ok')) buttons_horizontalLayout.addWidget(self.ok_pushButton) # cancel_pushButton self.cancel_pushButton = QPushButton(self) self.cancel_pushButton.setIcon(QIcon(icons + 'remove')) buttons_horizontalLayout.addWidget(self.cancel_pushButton) window_verticalLayout.addLayout(buttons_horizontalLayout) # labels self.setWindowTitle( QCoreApplication.translate("text_ui_tr", "Persepolis Download Manager")) self.queue_tabWidget.setTabText( self.queue_tabWidget.indexOf(self.links_tab), QCoreApplication.translate("text_ui_tr", 'Links')) self.queue_tabWidget.setTabText( self.queue_tabWidget.indexOf(self.options_tab), QCoreApplication.translate("text_ui_tr", 'Download Options')) self.select_all_pushButton.setText( QCoreApplication.translate("text_ui_tr", 'Select All')) self.deselect_all_pushButton.setText( QCoreApplication.translate("text_ui_tr", 'Deselect All')) self.add_queue_label.setText( QCoreApplication.translate("text_ui_tr", 'Add to queue: ')) self.proxy_checkBox.setText( QCoreApplication.translate("text_ui_tr", 'Proxy')) self.proxy_pass_label.setText( QCoreApplication.translate("text_ui_tr", "Proxy password: "******"text_ui_tr", "IP:")) self.proxy_user_label.setText( QCoreApplication.translate("text_ui_tr", "Proxy username: "******"text_ui_tr", "Port:")) self.download_checkBox.setText( QCoreApplication.translate("text_ui_tr", "Download username and password")) self.download_user_label.setText( QCoreApplication.translate("text_ui_tr", "Download username: "******"text_ui_tr", "Download password: "******"text_ui_tr", "Change Download Folder")) self.folder_checkBox.setText( QCoreApplication.translate("addlink_ui_tr", "Remember this path")) self.folder_label.setText( QCoreApplication.translate("text_ui_tr", "Download folder: ")) self.limit_checkBox.setText( QCoreApplication.translate("text_ui_tr", "Limit speed")) self.connections_label.setText( QCoreApplication.translate("text_ui_tr", "Number of connections:")) self.ok_pushButton.setText( QCoreApplication.translate("text_ui_tr", 'OK')) self.cancel_pushButton.setText( QCoreApplication.translate("text_ui_tr", 'Cancel'))
class MainWindow_Ui(QMainWindow): def __init__(self, persepolis_setting): super().__init__() # MainWindow self.persepolis_setting = persepolis_setting # add support for other languages locale = str(self.persepolis_setting.value('settings/locale')) QLocale.setDefault(QLocale(locale)) self.translator = QTranslator() if self.translator.load(':/translations/locales/ui_' + locale, 'ts'): QCoreApplication.installTranslator(self.translator) # set ui direction ui_direction = self.persepolis_setting.value('ui_direction') if ui_direction == 'rtl': self.setLayoutDirection(Qt.RightToLeft) elif ui_direction in 'ltr': self.setLayoutDirection(Qt.LeftToRight) icons = ':/' + \ str(self.persepolis_setting.value('settings/icons')) + '/' self.setWindowTitle( QCoreApplication.translate("mainwindow_ui_tr", "Persepolis Download Manager")) self.setWindowIcon( QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg'))) self.centralwidget = QWidget(self) self.verticalLayout = QVBoxLayout(self.centralwidget) # enable drag and drop self.setAcceptDrops(True) # frame self.frame = QFrame(self.centralwidget) # download_table_horizontalLayout download_table_horizontalLayout = QHBoxLayout() horizontal_splitter = QSplitter(Qt.Horizontal) vertical_splitter = QSplitter(Qt.Vertical) # category_tree self.category_tree_qwidget = QWidget(self) category_tree_verticalLayout = QVBoxLayout() self.category_tree = CategoryTreeView(self) category_tree_verticalLayout.addWidget(self.category_tree) self.category_tree_model = QStandardItemModel() self.category_tree.setModel(self.category_tree_model) category_table_header = [ QCoreApplication.translate("mainwindow_ui_tr", 'Category') ] self.category_tree_model.setHorizontalHeaderLabels( category_table_header) self.category_tree.header().setStretchLastSection(True) self.category_tree.header().setDefaultAlignment(Qt.AlignCenter) # queue_panel self.queue_panel_widget = QWidget(self) queue_panel_verticalLayout_main = QVBoxLayout(self.queue_panel_widget) # queue_panel_show_button self.queue_panel_show_button = QPushButton(self) queue_panel_verticalLayout_main.addWidget(self.queue_panel_show_button) # queue_panel_widget_frame self.queue_panel_widget_frame = QFrame(self) self.queue_panel_widget_frame.setFrameShape(QFrame.StyledPanel) self.queue_panel_widget_frame.setFrameShadow(QFrame.Raised) queue_panel_verticalLayout_main.addWidget( self.queue_panel_widget_frame) queue_panel_verticalLayout = QVBoxLayout(self.queue_panel_widget_frame) queue_panel_verticalLayout_main.setContentsMargins(50, -1, 50, -1) # start_end_frame self.start_end_frame = QFrame(self) # start time start_verticalLayout = QVBoxLayout(self.start_end_frame) self.start_checkBox = QCheckBox(self) start_verticalLayout.addWidget(self.start_checkBox) self.start_frame = QFrame(self) self.start_frame.setFrameShape(QFrame.StyledPanel) self.start_frame.setFrameShadow(QFrame.Raised) start_frame_verticalLayout = QVBoxLayout(self.start_frame) self.start_time_qDataTimeEdit = MyQDateTimeEdit(self.start_frame) self.start_time_qDataTimeEdit.setDisplayFormat('H:mm') start_frame_verticalLayout.addWidget(self.start_time_qDataTimeEdit) start_verticalLayout.addWidget(self.start_frame) # end time self.end_checkBox = QCheckBox(self) start_verticalLayout.addWidget(self.end_checkBox) self.end_frame = QFrame(self) self.end_frame.setFrameShape(QFrame.StyledPanel) self.end_frame.setFrameShadow(QFrame.Raised) end_frame_verticalLayout = QVBoxLayout(self.end_frame) self.end_time_qDateTimeEdit = MyQDateTimeEdit(self.end_frame) self.end_time_qDateTimeEdit.setDisplayFormat('H:mm') end_frame_verticalLayout.addWidget(self.end_time_qDateTimeEdit) start_verticalLayout.addWidget(self.end_frame) self.reverse_checkBox = QCheckBox(self) start_verticalLayout.addWidget(self.reverse_checkBox) queue_panel_verticalLayout.addWidget(self.start_end_frame) # limit_after_frame self.limit_after_frame = QFrame(self) # limit_checkBox limit_verticalLayout = QVBoxLayout(self.limit_after_frame) self.limit_checkBox = QCheckBox(self) limit_verticalLayout.addWidget(self.limit_checkBox) # limit_frame self.limit_frame = QFrame(self) self.limit_frame.setFrameShape(QFrame.StyledPanel) self.limit_frame.setFrameShadow(QFrame.Raised) limit_verticalLayout.addWidget(self.limit_frame) limit_frame_verticalLayout = QVBoxLayout(self.limit_frame) # limit_spinBox limit_frame_horizontalLayout = QHBoxLayout() self.limit_spinBox = QDoubleSpinBox(self) self.limit_spinBox.setMinimum(1) self.limit_spinBox.setMaximum(1023) limit_frame_horizontalLayout.addWidget(self.limit_spinBox) # limit_comboBox self.limit_comboBox = QComboBox(self) self.limit_comboBox.addItem("") self.limit_comboBox.addItem("") limit_frame_horizontalLayout.addWidget(self.limit_comboBox) limit_frame_verticalLayout.addLayout(limit_frame_horizontalLayout) # limit_pushButton self.limit_pushButton = QPushButton(self) limit_frame_verticalLayout.addWidget(self.limit_pushButton) # after_checkBox self.after_checkBox = QCheckBox(self) limit_verticalLayout.addWidget(self.after_checkBox) # after_frame self.after_frame = QFrame(self) self.after_frame.setFrameShape(QFrame.StyledPanel) self.after_frame.setFrameShadow(QFrame.Raised) limit_verticalLayout.addWidget(self.after_frame) after_frame_verticalLayout = QVBoxLayout(self.after_frame) # after_comboBox self.after_comboBox = QComboBox(self) self.after_comboBox.addItem("") after_frame_verticalLayout.addWidget(self.after_comboBox) # after_pushButton self.after_pushButton = QPushButton(self) after_frame_verticalLayout.addWidget(self.after_pushButton) queue_panel_verticalLayout.addWidget(self.limit_after_frame) category_tree_verticalLayout.addWidget(self.queue_panel_widget) # keep_awake_checkBox self.keep_awake_checkBox = QCheckBox(self) queue_panel_verticalLayout.addWidget(self.keep_awake_checkBox) self.category_tree_qwidget.setLayout(category_tree_verticalLayout) horizontal_splitter.addWidget(self.category_tree_qwidget) # download table widget self.download_table_content_widget = QWidget(self) download_table_content_widget_verticalLayout = QVBoxLayout( self.download_table_content_widget) # download_table self.download_table = DownloadTableWidget(self) vertical_splitter.addWidget(self.download_table) horizontal_splitter.addWidget(self.download_table_content_widget) self.download_table.setColumnCount(13) self.download_table.setSelectionBehavior(QAbstractItemView.SelectRows) self.download_table.setEditTriggers(QAbstractItemView.NoEditTriggers) self.download_table.verticalHeader().hide() # hide column of GID and column of link. self.download_table.setColumnHidden(8, True) self.download_table.setColumnHidden(9, True) download_table_header = [ QCoreApplication.translate("mainwindow_ui_tr", 'File Name'), QCoreApplication.translate("mainwindow_ui_tr", 'Status'), QCoreApplication.translate("mainwindow_ui_tr", 'Size'), QCoreApplication.translate("mainwindow_ui_tr", 'Downloaded'), QCoreApplication.translate("mainwindow_ui_tr", 'Percentage'), QCoreApplication.translate("mainwindow_ui_tr", 'Connections'), QCoreApplication.translate("mainwindow_ui_tr", 'Transfer Rate'), QCoreApplication.translate("mainwindow_ui_tr", 'Estimated Time Left'), 'Gid', QCoreApplication.translate("mainwindow_ui_tr", 'Link'), QCoreApplication.translate("mainwindow_ui_tr", 'First Try Date'), QCoreApplication.translate("mainwindow_ui_tr", 'Last Try Date'), QCoreApplication.translate("mainwindow_ui_tr", 'Category') ] self.download_table.setHorizontalHeaderLabels(download_table_header) # fixing the size of download_table when window is Maximized! self.download_table.horizontalHeader().setSectionResizeMode( QHeaderView.ResizeMode.Interactive) self.download_table.horizontalHeader().setStretchLastSection(True) horizontal_splitter.setStretchFactor(0, 3) # category_tree width horizontal_splitter.setStretchFactor(1, 10) # ratio of tables's width # video_finder_widget self.video_finder_widget = QWidget(self) video_finder_horizontalLayout = QHBoxLayout(self.video_finder_widget) self.muxing_pushButton = QPushButton(self) self.muxing_pushButton.setIcon(QIcon(icons + 'video_finder')) video_finder_horizontalLayout.addWidget(self.muxing_pushButton) video_finder_horizontalLayout.addSpacing(20) video_audio_verticalLayout = QVBoxLayout() self.video_label = QLabel(self) video_audio_verticalLayout.addWidget(self.video_label) self.audio_label = QLabel(self) video_audio_verticalLayout.addWidget(self.audio_label) video_finder_horizontalLayout.addLayout(video_audio_verticalLayout) status_muxing_verticalLayout = QVBoxLayout() self.video_finder_status_label = QLabel(self) status_muxing_verticalLayout.addWidget(self.video_finder_status_label) self.muxing_status_label = QLabel(self) status_muxing_verticalLayout.addWidget(self.muxing_status_label) video_finder_horizontalLayout.addLayout(status_muxing_verticalLayout) vertical_splitter.addWidget(self.video_finder_widget) download_table_content_widget_verticalLayout.addWidget( vertical_splitter) download_table_horizontalLayout.addWidget(horizontal_splitter) self.frame.setLayout(download_table_horizontalLayout) self.verticalLayout.addWidget(self.frame) self.setCentralWidget(self.centralwidget) # menubar self.menubar = QMenuBar(self) self.menubar.setGeometry(QRect(0, 0, 600, 24)) self.setMenuBar(self.menubar) fileMenu = self.menubar.addMenu( QCoreApplication.translate("mainwindow_ui_tr", '&File')) editMenu = self.menubar.addMenu( QCoreApplication.translate("mainwindow_ui_tr", '&Edit')) viewMenu = self.menubar.addMenu( QCoreApplication.translate("mainwindow_ui_tr", '&View')) downloadMenu = self.menubar.addMenu( QCoreApplication.translate("mainwindow_ui_tr", '&Download')) queueMenu = self.menubar.addMenu( QCoreApplication.translate("mainwindow_ui_tr", '&Queue')) videoFinderMenu = self.menubar.addMenu( QCoreApplication.translate("mainwindow_ui_tr", 'V&ideo Finder')) helpMenu = self.menubar.addMenu( QCoreApplication.translate("mainwindow_ui_tr", '&Help')) # viewMenu submenus sortMenu = viewMenu.addMenu( QCoreApplication.translate("mainwindow_ui_tr", 'Sort by')) # statusbar self.statusbar = QStatusBar(self) self.setStatusBar(self.statusbar) self.statusbar.showMessage( QCoreApplication.translate("mainwindow_ui_tr", "Persepolis Download Manager")) # toolBar self.toolBar2 = QToolBar(self) self.addToolBar(Qt.TopToolBarArea, self.toolBar2) self.toolBar2.setWindowTitle( QCoreApplication.translate("mainwindow_ui_tr", 'Menu')) self.toolBar2.setFloatable(False) self.toolBar2.setMovable(False) self.toolBar = QToolBar(self) self.addToolBar(Qt.TopToolBarArea, self.toolBar) self.toolBar.setWindowTitle( QCoreApplication.translate("mainwindow_ui_tr", 'Toolbar')) self.toolBar.setFloatable(False) self.toolBar.setMovable(False) #toolBar and menubar and actions self.persepolis_setting.beginGroup('settings/shortcuts') # videoFinderAddLinkAction self.videoFinderAddLinkAction = QAction( QIcon(icons + 'video_finder'), QCoreApplication.translate("mainwindow_ui_tr", 'Find Video Links...'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Download video or audio from Youtube, Vimeo, etc.'), triggered=self.showVideoFinderAddLinkWindow) self.videoFinderAddLinkAction_shortcut = QShortcut( self.persepolis_setting.value('video_finder_shortcut'), self, self.showVideoFinderAddLinkWindow) videoFinderMenu.addAction(self.videoFinderAddLinkAction) # stopAllAction self.stopAllAction = QAction(QIcon(icons + 'stop_all'), QCoreApplication.translate( "mainwindow_ui_tr", 'Stop All Active Downloads'), self, statusTip='Stop All Active Downloads', triggered=self.stopAllDownloads) downloadMenu.addAction(self.stopAllAction) # sort_file_name_Action self.sort_file_name_Action = QAction(QCoreApplication.translate( "mainwindow_ui_tr", 'File Name'), self, triggered=self.sortByName) sortMenu.addAction(self.sort_file_name_Action) # sort_file_size_Action self.sort_file_size_Action = QAction(QCoreApplication.translate( "mainwindow_ui_tr", 'File Size'), self, triggered=self.sortBySize) sortMenu.addAction(self.sort_file_size_Action) # sort_first_try_date_Action self.sort_first_try_date_Action = QAction( QCoreApplication.translate("mainwindow_ui_tr", 'First Try Date'), self, triggered=self.sortByFirstTry) sortMenu.addAction(self.sort_first_try_date_Action) # sort_last_try_date_Action self.sort_last_try_date_Action = QAction(QCoreApplication.translate( "mainwindow_ui_tr", 'Last Try Date'), self, triggered=self.sortByLastTry) sortMenu.addAction(self.sort_last_try_date_Action) # sort_download_status_Action self.sort_download_status_Action = QAction(QCoreApplication.translate( "mainwindow_ui_tr", 'Download Status'), self, triggered=self.sortByStatus) sortMenu.addAction(self.sort_download_status_Action) # trayAction self.trayAction = QAction( QCoreApplication.translate("mainwindow_ui_tr", 'Show System Tray Icon'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Show/Hide system tray icon"), triggered=self.showTray) self.trayAction.setCheckable(True) viewMenu.addAction(self.trayAction) # showMenuBarAction self.showMenuBarAction = QAction( QCoreApplication.translate("mainwindow_ui_tr", 'Show Menubar'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Show Menubar'), triggered=self.showMenuBar) self.showMenuBarAction.setCheckable(True) viewMenu.addAction(self.showMenuBarAction) # showSidePanelAction self.showSidePanelAction = QAction( QCoreApplication.translate("mainwindow_ui_tr", 'Show Side Panel'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Show Side Panel'), triggered=self.showSidePanel) self.showSidePanelAction.setCheckable(True) viewMenu.addAction(self.showSidePanelAction) # minimizeAction self.minimizeAction = QAction( QIcon(icons + 'minimize'), QCoreApplication.translate("mainwindow_ui_tr", 'Minimize to System Tray'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Minimize to System Tray"), triggered=self.minMaxTray) self.minimizeAction_shortcut = QShortcut( self.persepolis_setting.value('hide_window_shortcut'), self, self.minMaxTray) viewMenu.addAction(self.minimizeAction) # addlinkAction self.addlinkAction = QAction( QIcon(icons + 'add'), QCoreApplication.translate("mainwindow_ui_tr", 'Add New Download Link...'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Add New Download Link"), triggered=self.addLinkButtonPressed) self.addlinkAction_shortcut = QShortcut( self.persepolis_setting.value('add_new_download_shortcut'), self, self.addLinkButtonPressed) fileMenu.addAction(self.addlinkAction) # importText self.addtextfileAction = QAction( QIcon(icons + 'file'), QCoreApplication.translate("mainwindow_ui_tr", 'Import Links from Text File...'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Create a text file and put links in it, line by line!'), triggered=self.importText) self.addtextfileAction_shortcut = QShortcut( self.persepolis_setting.value('import_text_shortcut'), self, self.importText) fileMenu.addAction(self.addtextfileAction) # resumeAction self.resumeAction = QAction( QIcon(icons + 'play'), QCoreApplication.translate("mainwindow_ui_tr", 'Resume Download'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Resume Download"), triggered=self.resumeButtonPressed) downloadMenu.addAction(self.resumeAction) # pauseAction self.pauseAction = QAction( QIcon(icons + 'pause'), QCoreApplication.translate("mainwindow_ui_tr", 'Pause Download'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Pause Download"), triggered=self.pauseButtonPressed) downloadMenu.addAction(self.pauseAction) # stopAction self.stopAction = QAction( QIcon(icons + 'stop'), QCoreApplication.translate("mainwindow_ui_tr", 'Stop Download'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Stop/Cancel Download"), triggered=self.stopButtonPressed) downloadMenu.addAction(self.stopAction) # propertiesAction self.propertiesAction = QAction( QIcon(icons + 'setting'), QCoreApplication.translate("mainwindow_ui_tr", 'Properties'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Properties"), triggered=self.propertiesButtonPressed) downloadMenu.addAction(self.propertiesAction) # progressAction self.progressAction = QAction( QIcon(icons + 'window'), QCoreApplication.translate("mainwindow_ui_tr", 'Progress'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Progress"), triggered=self.progressButtonPressed) downloadMenu.addAction(self.progressAction) # openFileAction self.openFileAction = QAction( QIcon(icons + 'file'), QCoreApplication.translate("mainwindow_ui_tr", 'Open File...'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Open File...'), triggered=self.openFile) fileMenu.addAction(self.openFileAction) # openDownloadFolderAction self.openDownloadFolderAction = QAction( QIcon(icons + 'folder'), QCoreApplication.translate("mainwindow_ui_tr", 'Open Download Folder'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Open Download Folder'), triggered=self.openDownloadFolder) fileMenu.addAction(self.openDownloadFolderAction) # openDefaultDownloadFolderAction self.openDefaultDownloadFolderAction = QAction( QIcon(icons + 'folder'), QCoreApplication.translate("mainwindow_ui_tr", 'Open Default Download Folder'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Open Default Download Folder'), triggered=self.openDefaultDownloadFolder) fileMenu.addAction(self.openDefaultDownloadFolderAction) # exitAction self.exitAction = QAction( QIcon(icons + 'exit'), QCoreApplication.translate("mainwindow_ui_tr", 'Exit'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Exit"), triggered=self.closeAction) self.exitAction_shortcut = QShortcut( self.persepolis_setting.value('quit_shortcut'), self, self.closeAction) fileMenu.addAction(self.exitAction) # clearAction self.clearAction = QAction(QIcon(icons + 'multi_remove'), QCoreApplication.translate( "mainwindow_ui_tr", 'Clear Download List'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Clear all items in download list'), triggered=self.clearDownloadList) editMenu.addAction(self.clearAction) # removeSelectedAction self.removeSelectedAction = QAction( QIcon(icons + 'remove'), QCoreApplication.translate("mainwindow_ui_tr", 'Remove Selected Downloads from List'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Remove Selected Downloads from List'), triggered=self.removeSelected) self.removeSelectedAction_shortcut = QShortcut( self.persepolis_setting.value('remove_shortcut'), self, self.removeSelected) editMenu.addAction(self.removeSelectedAction) self.removeSelectedAction.setEnabled(False) # deleteSelectedAction self.deleteSelectedAction = QAction( QIcon(icons + 'trash'), QCoreApplication.translate("mainwindow_ui_tr", 'Delete Selected Download Files'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Delete Selected Download Files'), triggered=self.deleteSelected) self.deleteSelectedAction_shortcut = QShortcut( self.persepolis_setting.value('delete_shortcut'), self, self.deleteSelected) editMenu.addAction(self.deleteSelectedAction) self.deleteSelectedAction.setEnabled(False) # moveSelectedDownloadsAction self.moveSelectedDownloadsAction = QAction( QIcon(icons + 'folder'), QCoreApplication.translate( "mainwindow_ui_tr", 'Move Selected Download Files to Another Folder...'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Move Selected Download Files to Another Folder'), triggered=self.moveSelectedDownloads) editMenu.addAction(self.moveSelectedDownloadsAction) self.moveSelectedDownloadsAction.setEnabled(False) # createQueueAction self.createQueueAction = QAction( QIcon(icons + 'add_queue'), QCoreApplication.translate("mainwindow_ui_tr", 'Create New Queue...'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Create new download queue'), triggered=self.createQueue) queueMenu.addAction(self.createQueueAction) # removeQueueAction self.removeQueueAction = QAction( QIcon(icons + 'remove_queue'), QCoreApplication.translate("mainwindow_ui_tr", 'Remove Queue'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Remove this queue'), triggered=self.removeQueue) queueMenu.addAction(self.removeQueueAction) # startQueueAction self.startQueueAction = QAction( QIcon(icons + 'start_queue'), QCoreApplication.translate("mainwindow_ui_tr", 'Start this queue'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Start Queue'), triggered=self.startQueue) queueMenu.addAction(self.startQueueAction) # stopQueueAction self.stopQueueAction = QAction( QIcon(icons + 'stop_queue'), QCoreApplication.translate("mainwindow_ui_tr", 'Stop this queue'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Stop Queue'), triggered=self.stopQueue) queueMenu.addAction(self.stopQueueAction) # moveUpSelectedAction self.moveUpSelectedAction = QAction( QIcon(icons + 'multi_up'), QCoreApplication.translate("mainwindow_ui_tr", 'Move Selected Items Up'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Move currently selected items up by one row'), triggered=self.moveUpSelected) self.moveUpSelectedAction_shortcut = QShortcut( self.persepolis_setting.value('move_up_selection_shortcut'), self, self.moveUpSelected) queueMenu.addAction(self.moveUpSelectedAction) # moveDownSelectedAction self.moveDownSelectedAction = QAction( QIcon(icons + 'multi_down'), QCoreApplication.translate("mainwindow_ui_tr", 'Move Selected Items Down'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Move currently selected items down by one row'), triggered=self.moveDownSelected) self.moveDownSelectedAction_shortcut = QShortcut( self.persepolis_setting.value('move_down_selection_shortcut'), self, self.moveDownSelected) queueMenu.addAction(self.moveDownSelectedAction) # preferencesAction self.preferencesAction = QAction( QIcon(icons + 'preferences'), QCoreApplication.translate("mainwindow_ui_tr", 'Preferences'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Preferences'), triggered=self.openPreferences, menuRole=QAction.MenuRole.PreferencesRole) editMenu.addAction(self.preferencesAction) # aboutAction self.aboutAction = QAction( QIcon(icons + 'about'), QCoreApplication.translate("mainwindow_ui_tr", 'About'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'About'), triggered=self.openAbout, menuRole=QAction.MenuRole.AboutRole) helpMenu.addAction(self.aboutAction) # issueAction self.issueAction = QAction( QIcon(icons + 'about'), QCoreApplication.translate("mainwindow_ui_tr", 'Report an Issue'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Report an issue'), triggered=self.reportIssue) helpMenu.addAction(self.issueAction) # updateAction self.updateAction = QAction( QIcon(icons + 'about'), QCoreApplication.translate("mainwindow_ui_tr", 'Check for Newer Version'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Check for newer release'), triggered=self.newUpdate) helpMenu.addAction(self.updateAction) # logAction self.logAction = QAction( QIcon(icons + 'about'), QCoreApplication.translate("mainwindow_ui_tr", 'Show Log File'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Help'), triggered=self.showLog) helpMenu.addAction(self.logAction) # helpAction self.helpAction = QAction( QIcon(icons + 'about'), QCoreApplication.translate("mainwindow_ui_tr", 'Help'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Help'), triggered=self.persepolisHelp) helpMenu.addAction(self.helpAction) self.persepolis_setting.endGroup() self.qmenu = MenuWidget(self) self.toolBar2.addWidget(self.qmenu) # labels self.queue_panel_show_button.setText( QCoreApplication.translate("mainwindow_ui_tr", "Hide Options")) self.start_checkBox.setText( QCoreApplication.translate("mainwindow_ui_tr", "Start Time")) self.end_checkBox.setText( QCoreApplication.translate("mainwindow_ui_tr", "End Time")) self.reverse_checkBox.setText( QCoreApplication.translate("mainwindow_ui_tr", "Download bottom of\n the list first")) self.limit_checkBox.setText( QCoreApplication.translate("mainwindow_ui_tr", "Limit Speed")) self.limit_comboBox.setItemText(0, "KiB/s") self.limit_comboBox.setItemText(1, "MiB/s") self.limit_pushButton.setText( QCoreApplication.translate("mainwindow_ui_tr", "Apply")) self.after_checkBox.setText( QCoreApplication.translate("mainwindow_ui_tr", "After download")) self.after_comboBox.setItemText( 0, QCoreApplication.translate("mainwindow_ui_tr", "Shut Down")) self.keep_awake_checkBox.setText( QCoreApplication.translate("mainwindow_ui_tr", "Keep System Awake!")) self.keep_awake_checkBox.setToolTip( QCoreApplication.translate( "mainwindow_ui_tr", "<html><head/><body><p>This option will prevent the system from going to sleep.\ It is necessary if your power manager is suspending the system automatically. </p></body></html>" )) self.after_pushButton.setText( QCoreApplication.translate("mainwindow_ui_tr", "Apply")) self.muxing_pushButton.setText( QCoreApplication.translate("mainwindow_ui_tr", "Start Mixing")) self.video_label.setText( QCoreApplication.translate("mainwindow_ui_tr", "<b>Video File Status: </b>")) self.audio_label.setText( QCoreApplication.translate("mainwindow_ui_tr", "<b>Audio File Status: </b>")) self.video_finder_status_label.setText( QCoreApplication.translate("mainwindow_ui_tr", "<b>Status: </b>")) self.muxing_status_label.setText( QCoreApplication.translate("mainwindow_ui_tr", "<b>Mixing status: </b>"))
class Ui_MainWindow(QMainWindow): def __init__(self): super().__init__() self.setWindowIcon(QIcon(resource_path('icon.ico'))) self.setFixedSize(540, 470) def setupUi(self): self.centralwidget = QWidget(self) with open(resource_path('style.css'), 'r') as file: self.centralwidget.setStyleSheet(file.read()) self.appswidget = QWidget(self.centralwidget) self.appswidget.setGeometry(50, 0, 490, 470) self.appswidget.setProperty('class', 'appswidget') self.sidebar = QFrame(self.centralwidget) self.sidebar.setFrameShape(QFrame.StyledPanel) self.sidebar.setGeometry(0, 0, 50, 470) self.sidebar.setProperty('class', 'sidebar') self.refresh_btn = QPushButton(self.sidebar) self.refresh_btn.setGeometry(QRect(0, 0, 51, 51)) self.refresh_btn.setProperty('class', 'sidebar_btns') self.refresh_btn.setIcon(QIcon(':/icon/refresh_icon.png')) self.refresh_btn.setIconSize(QSize(24, 24)) self.refresh_bind = QShortcut(QKeySequence('Ctrl+R'), self) self.store_btn = QPushButton(self.sidebar) self.store_btn.setGeometry(QRect(0, 51, 51, 51)) self.store_btn.setProperty('class', 'sidebar_btns') self.store_btn.setIcon(QIcon(':/icon/store_icon.png')) self.store_btn.setIconSize(QSize(24, 24)) self.store_bind = QShortcut(QKeySequence('Ctrl+S'), self) self.homepage_btn = QPushButton(self.sidebar) self.homepage_btn.setGeometry(QRect(0, 102, 51, 51)) self.homepage_btn.setProperty('class', 'sidebar_btns') self.homepage_btn.setIcon(QIcon(':/icon/github_icon.png')) self.homepage_btn.setIconSize(QSize(24, 24)) self.homepage_bind = QShortcut(QKeySequence('Ctrl+G'), self) self.about_btn = QPushButton(self.sidebar) self.about_btn.setGeometry(QRect(0, 153, 51, 51)) self.about_btn.setProperty('class', 'sidebar_btns') self.about_btn.setIcon(QIcon(':/icon/about_icon.png')) self.about_btn.setIconSize(QSize(24, 24)) self.about_bind = QShortcut(QKeySequence('Ctrl+A'), self) self.quit_btn = QPushButton(self.sidebar) self.quit_btn.setGeometry(QRect(0, 420, 51, 51)) self.quit_btn.setProperty('class', 'sidebar_btns_quit') self.quit_btn.setIcon(QIcon(':/icon/quit_icon.png')) self.quit_btn.setIconSize(QSize(24, 24)) self.quit_bind = QShortcut(QKeySequence('Ctrl+Q'), self) self.font = QFont() self.font.setPointSize(8) self.font.setStyleStrategy(QFont.PreferAntialias) self.label_refresh = QLabel(self.appswidget) self.label_refresh.setFont(self.font) self.label_refresh.setGeometry(QRect(20, 10, 441, 15)) self.label_info = QLabel(self.appswidget) self.label_info.setFont(self.font) self.label_info.setGeometry(QRect(20, 10, 441, 30)) self.progressbar = QProgressBar(self.appswidget) self.progressbar.setGeometry(QRect(20, 30, 441, 20)) self.layout_widget_checkboxes = QWidget(self.appswidget) self.layout_widget_checkboxes.setGeometry(QRect(20, 55, 155, 311)) self.layout_checkboxes = QVBoxLayout(self.layout_widget_checkboxes) self.layout_checkboxes.setContentsMargins(0, 0, 0, 0) self.layout_widget_checkboxes_2 = QWidget(self.appswidget) self.layout_widget_checkboxes_2.setGeometry(QRect(175, 55, 155, 311)) self.layout_checkboxes_2 = QVBoxLayout(self.layout_widget_checkboxes_2) self.layout_checkboxes_2.setContentsMargins(0, 0, 0, 0) self.layout_widget_checkboxes_3 = QWidget(self.appswidget) self.layout_widget_checkboxes_3.setGeometry(QRect(330, 55, 155, 311)) self.layout_checkboxes_3 = QVBoxLayout(self.layout_widget_checkboxes_3) self.layout_checkboxes_3.setContentsMargins(0, 0, 0, 0) self.layout_widget_labels = QWidget(self.appswidget) self.layout_widget_labels.setGeometry(QRect(20, 390, 350, 16)) self.layout_labels = QHBoxLayout(self.layout_widget_labels) self.layout_labels.setContentsMargins(0, 0, 0, 0) self.label_space = QLabel(self.appswidget) self.label_space.setFont(self.font) self.layout_labels.addWidget(self.label_space) self.label_size = QLabel(self.appswidget) self.label_size.setFont(self.font) self.layout_labels.addWidget(self.label_size) self.layout_widget_buttons = QWidget(self.appswidget) self.layout_widget_buttons.setGeometry(QRect(20, 420, 454, 31)) self.layout_buttons = QHBoxLayout(self.layout_widget_buttons) self.layout_buttons.setContentsMargins(0, 0, 0, 0) self.button_select_all = QPushButton(self.layout_widget_buttons) self.button_select_all.setIcon(QIcon(':/icon/check_icon.png')) self.button_select_all.setIconSize(QSize(18, 18)) self.button_select_all.setLayoutDirection(Qt.RightToLeft) self.layout_buttons.addWidget(self.button_select_all) self.button_select_all.setMinimumSize(100, 30) self.button_select_all.setProperty('class', 'Aqua') self.button_deselect_all = QPushButton(self.layout_widget_buttons) self.button_deselect_all.setIcon(QIcon(':/icon/cancel_icon.png')) self.button_deselect_all.setIconSize(QSize(18, 18)) self.button_deselect_all.setLayoutDirection(Qt.RightToLeft) self.layout_buttons.addWidget(self.button_deselect_all) self.button_deselect_all.setMinimumSize(100, 30) self.button_deselect_all.setProperty('class', 'Aqua') self.layout_buttons.addStretch() self.button_uninstall = QPushButton(self.layout_widget_buttons) self.button_uninstall.setIcon(QIcon(':/icon/trash_icon.png')) self.button_uninstall.setIconSize(QSize(18, 18)) self.button_uninstall.setLayoutDirection(Qt.RightToLeft) self.layout_buttons.addWidget(self.button_uninstall) self.button_uninstall.setMinimumSize(100, 30) self.button_uninstall.setProperty('class', 'Grapefruit') self.setCentralWidget(self.centralwidget) self.retranslateUi() QMetaObject.connectSlotsByName(self) def retranslateUi(self): QToolTip.setFont(self.font) self.setWindowTitle(QCoreApplication.translate("Title", "PyDebloatX")) self.label_info.setText(QCoreApplication.translate("Label", "")) self.app_name_list = list( ( # Convert tuple to list, because lupdate ignores initial lists QCoreApplication.translate("AppName", "3D Builder"), QCoreApplication.translate("AppName", "3D Viewer"), QCoreApplication.translate("AppName", "Alarms and Clock"), QCoreApplication.translate("AppName", "Calculator"), QCoreApplication.translate("AppName", "Calendar and Mail"), QCoreApplication.translate("AppName", "Camera"), QCoreApplication.translate("AppName", "Feedback Hub"), QCoreApplication.translate("AppName", "Get Help"), QCoreApplication.translate("AppName", "Groove Music"), QCoreApplication.translate("AppName", "Maps"), QCoreApplication.translate("AppName", "Messaging"), QCoreApplication.translate("AppName", "Mixed Reality Portal"), QCoreApplication.translate("AppName", "Mobile Plans"), QCoreApplication.translate("AppName", "Money"), QCoreApplication.translate("AppName", "Movies && TV"), QCoreApplication.translate("AppName", "News"), QCoreApplication.translate("AppName", "Office"), QCoreApplication.translate("AppName", "OneNote"), QCoreApplication.translate("AppName", "Paint 3D"), QCoreApplication.translate("AppName", "People"), QCoreApplication.translate("AppName", "Photos"), QCoreApplication.translate("AppName", "Print 3D"), QCoreApplication.translate("AppName", "Skype"), QCoreApplication.translate("AppName", "Snip && Sketch"), QCoreApplication.translate("AppName", "Solitaire"), QCoreApplication.translate("AppName", "Sports"), QCoreApplication.translate("AppName", "Spotify"), QCoreApplication.translate("AppName", "Sticky Notes"), QCoreApplication.translate("AppName", "Tips"), QCoreApplication.translate("AppName", "Translator"), QCoreApplication.translate("AppName", "Voice Recorder"), QCoreApplication.translate("AppName", "Weather"), QCoreApplication.translate("AppName", "Xbox"), QCoreApplication.translate("AppName", "Xbox Game Bar"), QCoreApplication.translate("AppName", "Your Phone"))) self.tooltip_list = list(( QCoreApplication.translate( "ToolTip", "View, create, and personalize 3D objects."), QCoreApplication.translate( "ToolTip", "View 3D models and animations in real-time."), QCoreApplication.translate( "ToolTip", "A combination of alarm clock, world clock, timer, and stopwatch." ), QCoreApplication.translate( "ToolTip", "A calculator that includes standard, scientific, and programmer modes, as well as a unit converter." ), QCoreApplication.translate( "ToolTip", "Stay up to date with email and schedule managing."), QCoreApplication.translate( "ToolTip", "Point and shoot to take pictures on Windows 10."), QCoreApplication.translate( "ToolTip", "Provide feedback about Windows and apps by sharing suggestions or problems." ), QCoreApplication.translate( "ToolTip", "Provide a way to ask a question and get recommended solutions or contact assisted support." ), QCoreApplication.translate( "ToolTip", "Listen to music on Windows, iOS, and Android devices."), QCoreApplication.translate( "ToolTip", "Search for places to get directions, business info, and reviews." ), QCoreApplication.translate( "ToolTip", "Quick, reliable SMS, MMS and RCS messaging from your phone."), QCoreApplication.translate( "ToolTip", "Discover Windows Mixed Reality and dive into more than 3,000 games and VR experiences from Steam VR and Microsoft Store." ), QCoreApplication.translate( "ToolTip", "Sign up for a data plan and connect with mobile operators in your area. You will need a supported SIM card." ), QCoreApplication.translate( "ToolTip", "Finance calculators, currency exchange rates and commodity prices from around the world." ), QCoreApplication.translate( "ToolTip", "All your movies and TV shows, all in one place, on all your devices." ), QCoreApplication.translate( "ToolTip", "Deliver breaking news and trusted, in-depth reporting from the world\'s best journalists." ), QCoreApplication.translate( "ToolTip", "Find all your Office apps and files in one place."), QCoreApplication.translate( "ToolTip", "Digital notebook for capturing and organizing everything across your devices." ), QCoreApplication.translate( "ToolTip", "Make 2D masterpieces or 3D models that you can play with from all angles." ), QCoreApplication.translate( "ToolTip", "Connect with all your friends, family, colleagues, and acquaintances in one place." ), QCoreApplication.translate( "ToolTip", "View and edit your photos and videos, make movies, and create albums." ), QCoreApplication.translate( "ToolTip", "Quickly and easily prepare objects for 3D printing on your PC." ), QCoreApplication.translate( "ToolTip", "Instant message, voice or video call application."), QCoreApplication.translate( "ToolTip", "Quickly annotate screenshots, photos and other images and save, paste or share with other apps." ), QCoreApplication.translate( "ToolTip", "Solitaire is one of the most played computer card games of all time." ), QCoreApplication.translate( "ToolTip", "Live scores and in-depth game experiences for more than 150 leagues." ), QCoreApplication.translate( "ToolTip", "Play your favorite songs and albums free on Windows 10 with Spotify." ), QCoreApplication.translate( "ToolTip", "Create notes, type, ink or add a picture, add text formatting, or stick them to the desktop." ), QCoreApplication.translate( "ToolTip", "Provide users with information and tips about operating system features." ), QCoreApplication.translate( "ToolTip", "Translate text and speech, have translated conversations, and even download AI-powered language packs to use offline." ), QCoreApplication.translate( "ToolTip", "Record sounds, lectures, interviews, and other events."), QCoreApplication.translate( "ToolTip", "Latest weather conditions, accurate 10-day and hourly forecasts." ), QCoreApplication.translate( "ToolTip", "Browse the catalogue, view recommendations, and discover PC games with Xbox Game Pass." ), QCoreApplication.translate( "ToolTip", "Instant access to widgets for screen capture and sharing, and chatting with Xbox friends." ), QCoreApplication.translate( "ToolTip", "Link your Android phone and PC to view and reply to text messages, access mobile apps, and receive notifications." ))) self.app_data_list = [{ "name": "*Microsoft.3DBuilder*", "link": "/?PFN=Microsoft.3DBuilder_8wekyb3d8bbwe", "size": 0 }, { "name": "*Microsoft.Microsoft3DViewer*", "link": "/?PFN=Microsoft.Microsoft3DViewer_8wekyb3d8bbwe", "size": 0 }, { "name": "*Microsoft.WindowsAlarms*", "link": "/?PFN=Microsoft.WindowsAlarms_8wekyb3d8bbwe", "size": 0 }, { "name": "*Microsoft.WindowsCalculator*", "link": "/?PFN=Microsoft.WindowsCalculator_8wekyb3d8bbwe", "size": 0 }, { "name": "*microsoft.windowscommunicationsapps*", "link": "/?PFN=Microsoft.windowscommunicationsapps_8wekyb3d8bbwe", "size": 0 }, { "name": "*Microsoft.WindowsCamera*", "link": "/?PFN=Microsoft.WindowsCamera_8wekyb3d8bbwe", "size": 0 }, { "name": "*Microsoft.WindowsFeedbackHub*", "link": "/?PFN=Microsoft.WindowsFeedbackHub_8wekyb3d8bbwe", "size": 0 }, { "name": "*Microsoft.GetHelp*", "link": "/?PFN=Microsoft.Gethelp_8wekyb3d8bbwe", "size": 0 }, { "name": "*Microsoft.ZuneMusic*", "link": "/?PFN=Microsoft.ZuneMusic_8wekyb3d8bbwe", "size": 0 }, { "name": "*Microsoft.WindowsMaps*", "link": "/?PFN=Microsoft.WindowsMaps_8wekyb3d8bbwe", "size": 0 }, { "name": "*Microsoft.Messaging*", "link": "/?PFN=Microsoft.Messaging_8wekyb3d8bbwe", "size": 0 }, { "name": "*Microsoft.MixedReality.Portal*", "link": "/?PFN=Microsoft.MixedReality.Portal_8wekyb3d8bbwe", "size": 0 }, { "name": "*Microsoft.OneConnect*", "link": "/?PFN=Microsoft.OneConnect_8wekyb3d8bbwe", "size": 0 }, { "name": "*Microsoft.BingFinance*", "link": "/?PFN=Microsoft.BingFinance_8wekyb3d8bbwe", "size": 0 }, { "name": "*Microsoft.ZuneVideo*", "link": "/?PFN=Microsoft.ZuneVideo_8wekyb3d8bbwe", "size": 0 }, { "name": "*Microsoft.BingNews*", "link": "/?PFN=Microsoft.BingNews_8wekyb3d8bbwe", "size": 0 }, { "name": "*Microsoft.MicrosoftOfficeHub*", "link": "/?PFN=Microsoft.MicrosoftOfficeHub_8wekyb3d8bbwe", "size": 0 }, { "name": "*Microsoft.Office.OneNote*", "link": "/?PFN=Microsoft.Office.OneNote_8wekyb3d8bbwe", "size": 0 }, { "name": "*Microsoft.MSPaint*", "link": "/?PFN=Microsoft.MSPaint_8wekyb3d8bbwe", "size": 0 }, { "name": "*Microsoft.People*", "link": "/?PFN=Microsoft.People_8wekyb3d8bbwe", "size": 0 }, { "name": "*Microsoft.Windows.Photos*", "link": "/?PFN=Microsoft.Windows.Photos_8wekyb3d8bbwe", "size": 0 }, { "name": "*Microsoft.Print3D*", "link": "/?PFN=Microsoft.Print3D_8wekyb3d8bbwe", "size": 0 }, { "name": "*Microsoft.SkypeApp*", "link": "/?PFN=Microsoft.SkypeApp_kzf8qxf38zg5c", "size": 0 }, { "name": "*Microsoft.ScreenSketch*", "link": "/?PFN=Microsoft.ScreenSketch_8wekyb3d8bbwe", "size": 0 }, { "name": "*Microsoft.MicrosoftSolitaireCollection*", "link": "/?PFN=Microsoft.MicrosoftSolitaireCollection_8wekyb3d8bbwe", "size": 0 }, { "name": "*Microsoft.BingSports*", "link": "/?PFN=Microsoft.BingSports_8wekyb3d8bbwe", "size": 0 }, { "name": "*SpotifyAB.SpotifyMusic*", "link": "/?PFN=SpotifyAB.SpotifyMusic_zpdnekdrzrea0", "size": 0 }, { "name": "*Microsoft.MicrosoftStickyNotes*", "link": "/?PFN=Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe", "size": 0 }, { "name": "*Microsoft.Getstarted*", "link": "/?PFN=Microsoft.Getstarted_8wekyb3d8bbwe", "size": 0 }, { "name": "*Microsoft.BingTranslator*", "link": "/?PFN=Microsoft.BingTranslator_8wekyb3d8bbwe", "size": 0 }, { "name": "*Microsoft.WindowsSoundRecorder*", "link": "/?PFN=Microsoft.WindowsSoundRecorder_8wekyb3d8bbwe", "size": 0 }, { "name": "*Microsoft.BingWeather*", "link": "/?PFN=Microsoft.BingWeather_8wekyb3d8bbwe", "size": 0 }, { "name": "*Microsoft.GamingApp*", "link": "/?PFN=Microsoft.GamingApp_8wekyb3d8bbwe", "size": 0 }, { "name": "*Xbox*", "link": "/?PFN=Microsoft.XboxGameOverlay_8wekyb3d8bbwe", "size": 0 }, { "name": "*Microsoft.YourPhone*", "link": "/?PFN=Microsoft.YourPhone_8wekyb3d8bbwe", "size": 0 }] if version.parse(platform.version()) >= version.parse("10.0.19041"): insort(self.app_name_list, QCoreApplication.translate("AppName", "Cortana")) cortana_index = self.app_name_list.index("Cortana") self.tooltip_list.insert( cortana_index, QCoreApplication.translate("ToolTip", "Personal intelligence assistant.")) self.app_data_list.insert( cortana_index, { "name": "*Microsoft.549981C3F5F10*", "link": "/?PFN=Microsoft.549981C3F5F10_8wekyb3d8bbwe", "size": 0 }) self.checkbox_list = [] for i, _ in enumerate(self.app_name_list): self.checkbox_list.append(QCheckBox()) if i % 3 == 2: self.layout_checkboxes_3.addWidget(self.checkbox_list[i]) elif i % 3 == 1: self.layout_checkboxes_2.addWidget(self.checkbox_list[i]) else: self.layout_checkboxes.addWidget(self.checkbox_list[i]) self.apps_dict = {} for i, checkbox in enumerate(self.checkbox_list): checkbox.setText(self.app_name_list[i]) checkbox.setToolTip(self.tooltip_list[i]) checkbox.setFont(self.font) self.apps_dict[checkbox] = self.app_data_list[i] self.label_space.setText( QCoreApplication.translate("Label", "Total amount of disk space:")) self.label_size.setText(QCoreApplication.translate("Label", "0 MB")) self.button_select_all.setText( QCoreApplication.translate("Button", "Select All")) self.button_deselect_all.setText( QCoreApplication.translate("Button", "Deselect All")) self.button_uninstall.setText( QCoreApplication.translate("Button", "Uninstall"))
class UIManipulateROIWindow: def setup_ui(self, manipulate_roi_window_instance, rois, dataset_rtss, roi_color, signal_roi_manipulated): self.patient_dict_container = PatientDictContainer() self.rois = rois self.dataset_rtss = dataset_rtss self.signal_roi_manipulated = signal_roi_manipulated self.roi_color = roi_color self.roi_names = [] # Names of selected ROIs self.all_roi_names = [] # Names of all existing ROIs for roi_id, roi_dict in self.rois.items(): self.all_roi_names.append(roi_dict['name']) # Operation names self.single_roi_operation_names = [ "Expand", "Contract", "Inner Rind (annulus)", "Outer Rind (annulus)" ] self.multiple_roi_operation_names = [ "Union", "Intersection", "Difference" ] self.operation_names = self.multiple_roi_operation_names + \ self.single_roi_operation_names self.new_ROI_contours = None self.manipulate_roi_window_instance = manipulate_roi_window_instance self.dicom_view = DicomAxialView(metadata_formatted=True, is_four_view=True) self.dicom_preview = DicomAxialView(metadata_formatted=True, is_four_view=True) self.dicom_view.slider.valueChanged.connect( self.dicom_view_slider_value_changed) self.dicom_preview.slider.valueChanged.connect( self.dicom_preview_slider_value_changed) self.init_layout() QtCore.QMetaObject.connectSlotsByName(manipulate_roi_window_instance) def retranslate_ui(self, manipulate_roi_window_instance): _translate = QtCore.QCoreApplication.translate manipulate_roi_window_instance.setWindowTitle( _translate("ManipulateRoiWindowInstance", "OnkoDICOM - Draw Region Of Interest")) self.first_roi_name_label.setText( _translate("FirstROINameLabel", "ROI 1: ")) self.first_roi_name_dropdown_list.setPlaceholderText("ROI 1") self.first_roi_name_dropdown_list.addItems(self.all_roi_names) self.operation_name_label.setText( _translate("OperationNameLabel", "Operation")) self.operation_name_dropdown_list.setPlaceholderText("Operation") self.operation_name_dropdown_list.addItems(self.operation_names) self.second_roi_name_label.setText( _translate("SecondROINameLabel", "ROI 2: ")) self.second_roi_name_dropdown_list.setPlaceholderText("ROI 2") self.second_roi_name_dropdown_list.addItems(self.all_roi_names) self.manipulate_roi_window_instance_draw_button.setText( _translate("ManipulateRoiWindowInstanceDrawButton", "Draw")) self.manipulate_roi_window_instance_save_button.setText( _translate("ManipulateRoiWindowInstanceSaveButton", "Save")) self.manipulate_roi_window_instance_cancel_button.setText( _translate("ManipulateRoiWindowInstanceCancelButton", "Cancel")) self.margin_label.setText(_translate("MarginLabel", "Margin (mm): ")) self.new_roi_name_label.setText( _translate("NewROINameLabel", "New ROI Name")) self.ROI_view_box_label.setText("ROI") self.preview_box_label.setText("Preview") 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 ManipulateROIWindow 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.manipulate_roi_window_instance.setObjectName( "ManipulateRoiWindowInstance") self.manipulate_roi_window_instance.setWindowIcon(window_icon) # Creating a form box to hold all buttons and input fields self.manipulate_roi_window_input_container_box = QFormLayout() self.manipulate_roi_window_input_container_box.setObjectName( "ManipulateRoiWindowInputContainerBox") self.manipulate_roi_window_input_container_box.setLabelAlignment( Qt.AlignLeft) # Create a label for denoting the first ROI name self.first_roi_name_label = QLabel() self.first_roi_name_label.setObjectName("FirstROINameLabel") self.first_roi_name_dropdown_list = QComboBox() # Create an dropdown list for ROI name self.first_roi_name_dropdown_list.setObjectName( "FirstROINameDropdownList") self.first_roi_name_dropdown_list.setSizePolicy( QSizePolicy.Minimum, QSizePolicy.Minimum) self.first_roi_name_dropdown_list.resize( self.first_roi_name_dropdown_list.sizeHint().width(), self.first_roi_name_dropdown_list.sizeHint().height()) self.first_roi_name_dropdown_list.activated.connect( self.update_selected_rois) self.manipulate_roi_window_input_container_box.addRow( self.first_roi_name_label, self.first_roi_name_dropdown_list) # Create a label for denoting the operation self.operation_name_label = QLabel() self.operation_name_label.setObjectName("OperationNameLabel") self.operation_name_dropdown_list = QComboBox() # Create an dropdown list for operation name self.operation_name_dropdown_list.setObjectName( "OperationNameDropdownList") self.operation_name_dropdown_list.setSizePolicy( QSizePolicy.Minimum, QSizePolicy.Minimum) self.operation_name_dropdown_list.resize( self.operation_name_dropdown_list.sizeHint().width(), self.operation_name_dropdown_list.sizeHint().height()) self.operation_name_dropdown_list.activated.connect( self.operation_changed) self.manipulate_roi_window_input_container_box.addRow( self.operation_name_label, self.operation_name_dropdown_list) # Create a label for denoting the second ROI name self.second_roi_name_label = QLabel() self.second_roi_name_label.setObjectName("SecondROINameLabel") self.second_roi_name_label.setVisible(False) self.second_roi_name_dropdown_list = QComboBox() # Create an dropdown list for ROI name self.second_roi_name_dropdown_list.setObjectName( "SecondROINameDropdownList") self.second_roi_name_dropdown_list.setSizePolicy( QSizePolicy.Minimum, QSizePolicy.Minimum) self.second_roi_name_dropdown_list.resize( self.second_roi_name_dropdown_list.sizeHint().width(), self.second_roi_name_dropdown_list.sizeHint().height()) self.second_roi_name_dropdown_list.setVisible(False) self.second_roi_name_dropdown_list.activated.connect( self.update_selected_rois) self.manipulate_roi_window_input_container_box.addRow( self.second_roi_name_label, self.second_roi_name_dropdown_list) # Create a label for denoting the margin self.margin_label = QLabel() self.margin_label.setObjectName("MarginLabel") self.margin_label.setVisible(False) # Create input for the new ROI name self.margin_line_edit = QLineEdit() self.margin_line_edit.setObjectName("MarginInput") self.margin_line_edit.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Minimum) self.margin_line_edit.resize(self.margin_line_edit.sizeHint().width(), self.margin_line_edit.sizeHint().height()) self.margin_line_edit.setVisible(False) self.margin_line_edit.setValidator( QRegularExpressionValidator( QRegularExpression("^[0-9]*[.]?[0-9]*$"))) self.manipulate_roi_window_input_container_box.addRow( self.margin_label, self.margin_line_edit) # Create a label for denoting the new ROI name self.new_roi_name_label = QLabel() self.new_roi_name_label.setObjectName("NewROINameLabel") # Create input for the new ROI name self.new_roi_name_line_edit = QLineEdit() self.new_roi_name_line_edit.setObjectName("NewROINameInput") self.new_roi_name_line_edit.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Minimum) self.new_roi_name_line_edit.resize( self.new_roi_name_line_edit.sizeHint().width(), self.new_roi_name_line_edit.sizeHint().height()) self.manipulate_roi_window_input_container_box.addRow( self.new_roi_name_label, self.new_roi_name_line_edit) # Create a spacer between inputs and buttons spacer = QWidget() spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) spacer.setFocusPolicy(Qt.NoFocus) self.manipulate_roi_window_input_container_box.addRow(spacer) # Create a warning message when missing inputs self.warning_message = QWidget() self.warning_message.setContentsMargins(8, 5, 8, 5) warning_message_layout = QHBoxLayout() warning_message_layout.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignLeft) warning_message_icon = QLabel() warning_message_icon.setPixmap( QtGui.QPixmap( resource_path("res/images/btn-icons/alert_icon.png"))) warning_message_layout.addWidget(warning_message_icon) self.warning_message_text = QLabel() self.warning_message_text.setStyleSheet("color: red") warning_message_layout.addWidget(self.warning_message_text) self.warning_message.setLayout(warning_message_layout) self.warning_message.setVisible(False) self.manipulate_roi_window_input_container_box.addRow( self.warning_message) # Create a draw button self.manipulate_roi_window_instance_draw_button = QPushButton() self.manipulate_roi_window_instance_draw_button.setObjectName( "ManipulateRoiWindowInstanceDrawButton") self.manipulate_roi_window_instance_draw_button.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Minimum)) self.manipulate_roi_window_instance_draw_button.resize( self.manipulate_roi_window_instance_draw_button.sizeHint().width(), self.manipulate_roi_window_instance_draw_button.sizeHint().height( )) self.manipulate_roi_window_instance_draw_button.setCursor( QtGui.QCursor(QtCore.Qt.PointingHandCursor)) self.manipulate_roi_window_instance_draw_button.clicked.connect( self.onDrawButtonClicked) self.manipulate_roi_window_input_container_box.addRow( self.manipulate_roi_window_instance_draw_button) # Create a horizontal box for saving and cancel the drawing self.manipulate_roi_window_cancel_save_box = QHBoxLayout() self.manipulate_roi_window_cancel_save_box.setObjectName( "ManipulateRoiWindowCancelSaveBox") # Create an exit button to cancel the drawing # Add a button to go back/exit from the application self.manipulate_roi_window_instance_cancel_button = QPushButton() self.manipulate_roi_window_instance_cancel_button.setObjectName( "ManipulateRoiWindowInstanceCancelButton") self.manipulate_roi_window_instance_cancel_button.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Minimum)) self.manipulate_roi_window_instance_cancel_button.resize( self.manipulate_roi_window_instance_cancel_button.sizeHint().width( ), self.manipulate_roi_window_instance_cancel_button.sizeHint(). height()) self.manipulate_roi_window_instance_cancel_button.setCursor( QtGui.QCursor(QtCore.Qt.PointingHandCursor)) self.manipulate_roi_window_instance_cancel_button.clicked.connect( self.onCancelButtonClicked) self.manipulate_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.manipulate_roi_window_instance_cancel_button.setIcon(icon_cancel) self.manipulate_roi_window_cancel_save_box.addWidget( self.manipulate_roi_window_instance_cancel_button) # Create a save button to save all the changes self.manipulate_roi_window_instance_save_button = QPushButton() self.manipulate_roi_window_instance_save_button.setObjectName( "ManipulateRoiWindowInstanceSaveButton") self.manipulate_roi_window_instance_save_button.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Minimum)) self.manipulate_roi_window_instance_save_button.resize( self.manipulate_roi_window_instance_save_button.sizeHint().width(), self.manipulate_roi_window_instance_save_button.sizeHint().height( )) self.manipulate_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.manipulate_roi_window_instance_save_button.setIcon(icon_save) self.manipulate_roi_window_instance_save_button.clicked.connect( self.onSaveClicked) self.manipulate_roi_window_cancel_save_box.addWidget( self.manipulate_roi_window_instance_save_button) self.manipulate_roi_window_input_container_box.addRow( self.manipulate_roi_window_cancel_save_box) # Creating a horizontal box to hold the ROI view and the preview self.manipulate_roi_window_instance_view_box = QHBoxLayout() self.manipulate_roi_window_instance_view_box.setObjectName( "ManipulateRoiWindowInstanceViewBoxes") # Font for the ROI view and preview's labels font = QFont() font.setBold(True) font.setPixelSize(20) # Creating the ROI view self.ROI_view_box_layout = QVBoxLayout() self.ROI_view_box_label = QLabel() self.ROI_view_box_label.setFont(font) self.ROI_view_box_label.setAlignment(Qt.AlignHCenter) self.ROI_view_box_layout.addWidget(self.ROI_view_box_label) self.ROI_view_box_layout.addWidget(self.dicom_view) self.ROI_view_box_widget = QWidget() self.ROI_view_box_widget.setLayout(self.ROI_view_box_layout) # Creating the preview self.preview_box_layout = QVBoxLayout() self.preview_box_label = QLabel() self.preview_box_label.setFont(font) self.preview_box_label.setAlignment(Qt.AlignHCenter) self.preview_box_layout.addWidget(self.preview_box_label) self.preview_box_layout.addWidget(self.dicom_preview) self.preview_box_widget = QWidget() self.preview_box_widget.setLayout(self.preview_box_layout) # Add View and Slider into horizontal box self.manipulate_roi_window_instance_view_box.addWidget( self.ROI_view_box_widget) self.manipulate_roi_window_instance_view_box.addWidget( self.preview_box_widget) # Create a widget to hold the image slice box self.manipulate_roi_window_instance_view_widget = QWidget() self.manipulate_roi_window_instance_view_widget.setObjectName( "ManipulateRoiWindowInstanceActionWidget") self.manipulate_roi_window_instance_view_widget.setLayout( self.manipulate_roi_window_instance_view_box) # Create a horizontal box for containing the input fields and the # viewports self.manipulate_roi_window_main_box = QHBoxLayout() self.manipulate_roi_window_main_box.setObjectName( "ManipulateRoiWindowMainBox") self.manipulate_roi_window_main_box.addLayout( self.manipulate_roi_window_input_container_box, 1) self.manipulate_roi_window_main_box.addWidget( self.manipulate_roi_window_instance_view_widget, 11) # Create a new central widget to hold the horizontal box layout self.manipulate_roi_window_instance_central_widget = QWidget() self.manipulate_roi_window_instance_central_widget.setObjectName( "ManipulateRoiWindowInstanceCentralWidget") self.manipulate_roi_window_instance_central_widget.setLayout( self.manipulate_roi_window_main_box) self.retranslate_ui(self.manipulate_roi_window_instance) self.manipulate_roi_window_instance.setStyleSheet(stylesheet) self.manipulate_roi_window_instance.setCentralWidget( self.manipulate_roi_window_instance_central_widget) QtCore.QMetaObject.connectSlotsByName( self.manipulate_roi_window_instance) def dicom_view_slider_value_changed(self): """ Display selected ROIs in dropbox when moving to another image slice """ self.display_selected_roi() if self.dicom_preview.slider.value() != self.dicom_view.slider.value(): self.dicom_preview.slider.setValue(self.dicom_view.slider.value()) def dicom_preview_slider_value_changed(self): """ Display generated ROI when moving to another image slice """ self.draw_roi() if self.dicom_preview.slider.value() != self.dicom_view.slider.value(): self.dicom_view.slider.setValue(self.dicom_preview.slider.value()) def onCancelButtonClicked(self): """ This function is used for canceling the drawing """ self.close() def onDrawButtonClicked(self): """ Function triggered when the Draw button is pressed from the menu. """ # Hide warning message self.warning_message.setVisible(False) # Check inputs selected_operation = self.operation_name_dropdown_list.currentText() roi_1 = self.first_roi_name_dropdown_list.currentText() roi_2 = self.second_roi_name_dropdown_list.currentText() new_roi_name = self.new_roi_name_line_edit.text() # Check the selected inputs and execute the operations if roi_1 != "" and new_roi_name != "" and \ self.margin_line_edit.text() != "" and \ selected_operation in self.single_roi_operation_names: # Single ROI operations dict_rois_contours = ROI.get_roi_contour_pixel( self.patient_dict_container.get("raw_contour"), [roi_1], self.patient_dict_container.get("pixluts")) roi_geometry = ROI.roi_to_geometry(dict_rois_contours[roi_1]) margin = float(self.margin_line_edit.text()) if selected_operation == self.single_roi_operation_names[0]: new_geometry = ROI.scale_roi(roi_geometry, margin) elif selected_operation == self.single_roi_operation_names[1]: new_geometry = ROI.scale_roi(roi_geometry, -margin) elif selected_operation == self.single_roi_operation_names[2]: new_geometry = ROI.rind_roi(roi_geometry, -margin) else: new_geometry = ROI.rind_roi(roi_geometry, margin) self.new_ROI_contours = ROI.geometry_to_roi(new_geometry) self.draw_roi() return True elif roi_1 != "" and roi_2 != "" and new_roi_name != "" and \ selected_operation in self.multiple_roi_operation_names: # Multiple ROI operations dict_rois_contours = ROI.get_roi_contour_pixel( self.patient_dict_container.get("raw_contour"), [roi_1, roi_2], self.patient_dict_container.get("pixluts")) roi_1_geometry = ROI.roi_to_geometry(dict_rois_contours[roi_1]) roi_2_geometry = ROI.roi_to_geometry(dict_rois_contours[roi_2]) # Execute the selected operation new_geometry = ROI.manipulate_rois(roi_1_geometry, roi_2_geometry, selected_operation.upper()) self.new_ROI_contours = ROI.geometry_to_roi(new_geometry) self.draw_roi() return True self.warning_message_text.setText("Not all values are specified.") self.warning_message.setVisible(True) return False def onSaveClicked(self): """ Save the new ROI """ # Get the name of the new ROI new_roi_name = self.new_roi_name_line_edit.text() # If the new ROI hasn't been drawn, draw the new ROI. Then if the new # ROI is drawn successfully, proceed to save the new ROI. if self.new_ROI_contours is None: if not self.onDrawButtonClicked(): return # Get a dict to convert SOPInstanceUID to slice id slice_ids_dict = get_dict_slice_to_uid(PatientDictContainer()) # Transform new_ROI_contours to a list of roi information rois_to_save = {} for uid, contour_sequence in self.new_ROI_contours.items(): slider_id = slice_ids_dict[uid] location = self.patient_dict_container.filepaths[slider_id] ds = pydicom.dcmread(location) slice_info = {'coords': contour_sequence, 'ds': ds} rois_to_save[slider_id] = slice_info roi_list = ROI.convert_hull_list_to_contours_data( rois_to_save, self.patient_dict_container) connectSaveROIProgress(self, roi_list, self.dataset_rtss, new_roi_name, self.roi_saved) def draw_roi(self): """ Draw the new ROI """ # Get the new ROI's name new_roi_name = self.new_roi_name_line_edit.text() # Check if the new ROI contour is None if self.new_ROI_contours is None: return # Get the info required to draw the new ROI slider_id = self.dicom_preview.slider.value() curr_slice = self.patient_dict_container.get("dict_uid")[slider_id] # Calculate the new ROI's polygon dict_ROI_contours = {} dict_ROI_contours[new_roi_name] = self.new_ROI_contours polygons = ROI.calc_roi_polygon(new_roi_name, curr_slice, dict_ROI_contours) # Set the new ROI color color = QtGui.QColor() color.setRgb(90, 250, 175, 200) pen_color = QtGui.QColor(color.red(), color.green(), color.blue()) pen = QtGui.QPen(pen_color) pen.setStyle(QtCore.Qt.PenStyle(1)) pen.setWidthF(2.0) # Draw the new ROI self.dicom_preview.update_view() for i in range(len(polygons)): self.dicom_preview.scene.addPolygon(polygons[i], pen, QtGui.QBrush(color)) def update_selected_rois(self): """ Get the names of selected ROIs """ # Hide warning message self.warning_message.setVisible(False) self.roi_names = [] if self.first_roi_name_dropdown_list.currentText() != "": self.roi_names.append( self.first_roi_name_dropdown_list.currentText()) if self.second_roi_name_dropdown_list.currentText() != "" and \ self.second_roi_name_dropdown_list.isVisible(): self.roi_names.append( self.second_roi_name_dropdown_list.currentText()) self.dict_rois_contours_axial = ROI.get_roi_contour_pixel( self.patient_dict_container.get("raw_contour"), self.roi_names, self.patient_dict_container.get("pixluts")) self.display_selected_roi() def display_selected_roi(self): """ Display selected ROIs """ # Get the info required to display the selected ROIs slider_id = self.dicom_view.slider.value() curr_slice = self.patient_dict_container.get("dict_uid")[slider_id] self.rois = self.patient_dict_container.get("rois") # Display the selected ROIs self.dicom_view.update_view() for roi_id, roi_dict in self.rois.items(): roi_name = roi_dict['name'] if roi_name in self.roi_names: polygons = ROI.calc_roi_polygon(roi_name, curr_slice, self.dict_rois_contours_axial) self.dicom_view.draw_roi_polygons(roi_id, polygons, self.roi_color) def operation_changed(self): """ Change the form when users select different operations """ # Hide warning message self.warning_message.setVisible(False) selected_operation = self.operation_name_dropdown_list.currentText() if selected_operation in self.single_roi_operation_names: self.second_roi_name_label.setVisible(False) self.second_roi_name_dropdown_list.setVisible(False) self.margin_label.setVisible(True) self.margin_line_edit.setVisible(True) self.update_selected_rois() else: self.second_roi_name_label.setVisible(True) self.second_roi_name_dropdown_list.setVisible(True) self.margin_label.setVisible(False) self.margin_line_edit.setVisible(False) self.update_selected_rois() def roi_saved(self, new_rtss): """ Create a new ROI in Structure Tab and notify user """ new_roi_name = self.new_roi_name_line_edit.text() self.signal_roi_manipulated.emit((new_rtss, {"draw": new_roi_name})) QMessageBox.about(self.manipulate_roi_window_instance, "Saved", "New contour successfully created!") self.close()
class ProgressWindow_Ui(QWidget): def __init__(self, persepolis_setting): super().__init__() self.persepolis_setting = persepolis_setting icons = ':/' + str(persepolis_setting.value('settings/icons')) + '/' # add support for other languages locale = str(self.persepolis_setting.value('settings/locale')) QLocale.setDefault(QLocale(locale)) self.translator = QTranslator() if self.translator.load(':/translations/locales/ui_' + locale, 'ts'): QCoreApplication.installTranslator(self.translator) # set ui direction ui_direction = self.persepolis_setting.value('ui_direction') if ui_direction == 'rtl': self.setLayoutDirection(Qt.RightToLeft) elif ui_direction in 'ltr': self.setLayoutDirection(Qt.LeftToRight) # window self.setMinimumSize(QSize(595, 284)) self.setWindowIcon( QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg'))) self.setWindowTitle( QCoreApplication.translate("progress_ui_tr", "Persepolis Download Manager")) verticalLayout = QVBoxLayout(self) # progress_tabWidget self.progress_tabWidget = QTabWidget(self) # information_tab self.information_tab = QWidget() information_verticalLayout = QVBoxLayout(self.information_tab) # link_label self.link_label = QLabel(self.information_tab) information_verticalLayout.addWidget(self.link_label) # status_label self.status_label = QLabel(self.information_tab) information_verticalLayout.addWidget(self.status_label) # downloaded_label self.downloaded_label = QLabel(self.information_tab) information_verticalLayout.addWidget(self.downloaded_label) # rate_label self.rate_label = QLabel(self.information_tab) information_verticalLayout.addWidget(self.rate_label) # time_label self.time_label = QLabel(self.information_tab) information_verticalLayout.addWidget(self.time_label) # connections_label self.connections_label = QLabel(self.information_tab) information_verticalLayout.addWidget(self.connections_label) information_verticalLayout.addStretch(1) # add information_tab to progress_tabWidget self.progress_tabWidget.addTab(self.information_tab, "") # options_tab self.options_tab = QWidget() options_tab_verticalLayout = QVBoxLayout(self.options_tab) options_tab_horizontalLayout = QHBoxLayout() # options_tab_horizontalLayout.setContentsMargins(11, 11, 11, 11) # limit_checkBox self.limit_checkBox = QCheckBox(self.options_tab) limit_verticalLayout = QVBoxLayout() limit_verticalLayout.addWidget(self.limit_checkBox) # limit_frame self.limit_frame = QFrame(self.options_tab) self.limit_frame.setFrameShape(QFrame.StyledPanel) self.limit_frame.setFrameShadow(QFrame.Raised) limit_frame_verticalLayout = QVBoxLayout(self.limit_frame) limit_frame_horizontalLayout = QHBoxLayout() # limit_spinBox self.limit_spinBox = QDoubleSpinBox(self.options_tab) self.limit_spinBox.setMinimum(1) self.limit_spinBox.setMaximum(1023) limit_frame_horizontalLayout.addWidget(self.limit_spinBox) # limit_comboBox self.limit_comboBox = QComboBox(self.options_tab) self.limit_comboBox.addItem("") self.limit_comboBox.addItem("") limit_frame_horizontalLayout.addWidget(self.limit_comboBox) # limit_pushButton self.limit_pushButton = QPushButton(self.options_tab) limit_frame_verticalLayout.addLayout(limit_frame_horizontalLayout) limit_frame_verticalLayout.addWidget(self.limit_pushButton) limit_verticalLayout.addWidget(self.limit_frame) limit_verticalLayout.setContentsMargins(11, 11, 11, 11) options_tab_horizontalLayout.addLayout(limit_verticalLayout) options_tab_verticalLayout.addLayout(options_tab_horizontalLayout) options_tab_verticalLayout.addStretch(1) # after_checkBox self.after_checkBox = QCheckBox(self.options_tab) after_verticalLayout = QVBoxLayout() after_verticalLayout.addWidget(self.after_checkBox) # after_frame self.after_frame = QFrame(self.options_tab) self.after_frame.setFrameShape(QFrame.StyledPanel) self.after_frame.setFrameShadow(QFrame.Raised) after_frame_verticalLayout = QVBoxLayout(self.after_frame) # after_comboBox self.after_comboBox = QComboBox(self.options_tab) self.after_comboBox.addItem("") after_frame_verticalLayout.addWidget(self.after_comboBox) # after_pushButton self.after_pushButton = QPushButton(self.options_tab) after_frame_verticalLayout.addWidget(self.after_pushButton) after_verticalLayout.addWidget(self.after_frame) after_verticalLayout.setContentsMargins(11, 11, 11, 11) options_tab_horizontalLayout.addLayout(after_verticalLayout) self.progress_tabWidget.addTab(self.options_tab, "") verticalLayout.addWidget(self.progress_tabWidget) # download_progressBar self.download_progressBar = QProgressBar(self) verticalLayout.addWidget(self.download_progressBar) self.download_progressBar.setTextVisible(False) # buttons button_horizontalLayout = QHBoxLayout() button_horizontalLayout.addStretch(1) # resume_pushButton self.resume_pushButton = QPushButton(self) self.resume_pushButton.setIcon(QIcon(icons + 'play')) button_horizontalLayout.addWidget(self.resume_pushButton) # pause_pushButton self.pause_pushButton = QPushButton(self) self.pause_pushButton.setIcon(QIcon(icons + 'pause')) button_horizontalLayout.addWidget(self.pause_pushButton) # stop_pushButton self.stop_pushButton = QPushButton(self) self.stop_pushButton.setIcon(QIcon(icons + 'stop')) button_horizontalLayout.addWidget(self.stop_pushButton) verticalLayout.addLayout(button_horizontalLayout) self.progress_tabWidget.setCurrentIndex(0) # labels self.link_label.setText( QCoreApplication.translate("progress_ui_tr", "Link: ")) self.status_label.setText( QCoreApplication.translate("progress_ui_tr", "Status: ")) self.downloaded_label.setText( QCoreApplication.translate("progress_ui_tr", "Downloaded:")) self.rate_label.setText( QCoreApplication.translate("progress_ui_tr", "Transfer rate: ")) self.time_label.setText( QCoreApplication.translate("progress_ui_tr", "Estimated time left:")) self.connections_label.setText( QCoreApplication.translate("progress_ui_tr", "Number of connections: ")) self.progress_tabWidget.setTabText( self.progress_tabWidget.indexOf(self.information_tab), QCoreApplication.translate("progress_ui_tr", "Download Information")) self.limit_checkBox.setText( QCoreApplication.translate("progress_ui_tr", "Limit speed")) self.after_checkBox.setText( QCoreApplication.translate("progress_ui_tr", "After download")) self.limit_comboBox.setItemText(0, "KiB/s") self.limit_comboBox.setItemText(1, "MiB/s") self.limit_pushButton.setText( QCoreApplication.translate("progress_ui_tr", "Apply")) self.after_comboBox.setItemText( 0, QCoreApplication.translate("progress_ui_tr", "Shut Down")) self.progress_tabWidget.setTabText( self.progress_tabWidget.indexOf(self.options_tab), QCoreApplication.translate("progress_ui_tr", "Download Options")) self.resume_pushButton.setText( QCoreApplication.translate("progress_ui_tr", "Resume")) self.pause_pushButton.setText( QCoreApplication.translate("progress_ui_tr", "Pause")) self.stop_pushButton.setText( QCoreApplication.translate("progress_ui_tr", "Stop")) self.after_pushButton.setText( QCoreApplication.translate("progress_ui_tr", "Apply"))
class Setting_Ui(QWidget): def __init__(self, persepolis_setting): super().__init__() icon = QIcon() self.persepolis_setting = persepolis_setting # add support for other languages locale = str(self.persepolis_setting.value('settings/locale')) QLocale.setDefault(QLocale(locale)) self.translator = QTranslator() if self.translator.load(':/translations/locales/ui_' + locale, 'ts'): QCoreApplication.installTranslator(self.translator) self.setWindowIcon( QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg'))) self.setWindowTitle( QCoreApplication.translate("setting_ui_tr", 'Preferences')) # set ui direction ui_direction = self.persepolis_setting.value('ui_direction') if ui_direction == 'rtl': self.setLayoutDirection(Qt.RightToLeft) elif ui_direction in 'ltr': self.setLayoutDirection(Qt.LeftToRight) global icons icons = ':/' + str( self.persepolis_setting.value('settings/icons')) + '/' # main layout window_verticalLayout = QVBoxLayout(self) # setting_tabWidget self.setting_tabWidget = QTabWidget(self) # download_options_tab self.download_options_tab = QWidget() download_options_tab_verticalLayout = QVBoxLayout( self.download_options_tab) download_options_tab_verticalLayout.setContentsMargins(21, 21, 0, 0) # tries tries_horizontalLayout = QHBoxLayout() self.tries_label = QLabel(self.download_options_tab) tries_horizontalLayout.addWidget(self.tries_label) self.tries_spinBox = QSpinBox(self.download_options_tab) self.tries_spinBox.setMinimum(1) tries_horizontalLayout.addWidget(self.tries_spinBox) download_options_tab_verticalLayout.addLayout(tries_horizontalLayout) # wait wait_horizontalLayout = QHBoxLayout() self.wait_label = QLabel(self.download_options_tab) wait_horizontalLayout.addWidget(self.wait_label) self.wait_spinBox = QSpinBox(self.download_options_tab) wait_horizontalLayout.addWidget(self.wait_spinBox) download_options_tab_verticalLayout.addLayout(wait_horizontalLayout) # time_out time_out_horizontalLayout = QHBoxLayout() self.time_out_label = QLabel(self.download_options_tab) time_out_horizontalLayout.addWidget(self.time_out_label) self.time_out_spinBox = QSpinBox(self.download_options_tab) time_out_horizontalLayout.addWidget(self.time_out_spinBox) download_options_tab_verticalLayout.addLayout( time_out_horizontalLayout) # connections connections_horizontalLayout = QHBoxLayout() self.connections_label = QLabel(self.download_options_tab) connections_horizontalLayout.addWidget(self.connections_label) self.connections_spinBox = QSpinBox(self.download_options_tab) self.connections_spinBox.setMinimum(1) self.connections_spinBox.setMaximum(16) connections_horizontalLayout.addWidget(self.connections_spinBox) download_options_tab_verticalLayout.addLayout( connections_horizontalLayout) # rpc_port self.rpc_port_label = QLabel(self.download_options_tab) self.rpc_horizontalLayout = QHBoxLayout() self.rpc_horizontalLayout.addWidget(self.rpc_port_label) self.rpc_port_spinbox = QSpinBox(self.download_options_tab) self.rpc_port_spinbox.setMinimum(1024) self.rpc_port_spinbox.setMaximum(65535) self.rpc_horizontalLayout.addWidget(self.rpc_port_spinbox) download_options_tab_verticalLayout.addLayout( self.rpc_horizontalLayout) # wait_queue wait_queue_horizontalLayout = QHBoxLayout() self.wait_queue_label = QLabel(self.download_options_tab) wait_queue_horizontalLayout.addWidget(self.wait_queue_label) self.wait_queue_time = MyQDateTimeEdit(self.download_options_tab) self.wait_queue_time.setDisplayFormat('H:mm') wait_queue_horizontalLayout.addWidget(self.wait_queue_time) download_options_tab_verticalLayout.addLayout( wait_queue_horizontalLayout) # don't check certificate checkBox self.dont_check_certificate_checkBox = QCheckBox( self.download_options_tab) download_options_tab_verticalLayout.addWidget( self.dont_check_certificate_checkBox) # change aria2 path aria2_path_verticalLayout = QVBoxLayout() self.aria2_path_checkBox = QCheckBox(self.download_options_tab) aria2_path_verticalLayout.addWidget(self.aria2_path_checkBox) aria2_path_horizontalLayout = QHBoxLayout() self.aria2_path_lineEdit = QLineEdit(self.download_options_tab) aria2_path_horizontalLayout.addWidget(self.aria2_path_lineEdit) self.aria2_path_pushButton = QPushButton(self.download_options_tab) aria2_path_horizontalLayout.addWidget(self.aria2_path_pushButton) aria2_path_verticalLayout.addLayout(aria2_path_horizontalLayout) download_options_tab_verticalLayout.addLayout( aria2_path_verticalLayout) download_options_tab_verticalLayout.addStretch(1) self.setting_tabWidget.addTab(self.download_options_tab, "") # save_as_tab self.save_as_tab = QWidget() save_as_tab_verticalLayout = QVBoxLayout(self.save_as_tab) save_as_tab_verticalLayout.setContentsMargins(20, 30, 0, 0) # download_folder self.download_folder_horizontalLayout = QHBoxLayout() self.download_folder_label = QLabel(self.save_as_tab) self.download_folder_horizontalLayout.addWidget( self.download_folder_label) self.download_folder_lineEdit = QLineEdit(self.save_as_tab) self.download_folder_horizontalLayout.addWidget( self.download_folder_lineEdit) self.download_folder_pushButton = QPushButton(self.save_as_tab) self.download_folder_horizontalLayout.addWidget( self.download_folder_pushButton) save_as_tab_verticalLayout.addLayout( self.download_folder_horizontalLayout) # temp_download_folder self.temp_horizontalLayout = QHBoxLayout() self.temp_download_label = QLabel(self.save_as_tab) self.temp_horizontalLayout.addWidget(self.temp_download_label) self.temp_download_lineEdit = QLineEdit(self.save_as_tab) self.temp_horizontalLayout.addWidget(self.temp_download_lineEdit) self.temp_download_pushButton = QPushButton(self.save_as_tab) self.temp_horizontalLayout.addWidget(self.temp_download_pushButton) save_as_tab_verticalLayout.addLayout(self.temp_horizontalLayout) # create subfolder self.subfolder_checkBox = QCheckBox(self.save_as_tab) save_as_tab_verticalLayout.addWidget(self.subfolder_checkBox) save_as_tab_verticalLayout.addStretch(1) self.setting_tabWidget.addTab(self.save_as_tab, "") # notifications_tab self.notifications_tab = QWidget() notification_tab_verticalLayout = QVBoxLayout(self.notifications_tab) notification_tab_verticalLayout.setContentsMargins(21, 21, 0, 0) self.enable_notifications_checkBox = QCheckBox(self.notifications_tab) notification_tab_verticalLayout.addWidget( self.enable_notifications_checkBox) self.sound_frame = QFrame(self.notifications_tab) self.sound_frame.setFrameShape(QFrame.StyledPanel) self.sound_frame.setFrameShadow(QFrame.Raised) verticalLayout = QVBoxLayout(self.sound_frame) self.volume_label = QLabel(self.sound_frame) verticalLayout.addWidget(self.volume_label) self.volume_dial = QDial(self.sound_frame) self.volume_dial.setProperty("value", 100) verticalLayout.addWidget(self.volume_dial) notification_tab_verticalLayout.addWidget(self.sound_frame) # message_notification message_notification_horizontalLayout = QHBoxLayout() self.notification_label = QLabel(self.notifications_tab) message_notification_horizontalLayout.addWidget( self.notification_label) self.notification_comboBox = QComboBox(self.notifications_tab) message_notification_horizontalLayout.addWidget( self.notification_comboBox) notification_tab_verticalLayout.addLayout( message_notification_horizontalLayout) notification_tab_verticalLayout.addStretch(1) self.setting_tabWidget.addTab(self.notifications_tab, "") # style_tab self.style_tab = QWidget() style_tab_verticalLayout = QVBoxLayout(self.style_tab) style_tab_verticalLayout.setContentsMargins(21, 21, 0, 0) # style style_horizontalLayout = QHBoxLayout() self.style_label = QLabel(self.style_tab) style_horizontalLayout.addWidget(self.style_label) self.style_comboBox = QComboBox(self.style_tab) style_horizontalLayout.addWidget(self.style_comboBox) style_tab_verticalLayout.addLayout(style_horizontalLayout) # language language_horizontalLayout = QHBoxLayout() self.lang_label = QLabel(self.style_tab) language_horizontalLayout.addWidget(self.lang_label) self.lang_comboBox = QComboBox(self.style_tab) language_horizontalLayout.addWidget(self.lang_comboBox) style_tab_verticalLayout.addLayout(language_horizontalLayout) language_horizontalLayout = QHBoxLayout() self.lang_label.setText( QCoreApplication.translate("setting_ui_tr", "Language: ")) # color scheme self.color_label = QLabel(self.style_tab) language_horizontalLayout.addWidget(self.color_label) self.color_comboBox = QComboBox(self.style_tab) language_horizontalLayout.addWidget(self.color_comboBox) style_tab_verticalLayout.addLayout(language_horizontalLayout) # icons icons_horizontalLayout = QHBoxLayout() self.icon_label = QLabel(self.style_tab) icons_horizontalLayout.addWidget(self.icon_label) self.icon_comboBox = QComboBox(self.style_tab) icons_horizontalLayout.addWidget(self.icon_comboBox) style_tab_verticalLayout.addLayout(icons_horizontalLayout) self.icons_size_horizontalLayout = QHBoxLayout() self.icons_size_label = QLabel(self.style_tab) self.icons_size_horizontalLayout.addWidget(self.icons_size_label) self.icons_size_comboBox = QComboBox(self.style_tab) self.icons_size_horizontalLayout.addWidget(self.icons_size_comboBox) style_tab_verticalLayout.addLayout(self.icons_size_horizontalLayout) # font font_horizontalLayout = QHBoxLayout() self.font_checkBox = QCheckBox(self.style_tab) font_horizontalLayout.addWidget(self.font_checkBox) self.fontComboBox = QFontComboBox(self.style_tab) font_horizontalLayout.addWidget(self.fontComboBox) self.font_size_label = QLabel(self.style_tab) font_horizontalLayout.addWidget(self.font_size_label) self.font_size_spinBox = QSpinBox(self.style_tab) self.font_size_spinBox.setMinimum(1) font_horizontalLayout.addWidget(self.font_size_spinBox) style_tab_verticalLayout.addLayout(font_horizontalLayout) self.setting_tabWidget.addTab(self.style_tab, "") window_verticalLayout.addWidget(self.setting_tabWidget) # start persepolis in system tray if browser executed self.start_persepolis_if_browser_executed_checkBox = QCheckBox( self.style_tab) style_tab_verticalLayout.addWidget( self.start_persepolis_if_browser_executed_checkBox) # hide window if close button clicked self.hide_window_checkBox = QCheckBox(self.style_tab) style_tab_verticalLayout.addWidget(self.hide_window_checkBox) # Enable system tray icon self.enable_system_tray_checkBox = QCheckBox(self.style_tab) style_tab_verticalLayout.addWidget(self.enable_system_tray_checkBox) # after_download dialog self.after_download_checkBox = QCheckBox() style_tab_verticalLayout.addWidget(self.after_download_checkBox) # show_menubar_checkbox self.show_menubar_checkbox = QCheckBox() style_tab_verticalLayout.addWidget(self.show_menubar_checkbox) # show_sidepanel_checkbox self.show_sidepanel_checkbox = QCheckBox() style_tab_verticalLayout.addWidget(self.show_sidepanel_checkbox) # hide progress window self.show_progress_window_checkbox = QCheckBox() style_tab_verticalLayout.addWidget(self.show_progress_window_checkbox) # add persepolis to startup self.startup_checkbox = QCheckBox() style_tab_verticalLayout.addWidget(self.startup_checkbox) # keep system awake self.keep_awake_checkBox = QCheckBox() style_tab_verticalLayout.addWidget(self.keep_awake_checkBox) style_tab_verticalLayout.addStretch(1) # columns_tab self.columns_tab = QWidget() columns_tab_verticalLayout = QVBoxLayout(self.columns_tab) columns_tab_verticalLayout.setContentsMargins(21, 21, 0, 0) # creating checkBox for columns self.show_column_label = QLabel() self.column0_checkBox = QCheckBox() self.column1_checkBox = QCheckBox() self.column2_checkBox = QCheckBox() self.column3_checkBox = QCheckBox() self.column4_checkBox = QCheckBox() self.column5_checkBox = QCheckBox() self.column6_checkBox = QCheckBox() self.column7_checkBox = QCheckBox() self.column10_checkBox = QCheckBox() self.column11_checkBox = QCheckBox() self.column12_checkBox = QCheckBox() columns_tab_verticalLayout.addWidget(self.show_column_label) columns_tab_verticalLayout.addWidget(self.column0_checkBox) columns_tab_verticalLayout.addWidget(self.column1_checkBox) columns_tab_verticalLayout.addWidget(self.column2_checkBox) columns_tab_verticalLayout.addWidget(self.column3_checkBox) columns_tab_verticalLayout.addWidget(self.column4_checkBox) columns_tab_verticalLayout.addWidget(self.column5_checkBox) columns_tab_verticalLayout.addWidget(self.column6_checkBox) columns_tab_verticalLayout.addWidget(self.column7_checkBox) columns_tab_verticalLayout.addWidget(self.column10_checkBox) columns_tab_verticalLayout.addWidget(self.column11_checkBox) columns_tab_verticalLayout.addWidget(self.column12_checkBox) columns_tab_verticalLayout.addStretch(1) self.setting_tabWidget.addTab(self.columns_tab, '') # video_finder_tab self.video_finder_tab = QWidget() video_finder_layout = QVBoxLayout(self.video_finder_tab) video_finder_layout.setContentsMargins(21, 21, 0, 0) video_finder_tab_verticalLayout = QVBoxLayout() max_links_horizontalLayout = QHBoxLayout() # max_links_label self.max_links_label = QLabel(self.video_finder_tab) max_links_horizontalLayout.addWidget(self.max_links_label) # max_links_spinBox self.max_links_spinBox = QSpinBox(self.video_finder_tab) self.max_links_spinBox.setMinimum(1) self.max_links_spinBox.setMaximum(16) max_links_horizontalLayout.addWidget(self.max_links_spinBox) video_finder_tab_verticalLayout.addLayout(max_links_horizontalLayout) self.video_finder_dl_path_horizontalLayout = QHBoxLayout() self.video_finder_frame = QFrame(self.video_finder_tab) self.video_finder_frame.setLayout(video_finder_tab_verticalLayout) video_finder_tab_verticalLayout.addStretch(1) video_finder_layout.addWidget(self.video_finder_frame) self.setting_tabWidget.addTab(self.video_finder_tab, "") # shortcut tab self.shortcut_tab = QWidget() shortcut_tab_verticalLayout = QVBoxLayout(self.shortcut_tab) shortcut_tab_verticalLayout.setContentsMargins(21, 21, 0, 0) # shortcut_table self.shortcut_table = QTableWidget(self) self.shortcut_table.setColumnCount(2) self.shortcut_table.setSelectionBehavior(QAbstractItemView.SelectRows) self.shortcut_table.setSelectionMode(QAbstractItemView.SingleSelection) self.shortcut_table.setEditTriggers(QAbstractItemView.NoEditTriggers) self.shortcut_table.verticalHeader().hide() shortcut_table_header = [ QCoreApplication.translate("setting_ui_tr", 'Action'), QCoreApplication.translate("setting_ui_tr", 'Shortcut') ] self.shortcut_table.setHorizontalHeaderLabels(shortcut_table_header) shortcut_tab_verticalLayout.addWidget(self.shortcut_table) self.setting_tabWidget.addTab( self.shortcut_tab, QCoreApplication.translate("setting_ui_tr", "Shortcuts")) # Actions actions_list = [ QCoreApplication.translate('setting_ui_tr', 'Quit'), QCoreApplication.translate('setting_ui_tr', 'Minimize to System Tray'), QCoreApplication.translate('setting_ui_tr', 'Remove Download Items'), QCoreApplication.translate('setting_ui_tr', 'Delete Download Items'), QCoreApplication.translate('setting_ui_tr', 'Move Selected Items Up'), QCoreApplication.translate('setting_ui_tr', 'Move Selected Items Down'), QCoreApplication.translate('setting_ui_tr', 'Add New Download Link'), QCoreApplication.translate('setting_ui_tr', 'Add New Video Link'), QCoreApplication.translate('setting_ui_tr', 'Import Links from Text File') ] # add actions to the shortcut_table j = 0 for action in actions_list: item = QTableWidgetItem(str(action)) # align center item.setTextAlignment(0x0004 | 0x0080) # insert item in shortcut_table self.shortcut_table.insertRow(j) self.shortcut_table.setItem(j, 0, item) j = j + 1 self.shortcut_table.resizeColumnsToContents() # window buttons buttons_horizontalLayout = QHBoxLayout() buttons_horizontalLayout.addStretch(1) self.defaults_pushButton = QPushButton(self) buttons_horizontalLayout.addWidget(self.defaults_pushButton) self.cancel_pushButton = QPushButton(self) self.cancel_pushButton.setIcon(QIcon(icons + 'remove')) buttons_horizontalLayout.addWidget(self.cancel_pushButton) self.ok_pushButton = QPushButton(self) self.ok_pushButton.setIcon(QIcon(icons + 'ok')) buttons_horizontalLayout.addWidget(self.ok_pushButton) window_verticalLayout.addLayout(buttons_horizontalLayout) # set style_tab for default self.setting_tabWidget.setCurrentIndex(3) # labels and translations self.setWindowTitle( QCoreApplication.translate("setting_ui_tr", "Preferences")) self.tries_label.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>Set number of tries if download failed.</p></body></html>" )) self.tries_label.setText( QCoreApplication.translate("setting_ui_tr", "Number of tries: ")) self.tries_spinBox.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>Set number of tries if download failed.</p></body></html>" )) self.wait_label.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>Set the seconds to wait between retries. Download manager will retry downloads when the HTTP server returns a 503 response.</p></body></html>" )) self.wait_label.setText( QCoreApplication.translate( "setting_ui_tr", "Wait period between retries (seconds): ")) self.wait_spinBox.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>Set the seconds to wait between retries. Download manager will retry downloads when the HTTP server returns a 503 response.</p></body></html>" )) self.time_out_label.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>Set timeout in seconds. </p></body></html>" )) self.time_out_label.setText( QCoreApplication.translate("setting_ui_tr", "Timeout (seconds): ")) self.time_out_spinBox.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>Set timeout in seconds. </p></body></html>" )) self.connections_label.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>Using multiple connections can help speed up your download.</p></body></html>" )) self.connections_label.setText( QCoreApplication.translate("setting_ui_tr", "Number of connections: ")) self.connections_spinBox.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>Using multiple connections can help speed up your download.</p></body></html>" )) self.rpc_port_label.setText( QCoreApplication.translate("setting_ui_tr", "RPC port number: ")) self.rpc_port_spinbox.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p> Specify a port number for JSON-RPC/XML-RPC server to listen to. Possible Values: 1024 - 65535 Default: 6801 </p></body></html>" )) self.wait_queue_label.setText( QCoreApplication.translate( "setting_ui_tr", 'Wait period between each download in queue:')) self.dont_check_certificate_checkBox.setText( QCoreApplication.translate( "setting_ui_tr", "Don't use certificate to verify the peers")) self.dont_check_certificate_checkBox.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>This option avoids SSL/TLS handshake failure. But use it at your own risk!</p></body></html>" )) self.aria2_path_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'Change Aria2 default path')) self.aria2_path_pushButton.setText( QCoreApplication.translate("setting_ui_tr", 'Change')) aria2_path_tooltip = QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>Attention: Wrong path may cause problems! Do it carefully or don't change default setting!</p></body></html>" ) self.aria2_path_checkBox.setToolTip(aria2_path_tooltip) self.aria2_path_lineEdit.setToolTip(aria2_path_tooltip) self.aria2_path_pushButton.setToolTip(aria2_path_tooltip) self.setting_tabWidget.setTabText( self.setting_tabWidget.indexOf(self.download_options_tab), QCoreApplication.translate("setting_ui_tr", "Download Options")) self.download_folder_label.setText( QCoreApplication.translate("setting_ui_tr", "Download folder: ")) self.download_folder_pushButton.setText( QCoreApplication.translate("setting_ui_tr", "Change")) self.temp_download_label.setText( QCoreApplication.translate("setting_ui_tr", "Temporary download folder: ")) self.temp_download_pushButton.setText( QCoreApplication.translate("setting_ui_tr", "Change")) self.subfolder_checkBox.setText( QCoreApplication.translate( "setting_ui_tr", "Create subfolders for Music,Videos, ... in default download folder" )) self.setting_tabWidget.setTabText( self.setting_tabWidget.indexOf(self.save_as_tab), QCoreApplication.translate("setting_ui_tr", "Save As")) self.enable_notifications_checkBox.setText( QCoreApplication.translate("setting_ui_tr", "Enable Notification Sounds")) self.volume_label.setText( QCoreApplication.translate("setting_ui_tr", "Volume: ")) self.setting_tabWidget.setTabText( self.setting_tabWidget.indexOf(self.notifications_tab), QCoreApplication.translate("setting_ui_tr", "Notifications")) self.style_label.setText( QCoreApplication.translate("setting_ui_tr", "Style: ")) self.color_label.setText( QCoreApplication.translate("setting_ui_tr", "Color scheme: ")) self.icon_label.setText( QCoreApplication.translate("setting_ui_tr", "Icons: ")) self.icons_size_label.setText( QCoreApplication.translate("setting_ui_tr", "Toolbar icons size: ")) self.notification_label.setText( QCoreApplication.translate("setting_ui_tr", "Notification type: ")) self.font_checkBox.setText( QCoreApplication.translate("setting_ui_tr", "Font: ")) self.font_size_label.setText( QCoreApplication.translate("setting_ui_tr", "Size: ")) self.hide_window_checkBox.setText( QCoreApplication.translate( "setting_ui_tr", "Hide main window if close button clicked.")) self.hide_window_checkBox.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>This feature may not work in your operating system.</p></body></html>" )) self.start_persepolis_if_browser_executed_checkBox.setText( QCoreApplication.translate( 'setting_ui_tr', 'If browser is opened, start Persepolis in system tray')) self.enable_system_tray_checkBox.setText( QCoreApplication.translate("setting_ui_tr", "Enable system tray icon")) self.after_download_checkBox.setText( QCoreApplication.translate( "setting_ui_tr", "Show download complete dialog when download is finished")) self.show_menubar_checkbox.setText( QCoreApplication.translate("setting_ui_tr", "Show menubar")) self.show_sidepanel_checkbox.setText( QCoreApplication.translate("setting_ui_tr", "Show side panel")) self.show_progress_window_checkbox.setText( QCoreApplication.translate("setting_ui_tr", "Show download progress window")) self.startup_checkbox.setText( QCoreApplication.translate("setting_ui_tr", "Run Persepolis at startup")) self.keep_awake_checkBox.setText( QCoreApplication.translate("setting_ui_tr", "Keep system awake!")) self.keep_awake_checkBox.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>This option will prevent the system from going to sleep.\ It is necessary if your power manager is suspending the system automatically. </p></body></html>" )) self.wait_queue_time.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>Format HH:MM</p></body></html>")) self.setting_tabWidget.setTabText( self.setting_tabWidget.indexOf(self.style_tab), QCoreApplication.translate("setting_ui_tr", "Preferences")) # columns_tab self.show_column_label.setText( QCoreApplication.translate("setting_ui_tr", 'Show these columns:')) self.column0_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'File Name')) self.column1_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'Status')) self.column2_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'Size')) self.column3_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'Downloaded')) self.column4_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'Percentage')) self.column5_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'Connections')) self.column6_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'Transfer Rate')) self.column7_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'Estimated Time Left')) self.column10_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'First Try Date')) self.column11_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'Last Try Date')) self.column12_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'Category')) self.setting_tabWidget.setTabText( self.setting_tabWidget.indexOf(self.columns_tab), QCoreApplication.translate("setting_ui_tr", "Columns Customization")) # Video Finder options tab self.setting_tabWidget.setTabText( self.setting_tabWidget.indexOf(self.video_finder_tab), QCoreApplication.translate("setting_ui_tr", "Video Finder Options")) self.max_links_label.setText( QCoreApplication.translate( "setting_ui_tr", 'Maximum number of links to capture:<br/>' '<small>(If browser sends multiple video links at a time)</small>' )) # window buttons self.defaults_pushButton.setText( QCoreApplication.translate("setting_ui_tr", "Defaults")) self.cancel_pushButton.setText( QCoreApplication.translate("setting_ui_tr", "Cancel")) self.ok_pushButton.setText( QCoreApplication.translate("setting_ui_tr", "OK"))
class KeyCapturingWindow_Ui(QWidget): def __init__(self, persepolis_setting): super().__init__() icon = QIcon() self.persepolis_setting = persepolis_setting # add support for other languages locale = str(self.persepolis_setting.value('settings/locale')) QLocale.setDefault(QLocale(locale)) self.translator = QTranslator() if self.translator.load(':/translations/locales/ui_' + locale, 'ts'): QCoreApplication.installTranslator(self.translator) self.setWindowIcon( QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg'))) self.setWindowTitle( QCoreApplication.translate("setting_ui_tr", 'Preferences')) # set ui direction ui_direction = self.persepolis_setting.value('ui_direction') if ui_direction == 'rtl': self.setLayoutDirection(Qt.RightToLeft) elif ui_direction in 'ltr': self.setLayoutDirection(Qt.LeftToRight) global icons icons = ':/' + str( self.persepolis_setting.value('settings/icons')) + '/' window_verticalLayout = QVBoxLayout(self) self.pressKeyLabel = QLabel(self) window_verticalLayout.addWidget(self.pressKeyLabel) self.capturedKeyLabel = QLabel(self) window_verticalLayout.addWidget(self.capturedKeyLabel) # window buttons buttons_horizontalLayout = QHBoxLayout() buttons_horizontalLayout.addStretch(1) self.cancel_pushButton = QPushButton(self) self.cancel_pushButton.setIcon(QIcon(icons + 'remove')) buttons_horizontalLayout.addWidget(self.cancel_pushButton) self.ok_pushButton = QPushButton(self) self.ok_pushButton.setIcon(QIcon(icons + 'ok')) buttons_horizontalLayout.addWidget(self.ok_pushButton) window_verticalLayout.addLayout(buttons_horizontalLayout) # labels self.pressKeyLabel.setText( QCoreApplication.translate("setting_ui_tr", "Press new keys")) self.cancel_pushButton.setText( QCoreApplication.translate("setting_ui_tr", "Cancel")) self.ok_pushButton.setText( QCoreApplication.translate("setting_ui_tr", "OK"))
class AboutWindow_Ui(QWidget): def __init__(self, persepolis_setting): super().__init__() self.persepolis_setting = persepolis_setting # add support for other languages locale = str(self.persepolis_setting.value('settings/locale')) QLocale.setDefault(QLocale(locale)) self.translator = QTranslator() if self.translator.load(':/translations/locales/ui_' + locale, 'ts'): QCoreApplication.installTranslator(self.translator) # set ui direction ui_direction = self.persepolis_setting.value('ui_direction') if ui_direction == 'rtl': self.setLayoutDirection(Qt.RightToLeft) elif ui_direction in 'ltr': self.setLayoutDirection(Qt.LeftToRight) icons = ':/' + \ str(self.persepolis_setting.value('settings/icons')) + '/' self.setMinimumSize(QSize(545, 375)) self.setWindowIcon(QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg'))) verticalLayout = QVBoxLayout(self) self.about_tabWidget = QTabWidget(self) # about tab self.about_tab = QWidget(self) about_tab_horizontalLayout = QHBoxLayout(self.about_tab) about_tab_verticalLayout = QVBoxLayout() # persepolis icon if qtsvg_available: persepolis_icon_verticalLayout = QVBoxLayout() self.persepolis_icon = QtSvgWidget.QSvgWidget(':/persepolis.svg') self.persepolis_icon.setFixedSize(QSize(64, 64)) persepolis_icon_verticalLayout.addWidget(self.persepolis_icon) persepolis_icon_verticalLayout.addStretch(1) about_tab_horizontalLayout.addLayout(persepolis_icon_verticalLayout) self.title_label = QLabel(self.about_tab) font = QFont() font.setBold(True) font.setWeight(QFont.Weight.Bold) self.title_label.setFont(font) self.title_label.setAlignment(Qt.AlignCenter) about_tab_verticalLayout.addWidget(self.title_label) self.version_label = QLabel(self.about_tab) self.version_label.setAlignment(Qt.AlignCenter) about_tab_verticalLayout.addWidget(self.version_label) self.site2_label = QLabel(self.about_tab) self.site2_label.setTextFormat(Qt.RichText) self.site2_label.setAlignment(Qt.AlignCenter) self.site2_label.setOpenExternalLinks(True) self.site2_label.setTextInteractionFlags( Qt.TextBrowserInteraction) about_tab_verticalLayout.addWidget(self.site2_label) self.telegram_label = QLabel(self.about_tab) self.telegram_label.setTextFormat(Qt.RichText) self.telegram_label.setAlignment(Qt.AlignCenter) self.telegram_label.setOpenExternalLinks(True) self.telegram_label.setTextInteractionFlags( Qt.TextBrowserInteraction) about_tab_verticalLayout.addWidget(self.telegram_label) self.twitter_label = QLabel(self.about_tab) self.twitter_label.setTextFormat(Qt.RichText) self.twitter_label.setAlignment(Qt.AlignCenter) self.twitter_label.setOpenExternalLinks(True) self.twitter_label.setTextInteractionFlags( Qt.TextBrowserInteraction) about_tab_verticalLayout.addWidget(self.twitter_label) about_tab_verticalLayout.addStretch(1) about_tab_horizontalLayout.addLayout(about_tab_verticalLayout) # developers_tab # developers self.developers_tab = QWidget(self) developers_verticalLayout = QVBoxLayout(self.developers_tab) self.developers_title_label = QLabel(self.developers_tab) font.setBold(True) font.setWeight(QFont.Weight.Bold) self.developers_title_label.setFont(font) self.developers_title_label.setAlignment(Qt.AlignCenter) developers_verticalLayout.addWidget(self.developers_title_label) self.name_label = QLabel(self.developers_tab) self.name_label.setAlignment(Qt.AlignCenter) developers_verticalLayout.addWidget(self.name_label) # contributors self.contributors_thank_label = QLabel(self.developers_tab) self.contributors_thank_label.setFont(font) self.contributors_thank_label.setAlignment(Qt.AlignCenter) developers_verticalLayout.addWidget(self.contributors_thank_label) self.contributors_link_label = QLabel(self.developers_tab) self.contributors_link_label.setTextFormat(Qt.RichText) self.contributors_link_label.setAlignment(Qt.AlignCenter) self.contributors_link_label.setOpenExternalLinks(True) self.contributors_link_label.setTextInteractionFlags( Qt.TextBrowserInteraction) developers_verticalLayout.addWidget(self.contributors_link_label) developers_verticalLayout.addStretch(1) # translators tab self.translators_tab = QWidget(self) translators_tab_verticalLayout = QVBoxLayout(self.translators_tab) # translators self.translators_textEdit = QTextEdit(self.translators_tab) self.translators_textEdit.setReadOnly(True) translators_tab_verticalLayout.addWidget(self.translators_textEdit) # License tab self.license_tab = QWidget(self) license_tab_verticalLayout = QVBoxLayout(self.license_tab) self.license_text = QTextEdit(self.license_tab) self.license_text.setReadOnly(True) license_tab_verticalLayout.addWidget(self.license_text) verticalLayout.addWidget(self.about_tabWidget) # buttons button_horizontalLayout = QHBoxLayout() button_horizontalLayout.addStretch(1) self.pushButton = QPushButton(self) self.pushButton.setIcon(QIcon(icons + 'ok')) self.pushButton.clicked.connect(self.close) button_horizontalLayout.addWidget(self.pushButton) verticalLayout.addLayout(button_horizontalLayout) self.setWindowTitle(QCoreApplication.translate("about_ui_tr", "About Persepolis")) # about_tab self.title_label.setText(QCoreApplication.translate("about_ui_tr", "Persepolis Download Manager")) self.version_label.setText(QCoreApplication.translate("about_ui_tr", "Version 3.2.0")) self.site2_label.setText(QCoreApplication.translate("about_ui_tr", "<a href=https://persepolisdm.github.io>https://persepolisdm.github.io</a>", "TRANSLATORS NOTE: YOU REALLY DON'T NEED TO TRANSLATE THIS PART!")) self.telegram_label.setText(QCoreApplication.translate("about_ui_tr", "<a href=https://telegram.me/persepolisdm>https://telegram.me/persepolisdm</a>", "TRANSLATORS NOTE: YOU REALLY DON'T NEED TO TRANSLATE THIS PART!")) self.twitter_label.setText(QCoreApplication.translate("about_ui_tr", "<a href=https://twitter.com/persepolisdm>https://twitter.com/persepolisdm</a>", "TRANSLATORS NOTE: YOU REALLY DON'T NEED TO TRANSLATE THIS PART!")) # developers_tab self.developers_title_label.setText(QCoreApplication.translate('about_ui_tr', 'Developers:')) self.name_label.setText(QCoreApplication.translate("about_ui_tr", "\nAliReza AmirSamimi\nMohammadreza Abdollahzadeh\nSadegh Alirezaie\nMostafa Asadi\nMohammadAmin Vahedinia\nJafar Akhondali\nH.Rostami\nEhsan Titish", "TRANSLATORS NOTE: YOU REALLY DON'T NEED TO TRANSLATE THIS PART!")) self.contributors_thank_label.setText(QCoreApplication.translate('about_ui_tr', 'Special thanks to:')) self.contributors_link_label.setText( "<a href=https://github.com/persepolisdm/persepolis/graphs/contributors>our contributors</a>") # License self.license_text.setPlainText(""" This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. """) # tabs self.about_tabWidget.addTab(self.about_tab, QCoreApplication.translate("about_ui_tr", "About Persepolis")) self.about_tabWidget.addTab(self.developers_tab, QCoreApplication.translate("about_ui_tr", "Developers")) self.about_tabWidget.addTab(self.translators_tab, QCoreApplication.translate("about_ui_tr", "Translators")) self.about_tabWidget.addTab(self.license_tab, QCoreApplication.translate("about_ui_tr", "License")) # button self.pushButton.setText(QCoreApplication.translate("about_ui_tr", "OK"))
class MainWidget(QWidget): def __init__(self, parent: QWidget, model: Model) -> None: super().__init__(parent) logger.add(self.log) settings = QSettings() self.mainlayout = QVBoxLayout() self.mainlayout.setContentsMargins(5, 5, 5, 5) self.setLayout(self.mainlayout) # summary summarylayout = FlowLayout() summarylayout.setContentsMargins(0, 0, 0, 0) self.summary = QWidget() self.summary.setLayout(summarylayout) self.mainlayout.addWidget(self.summary) self.summary.setVisible( settings.value('showSummary', 'True') == 'True') detailslayout = QHBoxLayout() detailslayout.setContentsMargins(1, 0, 0, 0) detailslayout.setAlignment(Qt.AlignLeft | Qt.AlignVCenter) detailslayout.setSpacing(15) details = QWidget() details.setLayout(detailslayout) summarylayout.addWidget(details) self.modstotal = QLabel() detailslayout.addWidget(self.modstotal) self.modsenabled = QLabel() detailslayout.addWidget(self.modsenabled) self.overridden = QLabel() detailslayout.addWidget(self.overridden) self.conflicts = QLabel() detailslayout.addWidget(self.conflicts) buttonslayout = QHBoxLayout() buttonslayout.setContentsMargins(0, 0, 0, 0) buttonslayout.setAlignment(Qt.AlignRight | Qt.AlignVCenter) buttons = QWidget() buttons.setLayout(buttonslayout) summarylayout.addWidget(buttons) self.startscriptmerger = QPushButton('Start Script Merger') self.startscriptmerger.setContentsMargins(0, 0, 0, 0) self.startscriptmerger.setMinimumWidth(140) self.startscriptmerger.setIcon( QIcon(str(getRuntimePath('resources/icons/script.ico')))) self.startscriptmerger.clicked.connect(lambda: [ openExecutable(Path(str(settings.value('scriptMergerPath'))), True) ]) self.startscriptmerger.setEnabled( verifyScriptMergerPath( Path(str(settings.value('scriptMergerPath')))) is not None) buttonslayout.addWidget(self.startscriptmerger) self.startgame = QPushButton('Start Game') self.startgame.setContentsMargins(0, 0, 0, 0) self.startgame.setMinimumWidth(100) self.startgame.setIcon( QIcon(str(getRuntimePath('resources/icons/w3b.ico')))) buttonslayout.addWidget(self.startgame) # splitter self.splitter = QSplitter(Qt.Vertical) self.stack = QStackedWidget() self.splitter.addWidget(self.stack) # mod list widget self.modlistwidget = QWidget() self.modlistlayout = QVBoxLayout() self.modlistlayout.setContentsMargins(0, 0, 0, 0) self.modlistwidget.setLayout(self.modlistlayout) self.stack.addWidget(self.modlistwidget) # search bar self.searchbar = QLineEdit() self.searchbar.setPlaceholderText('Search...') self.modlistlayout.addWidget(self.searchbar) # mod list self.modlist = ModList(self, model) self.modlistlayout.addWidget(self.modlist) self.searchbar.textChanged.connect(lambda e: self.modlist.setFilter(e)) # welcome message welcomelayout = QVBoxLayout() welcomelayout.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) welcomewidget = QWidget() welcomewidget.setLayout(welcomelayout) welcomewidget.dragEnterEvent = self.modlist.dragEnterEvent # type: ignore welcomewidget.dragMoveEvent = self.modlist.dragMoveEvent # type: ignore welcomewidget.dragLeaveEvent = self.modlist.dragLeaveEvent # type: ignore welcomewidget.dropEvent = self.modlist.dropEvent # type: ignore welcomewidget.setAcceptDrops(True) icon = QIcon(str(getRuntimePath('resources/icons/open-folder.ico'))) iconpixmap = icon.pixmap(32, 32) icon = QLabel() icon.setPixmap(iconpixmap) icon.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) icon.setContentsMargins(4, 4, 4, 4) welcomelayout.addWidget(icon) welcome = QLabel('''<p><font> No mod installed yet. Drag a mod into this area to get started! </font></p>''') welcome.setAttribute(Qt.WA_TransparentForMouseEvents) welcome.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) welcomelayout.addWidget(welcome) self.stack.addWidget(welcomewidget) # output log self.output = QTextEdit(self) self.output.setTextInteractionFlags(Qt.NoTextInteraction) self.output.setReadOnly(True) self.output.setContextMenuPolicy(Qt.NoContextMenu) self.output.setPlaceholderText('Program output...') self.splitter.addWidget(self.output) # TODO: enhancement: show indicator if scripts have to be merged self.splitter.setStretchFactor(0, 1) self.splitter.setStretchFactor(1, 0) self.mainlayout.addWidget(self.splitter) # TODO: incomplete: make start game button functional if len(model): self.stack.setCurrentIndex(0) self.splitter.setSizes([self.splitter.size().height(), 50]) else: self.stack.setCurrentIndex(1) self.splitter.setSizes([self.splitter.size().height(), 0]) model.updateCallbacks.append(self.modelUpdateEvent) asyncio.create_task(model.loadInstalled()) def keyPressEvent(self, event: QKeyEvent) -> None: if event.key() == Qt.Key_Escape: self.modlist.setFocus() self.searchbar.setText('') elif event.matches(QKeySequence.Find): self.searchbar.setFocus() elif event.matches(QKeySequence.Paste): self.pasteEvent() # TODO: enhancement: add start game / start script merger shortcuts else: super().keyPressEvent(event) def pasteEvent(self) -> None: clipboard = QApplication.clipboard().text().splitlines() if len(clipboard) == 1 and isValidNexusModsUrl(clipboard[0]): self.parentWidget().showDownloadModDialog() else: urls = [ url for url in QApplication.clipboard().text().splitlines() if len(str(url.strip())) ] if all( isValidModDownloadUrl(url) or isValidFileUrl(url) for url in urls): asyncio.create_task(self.modlist.checkInstallFromURLs(urls)) def modelUpdateEvent(self, model: Model) -> None: total = len(model) enabled = len([mod for mod in model if model[mod].enabled]) overridden = sum( len(file) for file in model.conflicts.bundled.values()) conflicts = sum(len(file) for file in model.conflicts.scripts.values()) self.modstotal.setText( f'<font color="#73b500" size="4">{total}</font> \ <font color="#888" text-align="center">Installed Mod{"" if total == 1 else "s"}</font>' ) self.modsenabled.setText( f'<font color="#73b500" size="4">{enabled}</font> \ <font color="#888">Enabled Mod{"" if enabled == 1 else "s"}</font>' ) self.overridden.setText( f'<font color="{"#b08968" if overridden > 0 else "#84C318"}" size="4">{overridden}</font> \ <font color="#888">Overridden File{"" if overridden == 1 else "s"}</font> ' ) self.conflicts.setText( f'<font color="{"#E55934" if conflicts > 0 else "#aad576"}" size="4">{conflicts}</font> \ <font color="#888">Unresolved Conflict{"" if conflicts == 1 else "s"}</font> ' ) if len(model) > 0: if self.stack.currentIndex() != 0: self.stack.setCurrentIndex(0) self.repaint() else: if self.stack.currentIndex() != 1: self.stack.setCurrentIndex(1) self.repaint() def unhideOutput(self) -> None: if self.splitter.sizes()[1] < 10: self.splitter.setSizes([self.splitter.size().height(), 50]) def unhideModList(self) -> None: if self.splitter.sizes()[0] < 10: self.splitter.setSizes([50, self.splitter.size().height()]) def log(self, message: Any) -> None: # format log messages to user readable output settings = QSettings() record = message.record message = record['message'] extra = record['extra'] level = record['level'].name.lower() name = str(extra['name'] ) if 'name' in extra and extra['name'] is not None else '' path = str(extra['path'] ) if 'path' in extra and extra['path'] is not None else '' dots = bool( extra['dots'] ) if 'dots' in extra and extra['dots'] is not None else False newline = bool( extra['newline'] ) if 'newline' in extra and extra['newline'] is not None else False output = bool( extra['output'] ) if 'output' in extra and extra['output'] is not None else bool( message) modlist = bool( extra['modlist'] ) if 'modlist' in extra and extra['modlist'] is not None else False if level in ['debug' ] and settings.value('debugOutput', 'False') != 'True': if newline: self.output.append(f'') return n = '<br>' if newline else '' d = '...' if dots else '' if len(name) and len(path): path = f' ({path})' if output: message = html.escape(message, quote=True) if level in ['success', 'error', 'warning']: message = f'<strong>{message}</strong>' if level in ['success']: message = f'<font color="#04c45e">{message}</font>' if level in ['error', 'critical']: message = f'<font color="#ee3b3b">{message}</font>' if level in ['warning']: message = f'<font color="#ff6500">{message}</font>' if level in ['debug', 'trace']: message = f'<font color="#aaa">{message}</font>' path = f'<font color="#aaa">{path}</font>' if path else '' d = f'<font color="#aaa">{d}</font>' if d else '' time = record['time'].astimezone( tz=None).strftime('%Y-%m-%d %H:%M:%S') message = f'<font color="#aaa">{time}</font> {message}' self.output.append( f'{n}{message.strip()}{" " if name or path else ""}{name}{path}{d}' ) else: self.output.append(f'') self.output.verticalScrollBar().setValue( self.output.verticalScrollBar().maximum()) self.output.repaint() if modlist: self.unhideModList() if settings.value('unhideOutput', 'True') == 'True' and output: self.unhideOutput()
class TitleBar(QWidget): # Сигнал минимизации окна windowMinimumed = Signal() # увеличить максимальный сигнал окна windowMaximumed = Signal() # сигнал восстановления окна windowNormaled = Signal() # сигнал закрытия окна windowClosed = Signal() # Окно мобильных windowMoved = Signal(QPoint) # Сигнал Своя Кнопка +++ signalButtonMy = Signal() def __init__(self, *args, **kwargs): super(TitleBar, self).__init__(*args, **kwargs) # Поддержка настройки фона qss self.setAttribute(Qt.WA_StyledBackground, True) self.mPos = None self.iconSize = 20 # Размер значка по умолчанию # Установите цвет фона по умолчанию, иначе он будет прозрачным из-за влияния родительского окна self.setAutoFillBackground(True) palette = self.palette() palette.setColor(palette.Window, QColor(240, 240, 240)) self.setPalette(palette) # Подключение стиля self.setStyleSheet('Titlebar.qss') self.setStyleSheet(open("Titlebar.qss", "r").read()) # макет layout = QHBoxLayout(self) layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) # значок окна # название окна self.titleLabel = QLabel(self) self.titleLabel.setMargin(2) self.font_id = QFontDatabase.addApplicationFont( "Roboto/Roboto-Bold.ttf") font = QFont("Roboto-Bold", 12) font.setFamily(u"Roboto") font.setBold(True) self.buttonMy = QPushButton(self, clicked=self.showButtonMy, objectName='buttonMy') self.buttonMy.setIcon(QIcon('icon-white.ico')) layout.addWidget(self.buttonMy) layout.addStretch() self.titleLabel.setFont(font) layout.addStretch() layout.addWidget(self.titleLabel, alignment=Qt.AlignCenter) # Средний телескопический бар layout.addSpacerItem( QSpacerItem(40, 100, QSizePolicy.Expanding, QSizePolicy.Minimum)) # Использовать шрифты Webdings для отображения значков font = self.font() or QFont() font.setFamily('Webdings') # Своя Кнопка # Свернуть кнопку self.buttonMinimum = QPushButton('0', self, clicked=self.windowMinimumed.emit, font=font, objectName='buttonMinimum') layout.addWidget(self.buttonMinimum) # Кнопка Max / restore self.buttonMaximum = QPushButton('1', self, clicked=self.showMaximized, font=font, objectName='buttonMaximum') layout.addWidget(self.buttonMaximum) # Кнопка закрытия self.buttonClose = QPushButton('r', self, clicked=self.windowClosed.emit, font=font, objectName='buttonClose') layout.addWidget(self.buttonClose) # начальная высота self.setHeight() # +++ Вызывается по нажатию кнопки buttonMy def showButtonMy(self): print("Своя Кнопка ") self.signalButtonMy.emit() def showMaximized(self): if self.buttonMaximum.text() == '1': # Максимизировать self.buttonMaximum.setText('2') self.windowMaximumed.emit() else: # Восстановить self.buttonMaximum.setText('1') self.windowNormaled.emit() def setHeight(self, height=38): """ Установка высоты строки заголовка """ self.setMinimumHeight(height) self.setMaximumHeight(height) # Задайте размер правой кнопки ? self.buttonMinimum.setMinimumSize(height, height) self.buttonMinimum.setMaximumSize(height, height) self.buttonMaximum.setMinimumSize(height, height) self.buttonMaximum.setMaximumSize(height, height) self.buttonClose.setMinimumSize(height, height) self.buttonClose.setMaximumSize(height, height) self.buttonMy.setMinimumSize(height, height) self.buttonMy.setMaximumSize(height, height) def setTitle(self, title): """ Установить заголовок """ self.titleLabel.setText(title) def setIcon(self, icon): """ настройки значокa """ self.iconLabel.setPixmap(icon.pixmap(self.iconSize, self.iconSize)) def setIconSize(self, size): """ Установить размер значка """ self.iconSize = size def enterEvent(self, event): self.setCursor(Qt.ArrowCursor) super(TitleBar, self).enterEvent(event) def mouseDoubleClickEvent(self, event): super(TitleBar, self).mouseDoubleClickEvent(event) self.showMaximized() def mousePressEvent(self, event): """ Событие клика мыши """ if event.button() == Qt.LeftButton: self.mPos = event.pos() event.accept() def mouseReleaseEvent(self, event): ''' Событие отказов мыши ''' self.mPos = None event.accept() def mouseMoveEvent(self, event): if event.buttons() == Qt.LeftButton and self.mPos: self.windowMoved.emit(self.mapToGlobal(event.pos() - self.mPos)) event.accept()
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 MyWidget(QWidget): def __init__(self): super().__init__() # 设置属性 self.resize(400, 300) self.setWindowTitle("测试Qt进度条和aria2的联合") # 注册组件 self.labelUrl = QLabel("下载链接") self.lineEditorUrl = QLineEdit( "https://download.cnki.net/CAJViewer-x86_64-buildubuntu1604-210401.AppImage" ) self.labelProgress = QLabel("下载进度") self.downloadProgress = QProgressBar() self.textResult = QTextBrowser() self.buttonStart = QPushButton("开始") self.buttonPause = QPushButton("暂停") self.buttonUnpause = QPushButton("继续") self.buttonRemove = QPushButton("移除") self.buttonDebug = QPushButton("Debug") # 设置组件 self.lineEditorUrl.setClearButtonEnabled(True) self.buttonStart.setIcon(self.style().standardIcon( QStyle.SP_MediaPlay)) self.buttonPause.setIcon(self.style().standardIcon( QStyle.SP_MediaPause)) self.buttonUnpause.setIcon(self.style().standardIcon( QStyle.SP_MediaPlay)) self.buttonRemove.setIcon(self.style().standardIcon( QStyle.SP_MediaStop)) # self.buttonPause.setDisabled(True) # self.buttonStop.setDisabled(True) # 添加组件 self.layout = QGridLayout(self) self.layout.addWidget(self.labelUrl, 0, 0, 1, 1) self.layout.addWidget(self.lineEditorUrl, 0, 1, 1, 5) self.layout.addWidget(self.labelProgress, 1, 0, 1, 1) self.layout.addWidget(self.downloadProgress, 1, 1, 1, 5) self.layout.addWidget(self.textResult, 2, 0, 2, 5) self.layout.addWidget(self.buttonStart, 4, 0, 1, 1) self.layout.addWidget(self.buttonPause, 4, 1, 1, 1) self.layout.addWidget(self.buttonUnpause, 4, 2, 1, 1) self.layout.addWidget(self.buttonRemove, 4, 3, 1, 1) self.layout.addWidget(self.buttonDebug, 4, 4, 1, 1) # 添加组件功能 # class函数 @Slot(str) def updateProgress(self, value): self.downloadProgress.setMaximum(int(value['totalLength'])) self.downloadProgress.setValue( int(value['files'][0]['completedLength'])) if value["status"] == "complete": self.downloadProgress.setValue(int(value['totalLength'])) shutdown_aria2 = Signal() @Slot() def clearProgress(self): self.downloadProgress.setValue(0) def closeEvent(self, event): if QMessageBox.question(self, "退出程序", "确定退出吗?") == QMessageBox.No: event.ignore() else: event.accept() self.shutdown_aria2.emit()
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 Ui_MainWindow(object): def setupUi(self, MainWindow): if not MainWindow.objectName(): MainWindow.setObjectName(u"MainWindow") MainWindow.setWindowModality(Qt.ApplicationModal) MainWindow.resize(1492, 1852) sizePolicy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth()) MainWindow.setSizePolicy(sizePolicy) MainWindow.setMinimumSize(QSize(700, 700)) MainWindow.setMaximumSize(QSize(16777215, 16777215)) MainWindow.setBaseSize(QSize(600, 600)) font = QFont() font.setPointSize(12) font.setKerning(True) MainWindow.setFont(font) MainWindow.setAutoFillBackground(False) MainWindow.setStyleSheet(u"") MainWindow.setDocumentMode(False) MainWindow.setTabShape(QTabWidget.Rounded) MainWindow.setDockOptions(QMainWindow.AllowTabbedDocks|QMainWindow.AnimatedDocks) MainWindow.setUnifiedTitleAndToolBarOnMac(False) self.action_Quit = QAction(MainWindow) self.action_Quit.setObjectName(u"action_Quit") self.main_widget = QWidget(MainWindow) self.main_widget.setObjectName(u"main_widget") self.main_widget.setEnabled(True) self.main_widget.setMinimumSize(QSize(650, 650)) self.main_widget.setContextMenuPolicy(Qt.DefaultContextMenu) self.main_widget.setAutoFillBackground(False) self.main_widget.setStyleSheet(u"") self.main_layout = QGridLayout(self.main_widget) self.main_layout.setObjectName(u"main_layout") self.horizontalLayout_2 = QHBoxLayout() self.horizontalLayout_2.setObjectName(u"horizontalLayout_2") self.log_button = QPushButton(self.main_widget) self.log_button.setObjectName(u"log_button") sizePolicy1 = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy1.setHorizontalStretch(0) sizePolicy1.setVerticalStretch(0) sizePolicy1.setHeightForWidth(self.log_button.sizePolicy().hasHeightForWidth()) self.log_button.setSizePolicy(sizePolicy1) self.log_button.setMinimumSize(QSize(24, 24)) font1 = QFont() font1.setPointSize(9) font1.setBold(True) font1.setKerning(True) self.log_button.setFont(font1) self.log_button.setCursor(QCursor(Qt.PointingHandCursor)) self.log_button.setCheckable(False) self.log_button.setFlat(True) self.horizontalLayout_2.addWidget(self.log_button) self.main_layout.addLayout(self.horizontalLayout_2, 5, 2, 1, 1) self.shuttle_widget = QWidget(self.main_widget) self.shuttle_widget.setObjectName(u"shuttle_widget") self.shuttle_widget.setMinimumSize(QSize(600, 600)) self.shuttle_widget.setMaximumSize(QSize(600, 600)) self.shuttle_widget.setAutoFillBackground(False) self.shuttle_widget.setStyleSheet(u"QWidget#shuttle_widget {background: url(images/ShuttleXpress_Black.png);\n" " background-repeat:no-repeat;}\n" " ") self.button_1 = QCheckBox(self.shuttle_widget) self.button_1.setObjectName(u"button_1") self.button_1.setGeometry(QRect(80, 266, 24, 24)) sizePolicy1.setHeightForWidth(self.button_1.sizePolicy().hasHeightForWidth()) self.button_1.setSizePolicy(sizePolicy1) self.button_1.setMinimumSize(QSize(24, 24)) self.button_1.setFont(font) self.button_1.setStyleSheet(u"background: #000000ff;\n" " color: white;\n" " ") self.usb_status = QPushButton(self.shuttle_widget) self.usb_status.setObjectName(u"usb_status") self.usb_status.setEnabled(False) self.usb_status.setGeometry(QRect(288, 10, 24, 24)) sizePolicy1.setHeightForWidth(self.usb_status.sizePolicy().hasHeightForWidth()) self.usb_status.setSizePolicy(sizePolicy1) self.usb_status.setMinimumSize(QSize(24, 24)) self.usb_status.setFont(font1) self.usb_status.setCursor(QCursor(Qt.ArrowCursor)) self.usb_status.setAutoFillBackground(False) self.usb_status.setText(u"") icon = QIcon() icon.addFile(u"images/usb_black_24.png", QSize(), QIcon.Disabled, QIcon.Off) icon.addFile(u"images/usb_white_24.png", QSize(), QIcon.Disabled, QIcon.On) self.usb_status.setIcon(icon) self.usb_status.setIconSize(QSize(24, 24)) self.usb_status.setCheckable(True) self.usb_status.setChecked(False) self.usb_status.setFlat(True) self.button_5 = QCheckBox(self.shuttle_widget) self.button_5.setObjectName(u"button_5") self.button_5.setGeometry(QRect(498, 266, 24, 24)) sizePolicy1.setHeightForWidth(self.button_5.sizePolicy().hasHeightForWidth()) self.button_5.setSizePolicy(sizePolicy1) self.button_5.setMinimumSize(QSize(24, 24)) self.button_5.setFont(font) self.button_5.setLayoutDirection(Qt.RightToLeft) self.button_5.setStyleSheet(u"background: #000000ff;\n" " color: white;\n" " ") self.wheel_pos4 = QRadioButton(self.shuttle_widget) self.wheel_pos4.setObjectName(u"wheel_pos4") self.wheel_pos4.setGeometry(QRect(382, 164, 24, 24)) sizePolicy1.setHeightForWidth(self.wheel_pos4.sizePolicy().hasHeightForWidth()) self.wheel_pos4.setSizePolicy(sizePolicy1) self.wheel_pos4.setMinimumSize(QSize(24, 24)) self.wheel_pos4.setStyleSheet(u"background: #000000ff;\n" " color: white;\n" " ") self.wheel_cent0 = QRadioButton(self.shuttle_widget) self.wheel_cent0.setObjectName(u"wheel_cent0") self.wheel_cent0.setGeometry(QRect(289, 130, 24, 24)) sizePolicy1.setHeightForWidth(self.wheel_cent0.sizePolicy().hasHeightForWidth()) self.wheel_cent0.setSizePolicy(sizePolicy1) self.wheel_cent0.setMinimumSize(QSize(24, 24)) self.wheel_cent0.setStyleSheet(u"background: #000000ff;\n" " color: white;\n" " ") self.wheel_cent0.setChecked(True) self.wheel_pos1 = QRadioButton(self.shuttle_widget) self.wheel_pos1.setObjectName(u"wheel_pos1") self.wheel_pos1.setGeometry(QRect(314, 133, 24, 24)) sizePolicy1.setHeightForWidth(self.wheel_pos1.sizePolicy().hasHeightForWidth()) self.wheel_pos1.setSizePolicy(sizePolicy1) self.wheel_pos1.setMinimumSize(QSize(24, 24)) self.wheel_pos1.setStyleSheet(u"color: white;") self.wheel_pos2 = QRadioButton(self.shuttle_widget) self.wheel_pos2.setObjectName(u"wheel_pos2") self.wheel_pos2.setGeometry(QRect(338, 139, 24, 24)) sizePolicy1.setHeightForWidth(self.wheel_pos2.sizePolicy().hasHeightForWidth()) self.wheel_pos2.setSizePolicy(sizePolicy1) self.wheel_pos2.setMinimumSize(QSize(24, 24)) self.wheel_pos2.setStyleSheet(u"background: #000000ff;\n" " color: white;\n" " ") self.dial = QDial(self.shuttle_widget) self.dial.setObjectName(u"dial") self.dial.setGeometry(QRect(197, 178, 216, 216)) sizePolicy2 = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred) sizePolicy2.setHorizontalStretch(0) sizePolicy2.setVerticalStretch(0) sizePolicy2.setHeightForWidth(self.dial.sizePolicy().hasHeightForWidth()) self.dial.setSizePolicy(sizePolicy2) self.dial.setMinimumSize(QSize(24, 24)) self.dial.setAutoFillBackground(False) self.dial.setStyleSheet(u"background-color: black;") self.dial.setMinimum(0) self.dial.setMaximum(10) self.dial.setPageStep(1) self.dial.setValue(5) self.dial.setSliderPosition(5) self.dial.setInvertedAppearance(False) self.dial.setInvertedControls(False) self.dial.setWrapping(True) self.dial.setNotchTarget(3.700000000000000) self.dial.setNotchesVisible(False) self.wheel_neg6 = QRadioButton(self.shuttle_widget) self.wheel_neg6.setObjectName(u"wheel_neg6") self.wheel_neg6.setGeometry(QRect(162, 204, 24, 24)) sizePolicy1.setHeightForWidth(self.wheel_neg6.sizePolicy().hasHeightForWidth()) self.wheel_neg6.setSizePolicy(sizePolicy1) self.wheel_neg6.setMinimumSize(QSize(24, 24)) self.wheel_neg6.setStyleSheet(u"color: white;") self.wheel_pos5 = QRadioButton(self.shuttle_widget) self.wheel_pos5.setObjectName(u"wheel_pos5") self.wheel_pos5.setGeometry(QRect(400, 182, 24, 24)) sizePolicy1.setHeightForWidth(self.wheel_pos5.sizePolicy().hasHeightForWidth()) self.wheel_pos5.setSizePolicy(sizePolicy1) self.wheel_pos5.setMinimumSize(QSize(24, 24)) self.wheel_pos5.setStyleSheet(u"background: #000000ff;\n" " color: white;\n" " ") self.button_2 = QCheckBox(self.shuttle_widget) self.button_2.setObjectName(u"button_2") self.button_2.setGeometry(QRect(156, 122, 24, 24)) sizePolicy1.setHeightForWidth(self.button_2.sizePolicy().hasHeightForWidth()) self.button_2.setSizePolicy(sizePolicy1) self.button_2.setMinimumSize(QSize(24, 24)) self.button_2.setFont(font) self.button_2.setStyleSheet(u"background: #000000ff;\n" " color: white;\n" " ") self.wheel_neg5 = QRadioButton(self.shuttle_widget) self.wheel_neg5.setObjectName(u"wheel_neg5") self.wheel_neg5.setGeometry(QRect(178, 182, 24, 24)) sizePolicy1.setHeightForWidth(self.wheel_neg5.sizePolicy().hasHeightForWidth()) self.wheel_neg5.setSizePolicy(sizePolicy1) self.wheel_neg5.setMinimumSize(QSize(24, 24)) self.wheel_neg5.setStyleSheet(u"color: white;") self.wheel_pos6 = QRadioButton(self.shuttle_widget) self.wheel_pos6.setObjectName(u"wheel_pos6") self.wheel_pos6.setGeometry(QRect(416, 204, 24, 24)) sizePolicy1.setHeightForWidth(self.wheel_pos6.sizePolicy().hasHeightForWidth()) self.wheel_pos6.setSizePolicy(sizePolicy1) self.wheel_pos6.setMinimumSize(QSize(24, 24)) self.wheel_pos6.setStyleSheet(u"background: #000000ff;\n" " color: white;\n" " ") self.wheel_neg1 = QRadioButton(self.shuttle_widget) self.wheel_neg1.setObjectName(u"wheel_neg1") self.wheel_neg1.setGeometry(QRect(264, 133, 24, 24)) sizePolicy1.setHeightForWidth(self.wheel_neg1.sizePolicy().hasHeightForWidth()) self.wheel_neg1.setSizePolicy(sizePolicy1) self.wheel_neg1.setMinimumSize(QSize(24, 24)) self.wheel_neg1.setStyleSheet(u"background: #000000ff;\n" " color: white;\n" " ") self.button_4 = QCheckBox(self.shuttle_widget) self.button_4.setObjectName(u"button_4") self.button_4.setGeometry(QRect(430, 122, 24, 24)) sizePolicy1.setHeightForWidth(self.button_4.sizePolicy().hasHeightForWidth()) self.button_4.setSizePolicy(sizePolicy1) self.button_4.setMinimumSize(QSize(24, 24)) self.button_4.setFont(font) self.button_4.setLayoutDirection(Qt.RightToLeft) self.button_4.setAutoFillBackground(False) self.button_4.setStyleSheet(u"background: #000000ff;\n" " color: white;\n" " ") self.wheel_pos7 = QRadioButton(self.shuttle_widget) self.wheel_pos7.setObjectName(u"wheel_pos7") self.wheel_pos7.setGeometry(QRect(427, 229, 24, 24)) sizePolicy1.setHeightForWidth(self.wheel_pos7.sizePolicy().hasHeightForWidth()) self.wheel_pos7.setSizePolicy(sizePolicy1) self.wheel_pos7.setMinimumSize(QSize(24, 24)) self.wheel_pos7.setStyleSheet(u"background: #000000ff;\n" " color: white;\n" " ") self.button_3 = QCheckBox(self.shuttle_widget) self.button_3.setObjectName(u"button_3") self.button_3.setGeometry(QRect(290, 72, 24, 24)) sizePolicy1.setHeightForWidth(self.button_3.sizePolicy().hasHeightForWidth()) self.button_3.setSizePolicy(sizePolicy1) self.button_3.setMinimumSize(QSize(24, 24)) self.button_3.setFont(font) self.button_3.setStyleSheet(u"background: #000000ff;\n" " color: white;\n" " ") self.button_3.setTristate(False) self.wheel_neg2 = QRadioButton(self.shuttle_widget) self.wheel_neg2.setObjectName(u"wheel_neg2") self.wheel_neg2.setGeometry(QRect(240, 139, 24, 24)) sizePolicy1.setHeightForWidth(self.wheel_neg2.sizePolicy().hasHeightForWidth()) self.wheel_neg2.setSizePolicy(sizePolicy1) self.wheel_neg2.setMinimumSize(QSize(24, 24)) self.wheel_neg2.setStyleSheet(u"background: #000000ff;\n" " color: white;\n" " ") self.wheel_pos3 = QRadioButton(self.shuttle_widget) self.wheel_pos3.setObjectName(u"wheel_pos3") self.wheel_pos3.setGeometry(QRect(361, 149, 24, 24)) sizePolicy1.setHeightForWidth(self.wheel_pos3.sizePolicy().hasHeightForWidth()) self.wheel_pos3.setSizePolicy(sizePolicy1) self.wheel_pos3.setMinimumSize(QSize(24, 24)) self.wheel_pos3.setStyleSheet(u"background: #000000ff;\n" " color: white;\n" " ") self.wheel_neg3 = QRadioButton(self.shuttle_widget) self.wheel_neg3.setObjectName(u"wheel_neg3") self.wheel_neg3.setGeometry(QRect(217, 149, 24, 24)) sizePolicy1.setHeightForWidth(self.wheel_neg3.sizePolicy().hasHeightForWidth()) self.wheel_neg3.setSizePolicy(sizePolicy1) self.wheel_neg3.setMinimumSize(QSize(24, 24)) self.wheel_neg3.setStyleSheet(u"color: white;") self.wheel_neg4 = QRadioButton(self.shuttle_widget) self.wheel_neg4.setObjectName(u"wheel_neg4") self.wheel_neg4.setGeometry(QRect(196, 164, 24, 24)) sizePolicy1.setHeightForWidth(self.wheel_neg4.sizePolicy().hasHeightForWidth()) self.wheel_neg4.setSizePolicy(sizePolicy1) self.wheel_neg4.setMinimumSize(QSize(24, 24)) self.wheel_neg4.setStyleSheet(u"background: #000000ff;\n" " color: white;\n" " ") self.wheel_neg7 = QRadioButton(self.shuttle_widget) self.wheel_neg7.setObjectName(u"wheel_neg7") self.wheel_neg7.setGeometry(QRect(151, 229, 24, 24)) sizePolicy1.setHeightForWidth(self.wheel_neg7.sizePolicy().hasHeightForWidth()) self.wheel_neg7.setSizePolicy(sizePolicy1) self.wheel_neg7.setMinimumSize(QSize(24, 24)) self.wheel_neg7.setStyleSheet(u"color: white;") self.dial.raise_() self.button_1.raise_() self.usb_status.raise_() self.button_5.raise_() self.wheel_pos4.raise_() self.wheel_cent0.raise_() self.wheel_pos1.raise_() self.wheel_pos2.raise_() self.wheel_neg6.raise_() self.wheel_pos5.raise_() self.button_2.raise_() self.wheel_neg5.raise_() self.wheel_pos6.raise_() self.wheel_neg1.raise_() self.button_4.raise_() self.wheel_pos7.raise_() self.button_3.raise_() self.wheel_neg2.raise_() self.wheel_pos3.raise_() self.wheel_neg3.raise_() self.wheel_neg4.raise_() self.wheel_neg7.raise_() self.main_layout.addWidget(self.shuttle_widget, 3, 2, 1, 1) self.horizontalLayout = QHBoxLayout() self.horizontalLayout.setObjectName(u"horizontalLayout") self.about_button = QPushButton(self.main_widget) self.about_button.setObjectName(u"about_button") sizePolicy1.setHeightForWidth(self.about_button.sizePolicy().hasHeightForWidth()) self.about_button.setSizePolicy(sizePolicy1) self.about_button.setMinimumSize(QSize(24, 24)) self.about_button.setFont(font1) self.about_button.setCursor(QCursor(Qt.WhatsThisCursor)) self.about_button.setCheckable(False) self.about_button.setFlat(True) self.horizontalLayout.addWidget(self.about_button) self.main_layout.addLayout(self.horizontalLayout, 1, 2, 1, 1) self.horizontalLayout_3 = QHBoxLayout() self.horizontalLayout_3.setObjectName(u"horizontalLayout_3") self.plug_button = QPushButton(self.main_widget) self.plug_button.setObjectName(u"plug_button") sizePolicy1.setHeightForWidth(self.plug_button.sizePolicy().hasHeightForWidth()) self.plug_button.setSizePolicy(sizePolicy1) self.plug_button.setMinimumSize(QSize(24, 24)) self.plug_button.setFont(font1) self.plug_button.setCursor(QCursor(Qt.PointingHandCursor)) self.plug_button.setCheckable(False) self.plug_button.setFlat(True) self.horizontalLayout_3.addWidget(self.plug_button) self.main_layout.addLayout(self.horizontalLayout_3, 3, 1, 1, 1) self.verticalLayout = QVBoxLayout() self.verticalLayout.setObjectName(u"verticalLayout") self.conf_button = QPushButton(self.main_widget) self.conf_button.setObjectName(u"conf_button") sizePolicy1.setHeightForWidth(self.conf_button.sizePolicy().hasHeightForWidth()) self.conf_button.setSizePolicy(sizePolicy1) self.conf_button.setMinimumSize(QSize(24, 24)) self.conf_button.setFont(font1) self.conf_button.setCursor(QCursor(Qt.PointingHandCursor)) self.conf_button.setCheckable(False) self.conf_button.setFlat(True) self.verticalLayout.addWidget(self.conf_button) self.main_layout.addLayout(self.verticalLayout, 3, 4, 1, 1) MainWindow.setCentralWidget(self.main_widget) self.statusbar = QStatusBar(MainWindow) self.statusbar.setObjectName(u"statusbar") self.statusbar.setMinimumSize(QSize(600, 0)) MainWindow.setStatusBar(self.statusbar) self.about_widget = QDockWidget(MainWindow) self.about_widget.setObjectName(u"about_widget") self.about_widget.setEnabled(True) sizePolicy3 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy3.setHorizontalStretch(0) sizePolicy3.setVerticalStretch(0) sizePolicy3.setHeightForWidth(self.about_widget.sizePolicy().hasHeightForWidth()) self.about_widget.setSizePolicy(sizePolicy3) self.about_widget.setMinimumSize(QSize(600, 600)) self.about_widget.setVisible(True) self.about_widget.setFloating(False) self.about_widget.setFeatures(QDockWidget.DockWidgetClosable|QDockWidget.DockWidgetMovable) self.about_widget.setAllowedAreas(Qt.TopDockWidgetArea) self.about_layout = QWidget() self.about_layout.setObjectName(u"about_layout") sizePolicy3.setHeightForWidth(self.about_layout.sizePolicy().hasHeightForWidth()) self.about_layout.setSizePolicy(sizePolicy3) self.about_layout.setAutoFillBackground(False) self.gridLayout_3 = QGridLayout(self.about_layout) self.gridLayout_3.setObjectName(u"gridLayout_3") self.about_text = QTextEdit(self.about_layout) self.about_text.setObjectName(u"about_text") self.about_text.setFocusPolicy(Qt.WheelFocus) self.about_text.setAcceptDrops(False) self.about_text.setStyleSheet(u"color: white;") self.about_text.setFrameShape(QFrame.StyledPanel) self.about_text.setFrameShadow(QFrame.Sunken) self.about_text.setUndoRedoEnabled(False) self.about_text.setReadOnly(True) self.about_text.setAcceptRichText(True) self.gridLayout_3.addWidget(self.about_text, 0, 0, 1, 1) self.about_widget.setWidget(self.about_layout) MainWindow.addDockWidget(Qt.TopDockWidgetArea, self.about_widget) self.log_widget = QDockWidget(MainWindow) self.log_widget.setObjectName(u"log_widget") self.log_widget.setEnabled(True) self.log_widget.setMinimumSize(QSize(550, 158)) self.log_widget.setFont(font) self.log_widget.setVisible(True) self.log_widget.setFloating(False) self.log_widget.setFeatures(QDockWidget.DockWidgetClosable|QDockWidget.DockWidgetFloatable|QDockWidget.DockWidgetMovable) self.log_widget.setAllowedAreas(Qt.BottomDockWidgetArea) self.log_layout = QWidget() self.log_layout.setObjectName(u"log_layout") sizePolicy4 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) sizePolicy4.setHorizontalStretch(0) sizePolicy4.setVerticalStretch(0) sizePolicy4.setHeightForWidth(self.log_layout.sizePolicy().hasHeightForWidth()) self.log_layout.setSizePolicy(sizePolicy4) self.gridLayout_2 = QGridLayout(self.log_layout) self.gridLayout_2.setObjectName(u"gridLayout_2") self.log_content_layout = QVBoxLayout() self.log_content_layout.setObjectName(u"log_content_layout") self.log_content_layout.setSizeConstraint(QLayout.SetDefaultConstraint) self.log_text = QPlainTextEdit(self.log_layout) self.log_text.setObjectName(u"log_text") sizePolicy4.setHeightForWidth(self.log_text.sizePolicy().hasHeightForWidth()) self.log_text.setSizePolicy(sizePolicy4) self.log_text.setMinimumSize(QSize(0, 0)) self.log_text.setAcceptDrops(False) self.log_text.setFrameShape(QFrame.StyledPanel) self.log_text.setFrameShadow(QFrame.Sunken) self.log_text.setUndoRedoEnabled(False) self.log_text.setReadOnly(True) self.log_content_layout.addWidget(self.log_text) self.buttons_layout = QHBoxLayout() self.buttons_layout.setObjectName(u"buttons_layout") self.buttons_layout.setSizeConstraint(QLayout.SetDefaultConstraint) self.log_clear_button = QToolButton(self.log_layout) self.log_clear_button.setObjectName(u"log_clear_button") icon1 = QIcon() icon1.addFile(u"images/delete-sweep_24.png", QSize(), QIcon.Normal, QIcon.Off) self.log_clear_button.setIcon(icon1) self.log_clear_button.setIconSize(QSize(24, 24)) self.buttons_layout.addWidget(self.log_clear_button) self.log_content_layout.addLayout(self.buttons_layout) self.gridLayout_2.addLayout(self.log_content_layout, 0, 0, 1, 1) self.log_widget.setWidget(self.log_layout) MainWindow.addDockWidget(Qt.BottomDockWidgetArea, self.log_widget) self.config_widget = QDockWidget(MainWindow) self.config_widget.setObjectName(u"config_widget") self.config_widget.setEnabled(True) self.config_widget.setMinimumSize(QSize(250, 600)) self.config_widget.setFloating(False) self.config_widget.setFeatures(QDockWidget.DockWidgetClosable|QDockWidget.DockWidgetFloatable|QDockWidget.DockWidgetMovable) self.config_widget.setAllowedAreas(Qt.RightDockWidgetArea) self.config_layout = QWidget() self.config_layout.setObjectName(u"config_layout") self.gridLayout = QGridLayout(self.config_layout) self.gridLayout.setObjectName(u"gridLayout") self.config_content_layout = QFormLayout() self.config_content_layout.setObjectName(u"config_content_layout") self.gridLayout.addLayout(self.config_content_layout, 0, 0, 1, 1) self.config_widget.setWidget(self.config_layout) MainWindow.addDockWidget(Qt.RightDockWidgetArea, self.config_widget) self.plugins_widget = QDockWidget(MainWindow) self.plugins_widget.setObjectName(u"plugins_widget") self.plugins_widget.setMinimumSize(QSize(250, 600)) self.plugins_widget.setAllowedAreas(Qt.LeftDockWidgetArea) self.dockWidgetContents = QWidget() self.dockWidgetContents.setObjectName(u"dockWidgetContents") self.plugins_widget.setWidget(self.dockWidgetContents) MainWindow.addDockWidget(Qt.LeftDockWidgetArea, self.plugins_widget) self.about_widget.raise_() self.log_widget.raise_() self.retranslateUi(MainWindow) self.usb_status.setDefault(False) QMetaObject.connectSlotsByName(MainWindow) # setupUi def retranslateUi(self, MainWindow): MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"Contour ShuttleXpress", None)) self.action_Quit.setText(QCoreApplication.translate("MainWindow", u"&Quit", None)) #if QT_CONFIG(tooltip) self.log_button.setToolTip("") #endif // QT_CONFIG(tooltip) #if QT_CONFIG(statustip) self.log_button.setStatusTip(QCoreApplication.translate("MainWindow", u"Log", None)) #endif // QT_CONFIG(statustip) self.log_button.setText(QCoreApplication.translate("MainWindow", u"//", None)) #if QT_CONFIG(statustip) self.button_1.setStatusTip(QCoreApplication.translate("MainWindow", u"Button 1", None)) #endif // QT_CONFIG(statustip) self.button_1.setText("") #if QT_CONFIG(tooltip) self.usb_status.setToolTip("") #endif // QT_CONFIG(tooltip) #if QT_CONFIG(statustip) self.usb_status.setStatusTip(QCoreApplication.translate("MainWindow", u"USB connection status", None)) #endif // QT_CONFIG(statustip) #if QT_CONFIG(whatsthis) self.usb_status.setWhatsThis(QCoreApplication.translate("MainWindow", u"USB Status", None)) #endif // QT_CONFIG(whatsthis) #if QT_CONFIG(statustip) self.button_5.setStatusTip(QCoreApplication.translate("MainWindow", u"Button 5", None)) #endif // QT_CONFIG(statustip) self.button_5.setText("") #if QT_CONFIG(statustip) self.wheel_pos4.setStatusTip(QCoreApplication.translate("MainWindow", u"Wheel position: right 4", None)) #endif // QT_CONFIG(statustip) self.wheel_pos4.setText("") #if QT_CONFIG(statustip) self.wheel_cent0.setStatusTip(QCoreApplication.translate("MainWindow", u"Wheel position: center", None)) #endif // QT_CONFIG(statustip) self.wheel_cent0.setText("") #if QT_CONFIG(statustip) self.wheel_pos1.setStatusTip(QCoreApplication.translate("MainWindow", u"Wheel position: right 1", None)) #endif // QT_CONFIG(statustip) self.wheel_pos1.setText("") #if QT_CONFIG(statustip) self.wheel_pos2.setStatusTip(QCoreApplication.translate("MainWindow", u"Wheel position: right 2", None)) #endif // QT_CONFIG(statustip) self.wheel_pos2.setText("") #if QT_CONFIG(statustip) self.dial.setStatusTip(QCoreApplication.translate("MainWindow", u"Dial", None)) #endif // QT_CONFIG(statustip) #if QT_CONFIG(statustip) self.wheel_neg6.setStatusTip(QCoreApplication.translate("MainWindow", u"Wheel position: left 6", None)) #endif // QT_CONFIG(statustip) self.wheel_neg6.setText("") #if QT_CONFIG(statustip) self.wheel_pos5.setStatusTip(QCoreApplication.translate("MainWindow", u"Wheel position: right 5", None)) #endif // QT_CONFIG(statustip) self.wheel_pos5.setText("") #if QT_CONFIG(statustip) self.button_2.setStatusTip(QCoreApplication.translate("MainWindow", u"Button 2", None)) #endif // QT_CONFIG(statustip) self.button_2.setText("") #if QT_CONFIG(statustip) self.wheel_neg5.setStatusTip(QCoreApplication.translate("MainWindow", u"Wheel position: left 5", None)) #endif // QT_CONFIG(statustip) self.wheel_neg5.setText("") #if QT_CONFIG(statustip) self.wheel_pos6.setStatusTip(QCoreApplication.translate("MainWindow", u"Wheel position: right 6", None)) #endif // QT_CONFIG(statustip) self.wheel_pos6.setText("") #if QT_CONFIG(statustip) self.wheel_neg1.setStatusTip(QCoreApplication.translate("MainWindow", u"Wheel position: left 1", None)) #endif // QT_CONFIG(statustip) self.wheel_neg1.setText("") #if QT_CONFIG(statustip) self.button_4.setStatusTip(QCoreApplication.translate("MainWindow", u"Button 4", None)) #endif // QT_CONFIG(statustip) self.button_4.setText("") #if QT_CONFIG(statustip) self.wheel_pos7.setStatusTip(QCoreApplication.translate("MainWindow", u"Wheel position: right 7", None)) #endif // QT_CONFIG(statustip) self.wheel_pos7.setText("") #if QT_CONFIG(statustip) self.button_3.setStatusTip(QCoreApplication.translate("MainWindow", u"Button 3", None)) #endif // QT_CONFIG(statustip) self.button_3.setText("") #if QT_CONFIG(statustip) self.wheel_neg2.setStatusTip(QCoreApplication.translate("MainWindow", u"Wheel position: left 2", None)) #endif // QT_CONFIG(statustip) self.wheel_neg2.setText("") #if QT_CONFIG(statustip) self.wheel_pos3.setStatusTip(QCoreApplication.translate("MainWindow", u"Wheel position: right 3", None)) #endif // QT_CONFIG(statustip) self.wheel_pos3.setText("") #if QT_CONFIG(statustip) self.wheel_neg3.setStatusTip(QCoreApplication.translate("MainWindow", u"Wheel position: left 3", None)) #endif // QT_CONFIG(statustip) self.wheel_neg3.setText("") #if QT_CONFIG(statustip) self.wheel_neg4.setStatusTip(QCoreApplication.translate("MainWindow", u"Wheel position: left 4", None)) #endif // QT_CONFIG(statustip) self.wheel_neg4.setText(QCoreApplication.translate("MainWindow", u"-", None)) #if QT_CONFIG(statustip) self.wheel_neg7.setStatusTip(QCoreApplication.translate("MainWindow", u"Wheel position: left 7", None)) #endif // QT_CONFIG(statustip) self.wheel_neg7.setText("") #if QT_CONFIG(tooltip) self.about_button.setToolTip("") #endif // QT_CONFIG(tooltip) #if QT_CONFIG(statustip) self.about_button.setStatusTip(QCoreApplication.translate("MainWindow", u"About", None)) #endif // QT_CONFIG(statustip) self.about_button.setText(QCoreApplication.translate("MainWindow", u"?", None)) #if QT_CONFIG(tooltip) self.plug_button.setToolTip("") #endif // QT_CONFIG(tooltip) #if QT_CONFIG(statustip) self.plug_button.setStatusTip(QCoreApplication.translate("MainWindow", u"Configuration", None)) #endif // QT_CONFIG(statustip) self.plug_button.setText(QCoreApplication.translate("MainWindow", u"#", None)) #if QT_CONFIG(tooltip) self.conf_button.setToolTip("") #endif // QT_CONFIG(tooltip) #if QT_CONFIG(statustip) self.conf_button.setStatusTip(QCoreApplication.translate("MainWindow", u"Configuration", None)) #endif // QT_CONFIG(statustip) self.conf_button.setText(QCoreApplication.translate("MainWindow", u"=", None)) self.about_widget.setWindowTitle(QCoreApplication.translate("MainWindow", u"About", None)) self.about_text.setDocumentTitle("") self.log_widget.setWindowTitle(QCoreApplication.translate("MainWindow", u"Log", None)) self.log_clear_button.setText(QCoreApplication.translate("MainWindow", u"Clear", None)) self.config_widget.setWindowTitle(QCoreApplication.translate("MainWindow", u"Configuration", None)) self.plugins_widget.setWindowTitle(QCoreApplication.translate("MainWindow", u"Plugins", None))
class AfterDownloadWindow_Ui(QWidget): def __init__(self, persepolis_setting): super().__init__() self.persepolis_setting = persepolis_setting # add support for other languages locale = str(self.persepolis_setting.value('settings/locale')) QLocale.setDefault(QLocale(locale)) self.translator = QTranslator() if self.translator.load(':/translations/locales/ui_' + locale, 'ts'): QCoreApplication.installTranslator(self.translator) # set ui direction ui_direction = self.persepolis_setting.value('ui_direction') if ui_direction == 'rtl': self.setLayoutDirection(Qt.RightToLeft) elif ui_direction in 'ltr': self.setLayoutDirection(Qt.LeftToRight) icons = ':/' + str( self.persepolis_setting.value('settings/icons')) + '/' self.setWindowIcon( QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg'))) self.setWindowTitle( QCoreApplication.translate("after_download_ui_tr", "Persepolis Download Manager")) # complete_label window_verticalLayout = QVBoxLayout() window_verticalLayout.setContentsMargins(21, 21, 21, 21) self.complete_label = QLabel() window_verticalLayout.addWidget(self.complete_label) # file_name_label self.file_name_label = QLabel() window_verticalLayout.addWidget(self.file_name_label) # size_label self.size_label = QLabel() window_verticalLayout.addWidget(self.size_label) # link self.link_label = QLabel() window_verticalLayout.addWidget(self.link_label) self.link_lineEdit = QLineEdit() window_verticalLayout.addWidget(self.link_lineEdit) # save_as self.save_as_label = QLabel() window_verticalLayout.addWidget(self.save_as_label) self.save_as_lineEdit = QLineEdit() window_verticalLayout.addWidget(self.save_as_lineEdit) # open_pushButtun button_horizontalLayout = QHBoxLayout() button_horizontalLayout.setContentsMargins(10, 10, 10, 10) button_horizontalLayout.addStretch(1) self.open_pushButtun = QPushButton() self.open_pushButtun.setIcon(QIcon(icons + 'file')) button_horizontalLayout.addWidget(self.open_pushButtun) # open_folder_pushButtun self.open_folder_pushButtun = QPushButton() self.open_folder_pushButtun.setIcon(QIcon(icons + 'folder')) button_horizontalLayout.addWidget(self.open_folder_pushButtun) # ok_pushButton self.ok_pushButton = QPushButton() self.ok_pushButton.setIcon(QIcon(icons + 'ok')) button_horizontalLayout.addWidget(self.ok_pushButton) window_verticalLayout.addLayout(button_horizontalLayout) # dont_show_checkBox self.dont_show_checkBox = QCheckBox() window_verticalLayout.addWidget(self.dont_show_checkBox) window_verticalLayout.addStretch(1) self.setLayout(window_verticalLayout) # labels self.open_pushButtun.setText( QCoreApplication.translate("after_download_ui_tr", " Open File ")) self.open_folder_pushButtun.setText( QCoreApplication.translate("after_download_ui_tr", "Open Download Folder")) self.ok_pushButton.setText( QCoreApplication.translate("after_download_ui_tr", " OK ")) self.dont_show_checkBox.setText( QCoreApplication.translate("after_download_ui_tr", "Don't show this message again.")) self.complete_label.setText( QCoreApplication.translate("after_download_ui_tr", "<b>Download Completed!</b>")) self.save_as_label.setText( QCoreApplication.translate("after_download_ui_tr", "<b>Save as</b>: ")) self.link_label.setText( QCoreApplication.translate("after_download_ui_tr", "<b>Link</b>: "))
class UIBuilder(object): """Constructs the UI for a main application window""" def setup(self, main_window: QMainWindow) -> None: """ Initialize the UI. :param main_window: An instance of the `QMainWindow` class. :type main_window: :class:`QMainWindow` """ main_window.setObjectName("main_window") main_window.setWindowTitle("TeaseAI") main_window.resize(1137, 751) main_window.setSizePolicy(*EXP_EXP) main_window.setTabShape(QTabWidget.Rounded) self.menubar = QMenuBar(main_window) self.menubar.setObjectName("menubar") self.menubar.setGeometry(0, 0, 1137, 23) self.file_menu = QMenu("File", self.menubar) self.file_menu.setObjectName("file_men") self.server_menu = QMenu("Server", self.menubar) self.server_menu.setObjectName("server_men") self.options_menu = QMenu("Options", self.menubar) self.options_menu.setObjectName("options_men") self.media_menu = QMenu("Media", self.menubar) self.media_menu.setObjectName("media_men") main_window.setMenuBar(self.menubar) self.exit = QAction("Exit", main_window) self.exit.setObjectName("exit") self.start_server = QAction("Start Server", main_window) self.start_server.setObjectName("start_server") self.connect_server = QAction("Connect to Server", main_window) self.connect_server.setObjectName("connect_server") self.kill_server = QAction("Kill Server", main_window) self.kill_server.setObjectName("kill_server") self.options = QAction("Options", main_window) self.options.setObjectName("options") self.start_webcam = QAction("Start Webcam", main_window) self.start_webcam.setObjectName("start_webcam") self.start_webcam.setCheckable(False) self.centralwidget = QWidget(main_window) self.centralwidget.setObjectName("centralwidget") self.centralwidget.setContentsMargins(QMargins(0, 0, 0, 0)) self.centralwidget.setSizePolicy(*EXP_EXP) self.grid_layout = QGridLayout(self.centralwidget) self.media = QFrame(self.centralwidget) self.media.setObjectName("media") self.media.setSizePolicy(*EXP_EXP) self.media.setMinimumSize(200, 200) self.media.setStyleSheet("background: #000;") self.grid_layout.addWidget(self.media, 0, 0, 5, 1) self.users_label = QLabel(" Online users:", self.centralwidget) self.users_label.setObjectName("users_label") self.users_label.setMinimumSize(300, 15) self.users_label.setMaximumSize(300, 15) self.grid_layout.addWidget(self.users_label, 0, 1, 1, 2) self.online = QPlainTextEdit("", self.centralwidget) self.online.setObjectName("online") self.online.setSizePolicy(*FIX_FIX) self.online.setMinimumSize(300, 50) self.online.setMaximumSize(300, 50) self.online.setStyleSheet("margin-left: 3px;" + SUNKEN) self.online.setLineWidth(2) self.online.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.online.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.online.setSizeAdjustPolicy(QAbstractScrollArea.AdjustIgnored) self.online.setReadOnly(True) self.grid_layout.addWidget(self.online, 1, 1, 1, 2) self.chat = QPlainTextEdit("", self.centralwidget) self.chat.setObjectName("chat") self.chat.setSizePolicy(*FIX_EXP) self.chat.setMinimumSize(300, 0) self.chat.setMaximumSize(300, INFINITE) self.chat.setStyleSheet("margin-bottom: 3px; margin-top: 8px;" + SUNKEN) self.chat.setLineWidth(2) self.chat.setReadOnly(True) self.chat.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.grid_layout.addWidget(self.chat, 2, 1, 1, 2) self.input = QLineEdit(self.centralwidget) self.input.setObjectName("input") self.input.setSizePolicy(*FIX_FIX) self.input.setMinimumSize(224, 30) self.input.setMaximumSize(224, 30) self.input.setStyleSheet(SUNKEN) self.input.setEchoMode(QLineEdit.Normal) self.input.setClearButtonEnabled(True) self.grid_layout.addWidget(self.input, 3, 1, 1, 1) self.submit = QPushButton("Submit", self.centralwidget) self.submit.setObjectName("submit") self.submit.setSizePolicy(*FIX_FIX) self.submit.setMinimumSize(70, 30) self.submit.setMaximumSize(70, 30) self.grid_layout.addWidget(self.submit, 3, 2, 1, 1) self.tabs = QTabWidget(self.centralwidget) self.tabs.setObjectName("tabs") self.tabs.setSizePolicy(*FIX_FIX) self.tabs.setMinimumSize(300, 150) self.tabs.setMaximumSize(300, 150) self.tab = QWidget() self.tab.setObjectName("tab") self.tabs.addTab(self.tab, "Actions") self.tab2 = QWidget() self.tab2.setObjectName("tab2") self.tabs.addTab(self.tab2, "My Media") self.tab3 = QWidget() self.tab3.setObjectName("tab3") self.tab3.setSizePolicy(*FIX_FIX) self.grid_layout2 = QGridLayout(self.tab3) self.grid_layout2.setHorizontalSpacing(0) self.grid_layout2.setVerticalSpacing(3) self.grid_layout2.setContentsMargins(3, -1, 3, -1) self.server_folder = QLineEdit(self.tab3) self.server_folder.setObjectName("server_folder") self.grid_layout2.addWidget(self.server_folder, 0, 0, 1, 3) self.srv_browse = QPushButton("BROWSE", self.tab3) self.srv_browse.setObjectName("srv_browse") self.srv_browse.setStyleSheet("background: transparent;\n" " color: #4d4940;\n" " font-size: 8pt;\n" " font-weight: 450;\n" " padding: 6px;\n") self.grid_layout2.addWidget(self.srv_browse, 0, 3, 1, 1) self.back_button = QPushButton("", self.tab3) self.back_button.setObjectName("back_button") self.back_button.setSizePolicy(*FIX_FIX) self.back_button.setMaximumSize(SEVENTY_FIVE) self.back_button.setCursor(QCursor(Qt.PointingHandCursor)) self.back_button.setStyleSheet("border: 0;\n" "background: transparent;") icon = QIcon() icon.addFile(":/newPrefix/back_button.png", SIXTY_FOUR, QIcon.Normal, QIcon.Off) self.back_button.setIcon(icon) self.back_button.setIconSize(SIXTY_FOUR) self.grid_layout2.addWidget(self.back_button, 1, 0, 1, 1) self.play_button = QPushButton("", self.tab3) self.play_button.setObjectName("play_button") self.play_button.setSizePolicy(*FIX_FIX) self.play_button.setMaximumSize(SEVENTY_FIVE) self.play_button.setCursor(QCursor(Qt.PointingHandCursor)) self.play_button.setStyleSheet("border: 0;\n" "background: transparent;") icon1 = QIcon() icon1.addFile(":/newPrefix/play_button.png", SIXTY_FOUR, QIcon.Normal, QIcon.Off) self.play_button.setIcon(icon1) self.play_button.setIconSize(SIXTY_FOUR) self.grid_layout2.addWidget(self.play_button, 1, 1, 1, 1) self.stop_button = QPushButton("", self.tab3) self.stop_button.setObjectName("stop_button") self.stop_button.setSizePolicy(*FIX_FIX) self.stop_button.setMaximumSize(SEVENTY_FIVE) self.stop_button.setCursor(QCursor(Qt.PointingHandCursor)) self.stop_button.setStyleSheet("border: 0;\n" "background: transparent;") icon2 = QIcon() icon2.addFile(":/newPrefix/stop_button.png", SIXTY_FOUR, QIcon.Normal, QIcon.Off) self.stop_button.setIcon(icon2) self.stop_button.setIconSize(SIXTY_FOUR) self.grid_layout2.addWidget(self.stop_button, 1, 2, 1, 1) self.fast_forward = QPushButton("", self.tab3) self.fast_forward.setObjectName("fast_forward") self.fast_forward.setSizePolicy(*FIX_FIX) self.fast_forward.setMaximumSize(SEVENTY_FIVE) self.fast_forward.setCursor(QCursor(Qt.PointingHandCursor)) self.fast_forward.setStyleSheet("border: 0;\n" "background: transparent;") icon3 = QIcon() icon3.addFile(":/newPrefix/fast_forward.png", SIXTY_FOUR, QIcon.Normal, QIcon.Off) self.fast_forward.setIcon(icon3) self.fast_forward.setIconSize(SIXTY_FOUR) self.grid_layout2.addWidget(self.fast_forward, 1, 3, 1, 1) self.tabs.addTab(self.tab3, "Server Media") self.grid_layout.addWidget(self.tabs, 4, 1, 1, 2) main_window.setCentralWidget(self.centralwidget) self.statusbar = QStatusBar(main_window) self.statusbar.setObjectName("statusbar") self.statusbar.setEnabled(True) self.statusbar.setStyleSheet("margin-bottom: 5px;") self.statusbar.setSizePolicy(*EXP_FIX) self.statusbar.setMinimumSize(INFINITE, 30) self.statusbar.setMaximumSize(INFINITE, 30) self.statusbar.setSizeGripEnabled(False) main_window.setStatusBar(self.statusbar) self.menubar.addAction(self.file_menu.menuAction()) self.menubar.addAction(self.server_menu.menuAction()) self.menubar.addAction(self.options_menu.menuAction()) self.menubar.addAction(self.media_menu.menuAction()) self.file_menu.addAction(self.exit) self.server_menu.addAction(self.start_server) self.server_menu.addAction(self.connect_server) self.server_menu.addAction(self.kill_server) self.options_menu.addAction(self.options) self.media_menu.addAction(self.start_webcam) self.exit.triggered.connect(main_window.close) self.tabs.setCurrentIndex(0) QMetaObject.connectSlotsByName(main_window) self.exit.setStatusTip("Exit the program.") self.start_server.setStatusTip("Initialize a local server instance.") self.connect_server.setStatusTip("Connect to a remote server.") self.kill_server.setStatusTip("Shut down a running local server.") self.options.setStatusTip("Open the options menu.") self.start_webcam.setStatusTip("Start webcam feed.") self.tooltip = QLabel("", self.statusbar) tooltip_policy = QSizePolicy(*EXP_FIX) tooltip_policy.setHorizontalStretch(100) self.tooltip.setSizePolicy(tooltip_policy) self.tooltip.setMinimumSize(INFINITE, 26) self.tooltip.setMaximumSize(INFINITE, 26) self.server_status = QLabel("Server status:", self.statusbar) self.server_status.setSizePolicy(*FIX_FIX) self.server_status.setMinimumSize(300, 26) self.server_status.setMaximumSize(300, 26) self.client_status = QLabel("Client status:", self.statusbar) self.client_status.setSizePolicy(*FIX_FIX) self.client_status.setMinimumSize(302, 26) self.client_status.setMaximumSize(302, 26) self.statusbar.addPermanentWidget(self.tooltip) self.statusbar.addPermanentWidget(self.server_status) self.statusbar.addPermanentWidget(self.client_status) self.tooltip.setStyleSheet(SUNKEN + "margin-left: 4px;\ margin-right: 0px;") self.client_status.setStyleSheet(SUNKEN + "margin-right: 7px;") self.server_status.setStyleSheet(SUNKEN + "margin-right: 2px;\ margin-left: 2px;") self.statusbar.messageChanged.connect(main_window.status_tip)
def __init__(self, db: SqlDB): super().__init__() self.setWidgetResizable(True) self.db = db self.icons = Icons() base = QWidget() base.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) self.setWidget(base) grid = QGridLayout() grid.setColumnStretch(0, 1) grid.setColumnStretch(1, 1) grid.setColumnStretch(2, 2) grid.setColumnStretch(3, 1) grid.setColumnStretch(4, 1) grid.setColumnStretch(5, 1) base.setLayout(grid) row = 0 # _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_ # SUPPLIER Label supplier = QLabel('SUPPLIER') supplier.setStyleSheet( "QLabel {font-size:14pt; padding: 0 2px; background: #ddf;}") supplier.setFrameStyle(QFrame.StyledPanel | QFrame.Plain) grid.addWidget(supplier, row, 0, 1, 6) row += 1 # --------------------------------------------------------------------- # SUPPLIER NAME SHORT lab_name_supplier_short = QLabel('SHORT NAME') lab_name_supplier_short.setStyleSheet( "QLabel {font-size:10pt; padding: 0 2px;}") lab_name_supplier_short.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) ent_name_supplier_short = QLineEdit() ent_name_supplier_short.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) but_name_supplier_short = QPushButton() but_name_supplier_short.setIcon(QIcon(self.icons.CHECK)) but_name_supplier_short.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding) grid.addWidget(lab_name_supplier_short, row, 0) grid.addWidget(ent_name_supplier_short, row, 1) grid.addWidget(but_name_supplier_short, row, 5, 3, 1) row += 1 # --------------------------------------------------------------------- # SUPPLIER NAME FULL lab_name_supplier = QLabel('FULL NAME') lab_name_supplier.setStyleSheet( "QLabel {font-size:10pt; padding: 0 2px;}") lab_name_supplier.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) ent_name_supplier = QLineEdit() ent_name_supplier.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) grid.addWidget(lab_name_supplier, row, 0) grid.addWidget(ent_name_supplier, row, 1, 1, 4) row += 1 # --------------------------------------------------------------------- # SUPPLIER NAME in local language lab_name_supplier_local = QLabel('Local NAME') lab_name_supplier_local.setStyleSheet( "QLabel {font-size:10pt; padding: 0 2px;}") lab_name_supplier_local.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) ent_name_supplier_local = QLineEdit() ent_name_supplier_local.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) grid.addWidget(lab_name_supplier_local, row, 0) grid.addWidget(ent_name_supplier_local, row, 1, 1, 4) row += 1 # click on but_name_supplier_short but_name_supplier_short.clicked.connect( lambda: self.on_click_set_supplier(ent_name_supplier_short, ent_name_supplier, ent_name_supplier_local)) # _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_ # PART Label part = QLabel('PART') part.setStyleSheet( "QLabel {font-size:14pt; padding: 0 2px; background: #ddf;}") part.setFrameStyle(QFrame.StyledPanel | QFrame.Plain) grid.addWidget(part, row, 0, 1, 6) row += 1 # --------------------------------------------------------------------- # PART NUMBER lab_num_part = QLabel('PART#') lab_num_part.setStyleSheet("QLabel {font-size:10pt; padding: 0 2px;}") lab_num_part.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) ent_num_part = QLineEdit() ent_num_part.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) but_num_part = QPushButton() but_num_part.setIcon(QIcon(self.icons.CHECK)) but_num_part.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding) grid.addWidget(lab_num_part, row, 0) grid.addWidget(ent_num_part, row, 1) grid.addWidget(but_num_part, row, 5, 5, 1) row += 1 # --------------------------------------------------------------------- # Original PART NUMBER lab_num_part_orig = QLabel('Orig. PART#') lab_num_part_orig.setStyleSheet( "QLabel {font-size:10pt; padding: 0 2px;color: gray;}") lab_num_part_orig.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) combo_num_part_orig = QComboBox() combo_num_part_orig.setEnabled(False) combo_num_part_orig.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) check_num_part_orig = QCheckBox('use original drawing') check_num_part_orig.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) check_num_part_orig.stateChanged.connect( lambda: self.getPartsOptionCombo( lab_num_part_orig, combo_num_part_orig, check_num_part_orig)) grid.addWidget(lab_num_part_orig, row, 0) grid.addWidget(combo_num_part_orig, row, 1) grid.addWidget(check_num_part_orig, row, 2, 1, 3) row += 1 # --------------------------------------------------------------------- # PART Description lab_desc_part = QLabel('Description') lab_desc_part.setStyleSheet("QLabel {font-size:10pt; padding: 0 2px;}") lab_desc_part.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) ent_desc_part = QLineEdit() ent_desc_part.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) grid.addWidget(lab_desc_part, row, 0) grid.addWidget(ent_desc_part, row, 1, 1, 4) row += 1 # --------------------------------------------------------------------- # PART Supplier lab_part_supplier = QLabel('Part Supplier') lab_part_supplier.setStyleSheet( "QLabel {font-size:10pt; padding: 0 2px;}") lab_part_supplier.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) combo_part_supplier = QComboBox() self.add_supplier_list_to_combo(combo_part_supplier) combo_part_supplier.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) grid.addWidget(lab_part_supplier, row, 0) grid.addWidget(combo_part_supplier, row, 1) row += 1 # --------------------------------------------------------------------- # Assy PART NUMBER lab_num_part_assy = QLabel('Assy PART#') lab_num_part_assy.setStyleSheet( "QLabel {font-size:10pt; padding: 0 2px;color: gray;}") lab_num_part_assy.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) combo_num_part_assy = QComboBox() combo_num_part_assy.setEnabled(False) combo_num_part_assy.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) check_num_part_assy = QCheckBox('link to Assy') check_num_part_assy.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) #check_num_part_assy.stateChanged.connect( # lambda: self.getPartsOptionCombo( # lab_num_part_assy, # combo_num_part_assy, # check_num_part_assy # ) #) grid.addWidget(lab_num_part_assy, row, 0) grid.addWidget(combo_num_part_assy, row, 1) grid.addWidget(check_num_part_assy, row, 2, 1, 3) row += 1 # click on but_num_part but_num_part.clicked.connect(lambda: self.on_click_set_part( ent_num_part, combo_num_part_orig, check_num_part_orig, ent_desc_part, combo_part_supplier)) # _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_ # Drawing Label drawing = QLabel('Drawing') drawing.setStyleSheet( "QLabel {font-size:14pt; padding: 0 2px; background: #ddf;}") drawing.setFrameStyle(QFrame.StyledPanel | QFrame.Plain) grid.addWidget(drawing, row, 0, 1, 6) row += 1 # --------------------------------------------------------------------- # PART Number lab_num_part_drawing = QLabel('Part#') lab_num_part_drawing.setStyleSheet( "QLabel {font-size:10pt; padding: 0 2px;}") lab_num_part_drawing.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) combo_num_part_drawing = QComboBox() combo_num_part_drawing.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) combo_num_part_drawing.setEnabled(False) self.getParts4Combo(combo_num_part_drawing) lab_num_supplier_drawing = QLabel() lab_num_supplier_drawing.setStyleSheet( "QLabel {font-size:10pt; padding: 0 2px; color:gray;}") lab_num_supplier_drawing.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) but_num_part_drawing = QPushButton() but_num_part_drawing.setIcon(QIcon(self.icons.CHECK)) but_num_part_drawing.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding) grid.addWidget(lab_num_part_drawing, row, 0) grid.addWidget(combo_num_part_drawing, row, 1) grid.addWidget(lab_num_supplier_drawing, row, 2, 1, 3) grid.addWidget(but_num_part_drawing, row, 5, 4, 1) row += 1 # --------------------------------------------------------------------- # PART Drawing Description lab_num_desc_drawing = QLabel() lab_num_desc_drawing.setStyleSheet( "QLabel {font-size:10pt; padding: 0 2px; color:gray;}") lab_num_desc_drawing.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) grid.addWidget(lab_num_desc_drawing, row, 1, 1, 4) row += 1 self.part_selection_change(combo_num_part_drawing, lab_num_supplier_drawing, lab_num_desc_drawing) combo_num_part_drawing.currentIndexChanged.connect( lambda: self.part_selection_change(combo_num_part_drawing, lab_num_supplier_drawing, lab_num_desc_drawing)) # --------------------------------------------------------------------- # PART Drawing Revision lab_rev_drawing = QLabel('Revision') lab_rev_drawing.setStyleSheet( "QLabel {font-size:10pt; padding: 0 2px;}") lab_rev_drawing.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) ent_rev_drawing = QLineEdit() ent_rev_drawing.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) grid.addWidget(lab_rev_drawing, row, 0) grid.addWidget(ent_rev_drawing, row, 1) row += 1 # --------------------------------------------------------------------- # PART Drawing file lab_file_drawing = QLabel('PDF file') lab_file_drawing.setStyleSheet( "QLabel {font-size:10pt; padding: 0 2px;}") lab_file_drawing.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) ent_file_drawing = QLineEdit() ent_file_drawing.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) but_file_drawing = QPushButton() but_file_drawing.setIcon(QIcon(self.icons.PDF)) but_file_drawing.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) grid.addWidget(lab_file_drawing, row, 0) grid.addWidget(ent_file_drawing, row, 1, 1, 3) grid.addWidget(but_file_drawing, row, 4) row += 1