コード例 #1
0
ファイル: ui.py プロジェクト: hoeken/chinese-support-addon
def add_action(title, to, funct, checkable=False):
    action = QAction(_(title), mw)
    if checkable:
        action.setCheckable(True)
    mw.connect(action, SIGNAL("triggered()"), funct)
    to.addAction(action)
    return action
コード例 #2
0
ファイル: ImageResizer.py プロジェクト: searene/Anki-Addons
 def setupMenu(self):
     """
     setup menu in anki
     """
     action = QAction("Image Resizer", mw)
     mw.connect(action, SIGNAL("triggered()"), self._settings)
     mw.form.menuTools.addAction(action)
コード例 #3
0
ファイル: ImageResizer.py プロジェクト: Mauville/Dotfiles
 def setupMenu(self):
     """
     setup menu in anki
     """
     action = QAction("Image Resizer", mw)
     mw.connect(action, SIGNAL("triggered()"), self._settings)
     mw.form.menuTools.addAction(action)
コード例 #4
0
ファイル: AnkiEmperor.py プロジェクト: dmyyy/AnkiEmperor
    def __init__(self):

        # Setup
        self.db = DBConnect()
        self.__treasureChest = TreasureChest(self.db)
        self.__options = Options(self.db)
        self.__eventManager = EventManager(self, self.__options,
                                           self.__treasureChest)
        self.__stats = Stats(self.db, self.__eventManager)
        world = World(self.db, self.__options.getOption('activeCountry'))
        self.__buildingAuthority = BuildingAuthority(self, world)
        self.__ranks = Ranks(self.db, self.__eventManager, world)
        self.__ranks.updateRank(
            self.__treasureChest.getTotalGold(),
            self.__buildingAuthority.getActiveCountry().
            getCompletedObjectsPercentage(), True)
        self.__layout = None  # Setup as a property as we must be able to clear it
        self.__view = None  # Keep's track of current view. Useful if we want to update a view, but we're not sure which one
        self.deckSelected = False

        # Setup window
        QDialog.__init__(self, mw, Qt.WindowTitleHint)
        self.setWindowTitle(getPluginName())
        self.resize(300, 800)
        self.command("MainView||main")

        # Wrap Anki methods
        Reviewer._answerCard = wrap(self.answerCard, Reviewer._answerCard)
        _Collection.undo = wrap(_Collection.undo, self.undo)
        DeckManager.select = wrap(DeckManager.select, self.refreshSettings)

        # Add AnkiEmperor to the Anki menu
        action = QAction(getPluginName(), mw)
        mw.connect(action, SIGNAL("triggered()"), self.show)
        mw.form.menuTools.addAction(action)
コード例 #5
0
def create_item(prefix, root, name, fs):
    if name == '--':
        root.addSeparator()
    else:
        action = QAction(name, mw)
        mw.connect(action, SIGNAL("triggered()"), fs[prefix + '_' + to_id(name)])
        root.addAction(action)
コード例 #6
0
 def setupMenu(self):
     """
     setup menu in anki
     """
     action = QAction("GoldenDictMedia", mw)
     mw.connect(action, SIGNAL("triggered()"), self.openSettingsDialog)
     mw.form.menuTools.addAction(action)
コード例 #7
0
ファイル: dialog.py プロジェクト: fenildf/anki-kanjivocab
    def __init__(self):
        QDialog.__init__(self, mw)
        self.setupUi(self)

        # Fill both field combo boxes
        fields = sorted(anki.find.fieldNames(mw.col, downcase=False))
        def fillFieldCombo(combo, default):
            for field in fields:
                combo.addItem(field, field)
                if field == default:
                    combo.setCurrentIndex(combo.count() - 1)

        fillFieldCombo(self.kanjiFieldCombo, self.KANJI_DEFAULT_FIELD)
        fillFieldCombo(self.vocabFieldCombo, self.VOCAB_DEFAULT_FIELD)

        # Cheat and replace tagsLineEdit with a TagEdit
        self.tagsLineEdit.hide()
        self.tagsLineEdit = aqt.tagedit.TagEdit(self)
        self.tagsLineEdit.setCol(mw.col)
        self.tagsLayout.addWidget(self.tagsLineEdit)
        mw.connect(self.tagsLineEdit, SIGNAL("textChanged(const QString &)"),
                   self.on_tagsLineEdit_textChanged)

        self.helpDialog = KanjiVocabHelp()

        self.setOkEnabled(False)
コード例 #8
0
ファイル: lookup.py プロジェクト: greedychipmunk/ankiplugins
def createMenu():
    ml = QMenu()
    ml.setTitle("Lookup")
    mw.form.menuTools.addAction(ml.menuAction())
    # make it easier for other plugins to add to the menu
    mw.form.menuLookup = ml
    # add actions
    a = QAction(mw)
    a.setText("...expression on alc")
    a.setShortcut("Ctrl+1")
    ml.addAction(a)
    mw.connect(a, SIGNAL("triggered()"), onLookupExpression)
    a = QAction(mw)
    a.setText("...meaning on alc")
    a.setShortcut("Ctrl+2")
    ml.addAction(a)
    mw.connect(a, SIGNAL("triggered()"), onLookupMeaning)
    a = QAction(mw)
    a.setText("...selection on alc")
    a.setShortcut("Ctrl+3")
    ml.addAction(a)
    ml.addSeparator()
    mw.connect(a, SIGNAL("triggered()"), onLookupAlcSelection)
    a = QAction(mw)
    a.setText("...word selection on edict")
    a.setShortcut("Ctrl+4")
    ml.addAction(a)
    mw.connect(a, SIGNAL("triggered()"), onLookupEdictSelection)
    a = QAction(mw)
    a.setText("...kanji selection on edict")
    a.setShortcut("Ctrl+5")
    ml.addAction(a)
    mw.connect(a, SIGNAL("triggered()"), onLookupEdictKanjiSelection)
コード例 #9
0
def createMenu():
    ml = QMenu()
    ml.setTitle("Lookup")
    mw.form.menuTools.addAction(ml.menuAction())
    # make it easier for other plugins to add to the menu
    mw.form.menuLookup = ml
    # add actions
    a = QAction(mw)
    a.setText("...expression on alc")
    a.setShortcut("Ctrl+1")
    ml.addAction(a)
    mw.connect(a, SIGNAL("triggered()"), onLookupExpression)
    a = QAction(mw)
    a.setText("...meaning on alc")
    a.setShortcut("Ctrl+2")
    ml.addAction(a)
    mw.connect(a, SIGNAL("triggered()"), onLookupMeaning)
    a = QAction(mw)
    a.setText("...selection on alc")
    a.setShortcut("Ctrl+3")
    ml.addAction(a)
    ml.addSeparator()
    mw.connect(a, SIGNAL("triggered()"), onLookupAlcSelection)
    a = QAction(mw)
    a.setText("...word selection on edict")
    a.setShortcut("Ctrl+4")
    ml.addAction(a)
    mw.connect(a, SIGNAL("triggered()"), onLookupEdictSelection)
    a = QAction(mw)
    a.setText("...kanji selection on edict")
    a.setShortcut("Ctrl+5")
    ml.addAction(a)
    mw.connect(a, SIGNAL("triggered()"), onLookupEdictKanjiSelection)
