示例#1
0
 def onDelete():
     saveGeom(diag, "emptyCards")
     QDialog.accept(diag)
     self.checkpoint(_("Delete Empty"))
     self.col.remCards(cids)
     tooltip(ngettext("%d card deleted.", "%d cards deleted.", len(cids)) % len(cids))
     self.reset()
 def accept(self):
     saveGeom(self, "TT/TIFP")
     row = self.list_box.currentRow()
     if len(self.fuzzy_items) > 0:
         row = self.list_box.currentRow()
         self.selkey = self.fuzzy_items[row]
         if self.selkey not in self.originalkeys:
             k = self.selkey.strip()
             if " " in k:
                 tooltip('tags may not contain spaces. Aborting ...')
                 return
         if self.dict:
             self.selvalue = self.dict[self.selkey]
         QDialog.accept(self)
     else:
         if not self.allownew:
             tooltip('nothing entered. Aborting ...')
         else:
             input = self.input_line.text().strip()
             if input:
                 if " " in input:
                     tooltip('tags may not contain spaces. Aborting ...')
                 else:
                     self.selkey = input
                     QDialog.accept(self)
             else:
                 tooltip('nothing entered. Aborting ...')
示例#3
0
 def accept(self):
     # originally "Setting" was used for the foreground or background color. The value for
     # "Setting" is used when clicking a menu/button or shortcut. So before/after must be
     # in "Setting"
     # But only set this when closing the dialog so that the unique string is not shown
     # to the user. That workaround is a consequence of reading the config from the
     # QTableWidget directly ....
     bef = self.dialog.pte_before.toPlainText()
     aft = self.dialog.pte_after.toPlainText()
     self.newsetting = {
         "Category": "text wrapper",
         "Hotkey": self.dialog.hotkey.keySequence().toString(),
         "Setting": "",  # bef + unique_string + aft, 
         "Show_in_menu": self.dialog.cb_contextmenu_show.isChecked(),
         "Target group in menu": self.dialog.le_menu_group.text(),
         "Text_in_menu": self.dialog.le_contextmenu_text.text(),
         "Text_in_menu_styling": bef,
         "Text_in_menu_styling_nightmode": aft,
         "extrabutton_show": self.dialog.cb_extrabutton_show.isChecked(),
         "extrabutton_text": self.dialog.le_extrabutton_text.text(),
         "extrabutton_tooltip": self.dialog.le_tooltip_text.text(),
     }
     if self.config:  # new entries don't have this entry yet
         if "Category" in self.config:
             self.newsetting["Category"] = self.config["Category"]
     QDialog.accept(self)
示例#4
0
 def accept(self):
     # replace cursor with unique string
     s = """insertTextAtCursor('%s')""" % unique_string
     self.execJavaScript(s)
     mw.col.cmhelper_field_content = self.execJavaScript(self.js_save_cmd)
     saveGeom(self, "1043915942_CmDialog")
     self.web = None
     QDialog.accept(self)
示例#5
0
 def accept(self):
     row = self.frm.fields.currentRow()
     if row < len(self.model['flds']):
         self.field = self.model['flds'][row]['name']
     elif row == self.frm.fields.count() - 2:
         self.field = "_tags"
     else:
         self.field = None
     QDialog.accept(self)
示例#6
0
 def accept(self):
     saveGeom(self, self.geomKey)
     remHook('reset', self.onReset)
     row = self.form.list.currentRow()
     if row < 0:
         showInfo(_("Please select something."))
         return
     self.name = self.names[self.form.list.currentRow()]
     QDialog.accept(self)
示例#7
0
 def accept(self):
     self.tagstring = ""
     for t in self.line_list:
         if not self.basic_mode:
             t.hideCompleter()
         text = t.text()
         if text:
             self.tagstring += text + " "
     saveGeom(self, "TagDialogExtended")
     QDialog.accept(self)
示例#8
0
    def accept(self):
        self.conf_text_to_dict()  #  updates self.current_config
        self.clean_settings[self.active_settings_group] = self.current_config
        wcs("clean_settings", self.clean_settings)

        cbr = self.form.bot_cb_recent_notes
        AllItems = [int(cbr.itemText(i)) for i in range(cbr.count())]
        wcs("config_window_loadable_nids", AllItems)

        saveGeom(self, "html_cleaner_conf_window")
        aqt.dialogs.markClosed("html_cleaner_config")
        QDialog.accept(self)
示例#9
0
 def onAddDeck(self):
     row = self.form.list.currentRow()
     if row < 0:
         default = self.form.filter.text()
     else:
         default = self.names[self.form.list.currentRow()]
     n = getOnlyText(_("New deck name:"), default=default)
     if n:
         self.mw.col.decks.id(n)
         self.name = n
         # make sure we clean up reset hook when manually exiting
         remHook('reset', self.onReset)
         QDialog.accept(self)
