mirror of
https://github.com/ankitects/anki.git
synced 2025-12-13 23:00:58 -05:00
fix tag saving, remember added tags without having to reopen, fix ret in add
This commit is contained in:
parent
707ae75bd8
commit
a3ac8e3c0a
4 changed files with 13 additions and 2 deletions
|
|
@ -8,7 +8,7 @@ import ankiqt.forms
|
||||||
import anki
|
import anki
|
||||||
from anki.facts import Fact
|
from anki.facts import Fact
|
||||||
from anki.errors import *
|
from anki.errors import *
|
||||||
from anki.utils import stripHTML
|
from anki.utils import stripHTML, parseTags
|
||||||
from ankiqt.ui.utils import saveGeom, restoreGeom, saveSplitter, restoreSplitter
|
from ankiqt.ui.utils import saveGeom, restoreGeom, saveSplitter, restoreSplitter
|
||||||
from ankiqt import ui
|
from ankiqt import ui
|
||||||
|
|
||||||
|
|
@ -51,14 +51,16 @@ class AddCards(QDialog):
|
||||||
self.dialog.buttonBox.addButton(self.addButton,
|
self.dialog.buttonBox.addButton(self.addButton,
|
||||||
QDialogButtonBox.ActionRole)
|
QDialogButtonBox.ActionRole)
|
||||||
self.addButton.setShortcut(_("Ctrl+Return"))
|
self.addButton.setShortcut(_("Ctrl+Return"))
|
||||||
self.addButton.setDefault(True)
|
self.addButton.setAutoDefault(False)
|
||||||
s = QShortcut(QKeySequence(_("Ctrl+Enter")), self)
|
s = QShortcut(QKeySequence(_("Ctrl+Enter")), self)
|
||||||
s.connect(s, SIGNAL("activated()"), self.addButton, SLOT("click()"))
|
s.connect(s, SIGNAL("activated()"), self.addButton, SLOT("click()"))
|
||||||
self.connect(self.addButton, SIGNAL("clicked()"), self.addCards)
|
self.connect(self.addButton, SIGNAL("clicked()"), self.addCards)
|
||||||
self.closeButton = QPushButton(_("Close"))
|
self.closeButton = QPushButton(_("Close"))
|
||||||
|
self.closeButton.setAutoDefault(False)
|
||||||
self.dialog.buttonBox.addButton(self.closeButton,
|
self.dialog.buttonBox.addButton(self.closeButton,
|
||||||
QDialogButtonBox.RejectRole)
|
QDialogButtonBox.RejectRole)
|
||||||
self.helpButton = QPushButton(_("Help"))
|
self.helpButton = QPushButton(_("Help"))
|
||||||
|
self.helpButton.setAutoDefault(False)
|
||||||
self.dialog.buttonBox.addButton(self.helpButton,
|
self.dialog.buttonBox.addButton(self.helpButton,
|
||||||
QDialogButtonBox.HelpRole)
|
QDialogButtonBox.HelpRole)
|
||||||
self.connect(self.helpButton, SIGNAL("clicked()"), self.helpRequested)
|
self.connect(self.helpButton, SIGNAL("clicked()"), self.helpRequested)
|
||||||
|
|
@ -118,6 +120,8 @@ question or answer on all cards. Can't proceed."""), parent=self)
|
||||||
f = self.parent.deck.newFact()
|
f = self.parent.deck.newFact()
|
||||||
f.tags = self.parent.deck.lastTags
|
f.tags = self.parent.deck.lastTags
|
||||||
self.editor.setFact(f, check=True)
|
self.editor.setFact(f, check=True)
|
||||||
|
# let completer know our extra tags
|
||||||
|
self.editor.tags.addTags(parseTags(self.parent.deck.lastTags))
|
||||||
self.maybeSave()
|
self.maybeSave()
|
||||||
|
|
||||||
def closeEvent(self, evt):
|
def closeEvent(self, evt):
|
||||||
|
|
|
||||||
|
|
@ -359,6 +359,7 @@ class FactEditor(object):
|
||||||
w = self.focusedEdit()
|
w = self.focusedEdit()
|
||||||
if w:
|
if w:
|
||||||
self.onFocusLost(w)
|
self.onFocusLost(w)
|
||||||
|
self.onTagChange()
|
||||||
# ensure valid
|
# ensure valid
|
||||||
self.checkValid()
|
self.checkValid()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ class ModelChooser(QHBoxLayout):
|
||||||
label = QLabel(_("<b>Cards</b>:"))
|
label = QLabel(_("<b>Cards</b>:"))
|
||||||
self.addWidget(label)
|
self.addWidget(label)
|
||||||
self.cards = QPushButton()
|
self.cards = QPushButton()
|
||||||
|
self.cards.setAutoDefault(False)
|
||||||
self.connect(self.cards, SIGNAL("clicked()"), self.onCardChange)
|
self.connect(self.cards, SIGNAL("clicked()"), self.onCardChange)
|
||||||
self.addWidget(self.cards)
|
self.addWidget(self.cards)
|
||||||
self.drawCardModels()
|
self.drawCardModels()
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,11 @@ class TagEdit(QLineEdit):
|
||||||
self.model.setStringList(
|
self.model.setStringList(
|
||||||
QStringList(tags))
|
QStringList(tags))
|
||||||
|
|
||||||
|
def addTags(self, tags):
|
||||||
|
l = list(set([unicode(x) for x in list(self.model.stringList())] +
|
||||||
|
tags))
|
||||||
|
self.model.setStringList(QStringList(l))
|
||||||
|
|
||||||
def focusOutEvent(self, evt):
|
def focusOutEvent(self, evt):
|
||||||
QLineEdit.focusOutEvent(self, evt)
|
QLineEdit.focusOutEvent(self, evt)
|
||||||
self.emit(SIGNAL("lostFocus"))
|
self.emit(SIGNAL("lostFocus"))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue