示例#1
0
 def __init__(self, parent=None, alternatives=[]):
     self.parent = parent
     QDialog.__init__(self, parent, Qt.Window)
     self.dialog = settings_select_group.Ui_Dialog()
     self.dialog.setupUi(self)
     self.dialog.list_categories.addItems(alternatives)
     self.dialog.list_categories.itemDoubleClicked.connect(self.accept)
示例#2
0
    def __init__(self, parent=None, config=None):
        self.parent = parent
        self.config = config
        QDialog.__init__(self, parent, Qt.Window)
        self.dialog = settings_textwrapper.Ui_Dialog()
        self.dialog.setupUi(self)

        self.menuentry = ""
        if config:
            if config["Hotkey"]:
                self.dialog.hotkey.setKeySequence(config["Hotkey"])

            if config["Target group in menu"]:
                self.dialog.le_menu_group.setText(
                    config["Target group in menu"])
            if config["Text_in_menu_styling"]:
                self.dialog.pte_before.insertPlainText(
                    config["Text_in_menu_styling"])
            if config["Text_in_menu_styling_nightmode"]:
                self.dialog.pte_after.insertPlainText(
                    config["Text_in_menu_styling_nightmode"])
            if config["Show_in_menu"]:
                self.dialog.cb_contextmenu_show.setChecked(True)
            if config["Text_in_menu"]:
                self.dialog.le_contextmenu_text.setText(config["Text_in_menu"])
            if config["extrabutton_show"]:
                self.dialog.cb_extrabutton_show.setChecked(True)
            if config["extrabutton_text"]:
                self.dialog.le_extrabutton_text.setText(
                    config["extrabutton_text"])
            if config["extrabutton_tooltip"]:
                self.dialog.le_tooltip_text.setText(
                    config["extrabutton_tooltip"])
 def __init__(self, parent, thisconf, progs):
     if thisconf:
         self.thisconf = thisconf
     else:
         self.thisconf = {}
     self.progs = progs
     self.exts_used_when_opened = self.thisconf.get("extensions", [])
     self.parent = parent
     QDialog.__init__(self, parent, Qt.Window)
     self.dialog = config_dialog__add_edit_single_entry.Ui_Dialog()
     self.dialog.setupUi(self)
     self.adjustSize()
     self.fill_fields()
     self.dialog.pb_load_from_defaults.clicked.connect(
         self.load_from_defaults)
     self.dialog.pb_path_add.clicked.connect(self.add_default_path)
     self.dialog.pb_path_up.clicked.connect(self.path_up)
     self.dialog.pb_path_down.clicked.connect(self.path_down)
     self.dialog.pb_path_del.clicked.connect(self.del_default_path)
     self.dialog.pb_cmd_pickpath.clicked.connect(self.pickcmdpath)
     self.dialog.pb_cmd_guess.clicked.connect(self.cmdguess)
     self.dialog.pb_parameters_guess.clicked.connect(self.parameters_guess)
     self.dialog.buttonBox.accepted.disconnect(self.accept)
     self.dialog.buttonBox.accepted.connect(self.onAccept)
     self.dialog.buttonBox.rejected.disconnect(self.reject)
     self.dialog.buttonBox.rejected.connect(self.onReject)
     self.dialog.buttonBox.helpRequested.connect(self.onHelp)
     self.dialog.pb_parameters_guess.hide()
     self.dialog.pb_params_info.clicked.connect(self.onParamsInfo)
 def __init__(self, parent=None):
     self.parent = parent
     QDialog.__init__(self, parent, Qt.Window)
     self.dialog = settings_select_category.Ui_Dialog()
     self.dialog.setupUi(self)
     self.dialog.list_categories.addItems(addable_options)
     self.dialog.list_categories.itemDoubleClicked.connect(self.accept)
示例#5
0
    def __init__(self, parent):
        QDialog.__init__(self, parent)
        self.parent = parent
        self.fieldWidgets = {}

        self.controls = pinyin.forms.generated.builddb.Ui_BuildDB()
        self.controls.setupUi(self)
