def createEditor(self, userType, parent): if userType == QVariant.Double: doubleSpinBox = QtWidgets.QDoubleSpinBox(parent) doubleSpinBox.setDecimals(4) doubleSpinBox.setMaximum(-10000000) doubleSpinBox.setMaximum( 10000000) # The default maximum value is 99.99.所以要设置一下 return doubleSpinBox else: return super().createEditor(userType, parent) if __name__ == '__main__': import sys app = QtWidgets.QApplication([]) QLocale.setDefault(QLocale(QLocale.English, QLocale.UnitedStates)) w = QtWidgets.QMainWindow() table = TableView(w) styledItemDelegate = QtWidgets.QStyledItemDelegate() styledItemDelegate.setItemEditorFactory(SpinBoxDelegate()) table.setItemDelegate(styledItemDelegate) table.setModel( TableModel([[name, 0., 1., 0.1] for name in ['X_axis', 'Y_axis', 'theta_axis']], header=['Actuator', 'Start', 'Stop', 'Step'], editable=[False, True, True, True])) w.setCentralWidget(table) w.show() sys.exit(app.exec_())
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 = QtSvg.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(75) 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 self.developers_tab = QWidget(self) developers_verticalLayout = QVBoxLayout(self.developers_tab) self.developers_title_label = QLabel(self.developers_tab) font.setBold(True) font.setWeight(75) 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) developers_verticalLayout.addStretch(1) # translators tab self.translators_tab = QWidget(self) translators_tab_verticalLayout = QVBoxLayout(self.translators_tab) # chinese translators self.chinese_translators_label = QLabel(self.translators_tab) self.chinese_translators_label.setFont(font) self.chinese_translators_label.setAlignment(Qt.AlignCenter) translators_tab_verticalLayout.addWidget(self.chinese_translators_label) self.chinese_translatos_name_label = QLabel(self.translators_tab) self.chinese_translatos_name_label.setAlignment(Qt.AlignCenter) translators_tab_verticalLayout.addWidget(self.chinese_translatos_name_label) # persian translators self.persian_translators_label = QLabel(self.translators_tab) self.persian_translators_label.setFont(font) self.persian_translators_label.setAlignment(Qt.AlignCenter) translators_tab_verticalLayout.addWidget(self.persian_translators_label) self.persian_translatos_name_label = QLabel(self.translators_tab) self.persian_translatos_name_label.setAlignment(Qt.AlignCenter) translators_tab_verticalLayout.addWidget(self.persian_translatos_name_label) translators_tab_verticalLayout.addStretch(1) # 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.0.1")) 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", "TRANSLATORS NOTE: YOU REALLY DON'T NEED TO TRANSLATE THIS PART!")) # translators_tab self.persian_translators_label.setText(QCoreApplication.translate("about_ui_tr", "Persian translators:")) self.persian_translatos_name_label.setText(QCoreApplication.translate("about_ui_tr", "H.Rostami\nMostafa Asadi")) self.chinese_translators_label.setText(QCoreApplication.translate("about_ui_tr", "Chinese translators:")) self.chinese_translatos_name_label.setText(QCoreApplication.translate("about_ui_tr", "Davinma\n210hcl\nleoxxx")) # 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"))
def get_qlocale(): q = QLocale(_current_locale_language) return q
def _window_initialize(self): super()._window_initialize() self._interactor = self.figure.plotter.interactor self._window = self.figure.plotter.app_window self._window.setLocale(QLocale(QLocale.Language.English)) self._window.signal_close.connect(self._window_clean)
def export_text_interpolatevalues(state, data_to_table, horiz_headers, vertical_headers, data_2d, types, project_properties): filename = data_2d.filename path_prj = project_properties["path_prj"] unit_type = data_2d.unit_type fish_names = list(horiz_headers) # prep data for fish_num, fish_name in enumerate(fish_names): if "osi_" in fish_name: fish_names[fish_num] = fish_name.replace("osi_", "") if "wua_" in fish_name: fish_names[fish_num] = fish_name.replace("wua_", "") if "ua_" in fish_name: fish_names[fish_num] = fish_name.replace("ua_", "") # header 1 if project_properties['language'] == 0: if len(types.keys()) > 1: # date date_type = types["date"] header = 'reach\tdate\tunit' else: header = 'reach\tunit' else: if len(types.keys()) > 1: # date date_type = types["date"] header = 'troncon\tdate\tunit' else: header = 'troncon\tunit' header += "".join( ['\tOSI' + str(i) for i in range(int(len(fish_names) / 3))]) header += "".join( ['\tWUA' + str(i) for i in range(int(len(fish_names) / 3))]) header += "".join( ['\tUA' + str(i) for i in range(int(len(fish_names) / 3))]) header += '\n' # header 2 if len(types.keys()) > 1: # date header += '[]\t[' + date_type + ']\t[' + unit_type + ']' else: header += '[]\t[' + unit_type + ']' header += "".join(['\t[]' for _ in range(int(len(fish_names) / 3))]) header += "".join(['\t[m2]' for _ in range(int(len(fish_names) / 3))]) header += "".join(['\t[%]' for _ in range(int(len(fish_names) / 3))]) header += '\n' # header 3 if len(types.keys()) > 1: # date header += 'all\tall\tall' else: header += 'all\tall' for fish_name in fish_names: if "units" in fish_name: pass else: header += '\t' + fish_name.replace(' ', '_') # lines linetext = "" # for each line for row_index in range(len(vertical_headers)): # print("line", line) if len(types.keys()) > 1: # date linetext += "0" + "\t" + str(vertical_headers[row_index]) + "\t" else: linetext += "0" + "\t" + str(vertical_headers[row_index]) + "\t" # for each column for column_name in horiz_headers: hab_data = data_to_table[column_name][row_index] if not hab_data: linetext += "None" + "\t" if hab_data: # change decimal point locale = QLocale() if locale.decimalPoint() == ",": hab_data = str(hab_data).replace('.', ',') linetext += str(hab_data) + "\t" # new line linetext += "\n" text = header + "\n" + linetext # export try: output_full_path = os.path.join( path_prj, "output", "text", os.path.splitext(filename)[0] + "_interpolate_chronicle.txt") with open(output_full_path, 'wt') as f: f.write(text) state.value = 100 # process finished except: print('Error: ' + 'File not exported as it may be opened by another program.')
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, 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 l10nDecimal(dec, digits=2): from PyQt5.QtCore import QLocale l=QLocale() return l.toCurrencyString(float(dec))
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) # get icons name icons = ':/' + \ str(self.persepolis_setting.value('settings/icons')) + '/' self.setMinimumSize(QtCore.QSize(520, 425)) self.setWindowIcon( QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg'))) # main layout window_verticalLayout = QVBoxLayout() # add link tab widget self.add_link_tabWidget = QTabWidget(self) window_verticalLayout.addWidget(self.add_link_tabWidget) # link tab self.link_tab = QWidget() link_tab_verticalLayout = QVBoxLayout(self.link_tab) link_tab_verticalLayout.setContentsMargins(21, 21, 21, 81) self.link_frame = QFrame(self.link_tab) self.link_frame.setFrameShape(QFrame.StyledPanel) self.link_frame.setFrameShadow(QFrame.Raised) horizontalLayout_2 = QHBoxLayout(self.link_frame) self.link_verticalLayout = QVBoxLayout() # link -> self.link_horizontalLayout = QHBoxLayout() self.link_label = QLabel(self.link_frame) self.link_horizontalLayout.addWidget(self.link_label) self.link_lineEdit = QLineEdit(self.link_frame) self.link_horizontalLayout.addWidget(self.link_lineEdit) self.link_verticalLayout.addLayout(self.link_horizontalLayout) horizontalLayout_2.addLayout(self.link_verticalLayout) link_tab_verticalLayout.addWidget(self.link_frame) # add change_name field -> self.change_name_horizontalLayout = QHBoxLayout() self.change_name_checkBox = QCheckBox(self.link_frame) self.change_name_horizontalLayout.addWidget(self.change_name_checkBox) self.change_name_lineEdit = QLineEdit(self.link_frame) self.change_name_horizontalLayout.addWidget(self.change_name_lineEdit) self.link_verticalLayout.addLayout(self.change_name_horizontalLayout) # add_category -> queue_horizontalLayout = QHBoxLayout() self.queue_frame = QFrame(self) self.queue_frame.setFrameShape(QFrame.StyledPanel) self.queue_frame.setFrameShadow(QFrame.Raised) add_queue_horizontalLayout = QHBoxLayout(self.queue_frame) self.add_queue_label = QLabel(self.queue_frame) add_queue_horizontalLayout.addWidget(self.add_queue_label) self.add_queue_comboBox = QComboBox(self.queue_frame) add_queue_horizontalLayout.addWidget(self.add_queue_comboBox) queue_horizontalLayout.addWidget(self.queue_frame) queue_horizontalLayout.addStretch(1) self.size_label = QLabel(self) queue_horizontalLayout.addWidget(self.size_label) link_tab_verticalLayout.addLayout(queue_horizontalLayout) link_tab_verticalLayout.addStretch(1) self.add_link_tabWidget.addTab(self.link_tab, '') # proxy tab self.proxy_tab = QWidget(self) proxy_verticalLayout = QVBoxLayout(self.proxy_tab) proxy_verticalLayout.setContentsMargins(21, 21, 21, 171) proxy_horizontalLayout = QHBoxLayout() self.proxy_checkBox = QCheckBox(self.proxy_tab) self.detect_proxy_pushButton = QPushButton(self.proxy_tab) self.detect_proxy_label = QLabel(self.proxy_tab) proxy_horizontalLayout.addWidget(self.proxy_checkBox) proxy_horizontalLayout.addWidget(self.detect_proxy_label) proxy_horizontalLayout.addWidget(self.detect_proxy_pushButton) proxy_verticalLayout.addLayout(proxy_horizontalLayout) self.proxy_frame = QFrame(self.proxy_tab) self.proxy_frame.setFrameShape(QFrame.StyledPanel) self.proxy_frame.setFrameShadow(QFrame.Raised) gridLayout = QGridLayout(self.proxy_frame) self.ip_label = QLabel(self.proxy_frame) gridLayout.addWidget(self.ip_label, 0, 0, 1, 1) self.ip_lineEdit = QLineEdit(self.proxy_frame) self.ip_lineEdit.setInputMethodHints(QtCore.Qt.ImhNone) gridLayout.addWidget(self.ip_lineEdit, 0, 1, 1, 1) self.port_label = QLabel(self.proxy_frame) gridLayout.addWidget(self.port_label, 0, 2, 1, 1) self.port_spinBox = QSpinBox(self.proxy_frame) self.port_spinBox.setMaximum(65535) self.port_spinBox.setSingleStep(1) gridLayout.addWidget(self.port_spinBox, 0, 3, 1, 1) self.proxy_user_label = QLabel(self.proxy_frame) gridLayout.addWidget(self.proxy_user_label, 2, 0, 1, 1) self.proxy_user_lineEdit = QLineEdit(self.proxy_frame) gridLayout.addWidget(self.proxy_user_lineEdit, 2, 1, 1, 1) self.proxy_pass_label = QLabel(self.proxy_frame) 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) gridLayout.addWidget(self.proxy_pass_lineEdit, 2, 3, 1, 1) proxy_verticalLayout.addWidget(self.proxy_frame) proxy_verticalLayout.addStretch(1) self.add_link_tabWidget.addTab(self.proxy_tab, '') # more options tab self.more_options_tab = QWidget(self) more_options_tab_verticalLayout = QVBoxLayout(self.more_options_tab) # download UserName & Password -> download_horizontalLayout = QHBoxLayout() download_horizontalLayout.setContentsMargins(-1, 10, -1, -1) download_verticalLayout = QVBoxLayout() self.download_checkBox = QCheckBox(self.more_options_tab) download_verticalLayout.addWidget(self.download_checkBox) self.download_frame = QFrame(self.more_options_tab) self.download_frame.setFrameShape(QFrame.StyledPanel) self.download_frame.setFrameShadow(QFrame.Raised) gridLayout_2 = QGridLayout(self.download_frame) self.download_user_lineEdit = QLineEdit(self.download_frame) gridLayout_2.addWidget(self.download_user_lineEdit, 0, 1, 1, 1) self.download_user_label = QLabel(self.download_frame) gridLayout_2.addWidget(self.download_user_label, 0, 0, 1, 1) self.download_pass_label = QLabel(self.download_frame) gridLayout_2.addWidget(self.download_pass_label, 1, 0, 1, 1) self.download_pass_lineEdit = QLineEdit(self.download_frame) self.download_pass_lineEdit.setEchoMode(QLineEdit.Password) gridLayout_2.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.more_options_tab) self.folder_frame.setFrameShape(QFrame.StyledPanel) self.folder_frame.setFrameShadow(QFrame.Raised) gridLayout_3 = QGridLayout(self.folder_frame) self.download_folder_lineEdit = QLineEdit(self.folder_frame) gridLayout_3.addWidget(self.download_folder_lineEdit, 2, 0, 1, 1) self.folder_pushButton = QPushButton(self.folder_frame) gridLayout_3.addWidget(self.folder_pushButton, 3, 0, 1, 1) self.folder_pushButton.setIcon(QIcon(icons + 'folder')) self.folder_label = QLabel(self.folder_frame) self.folder_label.setAlignment(QtCore.Qt.AlignCenter) gridLayout_3.addWidget(self.folder_label, 1, 0, 1, 1) download_horizontalLayout.addWidget(self.folder_frame) more_options_tab_verticalLayout.addLayout(download_horizontalLayout) # start time -> time_limit_horizontalLayout = QHBoxLayout() time_limit_horizontalLayout.setContentsMargins(-1, 10, -1, -1) start_verticalLayout = QVBoxLayout() self.start_checkBox = QCheckBox(self.more_options_tab) start_verticalLayout.addWidget(self.start_checkBox) self.start_frame = QFrame(self.more_options_tab) self.start_frame.setFrameShape(QFrame.StyledPanel) self.start_frame.setFrameShadow(QFrame.Raised) horizontalLayout_5 = QHBoxLayout(self.start_frame) self.start_time_qDataTimeEdit = QDateTimeEdit(self.start_frame) self.start_time_qDataTimeEdit.setDisplayFormat('H:mm') horizontalLayout_5.addWidget(self.start_time_qDataTimeEdit) start_verticalLayout.addWidget(self.start_frame) time_limit_horizontalLayout.addLayout(start_verticalLayout) # end time -> end_verticalLayout = QVBoxLayout() self.end_checkBox = QCheckBox(self.more_options_tab) end_verticalLayout.addWidget(self.end_checkBox) self.end_frame = QFrame(self.more_options_tab) self.end_frame.setFrameShape(QFrame.StyledPanel) self.end_frame.setFrameShadow(QFrame.Raised) horizontalLayout_6 = QHBoxLayout(self.end_frame) self.end_time_qDateTimeEdit = QDateTimeEdit(self.end_frame) self.end_time_qDateTimeEdit.setDisplayFormat('H:mm') horizontalLayout_6.addWidget(self.end_time_qDateTimeEdit) end_verticalLayout.addWidget(self.end_frame) time_limit_horizontalLayout.addLayout(end_verticalLayout) # limit Speed -> limit_verticalLayout = QVBoxLayout() self.limit_checkBox = QCheckBox(self.more_options_tab) limit_verticalLayout.addWidget(self.limit_checkBox) self.limit_frame = QFrame(self.more_options_tab) self.limit_frame.setFrameShape(QFrame.StyledPanel) self.limit_frame.setFrameShadow(QFrame.Raised) horizontalLayout_4 = QHBoxLayout(self.limit_frame) self.limit_spinBox = QDoubleSpinBox(self.limit_frame) self.limit_spinBox.setMinimum(1) self.limit_spinBox.setMaximum(1023) horizontalLayout_4.addWidget(self.limit_spinBox) self.limit_comboBox = QComboBox(self.limit_frame) self.limit_comboBox.addItem("") self.limit_comboBox.addItem("") horizontalLayout_4.addWidget(self.limit_comboBox) limit_verticalLayout.addWidget(self.limit_frame) time_limit_horizontalLayout.addLayout(limit_verticalLayout) more_options_tab_verticalLayout.addLayout(time_limit_horizontalLayout) # number of connections -> connections_horizontalLayout = QHBoxLayout() connections_horizontalLayout.setContentsMargins(-1, 10, -1, -1) self.connections_frame = QFrame(self.more_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) connections_horizontalLayout.addStretch(1) more_options_tab_verticalLayout.addLayout(connections_horizontalLayout) more_options_tab_verticalLayout.addStretch(1) self.add_link_tabWidget.addTab(self.more_options_tab, '') # advance options self.advance_options_tab = QWidget(self) advance_options_tab_verticalLayout = QVBoxLayout( self.advance_options_tab) # referer referer_horizontalLayout = QHBoxLayout() self.referer_label = QLabel(self.advance_options_tab) referer_horizontalLayout.addWidget(self.referer_label) self.referer_lineEdit = QLineEdit(self.advance_options_tab) referer_horizontalLayout.addWidget(self.referer_lineEdit) advance_options_tab_verticalLayout.addLayout(referer_horizontalLayout) # header header_horizontalLayout = QHBoxLayout() self.header_label = QLabel(self.advance_options_tab) header_horizontalLayout.addWidget(self.header_label) self.header_lineEdit = QLineEdit(self.advance_options_tab) header_horizontalLayout.addWidget(self.header_lineEdit) advance_options_tab_verticalLayout.addLayout(header_horizontalLayout) # user_agent user_agent_horizontalLayout = QHBoxLayout() self.user_agent_label = QLabel(self.advance_options_tab) user_agent_horizontalLayout.addWidget(self.user_agent_label) self.user_agent_lineEdit = QLineEdit(self.advance_options_tab) user_agent_horizontalLayout.addWidget(self.user_agent_lineEdit) advance_options_tab_verticalLayout.addLayout( user_agent_horizontalLayout) # load_cookies load_cookies_horizontalLayout = QHBoxLayout() self.load_cookies_label = QLabel(self.advance_options_tab) load_cookies_horizontalLayout.addWidget(self.load_cookies_label) self.load_cookies_lineEdit = QLineEdit(self.advance_options_tab) load_cookies_horizontalLayout.addWidget(self.load_cookies_lineEdit) advance_options_tab_verticalLayout.addLayout( load_cookies_horizontalLayout) advance_options_tab_verticalLayout.addStretch(1) self.add_link_tabWidget.addTab(self.advance_options_tab, '') # ok cancel download_later buttons -> buttons_horizontalLayout = QHBoxLayout() buttons_horizontalLayout.addStretch(1) self.download_later_pushButton = QPushButton(self) self.download_later_pushButton.setIcon(QIcon(icons + 'stop')) self.cancel_pushButton = QPushButton(self) self.cancel_pushButton.setIcon(QIcon(icons + 'remove')) self.ok_pushButton = QPushButton(self) self.ok_pushButton.setIcon(QIcon(icons + 'ok')) buttons_horizontalLayout.addWidget(self.download_later_pushButton) buttons_horizontalLayout.addWidget(self.cancel_pushButton) buttons_horizontalLayout.addWidget(self.ok_pushButton) window_verticalLayout.addLayout(buttons_horizontalLayout) self.setLayout(window_verticalLayout) # labels -> self.setWindowTitle( QCoreApplication.translate("addlink_ui_tr", "Enter Your Link")) self.link_label.setText( QCoreApplication.translate("addlink_ui_tr", "Download Link: ")) self.add_queue_label.setText( QCoreApplication.translate("addlink_ui_tr", "Add to category: ")) self.change_name_checkBox.setText( QCoreApplication.translate("addlink_ui_tr", "Change File Name: ")) self.detect_proxy_pushButton.setText( QCoreApplication.translate("addlink_ui_tr", "Detect system proxy setting")) self.proxy_checkBox.setText( QCoreApplication.translate("addlink_ui_tr", "Proxy")) self.proxy_pass_label.setText( QCoreApplication.translate("addlink_ui_tr", "Proxy PassWord: "******"addlink_ui_tr", "IP: ")) self.proxy_user_label.setText( QCoreApplication.translate("addlink_ui_tr", "Proxy UserName: "******"addlink_ui_tr", "Port:")) self.download_checkBox.setText( QCoreApplication.translate("addlink_ui_tr", "Download UserName and PassWord")) self.download_user_label.setText( QCoreApplication.translate("addlink_ui_tr", "Download UserName: "******"addlink_ui_tr", "Download PassWord: "******"addlink_ui_tr", "Change Download Folder")) self.folder_label.setText( QCoreApplication.translate("addlink_ui_tr", "Download Folder: ")) self.start_checkBox.setText( QCoreApplication.translate("addlink_ui_tr", "Start Time")) self.end_checkBox.setText( QCoreApplication.translate("addlink_ui_tr", "End Time")) self.limit_checkBox.setText( QCoreApplication.translate("addlink_ui_tr", "Limit Speed")) self.limit_comboBox.setItemText(0, "KiB/s") self.limit_comboBox.setItemText(1, "MiB/s") self.connections_label.setText( QCoreApplication.translate("addlink_ui_tr", "Number Of Connections:")) self.cancel_pushButton.setText( QCoreApplication.translate("addlink_ui_tr", "Cancel")) self.ok_pushButton.setText( QCoreApplication.translate("addlink_ui_tr", "OK")) self.download_later_pushButton.setText( QCoreApplication.translate("addlink_ui_tr", "Download later")) self.add_link_tabWidget.setTabText( self.add_link_tabWidget.indexOf(self.link_tab), QCoreApplication.translate("addlink_ui_tr", "Link")) self.add_link_tabWidget.setTabText( self.add_link_tabWidget.indexOf(self.proxy_tab), QCoreApplication.translate("addlink_ui_tr", "Proxy")) self.add_link_tabWidget.setTabText( self.add_link_tabWidget.indexOf(self.more_options_tab), QCoreApplication.translate("addlink_ui_tr", "More Options")) self.add_link_tabWidget.setTabText( self.add_link_tabWidget.indexOf(self.advance_options_tab), QCoreApplication.translate("addlink_ui_tr", "Advanced Options")) self.referer_label.setText( QCoreApplication.translate("addlink_ui_tr", 'Referrer: ')) self.header_label.setText( QCoreApplication.translate("addlink_ui_tr", 'Header: ')) self.load_cookies_label.setText( QCoreApplication.translate("addlink_ui_tr", 'Load cookies: ')) self.user_agent_label.setText( QCoreApplication.translate("addlink_ui_tr", 'User agent: '))
def data(self, index, role): source_index = self.mapToSource(index) source_model = self.sourceModel() if not source_index.isValid(): return QVariant() source_data = source_model.data(source_index, role) if role == Qt.DisplayRole: if index.column() == NetworkTableModel.columns_types.index( 'is_member'): value = { True: QT_TRANSLATE_NOOP("NetworkTableModel", 'yes'), False: QT_TRANSLATE_NOOP("NetworkTableModel", 'no'), None: QT_TRANSLATE_NOOP("NetworkTableModel", 'offline') } return value[source_data] if index.column() == NetworkTableModel.columns_types.index( 'pubkey'): return source_data[:5] if index.column() == NetworkTableModel.columns_types.index( 'current_block'): if source_data == -1: return "" else: return source_data if index.column() == NetworkTableModel.columns_types.index('address') \ or index.column() == NetworkTableModel.columns_types.index('port'): return "<p>" + source_data.replace('\n', "<br>") + "</p>" if index.column() == NetworkTableModel.columns_types.index( 'current_hash'): return source_data[:10] if index.column() == NetworkTableModel.columns_types.index( 'current_time') and source_data: ts = self.blockchain_processor.adjusted_ts( self.app.currency, source_data) return QLocale.toString( QLocale(), QDateTime.fromTime_t(ts), QLocale.dateTimeFormat(QLocale(), QLocale.ShortFormat)) if role == Qt.TextAlignmentRole: if source_index.column() == NetworkTableModel.columns_types.index( 'address') or source_index.column() == self.sourceModel( ).columns_types.index('current_block'): return Qt.AlignRight | Qt.AlignVCenter if source_index.column() == NetworkTableModel.columns_types.index( 'is_member'): return Qt.AlignCenter if role == Qt.FontRole: is_root_col = NetworkTableModel.columns_types.index('is_root') index_root_col = source_model.index(source_index.row(), is_root_col) if source_model.data(index_root_col, Qt.DisplayRole): font = QFont() font.setBold(True) return font return source_data
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(QtCore.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) # add information_tab to progress_tabWidget self.progress_tabWidget.addTab(self.information_tab, "") # options_tab self.options_tab = QWidget() options_tab_horizontalLayout = QHBoxLayout(self.options_tab) 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(QtWidgets.QFrame.StyledPanel) self.limit_frame.setFrameShadow(QtWidgets.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) # 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(QtWidgets.QFrame.StyledPanel) self.after_frame.setFrameShadow(QtWidgets.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) # 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 = QtWidgets.QPushButton(self) self.pause_pushButton.setIcon(QIcon(icons + 'pause')) button_horizontalLayout.addWidget(self.pause_pushButton) # stop_pushButton self.stop_pushButton = QtWidgets.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"))
def update_model(self, filter=""): log.info("updating clip properties model.") app = get_app() _ = app._tr # Stop QTimer self.update_timer.stop() # Check for a selected clip if self.selected and self.selected[0]: c, item_type = self.selected[0] # Skip blank clips # TODO: Determine why c is occasional = None if not c: return # Get raw unordered JSON properties raw_properties = json.loads(c.PropertiesJSON(self.frame_number)) all_properties = OrderedDict(sorted(raw_properties.items(), key=lambda x: x[1]['name'])) log.info("Getting properties for frame %s: %s" % (self.frame_number, str(all_properties))) # Check if filter was changed (if so, wipe previous model data) if self.previous_filter != filter: self.previous_filter = filter self.new_item = True # filter changed, so we need to regenerate the entire model # Ignore any events from this method self.ignore_update_signal = True # Clear previous model data (if item is different) if self.new_item: # Prepare for new properties self.items = {} self.model.clear() # Add Headers self.model.setHorizontalHeaderLabels([_("Property"), _("Value")]) # Loop through properties, and build a model for property in all_properties.items(): label = property[1]["name"] name = property[0] value = property[1]["value"] type = property[1]["type"] memo = property[1]["memo"] readonly = property[1]["readonly"] keyframe = property[1]["keyframe"] points = property[1]["points"] interpolation = property[1]["interpolation"] closest_point_x = property[1]["closest_point_x"] choices = property[1]["choices"] # Adding Transparency to translation file transparency_label = _("Transparency") selected_choice = None if choices: selected_choice = [c for c in choices if c["selected"] == True][0]["name"] # Hide filtered out properties if filter and filter.lower() not in name.lower(): continue # Hide unused base properties (if any) if name in self.filter_base_properties: continue # Insert new data into model, or update existing values row = [] if self.new_item: # Append Property Name col = QStandardItem("Property") col.setText(_(label)) col.setData(property) if keyframe and points > 1: col.setBackground(QColor("green")) # Highlight keyframe background elif points > 1: col.setBackground(QColor(42, 130, 218)) # Highlight interpolated value background if readonly: col.setFlags(Qt.ItemIsEnabled) else: col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable) row.append(col) # Append Value col = QStandardItem("Value") if selected_choice: col.setText(_(selected_choice)) elif type == "string": # Use string value col.setText(memo) elif type == "bool": # Use boolean value if value: col.setText(_("True")) else: col.setText(_("False")) elif type == "color": # Don't output a value for colors col.setText("") elif type == "int": col.setText("%d" % value) else: # Use numeric value col.setText(QLocale().system().toString(float(value), "f", precision=2)) col.setData((c.Id(), item_type)) if points > 1: # Apply icon to cell my_icon = QPixmap(os.path.join(info.IMAGES_PATH, "keyframe-%s.png" % interpolation)) col.setData(my_icon, Qt.DecorationRole) log.info(os.path.join(info.IMAGES_PATH, "keyframe-%s.png" % interpolation)) # Set the background color of the cell if keyframe: col.setBackground(QColor("green")) # Highlight keyframe background else: col.setBackground(QColor(42, 130, 218)) # Highlight interpolated value background if type == "color": # Color needs to be handled special red = property[1]["red"]["value"] green = property[1]["green"]["value"] blue = property[1]["blue"]["value"] col.setBackground(QColor(red, green, blue)) if readonly or type == "color" or choices: col.setFlags(Qt.ItemIsEnabled) else: col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsEditable) row.append(col) # Append ROW to MODEL (if does not already exist in model) self.model.appendRow(row) else: # Update the value of the existing model # Get 1st Column col = self.items[name]["row"][0] col.setData(property) # For non-color types, update the background color if keyframe and points > 1: col.setBackground(QColor("green")) # Highlight keyframe background elif points > 1: col.setBackground(QColor(42, 130, 218)) # Highlight interpolated value background else: col.setBackground(QStandardItem("Empty").background()) # Update helper dictionary row.append(col) # Get 2nd Column col = self.items[name]["row"][1] if selected_choice: col.setText(_(selected_choice)) elif type == "string": # Use string value col.setText(memo) elif type == "bool": # Use boolean value if value: col.setText(_("True")) else: col.setText(_("False")) elif type == "color": # Don't output a value for colors col.setText("") elif type == "int": col.setText("%d" % value) else: # Use numeric value col.setText(QLocale().system().toString(float(value), "f", precision=2)) if points > 1: # Apply icon to cell my_icon = QPixmap(os.path.join(info.IMAGES_PATH, "keyframe-%s.png" % interpolation)) col.setData(my_icon, Qt.DecorationRole) # Set the background color of the cell if keyframe: col.setBackground(QColor("green")) # Highlight keyframe background else: col.setBackground(QColor(42, 130, 218)) # Highlight interpolated value background else: # clear background color col.setBackground(QStandardItem("Empty").background()) # clear icon my_icon = QPixmap() col.setData(my_icon, Qt.DecorationRole) if type == "color": # Update the color based on the color curves red = property[1]["red"]["value"] green = property[1]["green"]["value"] blue = property[1]["blue"]["value"] col.setBackground(QColor(red, green, blue)) # Update helper dictionary row.append(col) # Keep track of items in a dictionary (for quick look up) self.items[name] = {"row": row, "property": property} # Update the values on the next call to this method (instead of adding rows) self.new_item = False else: # Clear previous properties hash self.previous_hash = "" # Clear previous model data (if any) self.model.clear() # Add Headers self.model.setHorizontalHeaderLabels([_("Property"), _("Value")]) # Done updating model self.ignore_update_signal = False
def value_updated(self, item, interpolation=-1, value=None, interpolation_details=[]): """ Table cell change event - also handles context menu to update interpolation value """ if self.ignore_update_signal: return # Get translation method _ = get_app()._tr # Determine what was changed property = self.model.item(item.row(), 0).data() property_name = property[1]["name"] closest_point_x = property[1]["closest_point_x"] previous_point_x = property[1]["previous_point_x"] property_type = property[1]["type"] property_key = property[0] clip_id, item_type = item.data() # Get value (if any) if item.text(): # Set and format value based on property type if value != None: # Override value new_value = value elif property_type == "string": # Use string value new_value = item.text() elif property_type == "bool": # Use boolean value if item.text() == _("False"): new_value = False else: new_value = True elif property_type == "int": # Use int value new_value = QLocale().system().toInt(item.text())[0] else: # Use decimal value new_value = QLocale().system().toFloat(item.text())[0] else: new_value = None log.info("%s for %s changed to %s at frame %s with interpolation: %s at closest x: %s" % (property_key, clip_id, new_value, self.frame_number, interpolation, closest_point_x)) # Find this clip c = None clip_updated = False if item_type == "clip": # Get clip object c = Clip.get(id=clip_id) elif item_type == "transition": # Get transition object c = Transition.get(id=clip_id) elif item_type == "effect": # Get effect object c = Effect.get(id=clip_id) if c: # Update clip attribute if property_key in c.data: log.info("value updated: %s" % c.data) # Check the type of property (some are keyframe, and some are not) if type(c.data[property_key]) == dict: # Keyframe # Loop through points, find a matching points on this frame found_point = False point_to_delete = None for point in c.data[property_key]["Points"]: log.info("looping points: co.X = %s" % point["co"]["X"]) if interpolation == -1 and point["co"]["X"] == self.frame_number: # Found point, Update value found_point = True clip_updated = True # Update or delete point if new_value != None: point["co"]["Y"] = float(new_value) log.info("updating point: co.X = %s to value: %s" % (point["co"]["X"], float(new_value))) else: point_to_delete = point break elif interpolation > -1 and point["co"]["X"] == previous_point_x: # Only update interpolation type (and the LEFT side of the curve) found_point = True clip_updated = True point["interpolation"] = interpolation if interpolation == 0: point["handle_right"] = point.get("handle_right") or {"Y": 0.0, "X": 0.0} point["handle_right"]["X"] = interpolation_details[0] point["handle_right"]["Y"] = interpolation_details[1] log.info("updating interpolation mode point: co.X = %s to %s" % (point["co"]["X"], interpolation)) log.info("use interpolation preset: %s" % str(interpolation_details)) elif interpolation > -1 and point["co"]["X"] == closest_point_x: # Only update interpolation type (and the RIGHT side of the curve) found_point = True clip_updated = True point["interpolation"] = interpolation if interpolation == 0: point["handle_left"] = point.get("handle_left") or {"Y": 0.0, "X": 0.0} point["handle_left"]["X"] = interpolation_details[2] point["handle_left"]["Y"] = interpolation_details[3] log.info("updating interpolation mode point: co.X = %s to %s" % (point["co"]["X"], interpolation)) log.info("use interpolation preset: %s" % str(interpolation_details)) # Delete point (if needed) if point_to_delete: clip_updated = True log.info("Found point to delete at X=%s" % point_to_delete["co"]["X"]) c.data[property_key]["Points"].remove(point_to_delete) # Create new point (if needed) elif not found_point and new_value != None: clip_updated = True log.info("Created new point at X=%s" % self.frame_number) c.data[property_key]["Points"].append({'co': {'X': self.frame_number, 'Y': new_value}, 'interpolation': 1}) elif property_type == "int": # Integer clip_updated = True c.data[property_key] = int(new_value) elif property_type == "float": # Float clip_updated = True c.data[property_key] = new_value elif property_type == "bool": # Boolean clip_updated = True c.data[property_key] = bool(new_value) elif property_type == "string": # String clip_updated = True c.data[property_key] = str(new_value) # Reduce # of clip properties we are saving (performance boost) c.data = {property_key: c.data.get(property_key)} # Save changes if clip_updated: # Save c.save() # Update the preview get_app().window.refreshFrameSignal.emit() # Clear selection self.parent.clearSelection()
def __init__(self, *args, **kwargs): QLocale.setDefault(QLocale(QLocale.English, QLocale.UnitedStates)) super().__init__(*args, **kwargs) self.setupview()
def textFromValue(self, value): decimalPoint = QLocale().decimalPoint() if value.is_integer(): return str(int(value)) else: return str(value).replace(".", decimalPoint)
def __init__(self): """ Initializes the GUI. """ QMainWindow.__init__(self, flags=Qt.Window) Debug(self, ": Init") self.locale = QLocale(QLocale.English) self.set_window() self.config = Config() self.config.set_changed_callback(self.on_config_changed) self.config.set_filename(self.DefaultFilename) self.config.load() # The calculation thread is started once initially; after that, recalculation is triggered through ModelAccess self.calculation_thread = None # Will be initialized by self.recalculate() but is needed here for ModelAccess self.calculation_start_time = None # Register exit handler (used by Assert_Dialog to exit gracefully) atexit.register(self.quit) # Create the model first, as the following objects will access it (each widget acts as view *and* controller) self.model = Model(self) # Create the left and right sidebar # Note: These create the wire, sampling volume, field and metric widgets, each populating the model from config self.sidebar_left = SidebarLeft(self) self.sidebar_right = SidebarRight(self) # Create the VisPy canvas (our 3D scene) and statusbar self.vispy_canvas = VispyCanvas(self) self.vispy_canvas.native.setFocusPolicy( Qt.NoFocus ) # Don't let VisPy gain control -- handle all events in GUI self.statusbar = Statusbar(self) # Insert left sidebar, VisPy canvas and right sidebar into main layout. self.splitter = QSplitter(Qt.Horizontal) self.splitter.addWidget(self.sidebar_left) self.splitter.addWidget(self.vispy_canvas.native) self.splitter.addWidget(self.sidebar_right) self.setCentralWidget(self.splitter) self.splitter.setHandleWidth(8) # Create the menu self.menu = Menu(self) # Connect the calculation thread communication signals self.calculation_status.connect(lambda text: self.statusbar.text(text)) self.calculation_exited.connect( lambda success: self.on_calculation_exited(success)) self.initializing = True # Kick off the field calculation if self.config.get_bool("auto_calculation"): self.recalculate() else: self.redraw()
def closeEvent(self, event): app = QApplication.instance() self.settings.setValue('app_style', app.styleSheet()) self.settings.setValue('app_font', app.font().toString()) self.settings.setValue('app_lang', QLocale().name().split('_')[0])
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) # 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 main window to the tray icon'), QCoreApplication.translate('setting_ui_tr', 'Remove download items'), QCoreApplication.translate('setting_ui_tr', 'Delete download items'), QCoreApplication.translate('setting_ui_tr', 'Move up selected items'), QCoreApplication.translate('setting_ui_tr', 'Move down selected items'), 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 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 between every downloads in queue:')) 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 have caused problem! 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's 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', 'Start Persepolis in system tray, If browser is executed.')) 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 has 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's 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 is preventing system from going to sleep.\ This is necessary if your power manager is suspending 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 this 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"))
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'))) # 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') q_time = QTime(int(wait_queue_list[0]), int(wait_queue_list[1])) 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 == 'Linux' or os_type == 'FreeBSD' or os_type == 'OpenBSD': 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: # 'GTK' or 'gtk' styles may cause to crashing! Eliminate them! if 'gtk' not in str(style) and 'GTK' not in str(style): 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' ] 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 mouseMoveEvent(self, event): # Get data model and selection model = self.clip_properties_model.model row = self.indexAt(event.pos()).row() column = self.indexAt(event.pos()).column() if model.item(row, 0): self.selected_label = model.item(row, 0) self.selected_item = model.item(row, 1) # Is the user dragging on the value column if self.selected_label and self.selected_item: frame_number = self.clip_properties_model.frame_number # Get the position of the cursor and % value value_column_x = self.columnViewportPosition(1) value_column_y = value_column_x + self.columnWidth(1) cursor_value = event.x() - value_column_x cursor_value_percent = cursor_value / self.columnWidth(1) property = self.selected_label.data() property_key = property[0] property_name = property[1]["name"] property_type = property[1]["type"] property_max = property[1]["max"] property_min = property[1]["min"] property_value = property[1]["value"] readonly = property[1]["readonly"] item_id, item_type = self.selected_item.data() # Bail if readonly if readonly: return # Get the original data of this item (prior to any updates, for the undo/redo system) if not self.original_data: # Ignore undo/redo history temporarily (to avoid a huge pile of undo/redo history) get_app().updates.ignore_history = True # Find this clip c = None if item_type == "clip": # Get clip object c = Clip.get(id=item_id) elif item_type == "transition": # Get transition object c = Transition.get(id=item_id) elif item_type == "effect": # Get effect object c = Effect.get(id=item_id) if c: if property_key in c.data: # Grab the original data for this item/property self.original_data = c.data # Calculate percentage value if property_type in ["float", "int"]: min_max_range = float(property_max) - float(property_min) # Determine if range is unreasonably long (such as position, start, end, etc.... which can be huge #'s) if min_max_range > 1000.0: # Get the current value self.new_value = QLocale().system().toDouble( self.selected_item.text())[0] # Huge range - increment / decrement slowly if self.previous_x == -1: # init previous_x for the first time self.previous_x = event.x() # calculate # of pixels dragged drag_diff = self.previous_x - event.x() if drag_diff > 0: # Move to the left by a small amount self.new_value -= 0.50 elif drag_diff < 0: # Move to the right by a small amount self.new_value += 0.50 # update previous x self.previous_x = event.x() else: # Small range - use cursor % to calculate new value self.new_value = property_min + (min_max_range * cursor_value_percent) # Clamp value between min and max (just incase user drags too big) self.new_value = max(property_min, self.new_value) self.new_value = min(property_max, self.new_value) # Update value of this property self.clip_properties_model.value_updated( self.selected_item, -1, self.new_value) # Repaint self.viewport().update()
def setup_gettext(localedir, ui_language=None, logger=None): """Setup locales, load translations, install gettext functions.""" if not logger: logger = lambda *a, **b: None # noqa: E731 current_locale = '' if ui_language: try: current_locale = locale.normalize(ui_language + '.' + locale.getpreferredencoding()) locale.setlocale(locale.LC_ALL, current_locale) except Exception as e: logger(e) else: if IS_WIN: from ctypes import windll try: current_locale = locale.windows_locale[ windll.kernel32.GetUserDefaultUILanguage()] current_locale += '.' + locale.getpreferredencoding() locale.setlocale(locale.LC_ALL, current_locale) except KeyError: try: current_locale = locale.setlocale(locale.LC_ALL, '') except Exception as e: logger(e) except Exception as e: logger(e) elif IS_MACOS: try: import Foundation defaults = Foundation.NSUserDefaults.standardUserDefaults() current_locale = defaults.objectForKey_('AppleLanguages')[0] current_locale = current_locale.replace('-', '_') locale.setlocale(locale.LC_ALL, current_locale) except Exception as e: logger(e) else: try: locale.setlocale(locale.LC_ALL, '') current_locale = '.'.join(locale.getlocale(locale.LC_MESSAGES)) except Exception as e: logger(e) os.environ['LANGUAGE'] = os.environ['LANG'] = current_locale QLocale.setDefault(QLocale(current_locale)) logger("Using locale %r", current_locale) try: logger("Loading gettext translation, localedir=%r", localedir) trans = gettext.translation("picard", localedir) logger("Loading gettext translation (picard-countries), localedir=%r", localedir) trans_countries = gettext.translation("picard-countries", localedir) logger("Loading gettext translation (picard-attributes), localedir=%r", localedir) trans_attributes = gettext.translation("picard-attributes", localedir) except IOError as e: logger(e) trans = gettext.NullTranslations() trans_countries = gettext.NullTranslations() trans_attributes = gettext.NullTranslations() trans.install(['ngettext']) builtins.__dict__['gettext_countries'] = trans_countries.gettext builtins.__dict__['gettext_attributes'] = trans_attributes.gettext logger("_ = %r", _) logger("N_ = %r", N_) logger("ngettext = %r", ngettext) logger("gettext_countries = %r", gettext_countries) logger("gettext_attributes = %r", gettext_attributes)
def paint(self, painter, option, index): painter.save() painter.setRenderHint(QPainter.Antialiasing) # Get data model and selection model = get_app().window.propertyTableView.clip_properties_model.model row = model.itemFromIndex(index).row() selected_label = model.item(row, 0) selected_value = model.item(row, 1) property = selected_label.data() # Get min/max values for this property property_name = property[1]["name"] property_type = property[1]["type"] property_max = property[1]["max"] property_min = property[1]["min"] readonly = property[1]["readonly"] keyframe = property[1]["keyframe"] points = property[1]["points"] interpolation = property[1]["interpolation"] # Calculate percentage value if property_type in ["float", "int"]: # Get the current value current_value = QLocale().system().toDouble( selected_value.text())[0] # Shift my range to be positive if property_min < 0.0: property_shift = 0.0 - property_min property_min += property_shift property_max += property_shift current_value += property_shift # Calculate current value as % of min/max range min_max_range = float(property_max) - float(property_min) value_percent = current_value / min_max_range else: value_percent = 0.0 # set background color painter.setPen(QPen(Qt.NoPen)) if property_type == "color": # Color keyframe red = property[1]["red"]["value"] green = property[1]["green"]["value"] blue = property[1]["blue"]["value"] painter.setBrush(QBrush(QColor(QColor(red, green, blue)))) else: # Normal Keyframe if option.state & QStyle.State_Selected: painter.setBrush(QBrush(QColor("#575757"))) else: painter.setBrush(QBrush(QColor("#3e3e3e"))) if not readonly: path = QPainterPath() path.addRoundedRect(QRectF(option.rect), 15, 15) painter.fillPath(path, QColor("#3e3e3e")) painter.drawPath(path) # Render mask rectangle painter.setBrush(QBrush(QColor("#000000"))) mask_rect = QRectF(option.rect) mask_rect.setWidth(option.rect.width() * value_percent) painter.setClipRect(mask_rect, Qt.IntersectClip) # gradient for value box gradient = QLinearGradient(option.rect.topLeft(), option.rect.topRight()) gradient.setColorAt(0, QColor("#828282")) gradient.setColorAt(1, QColor("#828282")) # Render progress painter.setBrush(gradient) path = QPainterPath() value_rect = QRectF(option.rect) path.addRoundedRect(value_rect, 15, 15) painter.fillPath(path, gradient) painter.drawPath(path) painter.setClipping(False) if points > 1: # Draw interpolation icon on top painter.drawPixmap( option.rect.x() + option.rect.width() - 30.0, option.rect.y() + 4, self.curve_pixmaps[interpolation]) # set text color painter.setPen(QPen(Qt.white)) value = index.data(Qt.DisplayRole) if value: painter.drawText(option.rect, Qt.AlignCenter, value) painter.restore()
def __init__(self, parent=None): """ Constructor @param parent reference to the parent object (QObject) """ super(SymbolsModel, self).__init__(parent) self.__locale = QLocale() self.__headerData = [ self.tr("Code"), self.tr("Char"), self.tr("Hex"), self.tr("HTML"), self.tr("Name"), ] self.__tables = [ # first last display name (0x0, 0x1f, self.tr("Control Characters")), (0x20, 0x7f, self.tr("Basic Latin")), (0x80, 0xff, self.tr("Latin-1 Supplement")), (0x100, 0x17f, self.tr("Latin Extended-A")), (0x180, 0x24f, self.tr("Latin Extended-B")), (0x250, 0x2af, self.tr("IPA Extensions")), (0x2b0, 0x2ff, self.tr("Spacing Modifier Letters")), (0x300, 0x36f, self.tr("Combining Diacritical Marks")), (0x370, 0x3ff, self.tr("Greek and Coptic")), (0x400, 0x4ff, self.tr("Cyrillic")), (0x500, 0x52f, self.tr("Cyrillic Supplement")), (0x530, 0x58f, self.tr("Armenian")), (0x590, 0x5ff, self.tr("Hebrew")), (0x600, 0x6ff, self.tr("Arabic")), (0x700, 0x74f, self.tr("Syriac")), (0x780, 0x7bf, self.tr("Thaana")), (0x7c0, 0x7ff, self.tr("N'Ko")), (0x800, 0x83f, self.tr("Samaritan")), (0x840, 0x85f, self.tr("Mandaic")), (0x8a0, 0x8ff, self.tr("Arabic Extended-A")), (0x900, 0x97f, self.tr("Devanagari")), (0x980, 0x9ff, self.tr("Bengali")), (0xa00, 0xa7f, self.tr("Gurmukhi")), (0xa80, 0xaff, self.tr("Gujarati")), (0xb00, 0xb7f, self.tr("Oriya")), (0xb80, 0xbff, self.tr("Tamil")), (0xc00, 0xc7f, self.tr("Telugu")), (0xc80, 0xcff, self.tr("Kannada")), (0xd00, 0xd7f, self.tr("Malayalam")), (0xd80, 0xdff, self.tr("Sinhala")), (0xe00, 0xe7f, self.tr("Thai")), (0xe80, 0xeff, self.tr("Lao")), (0xf00, 0xfff, self.tr("Tibetan")), (0x1000, 0x109f, self.tr("Myanmar")), (0x10a0, 0x10ff, self.tr("Georgian")), (0x1100, 0x11ff, self.tr("Hangul Jamo")), (0x1200, 0x137f, self.tr("Ethiopic")), (0x1380, 0x139f, self.tr("Ethiopic Supplement")), (0x13a0, 0x13ff, self.tr("Cherokee")), (0x1400, 0x167f, self.tr("Unified Canadian Aboriginal Syllabics")), (0x1680, 0x169f, self.tr("Ogham")), (0x16a0, 0x16ff, self.tr("Runic")), (0x1700, 0x171f, self.tr("Tagalog")), (0x1720, 0x173f, self.tr("Hanunoo")), (0x1740, 0x175f, self.tr("Buhid")), (0x1760, 0x177f, self.tr("Tagbanwa")), (0x1780, 0x17ff, self.tr("Khmer")), (0x1800, 0x18af, self.tr("Mongolian")), (0x18b0, 0x18ff, self.tr("Unified Canadian Aboriginal Syllabics Extended")), (0x1900, 0x194f, self.tr("Limbu")), (0x1950, 0x197f, self.tr("Tai Le")), (0x19e0, 0x19ff, self.tr("Khmer Symbols")), (0x1a00, 0x1a1f, self.tr("Buginese")), (0x1a20, 0x1aaf, self.tr("Tai Tham")), (0x1b00, 0x1b7f, self.tr("Balinese")), (0x1b80, 0x1bbf, self.tr("Sundanese")), (0x1bc0, 0x1bff, self.tr("Batak")), (0x1c00, 0x1c4f, self.tr("Lepcha")), (0x1c50, 0x1c7f, self.tr("Ol Chiki")), (0x1cc0, 0x1ccf, self.tr("Sundanese Supplement")), (0x1cd0, 0x1cff, self.tr("Vedic Extensions")), (0x1d00, 0x1d7f, self.tr("Phonetic Extensions")), (0x1d80, 0x1dbf, self.tr("Phonetic Extensions Supplement")), (0x1dc0, 0x1dff, self.tr("Combining Diacritical Marks Supplement")), (0x1e00, 0x1eff, self.tr("Latin Extended Additional")), (0x1f00, 0x1fff, self.tr("Greek Extended")), (0x2000, 0x206f, self.tr("General Punctuation")), (0x2070, 0x209f, self.tr("Superscripts and Subscripts")), (0x20a0, 0x20cf, self.tr("Currency Symbols")), (0x20d0, 0x20ff, self.tr("Combining Diacritical Marks")), (0x2100, 0x214f, self.tr("Letterlike Symbols")), (0x2150, 0x218f, self.tr("Number Forms")), (0x2190, 0x21ff, self.tr("Arcolumns")), (0x2200, 0x22ff, self.tr("Mathematical Operators")), (0x2300, 0x23ff, self.tr("Miscellaneous Technical")), (0x2400, 0x243f, self.tr("Control Pictures")), (0x2440, 0x245f, self.tr("Optical Character Recognition")), (0x2460, 0x24ff, self.tr("Enclosed Alphanumerics")), (0x2500, 0x257f, self.tr("Box Drawing")), (0x2580, 0x259f, self.tr("Block Elements")), (0x25A0, 0x25ff, self.tr("Geometric Shapes")), (0x2600, 0x26ff, self.tr("Miscellaneous Symbols")), (0x2700, 0x27bf, self.tr("Dingbats")), (0x27c0, 0x27ef, self.tr("Miscellaneous Mathematical Symbols-A")), (0x27f0, 0x27ff, self.tr("Supplement Arcolumns-A")), (0x2800, 0x28ff, self.tr("Braille Patterns")), (0x2900, 0x297f, self.tr("Supplement Arcolumns-B")), (0x2980, 0x29ff, self.tr("Miscellaneous Mathematical Symbols-B")), (0x2a00, 0x2aff, self.tr("Supplemental Mathematical Operators")), (0x2b00, 0x2bff, self.tr("Miscellaneous Symbols and Arcolumns")), (0x2c00, 0x2c5f, self.tr("Glagolitic")), (0x2c60, 0x2c7f, self.tr("Latin Extended-C")), (0x2c80, 0x2cff, self.tr("Coptic")), (0x2d00, 0x2d2f, self.tr("Georgian Supplement")), (0x2d30, 0x2d7f, self.tr("Tifinagh")), (0x2d80, 0x2ddf, self.tr("Ethiopic Extended")), (0x2de0, 0x2dff, self.tr("Cyrillic Extended-A")), (0x2e00, 0x2e7f, self.tr("Supplemental Punctuation")), (0x2e80, 0x2eff, self.tr("CJK Radicals Supplement")), (0x2f00, 0x2fdf, self.tr("KangXi Radicals")), (0x2ff0, 0x2fff, self.tr("Ideographic Description Chars")), (0x3000, 0x303f, self.tr("CJK Symbols and Punctuation")), (0x3040, 0x309f, self.tr("Hiragana")), (0x30a0, 0x30ff, self.tr("Katakana")), (0x3100, 0x312f, self.tr("Bopomofo")), (0x3130, 0x318f, self.tr("Hangul Compatibility Jamo")), (0x3190, 0x319f, self.tr("Kanbun")), (0x31a0, 0x31bf, self.tr("Bopomofo Extended")), (0x31c0, 0x31ef, self.tr("CJK Strokes")), (0x31f0, 0x31ff, self.tr("Katakana Phonetic Extensions")), (0x3200, 0x32ff, self.tr("Enclosed CJK Letters and Months")), (0x3300, 0x33ff, self.tr("CJK Compatibility")), (0x3400, 0x4dbf, self.tr("CJK Unified Ideogr. Ext. A")), (0x4dc0, 0x4dff, self.tr("Yijing Hexagram Symbols")), (0x4e00, 0x9fff, self.tr("CJK Unified Ideographs")), (0xa000, 0xa48f, self.tr("Yi Syllables")), (0xa490, 0xa4cf, self.tr("Yi Radicals")), (0xa4d0, 0xa4ff, self.tr("Lisu")), (0xa500, 0xa63f, self.tr("Vai")), (0xa640, 0xa69f, self.tr("Cyrillic Extended-B")), (0xa6a0, 0xa6ff, self.tr("Bamum")), (0xa700, 0xa71f, self.tr("Modifier Tone Letters")), (0xa720, 0xa7ff, self.tr("Latin Extended-D")), (0xa800, 0xa82f, self.tr("Syloti Nagri")), (0xa830, 0xa83f, self.tr("Common Indic Number Forms")), (0xa840, 0xa87f, self.tr("Phags-pa")), (0xa880, 0xa8df, self.tr("Saurashtra")), (0xa8e0, 0xa8ff, self.tr("Devanagari Extended")), (0xa900, 0xa92f, self.tr("Kayah Li")), (0xa930, 0xa95f, self.tr("Rejang")), (0xa960, 0xa97f, self.tr("Hangul Jamo Extended-A")), (0xa980, 0xa9df, self.tr("Javanese")), (0xaa00, 0xaa5f, self.tr("Cham")), (0xaa60, 0xaa7f, self.tr("Myanmar Extended-A")), (0xaa80, 0xaadf, self.tr("Tai Viet")), (0xaae0, 0xaaff, self.tr("Meetei Mayek Extensions")), (0xab00, 0xab2f, self.tr("Ethiopic Extended-A")), (0xabc0, 0xabff, self.tr("Meetei Mayek")), (0xac00, 0xd7af, self.tr("Hangul Syllables")), (0xd7b0, 0xd7ff, self.tr("Hangul Jamo Extended-B")), (0xd800, 0xdb7f, self.tr("High Surrogates")), (0xdb80, 0xdbff, self.tr("High Private Use Surrogates")), (0xdc00, 0xdfff, self.tr("Low Surrogates")), (0xe000, 0xf8ff, self.tr("Private Use")), (0xf900, 0xfaff, self.tr("CJK Compatibility Ideographs")), (0xfb00, 0xfb4f, self.tr("Alphabetic Presentation Forms")), (0xfb50, 0xfdff, self.tr("Arabic Presentation Forms-A")), (0xfe00, 0xfe0f, self.tr("Variation Selectors")), (0xfe10, 0xfe1f, self.tr("Vertical Forms")), (0xfe20, 0xfe2f, self.tr("Combining Half Marks")), (0xfe30, 0xfe4f, self.tr("CJK Compatibility Forms")), (0xfe50, 0xfe6f, self.tr("Small Form Variants")), (0xfe70, 0xfeff, self.tr("Arabic Presentation Forms-B")), (0xff00, 0xffef, self.tr("Half- and Fullwidth Forms")), (0xfff0, 0xffff, self.tr("Specials")), ] if sys.maxunicode > 0xffff: self.__tables.extend([ (0x10000, 0x1007f, self.tr("Linear B Syllabary")), (0x10080, 0x100ff, self.tr("Linear B Ideograms")), (0x10100, 0x1013f, self.tr("Aegean Numbers")), (0x10140, 0x1018f, self.tr("Ancient Greek Numbers")), (0x10190, 0x101cf, self.tr("Ancient Symbols")), (0x101d0, 0x101ff, self.tr("Phaistos Disc")), (0x10280, 0x1029f, self.tr("Lycian")), (0x102a0, 0x102df, self.tr("Carian")), (0x10300, 0x1032f, self.tr("Old Italic")), (0x10330, 0x1034f, self.tr("Gothic")), (0x10380, 0x1039f, self.tr("Ugaritic")), (0x103a0, 0x103df, self.tr("Old Persian")), (0x10400, 0x1044f, self.tr("Deseret")), (0x10450, 0x1047f, self.tr("Shavian")), (0x10480, 0x104af, self.tr("Osmanya")), (0x10800, 0x1083f, self.tr("Cypriot Syllabary")), (0x10840, 0x1085f, self.tr("Imperial Aramaic")), (0x10900, 0x1091f, self.tr("Phoenician")), (0x10920, 0x1093f, self.tr("Lydian")), (0x10980, 0x1099f, self.tr("Meroitic Hieroglyphs")), (0x109a0, 0x109ff, self.tr("Meroitic Cursive")), (0x10a00, 0x10a5f, self.tr("Kharoshthi")), (0x10a60, 0x10a7f, self.tr("Old South Arabian")), (0x10b00, 0x10b3f, self.tr("Avestan")), (0x10b40, 0x10b5f, self.tr("Inscriptional Parthian")), (0x10b60, 0x10b7f, self.tr("Inscriptional Pahlavi")), (0x10c00, 0x10c4f, self.tr("Old Turkic")), (0x10e60, 0x10e7f, self.tr("Rumi Numeral Symbols")), (0x11000, 0x1107f, self.tr("Brahmi")), (0x11080, 0x110cf, self.tr("Kaithi")), (0x110d0, 0x110ff, self.tr("Sora Sompeng")), (0x11100, 0x1114f, self.tr("Chakma")), (0x11180, 0x111df, self.tr("Sharada")), (0x11680, 0x116cf, self.tr("Takri")), (0x12000, 0x123ff, self.tr("Cuneiform")), (0x12400, 0x1247f, self.tr("Cuneiform Numbers and Punctuation")), (0x13000, 0x1342f, self.tr("Egyptian Hieroglyphs")), (0x16800, 0x16a3f, self.tr("Bamum Supplement")), (0x16f00, 0x16f9f, self.tr("Miao")), (0x1b000, 0x1b0ff, self.tr("Kana Supplement")), (0x1d000, 0x1d0ff, self.tr("Byzantine Musical Symbols")), (0x1d100, 0x1d1ff, self.tr("Musical Symbols")), (0x1d200, 0x1d24f, self.tr("Ancient Greek Musical Notation")), (0x1d300, 0x1d35f, self.tr("Tai Xuan Jing Symbols")), (0x1d360, 0x1d37f, self.tr("Counting Rod Numerals")), (0x1d400, 0x1d7ff, self.tr("Mathematical Alphanumeric Symbols")), (0x1ee00, 0x1eeff, self.tr("Arabic Mathematical Alphabetic Symbols")), (0x1f000, 0x1f02f, self.tr("Mahjong Tiles")), (0x1f030, 0x1f09f, self.tr("Domino Tiles")), (0x1f0a0, 0x1f0ff, self.tr("Playing Cards")), (0x1f100, 0x1f1ff, self.tr("Enclosed Alphanumeric Supplement")), (0x1f200, 0x1f2ff, self.tr("Enclosed Ideographic Supplement")), (0x1f300, 0x1f5ff, self.tr("Miscellaneous Symbols And Pictographs")), (0x1f600, 0x1f64f, self.tr("Emoticons")), (0x1f680, 0x1f6ff, self.tr("Transport And Map Symbols")), (0x1f700, 0x1f77f, self.tr("Alchemical Symbols")), (0x20000, 0x2a6df, self.tr("CJK Unified Ideogr. Ext. B")), (0x2a700, 0x2b73f, self.tr("CJK Unified Ideographs Extension C")), (0x2b740, 0x2b81f, self.tr("CJK Unified Ideographs Extension D")), (0x2f800, 0x2fa1f, self.tr("CJK Compatapility Ideogr. Suppl.")), (0xe0000, 0xe007f, self.tr("Tags")), (0xe0100, 0xe01ef, self.tr("Variation Selectors Supplement")), (0xf0000, 0xfffff, self.tr("Supplementary Private Use Area-A")), (0x100000, 0x10ffff, self.tr("Supplementary Private Use Area-B")), ]) self.__currentTableIndex = 0
def __init__(self, settings, parent=None): super().__init__(parent=parent) self.settings = settings urlGroupBox = QGroupBox('Query URLs', self) self.downloadUrlLE = QLineEdit( self.settings.value('downloadURL', type=str), self) self.uploadUrlLE = QLineEdit( self.settings.value('uploadURL', type=str), self) self.listFolderUrlLE = QLineEdit( self.settings.value('listFolderURL', type=str), self) urlLayout = QGridLayout() urlLayout.addWidget(QLabel('Download URL:'), 0, 0) urlLayout.addWidget(self.downloadUrlLE, 0, 1) urlLayout.addWidget(QLabel('Upload URL:'), 1, 0) urlLayout.addWidget(self.uploadUrlLE, 1, 1) urlLayout.addWidget(QLabel('List folder URL:'), 2, 0) urlLayout.addWidget(self.listFolderUrlLE, 2, 1) urlLayout.setColumnMinimumWidth(1, 300) urlGroupBox.setLayout(urlLayout) miscGroupBox = QGroupBox('Miscellaneous', self) locale = QLocale() val = locale.toString(self.settings.value('HTTPTimeout', type=int)) self.httpTimeoutLE = QLineEdit(val, self) self.httpTimeoutLE.setValidator( QIntValidator(constants.HttpTimeoutMin, constants.HttpTimeoutMax, self)) val = locale.toString(self.settings.value('HTTPShortTimeout', type=float), precision=constants.HttpShortTimeoutMaxDecimals) self.httpShortTimeoutLE = QLineEdit(val, self) self.httpShortTimeoutLE.setValidator( QDoubleValidator(constants.HttpShortTimeoutMin, constants.HttpShortTimeoutMax, constants.HttpShortTimeoutMaxDecimals, self)) val = locale.toString(self.settings.value('PNGResolution', type=int)) self.pngResolutionLE = QLineEdit(val, self) self.pngResolutionLE.setValidator( QIntValidator(constants.PngExportDpiMin, constants.PngExportDpiMax, self)) miscLayout = QGridLayout() miscLayout.addWidget(QLabel('HTTP timeout (s):'), 0, 0) miscLayout.addWidget(self.httpTimeoutLE, 0, 1) miscLayout.addWidget(QLabel('HTTP short timeout (s):'), 1, 0) miscLayout.addWidget(self.httpShortTimeoutLE, 1, 1) miscLayout.addWidget(QLabel('PNG export resolution (dpi):'), 2, 0) miscLayout.addWidget(self.pngResolutionLE, 2, 1) miscGroupBox.setLayout(miscLayout) securityGroupBox = QGroupBox('Security', self) self.changePassphraseBtn = QPushButton("Set/change", self) self.changePassphraseBtn.clicked.connect(self.changePassphrase) self.deletePassphraseBtn = QPushButton("Delete", self) self.deletePassphraseBtn.clicked.connect(self.deletePassphrase) securityLayout = QGridLayout() securityLayout.addWidget( QLabel('Set or change the master passphrase:'), 0, 0) securityLayout.addWidget(self.changePassphraseBtn, 0, 1) securityLayout.addWidget(QLabel('Delete the master passphrase:'), 1, 0) securityLayout.addWidget(self.deletePassphraseBtn, 1, 1) securityGroupBox.setLayout(securityLayout) sshGroupBox = QGroupBox('SSH', self) self.sshHostLE = QLineEdit( self.settings.value('TabletHostname', type=str), self) self.sshUsernameLE = QLineEdit( self.settings.value('SSHUsername', type=str), self) self.changeSSHPasswordBtn = QPushButton("Set/change", self) self.changeSSHPasswordBtn.clicked.connect(self.changeSSHPassword) self.tabletDocsDirLE = QLineEdit( self.settings.value('TabletDocumentsDir', type=str), self) sshLayout = QGridLayout() sshLayout.addWidget(QLabel('Hostname or IP address:'), 0, 0) sshLayout.addWidget(self.sshHostLE, 0, 1) sshLayout.addWidget(QLabel('Username:'******'Password:'******'Documents directory:'), 3, 0) sshLayout.addWidget(self.tabletDocsDirLE, 3, 1) sshGroupBox.setLayout(sshLayout) mainLayout = QVBoxLayout() mainLayout.addWidget(urlGroupBox) mainLayout.addWidget(miscGroupBox) mainLayout.addWidget(securityGroupBox) mainLayout.addWidget(sshGroupBox) self.setLayout(mainLayout) self.updateWindowState() self.setWindowTitle('Settings') self.accepted.connect(self.updateSettings)
def __init__(self, parent=None): QLocale.setDefault(QLocale(QLocale.English, QLocale.UnitedStates)) super(ImageWidget, self).__init__(parent) self.setupUI()
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 __init__(self, persepolis_setting): super().__init__() icon = QtGui.QIcon() # add support for other languages locale = str(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 = 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(persepolis_setting.value('settings/icons')) + '/' self.verticalLayout_2 = QVBoxLayout(self) self.setting_tabWidget = QTabWidget(self) # download_options_tab self.download_options_tab = QWidget() self.layoutWidget = QWidget(self.download_options_tab) self.download_options_verticalLayout = QVBoxLayout(self.layoutWidget) self.download_options_verticalLayout.setContentsMargins(21, 21, 0, 0) self.download_options_verticalLayout.setObjectName( "download_options_verticalLayout") self.horizontalLayout_5 = QHBoxLayout() # tries_label self.tries_label = QLabel(self.layoutWidget) self.horizontalLayout_5.addWidget(self.tries_label) # tries_spinBox self.tries_spinBox = QSpinBox(self.layoutWidget) self.tries_spinBox.setMinimum(1) self.horizontalLayout_5.addWidget(self.tries_spinBox) self.download_options_verticalLayout.addLayout(self.horizontalLayout_5) self.horizontalLayout_4 = QHBoxLayout() # wait_label self.wait_label = QLabel(self.layoutWidget) self.horizontalLayout_4.addWidget(self.wait_label) # wait_spinBox self.wait_spinBox = QSpinBox(self.layoutWidget) self.horizontalLayout_4.addWidget(self.wait_spinBox) self.download_options_verticalLayout.addLayout(self.horizontalLayout_4) self.horizontalLayout_3 = QHBoxLayout() # time_out_label self.time_out_label = QLabel(self.layoutWidget) self.horizontalLayout_3.addWidget(self.time_out_label) # time_out_spinBox self.time_out_spinBox = QSpinBox(self.layoutWidget) self.horizontalLayout_3.addWidget(self.time_out_spinBox) self.download_options_verticalLayout.addLayout(self.horizontalLayout_3) self.horizontalLayout_2 = QHBoxLayout() # connections_label self.connections_label = QLabel(self.layoutWidget) self.horizontalLayout_2.addWidget(self.connections_label) # connections_spinBox self.connections_spinBox = QSpinBox(self.layoutWidget) self.connections_spinBox.setMinimum(1) self.connections_spinBox.setMaximum(16) self.horizontalLayout_2.addWidget(self.connections_spinBox) self.download_options_verticalLayout.addLayout(self.horizontalLayout_2) # rpc_port_label self.rpc_port_label = QLabel(self.layoutWidget) self.rpc_horizontalLayout = QHBoxLayout() self.rpc_horizontalLayout.addWidget(self.rpc_port_label) # rpc_port_spinbox self.rpc_port_spinbox = QSpinBox(self.layoutWidget) self.rpc_port_spinbox.setMinimum(1024) self.rpc_port_spinbox.setMaximum(65535) self.rpc_horizontalLayout.addWidget(self.rpc_port_spinbox) self.download_options_verticalLayout.addLayout( self.rpc_horizontalLayout) # wait_queue wait_queue_horizontalLayout = QHBoxLayout() self.wait_queue_label = QLabel(self.layoutWidget) wait_queue_horizontalLayout.addWidget(self.wait_queue_label) self.wait_queue_time = QDateTimeEdit(self.layoutWidget) self.wait_queue_time.setDisplayFormat('H:mm') wait_queue_horizontalLayout.addWidget(self.wait_queue_time) self.download_options_verticalLayout.addLayout( wait_queue_horizontalLayout) # change aria2 path aria2_path_verticalLayout = QVBoxLayout() self.aria2_path_checkBox = QCheckBox(self.layoutWidget) aria2_path_verticalLayout.addWidget(self.aria2_path_checkBox) aria2_path_horizontalLayout = QHBoxLayout() self.aria2_path_lineEdit = QLineEdit(self.layoutWidget) aria2_path_horizontalLayout.addWidget(self.aria2_path_lineEdit) self.aria2_path_pushButton = QPushButton(self.layoutWidget) aria2_path_horizontalLayout.addWidget(self.aria2_path_pushButton) aria2_path_verticalLayout.addLayout(aria2_path_horizontalLayout) self.download_options_verticalLayout.addLayout( aria2_path_verticalLayout) self.setting_tabWidget.addTab(self.download_options_tab, "") # save_as_tab self.save_as_tab = QWidget() self.layoutWidget1 = QWidget(self.save_as_tab) self.save_as_verticalLayout = QVBoxLayout(self.layoutWidget1) self.save_as_verticalLayout.setContentsMargins(20, 30, 0, 0) self.download_folder_horizontalLayout = QHBoxLayout() # download_folder_label self.download_folder_label = QLabel(self.layoutWidget1) self.download_folder_horizontalLayout.addWidget( self.download_folder_label) # download_folder_lineEdit self.download_folder_lineEdit = QLineEdit(self.layoutWidget1) self.download_folder_horizontalLayout.addWidget( self.download_folder_lineEdit) # download_folder_pushButton self.download_folder_pushButton = QPushButton(self.layoutWidget1) self.download_folder_horizontalLayout.addWidget( self.download_folder_pushButton) self.save_as_verticalLayout.addLayout( self.download_folder_horizontalLayout) self.temp_horizontalLayout = QHBoxLayout() # temp_download_label self.temp_download_label = QLabel(self.layoutWidget1) self.temp_horizontalLayout.addWidget(self.temp_download_label) # temp_download_lineEdit self.temp_download_lineEdit = QLineEdit(self.layoutWidget1) self.temp_horizontalLayout.addWidget(self.temp_download_lineEdit) # temp_download_pushButton self.temp_download_pushButton = QPushButton(self.layoutWidget1) self.temp_horizontalLayout.addWidget(self.temp_download_pushButton) self.save_as_verticalLayout.addLayout(self.temp_horizontalLayout) # create subfolder checkBox self.subfolder_checkBox = QCheckBox(self.layoutWidget1) self.save_as_verticalLayout.addWidget(self.subfolder_checkBox) self.setting_tabWidget.addTab(self.save_as_tab, "") # notifications_tab self.notifications_tab = QWidget() self.layoutWidget2 = QWidget(self.notifications_tab) self.verticalLayout_4 = QVBoxLayout(self.layoutWidget2) self.verticalLayout_4.setContentsMargins(21, 21, 0, 0) # enable_notifications_checkBox self.enable_notifications_checkBox = QCheckBox(self.layoutWidget2) self.verticalLayout_4.addWidget(self.enable_notifications_checkBox) # sound_frame self.sound_frame = QFrame(self.layoutWidget2) self.sound_frame.setFrameShape(QFrame.StyledPanel) self.sound_frame.setFrameShadow(QFrame.Raised) self.verticalLayout = QVBoxLayout(self.sound_frame) # volume_label self.volume_label = QLabel(self.sound_frame) self.verticalLayout.addWidget(self.volume_label) # volume_dial self.volume_dial = QDial(self.sound_frame) self.volume_dial.setProperty("value", 100) self.verticalLayout.addWidget(self.volume_dial) self.verticalLayout_4.addWidget(self.sound_frame) self.setting_tabWidget.addTab(self.notifications_tab, "") # style_tab self.style_tab = QWidget() self.layoutWidget3 = QWidget(self.style_tab) self.verticalLayout_3 = QVBoxLayout(self.layoutWidget3) self.verticalLayout_3.setContentsMargins(21, 21, 0, 0) self.horizontalLayout_8 = QHBoxLayout() # style_label self.style_label = QLabel(self.layoutWidget3) self.horizontalLayout_8.addWidget(self.style_label) # style_comboBox self.style_comboBox = QComboBox(self.layoutWidget3) self.horizontalLayout_8.addWidget(self.style_comboBox) self.verticalLayout_3.addLayout(self.horizontalLayout_8) self.horizontalLayout_7 = QHBoxLayout() # language_combox self.lang_label = QLabel(self.layoutWidget3) self.horizontalLayout_7.addWidget(self.lang_label) self.lang_comboBox = QComboBox(self.layoutWidget3) self.horizontalLayout_7.addWidget(self.lang_comboBox) # language_label self.verticalLayout_3.addLayout(self.horizontalLayout_7) self.horizontalLayout_7 = QHBoxLayout() self.lang_label.setText( QCoreApplication.translate("setting_ui_tr", "language :")) # color_label self.color_label = QLabel(self.layoutWidget3) self.horizontalLayout_7.addWidget(self.color_label) # color_comboBox self.color_comboBox = QComboBox(self.layoutWidget3) self.horizontalLayout_7.addWidget(self.color_comboBox) self.verticalLayout_3.addLayout(self.horizontalLayout_7) # icon_label self.horizontalLayout_12 = QHBoxLayout() self.icon_label = QLabel(self.layoutWidget3) self.horizontalLayout_12.addWidget(self.icon_label) # icon_comboBox self.icon_comboBox = QComboBox(self.layoutWidget3) self.horizontalLayout_12.addWidget(self.icon_comboBox) self.verticalLayout_3.addLayout(self.horizontalLayout_12) # icons_size_comboBox self.icons_size_horizontalLayout = QHBoxLayout() self.icons_size_label = QLabel(self.layoutWidget3) self.icons_size_horizontalLayout.addWidget(self.icons_size_label) self.icons_size_comboBox = QComboBox(self.layoutWidget3) self.icons_size_horizontalLayout.addWidget(self.icons_size_comboBox) self.verticalLayout_3.addLayout(self.icons_size_horizontalLayout) self.horizontalLayout_6 = QHBoxLayout() # notification_label self.horizontalLayout_13 = QHBoxLayout() self.notification_label = QLabel(self.layoutWidget3) self.horizontalLayout_13.addWidget(self.notification_label) # notification_comboBox self.notification_comboBox = QComboBox(self.layoutWidget3) self.horizontalLayout_13.addWidget(self.notification_comboBox) self.verticalLayout_3.addLayout(self.horizontalLayout_13) # font_checkBox self.font_checkBox = QCheckBox(self.layoutWidget3) self.horizontalLayout_6.addWidget(self.font_checkBox) # fontComboBox self.fontComboBox = QFontComboBox(self.layoutWidget3) self.horizontalLayout_6.addWidget(self.fontComboBox) # font_size_label self.font_size_label = QLabel(self.layoutWidget3) self.horizontalLayout_6.addWidget(self.font_size_label) # font_size_spinBox self.font_size_spinBox = QSpinBox(self.layoutWidget3) self.font_size_spinBox.setMinimum(1) self.horizontalLayout_6.addWidget(self.font_size_spinBox) self.verticalLayout_3.addLayout(self.horizontalLayout_6) self.setting_tabWidget.addTab(self.style_tab, "") self.verticalLayout_2.addWidget(self.setting_tabWidget) self.horizontalLayout = QHBoxLayout() spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem) # Enable system tray icon self.enable_system_tray_checkBox = QCheckBox(self.layoutWidget3) self.verticalLayout_3.addWidget(self.enable_system_tray_checkBox) # after_download dialog self.after_download_checkBox = QCheckBox() self.verticalLayout_3.addWidget(self.after_download_checkBox) # show_menubar_checkbox self.show_menubar_checkbox = QCheckBox() self.verticalLayout_3.addWidget(self.show_menubar_checkbox) # show_sidepanel_checkbox self.show_sidepanel_checkbox = QCheckBox() self.verticalLayout_3.addWidget(self.show_sidepanel_checkbox) # hide progress window self.show_progress_window_checkbox = QCheckBox() self.verticalLayout_3.addWidget(self.show_progress_window_checkbox) # add persepolis to startup self.startup_checkbox = QCheckBox() self.verticalLayout_3.addWidget(self.startup_checkbox) # keep system awake self.keep_awake_checkBox = QCheckBox() self.verticalLayout_3.addWidget(self.keep_awake_checkBox) # columns_tab self.columns_tab = QWidget() layoutWidget4 = QWidget(self.columns_tab) column_verticalLayout = QVBoxLayout(layoutWidget4) column_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() column_verticalLayout.addWidget(self.show_column_label) column_verticalLayout.addWidget(self.column0_checkBox) column_verticalLayout.addWidget(self.column1_checkBox) column_verticalLayout.addWidget(self.column2_checkBox) column_verticalLayout.addWidget(self.column3_checkBox) column_verticalLayout.addWidget(self.column4_checkBox) column_verticalLayout.addWidget(self.column5_checkBox) column_verticalLayout.addWidget(self.column6_checkBox) column_verticalLayout.addWidget(self.column7_checkBox) column_verticalLayout.addWidget(self.column10_checkBox) column_verticalLayout.addWidget(self.column11_checkBox) column_verticalLayout.addWidget(self.column12_checkBox) self.setting_tabWidget.addTab(self.columns_tab, '') # youtube_tab self.youtube_tab = QWidget() self.layoutWidgetYTD = QWidget(self.youtube_tab) self.youtube_layout = QVBoxLayout(self.layoutWidgetYTD) self.youtube_layout.setContentsMargins(20, 30, 0, 0) self.youtube_verticalLayout = QVBoxLayout() # Whether to enable video link capturing. self.enable_ytd_checkbox = QCheckBox(self.layoutWidgetYTD) self.youtube_layout.addWidget(self.enable_ytd_checkbox) # If we should hide videos with no audio self.hide_no_audio_checkbox = QCheckBox(self.layoutWidgetYTD) self.youtube_verticalLayout.addWidget(self.hide_no_audio_checkbox) # If we should hide audios without video self.hide_no_video_checkbox = QCheckBox(self.layoutWidgetYTD) self.youtube_verticalLayout.addWidget(self.hide_no_video_checkbox) self.max_links_horizontalLayout = QHBoxLayout() # max_links_label self.max_links_label = QLabel(self.layoutWidgetYTD) self.max_links_horizontalLayout.addWidget(self.max_links_label) # max_links_spinBox self.max_links_spinBox = QSpinBox(self.layoutWidgetYTD) self.max_links_spinBox.setMinimum(1) self.max_links_spinBox.setMaximum(16) self.max_links_horizontalLayout.addWidget(self.max_links_spinBox) self.youtube_verticalLayout.addLayout(self.max_links_horizontalLayout) self.youtube_dl_path_horizontalLayout = QHBoxLayout() self.youtube_frame = QFrame(self.youtube_tab) self.youtube_frame.setLayout(self.youtube_verticalLayout) self.youtube_layout.addWidget(self.youtube_frame) self.setting_tabWidget.addTab(self.youtube_tab, "") # defaults_pushButton self.defaults_pushButton = QPushButton(self) self.horizontalLayout.addWidget(self.defaults_pushButton) # cancel_pushButton self.cancel_pushButton = QPushButton(self) self.cancel_pushButton.setIcon(QIcon(icons + 'remove')) self.horizontalLayout.addWidget(self.cancel_pushButton) # ok_pushButton self.ok_pushButton = QPushButton(self) self.ok_pushButton.setIcon(QIcon(icons + 'ok')) self.horizontalLayout.addWidget(self.ok_pushButton) self.verticalLayout_2.addLayout(self.horizontalLayout) self.setting_tabWidget.setCurrentIndex(3) 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 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", "Time out (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 between every downloads in queue:')) 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 have caused problem! 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's 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.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 has 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's 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 is preventing system from going to sleep.\ This is necessary if your power manager is suspending 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 this 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.youtube_tab), QCoreApplication.translate("setting_ui_tr", "Video Finder Options")) self.enable_ytd_checkbox.setText( QCoreApplication.translate("setting_ui_tr", 'Enable Video Finder')) self.hide_no_audio_checkbox.setText( QCoreApplication.translate("setting_ui_tr", 'Hide videos with no audio')) self.hide_no_video_checkbox.setText( QCoreApplication.translate("setting_ui_tr", 'Hide audios with no video')) 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"))
def __init__(self, parent=None, *args_plotitem, **kwargs_plotitem): QLocale.setDefault(QLocale(QLocale.English, QLocale.UnitedStates)) super(ImageWidget, self).__init__(parent) self.setupUI(*args_plotitem, **kwargs_plotitem)
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.01' # 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.0.1')) 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)
def data(self, index, role): source_index = self.mapToSource(index) if source_index.isValid(): source_data = self.sourceModel().data(source_index, role) publication_col = CertifiersTableModel.columns_ids.index( 'publication') publication_index = self.sourceModel().index( source_index.row(), publication_col) expiration_col = CertifiersTableModel.columns_ids.index( 'expiration') expiration_index = self.sourceModel().index( source_index.row(), expiration_col) written_col = CertifiersTableModel.columns_ids.index('written') written_index = self.sourceModel().index(source_index.row(), written_col) publication_data = self.sourceModel().data(publication_index, Qt.DisplayRole) expiration_data = self.sourceModel().data(expiration_index, Qt.DisplayRole) written_data = self.sourceModel().data(written_index, Qt.DisplayRole) current_time = QDateTime().currentDateTime().toMSecsSinceEpoch() warning_expiration_time = int( (expiration_data - publication_data) / 3) #logging.debug("{0} > {1}".format(current_time, expiration_data)) if role == Qt.DisplayRole: if source_index.column( ) == CertifiersTableModel.columns_ids.index('expiration'): if source_data: ts = self.blockchain_processor.adjusted_ts( self.app.currency, source_data) return QLocale.toString( QLocale(), QDateTime.fromTime_t(ts), QLocale.dateTimeFormat( QLocale(), QLocale.ShortFormat)) + " BAT" else: return "" if source_index.column( ) == CertifiersTableModel.columns_ids.index('publication'): if source_data: ts = self.blockchain_processor.adjusted_ts( self.app.currency, source_data) return QLocale.toString( QLocale(), QDateTime.fromTime_t(ts), QLocale.dateTimeFormat( QLocale(), QLocale.ShortFormat)) + " BAT" else: return "" if source_index.column( ) == CertifiersTableModel.columns_ids.index('pubkey'): return source_data if role == Qt.FontRole: font = QFont() if not written_data: font.setItalic(True) return font if role == Qt.ForegroundRole: if current_time > ((expiration_data * 1000) - (warning_expiration_time * 1000)): return QColor("darkorange").darker(120) return source_data