示例#1
0
 def applyShortcuts(self, shortcuts):
     qshortcuts = []
     for key, fn in shortcuts:
         scut = QShortcut(QKeySequence(key), self, activated=fn)
         scut.setAutoRepeat(False)
         qshortcuts.append(scut)
     return qshortcuts
示例#2
0
文件: webview.py 项目: solarmist/anki
    def __init__(self, parent=None):
        QWebEngineView.__init__(self, parent=parent)
        self.title = "default"
        self._page = AnkiWebPage(self._onBridgeCmd)
        self._page.setBackgroundColor(self._getWindowColor())  # reduce flicker

        self._domDone = True
        self._pendingActions = []
        self.requiresCol = True
        self.setPage(self._page)

        self._page.profile().setHttpCacheType(QWebEngineProfile.NoCache)
        self.resetHandlers()
        self.allowDrops = False
        self._filterSet = False
        QShortcut(QKeySequence("Esc"), self,
                  context=Qt.WidgetWithChildrenShortcut, activated=self.onEsc)
        if isMac:
            for key, fn in [
                (QKeySequence.Copy, self.onCopy),
                (QKeySequence.Paste, self.onPaste),
                (QKeySequence.Cut, self.onCut),
                (QKeySequence.SelectAll, self.onSelectAll),
            ]:
                QShortcut(key, self,
                          context=Qt.WidgetWithChildrenShortcut,
                          activated=fn)
            QShortcut(QKeySequence("ctrl+shift+v"), self,
                      context=Qt.WidgetWithChildrenShortcut, activated=self.onPaste)
示例#3
0
    def __init__(self, parent, tags, alltags):
        QDialog.__init__(self, parent, Qt.WindowType.Window)  # super().__init__(parent)
        self.parent = parent
        self.all_tags = alltags
        self.setWindowTitle("Anki - Edit Tags")

        self.form = dialog_qlistwidget.Ui_Dialog()
        self.form.setupUi(self)
        
        sheet_to_use = stylesheet_dark if theme_manager.night_mode else stylesheet_light
        self.form.listWidget.setStyleSheet(sheet_to_use)
        # self.form.listWidget.currentRowChanged.connect(self.on_row_changed)

        self.form.buttonBox.accepted.connect(self.accept)
        self.form.buttonBox.rejected.connect(self.reject)
        self.form.pb_search.clicked.connect(lambda: self.do_browser_search(extra_search=""))
        self.form.pb_edit_tag.clicked.connect(self.tagselector)
        self.form.pb_add_empty.clicked.connect(lambda: self.maybe_add_line(force=True))

        self.shortcut = QShortcut(QKeySequence("Ctrl+Return"), self)
        self.shortcut.activated.connect(self.accept)

        originalheight = self.height()
        restoreGeom(self, "TagDialogExtended")
        self.resize(self.width(), originalheight)
        
        if not tags:
            tags = ["",]
        else:
            tags.append("")
        
        for t in tags:
            self.maybe_add_line(t)

        self.cut = gc("in tag lines dialog: open filterdialog for single tag")
        if self.cut:
            self.form.pb_edit_tag.setToolTip('shortcut: {}'.format(self.cut))
            self.selkey = QShortcut(QKeySequence(self.cut), self)
            self.selkey.activated.connect(self.tagselector)
        
        self.browser_scut = gc("in tag lines dialog: search browser for tag")
        if self.browser_scut:
            self.form.pb_search.setToolTip('shortcut: {}'.format(self.browser_scut))
            self.browser_scut_key = QShortcut(QKeySequence(self.browser_scut), self)
            self.browser_scut_key.activated.connect(lambda: self.do_browser_search(extra_search=""))
        
        # don't also set Ctrl+t,a/gc("editor: show filterdialog to add single tag") for 
        # self.tagselector: What if the user has already set them to the same etc. I'd have
        # to do a lot of checking
        self.addnl = gc("in tag lines dialog: insert additional line")
        if self.addnl:
            self.form.pb_add_empty.setToolTip('shortcut: {}'.format(self.addnl))
            self.addnlscut = QShortcut(QKeySequence(self.addnl), self)
            self.addnlscut.activated.connect(lambda: self.maybe_add_line(force=True))       