示例#6
0
 def __init__(self, mw):
     QDialog.__init__(self, mw, Qt.Window)
     mw.setupDialogGC(self)
     self.mw = mw
     self.name = "deckStats"
     self.period = 0
     self.form = aqt.forms.stats.Ui_Dialog()
     self.oldPos = None
     self.wholeCollection = False
     self.setMinimumWidth(700)
     f = self.form
     f.setupUi(self)
     restoreGeom(self, self.name)
     b = f.buttonBox.addButton(_("Save PDF"), QDialogButtonBox.ActionRole)
     b.clicked.connect(self.saveImage)
     b.setAutoDefault(False)
     f.groups.clicked.connect(lambda: self.changeScope("deck"))
     f.groups.setShortcut("g")
     f.all.clicked.connect(lambda: self.changeScope("collection"))
     f.month.clicked.connect(lambda: self.changePeriod(0))
     f.year.clicked.connect(lambda: self.changePeriod(1))
     f.life.clicked.connect(lambda: self.changePeriod(2))
     maybeHideClose(self.form.buttonBox)
     addCloseShortcut(self)
     self.show()
     self.refresh()
     self.activateWindow()
示例#7
0
文件: utils.py 项目: solarmist/anki
 def __init__(self, parent, question, help=None, edit=None, default="", \
              title="Anki", minWidth=400):
     QDialog.__init__(self, parent)
     self.setWindowTitle(title)
     self.question = question
     self.help = help
     self.qlabel = QLabel(question)
     self.setMinimumWidth(minWidth)
     v = QVBoxLayout()
     v.addWidget(self.qlabel)
     if not edit:
         edit = QLineEdit()
     self.l = edit
     if default:
         self.l.setText(default)
         self.l.selectAll()
     v.addWidget(self.l)
     buts = QDialogButtonBox.Ok | QDialogButtonBox.Cancel
     if help:
         buts |= QDialogButtonBox.Help
     b = QDialogButtonBox(buts)
     v.addWidget(b)
     self.setLayout(v)
     b.button(QDialogButtonBox.Ok).clicked.connect(self.accept)
     b.button(QDialogButtonBox.Cancel).clicked.connect(self.reject)
     if help:
         b.button(QDialogButtonBox.Help).clicked.connect(self.helpRequested)
示例#8
0
 def __init__(self, parent):
     QDialog.__init__(self, parent)
     self.parent = parent
     self.fieldWidgets = {}
     
     self.controls = pinyin.forms.generated.builddb.Ui_BuildDB()
     self.controls.setupUi(self)
示例#9
0
 def __init__(self, mw, deck):
     QDialog.__init__(self, mw)
     self.mw = mw
     self.deck = deck
     self.childDids = [
         d[1] for d in self.mw.col.decks.children(self.deck['id'])
     ]
     self._origNewOrder = None
     self.form = aqt.forms.dconf.Ui_Dialog()
     self.form.setupUi(self)
     self.mw.checkpoint(_("Options"))
     self.setupCombos()
     self.setupConfs()
     self.setWindowModality(Qt.WindowModal)
     self.form.buttonBox.helpRequested.connect(
         lambda: openHelp("deckoptions"))
     self.form.confOpts.clicked.connect(self.confOpts)
     self.form.buttonBox.button(
         QDialogButtonBox.RestoreDefaults).clicked.connect(self.onRestore)
     self.setWindowTitle(_("Options for %s") % self.deck['name'])
     # qt doesn't size properly with altered fonts otherwise
     restoreGeom(self, "deckconf", adjustSize=True)
     self.show()
     self.exec_()
     saveGeom(self, "deckconf")
示例#10
0
 def __init__(self, mw, did=None):
     QDialog.__init__(self, mw, Qt.Window)
     self.mw = mw
     self.col = mw.col
     self.frm = aqt.forms.exporting.Ui_ExportDialog()
     self.frm.setupUi(self)
     self.exporter = None
     self.setup(did)
     self.exec_()