示例#10
0
    def accept(self):
        # check maps
        field_map = self.get_field_map()
        templates_map = self.get_template_map()
        if any(True for template in list(templates_map.values()) if template is None) and \
                not aqt.utils.askUser(_(
                    "Any cards mapped to nothing will be deleted. "
                    "If a note has no remaining cards, it will be lost. "
                    "Are you sure you want to continue?")):
                return

        self.collection.models.change(self.old_model, self.note_id_list, self.targetModel, field_map, templates_map)

        self.cleanup()

        QDialog.accept(self)
    def accept(self):
        # check maps
        field_map = self.get_field_map()
        templates_map = self.get_template_map()
        if any(True for template in list(templates_map.values()) if template is None) and \
                not aqt.utils.askUser(_(
                    "Any cards mapped to nothing will be deleted. "
                    "If a note has no remaining cards, it will be lost. "
                    "Are you sure you want to continue?")):
            return

        self.collection.models.change(self.old_model, self.note_id_list,
                                      self.targetModel, field_map,
                                      templates_map)

        self.cleanup()

        QDialog.accept(self)
 def accept(self):
     sel = self.dialog.list_categories.currentItem().text()
     if sel in ["Backcolor (inline)", "style (inline)"]:
         if not askUser(inlinewarning):
             return
     if sel in [
             "class (other)", "Backcolor (via class)",
             "Forecolor (via class)", "font size (via class)",
             "class (other), wrapped in div"
     ]:
         if not askUser(classeswarning):
             return
     a = gui_dialog(self, sel=sel, config=None)
     if a.exec_():
         self.newsetting = a.newsetting
         self.newsetting['Category'] = sel
         QDialog.accept(self)
     else:
         QDialog.reject(self)
示例#13
0
文件: addons.py 项目: solarmist/anki
    def accept(self):
        # get codes
        try:
            ids = [int(n) for n in self.form.code.text().split()]
        except ValueError:
            showWarning(_("Invalid code."))
            return

        log, errs = self.mgr.downloadIds(ids)

        if log:
            log_html = "<br>".join(log)
            if len(log) == 1:
                tooltip(log_html, parent=self)
            else:
                showInfo(log_html, parent=self, textFormat="rich")
        if errs:
            showWarning("\n\n".join(errs), textFormat="plain")

        self.addonsDlg.redrawAddons()
        QDialog.accept(self)
示例#14
0
 def accept(self):
     self.hide()
     n = 0
     # gather yes/no tags
     yes = []
     no = []
     for c in range(self.dialog.activeList.count()):
         # active
         if self.dialog.activeCheck.isChecked():
             item = self.dialog.activeList.item(c)
             idx = self.dialog.activeList.indexFromItem(item)
             if self.dialog.activeList.selectionModel().isSelected(idx):
                 yes.append(self.tags[c])
         # inactive
         item = self.dialog.inactiveList.item(c)
         idx = self.dialog.inactiveList.indexFromItem(item)
         if self.dialog.inactiveList.selectionModel().isSelected(idx):
             no.append(self.tags[c])
     # save in the deck for future invocations
     self.deck['activeTags'] = yes
     self.deck['inactiveTags'] = no
     self.mw.col.decks.save(self.deck)
     # build query string
     self.tags = ""
     if yes:
         arr = []
         for req in yes:
             arr.append("tag:'%s'" % req)
         self.tags += "(" + " or ".join(arr) + ")"
     if no:
         arr = []
         for req in no:
             arr.append("-tag:'%s'" % req)
         self.tags += " " + " ".join(arr)
     saveGeom(self, "tagLimit")
     QDialog.accept(self)
示例#15
0
 def accept(self):
     f = self.form
     i = self.radioIdx
     spin = f.spin.value()
     if i == RADIO_NEW:
         self.deck['extendNew'] = spin
         self.mw.col.decks.save(self.deck)
         self.mw.col.sched.extendLimits(spin, 0)
         self.mw.reset()
         return QDialog.accept(self)
     elif i == RADIO_REV:
         self.deck['extendRev'] = spin
         self.mw.col.decks.save(self.deck)
         self.mw.col.sched.extendLimits(0, spin)
         self.mw.reset()
         return QDialog.accept(self)
     elif i == RADIO_CRAM:
         tags = self._getTags()
     # the rest create a filtered deck
     cur = self.mw.col.decks.byName(_("Custom Study Session"))
     if cur:
         if not cur['dyn']:
             showInfo("Please rename the existing Custom Study deck first.")
             return QDialog.accept(self)
         else:
             # safe to empty
             self.mw.col.sched.emptyDyn(cur['id'])
             # reuse; don't delete as it may have children
             dyn = cur
             self.mw.col.decks.select(cur['id'])
     else:
         did = self.mw.col.decks.newDyn(_("Custom Study Session"))
         dyn = self.mw.col.decks.get(did)
     # and then set various options
     if i == RADIO_FORGOT:
         dyn['terms'][0] = ['rated:%d:1' % spin, DYN_MAX_SIZE, DYN_RANDOM]
         dyn['resched'] = False
     elif i == RADIO_AHEAD:
         dyn['terms'][0] = ['prop:due<=%d' % spin, DYN_MAX_SIZE, DYN_DUE]
         dyn['resched'] = True
     elif i == RADIO_PREVIEW:
         dyn['terms'][0] = [
             'is:new added:%s' % spin, DYN_MAX_SIZE, DYN_OLDEST
         ]
         dyn['resched'] = False
     elif i == RADIO_CRAM:
         type = f.cardType.currentRow()
         if type == TYPE_NEW:
             terms = "is:new "
             ord = DYN_ADDED
             dyn['resched'] = True
         elif type == TYPE_DUE:
             terms = "is:due "
             ord = DYN_DUE
             dyn['resched'] = True
         elif type == TYPE_REVIEW:
             terms = "-is:new "
             ord = DYN_RANDOM
             dyn['resched'] = True
         else:
             terms = ""
             ord = DYN_RANDOM
             dyn['resched'] = False
         dyn['terms'][0] = [(terms + tags).strip(), spin, ord]
     # add deck limit
     dyn['terms'][0][0] = "deck:\"%s\" %s " % (self.deck['name'],
                                               dyn['terms'][0][0])
     # generate cards
     if not self.mw.col.sched.rebuildDyn():
         return showWarning(
             _("No cards matched the criteria you provided."))
     self.mw.moveToState("overview")
     QDialog.accept(self)