コード例 #10
0
def setup_menu():
    u"""
    Add a submenu to a view menu.

    Add a submenu that lists the available extra classes to the view
    menu, creating that menu when neccessary
    """
    if extra_classes_list:
        try:
            mw.addon_view_menu
        except AttributeError:
            mw.addon_view_menu = QMenu(_(u"&View"), mw)
            mw.form.menubar.insertMenu(
                mw.form.menuTools.menuAction(), mw.addon_view_menu)
        mw.extra_class_submenu = QMenu(u"Mode (e&xtra class)", mw)
        mw.addon_view_menu.addMenu(mw.extra_class_submenu)
        action_group = QActionGroup(mw, exclusive=True)
        no_class_action = action_group.addAction(
            QAction('(none/standard)', mw, checkable=True))
        no_class_action.setChecked(True)
        mw.extra_class_submenu.addAction(no_class_action)
        mw.connect(no_class_action, SIGNAL("triggered()"),
                   lambda: set_extra_class(None))
        for ecd in extra_classes_list:
            nn_class_action = action_group.addAction(
                QAction(ecd['display'], mw, checkable=True))
            mw.extra_class_submenu.addAction(nn_class_action)
            mw.connect(nn_class_action, SIGNAL("triggered()"),
                       lambda ec=ecd['class']: set_extra_class(ec))
コード例 #11
0
def init():
    action = QAction("Open audio in Audacity", mw)
    action.setShortcut('Ctrl+Shift+A')
    action.setEnabled(True)

    mw.connect(action, SIGNAL('triggered()'), open_in_audacity)
    mw.form.menuTools.addAction(action)
コード例 #12
0
ファイル: AnkiEmperor.py プロジェクト: from3004/AnkiEmperor
    def __init__(self):

        # Setup
        self.db = DBConnect()
        self.__treasureChest = TreasureChest(self.db)
        self.__options = Options(self.db)
        self.__eventManager = EventManager(self, self.__options, self.__treasureChest)
        self.__stats = Stats(self.db, self.__eventManager)
        world = World(self.db, self.__options.getOption('activeCountry'))
        self.__buildingAuthority = BuildingAuthority(self, world)
        self.__ranks = Ranks(self.db, self.__eventManager, world)
        self.__ranks.updateRank(self.__treasureChest.getTotalGold(), self.__buildingAuthority.getActiveCountry().getCompletedObjectsPercentage(), True)
        self.__layout = None    # Setup as a property as we must be able to clear it
        self.__view = None  # Keep's track of current view. Useful if we want to update a view, but we're not sure which one
        self.deckSelected = False

        # Setup window
        QDialog.__init__(self, mw, Qt.WindowTitleHint)
        self.setWindowTitle(getPluginName())
        self.resize(300, 800)
        self.command("MainView||main")

        # Wrap Anki methods
        Reviewer._answerCard = wrap(self.answerCard, Reviewer._answerCard)
        _Collection.undo = wrap(_Collection.undo, self.undo)
        DeckManager.select = wrap(DeckManager.select, self.refreshSettings)

        # Add AnkiEmperor to the Anki menu
        action = QAction(getPluginName(), mw)
        mw.connect(action, SIGNAL("triggered()"), self.show)
        mw.form.menuTools.addAction(action)
コード例 #13
0
def setup_menu():
    u"""
    Add a submenu to a view menu.

    Add a submenu that lists the available extra classes to the view
    menu, creating that menu when neccessary
    """
    if extra_classes_list:
        try:
            mw.addon_view_menu
        except AttributeError:
            mw.addon_view_menu = QMenu(_(u"&View"), mw)
            mw.form.menubar.insertMenu(
                mw.form.menuTools.menuAction(), mw.addon_view_menu)
        mw.extra_class_submenu = QMenu(u"Mode (e&xtra class)", mw)
        mw.addon_view_menu.addMenu(mw.extra_class_submenu)
        action_group = QActionGroup(mw, exclusive=True)
        no_class_action = action_group.addAction(
            QAction('(none/standard)', mw, checkable=True))
        no_class_action.setChecked(True)
        mw.extra_class_submenu.addAction(no_class_action)
        mw.connect(no_class_action, SIGNAL("triggered()"),
                   lambda: set_extra_class(None))
        for ecd in extra_classes_list:
            nn_class_action = action_group.addAction(
                QAction(ecd['display'], mw, checkable=True))
            mw.extra_class_submenu.addAction(nn_class_action)
            mw.connect(nn_class_action, SIGNAL("triggered()"),
                       lambda ec=ecd['class']: set_extra_class(ec))
コード例 #14
0
ファイル: main.py プロジェクト: franekp/ankidict
    def __init__(self, config):
        mw.ankidict = self
        self.config = config
        self.initialized_dictionary = False
        self.initialized_reviews = False

        from logic.collection import Collection
        from logic.reviewer import Reviewer
        self.col = Collection()
        self.reviewer = Reviewer(aqt.mw.col)

        # place where we want to place our menu action
        basep = mw.form.menuTools.actions()[6]

        mw.form.menuTools.insertSeparator(basep)

        self.dictact = QAction("AnkiDict: Macmillan dictionary", mw)
        self.dictact.setShortcut("Ctrl+D")
        mw.connect(self.dictact, SIGNAL("triggered()"), self.show_dictionary)
        mw.form.menuTools.insertAction(basep, self.dictact)

        self.reviewact = QAction("AnkiDict: Review cards", mw)
        self.reviewact.setShortcut("Ctrl+R")
        mw.connect(self.reviewact, SIGNAL("triggered()"), self.show_reviews)
        mw.form.menuTools.insertAction(basep, self.reviewact)
        self.init_webserver()
        QtCore.QTimer.singleShot(
            100,
            lambda: self.init_reviews()
        )
コード例 #15
0
ファイル: ui.py プロジェクト: gbraad/chinese-support-addon
def add_action(title, to, funct, checkable=False):
    action = QAction(_(title), mw)
    if checkable:
        action.setCheckable(True)
    mw.connect(action, SIGNAL("triggered()"), funct)
    to.addAction(action)
    return action
コード例 #16
0
def setupMenu(mw):
    
    #menuconf = QAction("AwesomeTTS", mw)
    a = QAction( 'JWord Suggester', mw )
    mw.connect(a, SIGNAL("triggered()"), lambda e=mw: onSuggester(e))
    mw.form.menuEdit.addSeparator()
    mw.form.menuTools.addAction( a )