示例#11
0
 def __init__(self,
              mw,
              names=None,
              accept=None,
              title=None,
              help="studydeck",
              current=None,
              cancel=True,
              parent=None,
              dyn=False,
              buttons=None,
              geomKey="default"):
     QDialog.__init__(self, parent or mw)
     if buttons is None:
         buttons = []
     self.mw = mw
     self.form = aqt.forms.studydeck.Ui_Dialog()
     self.form.setupUi(self)
     self.form.filter.installEventFilter(self)
     self.cancel = cancel
     addHook('reset', self.onReset)
     self.geomKey = "studyDeck-" + geomKey
     restoreGeom(self, self.geomKey)
     if not cancel:
         self.form.buttonBox.removeButton(
             self.form.buttonBox.button(QDialogButtonBox.Cancel))
     if buttons:
         for b in buttons:
             self.form.buttonBox.addButton(b, QDialogButtonBox.ActionRole)
     else:
         b = QPushButton(_("Add"))
         b.setShortcut(QKeySequence("Ctrl+N"))
         b.setToolTip(shortcut(_("Add New Deck (Ctrl+N)")))
         self.form.buttonBox.addButton(b, QDialogButtonBox.ActionRole)
         b.clicked.connect(self.onAddDeck)
     if title:
         self.setWindowTitle(title)
     if not names:
         names = sorted(self.mw.col.decks.allNames(dyn=dyn))
         self.nameFunc = None
         self.origNames = names
     else:
         self.nameFunc = names
         self.origNames = names()
     self.name = None
     self.ok = self.form.buttonBox.addButton(accept or _("Study"),
                                             QDialogButtonBox.AcceptRole)
     self.setWindowModality(Qt.WindowModal)
     self.form.buttonBox.helpRequested.connect(lambda: openHelp(help))
     self.form.filter.textEdited.connect(self.redraw)
     self.form.list.itemDoubleClicked.connect(self.accept)
     self.show()
     # redraw after show so position at center correct
     self.redraw("", current)
     self.exec_()
示例#12
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))       
示例#13
0
    def __init__(self,
                 editor,
                 parent_window,
                 selected_text,
                 selected_is_url=False):
        QDialog.__init__(self, parent_window, Qt.Window)
        self.editor_instance = editor
        self.parent_window = parent_window
        self.selected_text = selected_text
        self.selected_is_url = selected_is_url
        self.setWindowTitle("Anki: Create a hyperlink")
        self.resize(DIALOG_SIZE_X, DIALOG_SIZE_Y)
        restoreGeom(self, "318752047__add_hyperlink")

        self.pb_ok = QPushButton("&OK", self)
        self.pb_ok.setEnabled(False)
        self.pb_ok.clicked.connect(
            lambda: self.insert_anchor(url_edit.text(), urltext_edit.text()))

        self.pb_cancel = QPushButton("&Cancel", self)
        self.pb_cancel.clicked.connect(self.reject)

        url_label = QLabel("Link to:")
        url_edit = QLineEdit()
        url_edit.setPlaceholderText("URL")
        url_edit.textChanged.connect(lambda: self.enable_ok_button(
            self.pb_ok, url_edit.text(), urltext_edit.text()))

        urltext_label = QLabel("Text to display:")
        urltext_edit = QLineEdit()
        urltext_edit.setPlaceholderText("Text")
        urltext_edit.textChanged.connect(lambda: self.enable_ok_button(
            self.pb_ok, url_edit.text(), urltext_edit.text()))

        self.button_bar = QHBoxLayout()
        self.button_bar.addStretch(1)
        self.button_bar.addWidget(self.pb_cancel)
        self.button_bar.addWidget(self.pb_ok)

        self.dialog_vbox = QVBoxLayout()
        self.dialog_vbox.addWidget(url_label)
        self.dialog_vbox.addWidget(url_edit)
        self.dialog_vbox.addWidget(urltext_label)
        self.dialog_vbox.addWidget(urltext_edit)
        self.dialog_vbox.addLayout(self.button_bar)
        self.setLayout(self.dialog_vbox)
        # if user already selected text, put it in urltext_edit
        if self.selected_text:
            if self.selected_is_url:
                url_edit.setText(self.selected_text)
                urltext_edit.setFocus()
            else:
                urltext_edit.setText(self.selected_text)
                url_edit.setFocus()
