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"))
def __init__(self, parent, dict, persepolis_setting): super().__init__(persepolis_setting) self.persepolis_setting = persepolis_setting self.dict = dict self.parent = parent # 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) # connecting buttons self.open_pushButtun.clicked.connect(self.openFile) self.open_folder_pushButtun.clicked.connect(self.openFolder) self.ok_pushButton.clicked.connect(self.okButtonPressed) # labels # find gid gid = self.dict['gid'] # get file_path from data base self.add_link_dict = self.parent.persepolis_db.searchGidInAddLinkTable(gid) file_path = self.add_link_dict['download_path'] # save_as self.save_as_lineEdit.setText(file_path) self.save_as_lineEdit.setToolTip(file_path) # link link = str(self.dict['link']) self.link_lineEdit.setText(link) self.link_lineEdit.setToolTip(link) # file_name window_title = str(self.dict['file_name']) file_name = QCoreApplication.translate("after_download_src_ui_tr", "<b>File name</b>: ") + \ window_title self.setWindowTitle(window_title) self.file_name_label.setText(file_name) # size size = QCoreApplication.translate("after_download_src_ui_tr", "<b>Size</b>: ") + str(self.dict['size']) self.size_label.setText(size) # disable link_lineEdit and save_as_lineEdit self.link_lineEdit.setEnabled(False) self.save_as_lineEdit.setEnabled(False) # set window size and position size = self.persepolis_setting.value( 'AfterDownloadWindow/size', QSize(570, 290)) position = self.persepolis_setting.value( 'AfterDownloadWindow/position', QPoint(300, 300)) self.resize(size) self.move(position)
def __init__(self, parent, gid, persepolis_setting): super().__init__(persepolis_setting) self.persepolis_setting = persepolis_setting self.parent = parent self.gid = gid self.status = None self.resume_pushButton.clicked.connect(self.resumePushButtonPressed) self.stop_pushButton.clicked.connect(self.stopPushButtonPressed) self.pause_pushButton.clicked.connect(self.pausePushButtonPressed) self.download_progressBar.setValue(0) self.limit_pushButton.clicked.connect(self.limitPushButtonPressed) self.limit_frame.setEnabled(False) self.limit_checkBox.toggled.connect(self.limitCheckBoxToggled) self.after_frame.setEnabled(False) self.after_checkBox.toggled.connect(self.afterCheckBoxToggled) self.after_pushButton.clicked.connect(self.afterPushButtonPressed) # 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) # check if limit speed activated by user or not add_link_dictionary = self.parent.persepolis_db.searchGidInAddLinkTable( gid) limit = str(add_link_dictionary['limit_value']) if limit != '0': limit_number = limit[:-1] limit_unit = limit[-1] self.limit_spinBox.setValue(float(limit_number)) if limit_unit == 'K': self.after_comboBox.setCurrentIndex(0) else: self.after_comboBox.setCurrentIndex(1) self.limit_checkBox.setChecked(True) self.after_comboBox.currentIndexChanged.connect( self.afterComboBoxChanged) self.limit_comboBox.currentIndexChanged.connect( self.limitComboBoxChanged) self.limit_spinBox.valueChanged.connect(self.limitComboBoxChanged) # set window size and position size = self.persepolis_setting.value('ProgressWindow/size', QSize(595, 274)) position = self.persepolis_setting.value('ProgressWindow/position', QPoint(300, 300)) self.resize(size) self.move(position)
def __formatDecimal(self, num): if self.settings['showGroupSeparator']: decStr = '{:,}'.format(num) if self.__groupSeparator() == QLocale.system().groupSeparator(): return decStr return decStr.replace(QLocale.system().groupSeparator(), self.__groupSeparator()) else: return '%d' % num
def onLanguageChanged(self, action): language_code = action.data() if language_code != self.currentLanguage: JalSettings().setValue('Language', JalDB().get_language_id(language_code)) QMessageBox().information(self, self.tr("Restart required"), self.tr("Language was changed to ") + QLocale.languageToString(QLocale(language_code).language()) + "\n" + self.tr("You should restart application to apply changes\n" "Application will be terminated now"), QMessageBox.Ok) self.close()
def createLanguageMenu(self): langPath = get_app_path() + Setup.LANG_PATH + os.sep langDirectory = QDir(langPath) for language_file in langDirectory.entryList(['*.qm']): language_code = language_file.split('.')[0] language = QLocale.languageToString(QLocale(language_code).language()) language_icon = QIcon(langPath + language_code + '.png') action = QAction(language_icon, language, self) action.setCheckable(True) action.setData(language_code) self.menuLanguage.addAction(action) self.langGroup.addAction(action)
def setEditorData(self, editor, index): if index.column() == self._key: editor.setCurrentIndex( editor.findData(index.model().data(index, Qt.EditRole))) elif index.column() == self._value: type_idx = index.model().data(index.sibling( index.row(), self._key), role=Qt.EditRole) if self.types[type_idx][1] == "str": editor.setText(index.model().data(index, Qt.EditRole)) elif self.types[type_idx][1] == "date": try: timestamp = int(index.model().data(index, Qt.EditRole)) editor.setDateTime( QDateTime.fromSecsSinceEpoch(timestamp, spec=Qt.UTC)) except ValueError: QStyledItemDelegate.setEditorData(self, editor, index) elif self.types[type_idx][1] == "float": try: amount = float(index.model().data(index, Qt.EditRole)) except (ValueError, TypeError): amount = 0.0 # QLocale().toString works in a bit weird way with float formatting - garbage appears after 5-6 decimal digits # if too long precision is specified for short number. So we need to be more precise setting precision. decimal_places = -decimal.Decimal( str(amount).rstrip('0')).as_tuple().exponent editor.setText(QLocale().toString(amount, 'f', decimal_places)) else: assert False, f"Unknown data type '{self.types[type_idx][1]}' in DataDelegate.setEditorData()" else: assert False, f"Delegate DataDelegate.setEditorData() called for not-initialized column {index.column()}"
def __groupSeparator(self): if self.settings['decimalPointGroupSeparator'] == 1: return '.' elif self.settings['decimalPointGroupSeparator'] == 2: return ',' else: return QLocale.system().groupSeparator()
def formatFloatLong(self, value): precision = self._tolerance decimal_places = -decimal.Decimal( str(value).rstrip('0')).as_tuple().exponent if self._allow_tail and (decimal_places > self._tolerance): precision = decimal_places return QLocale().toString(value, 'f', precision)
def setEditorData(self, editor, index): try: amount = float(index.model().data(index, Qt.EditRole)) except (ValueError, TypeError): amount = 0.0 # QLocale().toString works in a bit weird way with float formatting - garbage appears after 5-6 decimal digits # if too long precision is specified for short number. So we need to be more precise setting precision. decimal_places = -decimal.Decimal( str(amount).rstrip('0')).as_tuple().exponent editor.setText(QLocale().toString(amount, 'f', decimal_places))
def __init__(self, tolerance=None, allow_tail=True, colors=False, parent=None): self._parent = parent QStyledItemDelegate.__init__(self, parent) try: self._tolerance = int(tolerance) except (ValueError, TypeError): self._tolerance = self.DEFAULT_TOLERANCE self._allow_tail = allow_tail self._colors = colors self._color = None self._validator = QDoubleValidator() self._validator.setLocale(QLocale().system())
def data_text(self, data, column): if column == 0: if data['level'] == 0: return data['currency'] elif data['level'] == 1: return data['account'] else: return data['asset'] elif column == 1: expiry_text = "" if data['expiry']: expiry_date = datetime.utcfromtimestamp(data['expiry']) expiry_header = self.tr("Exp:") expiry_text = f" [{expiry_header} {expiry_date.strftime('%d.%m.%Y')}]" return data['asset_name'] + expiry_text elif column == 2: if data['qty']: if data['asset_is_currency']: decimal_places = 2 else: decimal_places = -decimal.Decimal( str(data['qty']).rstrip('0')).as_tuple().exponent decimal_places = 6 if decimal_places > 6 else decimal_places return QLocale().toString(data['qty'], 'f', decimal_places) else: return '' elif column == 3: if data['qty'] != 0 and data['value_i'] != 0: return f"{(data['value_i'] / data['qty']):,.4f}" else: return '' elif column == 4: return f"{data['quote']:,.4f}" if data[ 'quote'] and data['qty'] != 0 else '' elif column == 5: return f"{data['share']:,.2f}" if data['share'] else '-.--' elif column == 6: return f"{100.0 * data['profit_rel']:,.2f}" if data[ 'profit_rel'] else '' elif column == 7: return f"{data['profit']:,.2f}" if data['profit'] else '' elif column == 8: return f"{data['value']:,.2f}" if data['value'] else '' elif column == 9: return f"{data['value_a']:,.2f}" if data['value_a'] else '-.--' else: assert False
def setModelData(self, editor, model, index): if index.column() == self._key: model.setData(index, editor.currentData()) model.setData(index.sibling(index.row(), self._value), '') # Reset data value on type change elif index.column() == self._value: type_idx = index.model().data(index.sibling( index.row(), self._key), role=Qt.EditRole) if self.types[type_idx][1] == "str": model.setData(index, editor.text()) elif self.types[type_idx][1] == "date": timestamp = editor.dateTime().toSecsSinceEpoch() model.setData(index, str(timestamp)) elif self.types[type_idx][1] == "float": value = QLocale().toDouble(editor.text())[0] model.setData(index, value) else: assert False, f"Unknown data type '{self.types[type_idx][1]}' in DataDelegate.setModelData()" else: assert False, f"Delegate DataDelegate.setModelData() called for not-initialized column {index.column()}"
def SetLanguage(self, app, owner): language = config.Language # Auto if language == 0: locale = QLocale.system().name() Log.Info("Init translate {}".format(locale)) if locale[:3].lower() == "zh_": if locale.lower() == "zh_cn": language = 1 else: language = 2 else: language = 3 if language == 1: app.removeTranslator(self.translate) elif language == 2: self.translate.load(":/tr_hk.qm") app.installTranslator(self.translate) else: self.translate.load(":/tr_en.qm") app.installTranslator(self.translate) owner.RetranslateUi()
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'))
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)
def __init__(self, parent, receiver_slot, settings, video_dict={}): super().__init__(parent, receiver_slot, settings, video_dict) self.setWindowTitle( QCoreApplication.translate("ytaddlink_src_ui_tr", 'Video Finder')) self.size_label.hide() # empty lists for no_audio and no_video and video_audio files self.no_audio_list = [] self.no_video_list = [] self.video_audio_list = [] self.media_title = '' # add support for other languages locale = str(self.persepolis_setting.value('settings/locale')) QLocale.setDefault(QLocale(locale)) self.translator = QTranslator() if self.translator.load(':/translations/locales/ui_' + locale, 'ts'): QCoreApplication.installTranslator(self.translator) # extension_label self.extension_label = QLabel(self.link_frame) self.change_name_horizontalLayout.addWidget(self.extension_label) # Fetch Button self.url_submit_pushButtontton = QPushButton(self.link_frame) self.link_horizontalLayout.addWidget(self.url_submit_pushButtontton) # Status Box self.status_box_textEdit = QTextEdit(self.link_frame) self.status_box_textEdit.setMaximumHeight(150) self.link_verticalLayout.addWidget(self.status_box_textEdit) # Select format horizontal layout select_format_horizontalLayout = QHBoxLayout() # Selection Label self.select_format_label = QLabel(self.link_frame) select_format_horizontalLayout.addWidget(self.select_format_label) # Selection combobox self.media_comboBox = QComboBox(self.link_frame) self.media_comboBox.setMinimumWidth(200) select_format_horizontalLayout.addWidget(self.media_comboBox) # Duration label self.duration_label = QLabel(self.link_frame) select_format_horizontalLayout.addWidget(self.duration_label) self.format_selection_frame = QFrame(self) self.format_selection_frame.setLayout(select_format_horizontalLayout) self.link_verticalLayout.addWidget(self.format_selection_frame) # advanced_format_selection_checkBox self.advanced_format_selection_checkBox = QCheckBox(self) self.link_verticalLayout.addWidget( self.advanced_format_selection_checkBox) # advanced_format_selection_frame self.advanced_format_selection_frame = QFrame(self) self.link_verticalLayout.addWidget( self.advanced_format_selection_frame) advanced_format_selection_horizontalLayout = QHBoxLayout( self.advanced_format_selection_frame) # video_format_selection self.video_format_selection_label = QLabel( self.advanced_format_selection_frame) self.video_format_selection_comboBox = QComboBox( self.advanced_format_selection_frame) # audio_format_selection self.audio_format_selection_label = QLabel( self.advanced_format_selection_frame) self.audio_format_selection_comboBox = QComboBox( self.advanced_format_selection_frame) for widget in [ self.video_format_selection_label, self.video_format_selection_comboBox, self.audio_format_selection_label, self.audio_format_selection_comboBox ]: advanced_format_selection_horizontalLayout.addWidget(widget) # Set Texts self.url_submit_pushButtontton.setText( QCoreApplication.translate("ytaddlink_src_ui_tr", 'Fetch Media List')) self.select_format_label.setText( QCoreApplication.translate("ytaddlink_src_ui_tr", 'Select a format')) self.video_format_selection_label.setText( QCoreApplication.translate("ytaddlink_src_ui_tr", 'Video format:')) self.audio_format_selection_label.setText( QCoreApplication.translate("ytaddlink_src_ui_tr", 'Audio format:')) self.advanced_format_selection_checkBox.setText( QCoreApplication.translate("ytaddlink_src_ui_tr", 'Advanced options')) # Add Slot Connections self.url_submit_pushButtontton.setEnabled(False) self.change_name_lineEdit.setEnabled(False) self.ok_pushButton.setEnabled(False) self.download_later_pushButton.setEnabled(False) self.format_selection_frame.setEnabled(True) self.advanced_format_selection_frame.setEnabled(False) self.advanced_format_selection_checkBox.toggled.connect( self.advancedFormatFrame) self.url_submit_pushButtontton.clicked.connect(self.submitClicked) self.media_comboBox.activated.connect( partial(self.mediaSelectionChanged, 'video_audio')) self.video_format_selection_comboBox.activated.connect( partial(self.mediaSelectionChanged, 'video')) self.audio_format_selection_comboBox.activated.connect( partial(self.mediaSelectionChanged, 'audio')) self.link_lineEdit.textChanged.disconnect( super().linkLineChanged) # Should be disconnected. self.link_lineEdit.textChanged.connect(self.linkLineChangedHere) self.setMinimumSize(650, 480) self.status_box_textEdit.hide() self.format_selection_frame.hide() self.advanced_format_selection_frame.hide() self.advanced_format_selection_checkBox.hide() if 'link' in video_dict.keys() and video_dict['link']: self.link_lineEdit.setText(video_dict['link']) self.url_submit_pushButtontton.setEnabled(True) else: # check clipboard clipboard = QApplication.clipboard() text = clipboard.text() if (("tp:/" in text[2:6]) or ("tps:/" in text[2:7])): self.link_lineEdit.setText(str(text)) self.url_submit_pushButtontton.setEnabled(True)
def __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>: "))
def ja_jp_locale(): return QLocale(QLocale.Japanese, QLocale.Japan)
def __init__(self, persepolis_setting): super().__init__() # defining UI self.persepolis_setting = persepolis_setting icons = ':/' + \ str(self.persepolis_setting.value('settings/icons')) + '/' self.setWindowIcon( QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg'))) # 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.setWindowTitle( QCoreApplication.translate("update_src_ui_tr", 'Checking for newer version')) # installed version self.client_version = '3.20' # first line text self.update_label = QLabel( QCoreApplication.translate( "update_src_ui_tr", "The newest is the best, we recommend to update Persepolis.")) self.update_label.setTextFormat(QtCore.Qt.RichText) self.update_label.setAlignment(QtCore.Qt.AlignCenter) # second line text self.version_label = QLabel( QCoreApplication.translate( "update_src_ui_tr", 'This is Persepolis Download Manager version 3.2.0')) self.version_label.setAlignment(QtCore.Qt.AlignCenter) # release link self.link_label = QLabel( '<a href=https://github.com/persepolisdm/persepolis/releases>https://github.com/persepolisdm/persepolis/releases</a>' ) self.link_label.setAlignment(QtCore.Qt.AlignCenter) self.link_label.setOpenExternalLinks(True) # version status self.status_label = QLabel() self.status_label.setTextFormat(QtCore.Qt.RichText) self.status_label.setAlignment(QtCore.Qt.AlignCenter) # update button self.check_button = QPushButton( QCoreApplication.translate("update_src_ui_tr", "Check for new update")) self.check_button.clicked.connect(self.updateCheck) # verticalLayout vbox = QVBoxLayout() vbox.addWidget(self.update_label) vbox.addWidget(self.version_label) vbox.addWidget(self.link_label) vbox.addWidget(self.check_button) vbox.addWidget(self.status_label) # horizontalLayout hbox = QHBoxLayout() hbox.addLayout(vbox) # window layout self.setLayout(hbox) # window size and position size = self.persepolis_setting.value('checkupdate/size', QSize(360, 250)) position = self.persepolis_setting.value('checkupdate/position', QPoint(300, 300)) self.resize(size) self.move(position)
) self.translate("CONTEXT", "EVEN MORE TEXT", "A COMMENT WITH PLURALIZATION", 42) self.translate( "CONTEXT", "YET MORE TEXT", "A COMMENT WITH PLURALIZATION AND A TRAILING COMMA", 42, ) self.translate( "CONTEXT", "SOME TEXT, SHOULD NOT BE EXTRACTED", "A COMMENT WITH PLURALIZATION AND A TRAILING COMMA AND GARBAGE", 42, "THIS SHOULD NOT WORK") if __name__ == '__main__': app = QApplication(sys.argv) path = QLibraryInfo.location(QLibraryInfo.TranslationsPath) translator = QTranslator(app) if translator.load(QLocale.system(), 'qtbase_', '', path): app.installTranslator(translator) translator = QTranslator(app) path = ':/translations' if translator.load(QLocale.system(), 'example_', '', path): app.installTranslator(translator) window = Window() window.show() sys.exit(app.exec())
def __init__(self, parent, persepolis_setting): super().__init__(persepolis_setting) self.persepolis_setting = persepolis_setting self.parent = parent self.grandparent = parent.persepolis_main self.persepolis_setting.beginGroup('settings') # initialization self.tries_spinBox.setValue( int(self.persepolis_setting.value('max-tries'))) self.wait_spinBox.setValue( int(self.persepolis_setting.value('retry-wait'))) self.time_out_spinBox.setValue( int(self.persepolis_setting.value('timeout'))) self.connections_spinBox.setValue( int(self.persepolis_setting.value('connections'))) self.rpc_port_spinbox.setValue( int(self.persepolis_setting.value('rpc-port'))) if str(self.persepolis_setting.value( 'dont-check-certificate')) == 'yes': self.dont_check_certificate_checkBox.setChecked(True) else: self.dont_check_certificate_checkBox.setChecked(False) # 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) # wait_queue wait_queue_list = self.persepolis_setting.value('wait-queue') try: q_time = QTime(int(wait_queue_list[0]), int(wait_queue_list[1])) except: q_time = QTime(0, 0) self.wait_queue_time.setTime(q_time) # change aria2 path self.aria2_path_pushButton.clicked.connect(self.changeAria2Path) self.aria2_path_checkBox.toggled.connect(self.ariaCheckBoxToggled) aria2_path = self.persepolis_setting.value('settings/aria2_path') self.aria2_path_lineEdit.setEnabled(False) if aria2_path != None: self.aria2_path_checkBox.setChecked(True) self.aria2_path_lineEdit.setText(str(aria2_path)) self.ariaCheckBoxToggled('aria2') if os_type in OS.UNIX_LIKE: for widget in self.aria2_path_checkBox, self.aria2_path_lineEdit, self.aria2_path_pushButton: widget.hide() # save_as_tab self.download_folder_lineEdit.setText( str(self.persepolis_setting.value('download_path'))) self.temp_download_lineEdit.setText( str(self.persepolis_setting.value('download_path_temp'))) # subfolder if str(self.persepolis_setting.value('subfolder')) == 'yes': self.subfolder_checkBox.setChecked(True) else: self.subfolder_checkBox.setChecked(False) # notifications_tab self.volume_label.setText( 'Volume : ' + str(self.persepolis_setting.value('sound-volume'))) self.volume_dial.setValue( int(self.persepolis_setting.value('sound-volume'))) # set style # find available styles(It's depends on operating system and desktop environments). available_styles = QStyleFactory.keys() for style in available_styles: # 'bb10dark', 'GTK', 'gtk' styles may cause to crashing! Eliminate them! style_black_list = ['bb10dark', 'bb10bright', 'GTK', 'gtk', 'gtk2'] if style not in style_black_list: self.style_comboBox.addItem(style) # System >> for system default style # when user select System for style section, the default system style is using. self.style_comboBox.addItem('System') current_style_index = self.style_comboBox.findText( str(self.persepolis_setting.value('style'))) if current_style_index != -1: self.style_comboBox.setCurrentIndex(current_style_index) # available language available_language = [ 'en_US', 'fa_IR', 'ar', 'zh_CN', 'fr_FR', 'pl_PL', 'nl_NL', 'pt_BR', 'es_ES', 'hu', 'tr', 'tr_TR' ] for lang in available_language: self.lang_comboBox.addItem(str(QLocale(lang).nativeLanguageName()), lang) current_locale = self.lang_comboBox.findData( str(self.persepolis_setting.value('locale'))) self.lang_comboBox.setCurrentIndex(current_locale) self.current_icon = self.persepolis_setting.value('icons') # icon size size = ['128', '64', '48', '32', '24', '16'] self.icons_size_comboBox.addItems(size) current_icons_size_index = self.icons_size_comboBox.findText( str(self.persepolis_setting.value('toolbar_icon_size'))) self.icons_size_comboBox.setCurrentIndex(current_icons_size_index) # call setDarkLightIcon if index is changed self.icons_size_comboBox.currentIndexChanged.connect( self.setDarkLightIcon) # set notification notifications = ['Native notification', 'QT notification'] self.notification_comboBox.addItems(notifications) current_notification_index = self.notification_comboBox.findText( str(self.persepolis_setting.value('notification'))) self.notification_comboBox.setCurrentIndex(current_notification_index) # set font font_setting = QFont() font_setting.setFamily(str(self.persepolis_setting.value('font'))) self.fontComboBox.setCurrentFont(font_setting) self.font_size_spinBox.setValue( int(self.persepolis_setting.value('font-size'))) # sound frame self.sound_frame.setEnabled(False) self.enable_notifications_checkBox.toggled.connect(self.soundFrame) if str(self.persepolis_setting.value('sound')) == 'yes': self.enable_notifications_checkBox.setChecked(True) else: self.enable_notifications_checkBox.setChecked(False) # connect folder buttons self.download_folder_lineEdit.setEnabled(False) self.download_folder_pushButton.clicked.connect( self.downloadFolderPushButtonClicked) self.temp_download_lineEdit.setEnabled(False) self.temp_download_pushButton.clicked.connect( self.tempDownloadPushButtonClicked) # dial self.volume_dial.setNotchesVisible(True) self.volume_dial.valueChanged.connect(self.dialChanged) # start_persepolis_if_browser_executed_checkBox if str(self.persepolis_setting.value('browser-persepolis')) == 'yes': self.start_persepolis_if_browser_executed_checkBox.setChecked(True) else: self.start_persepolis_if_browser_executed_checkBox.setChecked( False) # hide window if str(self.persepolis_setting.value('hide-window')) == 'yes': self.hide_window_checkBox.setChecked(True) else: self.hide_window_checkBox.setChecked(False) # tray icon if str(self.persepolis_setting.value('tray-icon')) == 'yes': self.enable_system_tray_checkBox.setChecked(True) else: self.enable_notifications_checkBox.setChecked(False) # show_menubar if str(self.persepolis_setting.value('show-menubar')) == 'yes': self.show_menubar_checkbox.setChecked(True) else: self.show_menubar_checkbox.setChecked(False) if platform.system() == 'Darwin': self.show_menubar_checkbox.setChecked(True) self.show_menubar_checkbox.hide() # show_sidepanel if str(self.persepolis_setting.value('show-sidepanel')) == 'yes': self.show_sidepanel_checkbox.setChecked(True) else: self.show_sidepanel_checkbox.setChecked(False) # show ProgressWindow if str(self.persepolis_setting.value('show-progress')) == 'yes': self.show_progress_window_checkbox.setChecked(True) else: self.show_progress_window_checkbox.setChecked(False) # after download dialog if str(self.persepolis_setting.value('after-dialog')) == 'yes': self.after_download_checkBox.setChecked(True) else: self.after_download_checkBox.setChecked(False) # run persepolis at startup checkBox if str(self.persepolis_setting.value('startup')) == 'yes': self.startup_checkbox.setChecked(True) else: self.startup_checkbox.setChecked(False) # font_checkBox if str(self.persepolis_setting.value('custom-font')) == 'yes': self.font_checkBox.setChecked(True) else: self.font_checkBox.setChecked(False) self.fontCheckBoxState(self.font_checkBox) # keep_awake_checkBox if str(self.persepolis_setting.value('awake')) == 'yes': self.keep_awake_checkBox.setChecked(True) else: self.keep_awake_checkBox.setChecked(False) # columns_tab if str(self.persepolis_setting.value('column0')) == 'yes': self.column0_checkBox.setChecked(True) else: self.column0_checkBox.setChecked(False) if str(self.persepolis_setting.value('column1')) == 'yes': self.column1_checkBox.setChecked(True) else: self.column1_checkBox.setChecked(False) if str(self.persepolis_setting.value('column2')) == 'yes': self.column2_checkBox.setChecked(True) else: self.column2_checkBox.setChecked(False) if str(self.persepolis_setting.value('column3')) == 'yes': self.column3_checkBox.setChecked(True) else: self.column3_checkBox.setChecked(False) if str(self.persepolis_setting.value('column4')) == 'yes': self.column4_checkBox.setChecked(True) else: self.column4_checkBox.setChecked(False) if str(self.persepolis_setting.value('column5')) == 'yes': self.column5_checkBox.setChecked(True) else: self.column5_checkBox.setChecked(False) if str(self.persepolis_setting.value('column6')) == 'yes': self.column6_checkBox.setChecked(True) else: self.column6_checkBox.setChecked(False) if str(self.persepolis_setting.value('column7')) == 'yes': self.column7_checkBox.setChecked(True) else: self.column7_checkBox.setChecked(False) if str(self.persepolis_setting.value('column10')) == 'yes': self.column10_checkBox.setChecked(True) else: self.column10_checkBox.setChecked(False) if str(self.persepolis_setting.value('column11')) == 'yes': self.column11_checkBox.setChecked(True) else: self.column11_checkBox.setChecked(False) if str(self.persepolis_setting.value('column12')) == 'yes': self.column12_checkBox.setChecked(True) else: self.column12_checkBox.setChecked(False) # video_finder try: # Integer casting may raise exception. self.max_links_spinBox.setValue( int(persepolis_setting.value('video_finder/max_links', 3))) except: pass # shortcuts self.qshortcuts_list = [ self.parent.exitAction_shortcut, self.parent.minimizeAction_shortcut, self.parent.removeSelectedAction_shortcut, self.parent.deleteSelectedAction_shortcut, self.parent.moveUpSelectedAction_shortcut, self.parent.moveDownSelectedAction_shortcut, self.parent.addlinkAction_shortcut, self.parent.videoFinderAddLinkAction_shortcut, self.parent.addtextfileAction_shortcut ] self.shortcuts_list = [ self.parent.exitAction_shortcut.key().toString(), self.parent.minimizeAction_shortcut.key().toString(), self.parent.removeSelectedAction_shortcut.key().toString(), self.parent.deleteSelectedAction_shortcut.key().toString(), self.parent.moveUpSelectedAction_shortcut.key().toString(), self.parent.moveDownSelectedAction_shortcut.key().toString(), self.parent.addlinkAction_shortcut.key().toString(), self.parent.videoFinderAddLinkAction_shortcut.key().toString(), self.parent.addtextfileAction_shortcut.key().toString() ] # add shortcuts to the shortcut_table j = 0 for shortcut in self.shortcuts_list: item = QTableWidgetItem(shortcut) # align center item.setTextAlignment(0x0004 | 0x0080) # insert item in shortcut_table self.shortcut_table.setItem(j, 1, item) j = j + 1 # If user doubleclicks on a row, then run showCaptureKeyboardWindow method self.shortcut_table.itemDoubleClicked.connect( self.showCaptureKeyboardWindow) # ok cancel default button self.cancel_pushButton.clicked.connect(self.close) self.defaults_pushButton.clicked.connect( self.defaultsPushButtonPressed) self.ok_pushButton.clicked.connect(self.okPushButtonPressed) # font_checkBox connect self.font_checkBox.stateChanged.connect(self.fontCheckBoxState) # saving initial value of self.persepolis_setting in self.first_key_value_dict # at the end! in the okPushButtonPressed method, first_key_value_dict will compared with second_key_value_dict. # if any thing changed , then a message box notify user about "some changes take effect after restarting persepolis". self.first_key_value_dict = {} for member in self.persepolis_setting.allKeys(): self.first_key_value_dict[member] = str( self.persepolis_setting.value(member)) # if style_comboBox is changed, self.styleComboBoxChanged is called. self.style_comboBox.currentIndexChanged.connect( self.styleComboBoxChanged) self.styleComboBoxChanged() self.color_comboBox.currentIndexChanged.connect(self.setDarkLightIcon) self.persepolis_setting.endGroup() # setting window size and position size = self.persepolis_setting.value('PreferencesWindow/size', QSize(578, 565)) position = self.persepolis_setting.value('PreferencesWindow/position', QPoint(300, 300)) self.resize(size) self.move(position)
def en_us_locale(): return QLocale(QLocale.English, QLocale.UnitedStates)
def zh_tw_locale(): return QLocale(QLocale.Chinese, QLocale.TraditionalChineseScript, QLocale.Taiwan)
def ko_kr_locale(): return QLocale(QLocale.Korean, QLocale.SouthKorea)
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>"))
def __init__(self, parent): super().__init__() self.parent = parent icons = ':/' + \ str(self.parent.persepolis_setting.value('settings/icons')) + '/' # add support for other languages locale = str(self.parent.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.parent.persepolis_setting.value('ui_direction') if ui_direction == 'rtl': self.setLayoutDirection(Qt.RightToLeft) elif ui_direction in 'ltr': self.setLayoutDirection(Qt.LeftToRight) # creating context menu self.menubar = QMenu(self) self.setMenu(self.menubar) self.setIcon(QIcon(icons + 'menu')) self.setStyleSheet( """QPushButton{border: none; background-color: transparent; padding: 0px}""" ) 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", 'Video Finder')) helpMenu = self.menubar.addMenu( QCoreApplication.translate("mainwindow_ui_tr", 'Help')) sortMenu = viewMenu.addMenu( QCoreApplication.translate("mainwindow_ui_tr", 'Sort by')) videoFinderMenu.addAction(self.parent.videoFinderAddLinkAction) downloadMenu.addAction(self.parent.stopAllAction) sortMenu.addAction(self.parent.sort_file_name_Action) sortMenu.addAction(self.parent.sort_file_size_Action) sortMenu.addAction(self.parent.sort_first_try_date_Action) sortMenu.addAction(self.parent.sort_last_try_date_Action) sortMenu.addAction(self.parent.sort_download_status_Action) viewMenu.addAction(self.parent.trayAction) viewMenu.addAction(self.parent.showMenuBarAction) viewMenu.addAction(self.parent.showSidePanelAction) viewMenu.addAction(self.parent.minimizeAction) fileMenu.addAction(self.parent.addlinkAction) fileMenu.addAction(self.parent.addtextfileAction) downloadMenu.addAction(self.parent.resumeAction) downloadMenu.addAction(self.parent.pauseAction) downloadMenu.addAction(self.parent.stopAction) downloadMenu.addAction(self.parent.propertiesAction) downloadMenu.addAction(self.parent.progressAction) fileMenu.addAction(self.parent.openFileAction) fileMenu.addAction(self.parent.openDownloadFolderAction) fileMenu.addAction(self.parent.openDefaultDownloadFolderAction) fileMenu.addAction(self.parent.exitAction) editMenu.addAction(self.parent.clearAction) editMenu.addAction(self.parent.removeSelectedAction) editMenu.addAction(self.parent.deleteSelectedAction) queueMenu.addAction(self.parent.createQueueAction) queueMenu.addAction(self.parent.removeQueueAction) queueMenu.addAction(self.parent.startQueueAction) queueMenu.addAction(self.parent.stopQueueAction) queueMenu.addAction(self.parent.moveUpSelectedAction) queueMenu.addAction(self.parent.moveDownSelectedAction) editMenu.addAction(self.parent.preferencesAction) helpMenu.addAction(self.parent.aboutAction) helpMenu.addAction(self.parent.issueAction) helpMenu.addAction(self.parent.updateAction) helpMenu.addAction(self.parent.logAction) helpMenu.addAction(self.parent.helpAction)
def setModelData(self, editor, model, index): value = QLocale().toDouble(editor.text())[0] model.setData(index, value)
def setupUi(self, tfm): if not tfm.objectName(): tfm.setObjectName(u"tfm") tfm.resize(800, 600) tfm.setContextMenuPolicy(Qt.NoContextMenu) tfm.setLocale(QLocale(QLocale.English, QLocale.UnitedStates)) self.action_menu = QAction(tfm) self.action_menu.setObjectName(u"action_menu") self.action_new_dir = QAction(tfm) self.action_new_dir.setObjectName(u"action_new_dir") self.action_new_file = QAction(tfm) self.action_new_file.setObjectName(u"action_new_file") self.action_back = QAction(tfm) self.action_back.setObjectName(u"action_back") self.action_up = QAction(tfm) self.action_up.setObjectName(u"action_up") self.action_home = QAction(tfm) self.action_home.setObjectName(u"action_home") self.action_go = QAction(tfm) self.action_go.setObjectName(u"action_go") self.action_forward = QAction(tfm) self.action_forward.setObjectName(u"action_forward") self.action_copy = QAction(tfm) self.action_copy.setObjectName(u"action_copy") self.action_paste = QAction(tfm) self.action_paste.setObjectName(u"action_paste") self.action_cut = QAction(tfm) self.action_cut.setObjectName(u"action_cut") self.action_show_hidden = QAction(tfm) self.action_show_hidden.setObjectName(u"action_show_hidden") self.action_show_hidden.setCheckable(True) self.action_delete = QAction(tfm) self.action_delete.setObjectName(u"action_delete") self.action_rename = QAction(tfm) self.action_rename.setObjectName(u"action_rename") self.action_add_to_bookmarks = QAction(tfm) self.action_add_to_bookmarks.setObjectName(u"action_add_to_bookmarks") self.action_remove_bookmark = QAction(tfm) self.action_remove_bookmark.setObjectName(u"action_remove_bookmark") self.action_copy_path = QAction(tfm) self.action_copy_path.setObjectName(u"action_copy_path") self.action_extract_here = QAction(tfm) self.action_extract_here.setObjectName(u"action_extract_here") self.action_mount_iso = QAction(tfm) self.action_mount_iso.setObjectName(u"action_mount_iso") self.centralwidget = QWidget(tfm) self.centralwidget.setObjectName(u"centralwidget") self.horizontalLayout = QHBoxLayout(self.centralwidget) self.horizontalLayout.setObjectName(u"horizontalLayout") self.vsplit = QSplitter(self.centralwidget) self.vsplit.setObjectName(u"vsplit") self.vsplit.setOrientation(Qt.Horizontal) self.hsplit = QSplitter(self.vsplit) self.hsplit.setObjectName(u"hsplit") self.hsplit.setOrientation(Qt.Vertical) self.fs_tree = QTreeView(self.hsplit) self.fs_tree.setObjectName(u"fs_tree") sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(1) sizePolicy.setHeightForWidth( self.fs_tree.sizePolicy().hasHeightForWidth()) self.fs_tree.setSizePolicy(sizePolicy) self.fs_tree.setTabKeyNavigation(True) self.fs_tree.setProperty("showDropIndicator", True) self.fs_tree.setDragEnabled(False) self.fs_tree.setDragDropMode(QAbstractItemView.DropOnly) self.fs_tree.setDefaultDropAction(Qt.MoveAction) self.fs_tree.setRootIsDecorated(False) self.hsplit.addWidget(self.fs_tree) self.fs_tree.header().setVisible(False) self.bookmark_view = QListView(self.hsplit) self.bookmark_view.setObjectName(u"bookmark_view") self.bookmark_view.setContextMenuPolicy(Qt.ActionsContextMenu) self.bookmark_view.setEditTriggers(QAbstractItemView.DoubleClicked | QAbstractItemView.EditKeyPressed | QAbstractItemView.SelectedClicked) self.bookmark_view.setTabKeyNavigation(True) self.bookmark_view.setDragDropOverwriteMode(True) self.bookmark_view.setDragDropMode(QAbstractItemView.DropOnly) self.bookmark_view.setDefaultDropAction(Qt.CopyAction) self.bookmark_view.setAlternatingRowColors(True) self.hsplit.addWidget(self.bookmark_view) self.mounts_view = QListView(self.hsplit) self.mounts_view.setObjectName(u"mounts_view") self.mounts_view.setTabKeyNavigation(True) self.mounts_view.setAlternatingRowColors(True) self.hsplit.addWidget(self.mounts_view) self.vsplit.addWidget(self.hsplit) self.table_view = QTableView(self.vsplit) self.table_view.setObjectName(u"table_view") sizePolicy1 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) sizePolicy1.setHorizontalStretch(1) sizePolicy1.setVerticalStretch(0) sizePolicy1.setHeightForWidth( self.table_view.sizePolicy().hasHeightForWidth()) self.table_view.setSizePolicy(sizePolicy1) self.table_view.viewport().setProperty("cursor", QCursor(Qt.ArrowCursor)) self.table_view.setContextMenuPolicy(Qt.ActionsContextMenu) self.table_view.setAcceptDrops(True) self.table_view.setToolTipDuration(-3) self.table_view.setEditTriggers(QAbstractItemView.AnyKeyPressed | QAbstractItemView.EditKeyPressed | QAbstractItemView.SelectedClicked) self.table_view.setDragEnabled(True) self.table_view.setDragDropMode(QAbstractItemView.DragDrop) self.table_view.setDefaultDropAction(Qt.MoveAction) self.table_view.setAlternatingRowColors(True) self.table_view.setSelectionMode(QAbstractItemView.ExtendedSelection) self.table_view.setSelectionBehavior(QAbstractItemView.SelectRows) self.table_view.setTextElideMode(Qt.ElideMiddle) self.table_view.setShowGrid(False) self.table_view.setSortingEnabled(True) self.table_view.setWordWrap(False) self.vsplit.addWidget(self.table_view) self.table_view.horizontalHeader().setDefaultSectionSize(150) self.table_view.horizontalHeader().setHighlightSections(False) self.table_view.horizontalHeader().setStretchLastSection(True) self.table_view.verticalHeader().setVisible(False) self.horizontalLayout.addWidget(self.vsplit) tfm.setCentralWidget(self.centralwidget) self.statusbar = QStatusBar(tfm) self.statusbar.setObjectName(u"statusbar") self.statusbar.setContextMenuPolicy(Qt.NoContextMenu) self.statusbar.setSizeGripEnabled(False) tfm.setStatusBar(self.statusbar) self.toolbar = QToolBar(tfm) self.toolbar.setObjectName(u"toolbar") self.toolbar.setContextMenuPolicy(Qt.PreventContextMenu) self.toolbar.setMovable(False) tfm.addToolBar(Qt.TopToolBarArea, self.toolbar) self.toolbar.addAction(self.action_back) self.toolbar.addAction(self.action_forward) self.toolbar.addAction(self.action_up) self.toolbar.addAction(self.action_home) self.toolbar.addAction(self.action_go) self.retranslateUi(tfm) QMetaObject.connectSlotsByName(tfm)
def __init__(self, parent, gid_list, persepolis_setting): super().__init__(persepolis_setting) self.persepolis_setting = persepolis_setting self.parent = parent # first item in the gid_list is related to video's link and second item is related to audio's link. self.gid_list = gid_list # this variable can be changed by checkDownloadInfo method in mainwindow.py # self.gid defines that which gid is downloaded. self.gid = gid_list[0] # this variable used as category name in ShutDownThread self.video_finder_plus_gid = 'video_finder_' + str(gid_list[0]) # connect signals and s***s self.resume_pushButton.clicked.connect(self.resumePushButtonPressed) self.stop_pushButton.clicked.connect(self.stopPushButtonPressed) self.pause_pushButton.clicked.connect(self.pausePushButtonPressed) self.download_progressBar.setValue(0) self.limit_pushButton.clicked.connect(self.limitPushButtonPressed) self.limit_frame.setEnabled(False) self.limit_checkBox.toggled.connect(self.limitCheckBoxToggled) self.after_frame.setEnabled(False) self.after_checkBox.toggled.connect(self.afterCheckBoxToggled) self.after_pushButton.clicked.connect(self.afterPushButtonPressed) # 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) # check if limit speed is activated by user or not add_link_dictionary = self.parent.persepolis_db.searchGidInAddLinkTable( gid_list[0]) limit = str(add_link_dictionary['limit_value']) if limit != '0': limit_number = limit[:-1] limit_unit = limit[-1] self.limit_spinBox.setValue(float(limit_number)) if limit_unit == 'K': self.after_comboBox.setCurrentIndex(0) else: self.after_comboBox.setCurrentIndex(1) self.limit_checkBox.setChecked(True) self.after_comboBox.currentIndexChanged.connect( self.afterComboBoxChanged) self.limit_comboBox.currentIndexChanged.connect( self.limitComboBoxChanged) self.limit_spinBox.valueChanged.connect(self.limitComboBoxChanged) # set window size and position size = self.persepolis_setting.value('ProgressWindow/size', QSize(595, 274)) position = self.persepolis_setting.value('ProgressWindow/position', QPoint(300, 300)) self.resize(size) self.move(position)