コード例 #17
0
ファイル: grok_main.py プロジェクト: auntieNeo/grok
def init():
    scrapersDir = os.path.abspath(mw.addonManager.addonsFolder() + '/grok/scrapers')
    dialog = GrokDialog(scrapersDir);

    action = QAction(mw)
    action.setText("Grok Scraper")
    mw.form.menuTools.addAction(action)
    mw.connect(action, SIGNAL("triggered()"), dialog.showSettingsDialog)
コード例 #18
0
ファイル: menus.py プロジェクト: custommonkey/mcdsupport
def init():
    mw.form.actionAddMcd = QtGui.QAction('Add MCD Cards', mw)
    mw.form.actionAddMcd.setStatusTip('Add MCD Cards')
    mw.form.actionAddMcd.setEnabled(True)
    mw.form.actionAddMcd.setShortcut('Ctrl+M')
    mw.form.actionAddMcd.setIcon(QtGui.QIcon(':/icons/list-add.png'))
    mw.connect(mw.form.actionAddMcd, QtCore.SIGNAL('triggered()'), menuAddMcds)
    mw.form.menuTools.addSeparator()
    mw.form.menuTools.addAction(mw.form.actionAddMcd)
コード例 #19
0
def chooseAddon():
    global actionRepeat
    modules = {}
    filenames = mw.addonManager.files()
    for filename in filenames:
        modname = filename.replace(".py", "")
        try:
            module = __import__(modname)
        except:
            continue  #skip broken modules
        try:
            tmp = module.addon_reloader_before
        except:
            try:
                tmp = module.addon_reloader_teardown
            except:
                continue  #skip modules that don't have either function
        modules[modname] = module

    chooser = AddonChooser(mw, modules)
    response = chooser.exec_()
    choice = chooser.choice.currentText()
    if response == QDialog.Rejected:
        return
    if actionRepeat is not None:
        mw.form.menuTools.removeAction(actionRepeat)
        actionRepeat = None
    if choice != "":
        newAction = QAction("Reload " + choice, mw)
        newAction.setShortcut(_("Ctrl+R"))

        def reloadTheAddon():
            #take "before" in preference to "teardown", but must have one
            try:
                before = modules[choice].addon_reloader_before
            except:
                before = modules[choice].addon_reloader_teardown
            #take "after" if present, otherwise make it do nothing
            try:
                after = modules[choice].addon_reloader_after
            except:
                after = lambda: None
            #execute the reloading
            before()
            reload(modules[choice])
            after()

        mw.connect(newAction, SIGNAL("triggered()"), reloadTheAddon)
        mw.form.menuTools.addAction(newAction)
        actionRepeat = newAction
        reloadTheAddon()
コード例 #20
0
def createMenu():
    """ Add a hotkey and menu entry """
    if not getattr(mw.form, "menuLookup", None):
        ml = QMenu()
        ml.setTitle("Lookup")
        mw.form.menuTools.addAction(ml.menuAction())

    ml = mw.form.menuLookup
    # add action
    a = QAction(mw)
    a.setText("...pronunciation")
    a.setShortcut("Ctrl+6")
    ml.addAction(a)
    mw.connect(a, SIGNAL("triggered()"), onLookupPronunciation)
コード例 #21
0
    def loadPluginData(self):
        self.add_IRead_model()
        #create the model if it doesn't exist

        #quick keys dialog
        if (self.setHighlightColorMenuItem != None):
            mw.disconnect(self.setHighlightColorMenuItem,
                          SIGNAL("triggered()"),
                          mw.IRead2.showSetHighlightColorDialog)
            self.setHighlightColorMenuItem.setEnabled(False)
            mw.form.menuEdit.removeAction(self.setHighlightColorMenuItem)
            del self.setHighlightColorMenuItem
            mw.highlight.setEnabled(False)
            mw.disconnect(mw.highlight, SIGNAL("activated()"),
                          mw.IRead2.showSetHighlightColorDialog)
        mw.highlight = QShortcut(QKeySequence("Alt+2"), mw)
        mw.connect(mw.highlight, SIGNAL("activated()"),
                   mw.IRead2.showSetHighlightColorDialog)
        self.setHighlightColorMenuItem = QAction(
            "[IRead2]: Set highlight color (Alt+2)", mw)
        mw.connect(self.setHighlightColorMenuItem, SIGNAL("triggered()"),
                   mw.IRead2.showSetHighlightColorDialog)
        mw.form.menuEdit.addAction(self.setHighlightColorMenuItem)

        action = QAction("Incremental Reading Organizer", mw)
        mw.connect(action, SIGNAL("triggered()"),
                   mw.IRead2.callIRSchedulerDialog)
        mw.form.menuTools.addAction(action)

        action = QAction("Incremental Reading Scheduler Options", mw)
        mw.connect(action, SIGNAL("triggered()"),
                   mw.IRead2.callIRSchedulerOptionsDialog)
        mw.form.menuTools.addAction(action)

        #self.db = mw.col.db;
        #_addSchema(self.db);

        # File to persist zoom and scroll data
        self.dataDir = self.mw.pm.profileFolder() + '/collection.media'
        self.dataFilename = self.dataDir + '/_IncrementalReadingExtension.dat'
        if (os.path.isfile(self.dataFilename)):
            f = open(self.dataFilename, "r")
            tmp = f.read()
            if (tmp):
                self.ir2data = pickle.loads(tmp)
                self.zoomAndScroll = self.ir2data['zoomAndScroll']
                self.highlightColor = self.ir2data.get('highlightColor',
                                                       'yellow')
                #default yellow
                self.doHighlightFont = self.ir2data.get(
                    'doHighlightFont', 'false')
                #default false (highlight background)
                self.schedIROptions = self.ir2data.get(
                    'schedIROptions', 'pct,10,true,pct,50,true')
                #default soon: pct,10,true (randomize); later: pct, 50, true (randomize)
                self.parseIROptions(self.schedIROptions)
            f.close()
        #Add a hook to adjust zoom and scroll when the web viewer is reset (ie. when editing is done. Typically only done when 'show question is pressed')
        #Has to be done here because we get errors if apply this hook to reset before everything is setup.
        addHook('reset', self.adjustZoomAndScroll)
コード例 #22
0
ファイル: main.py プロジェクト: wkordalski/ankidict
  def __init__(self, config):
    mw.ankidict = self
    self.config = config
    self.initialized = False

    # place where we want to place our buttons
    basep = mw.form.menuTools.actions()[6]

    mw.form.menuTools.insertSeparator(basep)

    self.dictact = QAction("Macmillan dictionary", mw)
    self.dictact.setShortcut("Ctrl+D")
    mw.connect(self.dictact, SIGNAL("triggered()"), self.show_dictionary)
    mw.form.menuTools.insertAction(basep, self.dictact)
コード例 #23
0
def createMenu():
    """ Add a hotkey and menu entry """
    if not getattr(mw.form, "menuLookup", None):
        ml = QMenu()
        ml.setTitle("Lookup")
        mw.form.menuTools.addAction(ml.menuAction())

    ml = mw.form.menuLookup
    # add action
    a = QAction(mw)
    a.setText("...pronunciation")
    a.setShortcut("Ctrl+6")
    ml.addAction(a)
    mw.connect(a, SIGNAL("triggered()"), onLookupPronunciation)
コード例 #24
0
ファイル: passfail.py プロジェクト: jyore/anki-addon-suite
    def __init__(self, mw, menu):
        sumbenu = menu.addMenu("PassFail")

        self.config_action = QAction("Configure", mw)
        mw.connect(self.config_action, SIGNAL("triggered()"), self.config)
        sumbenu.addAction(self.config_action)

        self.options = config
        self.options.load()

        Reviewer._showAnswerButton = wrap(Reviewer._showAnswerButton,
                                          self.show_answer_button, 'after')
        Reviewer._answerButtons = wrap(Reviewer._answerButtons,
                                       self.answer_buttons, 'after')
        Reviewer._answerCard = pass_fail_answer_card
コード例 #25
0
ファイル: superstyler.py プロジェクト: ospalh/SuperStyler
 def show_dialog(self):
     if self.has_instance:
         return
     self.has_instance = True
     
     d = QDialog(mw)
     self.diag = d
     self.frm = maindialog.Ui_Dialog()
     self.frm.setupUi(d)
     self.frm.webView.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
     self.frm.webView.setHtml(ub.get_body())
     self.frm.webView.setStyleSheet(ub.get_stylesheet())
     mw.connect(self.frm.webView, SIGNAL("linkClicked(QUrl)"), self._link_clicked)
     mw.connect(d, SIGNAL("rejected()"), self._on_close)
     d.show()
コード例 #26
0
    def setQuickKey(self, keyModel):
        keyCombo = ''
        if (keyModel['ctrl'] == 1): keyCombo += "Ctrl+"
        if (keyModel['shift'] == 1): keyCombo += "Shift+"
        if (keyModel['alt'] == 1): keyCombo += "Alt+"
        keyCombo += keyModel['keyName']

        existingKeyModel = self.quickKeys.get(keyCombo, None)
        if (existingKeyModel != None):
            self.quickKeys.pop(keyCombo, None)
            if (existingKeyModel.get('transient', None) != None):
                shortcut = existingKeyModel['transient'].get('shortcut')
                mw.disconnect(shortcut, SIGNAL("activated()"),
                              existingKeyModel['transient'].get('callable'))
                shortcut.setEnabled(False)
                del shortcut
                menuItem = existingKeyModel['transient'].get('menuItem')
                mw.disconnect(menuItem, SIGNAL("activated()"),
                              existingKeyModel['transient'].get('callable'))
                menuItem.setEnabled(False)
                mw.form.menuEdit.removeAction(menuItem)
                del menuItem
        if (keyModel['enabled'] == 1):
            shortcut = QShortcut(QKeySequence(keyCombo), mw)
            callMe = lambda: self.quickAddCards(keyModel)
            mw.connect(shortcut, SIGNAL("activated()"), callMe)
            #add menu item showing defined shortcut
            menuText = "[Add Cards] " + keyModel[
                'modelName'] + " -> " + keyModel[
                    'deckName'] + " (" + keyCombo + ")"
            hColor = keyModel.get('color', None)
            if (hColor != None and len(hColor) > 0):
                menuText += " [" + hColor + "]"
            else:
                keyModel['color'] = None
            menuItem = QAction(menuText, mw)
            mw.connect(menuItem, SIGNAL("triggered()"), callMe)
            mw.form.menuEdit.addAction(menuItem)
            keyModel['transient'] = {
                'shortcut': shortcut,
                'callable': callMe,
                'menuItem': menuItem
            }
            self.quickKeys[keyCombo] = keyModel
            self.savePluginData()
コード例 #27
0
ファイル: menus.py プロジェクト: JDHankle/mcdsupport
def init():
    mw.form.menuTools.addSeparator()
    # add the menu option for the main dialog
    mw.form.actionAddMcd = QtGui.QAction('Add MCD Cards', mw)
    mw.form.actionAddMcd.setStatusTip('Add MCD Cards')
    mw.form.actionAddMcd.setEnabled(True)
    mw.form.actionAddMcd.setShortcut('Ctrl+M')
    mw.form.actionAddMcd.setIcon(QtGui.QIcon(':/icons/list-add.png'))
    mw.connect(mw.form.actionAddMcd, QtCore.SIGNAL('triggered()'), menuAddMcds)
    mw.form.menuTools.addAction(mw.form.actionAddMcd)
    # add the menu option to randomize the deck
    mw.form.actionAddMcd = QtGui.QAction('Randomize Deck', mw)
    mw.form.actionAddMcd.setStatusTip('Randomize Deck')
    mw.form.actionAddMcd.setEnabled(True)
    mw.form.actionAddMcd.setShortcut('Ctrl+R')
    mw.form.actionAddMcd.setIcon(QtGui.QIcon(':/icons/package_games_card.png'))
    mw.connect(mw.form.actionAddMcd, QtCore.SIGNAL('triggered()'), menuRandomizeDeck)
    mw.form.menuTools.addAction(mw.form.actionAddMcd)
コード例 #28
0
def resetMusicTimer():
    "Boosts volume back up and starts the music timer."
    #CHANGEME: The next lines are a python dictionary associating deck names with times (in milliseconds) between volume-decrements.
    #Eg, when using the deck "brainscience", volume will decrement every 5 seconds. When using a deck without a listed name, "other" is used.
    #Change this according to your decks. Decks with shorter, easier cards need less time.
    deckMusicTimes = {
                 "brainscience"  :   5000,
                 "rocketsurgery" :   3000,
                 "other"         :   2000,
                 }
    if mw.col.decks.current()['name'] in deckMusicTimes:
        mw.musicTimeToDecrement = deckMusicTimes[mw.col.decks.current()['name']]
    else:
        mw.musicTimeToDecrement = deckMusicTimes["other"]
    boostMusicVolume()
    mw.musicTimer = QTimer(mw)
    mw.musicTimer.setSingleShot(True)
    mw.musicTimer.start(mw.musicTimeToDecrement)
    mw.connect(mw.musicTimer, SIGNAL("timeout()"), decrementMusicVolume)