示例#4
0
    def _create_gui(self) -> None:
        self.setWindowTitle(tr(TR.ACTIONS_PREVIEW))

        self.close_shortcut = QShortcut(QKeySequence("Ctrl+Shift+P"), self)
        qconnect(self.close_shortcut.activated, self.close)

        qconnect(self.finished, self._on_finished)
        self.silentlyClose = True
        self.vbox = QVBoxLayout()
        self.vbox.setContentsMargins(0, 0, 0, 0)
        self._web = AnkiWebView(title="previewer")
        self.vbox.addWidget(self._web)
        self.bbox = QDialogButtonBox()

        self._replay = self.bbox.addButton(tr(TR.ACTIONS_REPLAY_AUDIO),
                                           QDialogButtonBox.ActionRole)
        self._replay.setAutoDefault(False)
        self._replay.setShortcut(QKeySequence("R"))
        self._replay.setToolTip(tr(TR.ACTIONS_SHORTCUT_KEY, val="R"))
        qconnect(self._replay.clicked, self._on_replay_audio)

        both_sides_button = QCheckBox(tr(TR.QT_MISC_BACK_SIDE_ONLY))
        both_sides_button.setShortcut(QKeySequence("B"))
        both_sides_button.setToolTip(tr(TR.ACTIONS_SHORTCUT_KEY, val="B"))
        self.bbox.addButton(both_sides_button, QDialogButtonBox.ActionRole)
        self._show_both_sides = self.mw.col.get_config_bool(
            Config.Bool.PREVIEW_BOTH_SIDES)
        both_sides_button.setChecked(self._show_both_sides)
        qconnect(both_sides_button.toggled, self._on_show_both_sides)

        self.vbox.addWidget(self.bbox)
        self.setLayout(self.vbox)
        restoreGeom(self, "preview")
示例#5
0
 def setupDecks(self):
     if self.label:
         self.deckLabel = QLabel(_("Deck"))
         self.addWidget(self.deckLabel)
     # decks box
     self.deck = QPushButton(clicked=self.onDeckChange)
     self.deck.setToolTip(shortcut(_("Target Deck (Ctrl+D)")))
     s = QShortcut(QKeySequence(_("Ctrl+D")), self.widget, activated=self.onDeckChange)
     self.addWidget(self.deck)
     # starting label
     if self.mw.col.conf.get("addToCur", True):
         col = self.mw.col
         did = col.conf['curDeck']
         if col.decks.isDyn(did):
             # if they're reviewing, try default to current card
             c = self.mw.reviewer.card
             if self.mw.state == "review" and c:
                 if not c.odid:
                     did = c.did
                 else:
                     did = c.odid
             else:
                 did = 1
         self.setDeckName(self.mw.col.decks.nameOrNone(
             did) or _("Default"))
     else:
         self.setDeckName(self.mw.col.decks.nameOrNone(
             self.mw.col.models.current()['did']) or _("Default"))
     # layout
     sizePolicy = QSizePolicy(
         QSizePolicy.Policy(7),
         QSizePolicy.Policy(0))
     self.deck.setSizePolicy(sizePolicy)
示例#6
0
文件: editor.py 项目: solarmist/anki
 def setupShortcuts(self):
     # if a third element is provided, enable shortcut even when no field selected
     cuts = [
         ("Ctrl+L", self.onCardLayout, True),
         ("Ctrl+B", self.toggleBold),
         ("Ctrl+I", self.toggleItalic),
         ("Ctrl+U", self.toggleUnderline),
         ("Ctrl++", self.toggleSuper),
         ("Ctrl+=", self.toggleSub),
         ("Ctrl+R", self.removeFormat),
         ("F7", self.onForeground),
         ("F8", self.onChangeCol),
         ("Ctrl+Shift+C", self.onCloze),
         ("Ctrl+Shift+Alt+C", self.onCloze),
         ("F3", self.onAddMedia),
         ("F5", self.onRecSound),
         ("Ctrl+T, T", self.insertLatex),
         ("Ctrl+T, E", self.insertLatexEqn),
         ("Ctrl+T, M", self.insertLatexMathEnv),
         ("Ctrl+M, M", self.insertMathjaxInline),
         ("Ctrl+M, E", self.insertMathjaxBlock),
         ("Ctrl+M, C", self.insertMathjaxChemistry),
         ("Ctrl+Shift+X", self.onHtmlEdit),
         ("Ctrl+Shift+T", self.onFocusTags, True)
     ]
     runHook("setupEditorShortcuts", cuts, self)
     for row in cuts:
         if len(row) == 2:
             keys, fn = row
             fn = self._addFocusCheck(fn)
         else:
             keys, fn, _ = row
         QShortcut(QKeySequence(keys), self.widget, activated=fn)