示例#14
0
 def __init__(self, mw):
     QDialog.__init__(self, mw)
     self.mw = mw
     self.deck = self.mw.col.decks.current()
     self.conf = self.mw.col.decks.getConf(self.deck['conf'])
     self.form = f = aqt.forms.customstudy.Ui_Dialog()
     f.setupUi(self)
     self.setWindowModality(Qt.WindowModal)
     self.setupSignals()
     f.radio1.click()
     self.exec_()
 def __init__(self, browser, searchstring, quick_insert_addon_filter_func):
     self.searchstring = searchstring
     self.parent = browser
     self.browser = browser
     QDialog.__init__(self, self.parent, Qt.Window)
     self.form = search_box.Ui_Dialog()
     self.form.setupUi(self)
     self.setupUI()
     self.settext()
     if quick_insert_addon_filter_func:
         self.quick_insert_addon_filter_func = quick_insert_addon_filter_func
         self.form.pte.textChanged.connect(self.text_change_helper)
示例#16
0
    def __init__(self, mw) -> None:
        QDialog.__init__(self)
        self.form = import_dialog.Ui_Dialog()
        self.form.setupUi(self)
        self.conf = mw.addonManager.getConfig(__name__)
        self.mw = mw

        self.extract_thread: Optional[ImportThread] = None
        self.notes: Set[TwNote] = set()
        self.warnings: List[str] = []
        self.wikis = list(self.conf['wikis'].items())
        self.form.wikiProgressBar.setMaximum(len(self.wikis))
示例#17
0
    def __init__(self, parent):
        QDialog.__init__(self, parent, Qt.Window)
        self.parent = parent
        mw.setupDialogGC(self)
        self.form = config_widgets_editors.Ui_Dialog()
        self.form.setupUi(self)
        self.setWindowTitle("Anki Add-on: Html Cleaner clean settings")
        self.resize(800, 1300)
        restoreGeom(self, "html_cleaner_conf_window")
        self.mw = mw

        self.editor_old = ShortcutLessNonEditableEditor(
            self.mw, self.form.widget_original, self, True)
        self.clean_ed = DupeIgnoringEditor(self.mw, self.form.widget_cleaned,
                                           self, True)

        # bottom
        for f in getUserOption("config_window_loadable_nids"):
            self.form.bot_cb_recent_notes.addItem(str(f))
        self.other_note_into_editor(firstrun=True)
        # initial run must before the next line or the editor_did_load_note hooks are run once more
        # so that I get another entry of Arthurs "clean" next a field name
        self.form.bot_cb_recent_notes.currentIndexChanged.connect(
            self.other_note_into_editor)
        self.form.bot_pb_add_note.clicked.connect(self.add_note)
        self.form.bot_pb_remove.clicked.connect(self.remove_note)
        self.form.bot_pb_ok.clicked.connect(self.accept)
        self.form.bot_pb_cancel.clicked.connect(self.reject)

        # sidebar
        self.clean_settings = getUserOption("clean_settings")
        self.active_settings_group = getUserOption(
            "clean_active_settings_group")
        self.current_config = self.clean_settings[self.active_settings_group]
        if self.active_settings_group not in self.clean_settings:
            showInfo((
                "Invalid config detected: the group set in 'clean_active_settings_group' "
                'must be in "clean_settings". Update/Repair your config. Aborting'
            ))
            self.reject()
        self.form.conf_pb_group.setText(self.active_settings_group)
        self.form.conf_pb_group.clicked.connect(self.on_config_group_change)
        self.populate_versions()
        self.form.conf_pb_backup.setVisible(False)
        self.form.conf_pb_backup.clicked.connect(self.backup_current_vals)
        self.form.conf_pb_save.clicked.connect(self.save_current_vals)

        self.set_conf_text(
        )  # initial run must before the next line or the editor_did_load_note hooks are run once more
        # so that I get another entry of Arthurs "clean" next a field name
        self.form.conf_pte_conf.textChanged.connect(self.update_clean_ed)
        self.show()