コード例 #29
0
    def __init__(self, field_updater, addon_name, model_name_substring=None,
            on_focus_lost=False):
        """Initialises the addon.

        Adds a hook to 'editFocusLost' and adds a (re)generate all button to
        the Tools menu.

        Args:
            field_updater (FieldUpdater): a strategy for updating fields.
            addon_name (str): the name of the addon.
            model_name_substring (str): if not None, only models that have
                this string in their name will be modifi
                on_focus_lost (bool): if True, add a hook to editFocusLost.

        """
        global button_action, menu_action

        if not self.__class__._initialised:
            self.__class__._initialised = True
            # set up menu action
            menu_action = NamedCallbackCollector()
            action = QAction("All field updater addons: regenerate all fields", 
                             mw)
            mw.connect(action, SIGNAL("triggered()"), menu_action)
            mw.form.menuTools.addAction(action)

        # state 
        self._field_updater = field_updater
        self._model_name_substring = model_name_substring
        self.name = addon_name

        # add hook
        button_action.register_callback(self.buttonCallback, addon_name)
        if on_focus_lost:
            addHook('editFocusLost', self.onFocusLost)

        # add menu item
        menu_action.register_callback(self.regenerateAll, addon_name)
        menu_item = "{} addon: regenerate all fields".format(addon_name)
        action = QAction(menu_item, mw)
        mw.connect(action, SIGNAL("triggered()"), self.regenerateAll)
        mw.form.menuTools.addAction(action)
コード例 #30
0
def resetMusicTimer():
    "Boosts volume back up and starts the music timer."
    #CHANGEME: The next lines are a python dictionary associating deck names with times (in milliseconds) between volume-decrements.
    #Eg, when using the deck "brainscience", volume will decrement every 5 seconds. When using a deck without a listed name, "other" is used.
    #Change this according to your decks. Decks with shorter, easier cards need less time.
    deckMusicTimes = {
        "brainscience": 5000,
        "rocketsurgery": 3000,
        "other": 2000,
    }
    if mw.col.decks.current()['name'] in deckMusicTimes:
        mw.musicTimeToDecrement = deckMusicTimes[mw.col.decks.current()
                                                 ['name']]
    else:
        mw.musicTimeToDecrement = deckMusicTimes["other"]
    boostMusicVolume()
    mw.musicTimer = QTimer(mw)
    mw.musicTimer.setSingleShot(True)
    mw.musicTimer.start(mw.musicTimeToDecrement)
    mw.connect(mw.musicTimer, SIGNAL("timeout()"), decrementMusicVolume)
コード例 #31
0
ファイル: lilypond.py プロジェクト: frostschutz/Anki-LilyPond
def lilypondMenu():
    '''Extend the addon menu with lilypond template entries.'''
    lm = None

    for action in mw.form.menuPlugins.actions():
        menu = action.menu()
        if menu and menu.title() == "lilypond":
            lm = menu
            break

    if not lm:
        return

    a = QAction(_("Add template..."), mw)
    mw.connect(a, SIGNAL("triggered()"), addtemplate)
    lm.addAction(a)

    for file in templatefiles():
        m = lm.addMenu(os.path.splitext(file)[0])

        a = QAction(_("Edit..."), mw)
        p = os.path.join(lilypondDir, file)
        mw.connect(a, SIGNAL("triggered()"),
                   lambda p=p: mw.addonManager.onEdit(p))
        m.addAction(a)
        a = QAction(_("Delete..."), mw)
        mw.connect(a, SIGNAL("triggered()"),
                   lambda p=p: mw.addonManager.onRem(p))
        m.addAction(a)
コード例 #32
0
def lilypondMenu():
    '''Extend the addon menu with lilypond template entries.'''
    lm = None

    for action in mw.form.menuPlugins.actions():
        menu = action.menu()
        if menu and menu.title() == "lilypond":
            lm = menu
            break

    if not lm:
        return

    a = QAction(_("Add template..."), mw)
    mw.connect(a, SIGNAL("triggered()"), addtemplate)
    lm.addAction(a)

    for file in templatefiles():
        m = lm.addMenu(os.path.splitext(file)[0])

        a = QAction(_("Edit..."), mw)
        p = os.path.join(lilypondDir, file)
        mw.connect(a,
                   SIGNAL("triggered()"),
                   lambda p=p: mw.addonManager.onEdit(p))
        m.addAction(a)
        a = QAction(_("Delete..."), mw)
        mw.connect(a,
                   SIGNAL("triggered()"),
                   lambda p=p: mw.addonManager.onRem(p))
        m.addAction(a)
コード例 #33
0
    def __init__(self, mw, menu):
        submenu = menu.addMenu("Ease Assistant")

        self.config_action = QAction("Configure", mw)
        mw.connect(self.config_action, SIGNAL("triggered()"), self.config)
        submenu.addAction(self.config_action)

        self.reset_action = QAction("Reset Ease Factor", mw)
        mw.connect(self.reset_action, SIGNAL("triggered()"), self.reset_ease)
        submenu.addAction(self.reset_action)

        self.options = cfg.Config(path, defaults)
        self.options.load()

        self.originals = {
            "rescheduleLapse": Scheduler._rescheduleLapse,
            "rescheduleRev": Scheduler._rescheduleRev,
            "nextRevIvl": Scheduler._nextRevIvl,
            "nextLapseIvl": Scheduler._nextLapseIvl,
            "dynIvlBoost": Scheduler._dynIvlBoost,
            "reschedCards": Scheduler.reschedCards,
            "forgetCards": Scheduler.forgetCards
        }
コード例 #34
0
def setup_menu():
    u"""
    Add a submenu to the edit menu.

    Add a submenu that lists the available extra classes to the edit
    menu.
    """
    if extra_classes_list:
        mw.extra_class_submenu = QMenu(u"Mode (e&xtra class)", mw)
        mw.form.menuEdit.addSeparator()
        mw.form.menuEdit.addMenu(mw.extra_class_submenu)
        action_group = QActionGroup(mw, exclusive=True)
        no_class_action = action_group.addAction(
            QAction('(none/standard)', mw, checkable=True))
        no_class_action.setChecked(True)
        mw.extra_class_submenu.addAction(no_class_action)
        mw.connect(no_class_action, SIGNAL("triggered()"),
                   lambda: set_extra_class(None))
        for ecd in extra_classes_list:
            nn_class_action = action_group.addAction(
                QAction(ecd['display'], mw, checkable=True))
            mw.extra_class_submenu.addAction(nn_class_action)
            mw.connect(nn_class_action, SIGNAL("triggered()"),
                       lambda ec=ecd['class']: set_extra_class(ec))