示例#7
0
    def _create_gui(self) -> None:
        self.setWindowTitle(tr.actions_preview())

        self.close_shortcut = QShortcut(QKeySequence("Ctrl+Shift+P"), self)
        qconnect(self.close_shortcut.activated, self.close)

        qconnect(self.finished, self._on_finished)
        self.silentlyClose = True
        self.vbox = QVBoxLayout()
        self.vbox.setContentsMargins(0, 0, 0, 0)
        self._web = AnkiWebView(title="previewer")
        self.vbox.addWidget(self._web)
        self.bbox = QDialogButtonBox()
        self.bbox.setLayoutDirection(Qt.LayoutDirection.LeftToRight)

        self._replay = self.bbox.addButton(
            tr.actions_replay_audio(), QDialogButtonBox.ButtonRole.ActionRole)
        self._replay.setAutoDefault(False)
        self._replay.setShortcut(QKeySequence("R"))
        self._replay.setToolTip(tr.actions_shortcut_key(val="R"))
        qconnect(self._replay.clicked, self._on_replay_audio)

        both_sides_button = QCheckBox(tr.qt_misc_back_side_only())
        both_sides_button.setShortcut(QKeySequence("B"))
        both_sides_button.setToolTip(tr.actions_shortcut_key(val="B"))
        self.bbox.addButton(both_sides_button,
                            QDialogButtonBox.ButtonRole.ActionRole)
        self._show_both_sides = self.mw.col.get_config_bool(
            Config.Bool.PREVIEW_BOTH_SIDES)
        both_sides_button.setChecked(self._show_both_sides)
        qconnect(both_sides_button.toggled, self._on_show_both_sides)

        self.vbox.addWidget(self.bbox)
        self.setLayout(self.vbox)
        restoreGeom(self, "preview")
def extend_debug_console(dc_instance):

    # OVERWRITE built-in context menu
    frm = mw.debug_diag_form
    frm.log.contextMenuEvent = lambda ev: addContextMenu(
        ev, "log", dc_instance)
    frm.text.contextMenuEvent = lambda ev: addContextMenu(
        ev, "text", dc_instance)

    cut = gc("debug console: shortcut open history window", "ctrl+i")
    if cut:
        hist_window = QShortcut(QKeySequence(cut), dc_instance)
        hist_window.activated.connect(lambda d=dc_instance: history_helper(d))
    cut = gc("debug console: shortcut save", "ctrl+s")
    if cut:
        save = QShortcut(QKeySequence(cut), dc_instance)
        save.activated.connect(lambda d=dc_instance: save_current(d))
示例#9
0
 def __init__(self, mw, parent):
     QDialog.__init__(self, parent, Qt.Window)
     self.mw = mw
     self.parent = parent
     self.deck = self.parent.deck
     self.dialog = aqt.forms.taglimit.Ui_Dialog()
     self.dialog.setupUi(self)
     s = QShortcut(QKeySequence("ctrl+d"),
                   self.dialog.activeList,
                   context=Qt.WidgetShortcut)
     s.activated.connect(self.dialog.activeList.clearSelection)
     s = QShortcut(QKeySequence("ctrl+d"),
                   self.dialog.inactiveList,
                   context=Qt.WidgetShortcut)
     s.activated.connect(self.dialog.inactiveList.clearSelection)
     self.rebuildTagList()
     restoreGeom(self, "tagLimit")
     self.exec_()
