def initUI(self): """ Init widget """ vbox = QVBoxLayout() vbox.addSpacing(2) # Head hbox = QHBoxLayout() hbox.addSpacing(2) # Create button which returns to the menu self._buttonBack = QPushButton(QIcon(PATH_IMAGE_BACK_NEDDLE), "", self) self._buttonBack.clicked.connect(self.signalController.back2menu) hbox.addWidget(self._buttonBack, 0, QtCore.Qt.AlignLeft) # Header of this widget self._headWidget = QLabel("About game") hbox.addWidget(self._headWidget, 1, QtCore.Qt.AlignCenter) vbox.addLayout(hbox, 0) # Create text about game text = ABOUT_GAME_STR self.textAboutGame = QLabel(text) self.textAboutGame.setWordWrap(True) self.setFont(QFont("Times", 12, QFont.Bold)) vbox.addWidget(self.textAboutGame, 1, QtCore.Qt.AlignCenter) self.setLayout(vbox) self.setWindowTitle("About game")
def initUI(self): """ Init widget """ vbox = QVBoxLayout() vbox.addSpacing(2) # Head hbox = QHBoxLayout() hbox.addSpacing(3) # Create button which returns to the menu self._buttonBack = QPushButton(QIcon(PATH_IMAGE_BACK_NEDDLE), "", self) self._buttonBack.clicked.connect(self.signalController.back2menu) hbox.addWidget(self._buttonBack, 0, QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) # Header of this widget self._headWidget = QLabel("Add new figure") hbox.addWidget(self._headWidget, 1, QtCore.Qt.AlignCenter | QtCore.Qt.AlignTop) # Create button to choose color of new figure self._pickColorButton = QPushButton('Pick color') self._pickColorButton.clicked.connect(self.update_color_name) hbox.addWidget(self._pickColorButton, 2, QtCore.Qt.AlignRight | QtCore.Qt.AlignTop) # Create button to save figure self._saveFigureButton = QPushButton('Save') self._saveFigureButton.clicked.connect(self.save_figure_shape) hbox.addWidget(self._saveFigureButton, 2, QtCore.Qt.AlignRight | QtCore.Qt.AlignTop) vbox.addLayout(hbox, 0) grid = QGridLayout() self._sheet = [] self._choosenFigureList = [] self._proposedFiguresList = [] self._savedColor = 'black' for i in range(self.MAX_X): row = [] for j in range(self.MAX_Y): single = DrawBlockQFrame(self.signalPressedFrames, j, i) if i == 3 and j == 3: # Button in the center - must be with blur color # Save figure - possible only if blue button also clicked # This magic stuff are made in order to simplify saving figure single.COLOR_DEFAULT = 'blue' single.default_color() self.centerSheet = single row.append(single) grid.addWidget(single, i, j) self._sheet.append(row) vbox.addLayout(grid, 1) self.setLayout(vbox) self.setWindowTitle("Add new figure")
def initUI(self): """ Init widget """ grid = QGridLayout() hbox = QHBoxLayout() hbox.addSpacing(2) self._buttonBack = QPushButton(QIcon(PATH_IMAGE_BACK_NEDDLE), "", self) self._buttonBack.clicked.connect(self.signalController.back2menu) hbox.addWidget(self._buttonBack, 0, QtCore.Qt.AlignLeft) self.label = QLabel("SettingsView") hbox.addWidget(self.label, 1, QtCore.Qt.AlignCenter) grid.addLayout(hbox, 0, 0, QtCore.Qt.AlignTop) jsonDataSettings = self.get_settings(None) # TODO: Possibility to change settings via this widget #self._labels_settings = [] counter = 1 for name in jsonDataSettings: single = jsonDataSettings[name] translated = single[self.TRANSLATED] value = single[self.VALUE] newLabel = QLabel(name.replace('_', ' ')) if translated: secondLabel = QLabel(QKeySequence(value).toString()) else: secondLabel = QLabel(str(value)) grid.addWidget(newLabel, counter, 0, QtCore.Qt.AlignLeft) grid.addWidget(secondLabel, counter, 1, QtCore.Qt.AlignRight) counter += 1 self.setLayout(grid) self.setWindowTitle("Game settings")
def __init__(self, persepolis_setting): super().__init__() # MainWindow self.persepolis_setting = persepolis_setting # add support for other languages locale = str(self.persepolis_setting.value('settings/locale')) QLocale.setDefault(QLocale(locale)) self.translator = QTranslator() if self.translator.load(':/translations/locales/ui_' + locale, 'ts'): QCoreApplication.installTranslator(self.translator) # set ui direction ui_direction = self.persepolis_setting.value('ui_direction') if ui_direction == 'rtl': self.setLayoutDirection(Qt.RightToLeft) elif ui_direction in 'ltr': self.setLayoutDirection(Qt.LeftToRight) icons = ':/' + \ str(self.persepolis_setting.value('settings/icons')) + '/' self.setWindowTitle( QCoreApplication.translate("mainwindow_ui_tr", "Persepolis Download Manager")) self.setWindowIcon( QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg'))) self.centralwidget = QWidget(self) self.verticalLayout = QVBoxLayout(self.centralwidget) # enable drag and drop self.setAcceptDrops(True) # frame self.frame = QFrame(self.centralwidget) # download_table_horizontalLayout download_table_horizontalLayout = QHBoxLayout() horizontal_splitter = QSplitter(Qt.Horizontal) vertical_splitter = QSplitter(Qt.Vertical) # category_tree self.category_tree_qwidget = QWidget(self) category_tree_verticalLayout = QVBoxLayout() self.category_tree = CategoryTreeView(self) category_tree_verticalLayout.addWidget(self.category_tree) self.category_tree_model = QStandardItemModel() self.category_tree.setModel(self.category_tree_model) category_table_header = [ QCoreApplication.translate("mainwindow_ui_tr", 'Category') ] self.category_tree_model.setHorizontalHeaderLabels( category_table_header) self.category_tree.header().setStretchLastSection(True) self.category_tree.header().setDefaultAlignment(Qt.AlignCenter) # queue_panel self.queue_panel_widget = QWidget(self) queue_panel_verticalLayout_main = QVBoxLayout(self.queue_panel_widget) # queue_panel_show_button self.queue_panel_show_button = QPushButton(self) queue_panel_verticalLayout_main.addWidget(self.queue_panel_show_button) # queue_panel_widget_frame self.queue_panel_widget_frame = QFrame(self) self.queue_panel_widget_frame.setFrameShape(QFrame.StyledPanel) self.queue_panel_widget_frame.setFrameShadow(QFrame.Raised) queue_panel_verticalLayout_main.addWidget( self.queue_panel_widget_frame) queue_panel_verticalLayout = QVBoxLayout(self.queue_panel_widget_frame) queue_panel_verticalLayout_main.setContentsMargins(50, -1, 50, -1) # start_end_frame self.start_end_frame = QFrame(self) # start time start_verticalLayout = QVBoxLayout(self.start_end_frame) self.start_checkBox = QCheckBox(self) start_verticalLayout.addWidget(self.start_checkBox) self.start_frame = QFrame(self) self.start_frame.setFrameShape(QFrame.StyledPanel) self.start_frame.setFrameShadow(QFrame.Raised) start_frame_verticalLayout = QVBoxLayout(self.start_frame) self.start_time_qDataTimeEdit = MyQDateTimeEdit(self.start_frame) self.start_time_qDataTimeEdit.setDisplayFormat('H:mm') start_frame_verticalLayout.addWidget(self.start_time_qDataTimeEdit) start_verticalLayout.addWidget(self.start_frame) # end time self.end_checkBox = QCheckBox(self) start_verticalLayout.addWidget(self.end_checkBox) self.end_frame = QFrame(self) self.end_frame.setFrameShape(QFrame.StyledPanel) self.end_frame.setFrameShadow(QFrame.Raised) end_frame_verticalLayout = QVBoxLayout(self.end_frame) self.end_time_qDateTimeEdit = MyQDateTimeEdit(self.end_frame) self.end_time_qDateTimeEdit.setDisplayFormat('H:mm') end_frame_verticalLayout.addWidget(self.end_time_qDateTimeEdit) start_verticalLayout.addWidget(self.end_frame) self.reverse_checkBox = QCheckBox(self) start_verticalLayout.addWidget(self.reverse_checkBox) queue_panel_verticalLayout.addWidget(self.start_end_frame) # limit_after_frame self.limit_after_frame = QFrame(self) # limit_checkBox limit_verticalLayout = QVBoxLayout(self.limit_after_frame) self.limit_checkBox = QCheckBox(self) limit_verticalLayout.addWidget(self.limit_checkBox) # limit_frame self.limit_frame = QFrame(self) self.limit_frame.setFrameShape(QFrame.StyledPanel) self.limit_frame.setFrameShadow(QFrame.Raised) limit_verticalLayout.addWidget(self.limit_frame) limit_frame_verticalLayout = QVBoxLayout(self.limit_frame) # limit_spinBox limit_frame_horizontalLayout = QHBoxLayout() self.limit_spinBox = QDoubleSpinBox(self) self.limit_spinBox.setMinimum(1) self.limit_spinBox.setMaximum(1023) limit_frame_horizontalLayout.addWidget(self.limit_spinBox) # limit_comboBox self.limit_comboBox = QComboBox(self) self.limit_comboBox.addItem("") self.limit_comboBox.addItem("") limit_frame_horizontalLayout.addWidget(self.limit_comboBox) limit_frame_verticalLayout.addLayout(limit_frame_horizontalLayout) # limit_pushButton self.limit_pushButton = QPushButton(self) limit_frame_verticalLayout.addWidget(self.limit_pushButton) # after_checkBox self.after_checkBox = QCheckBox(self) limit_verticalLayout.addWidget(self.after_checkBox) # after_frame self.after_frame = QFrame(self) self.after_frame.setFrameShape(QFrame.StyledPanel) self.after_frame.setFrameShadow(QFrame.Raised) limit_verticalLayout.addWidget(self.after_frame) after_frame_verticalLayout = QVBoxLayout(self.after_frame) # after_comboBox self.after_comboBox = QComboBox(self) self.after_comboBox.addItem("") after_frame_verticalLayout.addWidget(self.after_comboBox) # after_pushButton self.after_pushButton = QPushButton(self) after_frame_verticalLayout.addWidget(self.after_pushButton) queue_panel_verticalLayout.addWidget(self.limit_after_frame) category_tree_verticalLayout.addWidget(self.queue_panel_widget) # keep_awake_checkBox self.keep_awake_checkBox = QCheckBox(self) queue_panel_verticalLayout.addWidget(self.keep_awake_checkBox) self.category_tree_qwidget.setLayout(category_tree_verticalLayout) horizontal_splitter.addWidget(self.category_tree_qwidget) # download table widget self.download_table_content_widget = QWidget(self) download_table_content_widget_verticalLayout = QVBoxLayout( self.download_table_content_widget) # download_table self.download_table = DownloadTableWidget(self) vertical_splitter.addWidget(self.download_table) horizontal_splitter.addWidget(self.download_table_content_widget) self.download_table.setColumnCount(13) self.download_table.setSelectionBehavior(QAbstractItemView.SelectRows) self.download_table.setEditTriggers(QAbstractItemView.NoEditTriggers) self.download_table.verticalHeader().hide() # hide column of GID and column of link. self.download_table.setColumnHidden(8, True) self.download_table.setColumnHidden(9, True) download_table_header = [ QCoreApplication.translate("mainwindow_ui_tr", 'File Name'), QCoreApplication.translate("mainwindow_ui_tr", 'Status'), QCoreApplication.translate("mainwindow_ui_tr", 'Size'), QCoreApplication.translate("mainwindow_ui_tr", 'Downloaded'), QCoreApplication.translate("mainwindow_ui_tr", 'Percentage'), QCoreApplication.translate("mainwindow_ui_tr", 'Connections'), QCoreApplication.translate("mainwindow_ui_tr", 'Transfer Rate'), QCoreApplication.translate("mainwindow_ui_tr", 'Estimated Time Left'), 'Gid', QCoreApplication.translate("mainwindow_ui_tr", 'Link'), QCoreApplication.translate("mainwindow_ui_tr", 'First Try Date'), QCoreApplication.translate("mainwindow_ui_tr", 'Last Try Date'), QCoreApplication.translate("mainwindow_ui_tr", 'Category') ] self.download_table.setHorizontalHeaderLabels(download_table_header) # fixing the size of download_table when window is Maximized! self.download_table.horizontalHeader().setSectionResizeMode( QHeaderView.ResizeMode.Interactive) self.download_table.horizontalHeader().setStretchLastSection(True) horizontal_splitter.setStretchFactor(0, 3) # category_tree width horizontal_splitter.setStretchFactor(1, 10) # ratio of tables's width # video_finder_widget self.video_finder_widget = QWidget(self) video_finder_horizontalLayout = QHBoxLayout(self.video_finder_widget) self.muxing_pushButton = QPushButton(self) self.muxing_pushButton.setIcon(QIcon(icons + 'video_finder')) video_finder_horizontalLayout.addWidget(self.muxing_pushButton) video_finder_horizontalLayout.addSpacing(20) video_audio_verticalLayout = QVBoxLayout() self.video_label = QLabel(self) video_audio_verticalLayout.addWidget(self.video_label) self.audio_label = QLabel(self) video_audio_verticalLayout.addWidget(self.audio_label) video_finder_horizontalLayout.addLayout(video_audio_verticalLayout) status_muxing_verticalLayout = QVBoxLayout() self.video_finder_status_label = QLabel(self) status_muxing_verticalLayout.addWidget(self.video_finder_status_label) self.muxing_status_label = QLabel(self) status_muxing_verticalLayout.addWidget(self.muxing_status_label) video_finder_horizontalLayout.addLayout(status_muxing_verticalLayout) vertical_splitter.addWidget(self.video_finder_widget) download_table_content_widget_verticalLayout.addWidget( vertical_splitter) download_table_horizontalLayout.addWidget(horizontal_splitter) self.frame.setLayout(download_table_horizontalLayout) self.verticalLayout.addWidget(self.frame) self.setCentralWidget(self.centralwidget) # menubar self.menubar = QMenuBar(self) self.menubar.setGeometry(QRect(0, 0, 600, 24)) self.setMenuBar(self.menubar) fileMenu = self.menubar.addMenu( QCoreApplication.translate("mainwindow_ui_tr", '&File')) editMenu = self.menubar.addMenu( QCoreApplication.translate("mainwindow_ui_tr", '&Edit')) viewMenu = self.menubar.addMenu( QCoreApplication.translate("mainwindow_ui_tr", '&View')) downloadMenu = self.menubar.addMenu( QCoreApplication.translate("mainwindow_ui_tr", '&Download')) queueMenu = self.menubar.addMenu( QCoreApplication.translate("mainwindow_ui_tr", '&Queue')) videoFinderMenu = self.menubar.addMenu( QCoreApplication.translate("mainwindow_ui_tr", 'V&ideo Finder')) helpMenu = self.menubar.addMenu( QCoreApplication.translate("mainwindow_ui_tr", '&Help')) # viewMenu submenus sortMenu = viewMenu.addMenu( QCoreApplication.translate("mainwindow_ui_tr", 'Sort by')) # statusbar self.statusbar = QStatusBar(self) self.setStatusBar(self.statusbar) self.statusbar.showMessage( QCoreApplication.translate("mainwindow_ui_tr", "Persepolis Download Manager")) # toolBar self.toolBar2 = QToolBar(self) self.addToolBar(Qt.TopToolBarArea, self.toolBar2) self.toolBar2.setWindowTitle( QCoreApplication.translate("mainwindow_ui_tr", 'Menu')) self.toolBar2.setFloatable(False) self.toolBar2.setMovable(False) self.toolBar = QToolBar(self) self.addToolBar(Qt.TopToolBarArea, self.toolBar) self.toolBar.setWindowTitle( QCoreApplication.translate("mainwindow_ui_tr", 'Toolbar')) self.toolBar.setFloatable(False) self.toolBar.setMovable(False) #toolBar and menubar and actions self.persepolis_setting.beginGroup('settings/shortcuts') # videoFinderAddLinkAction self.videoFinderAddLinkAction = QAction( QIcon(icons + 'video_finder'), QCoreApplication.translate("mainwindow_ui_tr", 'Find Video Links...'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Download video or audio from Youtube, Vimeo, etc.'), triggered=self.showVideoFinderAddLinkWindow) self.videoFinderAddLinkAction_shortcut = QShortcut( self.persepolis_setting.value('video_finder_shortcut'), self, self.showVideoFinderAddLinkWindow) videoFinderMenu.addAction(self.videoFinderAddLinkAction) # stopAllAction self.stopAllAction = QAction(QIcon(icons + 'stop_all'), QCoreApplication.translate( "mainwindow_ui_tr", 'Stop All Active Downloads'), self, statusTip='Stop All Active Downloads', triggered=self.stopAllDownloads) downloadMenu.addAction(self.stopAllAction) # sort_file_name_Action self.sort_file_name_Action = QAction(QCoreApplication.translate( "mainwindow_ui_tr", 'File Name'), self, triggered=self.sortByName) sortMenu.addAction(self.sort_file_name_Action) # sort_file_size_Action self.sort_file_size_Action = QAction(QCoreApplication.translate( "mainwindow_ui_tr", 'File Size'), self, triggered=self.sortBySize) sortMenu.addAction(self.sort_file_size_Action) # sort_first_try_date_Action self.sort_first_try_date_Action = QAction( QCoreApplication.translate("mainwindow_ui_tr", 'First Try Date'), self, triggered=self.sortByFirstTry) sortMenu.addAction(self.sort_first_try_date_Action) # sort_last_try_date_Action self.sort_last_try_date_Action = QAction(QCoreApplication.translate( "mainwindow_ui_tr", 'Last Try Date'), self, triggered=self.sortByLastTry) sortMenu.addAction(self.sort_last_try_date_Action) # sort_download_status_Action self.sort_download_status_Action = QAction(QCoreApplication.translate( "mainwindow_ui_tr", 'Download Status'), self, triggered=self.sortByStatus) sortMenu.addAction(self.sort_download_status_Action) # trayAction self.trayAction = QAction( QCoreApplication.translate("mainwindow_ui_tr", 'Show System Tray Icon'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Show/Hide system tray icon"), triggered=self.showTray) self.trayAction.setCheckable(True) viewMenu.addAction(self.trayAction) # showMenuBarAction self.showMenuBarAction = QAction( QCoreApplication.translate("mainwindow_ui_tr", 'Show Menubar'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Show Menubar'), triggered=self.showMenuBar) self.showMenuBarAction.setCheckable(True) viewMenu.addAction(self.showMenuBarAction) # showSidePanelAction self.showSidePanelAction = QAction( QCoreApplication.translate("mainwindow_ui_tr", 'Show Side Panel'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Show Side Panel'), triggered=self.showSidePanel) self.showSidePanelAction.setCheckable(True) viewMenu.addAction(self.showSidePanelAction) # minimizeAction self.minimizeAction = QAction( QIcon(icons + 'minimize'), QCoreApplication.translate("mainwindow_ui_tr", 'Minimize to System Tray'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Minimize to System Tray"), triggered=self.minMaxTray) self.minimizeAction_shortcut = QShortcut( self.persepolis_setting.value('hide_window_shortcut'), self, self.minMaxTray) viewMenu.addAction(self.minimizeAction) # addlinkAction self.addlinkAction = QAction( QIcon(icons + 'add'), QCoreApplication.translate("mainwindow_ui_tr", 'Add New Download Link...'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Add New Download Link"), triggered=self.addLinkButtonPressed) self.addlinkAction_shortcut = QShortcut( self.persepolis_setting.value('add_new_download_shortcut'), self, self.addLinkButtonPressed) fileMenu.addAction(self.addlinkAction) # importText self.addtextfileAction = QAction( QIcon(icons + 'file'), QCoreApplication.translate("mainwindow_ui_tr", 'Import Links from Text File...'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Create a text file and put links in it, line by line!'), triggered=self.importText) self.addtextfileAction_shortcut = QShortcut( self.persepolis_setting.value('import_text_shortcut'), self, self.importText) fileMenu.addAction(self.addtextfileAction) # resumeAction self.resumeAction = QAction( QIcon(icons + 'play'), QCoreApplication.translate("mainwindow_ui_tr", 'Resume Download'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Resume Download"), triggered=self.resumeButtonPressed) downloadMenu.addAction(self.resumeAction) # pauseAction self.pauseAction = QAction( QIcon(icons + 'pause'), QCoreApplication.translate("mainwindow_ui_tr", 'Pause Download'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Pause Download"), triggered=self.pauseButtonPressed) downloadMenu.addAction(self.pauseAction) # stopAction self.stopAction = QAction( QIcon(icons + 'stop'), QCoreApplication.translate("mainwindow_ui_tr", 'Stop Download'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Stop/Cancel Download"), triggered=self.stopButtonPressed) downloadMenu.addAction(self.stopAction) # propertiesAction self.propertiesAction = QAction( QIcon(icons + 'setting'), QCoreApplication.translate("mainwindow_ui_tr", 'Properties'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Properties"), triggered=self.propertiesButtonPressed) downloadMenu.addAction(self.propertiesAction) # progressAction self.progressAction = QAction( QIcon(icons + 'window'), QCoreApplication.translate("mainwindow_ui_tr", 'Progress'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Progress"), triggered=self.progressButtonPressed) downloadMenu.addAction(self.progressAction) # openFileAction self.openFileAction = QAction( QIcon(icons + 'file'), QCoreApplication.translate("mainwindow_ui_tr", 'Open File...'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Open File...'), triggered=self.openFile) fileMenu.addAction(self.openFileAction) # openDownloadFolderAction self.openDownloadFolderAction = QAction( QIcon(icons + 'folder'), QCoreApplication.translate("mainwindow_ui_tr", 'Open Download Folder'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Open Download Folder'), triggered=self.openDownloadFolder) fileMenu.addAction(self.openDownloadFolderAction) # openDefaultDownloadFolderAction self.openDefaultDownloadFolderAction = QAction( QIcon(icons + 'folder'), QCoreApplication.translate("mainwindow_ui_tr", 'Open Default Download Folder'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Open Default Download Folder'), triggered=self.openDefaultDownloadFolder) fileMenu.addAction(self.openDefaultDownloadFolderAction) # exitAction self.exitAction = QAction( QIcon(icons + 'exit'), QCoreApplication.translate("mainwindow_ui_tr", 'Exit'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Exit"), triggered=self.closeAction) self.exitAction_shortcut = QShortcut( self.persepolis_setting.value('quit_shortcut'), self, self.closeAction) fileMenu.addAction(self.exitAction) # clearAction self.clearAction = QAction(QIcon(icons + 'multi_remove'), QCoreApplication.translate( "mainwindow_ui_tr", 'Clear Download List'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Clear all items in download list'), triggered=self.clearDownloadList) editMenu.addAction(self.clearAction) # removeSelectedAction self.removeSelectedAction = QAction( QIcon(icons + 'remove'), QCoreApplication.translate("mainwindow_ui_tr", 'Remove Selected Downloads from List'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Remove Selected Downloads from List'), triggered=self.removeSelected) self.removeSelectedAction_shortcut = QShortcut( self.persepolis_setting.value('remove_shortcut'), self, self.removeSelected) editMenu.addAction(self.removeSelectedAction) self.removeSelectedAction.setEnabled(False) # deleteSelectedAction self.deleteSelectedAction = QAction( QIcon(icons + 'trash'), QCoreApplication.translate("mainwindow_ui_tr", 'Delete Selected Download Files'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Delete Selected Download Files'), triggered=self.deleteSelected) self.deleteSelectedAction_shortcut = QShortcut( self.persepolis_setting.value('delete_shortcut'), self, self.deleteSelected) editMenu.addAction(self.deleteSelectedAction) self.deleteSelectedAction.setEnabled(False) # moveSelectedDownloadsAction self.moveSelectedDownloadsAction = QAction( QIcon(icons + 'folder'), QCoreApplication.translate( "mainwindow_ui_tr", 'Move Selected Download Files to Another Folder...'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Move Selected Download Files to Another Folder'), triggered=self.moveSelectedDownloads) editMenu.addAction(self.moveSelectedDownloadsAction) self.moveSelectedDownloadsAction.setEnabled(False) # createQueueAction self.createQueueAction = QAction( QIcon(icons + 'add_queue'), QCoreApplication.translate("mainwindow_ui_tr", 'Create New Queue...'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Create new download queue'), triggered=self.createQueue) queueMenu.addAction(self.createQueueAction) # removeQueueAction self.removeQueueAction = QAction( QIcon(icons + 'remove_queue'), QCoreApplication.translate("mainwindow_ui_tr", 'Remove Queue'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Remove this queue'), triggered=self.removeQueue) queueMenu.addAction(self.removeQueueAction) # startQueueAction self.startQueueAction = QAction( QIcon(icons + 'start_queue'), QCoreApplication.translate("mainwindow_ui_tr", 'Start this queue'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Start Queue'), triggered=self.startQueue) queueMenu.addAction(self.startQueueAction) # stopQueueAction self.stopQueueAction = QAction( QIcon(icons + 'stop_queue'), QCoreApplication.translate("mainwindow_ui_tr", 'Stop this queue'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Stop Queue'), triggered=self.stopQueue) queueMenu.addAction(self.stopQueueAction) # moveUpSelectedAction self.moveUpSelectedAction = QAction( QIcon(icons + 'multi_up'), QCoreApplication.translate("mainwindow_ui_tr", 'Move Selected Items Up'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Move currently selected items up by one row'), triggered=self.moveUpSelected) self.moveUpSelectedAction_shortcut = QShortcut( self.persepolis_setting.value('move_up_selection_shortcut'), self, self.moveUpSelected) queueMenu.addAction(self.moveUpSelectedAction) # moveDownSelectedAction self.moveDownSelectedAction = QAction( QIcon(icons + 'multi_down'), QCoreApplication.translate("mainwindow_ui_tr", 'Move Selected Items Down'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Move currently selected items down by one row'), triggered=self.moveDownSelected) self.moveDownSelectedAction_shortcut = QShortcut( self.persepolis_setting.value('move_down_selection_shortcut'), self, self.moveDownSelected) queueMenu.addAction(self.moveDownSelectedAction) # preferencesAction self.preferencesAction = QAction( QIcon(icons + 'preferences'), QCoreApplication.translate("mainwindow_ui_tr", 'Preferences'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Preferences'), triggered=self.openPreferences, menuRole=QAction.MenuRole.PreferencesRole) editMenu.addAction(self.preferencesAction) # aboutAction self.aboutAction = QAction( QIcon(icons + 'about'), QCoreApplication.translate("mainwindow_ui_tr", 'About'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'About'), triggered=self.openAbout, menuRole=QAction.MenuRole.AboutRole) helpMenu.addAction(self.aboutAction) # issueAction self.issueAction = QAction( QIcon(icons + 'about'), QCoreApplication.translate("mainwindow_ui_tr", 'Report an Issue'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Report an issue'), triggered=self.reportIssue) helpMenu.addAction(self.issueAction) # updateAction self.updateAction = QAction( QIcon(icons + 'about'), QCoreApplication.translate("mainwindow_ui_tr", 'Check for Newer Version'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Check for newer release'), triggered=self.newUpdate) helpMenu.addAction(self.updateAction) # logAction self.logAction = QAction( QIcon(icons + 'about'), QCoreApplication.translate("mainwindow_ui_tr", 'Show Log File'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Help'), triggered=self.showLog) helpMenu.addAction(self.logAction) # helpAction self.helpAction = QAction( QIcon(icons + 'about'), QCoreApplication.translate("mainwindow_ui_tr", 'Help'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Help'), triggered=self.persepolisHelp) helpMenu.addAction(self.helpAction) self.persepolis_setting.endGroup() self.qmenu = MenuWidget(self) self.toolBar2.addWidget(self.qmenu) # labels self.queue_panel_show_button.setText( QCoreApplication.translate("mainwindow_ui_tr", "Hide Options")) self.start_checkBox.setText( QCoreApplication.translate("mainwindow_ui_tr", "Start Time")) self.end_checkBox.setText( QCoreApplication.translate("mainwindow_ui_tr", "End Time")) self.reverse_checkBox.setText( QCoreApplication.translate("mainwindow_ui_tr", "Download bottom of\n the list first")) self.limit_checkBox.setText( QCoreApplication.translate("mainwindow_ui_tr", "Limit Speed")) self.limit_comboBox.setItemText(0, "KiB/s") self.limit_comboBox.setItemText(1, "MiB/s") self.limit_pushButton.setText( QCoreApplication.translate("mainwindow_ui_tr", "Apply")) self.after_checkBox.setText( QCoreApplication.translate("mainwindow_ui_tr", "After download")) self.after_comboBox.setItemText( 0, QCoreApplication.translate("mainwindow_ui_tr", "Shut Down")) self.keep_awake_checkBox.setText( QCoreApplication.translate("mainwindow_ui_tr", "Keep System Awake!")) self.keep_awake_checkBox.setToolTip( QCoreApplication.translate( "mainwindow_ui_tr", "<html><head/><body><p>This option will prevent the system from going to sleep.\ It is necessary if your power manager is suspending the system automatically. </p></body></html>" )) self.after_pushButton.setText( QCoreApplication.translate("mainwindow_ui_tr", "Apply")) self.muxing_pushButton.setText( QCoreApplication.translate("mainwindow_ui_tr", "Start Mixing")) self.video_label.setText( QCoreApplication.translate("mainwindow_ui_tr", "<b>Video File Status: </b>")) self.audio_label.setText( QCoreApplication.translate("mainwindow_ui_tr", "<b>Audio File Status: </b>")) self.video_finder_status_label.setText( QCoreApplication.translate("mainwindow_ui_tr", "<b>Status: </b>")) self.muxing_status_label.setText( QCoreApplication.translate("mainwindow_ui_tr", "<b>Mixing status: </b>"))
class DeviceItem(QWidget): numberChanged = Signal() def __init__(self, device: RigDevice): super().__init__() self.device = device self._nameLabel = QLabel(device.serialNumber) self._statusLabel = QLabel("") self._startNumberDial = QSpinBox() self._startNumberDial.setMinimum(0) self._startNumberDial.setMaximum(9999) self._startNumberDial.setValue(device.startNumber) self._startNumberDial.valueChanged.connect(self.SetStartNumber) self._enableToggle = QToolButton() self._enableToggle.clicked.connect(self.ToggleEnable) self._enableToggle.setText("Disable") self._layout = QHBoxLayout() self.setLayout(self._layout) self._layout.addWidget(self._nameLabel, stretch=1) self._layout.addWidget(self._statusLabel, stretch=1) self._layout.addWidget(self._enableToggle) self._layout.addWidget(self._startNumberDial) self._layout.addStretch(1) solenoidLabelLayout = QVBoxLayout() solenoidLabelLayout.addWidget(QLabel("State"), alignment=Qt.AlignRight) solenoidLabelLayout.addWidget(QLabel("Invert"), alignment=Qt.AlignRight) self._layout.addLayout(solenoidLabelLayout) self._layout.addSpacing(5) self._solenoidButtons: List[SolenoidButton] = [] for solenoidNumber in range(24): newButton = SolenoidButton( solenoidNumber, device.solenoidPolarities[solenoidNumber]) newButton.solenoidClicked.connect( lambda s=newButton: self.ToggleSolenoid(s)) newButton.polarityClicked.connect( lambda s=newButton: self.TogglePolarity(s)) self._solenoidButtons.append(newButton) self._layout.addWidget(newButton, stretch=0) self.Update() def SetStartNumber(self): self.device.startNumber = self._startNumberDial.value() self.Update() self.numberChanged.emit() def ToggleEnable(self): self.device.SetEnabled(not self.device.isEnabled) self.Update() def ToggleSolenoid(self, button: 'SolenoidButton'): index = self._solenoidButtons.index(button) AppGlobals.Rig().SetSolenoidState( self.device.startNumber + index, not AppGlobals.Rig().GetSolenoidState(self.device.startNumber + index)) AppGlobals.Rig().FlushStates() self.Update() def TogglePolarity(self, button: 'SolenoidButton'): index = self._solenoidButtons.index(button) self.device.solenoidPolarities[ index] = not self.device.solenoidPolarities[index] AppGlobals.Rig().FlushStates() self.Update() def Update(self): if not self.device.IsDeviceAvailable(): self.deleteLater() return if self.device.isConnected: self._statusLabel.setText("Connected.") else: if self.device.isEnabled: self._statusLabel.setText(self.device.errorMessage) else: self._statusLabel.setText("Disabled.") self._enableToggle.setText({ False: "Enable", True: "Disable" }[self.device.isEnabled]) self._startNumberDial.setEnabled(self.device.isEnabled and self.device.isConnected) for i in range(24): self._solenoidButtons[i].setEnabled(self.device.isConnected and self.device.isEnabled) self._solenoidButtons[i].Update(self.device.startNumber + i, self.device.solenoidPolarities[i])
class EntryWidget(TritonWidget): def __init__(self, base, account): TritonWidget.__init__(self, base) self.account = account self.type = account['type'] self.name = account['name'] self.icon = account['icon'].replace('\\', '/') self.timer = None self.secretWidget = None self.iconWidget = None self.closeEvent = self.widgetDeleted self.boxLayout = QHBoxLayout(self) self.boxLayout.setContentsMargins(0, 0, 0, 0) self.image = QLabel() self.image.setFixedSize(48, 48) self.reloadIcon() self.detailWidget = QWidget() self.detailLayout = QVBoxLayout(self.detailWidget) self.detailLayout.setContentsMargins(0, 0, 0, 0) self.nameLabel = EditableLabel(True, None) self.nameLabel.callback = self.renameAccount self.nameLabel.setText(self.name) self.nameLabel.setAlignment(Qt.AlignTop) self.nameLabel.setFont(QFont('Helvetica', 11)) self.passLabel = EditableLabel(False, self.openPassLabel) self.passLabel.disableEdit() self.passLabel.setAlignment(Qt.AlignBottom) self.detailLayout.addWidget(self.nameLabel) self.detailLayout.addWidget(self.passLabel) self.showButton = PixmapButton(QPixmap('icons/RefreshIcon.png').scaled(48, 48)) self.showButton.clicked.connect(self.buttonPressed) self.timerProgress = QRoundProgressBar() self.timerProgress.setBarStyle(QRoundProgressBar.BarStyle.PIE) self.timerProgress.setFixedSize(48, 48) self.timerProgress.setFormat('') self.timerProgress.mouseReleaseEvent = self.buttonPressed palette = QPalette() brush = QBrush(QColor(155, 183, 214)) brush.setStyle(Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.Highlight, brush) self.timerProgress.setPalette(palette) self.timerProgress.hide() self.boxLayout.addWidget(self.image) self.boxLayout.addSpacing(5) self.boxLayout.addWidget(self.detailWidget) self.boxLayout.addWidget(self.showButton, 0, Qt.AlignRight) self.boxLayout.addWidget(self.timerProgress, 0, Qt.AlignRight) self.setFixedSize(360, 48) self.hidePassword() self.setContextMenuPolicy(Qt.CustomContextMenu) self.customContextMenuRequested.connect(self.openContextMenu) self.menu = QMenu(self) self.removeAction = QAction('Remove') self.removeAction.triggered.connect(self.removeAccount) self.iconAction = QAction('Edit icon') self.iconAction.triggered.connect(self.editIcon) self.showAction = QAction('Show secret key') self.showAction.triggered.connect(self.showSecretKey) self.menu.addAction(self.removeAction) self.menu.addSeparator() self.menu.addAction(self.iconAction) self.menu.addAction(self.showAction) def getValue(self): return self.base.getAuthCode(self.account) def widgetDeleted(self, *args): self.stopTimer() self.name = None self.account = None def buttonPressed(self, *args): if not self.timer: self.showPassword() def openPassLabel(self, *args): self.buttonPressed() self.passLabel.mouseDoubleClickEvent() def openContextMenu(self, point): self.menu.exec_(self.mapToGlobal(point)) def reloadIcon(self): pixmap = QPixmap(self.icon).scaled(48, 48) self.image.setPixmap(pixmap) def stopTimer(self): if self.timer: self.timer.stop() self.timer = None def hidePassword(self): font = QFont('Helvetica', 10, weight=QFont.Bold) font.setLetterSpacing(QFont.PercentageSpacing, 110) self.stopTimer() self.passLabel.setText('* ' * 5) self.passLabel.setFont(font) self.passLabel.disableEdit() self.showButton.show() self.timerProgress.hide() def showPassword(self): font = QFont('Helvetica', 13, weight=QFont.Bold) font.setLetterSpacing(QFont.PercentageSpacing, 110) self.passLabel.setText(self.getValue()) self.passLabel.setFont(font) self.passLabel.enableEdit() self.showButton.hide() self.timerProgress.show() self.timerEnd = time.time() + 15 if not self.timer: self.timerProgress.setValue(100) self.timer = QTimer() self.timer.timeout.connect(self.updateProgress) self.timer.start(100) def updateProgress(self): if self.timerProgress.isHidden() or self.timerEnd <= time.time(): self.hidePassword() return delta = (self.timerEnd - time.time()) / 15 * 100 self.timerProgress.setValue(delta) def removeAccount(self): reply = QMessageBox.question(self, self.name, 'ATTENTION! Deleting this account is an irreversible action!\n\nAre you absolutely sure?', QMessageBox.Yes | QMessageBox.No, QMessageBox.No) if reply == QMessageBox.Yes: self.base.deleteAccount(self.account) def renameAccount(self, name): index = self.base.getAccountIndex(self.account) self.account['name'] = name self.base.setAccount(index, self.account) def editIcon(self): self.iconWidget = EditIconWidget(self.base, self.name, self.editIconCallback) def editIconCallback(self, icon): index = self.base.getAccountIndex(self.account) self.icon = icon.replace('\\', '/') self.account['icon'] = icon self.base.setAccount(index, self.account) self.reloadIcon() def showSecretKey(self): if self.type == Globals.OTPAuth: keys = [ ('Key', self.account['key']) ] elif self.type == Globals.SteamAuth: keys = [ ('Steam ID', self.account['steamId']), ('Shared Secret', self.account['sharedSecret']), ('Identity Secret', self.account['identitySecret']) ] else: keys = [] self.secretWidget = ShowSecretWidget(self.base, keys, self.name)
def __init__(self): QMainWindow.__init__(self) # Variaveis self.separador = ";" # Separador padrao de colunas em um arquivo txt ou csv self.selected = np.array([1, 24, 48, 96]).astype('timedelta64[h]') # selecionados ao iniciar o programa, modificavel. self.fileformat = '' # Reservado para o formato do arquivo a ser aberto. Pode ser .xlsx ou .odf. ou .csv e assim vai. # facilita o acesso a variavel. self.timedeltastr = ("1 Hora","2 Horas", "3 Horas", "4 Horas","12 Horas", "24 Horas", "48 Horas", "72 horas", "96 horas", "30 Dias") self.timedeltas = np.array([1, 2, 3, 4, 12, 24, 48, 72, 96, 24*30]).astype('timedelta64[h]') self.linktimedelta = dict([(self.timedeltas[x], self.timedeltastr[x]) for x in range(len(self.timedeltastr))]) self.datastring = ["DD/MM/AAAA",'AAAA/MM/DD', "AAAA-MM-DD", "DD-MM-AAAA"] self.dataformat = ["%d/%m/%Y", "%Y/%m/%d", "%Y-%m-%d", "%d-%m-%Y"] self.linkdata = dict([(self.datastring[x], self.dataformat[x]) for x in range(len(self.dataformat))]) self.timestring = ["hh:mm", "hh:mm:ss", "hh:mm:ss.ms"] self.timeformat = ["%H:%M", "%H:%M:%S", "%H:%M:%S.%f"] self.linktime = dict([(self.timestring[x], self.timeformat[x]) for x in range(len(self.timeformat))]) #Janela Principal widget = QWidget() self.setCentralWidget(widget) # Inicializa os Widgets self.folder = QLineEdit("Salvar Como...") self.path = QLineEdit("Abrir arquivo...") # buttonOpen = QPushButton('Abrir') buttonSave = QPushButton("Destino") Processar = QPushButton('Executar') Ajuda = QPushButton('Informações') # groupBox2 = QGroupBox("Delimitador") self.delimitador1 = QRadioButton("Ponto-Vírgula") self.delimitador2 = QRadioButton("Vírgula") self.delimitador3 = QRadioButton("Ponto") self.delimitador4 = QRadioButton("Tabulação") # checkGroup = QGroupBox("Mais opções") text3 = QPushButton("Configurações") text2 = QLabel("Formato da Data") text1 = QLabel("Formato da Hora") self.FormatoTime = QComboBox() self.FormatoTime.addItems(self.timestring) self.FormatoData = QComboBox() self.FormatoData.addItems(self.datastring) # text = QLabel("Por favor, selecione na tabela abaixo as colunas a utilizar:") self.ignore = QRadioButton("Possui Cabeçalho") # True se estiver selecionado, False caso nao # self.Tabela = QTableWidget(15,15) self.startTable() # Layouts MainLayout = QVBoxLayout() Gridlayout = QGridLayout() Gridlayout.addWidget(self.path, 0, 0) Gridlayout.addWidget(self.folder, 1, 0) Gridlayout.addWidget(buttonOpen, 0, 1) Gridlayout.addWidget(buttonSave, 1, 1) Gridlayout.addWidget(Processar, 0, 3) Gridlayout.addWidget(Ajuda, 1, 3) Gridlayout.setColumnStretch(0, 2) Gridlayout.setColumnStretch(3, 1) Gridlayout.setColumnMinimumWidth(2, 20) SecondLayout = QHBoxLayout() SecondLayout.addWidget(groupBox2) SecondLayout.addSpacing(40) SecondLayout.addWidget(checkGroup) # SepLayout = QVBoxLayout() SepLayout.addWidget(self.delimitador1) SepLayout.addWidget(self.delimitador2) SepLayout.addWidget(self.delimitador3) SepLayout.addWidget(self.delimitador4) # OptionsLayout = QVBoxLayout() OptionsLayout.addWidget(text3) OptionsLayout.addWidget(text2) OptionsLayout.addWidget(self.FormatoData) OptionsLayout.addWidget(text1) OptionsLayout.addWidget(self.FormatoTime) ThirdLayout = QVBoxLayout() ThirdLayout.addWidget(self.ignore) ThirdLayout.addWidget(text) MainLayout.addLayout(Gridlayout) MainLayout.addLayout(SecondLayout) MainLayout.addLayout(ThirdLayout) MainLayout.addWidget(self.Tabela) # Coloca o Layout principal na Janela widget.setLayout(MainLayout) # Comandos dos Widgets e edicoes. groupBox2.setLayout(SepLayout) self.delimitador1.setChecked(True) self.folder.setReadOnly(True) self.path.setReadOnly(True) checkGroup.setLayout(OptionsLayout) buttonOpen.clicked.connect(self.searchFile) buttonSave.clicked.connect(self.getNewFile) self.delimitador1.clicked.connect(self.updateDelimiter) self.delimitador2.clicked.connect(self.updateDelimiter) self.delimitador3.clicked.connect(self.updateDelimiter) self.delimitador4.clicked.connect(self.updateDelimiter) Ajuda.clicked.connect(self.help) Processar.clicked.connect(self.taskStart) text3.clicked.connect(self.openSubWindow) # Propriedades da janela principal height = 480 width = 640 myappid = 'GePlu.release1_0.0' # arbitrary string ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid) self.setWindowIcon(QIcon(r'images\icon6.ico')) self.setFixedSize(width, height) self.setWindowTitle("GePlu")