コード例 #35
0
def ts_setup_menu():
    """
    Initialize menu. If there is an entity "View" in top level menu
    (shared with other plugins, like "Zoom" of R. Sieker) options of
    Night Mode will be putted there. In other case it creates that menu.
    """
    global ts_menu_switch

    try:
        mw.addon_view_menu
    except AttributeError:
        mw.addon_view_menu = QMenu(_(u"&View"), mw)
        mw.form.menubar.insertMenu(mw.form.menuTools.menuAction(),
                                   mw.addon_view_menu)

    mw.ts_menu = QMenu(_('&Touchscreen'), mw)

    mw.addon_view_menu.addMenu(mw.ts_menu)

    ts_menu_switch = QAction(_('&Enable touchscreen mode'), mw, checkable=True)
    ts_menu_color = QAction(_('Set &pen color'), mw)
    ts_menu_width = QAction(_('Set &pen width'), mw)
    ts_menu_about = QAction(_('&About...'), mw)

    ts_toggle_seq = QKeySequence("Ctrl+r")
    ts_menu_switch.setShortcut(ts_toggle_seq)

    mw.ts_menu.addAction(ts_menu_switch)
    mw.ts_menu.addAction(ts_menu_color)
    mw.ts_menu.addAction(ts_menu_width)
    mw.ts_menu.addSeparator()
    mw.ts_menu.addAction(ts_menu_about)

    s = SIGNAL("triggered()")
    mw.connect(ts_menu_switch, s, ts_switch)
    mw.connect(ts_menu_color, s, ts_change_color)
    mw.connect(ts_menu_width, s, ts_change_width)
    mw.connect(ts_menu_about, s, ts_about)
コード例 #36
0
ファイル: main.py プロジェクト: wkordalski/ankidict
  def __init__(self, config):
    self.hideact = QAction("Hide window", mw)
    self.hideact.setShortcut("Ctrl+M")
    mw.connect(self.hideact, SIGNAL("triggered()"), self.minimize)
    mw.form.menuTools.insertAction(basep, self.hideact)

    if config.enable_debug_menu:
      self.dbgact = QAction("Debug", mw)
      mw.connect(self.dbgact, SIGNAL("triggered()"), self.debugger)
      mw.form.menuTools.insertAction(basep, self.dbgact)

    if config.enable_global_shortcut:
      import pyqxtgs as gs
      self.globact = gs.PyGlobalShortcutHandler()
      mw.connect(self.globact, SIGNAL('onGlobalShortcut()'), self.global_call)
      self.globact.setShortcut(self.config.shortcut)
      self.globact.enable()
コード例 #37
0
def abcMenu():
    '''Create "abc" menu and extend it with ABC template entries'''
    lm = mw.form.menuTools.addMenu(QIcon(os.path.join(abcDir,"abc.png")),"abc")

    a = QAction(_("Add template..."), mw)
    mw.connect(a, SIGNAL("triggered()"), addtemplate)
    lm.addAction(a)

    for file in templatefiles():
        m = lm.addMenu(os.path.splitext(file)[0])

        a = QAction(_("Edit..."), mw)
        p = os.path.join(abcDir, file)
        mw.connect(a, SIGNAL("triggered()"),
                   lambda p=p: mw.addonManager.onEdit(p))
        m.addAction(a)
        a = QAction(_("Delete..."), mw)
        mw.connect(a, SIGNAL("triggered()"),
                   lambda p=p: mw.addonManager.onRem(p))
        m.addAction(a)
コード例 #38
0
def createMenu():
    ml = QMenu()
    ml.setTitle("Kanji Extractor")
    mw.form.menuTools.addAction(ml.menuAction())
    mw.form.menuLookup = ml

    a = QAction(mw)
    a.setText("create kanji cards")
    ml.addAction(a)
    mw.connect(a, SIGNAL("triggered()"), createKanjiCards)

    a = QAction(mw)
    a.setText("Settings")
    ml.addAction(a)
    mw.connect(a, SIGNAL("triggered()"), initDialog)

    a = QAction(mw)
    a.setText("Reset")
    ml.addAction(a)
    mw.connect(a, SIGNAL("triggered()"), startReset)
コード例 #39
0
def abcMenu():
    '''Create "abc" menu and extend it with ABC template entries'''
    lm = mw.form.menuTools.addMenu(QIcon(os.path.join(abcDir, "abc.png")),
                                   "abc")

    a = QAction(_("Add template..."), mw)
    mw.connect(a, SIGNAL("triggered()"), addtemplate)
    lm.addAction(a)

    for file in templatefiles():
        m = lm.addMenu(os.path.splitext(file)[0])

        a = QAction(_("Edit..."), mw)
        p = os.path.join(abcDir, file)
        mw.connect(a,
                   SIGNAL("triggered()"),
                   lambda p=p: mw.addonManager.onEdit(p))
        m.addAction(a)
        a = QAction(_("Delete..."), mw)
        mw.connect(a,
                   SIGNAL("triggered()"),
                   lambda p=p: mw.addonManager.onRem(p))
        m.addAction(a)
コード例 #40
0
ファイル: zoom.py プロジェクト: AleksueiR/anki-addons
def setup_menu():
    u"""Set up the zoom menu."""
    try:
        mw.addon_view_menu
    except AttributeError:
        mw.addon_view_menu = QMenu(_(u"&View"), mw)
        mw.form.menubar.insertMenu(
            mw.form.menuTools.menuAction(), mw.addon_view_menu)
    mw.zoom_submenu = QMenu(_(u"&Zoom"), mw)
    mw.addon_view_menu.addMenu(mw.zoom_submenu)
    zoom_in_action = QAction(_('Zoom &In'), mw)
    zoom_in_action.setShortcut(QKeySequence("Ctrl++"))
    mw.zoom_submenu.addAction(zoom_in_action)
    mw.connect(zoom_in_action, SIGNAL("triggered()"), zoom_in)
    zoom_out_action = QAction(_('Zoom &Out'), mw)
    zoom_out_action.setShortcut(QKeySequence("Ctrl+-"))
    mw.zoom_submenu.addAction(zoom_out_action)
    mw.connect(zoom_out_action, SIGNAL("triggered()"), zoom_out)
    mw.zoom_submenu.addSeparator()
    reset_zoom_action = QAction(_('&Reset'), mw)
    reset_zoom_action.setShortcut(QKeySequence("Ctrl+0"))
    mw.zoom_submenu.addAction(reset_zoom_action)
    mw.connect(reset_zoom_action, SIGNAL("triggered()"), reset_zoom)
コード例 #41
0
ファイル: zoom.py プロジェクト: ekimoff/anki-download-audio
def setup_menu():
    u"""Set up the zoom menu."""
    try:
        mw.addon_view_menu
    except AttributeError:
        mw.addon_view_menu = QMenu(_(u"&View"), mw)
        mw.form.menubar.insertMenu(mw.form.menuTools.menuAction(),
                                   mw.addon_view_menu)
    mw.zoom_submenu = QMenu(_(u"&Zoom"), mw)
    mw.addon_view_menu.addMenu(mw.zoom_submenu)
    zoom_in_action = QAction(_('Zoom &In'), mw)
    zoom_in_action.setShortcut(QKeySequence("Ctrl++"))
    mw.zoom_submenu.addAction(zoom_in_action)
    mw.connect(zoom_in_action, SIGNAL("triggered()"), zoom_in)
    zoom_out_action = QAction(_('Zoom &Out'), mw)
    zoom_out_action.setShortcut(QKeySequence("Ctrl+-"))
    mw.zoom_submenu.addAction(zoom_out_action)
    mw.connect(zoom_out_action, SIGNAL("triggered()"), zoom_out)
    mw.zoom_submenu.addSeparator()
    reset_zoom_action = QAction(_('&Reset'), mw)
    reset_zoom_action.setShortcut(QKeySequence("Ctrl+0"))
    mw.zoom_submenu.addAction(reset_zoom_action)
    mw.connect(reset_zoom_action, SIGNAL("triggered()"), reset_zoom)