示例#18
0
    def __init__(self, parent):
        """
        Initialize dialog

        Arguments:
            parent {QWidget} -- Parent Qt widget
        """
        QDialog.__init__(self, parent=parent)
        self.parent = parent
        # self.active is used to trace whether there's any key held now:
        self.active = 0
        self._resetDialog()
        self._setupUI()
示例#19
0
文件: addons.py 项目: solarmist/anki
 def __init__(self, dlg):
     QDialog.__init__(self, dlg)
     self.addonsDlg = dlg
     self.mgr = dlg.mgr
     self.mw = self.mgr.mw
     self.form = aqt.forms.getaddons.Ui_Dialog()
     self.form.setupUi(self)
     b = self.form.buttonBox.addButton(_("Browse Add-ons"),
                                       QDialogButtonBox.ActionRole)
     b.clicked.connect(self.onBrowse)
     restoreGeom(self, "getaddons", adjustSize=True)
     self.exec_()
     saveGeom(self, "getaddons")
示例#20
0
    def __init__(self, reviewer):
        QDialog.__init__(self)

        # Create the UI dialog (created using Qt Designer)
        self.ui = Ui_gridDialog()
        self.ui.setupUi(self)

        # set modal
        self.setWindowModality(QtCore.Qt.ApplicationModal)

        v = self.ui.gridView
        v._page.setLinkHandler(self)
        self.keyPressEvent = self._myKeyHandler

        self.correct = random.randint(
            1,
            GridDlg._gridSize**2)  # e.g. a number from 1 to 4 or 9 (inclusive)
示例#21
0
    def __init__(self):
        mw.addonManager.setWebExports("AnkiEmperor", ".*")

        # 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
        # Keep's track of current view. Useful if we want to update a view, but we're not sure which one
        self.__view = None
        self.deckSelected = False

        # Setup window
        QDialog.__init__(self, mw, Qt.WindowTitleHint)
        self.setWindowTitle(getPluginName())
        self.resize(300, 800)
        gui_hooks.reviewer_did_answer_card.append(self.answerCard)
        gui_hooks.webview_did_receive_js_message.append(self.links)
        self.open_main()

        # Wrap Anki methods

        # This should probably be handled better
        # Should each view have its own call to did_receive_js_message?
        # FIXME Investigate if there are native versions of these functions..
        _Collection.undo = wrap(_Collection.undo, self.undo)
        DeckManager.select = wrap(DeckManager.select, self.refreshSettings)

        # Add AnkiEmperor to the Anki menu
        action = QAction(getPluginName(), mw)
        action.triggered.connect(self.show)
        # mw.connect(action, SIGNAL("triggered()"), self.show)
        mw.form.menuTools.addAction(action)
示例#22
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_()
示例#23
0
    def __init__(self, toolbar, expression):
        QDialog.__init__(self)
        self.selectDialog = Ui_selectDialog()
        self.selectDialog.setupUi(self)

        self.dictionary = toolbar.dictionary
        self.editor = toolbar.editor

        # Using custom delegate to render sentences in color
        self.itemDelegate = HTMLDelegate()
        self.selectDialog.listWidget.setItemDelegate(self.itemDelegate)

        # Find examples and list them
        self.resultsJapanese, self.resultsEnglish = self.dictionary.findExamples(
            expression)
        for sentence in self.resultsJapanese:
            item = QListWidgetItem()
            item.setText(sentence)
            self.selectDialog.listWidget.addItem(item)
