diff --git a/ankiqt/ui/importing.py b/ankiqt/ui/importing.py index 1cdb9c31e..24ac6e976 100644 --- a/ankiqt/ui/importing.py +++ b/ankiqt/ui/importing.py @@ -48,6 +48,9 @@ class ImportDialog(QDialog): self.parent = parent self.dialog = ankiqt.forms.importing.Ui_ImportDialog() self.dialog.setupUi(self) + self.tags = ui.tagedit.TagEdit(parent) + self.tags.setDeck(parent.deck) + self.dialog.topGrid.addWidget(self.tags,2,1,1,1) self.setupMappingFrame() self.setupOptions() self.exec_() @@ -111,7 +114,7 @@ class ImportDialog(QDialog): # windows sometimes has pending events permanently? break self.importer.mapping = self.mapping - self.importer.tagsToAdd = unicode(self.dialog.tags.text()) + self.importer.tagsToAdd = unicode(self.tags.text()) self.importer.tagDuplicates = self.dialog.tagDuplicates.isChecked() try: n = _("Import") diff --git a/ankiqt/ui/lookup.py b/ankiqt/ui/lookup.py index 38deb9364..8041177a3 100644 --- a/ankiqt/ui/lookup.py +++ b/ankiqt/ui/lookup.py @@ -24,7 +24,6 @@ class Lookup(object): return text = text.strip() if not text: - u ui.utils.showInfo(_("Empty selection.")) return function(text) @@ -44,7 +43,6 @@ class Lookup(object): else: baseUrl += "E" url = baseUrl + urllib.quote(text.encode("utf-8")) - ui.utils.showInfo(_("Looking %s up on edict...") % text) qurl = QUrl() qurl.setEncodedUrl(url) QDesktopServices.openUrl(qurl) @@ -56,7 +54,6 @@ class Lookup(object): "http://eow.alc.co.jp/" + newText + "/UTF-8/?ref=sa") - ui.utils.showInfo(_("Looking %s up on ALC...") % text) qurl = QUrl() qurl.setEncodedUrl(url) QDesktopServices.openUrl(qurl) diff --git a/ankiqt/ui/main.py b/ankiqt/ui/main.py index 9c2cea346..3c4db34ad 100644 --- a/ankiqt/ui/main.py +++ b/ankiqt/ui/main.py @@ -162,7 +162,6 @@ An error occurred. Please copy the following message into a bug report.\n\n""" + self.lastCard = None self.editor.deck = self.deck if self.deck: - self.mainWin.menu_Lookup.setEnabled(True) self.enableDeckMenuItems() self.updateRecentFilesMenu() self.updateViews(state) @@ -210,11 +209,9 @@ An error occurred. Please copy the following message into a bug report.\n\n""" + elif state == "deckEmpty": self.showWelcomeScreen() self.disableCardMenuItems() - self.mainWin.menu_Lookup.setEnabled(False) elif state == "deckFinished": self.deck.s.flush() self.hideButtons() - self.mainWin.menu_Lookup.setEnabled(False) self.disableCardMenuItems() self.startRefreshTimer() self.bodyView.setState(state) @@ -865,14 +862,14 @@ Error was:\n%s\n...\n%s""") % (fmt1, fmt2)) try: self.lookup.alc(self.currentCard.fact['Expression']) except KeyError: - self.setStatus(_("No expression in current card.")) + ui.utils.showInfo(_("No expression in current card.")) def onLookupMeaning(self): self.initLookup() try: self.lookup.alc(self.currentCard.fact['Meaning']) except KeyError: - self.setStatus(_("No meaning in current card.")) + ui.utils.showInfo(_("No meaning in current card.")) def onLookupEdictSelection(self): self.initLookup() @@ -982,6 +979,13 @@ Error was:\n%s\n...\n%s""") % (fmt1, fmt2)) self.reset() self.deck.setUndoEnd(undo) + def onDelete(self): + undo = _("Delete") + self.deck.setUndoStart(undo) + self.deck.deleteCard(self.currentCard.id) + self.reset() + self.deck.setUndoEnd(undo) + def onUndo(self): self.deck.undo() self.reset(count=False) @@ -1258,7 +1262,6 @@ Error was:\n%s\n...\n%s""") % (fmt1, fmt2)) "Undo", "Redo", "Export", - "MarkCard", "Graphs", "Dstats", "Kstats", @@ -1270,6 +1273,7 @@ Error was:\n%s\n...\n%s""") % (fmt1, fmt2)) "Tools", "Advanced", "Plugins", + "Current", ) def connectMenuActions(self): @@ -1307,6 +1311,7 @@ Error was:\n%s\n...\n%s""") % (fmt1, fmt2)) self.connect(m.actionExport, s, self.onExport) self.connect(m.actionMarkCard, SIGNAL("toggled(bool)"), self.onMark) self.connect(m.actionSuspendCard, s, self.onSuspend) + self.connect(m.actionDelete, s, self.onDelete) self.connect(m.actionModelProperties, s, self.onModelProperties) self.connect(m.actionRepeatAudio, s, self.onRepeatAudio) self.connect(m.actionUndo, s, self.onUndo) @@ -1374,20 +1379,41 @@ Error was:\n%s\n...\n%s""") % (fmt1, fmt2)) def disableCardMenuItems(self): self.maybeEnableUndo() - self.mainWin.actionMarkCard.setEnabled(False) - self.mainWin.actionSuspendCard.setEnabled(False) - self.mainWin.actionRepeatAudio.setEnabled(False) - self.mainWin.actionEditCurrent.setEnabled(False) + self.maybeShowLookup(False) + self.maybeShowKanjiStats() + self.mainWin.menuCurrent.setEnabled(False) def enableCardMenuItems(self): self.maybeEnableUndo() - self.mainWin.actionMarkCard.setEnabled(True) - self.mainWin.actionSuspendCard.setEnabled(True) + self.maybeShowLookup(True) + self.maybeShowKanjiStats() snd = (hasSound(self.currentCard.question) or (hasSound(self.currentCard.answer) and self.state != "getQuestion")) self.mainWin.actionRepeatAudio.setEnabled(snd) - self.mainWin.actionEditCurrent.setEnabled(True) + self.mainWin.menuCurrent.setEnabled(True) + + def maybeShowKanjiStats(self): + if not self.deck: + have = False + else: + if getattr(self.deck, "haveJapanese", None) is None: + self.deck.haveJapanese = False + if self.deck: + for m in self.deck.models: + if "Japanese" in m.tags: + self.deck.haveJapanese = True + break + have = self.deck.haveJapanese + self.mainWin.actionKstats.setVisible(have) + + def maybeShowLookup(self, enable): + if (self.currentCard and + "Japanese" in self.currentCard.fact.model.tags): + self.mainWin.menu_Lookup.menuAction().setVisible(True) + else: + self.mainWin.menu_Lookup.menuAction().setVisible(False) + self.mainWin.menu_Lookup.setEnabled(enable) def maybeEnableUndo(self): if self.deck and self.deck.undoAvailable(): diff --git a/designer/importing.ui b/designer/importing.ui index 12743c976..2811d3e58 100644 --- a/designer/importing.ui +++ b/designer/importing.ui @@ -22,36 +22,15 @@ 6 - - 9 - - - 9 - - - 9 - - + 9 - - + + 0 - - 0 - - - 0 - - - 0 - - - 6 - - + 6 @@ -95,9 +74,6 @@ - - - @@ -128,36 +104,15 @@ 6 - - 9 - - - 9 - - - 9 - - + 9 - + 0 - - 0 - - - 0 - - - 0 - - - 6 - - + 6 @@ -197,16 +152,7 @@ 6 - - 9 - - - 9 - - - 9 - - + 9 @@ -234,7 +180,6 @@ type file - tags tagDuplicates importButton status diff --git a/designer/main.ui b/designer/main.ui index e30e2c5c5..c2651a10e 100644 --- a/designer/main.ui +++ b/designer/main.ui @@ -737,7 +737,7 @@ - + &Current @@ -750,7 +750,7 @@ - +