コード例 #1
0
ファイル: editor.py プロジェクト: zlodag/anki
    def setupTags(self):
        import aqt.tagedit

        g = QGroupBox(self.widget)
        g.setStyleSheet("border: 0")
        tb = QGridLayout()
        tb.setSpacing(12)
        tb.setContentsMargins(2, 6, 2, 6)
        # tags
        l = QLabel(_("Tags"))
        tb.addWidget(l, 1, 0)
        self.tags = aqt.tagedit.TagEdit(self.widget)
        qconnect(self.tags.lostFocus, self.saveTags)
        self.tags.setToolTip(shortcut(_("Jump to tags with Ctrl+Shift+T")))
        border = theme_manager.str_color("border")
        self.tags.setStyleSheet(f"border: 1px solid {border}")
        tb.addWidget(self.tags, 1, 1)
        g.setLayout(tb)
        self.outerLayout.addWidget(g)
コード例 #2
0
ファイル: editor.py プロジェクト: yinminshcn/anki
    def setupTags(self):
        import aqt.tagedit

        g = QGroupBox(self.widget)
        g.setStyleSheet("border: 0")
        tb = QGridLayout()
        tb.setSpacing(12)
        tb.setContentsMargins(2, 6, 2, 6)
        # tags
        l = QLabel(tr(TR.EDITING_TAGS))
        tb.addWidget(l, 1, 0)
        self.tags = aqt.tagedit.TagEdit(self.widget)
        qconnect(self.tags.lostFocus, self.saveTags)
        self.tags.setToolTip(
            shortcut(tr(TR.EDITING_JUMP_TO_TAGS_WITH_CTRLANDSHIFTANDT)))
        border = theme_manager.str_color("border")
        self.tags.setStyleSheet(f"border: 1px solid {border}")
        tb.addWidget(self.tags, 1, 1)
        g.setLayout(tb)
        self.outerLayout.addWidget(g)
コード例 #3
0
ファイル: dyndeckconf.py プロジェクト: akanksha20048/anki
    def __init__(
        self,
        mw: AnkiQt,
        search: Optional[str] = None,
        search_2: Optional[str] = None,
        deck: Optional[Deck] = None,
    ) -> None:
        """If 'deck' is an existing filtered deck, load and modify its settings.
        Otherwise, build a new one and derive settings from the current deck.
        """

        QDialog.__init__(self, mw)
        self.mw = mw
        self.did: Optional[int] = None
        self.form = aqt.forms.dyndconf.Ui_Dialog()
        self.form.setupUi(self)
        self.mw.checkpoint(tr(TR.ACTIONS_OPTIONS))
        self.initialSetup()
        self.old_deck = self.mw.col.decks.current()

        if deck and deck["dyn"]:
            # modify existing dyn deck
            label = tr(TR.ACTIONS_REBUILD)
            self.deck = deck
            self.loadConf()
        elif self.old_deck["dyn"]:
            # create new dyn deck from other dyn deck
            label = tr(TR.DECKS_BUILD)
            self.loadConf(deck=self.old_deck)
            self.new_dyn_deck()
        else:
            # create new dyn deck from regular deck
            label = tr(TR.DECKS_BUILD)
            self.new_dyn_deck()
            self.loadConf()
            self.set_default_searches(self.old_deck["name"])

        self.form.name.setText(self.deck["name"])
        self.form.name.setPlaceholderText(self.deck["name"])
        self.set_custom_searches(search, search_2)
        qconnect(self.form.search_button.clicked, self.on_search_button)
        qconnect(self.form.search_button_2.clicked, self.on_search_button_2)
        color = theme_manager.str_color("link")
        self.setStyleSheet(
            f"""QPushButton[flat=true] {{ text-align: left; color: {color}; padding: 0; border: 0 }}
            QPushButton[flat=true]:hover {{ text-decoration: underline }}""")
        disable_help_button(self)
        self.setWindowModality(Qt.WindowModal)
        qconnect(self.form.buttonBox.helpRequested,
                 lambda: openHelp(HelpPage.FILTERED_DECK))
        self.setWindowTitle(
            without_unicode_isolation(
                tr(TR.ACTIONS_OPTIONS_FOR, val=self.deck["name"])))
        self.form.buttonBox.button(QDialogButtonBox.Ok).setText(label)
        self.form.buttonBox.button(QDialogButtonBox.Cancel).setText(
            tr(TR.ACTIONS_CANCEL))
        self.form.buttonBox.button(QDialogButtonBox.Help).setText(
            tr(TR.ACTIONS_HELP))
        if self.mw.col.schedVer() == 1:
            self.form.secondFilter.setVisible(False)
        restoreGeom(self, "dyndeckconf")

        self.show()