示例#24
0
 def __init__(self, mw):
     QDialog.__init__(self, None, Qt.Window)
     mw.setupDialogGC(self)
     self.mw = mw
     self.form = aqt.forms.addcards.Ui_Dialog()
     self.form.setupUi(self)
     self.setWindowTitle(_("Add"))
     self.setMinimumHeight(300)
     self.setMinimumWidth(400)
     self.setupChoosers()
     self.setupEditor()
     self.setupButtons()
     self.onReset()
     self.history = []
     restoreGeom(self, "add")
     addHook('reset', self.onReset)
     addHook('currentModelChanged', self.onModelChange)
     addCloseShortcut(self)
     self.show()
    def __init__(self, collection, note_id_list, old_model=None, parent=None):
        QDialog.__init__(self, parent)
        self.collection = collection
        self.note_id_list = note_id_list
        self.old_model = old_model
        if self.old_model is None:
            first_note = Note(collection, id=note_id_list[0])
            self.old_model = first_note.model()

        # todo consider extracting UI file
        self.form = aqt.forms.changemodel.Ui_Dialog()
        self.form.setupUi(self)
        self.setWindowModality(Qt.WindowModal)
        self.setup()

        self.pauseUpdate = False
        self.model_changed(self.collection.models.current())

        aqt.utils.restoreGeom(self, "changeModel")
        anki.hooks.addHook("reset", self.on_reset)
        anki.hooks.addHook("currentModelChanged", self.on_reset)
示例#26
0
 def __init__(self, mw):
     QDialog.__init__(self, None, Qt.Window)
     mw.setupDialogGC(self)
     self.mw = mw
     self.form = aqt.forms.editcurrent.Ui_Dialog()
     self.form.setupUi(self)
     self.setWindowTitle(_("Edit Current"))
     self.setMinimumHeight(400)
     self.setMinimumWidth(500)
     self.form.buttonBox.button(QDialogButtonBox.Close).setShortcut(
         QKeySequence("Ctrl+Return"))
     self.editor = Editor(self.mw, self.form.fieldsArea, self)
     self.editor.card = self.mw.reviewer.card
     self.editor.setNote(self.mw.reviewer.card.note(), focusTo=0)
     restoreGeom(self, "editcurrent")
     addHook("reset", self.onReset)
     self.mw.requireReset()
     self.show()
     # reset focus after open, taking care not to retain webview
     # pylint: disable=unnecessary-lambda
     self.mw.progress.timer(100, lambda: self.editor.web.setFocus(), False)
示例#27
0
 def __init__(self, mw, note, ord=0, parent=None):
     QDialog.__init__(self, parent or mw)  #, Qt.Window)
     self.mw = aqt.mw
     self.parent = parent or mw
     self.note = note
     self.col = self.mw.col
     self.mm = self.mw.col.models
     self.model = note.model()
     self.mw.checkpoint(_("Fields"))
     self.form = aqt.forms.fields.Ui_Dialog()
     self.form.setupUi(self)
     self.setWindowTitle(_("Fields for %s") % self.model['name'])
     self.form.buttonBox.button(QDialogButtonBox.Help).setAutoDefault(False)
     self.form.buttonBox.button(
         QDialogButtonBox.Close).setAutoDefault(False)
     self.currentIdx = None
     self.oldSortField = self.model['sortf']
     self.fillFields()
     self.setupSignals()
     self.form.fieldList.setCurrentRow(0)
     self.exec_()
示例#28
0
 def __init__(self, mw):
     if not mw.col:
         showInfo(_("Please open a profile first."))
         return
     QDialog.__init__(self, mw, Qt.Window)
     self.mw = mw
     self.prof = self.mw.pm.profile
     self.form = aqt.forms.preferences.Ui_Preferences()
     self.form.setupUi(self)
     self.form.buttonBox.button(QDialogButtonBox.Help).setAutoDefault(False)
     self.form.buttonBox.button(
         QDialogButtonBox.Close).setAutoDefault(False)
     self.form.buttonBox.helpRequested.connect(
         lambda: openHelp("profileprefs"))
     self.silentlyClose = True
     self.setupLang()
     self.setupCollection()
     self.setupNetwork()
     self.setupBackup()
     self.setupOptions()
     self.show()