示例#10
0
 def onDebug(self):
     d = self.debugDiag = QDialog()
     d.silentlyClose = True
     frm = aqt.forms.debug.Ui_Dialog()
     frm.setupUi(d)
     font = QFontDatabase.systemFont(QFontDatabase.FixedFont)
     font.setPointSize(frm.text.font().pointSize() + 1)
     frm.text.setFont(font)
     frm.log.setFont(font)
     s = self.debugDiagShort = QShortcut(QKeySequence("ctrl+return"), d)
     s.activated.connect(lambda: self.onDebugRet(frm))
     s = self.debugDiagShort = QShortcut(
         QKeySequence("ctrl+shift+return"), d)
     s.activated.connect(lambda: self.onDebugPrint(frm))
     s = self.debugDiagShort = QShortcut(QKeySequence("ctrl+l"), d)
     s.activated.connect(frm.log.clear)
     s = self.debugDiagShort = QShortcut(QKeySequence("ctrl+shift+l"), d)
     s.activated.connect(frm.text.clear)
     d.show()
示例#11
0
    def __init__(self, parent, bodyhtml, jsSavecommand, wintitle, dialogname):
        super(ExtraWysiwygEditorForField, self).__init__(parent)

        self.jsSavecommand = jsSavecommand
        self.parent = parent
        self.setWindowTitle(wintitle)
        self.resize(810, 700)
        restoreGeom(self, "805891399_winsize")

        mainLayout = QVBoxLayout()
        mainLayout.setContentsMargins(0, 0, 0, 0)
        mainLayout.setSpacing(0)
        self.setLayout(mainLayout)
        self.web = MyWebView(self)  # maybe also self.parent?
        self.web.allowDrops = True  # default in webview/AnkiWebView is False
        self.web.title = dialogname
        self.web.contextMenuEvent = self.contextMenuEvent
        mainLayout.addWidget(self.web)

        self.buttonBox = QDialogButtonBox(self)
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel
                                          | QDialogButtonBox.Save)
        mainLayout.addWidget(self.buttonBox)

        self.buttonBox.accepted.connect(self.onAccept)
        self.buttonBox.rejected.connect(self.onReject)
        QMetaObject.connectSlotsByName(self)
        acceptShortcut = QShortcut(QKeySequence("Ctrl+Return"), self)
        acceptShortcut.activated.connect(self.onAccept)

        zoomIn_Shortcut = QShortcut(QKeySequence("Ctrl++"), self)
        zoomIn_Shortcut.activated.connect(self.web.zoom_in)

        zoomOut_Shortcut = QShortcut(QKeySequence("Ctrl+-"), self)
        zoomOut_Shortcut.activated.connect(self.web.zoom_out)

        self.web.stdHtml(body=bodyhtml,
                         css=cssfiles,
                         js=addon_jsfiles + other_jsfiles,
                         head="",
                         context=self)
示例#12
0
文件: editor.py 项目: solarmist/anki
 def addButton(self, icon, cmd, func, tip="", label="", 
               id=None, toggleable=False, keys=None, disables=True):
     """Assign func to bridge cmd, register shortcut, return button"""
     if cmd not in self._links:
         self._links[cmd] = func
     if keys:
         QShortcut(QKeySequence(keys), self.widget,
                   activated = lambda s=self: func(s))
     btn = self._addButton(icon, cmd, tip=tip, label=label,
                           id=id, toggleable=toggleable, disables=disables)
     return btn
示例#13
0
def mySetupShortcuts(self):
    cuts = [
        (gc('hotkey_codemirror'), self.mirror_start),
    ]
    for row in cuts:
        if len(row) == 2:
            keys, fn = row
            fn = self._addFocusCheck(fn)
        else:
            keys, fn, _ = row
        QShortcut(QKeySequence(keys), self.widget, activated=fn)
示例#14
0
def setupBrowserShortcuts(self):
    # self is browser
    cut = gc("shortcut: open window")
    if cut:
        cm = QShortcut(QKeySequence(cut), self)
        qconnect(cm.activated, lambda b=self: open_multiline_searchwindow(b))
    view = getMenu(self, "&View")
    action = QAction(self)
    action.setText("Show search string in multi-line dialog")
    view.addAction(action)
    action.triggered.connect(lambda _, b=self: open_multiline_searchwindow(b))
