class Runner(): _window = None _application = None def __init__(self): self._application = QApplication(sys.argv) self._window = None # Main Window Initialized.. try: self._window = yali.gui.YaliWindow.Widget() except yali.Error, msg: ctx.logger.debug(msg) sys.exit(1) self._translator = QTranslator() self._translator.load( "qt_" + QLocale.system().name(), QLibraryInfo.location(QLibraryInfo.TranslationsPath)) ctx.mainScreen = self._window screens = self._get_screens(ctx.flags.install_type) self._set_steps(screens) # These shorcuts for developers :) prevScreenShortCut = QShortcut(QKeySequence(Qt.SHIFT + Qt.Key_F1), self._window) nextScreenShortCut = QShortcut(QKeySequence(Qt.SHIFT + Qt.Key_F2), self._window) prevScreenShortCut.activated.connect(self._window.slotBack) nextScreenShortCut.activated.connect(self._window.slotNext) # VBox utils ctx.logger.debug("Starting VirtualBox tools..") #FIXME:sh /etc/X11/Xsession.d/98-vboxclient.sh yali.util.run_batch("VBoxClient", ["--autoresize"]) yali.util.run_batch("VBoxClient", ["--clipboard"]) # Cp Reboot, ShutDown yali.util.run_batch("cp", ["/sbin/reboot", "/tmp/reboot"]) yali.util.run_batch("cp", ["/sbin/shutdown", "/tmp/shutdown"]) # base connections self._application.lastWindowClosed.connect(self._application.quit) self._window.signalProcessEvents.connect( self._application.processEvents) #hata olabilir self._application.desktop().resized[int].connect( self._reinit_screen) #hata olabilir # Font Resize fontMinusShortCut = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Minus), self._window) fontPlusShortCut = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Plus), self._window) fontMinusShortCut.activated.connect(self._window.setFontMinus) fontPlusShortCut.activated.connect(self._window.setFontPlus)
def setupUi(self, *args): # {{{ self.resize(990, 670) self.download_shortcut = QShortcut(self) self.download_shortcut.setKey(QKeySequence('Ctrl+D', QKeySequence.PortableText)) p = self.parent() if hasattr(p, 'keyboard'): kname = u'Interface Action: Edit Metadata (Edit Metadata) : menu action : download' sc = p.keyboard.keys_map.get(kname, None) if sc: self.download_shortcut.setKey(sc[0]) self.swap_title_author_shortcut = s = QShortcut(self) s.setKey(QKeySequence('Alt+Down', QKeySequence.PortableText)) self.button_box = bb = QDialogButtonBox(self) self.button_box.accepted.connect(self.accept) self.button_box.rejected.connect(self.reject) self.next_button = QPushButton(QIcon(I('forward.png')), _('Next'), self) self.next_button.setShortcut(QKeySequence('Alt+Right')) self.next_button.clicked.connect(self.next_clicked) self.prev_button = QPushButton(QIcon(I('back.png')), _('Previous'), self) self.prev_button.setShortcut(QKeySequence('Alt+Left')) self.button_box.addButton(self.prev_button, bb.ActionRole) self.button_box.addButton(self.next_button, bb.ActionRole) self.prev_button.clicked.connect(self.prev_clicked) bb.setStandardButtons(bb.Ok|bb.Cancel) bb.button(bb.Ok).setDefault(True) self.scroll_area = QScrollArea(self) self.scroll_area.setFrameShape(QScrollArea.NoFrame) self.scroll_area.setWidgetResizable(True) self.central_widget = QTabWidget(self) self.scroll_area.setWidget(self.central_widget) self.l = QVBoxLayout(self) self.setLayout(self.l) self.l.addWidget(self.scroll_area) ll = self.button_box_layout = QHBoxLayout() self.l.addLayout(ll) ll.addSpacing(10) ll.addWidget(self.button_box) self.setWindowIcon(QIcon(I('edit_input.png'))) self.setWindowTitle(BASE_TITLE) self.create_basic_metadata_widgets() if len(self.db.custom_column_label_map): self.create_custom_metadata_widgets() self.do_layout() geom = gprefs.get('metasingle_window_geometry3', None) if geom is not None: self.restoreGeometry(bytes(geom))
def __init_shortcuts(self): self.__keyF11 = QShortcut(self) self.__keyF11.setKey(Qt.Key_F11) self.__keyF11.activated.connect(self.__action_full_screen) self.__keyCtrlQ = QShortcut(self) self.__keyCtrlQ.setKey(Qt.CTRL + Qt.Key_Q) self.__keyCtrlQ.activated.connect(self.__action_quit) self.__keyCtrlH = QShortcut(self) self.__keyCtrlH.setKey(Qt.CTRL + Qt.Key_H) self.__keyCtrlH.activated.connect(self.__action_home) self.__keyCtrlR = QShortcut(self) self.__keyCtrlR.setKey(Qt.CTRL + Qt.Key_R) self.__keyCtrlR.activated.connect(self.__action_reload) self.__keyF5 = QShortcut(self) self.__keyF5.setKey(Qt.Key_F5) self.__keyF5.activated.connect(self.__action_reload) self.__keyAltLeft = QShortcut(self) self.__keyAltLeft.setKey(Qt.ALT + Qt.Key_Left) self.__keyAltLeft.activated.connect(self.__action_back) QTWSPluginManager.instance().each( lambda plugin: plugin.register_shortcuts(self))
def initUI(self): #self._layout = QHBoxLayout(self) self._widget = QWidget(self) #self._layout.addWidget(self._widget) self._menuBar = QMenuBar(self._widget) exitAct = QAction(QIcon('exit.png'), '&Exit', self) exitAct.setShortcut('Ctrl+Q') exitAct.setStatusTip('Exit application') exitAct.triggered.connect(qApp.quit) self.statusBar() #menubar = self.menuBar() menubar = self._menuBar fileMenu = menubar.addMenu('&File') fileMenu.addAction(exitAct) act = self._menuBar.addAction('test') act.setShortcut(QKeySequence('Ctrl+M')) def testCb(): print('hello') act.triggered.connect(testCb) act.setShortcutContext(Qt.WidgetShortcut) print('_menuBar parent', self._menuBar.parent()) print('act parent', act.parent()) print('_widget parent', self._widget.parent()) #act.setParent(self) #print(act.parent()) self.addAction(act) # This is important for Qt.WidgetShortcut # the Example is focused, and it's menu's act can trigger # Qt.WidgetShortcut context action #self.setFocus() #act.parent().setFocus() print('focusWidget', QApplication.focusWidget()) def cb(): tt = QApplication.focusWidget() print(tt) from PyQt5.Qt import QShortcut self.short0 = QShortcut(QKeySequence('Ctrl+N'), self) self.short0.activated.connect(cb) self.setGeometry(300, 300, 300, 200) self.setWindowTitle('Simple menu') self.show()
def __init__(self, title, widget=None, closeButton=True, keySequence=None, isDialog=False, icon=None): QDialog.__init__(self, ctx.mainScreen) self.setObjectName("dialog") self.isDialog = isDialog self.layout = QVBoxLayout() self.setLayout(self.layout) self.wlayout = QHBoxLayout() if icon: self.setStyleSheet( """QDialog QLabel{ margin-left:16px;margin-right:10px} QDialog#dialog {background-image:url(':/images/%s.png'); background-repeat:no-repeat; background-position: top left; padding-left:500px;} """ % icon) self.windowTitle = windowTitle(self, closeButton) self.setTitle(title) #self.layout.setMargin(0) self.layout.addWidget(self.windowTitle) if widget: self.addWidget(widget) try: widget.finished[int].connect(self.reject) except: pass finally: try: widget.resizeDialog[int, int].connect(self.resize) except: pass if closeButton: self.windowTitle.pushButton.clicked.connect(self.reject) if keySequence: shortCut = QShortcut(keySequence, self) shortCut.activated.connect(self.reject) QMetaObject.connectSlotsByName(self) self.resize(10, 10)
def __init__(self, view, parent=None): ''' @param: view WebView @param: parent QWidget ''' super().__init__(parent) self._ui = uic.loadUi('mc/webtab/SearchToolBar.ui', self) self._view = view # WebView self._findFlags = QWebEnginePage.FindCaseSensitively # QWebEnginePage.FindFlags self._searchRequests = 0 self._ui.closeButton.clicked.connect(self.close) self._ui.lineEdit.textEdited.connect(self.findNext) self._ui.next.clicked.connect(self.findNext) self._ui.previous.clicked.connect(self.findPrevious) self._ui.caseSensitive.clicked.connect(self.caseSensitivityChanged) findNextAction = QShortcut(QKeySequence('F3'), self) findNextAction.activated.connect(self.findNext) findPreviousAction = QShortcut(QKeySequence('Shift+F3'), self) findPreviousAction.activated.connect(self.findPrevious) parent.installEventFilter(self)
def __init__(self): super().__init__() self.initUI() self.installEventFilter(self.EventFilter(self)) self.setFocusPolicy(Qt.WheelFocus) self.setTabOrder(self.CmpTable, self.Inspector) self.setTabOrder(self.Inspector, self.Selector) self.setTabOrder(self.Selector, self.FieldInspector) #self.setTabOrder(self.FieldInspector, self.CmpTable) #---------------------------------------------------- # # Application Hotkeys # self.shortcutLeft = QShortcut(QKeySequence(Qt.ALT + Qt.Key_Left), self) self.shortcutRight = QShortcut(QKeySequence(Qt.ALT + Qt.Key_Right), self) self.shortcutLeft.setContext(Qt.ApplicationShortcut) self.shortcutRight.setContext(Qt.ApplicationShortcut) self.shortcutLeft.activated.connect(self.scroll_left) self.shortcutRight.activated.connect(self.scroll_right)
def __init__(self, parent, title, path): #super().__init__(parent, Qt.WA_DeleteOnClose ) super().__init__(parent, Qt.Window) self.text_browser = QTextBrowser(self) #self.text_browser = QWebEngineView(self) self.back_button = QPushButton('Back', self) self.forward_button = QPushButton('Forward', self) self.close_button = QPushButton('Close', self) self.layout = QVBoxLayout(self) self.btn_widget = QWidget(self) self.btn_layout = QHBoxLayout(self.btn_widget) self.btn_layout.addWidget(self.back_button) self.btn_layout.addWidget(self.forward_button) self.btn_layout.addStretch(1) self.btn_layout.addWidget(self.close_button) self.shortcutEscape = QShortcut(QKeySequence(Qt.Key_Escape), self) self.shortcutEscape.activated.connect(self.close) self.layout.addWidget(self.btn_widget) self.layout.addWidget(self.text_browser) self.back_button.clicked.connect(self.text_browser.backward) self.forward_button.clicked.connect(self.text_browser.forward) self.close_button.clicked.connect(self.close) self.text_browser.setSearchPaths([os.path.join(resources_path, 'doc')]) self.text_browser.setSource(QUrl(path)) # f = QFont() # f.setPointSize(14) # self.text_browser.setFont(f) Settings = QSettings('kicad-tools', 'Schematic Component Manager') if Settings.contains('help-window'): self.restoreGeometry(Settings.value('help-window')) #pos_x, pos_y, width, height = Settings.value('help-window') else: pos_x, pos_y, width, height = 0, 0, 640, 640 self.setGeometry(pos_x, pos_y, width, height) self.window().setWindowTitle(title) self.show()
def _setupMenu(self): if const.OS_MACOS: macMainMenu = None if not macMainMenu: macMainMenu = MainMenu(self, 0) macMainMenu.initMenuBar(QMenuBar(0)) gVar.app.activeWindowChanged.connect(macMainMenu.setWindow) else: macMainMenu.setWindow(self) else: self.setMenuBar(MenuBar(self)) self._mainMenu = MainMenu(self, self) self._mainMenu.initMenuBar(self.menuBar()) self._mainMenu.initSuperMenu(self._superMenu) # Setup other shortcuts reloadBypassCacheAction = QShortcut(QKeySequence('Ctrl+F5'), self) reloadBypassCacheAction2 = QShortcut(QKeySequence('Ctrl+Shift+R'), self) reloadBypassCacheAction.activated.connect(self.reloadBypassCache) reloadBypassCacheAction2.activated.connect(self.reloadBypassCache) closeTabAction = QShortcut(QKeySequence('Ctrl+W'), self) closeTabAction2 = QShortcut(QKeySequence('Ctrl+F4'), self) closeTabAction.activated.connect(self._closeTab) closeTabAction2.activated.connect(self._closeTab) reloadAction = QShortcut(QKeySequence('Ctrl+R'), self) reloadAction.activated.connect(self.reload) openLocationAction = QShortcut(QKeySequence('Alt+D'), self) openLocationAction.activated.connect(self._openLocation) inspectorAction = QShortcut(QKeySequence('F12'), self) inspectorAction.activated.connect(self.toggleWebInspector) restoreClosedWindow = QShortcut(QKeySequence('Ctrl+Shift+N'), self) restoreClosedWindow.activated.connect( gVar.app.closedWindowsManager().restoreClosedWindow)
def __init__(self, parent): #--------------------------------------------------- super().__init__(parent) self.Parent = parent #--------------------------------------------------- Settings = QSettings('kicad-tools', 'Schematic Component Manager') if Settings.contains('component-view'): CmpViewDict = Settings.value('component-view') else: CmpViewDict = { 'C': '$Value, $Footprint', 'D': '$LibRef', 'R': '$Value, $Footprint' } if Settings.contains('component-ignore'): IgnoreCmpRefsList = Settings.value('component-ignore') else: IgnoreCmpRefsList = [] #--------------------------------------------------- self.CmpViewTable = self.TCmpViewTable(self, CmpViewDict) self.IgnoreCmpList = self.TIgnoreCmpList(self, IgnoreCmpRefsList) #--------------------------------------------------- self.Tabs = QTabWidget(self) self.Tabs.addTab(self.CmpViewTable, 'Component View') self.Tabs.addTab(self.IgnoreCmpList, 'Ignore Component List') #--------------------------------------------------- self.ButtonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.ButtonBox.accepted.connect(self.save_settings) self.ButtonBox.rejected.connect(self.cancel) #--------------------------------------------------- self.Layout = QVBoxLayout(self) self.Layout.addWidget(self.Tabs) self.Layout.addWidget(self.ButtonBox) #--------------------------------------------------- self.setWindowTitle('Settings') self.setModal(True) #--------------------------------------------------- self.shortcutHelp = QShortcut(QKeySequence(Qt.Key_F1), self) self.shortcutHelp.activated.connect(self.show_help)
def __init__(self, parent=None): super().__init__(parent) self.ui = None # Ui::DownloadManager self._timer = QBasicTimer() self._lastDownloadPath = '' self._downloadPath = '' self._useNativeDialog = False self._isClosing = False self._closeOnFinish = False self._activeDownloadsCount = 0 self._useExternalManager = False self._externalExecutable = '' self._externalArguments = '' self._lastDownloadOption = self.NoOption # DownloadOption self._taskbarButton = None # QPointer<QWinTaskbarButton> self._ui = uic.loadUi('mc/downloads/DownloadManager.ui', self) self.setWindowFlags(self.windowFlags() ^ Qt.WindowMaximizeButtonHint) if const.OS_WIN: if QtWin.isCompositionEnabled(): # TODO: ? QtWin.extendFrameIntoClientArea(self, -1, -1, -1, -1) self._ui.clearButton.setIcon(QIcon.fromTheme('edit-clear')) gVar.appTools.centerWidgetOnScreen(self) self._ui.clearButton.clicked.connect(self._clearList) clearShortcut = QShortcut(QKeySequence('CTRL+L'), self) clearShortcut.activated.connect(self._clearList) self.loadSettings() gVar.appTools.setWmClass('Download Manager', self)
def __init_shortcuts(self): self.__keyF11 = QShortcut(self) self.__keyF11.setKey(Qt.Key_F11) self.__keyF11.activated.connect(self.__action_full_screen) self.__keyCtrlQ = QShortcut(self) self.__keyCtrlQ.setKey(Qt.CTRL + Qt.Key_Q) self.__keyCtrlQ.activated.connect(self.__action_quit) self.__keyCtrlH = QShortcut(self) self.__keyCtrlH.setKey(Qt.CTRL + Qt.Key_H) self.__keyCtrlH.activated.connect(self.__action_home) self.__keyCtrlR = QShortcut(self) self.__keyCtrlR.setKey(Qt.CTRL + Qt.Key_R) self.__keyCtrlR.activated.connect(self.__action_reload) self.__keyF5 = QShortcut(self) self.__keyF5.setKey(Qt.Key_F5) self.__keyF5.activated.connect(self.__action_reload) self.__keyAltLeft = QShortcut(self) self.__keyAltLeft.setKey(Qt.ALT + Qt.Key_Left) self.__keyAltLeft.activated.connect(self.__action_back)
def __init__(self, parent): QWidget.__init__(self, parent) self.parent = parent self._layout = QVBoxLayout() self.setLayout(self._layout) self._layout.setContentsMargins(0, 0, 0, 0) # Set up the find box & button search_layout = QHBoxLayout() self._layout.addLayout(search_layout) self.item_search = HistoryLineEdit(parent) self.item_search.setMinimumContentsLength(5) self.item_search.setSizeAdjustPolicy( self.item_search.AdjustToMinimumContentsLengthWithIcon) try: self.item_search.lineEdit().setPlaceholderText( _('Find item in tag browser')) except: pass # Using Qt < 4.7 self.item_search.setToolTip( _('Search for items. This is a "contains" search; items containing the\n' 'text anywhere in the name will be found. You can limit the search\n' 'to particular categories using syntax similar to search. For example,\n' 'tags:foo will find foo in any tag, but not in authors etc. Entering\n' '*foo will filter all categories at once, showing only those items\n' 'containing the text "foo"')) search_layout.addWidget(self.item_search) # Not sure if the shortcut should be translatable ... sc = QShortcut(QKeySequence(_('ALT+f')), parent) sc.activated.connect(self.set_focus_to_find_box) self.search_button = QToolButton() self.search_button.setText(_('F&ind')) self.search_button.setToolTip(_('Find the first/next matching item')) search_layout.addWidget(self.search_button) self.expand_button = QToolButton() self.expand_button.setText('-') self.expand_button.setToolTip(_('Collapse all categories')) search_layout.addWidget(self.expand_button) search_layout.setStretch(0, 10) search_layout.setStretch(1, 1) search_layout.setStretch(2, 1) self.current_find_position = None self.search_button.clicked.connect(self.find) self.item_search.initialize('tag_browser_search') self.item_search.lineEdit().returnPressed.connect(self.do_find) self.item_search.lineEdit().textEdited.connect(self.find_text_changed) self.item_search.activated[str].connect(self.do_find) self.item_search.completer().setCaseSensitivity(Qt.CaseSensitive) parent.tags_view = TagsView(parent) self.tags_view = parent.tags_view self.expand_button.clicked.connect(self.tags_view.collapseAll) self._layout.addWidget(parent.tags_view) # Now the floating 'not found' box l = QLabel(self.tags_view) self.not_found_label = l l.setFrameStyle(QFrame.StyledPanel) l.setAutoFillBackground(True) l.setText( '<p><b>' + _('No More Matches.</b><p> Click Find again to go to first match')) l.setAlignment(Qt.AlignVCenter) l.setWordWrap(True) l.resize(l.sizeHint()) l.move(10, 20) l.setVisible(False) self.not_found_label_timer = QTimer() self.not_found_label_timer.setSingleShot(True) self.not_found_label_timer.timeout.connect( self.not_found_label_timer_event, type=Qt.QueuedConnection) parent.alter_tb = l = QPushButton(parent) l.setText(_('Alter Tag Browser')) l.setIcon(QIcon(I('tags.png'))) l.m = QMenu() l.setMenu(l.m) self._layout.addWidget(l) sb = l.m.addAction(_('Sort by')) sb.m = l.sort_menu = QMenu(l.m) sb.setMenu(sb.m) sb.bg = QActionGroup(sb) # Must be in the same order as db2.CATEGORY_SORTS for i, x in enumerate((_('Sort by name'), _('Sort by number of books'), _('Sort by average rating'))): a = sb.m.addAction(x) sb.bg.addAction(a) a.setCheckable(True) if i == 0: a.setChecked(True) sb.setToolTip(_('Set the sort order for entries in the Tag Browser')) sb.setStatusTip(sb.toolTip()) ma = l.m.addAction(_('Search type when selecting multiple items')) ma.m = l.match_menu = QMenu(l.m) ma.setMenu(ma.m) ma.ag = QActionGroup(ma) # Must be in the same order as db2.MATCH_TYPE for i, x in enumerate( (_('Match any of the items'), _('Match all of the items'))): a = ma.m.addAction(x) ma.ag.addAction(a) a.setCheckable(True) if i == 0: a.setChecked(True) ma.setToolTip( _('When selecting multiple entries in the Tag Browser ' 'match any or all of them')) ma.setStatusTip(ma.toolTip()) mt = l.m.addAction(_('Manage authors, tags, etc.')) mt.setToolTip( _('All of these category_managers are available by right-clicking ' 'on items in the tag browser above')) mt.m = l.manage_menu = QMenu(l.m) mt.setMenu(mt.m)
def __init__(self, gui, row, toggle_shortcut): self.is_pane = gprefs.get('quickview_is_pane', False) if not self.is_pane: QDialog.__init__(self, gui, flags=Qt.WindowType.Widget) else: QDialog.__init__(self, gui) Ui_Quickview.__init__(self) self.setupUi(self) self.isClosed = False self.current_book = None self.closed_by_button = False if self.is_pane: self.main_grid_layout.setContentsMargins(0, 0, 0, 0) else: self.setWindowIcon(self.windowIcon()) self.books_table_column_widths = None try: self.books_table_column_widths = \ gprefs.get('quickview_dialog_books_table_widths', None) if not self.is_pane: geom = gprefs.get('quickview_dialog_geometry', None) if geom: QApplication.instance().safe_restore_geometry( self, QByteArray(geom)) except: pass self.view = gui.library_view self.db = self.view.model().db self.gui = gui self.is_closed = False self.current_book_id = None # the db id of the book used to fill the lh pane self.current_column = None # current logical column in books list self.current_key = None # current lookup key in books list self.last_search = None self.no_valid_items = False self.follow_library_view = True self.apply_vls.setCheckState( Qt.CheckState.Checked if gprefs['qv_respects_vls'] else Qt. CheckState.Unchecked) self.apply_vls.stateChanged.connect(self.vl_box_changed) self.fm = self.db.field_metadata self.items.setSelectionMode( QAbstractItemView.SelectionMode.SingleSelection) self.items.currentTextChanged.connect(self.item_selected) self.items.setProperty('highlight_current_item', 150) self.items.itemDoubleClicked.connect(self.item_doubleclicked) self.items.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.items.customContextMenuRequested.connect( self.show_item_context_menu) focus_filter = WidgetFocusFilter(self.items) focus_filter.focus_entered_signal.connect(self.focus_entered) self.items.installEventFilter(focus_filter) self.tab_pressed_signal.connect(self.tab_pressed) return_filter = BooksTableFilter(self.books_table) return_filter.return_pressed_signal.connect(self.return_pressed) self.books_table.installEventFilter(return_filter) focus_filter = WidgetFocusFilter(self.books_table) focus_filter.focus_entered_signal.connect(self.focus_entered) self.books_table.installEventFilter(focus_filter) self.close_button.clicked.connect(self.close_button_clicked) self.refresh_button.clicked.connect(self.refill) self.tab_order_widgets = [ self.items, self.books_table, self.lock_qv, self.dock_button, self.refresh_button, self.close_button ] for idx, widget in enumerate(self.tab_order_widgets): widget.installEventFilter( WidgetTabFilter(widget, idx, self.tab_pressed_signal)) self.books_table.setSelectionBehavior( QAbstractItemView.SelectionBehavior.SelectRows) self.books_table.setSelectionMode( QAbstractItemView.SelectionMode.SingleSelection) self.books_table.setProperty('highlight_current_item', 150) # Set up the books table columns self.add_columns_to_widget() self.books_table_header_height = self.books_table.height() self.books_table.cellDoubleClicked.connect(self.book_doubleclicked) self.books_table.currentCellChanged.connect( self.books_table_cell_changed) self.books_table.cellClicked.connect( self.books_table_set_search_string) self.books_table.cellActivated.connect( self.books_table_set_search_string) self.books_table.sortByColumn(0, Qt.SortOrder.AscendingOrder) # get the standard table row height. Do this here because calling # resizeRowsToContents can word wrap long cell contents, creating # double-high rows self.books_table.setRowCount(1) self.books_table.setItem(0, 0, TableItem('A', '')) self.books_table.resizeRowsToContents() self.books_table_row_height = self.books_table.rowHeight(0) self.books_table.setRowCount(0) # Add the data self.refresh(row) self.view.clicked.connect(self.slave) self.view.selectionModel().currentColumnChanged.connect( self.column_slave) QCoreApplication.instance().aboutToQuit.connect(self.save_state) self.view.model().new_bookdisplay_data.connect(self.book_was_changed) self.close_button.setDefault(False) self.close_button_tooltip = _( 'The Quickview shortcut ({0}) shows/hides the Quickview panel') if self.is_pane: self.dock_button.setText(_('Undock')) self.dock_button.setToolTip( _('Show the Quickview panel in its own floating window')) self.dock_button.setIcon(QIcon(I('arrow-up.png'))) # Remove the ampersands from the buttons because shortcuts exist. self.lock_qv.setText(_('Lock Quickview contents')) self.refresh_button.setText(_('Refresh')) self.gui.quickview_splitter.add_quickview_dialog(self) self.close_button.setVisible(False) else: self.dock_button.setToolTip( _('Embed the quickview panel into the main calibre window')) self.dock_button.setIcon(QIcon(I('arrow-down.png'))) self.set_focus() self.books_table.horizontalHeader().sectionResized.connect( self.section_resized) self.dock_button.clicked.connect(self.show_as_pane_changed) self.view.model().search_done.connect(self.check_for_no_items) # Enable the refresh button only when QV is locked self.refresh_button.setEnabled(False) self.lock_qv.stateChanged.connect(self.lock_qv_changed) self.view_icon = QIcon(I('view.png')) self.view_plugin = self.gui.iactions['View'] self.edit_metadata_icon = QIcon(I('edit_input.png')) self.quickview_icon = QIcon(I('quickview.png')) self.select_book_icon = QIcon(I('library.png')) self.search_icon = QIcon(I('search.png')) self.books_table.setContextMenuPolicy( Qt.ContextMenuPolicy.CustomContextMenu) self.books_table.customContextMenuRequested.connect( self.show_context_menu) # Add the quickview toggle as a shortcut for the close button # Don't add it if it identical to the current &X shortcut because that # breaks &X if (not self.is_pane and toggle_shortcut and self.close_button.shortcut() != toggle_shortcut): toggle_sc = QShortcut(toggle_shortcut, self.close_button) toggle_sc.activated.connect(lambda: self.close_button_clicked()) toggle_sc.setEnabled(True) self.close_button.setToolTip( _('Alternate shortcut: ') + toggle_shortcut.toString())
def initUI(self): #---------------------------------------------------- # # Main Window # work_zone = QWidget(self) Layout = QHBoxLayout(work_zone) self.setCentralWidget(work_zone) openAction = QAction(QIcon(os.path.join(resources_path, 'open24.png')), 'Open', self) openAction.setShortcut('Ctrl+O') openAction.setStatusTip('Open Schematic File') openAction.triggered.connect(self.open_file) saveAction = QAction(QIcon(os.path.join(resources_path, 'save24.png')), 'Save', self) saveAction.setShortcut('Ctrl+S') saveAction.setStatusTip('Save Schematic File') saveAction.triggered.connect(self.save_file) saveAsAction = QAction( QIcon(os.path.join(resources_path, 'save-as24.png')), 'Save As...', self) saveAsAction.setShortcut('Ctrl+Shift+S') saveAsAction.setStatusTip('Save Schematic File As...') saveAsAction.triggered.connect(self.save_file_as) exitAction = QAction(QIcon(os.path.join(resources_path, 'exit24.png')), 'Exit', self) exitAction.setShortcut('Ctrl+Q') exitAction.setStatusTip('Exit application') exitAction.triggered.connect(self.close) settingsAction = QAction( QIcon(os.path.join(resources_path, 'settings24.png')), 'Settings', self) settingsAction.setShortcut('Ctrl+Alt+S') settingsAction.setStatusTip('Edit settings') settingsAction.triggered.connect(self.edit_settings) helpAction = QAction( QIcon(os.path.join(resources_path, 'help_book24.png')), 'User\'s Manual', self) helpAction.setShortcut('F1') helpAction.setStatusTip('User\'s Manual') helpAction.triggered.connect(self.show_user_manual_slot) helpSDAction = QAction( QIcon(os.path.join(resources_path, 'gear24.png')), 'Settings Dialog', self) helpSDAction.setShortcut('Ctrl+F1') helpSDAction.setStatusTip('Settings Dialog Help') helpSDAction.triggered.connect(self.show_setting_dialog_help_slot) helpHKAction = QAction( QIcon(os.path.join(resources_path, 'rocket24.png')), 'Hotkeys', self) helpHKAction.setShortcut('Shift+F1') helpHKAction.setStatusTip('Hotkeys Help') helpHKAction.triggered.connect(self.show_hotkeys_help_slot) self.statusBar().showMessage('Ready') #-------------------------------------------- # # Main Menu # menubar = self.menuBar() fileMenu = menubar.addMenu('&File') fileMenu.addAction(openAction) fileMenu.addAction(saveAction) fileMenu.addAction(saveAsAction) fileMenu.addAction(exitAction) #-------------------------------------------- # # Options Menu # optionsMenu = menubar.addMenu('&Options') optionsMenu.addAction(settingsAction) #-------------------------------------------- # # Help Menu # helpMenu = menubar.addMenu('&Help') helpMenu.addAction(helpAction) helpMenu.addAction(helpSDAction) helpMenu.addAction(helpHKAction) #-------------------------------------------- # # Toolbar # toolbar = self.addToolBar('Exit') toolbar.addAction(exitAction) toolbar.addAction(openAction) toolbar.addAction(saveAction) toolbar.addAction(saveAsAction) toolbar.addAction(settingsAction) toolbar.addAction(helpAction) #---------------------------------------------------- # # Settings Dialog # #---------------------------------------------------- # # Components Table # self.CmpTabBox = QGroupBox('Components', self) self.CmpTabLayout = QVBoxLayout(self.CmpTabBox) self.CmpTabLayout.setContentsMargins(4, 10, 4, 4) self.CmpTabLayout.setSpacing(10) self.CmpTabLayout.setSizeConstraint(QVBoxLayout.SetMaximumSize) self.CmpTable = ComponentsTable(self) #self.CmpChooseButton = QPushButton('Choose', self) self.CmpTabLayout.addWidget(self.CmpTable) #self.CmpTabLayout.addWidget(self.CmpChooseButton) #---------------------------------------------------- # # Selector # self.SelectorBox = QGroupBox('Selector', self) self.SelectorLayout = QVBoxLayout(self.SelectorBox) self.SelectorLayout.setContentsMargins(4, 10, 4, 4) self.SelectorLayout.setSpacing(2) self.SelectorBtnWidget = QWidget(self) self.SelectorBtnLayout = QHBoxLayout(self.SelectorBtnWidget) self.SelectorBtnLayout.setContentsMargins(4, 10, 4, 4) self.SelectorBtnLayout.setSpacing(10) self.Selector = Selector(self) self.SelApplyButton = QPushButton('Apply', self) self.SelApplyButton.setToolTip( 'Alt+S: Apply selection patterns to components') self.SelClearButton = QPushButton('Clear', self) self.SelClearButton.setToolTip('Alt+C: Clear selection patterns') self.SelTemplateButton = QPushButton('Use Component', self) self.SelTemplateButton.setToolTip( 'Alt+T: Use Selected Component As Template') self.SelectorLayout.addWidget(self.Selector) self.SelectorBtnLayout.addWidget(self.SelTemplateButton) self.SelectorBtnLayout.addWidget(self.SelApplyButton) self.SelectorBtnLayout.addWidget(self.SelClearButton) self.SelectorLayout.addWidget(self.SelectorBtnWidget) self.shortcutSelApply = QShortcut(QKeySequence(Qt.ALT + Qt.Key_S), self) self.shortcutSelApply.activated.connect(self.Selector.apply_slot) self.shortcutSelClear = QShortcut(QKeySequence(Qt.ALT + Qt.Key_C), self) self.shortcutSelClear.activated.connect(self.Selector.clear_slot) self.shortcutSelTemplate = QShortcut(QKeySequence(Qt.ALT + Qt.Key_T), self) self.shortcutSelTemplate.activated.connect( self.Selector.use_comp_as_template_slot) #---------------------------------------------------- # # Inspector # self.Inspector = Inspector(self) self.FieldInspector = FieldInspector(self) self.InspectorBtnWidget = QWidget(self) self.InspectorBtnLayout = QHBoxLayout(self.InspectorBtnWidget) self.InspectorBtnLayout.setContentsMargins(4, 10, 4, 4) self.InspectorBtnLayout.setSpacing(10) self.AddUserProperty = QPushButton('Add Property', self) self.AddUserProperty.setToolTip('Alt+A: Add new user property') self.DeleteUserProperty = QPushButton('Delete Property', self) self.DeleteUserProperty.setToolTip('Alt+Delete: Delete user property') self.RenameUserProperty = QPushButton('Rename Property', self) self.RenameUserProperty.setToolTip('Alt+R: Rename user property') self.InspectorBox = QGroupBox('Inspector', self) self.InspectorSplit = QSplitter(Qt.Vertical, self) self.InspectorLayout = QVBoxLayout(self.InspectorBox) self.InspectorLayout.setContentsMargins(4, 10, 4, 4) self.InspectorLayout.setSpacing(2) self.InspectorSplit.addWidget(self.Inspector) self.InspectorSplit.addWidget(self.FieldInspector) self.InspectorLayout.addWidget(self.InspectorSplit) self.InspectorBtnLayout.addWidget(self.AddUserProperty) self.InspectorBtnLayout.addWidget(self.DeleteUserProperty) self.InspectorBtnLayout.addWidget(self.RenameUserProperty) self.InspectorLayout.addWidget(self.InspectorBtnWidget) self.shortcutSelApply = QShortcut(QKeySequence(Qt.ALT + Qt.Key_A), self) self.shortcutSelApply.activated.connect(self.add_user_property) self.shortcutSelApply = QShortcut(QKeySequence(Qt.ALT + Qt.Key_Delete), self) self.shortcutSelApply.activated.connect(self.remove_user_property) self.shortcutSelApply = QShortcut(QKeySequence(Qt.ALT + Qt.Key_R), self) self.shortcutSelApply.activated.connect(self.rename_user_property) #---------------------------------------------------- self.Splitter = QSplitter(self) self.Splitter.addWidget(self.CmpTabBox) self.Splitter.addWidget(self.SelectorBox) self.Splitter.addWidget(self.InspectorBox) self.centralWidget().layout().addWidget(self.Splitter) #---------------------------------------------------- # # Signals and Slots connections # self.CmpTable.cells_chosen.connect(self.Inspector.load_cmp) self.CmpTable.cells_chosen.connect(self.Selector.comp_template_slot) self.CmpTable.file_load.connect(self.file_loaded_slot) self.CmpTable.cmps_updated.connect(self.Selector.process_comps_slot) self.CmpTable.cmps_selected.connect(self.set_status_text_slot) self.SelApplyButton.clicked.connect(self.Selector.apply_slot) self.SelClearButton.clicked.connect(self.Selector.clear_slot) self.SelTemplateButton.clicked.connect( self.Selector.use_comp_as_template_slot) self.Selector.select_comps_signal.connect( self.CmpTable.select_comps_slot) self.Inspector.load_field.connect(self.FieldInspector.load_field_slot) self.Inspector.update_comps.connect(self.data_changed_slot) self.Inspector.update_comps.connect(self.CmpTable.update_cmp_list_slot) self.FieldInspector.data_changed.connect(self.data_changed_slot) CmpMgr.file_saved.connect(self.file_saved_slot) self.CmpTable.mouse_click.connect(self.mouse_change_tool) self.Inspector.mouse_click.connect(self.mouse_change_tool) self.FieldInspector.mouse_click.connect(self.mouse_change_tool) self.Inspector.header().sectionResized.connect( self.FieldInspector.column_resize) self.AddUserProperty.clicked.connect(self.add_user_property) self.DeleteUserProperty.clicked.connect(self.remove_user_property) self.RenameUserProperty.clicked.connect(self.rename_user_property) #---------------------------------------------------- self.ToolList = [] self.ToolList.append(self.CmpTable) self.ToolList.append(self.Selector) self.ToolList.append(self.Inspector) self.ToolList.append(self.FieldInspector) self.ToolIndex = 0 #---------------------------------------------------- # # Window # self.setWindowTitle(self.PROGRAM_NAME) Settings = QSettings('kicad-tools', 'Schematic Component Manager') #print(Settings.allKeys()) if Settings.contains('geometry'): self.restoreGeometry(Settings.value('geometry')) else: self.setGeometry(100, 100, 1024, 768) if Settings.contains('cmptable'): w0, w1 = Settings.value('cmptable') self.CmpTable.setColumnWidth(0, int(w0)) self.CmpTable.setColumnWidth(1, int(w1)) if Settings.contains('selector'): w0, w1 = Settings.value('selector') self.Selector.setColumnWidth(0, int(w0)) self.Selector.setColumnWidth(1, int(w1)) if Settings.contains('inspector'): w0, w1 = Settings.value('inspector') self.Inspector.setColumnWidth(0, int(w0)) self.Inspector.setColumnWidth(1, int(w1)) self.FieldInspector.setColumnWidth(0, int(w0)) self.FieldInspector.setColumnWidth(1, int(w1)) #self.Inspector.setColumnWidth( 2, int(w2) ) if Settings.contains('splitter'): self.Splitter.restoreState(Settings.value('splitter')) if Settings.contains('inssplitter'): self.InspectorSplit.restoreState(Settings.value('inssplitter')) #---------------------------------------------------- # # Process command line arguments # if len(sys.argv) > 1: fname = sys.argv[1] if os.path.exists(fname): self.CmpTable.load_file(fname) else: print('E: input file "' + fname + '"does not exist') self.show()
def __init__(self, parent=None): ''' @param parent QWidget ''' super().__init__(parent) self._ui = uic.loadUi('mc/cookies/CookieManager.ui', self) self._domainHash = {} # QHash<QString, QTreeWidgetItem> self._itemHash = {} # QHash<QTreeWidgetItem, QNetworkCookie> self.setAttribute(Qt.WA_DeleteOnClose) gVar.appTools.centerWidgetOnScreen(self) if self.isRightToLeft(): self._ui.cookieTree.headerItem().setTextAlignment( 0, Qt.AlignRight | Qt.AlignVCenter) self._ui.cookieTree.headerItem().setTextAlignment( 1, Qt.AlignRight | Qt.AlignVCenter) self._ui.cookieTree.setLayoutDirection(Qt.LeftToRight) self._ui.whiteList.setLayoutDirection(Qt.LeftToRight) self._ui.blackList.setLayoutDirection(Qt.LeftToRight) # Stored Cookies self._ui.cookieTree.currentItemChanged.connect( self._currentItemChanged) self._ui.removeAll.clicked.connect(self._removeAll) self._ui.removeOne.clicked.connect(self._remove) self._ui.close.clicked.connect(lambda: self._close()) self._ui.close2.clicked.connect(lambda: self._close()) self._ui.close3.clicked.connect(lambda: self._close()) self._ui.search.textChanged.connect(self._filterString) # Cookie Filtering self._ui.whiteAdd.clicked.connect(self._addWhitelist) self._ui.whiteRemove.clicked.connect(self._removeWhitelist) self._ui.blackAdd.clicked.connect(self._addBlacklist) self._ui.blackRemove.clicked.connect(self._removeBlacklist) # Cookie Settings settings = Settings() settings.beginGroup('Cookie-Settings') self._ui.saveCookies.setChecked(settings.value('allCookies', True)) self._ui.filter3rdParty.setChecked( settings.value('filterThirdPartyCookies', False)) self._ui.filterTracking.setChecked( settings.value('filterTrackingCookie', False)) self._ui.deleteCookiesOnClose.setChecked( settings.value('deleteCookiesOnClose', False)) self._ui.whiteList.addItems(settings.value('whitelist', [])) self._ui.blackList.addItems(settings.value('blacklist', [])) settings.endGroup() if const.QTWEBENGINEWIDGETS_VERSION < const.QT_VERSION_CHECK(5, 11, 0): self._ui.filter3rdParty.hide() self._ui.search.setPlaceholderText(_('Search')) self._ui.cookieTree.setDefaultItemShowMode(TreeWidget.ItemsCollapsed) self._ui.cookieTree.sortItems(0, Qt.AscendingOrder) self._ui.cookieTree.header().setDefaultSectionSize(220) self._ui.cookieTree.setFocus() self._ui.whiteList.setSortingEnabled(True) self._ui.blackList.setSortingEnabled(True) self._removeShortcut = QShortcut(QKeySequence('Del'), self) self._removeShortcut.activated.connect(self._deletePressed) self._ui.search.textChanged.connect(self._filterString) cookieJar = gVar.app.cookieJar() cookieJar.cookieAdded.connect(self._addCookie) cookieJar.cookieRemoved.connect(self._removeCookie) # Load cookies for cookie in cookieJar.getAllCookies(): self._addCookie(cookie) gVar.appTools.setWmClass('Cookies', self)
def register_shortcuts(self, window): self.__keyCtrlF = QShortcut(window) self.__keyCtrlF.setKey(Qt.CTRL + Qt.Key_F) self.__keyCtrlF.activated.connect(lambda: self.__activate_floating())
def __init__(self, parent, view, row, link_delegate): QDialog.__init__(self, parent) self.normal_brush = QBrush(Qt.white) self.marked_brush = QBrush(Qt.lightGray) self.marked = None self.gui = parent self.splitter = QSplitter(self) self._l = l = QVBoxLayout(self) self.setLayout(l) l.addWidget(self.splitter) self.cover = CoverView(self) self.cover.resizeEvent = self.cover_view_resized self.cover.cover_changed.connect(self.cover_changed) self.cover_pixmap = None self.cover.sizeHint = self.details_size_hint self.splitter.addWidget(self.cover) self.details = Details(parent.book_details.book_info, self) self.details.page().setLinkDelegationPolicy( self.details.page().DelegateAllLinks) self.details.linkClicked.connect(self.link_clicked) s = self.details.page().settings() s.setAttribute(s.JavascriptEnabled, False) self.css = css() self.link_delegate = link_delegate self.details.setAttribute(Qt.WA_OpaquePaintEvent, False) palette = self.details.palette() self.details.setAcceptDrops(False) palette.setBrush(QPalette.Base, Qt.transparent) self.details.page().setPalette(palette) self.c = QWidget(self) self.c.l = l2 = QGridLayout(self.c) self.c.setLayout(l2) l2.addWidget(self.details, 0, 0, 1, -1) self.splitter.addWidget(self.c) self.fit_cover = QCheckBox(_('Fit &cover within view'), self) self.fit_cover.setChecked( gprefs.get('book_info_dialog_fit_cover', True)) l2.addWidget(self.fit_cover, l2.rowCount(), 0, 1, -1) self.previous_button = QPushButton(QIcon(I('previous.png')), _('&Previous'), self) self.previous_button.clicked.connect(self.previous) l2.addWidget(self.previous_button, l2.rowCount(), 0) self.next_button = QPushButton(QIcon(I('next.png')), _('&Next'), self) self.next_button.clicked.connect(self.next) l2.addWidget(self.next_button, l2.rowCount() - 1, 1) self.view = view self.current_row = None self.refresh(row) self.view.model().new_bookdisplay_data.connect(self.slave) self.fit_cover.stateChanged.connect(self.toggle_cover_fit) self.ns = QShortcut(QKeySequence('Alt+Right'), self) self.ns.activated.connect(self.next) self.ps = QShortcut(QKeySequence('Alt+Left'), self) self.ps.activated.connect(self.previous) self.next_button.setToolTip( _('Next [%s]') % unicode(self.ns.key().toString(QKeySequence.NativeText))) self.previous_button.setToolTip( _('Previous [%s]') % unicode(self.ps.key().toString(QKeySequence.NativeText))) geom = QCoreApplication.instance().desktop().availableGeometry(self) screen_height = geom.height() - 100 screen_width = geom.width() - 100 self.resize(max(int(screen_width / 2), 700), screen_height) saved_layout = gprefs.get('book_info_dialog_layout', None) if saved_layout is not None: try: self.restoreGeometry(saved_layout[0]) self.splitter.restoreState(saved_layout[1]) except Exception: pass
def set_shortcuts(lista, context=Qt.WidgetWithChildrenShortcut): """ Creates QShortcuts from a list of (key, owner, callback) 3-tuples """ for (shortcut, owner, callback) in lista: QShortcut(shortcut, owner, callback).setContext(context)
def setup_widgets(self): # file editing and tabs self.editor_pane = gui_widgets.TabController(self, self.ontologies) self.editor_pane.currentChanged.connect(self.__on_tab_change) # project navigation self.explorer_tab = QTabWidget(self) self.project_explorer = gui_widgets.ProjectExplorer(self, self.root_path, self.editor_pane) self.explorer_tab.addTab(self.project_explorer, "Directory") self.import_explorer = gui_widgets.ImportSidebar(self, self.root_path, self.editor_pane) self.explorer_tab.addTab(self.import_explorer, "Imports") # informational sidebar self.info_bar = gui_widgets.InformationSidebar(self, self.root_path) # output self.console = gui_widgets.Console(self) main_menu = self.menuBar() # file menu and associated actions file_menu = main_menu.addMenu('File') # Create a new tab new_action = QAction("New File", self) file_menu.addAction(new_action) new_action.triggered.connect(self.new_command) # Open a file open_action = QAction("Open", self) file_menu.addAction(open_action) open_action.triggered.connect(self.open_command) open_shortcut = QShortcut(QKeySequence("Ctrl+O"), self) open_shortcut.activated.connect(self.open_command) # Save file; if no file, open dialog save_action = QAction("Save", self) file_menu.addAction(save_action) save_action.triggered.connect(self.save_command) save_shortcut = QShortcut(QKeySequence("Ctrl+S"), self) save_shortcut.activated.connect(self.save_command) # Open Save dialog saveas_action = QAction("Save As..", self) file_menu.addAction(saveas_action) saveas_action.triggered.connect(self.saveas_command) # Open settings dialog settings_action = QAction("Settings..", self) file_menu.addAction(settings_action) settings_action.triggered.connect(self.settings_command) # Open Export dialog export_action = QAction("Export.. ", self) file_menu.addAction(export_action) export_action.triggered.connect(self.export_command) # Run menu and associated actions run_menu = main_menu.addMenu('Run') # Run the parse w/out resolving imports parse_action = QAction("Parse (No Imports)", self) run_menu.addAction(parse_action) parse_action.triggered.connect(self.parse_command) # Run the parse w/ imports parse_imports_action = QAction("Parse (w/ Imports)", self) run_menu.addAction(parse_imports_action) parse_imports_action.triggered.connect(self.parse_imports_command) run_menu.addSeparator() # Run the check consistency dialog check_consistency_action = QAction("Check Consistency..", self) run_menu.addAction(check_consistency_action) check_consistency_action.triggered.connect(self.check_consistency_command) # Threads self.parse_thread = gui_threads.ParseThread() self.parse_thread.finished.connect(self.__on_parse_done)
def __init__(self): QWidget.__init__(self, None) # Set pixmaps resource before Main Window initialized self._resource = os.path.join(ctx.consts.theme_dir, ctx.flags.theme, ctx.consts.pixmaps_resource_file) if os.path.exists(self._resource): resource = QResource() resource.registerResource(self._resource) else: raise yali.Error, _("Pixmaps resources file doesn't exists") self.ui = Ui_YaliMain() self.ui.setupUi(self) self.font = 10 self.animation_type = None self.screens = None self.screens_content = None self.pds_helper = HelpWidget(self.ui.scrollAreaWidgetContents) # shortcut to open help self.help_shortcut = QShortcut(QKeySequence(Qt.Key_F1), self) # shortcut to open debug window #self.debugShortCut = QtWidgets.QShortcut(QtWidgets.QKeySequence(Qt.Key_F2),self) # something funny self.tetris_shortcut = QShortcut(QKeySequence(Qt.Key_F6), self) self.cursor_shortcut = QShortcut(QKeySequence(Qt.Key_F7), self) self.theme_shortcut = QShortcut(QKeySequence(Qt.Key_F8), self) # shortcut to open a console self.console_shortcut = QShortcut(QKeySequence(Qt.Key_F11), self) # set style self._style = os.path.join(ctx.consts.theme_dir, ctx.flags.theme, ctx.consts.style_file) if os.path.exists(self._style): self.updateStyle() else: raise yali.Error, _("Style file doesn't exists") # set screens content release_file = os.path.join(ctx.consts.branding_dir, ctx.flags.branding, ctx.consts.release_file) if os.path.exists(release_file): self.screens_content = yali.util.parse_branding_screens( release_file) else: raise yali.Error, _("Release file doesn't exists") # move one step at a time self.step_increment = 1 # ToolButton Popup Menu self.menu = QMenu() self.shutdown = self.menu.addAction( QIcon(QPixmap(":/images/system-shutdown.png")), _("Turn Off Computer")) self.reboot = self.menu.addAction( QIcon(QPixmap(":/images/system-reboot.png")), _("Restart Computer")) self.restart = self.menu.addAction( QIcon(QPixmap(":/images/system-yali-reboot.png")), _("Restart YALI")) #self.menu.setDefaultAction(self.shutdown) self.ui.system_menu.setMenu(self.menu) self.ui.system_menu.setDefaultAction(self.shutdown) # Main Slots self.help_shortcut.activated.connect(self.pds_helper.toggleHelp) #self.debugShortCut.activated.connect(self.toggleDebug) self.console_shortcut.activated.connect(self.toggleConsole) self.cursor_shortcut.activated.connect(self.toggleCursor) self.theme_shortcut.activated.connect(self.toggleTheme) self.tetris_shortcut.activated.connect(self.toggleTetris) self.ui.buttonNext.clicked.connect(self.slotNext) self.ui.buttonBack.clicked.connect(self.slotBack) self.ui.toggleHelp.clicked.connect(self.pds_helper.toggleHelp) if not ctx.flags.install_type == ctx.STEP_FIRST_BOOT: self.ui.releaseNotes.clicked.connect(self.showReleaseNotes) else: self.ui.releaseNotes.hide() self.menu.triggered[QAction].connect(self.slotMenu) self.cmb = _("right") self.dont_ask_again = False self.terminal = None self.tetris = None self.ui.helpContentFrame.hide() self.effect = QGraphicsOpacityEffect(self) self.ui.mainStack.setGraphicsEffect(self.effect) self.effect.setOpacity(1.0) self.anime = QTimer(self) self.anime.timeout.connect(self.animate)
def __init__(self, parent, view, row, link_delegate): QDialog.__init__(self, parent) self.normal_brush = QBrush(Qt.white) self.marked_brush = QBrush(Qt.lightGray) self.marked = None self.gui = parent self.splitter = QSplitter(self) self._l = l = QVBoxLayout(self) self.setLayout(l) l.addWidget(self.splitter) self.cover = CoverView(self, show_size=gprefs['bd_overlay_cover_size']) self.cover.resizeEvent = self.cover_view_resized self.cover.cover_changed.connect(self.cover_changed) self.cover_pixmap = None self.cover.sizeHint = self.details_size_hint self.splitter.addWidget(self.cover) self.details = Details(parent.book_details.book_info, self) self.details.anchor_clicked.connect(self.on_link_clicked) self.link_delegate = link_delegate self.details.setAttribute(Qt.WA_OpaquePaintEvent, False) palette = self.details.palette() self.details.setAcceptDrops(False) palette.setBrush(QPalette.Base, Qt.transparent) self.details.setPalette(palette) self.c = QWidget(self) self.c.l = l2 = QGridLayout(self.c) l2.setContentsMargins(0, 0, 0, 0) self.c.setLayout(l2) l2.addWidget(self.details, 0, 0, 1, -1) self.splitter.addWidget(self.c) self.fit_cover = QCheckBox(_('Fit &cover within view'), self) self.fit_cover.setChecked( gprefs.get('book_info_dialog_fit_cover', True)) self.hl = hl = QHBoxLayout() hl.setContentsMargins(0, 0, 0, 0) l2.addLayout(hl, l2.rowCount(), 0, 1, -1) hl.addWidget(self.fit_cover), hl.addStretch() self.clabel = QLabel( '<div style="text-align: right"><a href="calibre:conf" title="{}" style="text-decoration: none">{}</a>' .format(_('Configure this view'), _('Configure'))) self.clabel.linkActivated.connect(self.configure) hl.addWidget(self.clabel) self.previous_button = QPushButton(QIcon(I('previous.png')), _('&Previous'), self) self.previous_button.clicked.connect(self.previous) l2.addWidget(self.previous_button, l2.rowCount(), 0) self.next_button = QPushButton(QIcon(I('next.png')), _('&Next'), self) self.next_button.clicked.connect(self.next) l2.addWidget(self.next_button, l2.rowCount() - 1, 1) self.view = view self.current_row = None self.refresh(row) self.view.model().new_bookdisplay_data.connect(self.slave) self.fit_cover.stateChanged.connect(self.toggle_cover_fit) self.ns = QShortcut(QKeySequence('Alt+Right'), self) self.ns.activated.connect(self.next) self.ps = QShortcut(QKeySequence('Alt+Left'), self) self.ps.activated.connect(self.previous) self.next_button.setToolTip( _('Next [%s]') % unicode_type(self.ns.key().toString(QKeySequence.NativeText))) self.previous_button.setToolTip( _('Previous [%s]') % unicode_type(self.ps.key().toString(QKeySequence.NativeText))) geom = QCoreApplication.instance().desktop().availableGeometry(self) screen_height = geom.height() - 100 screen_width = geom.width() - 100 self.resize(max(int(screen_width / 2), 700), screen_height) saved_layout = gprefs.get('book_info_dialog_layout', None) if saved_layout is not None: try: self.restoreGeometry(saved_layout[0]) self.splitter.restoreState(saved_layout[1]) except Exception: pass
def register_shortcuts(self, window): self.__keyCtrlP = QShortcut(window) self.__keyCtrlP.setKey(Qt.CTRL + Qt.Key_P) self.__keyCtrlP.activated.connect( lambda: self.__show_profile_manager())