示例#16
0
 def accept(self):
     self.saveConf()
     self.mw.reset()
     QDialog.accept(self)
 def accept(self):
     saveGeom(self, "BSMH")
     self.newsearch = self.process_text()
     QDialog.accept(self)
示例#18
0
 def accept(self):
     QDialog.accept(self)
示例#19
0
 def accept(self):
     self.sel = self.dialog.list_categories.currentItem().text()
     QDialog.accept(self)
示例#20
0
文件: about.py 项目: solarmist/anki
 def accept(self):
     aqt.dialogs.markClosed("About")
     QDialog.accept(self)
示例#21
0
 def accept(self):
     self.tagstring = ""
     for t in self.current_tags_list():
         self.tagstring += f"{t} "
     saveGeom(self, "TagDialogExtended")
     QDialog.accept(self)
示例#22
0
文件: utils.py 项目: solarmist/anki
 def accept(self):
     return QDialog.accept(self)
示例#23
0
    def accept(self):
        self.exporter.includeSched = (self.frm.includeSched.isChecked())
        self.exporter.includeMedia = (self.frm.includeMedia.isChecked())
        self.exporter.includeTags = (self.frm.includeTags.isChecked())
        self.exporter.includeHTML = (self.frm.includeHTML.isChecked())
        if not self.frm.deck.currentIndex():
            self.exporter.did = None
        else:
            name = self.decks[self.frm.deck.currentIndex()]
            self.exporter.did = self.col.decks.id(name)
        if self.isVerbatim:
            name = time.strftime("-%Y-%m-%d@%H-%M-%S",
                                 time.localtime(time.time()))
            deck_name = _("collection") + name
        else:
            # Get deck name and remove invalid filename characters
            deck_name = self.decks[self.frm.deck.currentIndex()]
            deck_name = re.sub('[\\\\/?<>:*|"^]', '_', deck_name)

        if not self.isVerbatim and self.isApkg and self.exporter.includeSched and self.col.schedVer(
        ) == 2:
            showInfo(
                "Please switch to the regular scheduler before exporting a single deck .apkg with scheduling."
            )
            return

        filename = '{0}{1}'.format(deck_name, self.exporter.ext)
        while 1:
            file = getSaveFile(self,
                               _("Export"),
                               "export",
                               self.exporter.key,
                               self.exporter.ext,
                               fname=filename)
            if not file:
                return
            if checkInvalidFilename(os.path.basename(file), dirsep=False):
                continue
            break
        self.hide()
        if file:
            self.mw.progress.start(immediate=True)
            try:
                f = open(file, "wb")
                f.close()
            except (OSError, IOError) as e:
                showWarning(_("Couldn't save file: %s") % str(e))
            else:
                os.unlink(file)
                exportedMedia = lambda cnt: self.mw.progress.update(
                    label=ngettext("Exported %d media file",
                                   "Exported %d media files", cnt) % cnt)
                addHook("exportedMediaFiles", exportedMedia)
                self.exporter.exportInto(file)
                remHook("exportedMediaFiles", exportedMedia)
                period = 3000
                if self.isVerbatim:
                    msg = _("Collection exported.")
                else:
                    if self.isTextNote:
                        msg = ngettext(
                            "%d note exported.", "%d notes exported.",
                            self.exporter.count) % self.exporter.count
                    else:
                        msg = ngettext(
                            "%d card exported.", "%d cards exported.",
                            self.exporter.count) % self.exporter.count
                tooltip(msg, period=period)
            finally:
                self.mw.progress.finish()
        QDialog.accept(self)