コード例 #42
0
ファイル: wanikani.py プロジェクト: nigelkerr/wanikani2anki
    if button:
        button.setChecked(True)
    button = d.findChild(QRadioButton,wkconf['card_direction'])
    if button:
        button.setChecked(True)

    button = d.findChild(QCheckBox,'includeTangorinLink')
    button.setChecked(wkconf.get('include_tangorin_link', False))

    button = d.findChild(QPushButton,'updateWaniKaniDecks')
    button.clicked.connect(updateWaniKaniDeck)

    d.setWindowModality(Qt.WindowModal)

    if d.exec_():
        wkconf['key'] = form.key.text()
        wkconf['deck_separation'] = form.deckSeparation.checkedButton().objectName()
        wkconf['card_direction'] = form.cardDirection.checkedButton().objectName()
        wkconf['include_tangorin_link'] = form.includeTangorinLink.isChecked()
        writeConf();

    mw.app.processEvents()
    mw.reset()
    mw.deckBrowser.show()

readConf()

confaction = QAction("WaniKani 2 Anki", mw)
mw.connect(confaction, SIGNAL("triggered()"), showConfDialog)
mw.form.menuTools.addAction(confaction)
コード例 #43
0

# Add a colorized kanji to a Diagram whenever leaving a Kanji field

def onFocusLost(flag, note, currentFieldIndex):
    return addKanji(note, flag, currentFieldIndex)

addHook('editFocusLost', onFocusLost)


# menu item to regenerate all

def regenerate_all():
    # Find the models that have the right name and fields; faster than
    # checking every note
    if not askUser("Do you want to regenerate all kanji diagrams? "
                   'This may take some time and will overwrite the '
                   'destination Diagram fields.'):
        return
    models = [m for m in mw.col.models.all() if modelIsCorrectType(m)]
    # Find the notes in those models and give them kanji
    for model in models:
        for nid in mw.col.models.nids(model):
            addKanji(mw.col.getNote(nid))
    showInfo("Done regenerating colorized kanji diagrams!")

# add menu item
do_regenerate_all = QAction("Kanji Colorizer: (re)generate all", mw)
mw.connect(do_regenerate_all, SIGNAL("triggered()"), regenerate_all)
mw.form.menuTools.addAction(do_regenerate_all)
コード例 #44
0
    else:

        n = datetime.date.today()
        d = datetime.date.fromtimestamp(
            time.mktime(time.strptime(d, '%Y-%m-%d')))

        return max(0, (d - n).days)


## COMPUTES WHEN THE CARD WAS SEEN LAST
def seenLast(seen):

    s = seen.encode('utf-8')

    if s == '0000-00-00 00:00:00':

        return 0

    else:
        n = datetime.date.today()
        s = datetime.date.fromtimestamp(
            time.mktime(time.strptime(s, '%Y-%m-%d %H:%M:%S')))

        return max(0, (n - s).days)


## MENU ENTRY ##
action = QAction('Import RevTK progress...', mw)
mw.connect(action, SIGNAL('triggered()'), run)
mw.form.menuTools.addAction(action)
コード例 #45
0
        note[dst_field] = kanji_svg_kyoukasho(src_txt)
    try:
        if not note[rest_field]:
            note[rest_field] = kanji_svg_rest(src_txt)
    except KeyError:
        pass
    note.flush()
    return True


# menu item to copy all


def copy_all():
    # Find the models that have the right name and fields; faster than
    # checking every note
    if not askUser("Fill with kanji diagrams references?"):
        return
    models = [m for m in mw.col.models.all() if model_is_correct_type(m)]
    # Find the notes in those models and give them kanji
    for model in models:
        for nid in mw.col.models.nids(model):
            add_kanji(mw.col.getNote(nid))
    tooltip("Done copying colorized kanji diagrams!")


# add menu item
do_copy_all = QAction("Copy diagrams", mw)
mw.connect(do_copy_all, SIGNAL("triggered()"), copy_all)
mw.form.menuTools.addAction(do_copy_all)
コード例 #46
0

def fetchData(col, model, tag):
    # Get all the notes with specified criteria
    if tag != '':
        nid = col.db.list("SELECT id FROM notes WHERE mid=" +
                          str(model['id']) + " AND tags LIKE \'% " + tag +
                          " %\'")
        tags = col.db.list("SELECT tags FROM notes WHERE mid=" +
                           str(model['id']) + " AND tags LIKE \'% " + tag +
                           " %\'")
        flds = col.db.list("SELECT flds FROM notes WHERE mid=" +
                           str(model['id']) + " AND tags LIKE \'% " + tag +
                           " %\'")
    else:
        nid = col.db.list("SELECT id FROM notes WHERE mid=" + str(model['id']))
        tags = col.db.list("SELECT tags FROM notes WHERE mid=" +
                           str(model['id']))
        flds = col.db.list("SELECT flds FROM notes WHERE mid=" +
                           str(model['id']))
    return nid, tags, flds


# create a new menu item, "Replace all"
action = QAction("Replace all", mw)
# set it to call loadMainFrontend() when it's clicked
mw.connect(action, SIGNAL("triggered()"), loadMainFrontend)
# and add it to the tools menu of main window
mw.form.menuTools.addAction(action)
#browser.Browser.Ui_Dialog.
コード例 #47
0
ファイル: importer.py プロジェクト: taonguyen740/Anki_addon
        self.progressBar.show()
        self.progressBar.setValue(0)

        courseUrl = self.courseUrlLineEdit.text()
        self.loader.downloadMedia = self.downloadMediaCheckBox.isChecked()
        self.loader.skipExistingMedia = self.skipExistingMediaCheckBox.isChecked(
        )
        self.loader.downloadMems = self.importMemsCheckBox.isChecked(
        ) and self.downloadMediaCheckBox.isChecked()
        self.loader.embedMemsOnlineMedia = self.importMemsCheckBox.isChecked(
        ) and self.embedMemsOnlineMediaCheckBox.isChecked()
        self.loader.start(courseUrl)