示例#15
0
 def setupSystemSpecific(self):
     self.hideMenuAccels = False
     if isMac:
         # mac users expect a minimize option
         self.minimizeShortcut = QShortcut("Ctrl+M", self)
         self.minimizeShortcut.activated.connect(self.onMacMinimize)
         self.hideMenuAccels = True
         self.maybeHideAccelerators()
         self.hideStatusTips()
     elif isWin:
         # make sure ctypes is bundled
         from ctypes import windll, wintypes
         _dummy = windll
         _dummy = wintypes
示例#16
0
    def add_preview_button(self, editor):
        QShortcut(QKeySequence("Ctrl+Shift+P"), self, self.show_preview)

        if anki_version < (2, 1, 50):
            editor._links = editor._links.copy()
            editor.web.eval("""
                $editorToolbar.then(({notetypeButtons}) => 
                    notetypeButtons.appendButton(
                        {component: editorToolbar.PreviewButton, id: 'preview'}
                    )
                );
            """)

        editor._links["preview"] = lambda _editor: self.show_preview() and None
示例#17
0
 def setupModels(self):
     if self.label:
         self.modelLabel = QLabel(_("Type"))
         self.addWidget(self.modelLabel)
     # models box
     self.models = QPushButton()
     #self.models.setStyleSheet("* { text-align: left; }")
     self.models.setToolTip(shortcut(_("Change Note Type (Ctrl+N)")))
     s = QShortcut(QKeySequence(_("Ctrl+N")),
                   self.widget,
                   activated=self.onModelChange)
     self.models.setAutoDefault(False)
     self.addWidget(self.models)
     self.models.clicked.connect(self.onModelChange)
     # layout
     sizePolicy = QSizePolicy(QSizePolicy.Policy(7), QSizePolicy.Policy(0))
     self.models.setSizePolicy(sizePolicy)
     self.updateModels()
示例#18
0
def setupButtons(righttopbtns, editor):
    cut = getUserOption("shortcut_editor_menu_show")
    tip = "Clean HTML"
    if cut:
        tip += "(%s)".format(cut)
    righttopbtns.append(
        editor.addButton(
            icon="",
            cmd="clean_html",
            func=lambda e=editor: clean_html_menu(e),
            label="cH",
            tip=tip,
            keys=cut,
        ))
    for cut, text, func in template:
        cut = getUserOption(cut)
        if not cut:
            continue
        t = QShortcut(QKeySequence(cut), editor.parentWindow)
        t.activated.connect(lambda e=editor, f=func: f(e))
示例#19
0
 def showProfileManager(self):
     self.pm.profile = None
     self.state = "profileManager"
     d = self.profileDiag = self.ProfileManager()
     f = self.profileForm = aqt.forms.profiles.Ui_MainWindow()
     f.setupUi(d)
     f.login.clicked.connect(self.onOpenProfile)
     f.profiles.itemDoubleClicked.connect(self.onOpenProfile)
     f.openBackup.clicked.connect(self.onOpenBackup)
     f.quit.clicked.connect(d.close)
     d.onClose.connect(self.cleanupAndExit)
     f.add.clicked.connect(self.onAddProfile)
     f.rename.clicked.connect(self.onRenameProfile)
     f.delete_2.clicked.connect(self.onRemProfile)
     f.profiles.currentRowChanged.connect(self.onProfileRowChange)
     f.statusbar.setVisible(False)
     # enter key opens profile
     QShortcut(QKeySequence("Return"), d, activated=self.onOpenProfile)
     self.refreshProfilesList()
     # raise first, for osx testing
     d.show()
     d.activateWindow()
     d.raise_()