示例#29
0
    def __init__(self, collection, note_id_list, old_model=None, parent=None):
        QDialog.__init__(self, parent)
        self.collection = collection
        self.note_id_list = note_id_list
        self.old_model = old_model
        if self.old_model is None:
            first_note = Note(collection, id=note_id_list[0])
            self.old_model = first_note.model()

        # todo consider extracting UI file
        self.form = aqt.forms.changemodel.Ui_Dialog()
        self.form.setupUi(self)
        self.setWindowModality(Qt.WindowModal)
        self.setup()

        self.pauseUpdate = False
        self.model_changed(self.collection.models.current())

        aqt.utils.restoreGeom(self, "changeModel")
        anki.hooks.addHook("reset", self.on_reset)
        anki.hooks.addHook("currentModelChanged", self.on_reset)
示例#30
0
文件: clayout.py 项目: solarmist/anki
 def __init__(self, mw, note, ord=0, parent=None, addMode=False):
     QDialog.__init__(self, parent or mw, Qt.Window)
     mw.setupDialogGC(self)
     self.mw = aqt.mw
     self.parent = parent or mw
     self.note = note
     self.ord = ord
     self.col = self.mw.col
     self.mm = self.mw.col.models
     self.model = note.model()
     self.mw.checkpoint(_("Card Types"))
     self.addMode = addMode
     if addMode:
         # save it to DB temporarily
         self.emptyFields = []
         for name, val in list(note.items()):
             if val.strip():
                 continue
             self.emptyFields.append(name)
             note[name] = "(%s)" % name
         note.flush()
     self.setupTopArea()
     self.setupMainArea()
     self.setupButtons()
     self.setupShortcuts()
     self.setWindowTitle(_("Card Types for %s") % self.model['name'])
     v1 = QVBoxLayout()
     v1.addWidget(self.topArea)
     v1.addWidget(self.mainArea)
     v1.addLayout(self.buttons)
     v1.setContentsMargins(12,12,12,12)
     self.setLayout(v1)
     self.redraw()
     restoreGeom(self, "CardLayout")
     self.setWindowModality(Qt.ApplicationModal)
     self.show()
     # take the focus away from the first input area when starting up,
     # as users tend to accidentally type into the template
     self.setFocus()
示例#31
0
 def __init__(self, mw, model, current):
     QDialog.__init__(self, mw, Qt.Window)
     self.mw = mw
     self.model = model
     self.frm = aqt.forms.changemap.Ui_ChangeMap()
     self.frm.setupUi(self)
     n = 0
     setCurrent = False
     for field in self.model['flds']:
         item = QListWidgetItem(_("Map to %s") % field['name'])
         self.frm.fields.addItem(item)
         if current == field['name']:
             setCurrent = True
             self.frm.fields.setCurrentRow(n)
         n += 1
     self.frm.fields.addItem(QListWidgetItem(_("Map to Tags")))
     self.frm.fields.addItem(QListWidgetItem(_("Ignore field")))
     if not setCurrent:
         if current == "_tags":
             self.frm.fields.setCurrentRow(n)
         else:
             self.frm.fields.setCurrentRow(n + 1)
     self.field = None
示例#32
0
 def __init__(self, mw, importer):
     QDialog.__init__(self, mw, Qt.Window)
     self.mw = mw
     self.importer = importer
     self.frm = aqt.forms.importing.Ui_ImportDialog()
     self.frm.setupUi(self)
     self.frm.buttonBox.button(QDialogButtonBox.Help).clicked.connect(
         self.helpRequested)
     self.setupMappingFrame()
     self.setupOptions()
     self.modelChanged()
     self.frm.autoDetect.setVisible(self.importer.needDelimiter)
     addHook("currentModelChanged", self.modelChanged)
     self.frm.autoDetect.clicked.connect(self.onDelimiter)
     self.updateDelimiterButtonText()
     self.frm.allowHTML.setChecked(self.mw.pm.profile.get(
         'allowHTML', True))
     self.frm.importMode.setCurrentIndex(
         self.mw.pm.profile.get('importMode', 1))
     # import button
     b = QPushButton(_("Import"))
     self.frm.buttonBox.addButton(b, QDialogButtonBox.AcceptRole)
     self.exec_()