def startCourseImporter():
    downloadDirectory = MediaManager(mw.col, None).dir()
    cookiefilename = os.path.join(mw.pm.profileFolder(), 'memrise.cookies')
    cookiejar = cookielib.MozillaCookieJar(cookiefilename)
    if os.path.isfile(cookiefilename):
        cookiejar.load()
    memriseService = memrise.Service(downloadDirectory, cookiejar)
    if memriseService.isLoggedIn() or MemriseLoginDialog.login(memriseService):
        cookiejar.save()
        memriseCourseImporter = MemriseImportDialog(memriseService)
        memriseCourseImporter.exec_()


action = QAction("Import Memrise Course...", mw)
mw.connect(action, SIGNAL("triggered()"), startCourseImporter)
mw.form.menuTools.addAction(action)
コード例 #48
0
                self.clearLayout(child.layout())


def showCompletionDialog(newCount):
    QMessageBox.about(
        mw, "Media Import Complete", """
<p>
Media import is complete and %s new notes were created. 
All generated cards are placed in the <b>MediaImport</b> deck.
<br><br>
Please refer to the introductory videos for instructions on 
<a href="https://youtube.com/watch?v=DnbKwHEQ1mA">flipping card content</a> or 
<a href="http://youtube.com/watch?v=F1j1Zx0mXME">modifying the appearance of cards.</a>
</p>""" % newCount)


def showFailureDialog():
    QMessageBox.about(
        mw, "Media Import Failure", """
<p>
Failed to generate cards and no media files were imported. Please ensure the
note type you selected is able to generate cards by using a valid
<a href="http://ankisrs.net/docs/manual.html#cards-and-templates">card template</a>.
</p>
""")


action = QAction("Media Import...", mw)
mw.connect(action, SIGNAL("triggered()"), doMediaImport)
mw.form.menuTools.addAction(action)
コード例 #49
0
ファイル: download.py プロジェクト: mistaecko/anki-addons
# separator, otherwise create that menu.
try:
    mw.edit_media_submenu.addSeparator()
except AttributeError:
    mw.edit_media_submenu = QMenu(u"&Media", mw)
    mw.form.menuEdit.addSeparator()
    mw.form.menuEdit.addMenu(mw.edit_media_submenu)


mw.note_download_action = QAction(mw)
mw.note_download_action.setText(u"Note audio")
mw.note_download_action.setIcon(QIcon(os.path.join(icons_dir,
                                                   'download_note_audio.png')))
mw.note_download_action.setToolTip(
    "Download audio for all audio fields of this note.")
mw.connect(mw.note_download_action, SIGNAL("triggered()"), download_for_note)

mw.side_download_action = QAction(mw)
mw.side_download_action.setText(u"Side audio")
mw.side_download_action.setIcon(
    QIcon(os.path.join(icons_dir, 'download_side_audio.png')))
mw.side_download_action.setToolTip(
    "Download audio for audio fields currently visible.")
mw.connect(mw.side_download_action, SIGNAL("triggered()"), download_for_side)

mw.manual_download_action = QAction(mw)
mw.manual_download_action.setText(u"Manual audio")
mw.manual_download_action.setIcon(
    QIcon(os.path.join(icons_dir, 'download_audio_manual.png')))
mw.manual_download_action.setToolTip(
    "Download audio, editing the information first.")
コード例 #50
0
  for f in range(len(model['flds'])):
    if model['flds'][f]['name'].lower()==fieldName:
      fieldIdx.append(f)
  if len(fieldIdx)==1:
    return fieldIdx[0]
  elif len(fieldIdx)==0:
    raise NameError("Specified field \'" + fieldName + "\' not found")
  else:
    raise NameError("Specified field \'" + fieldName + "\' not unique")
    
def fetchData(col,model,tag):
  # Get all the notes with specified criteria
  if tag!='':
    nid=col.db.list("SELECT id FROM notes WHERE mid="+str(model['id'])+" AND tags LIKE \'% "+tag+" %\'")
    tags=col.db.list("SELECT tags FROM notes WHERE mid="+str(model['id'])+" AND tags LIKE \'% "+tag+" %\'")
    flds=col.db.list("SELECT flds FROM notes WHERE mid="+str(model['id'])+" AND tags LIKE \'% "+tag+" %\'")
  else:
    nid=col.db.list("SELECT id FROM notes WHERE mid="+str(model['id']))
    tags=col.db.list("SELECT tags FROM notes WHERE mid="+str(model['id']))
    flds=col.db.list("SELECT flds FROM notes WHERE mid="+str(model['id']))  
  return nid,tags,flds       
  

# create a new menu item, "Replace all"
action = QAction("Replace all", mw)
# set it to call loadMainFrontend() when it's clicked
mw.connect(action, SIGNAL("triggered()"),loadMainFrontend)
# and add it to the tools menu of main window
mw.form.menuTools.addAction(action)
#browser.Browser.Ui_Dialog.
コード例 #51
0
ファイル: fixunicode.py プロジェクト: bsaintjo/ankiplugins
    (                    # begin group
    [\ud800-\udbff]      #   match leading surrogate
    (?![\udc00-\udfff])  #   but only if not followed by trailing surrogate
    )                    # end group
    |                    #  OR
    (                    # begin group
    (?<![\ud800-\udbff]) #   if not preceded by leading surrogate
    [\udc00-\udfff]      #   match trailing surrogate
    )                    # end group
    """
)


def fix():
    mw.col.modSchema(check=True)
    mw.progress.start()
    toFix = []
    for nid, flds in mw.col.db.execute("select id, flds from notes"):
        rep = lone.sub("", flds)
        if rep != flds:
            toFix.append((rep, nid))
    mw.col.db.executemany("update notes set flds=? where id=?", toFix)
    mw.progress.finish()
    showInfo("Found & fixed %d notes. Please upload your collection and download it to other devices." % len(toFix))


a = QAction(mw)
a.setText("Fix Invalid Characters")
mw.form.menuTools.addAction(a)
mw.connect(a, SIGNAL("triggered()"), fix)
コード例 #52
0
ファイル: Hanzi_Stats.py プロジェクト: yndislegur/Hanzi_Stats
def createMenu():
    a = QAction(mw)
    a.setText("Hanzi Stats")
    mw.connect(a, SIGNAL("triggered()"), onhanziStats)
    mw.form.menuTools.addAction(a)
コード例 #53
0
ファイル: gui.py プロジェクト: fbriere/anki-kdrill
def init():
    """Hook this add-on into Anki."""
    action = QAction(_("Tag kanji cards listed in KDrill usefile"), mw)

    mw.connect(action, SIGNAL("triggered()"), onMenuEntry)
    mw.form.menuTools.addAction(action)
コード例 #54
0
ファイル: stats.py プロジェクト: igorfarias/ankiplugins
def createMenu():
    a = QAction(mw)
    a.setText("Kanji Stats")
    mw.form.menuTools.addAction(a)
    mw.connect(a, SIGNAL("triggered()"), onKanjiStats)