示例#20
0
 def __init__(self, parent, content, mode, win_title):
     super(CmDialogBase, self).__init__(parent)
     self.parent = parent
     self.js_save_cmd = "editor.getValue()"
     self.setWindowTitle(win_title)
     self.dialog = edit_window.Ui_Dialog()
     self.dialog.setupUi(self)
     self.dialog.outer.setContentsMargins(0, 0, 0, 0)
     self.dialog.outer.setSpacing(0)
     self.web = MyWebView(self.parent)
     self.dialog.outer.addWidget(self.web)
     qsp = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
     qsp.setVerticalStretch(2)
     self.web.setSizePolicy(qsp)
     acceptShortcut = QShortcut(QKeySequence("Ctrl+Return"), self)
     acceptShortcut.activated.connect(self.accept)
     self.web.title = "html source with codemirror"
     self.web.contextMenuEvent = self.contextMenuEvent
     tmpl_content = readfile("codemirror.html")
     # the following seems to break cm so I just remove it <!--StartFragment--><!--EndFragment-->
     self.content = content.replace("<!--StartFragment-->",
                                    "").replace("<!--EndFragment-->", "")
     bodyhtml = tmpl_content.format(
         autoformat_function="html_beautify"
         if mode == "htmlmixed" else "css_beautify",
         content="",
         isvim=keymap[1],
         keymap=keymap[0],
         mode=mode,
         theme=selectedtheme,
         unique_string=unique_string,
         lint="true",
     )
     self.web.stdHtml(bodyhtml, cssfiles, jsfiles)
     restoreGeom(self, "1043915942_CmDialog")
     self.web.loadFinished.connect(self.load_finished)
示例#21
0
文件: clayout.py 项目: solarmist/anki
 def setupShortcuts(self):
     for i in range(1,9):
         QShortcut(QKeySequence("Ctrl+%d" % i), self, activated=lambda i=i: self.selectCard(i))
示例#22
0
def setup_shortcut(shortcut_string: str, func):
    shortcut = QShortcut(QKeySequence(shortcut_string), mw)
    shortcut.activated.connect(func)

    mw.searchBar.add_shortcut(shortcut)
示例#23
0
文件: utils.py 项目: solarmist/anki
def addCloseShortcut(widg):
    if not isMac:
        return
    widg._closeShortcut = QShortcut(QKeySequence("Ctrl+W"), widg)
    widg._closeShortcut.activated.connect(widg.reject)
示例#24
0
    def mysetupButtons(self):
        self.addButton.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.addButton.customContextMenuRequested.connect(
            self.on_add_context_menu)

        self.contextmenu = QtGui.QMenu(self)

        a = self.contextmenu.addAction('clear counter')
        a.connect(a, QtCore.SIGNAL("triggered()"), self.clearcounter)

        a = self.contextmenu.addAction('add+reschedule - counter %d ' %
                                       self.counter)
        a.connect(
            a,
            QtCore.SIGNAL("triggered()"),
            lambda s=self: self.add_and_reschedule_with_counter(self.counter))

        self.contextmenu.addSeparator()

        a = self.contextmenu.addAction('add+reschedule - tomorrow')
        a.connect(a,
                  QtCore.SIGNAL("triggered()"),
                  lambda s=self: self.add_and_reschedule(1, 1))

        a = self.contextmenu.addAction('add+reschedule - 2 days')
        a.connect(a,
                  QtCore.SIGNAL("triggered()"),
                  lambda s=self: self.add_and_reschedule(2, 2))

        a = self.contextmenu.addAction('add+reschedule - 3 days')
        a.connect(a,
                  QtCore.SIGNAL("triggered()"),
                  lambda s=self: self.add_and_reschedule(3, 3))

        a = self.contextmenu.addAction('add+reschedule - 5 days')
        a.setShortcut(
            QKeySequence("Alt+Shift+Return"))  #just to add it to the gui
        a.connect(a,
                  QtCore.SIGNAL("triggered()"),
                  lambda s=self: self.add_and_reschedule(5, 5))
        #workaround
        a = QShortcut(QKeySequence("Alt+Shift+Return"), self)
        a.activated.connect(lambda s=self: self.add_and_reschedule(5, 5))

        self.contextmenu.addSeparator()

        a = self.contextmenu.addAction('add+reschedule - 7 days')
        a.connect(a,
                  QtCore.SIGNAL("triggered()"),
                  lambda s=self: self.add_and_reschedule(7, 7))

        self.contextmenu.addSeparator()

        a = self.contextmenu.addAction('add+reschedule - 1 months')
        a.connect(a,
                  QtCore.SIGNAL("triggered()"),
                  lambda s=self: self.add_and_reschedule(28, 32))

        a = self.contextmenu.addAction('add+reschedule - 1 year')
        a.connect(a,
                  QtCore.SIGNAL("triggered()"),
                  lambda s=self: self.add_and_reschedule(335, 395))

        self.contextmenu.addSeparator()

        #a = self.contextmenu.addAction('add as first new card')
        #a.connect(a, QtCore.SIGNAL("triggered()"), self.add_as_first_new)

        a = self.contextmenu.addAction('add+reschedule - ask ')
        a.setShortcut(QKeySequence("Ctrl+Return"))  #just to add it to the gui
        a.connect(a, QtCore.SIGNAL("triggered()"), self.ask_to_reschedule)
        a = QShortcut(QKeySequence("Alt+Return"), self)
        a.activated.connect(self.ask_to_reschedule)
示例#25
0
 def __init__(self, parent, tags, alltags):
     QDialog.__init__(self, parent,
                      Qt.WindowType.Window)  # super().__init__(parent)
     self.basic_mode = gc("dialog type: basic_but_quick")
     self.parent = parent
     self.alltags = alltags
     self.gridLayout = QGridLayout(self)
     self.gridLayout.setObjectName("gridLayout")
     self.label = QLabel("Edit tags:")
     self.gridLayout.addWidget(self.label, 0, 0, 1, 1)
     self.verticalLayout = QVBoxLayout()
     self.verticalLayout.setObjectName("verticalLayout")
     self.gridLayout.addLayout(self.verticalLayout, 1, 0, 1, 1)
     self.buttonBox = QDialogButtonBox(self)
     self.buttonBox.setOrientation(Qt.Orientation.Horizontal)
     self.buttonBox.setStandardButtons(
         QDialogButtonBox.StandardButton.Cancel
         | QDialogButtonBox.StandardButton.Ok)
     self.shortcut = QShortcut(QKeySequence("Ctrl+Return"), self)
     self.shortcut.activated.connect(self.accept)
     self.helpButton = QPushButton(
         "add empty line", clicked=lambda: self.maybe_add_line(force=True))
     self.buttonBox.addButton(self.helpButton,
                              QDialogButtonBox.ButtonRole.HelpRole)
     self.filterbutton = QPushButton("edit tag for current line",
                                     clicked=self.tagselector)
     self.buttonBox.addButton(self.filterbutton,
                              QDialogButtonBox.ButtonRole.ResetRole)
     self.searchButton = QPushButton(
         "search", clicked=lambda: self.do_browser_search(extra_search=""))
     self.buttonBox.addButton(self.searchButton,
                              QDialogButtonBox.ButtonRole.ResetRole)
     self.gridLayout.addWidget(self.buttonBox, 2, 0, 1, 1)
     self.buttonBox.accepted.connect(self.accept)
     self.buttonBox.rejected.connect(self.reject)
     self.setWindowTitle("Anki - Edit Tags")
     originalheight = self.height()
     restoreGeom(self, "TagDialogExtended")
     self.resize(self.width(), originalheight)
     if not tags:
         tags = [
             "",
         ]
     else:
         tags.append("")
     self.line_list = []
     for t in tags:
         self.maybe_add_line(t)
     self.cut = gc("in tag lines dialog: open filterdialog for single tag")
     if self.cut:
         self.filterbutton.setToolTip('shortcut: {}'.format(self.cut))
         self.selkey = QShortcut(QKeySequence(self.cut), self)
         self.selkey.activated.connect(self.tagselector)
     self.browser_scut = gc("in tag lines dialog: search browser for tag")
     if self.browser_scut:
         self.searchButton.setToolTip('shortcut: {}'.format(
             self.browser_scut))
         self.browser_scut_key = QShortcut(QKeySequence(self.browser_scut),
                                           self)
         self.browser_scut_key.activated.connect(
             lambda: self.do_browser_search(extra_search=""))
     # don't also set Ctrl+t,a/gc("editor: show filterdialog to add single tag") for
     # self.tagselector: What if the user has already set them to the same etc. I'd have
     # to do a lot of checking
     self.addnl = gc("in tag lines dialog: insert additional line")
     if self.addnl:
         self.helpButton.setToolTip('shortcut: {}'.format(self.addnl))
         self.addnlscut = QShortcut(QKeySequence(self.addnl), self)
         self.addnlscut.activated.connect(
             lambda: self.maybe_add_line(force=True))
 def _addButtonInvisible(keys, func, **kwargs):
     QShortcut(  # type: ignore
         QKeySequence(keys),
         editor.widget,
         activated=lambda s=editor: func(s),
     )