diff --git a/ankiqt/ui/activetags.py b/ankiqt/ui/activetags.py index ec6a10caf..0e60f649b 100644 --- a/ankiqt/ui/activetags.py +++ b/ankiqt/ui/activetags.py @@ -5,6 +5,7 @@ from PyQt4.QtGui import * from PyQt4.QtCore import * import ankiqt from anki.utils import parseTags, joinTags +from ankiqt.ui.utils import saveGeom, restoreGeom class ActiveTagsChooser(QDialog): @@ -16,7 +17,7 @@ class ActiveTagsChooser(QDialog): self.connect(self.dialog.buttonBox, SIGNAL("helpRequested()"), self.onHelp) self.rebuildTagList() - + restoreGeom(self, "activeTags") def rebuildTagList(self): self.tags = self.parent.deck.allTags() @@ -47,6 +48,7 @@ class ActiveTagsChooser(QDialog): self.parent.deck.suspended = joinTags(suspended + ["Suspended"]) self.parent.deck.setModified() self.parent.reset() + saveGeom(self, "activeTags") QDialog.accept(self) def onHelp(self): diff --git a/ankiqt/ui/addcards.py b/ankiqt/ui/addcards.py index a0324e6f5..804950a87 100644 --- a/ankiqt/ui/addcards.py +++ b/ankiqt/ui/addcards.py @@ -9,6 +9,7 @@ import anki from anki.facts import Fact from anki.errors import * from anki.utils import stripHTML +from ankiqt.ui.utils import saveGeom, restoreGeom from ankiqt import ui class AddCards(QDialog): @@ -25,6 +26,7 @@ class AddCards(QDialog): self.setupStatus() self.modelChanged(self.parent.deck.currentModel) self.addedItems = 0 + restoreGeom(self, "add") self.show() ui.dialogs.open("AddCards", self) @@ -117,6 +119,7 @@ class AddCards(QDialog): ui.dialogs.close("AddCards") self.parent.deck.s.flush() self.parent.moveToState("auto") + saveGeom(self, "add") return True else: return False diff --git a/ankiqt/ui/cardlist.py b/ankiqt/ui/cardlist.py index 498859040..601acfe2e 100644 --- a/ankiqt/ui/cardlist.py +++ b/ankiqt/ui/cardlist.py @@ -12,6 +12,7 @@ from anki.cards import cardsTable, Card from anki.facts import factsTable, fieldsTable, Fact from anki.utils import fmtTimeSpan, parseTags, findTag, addTags, deleteTags, \ stripHTML +from ankiqt.ui.utils import saveGeom, restoreGeom from anki.errors import * from anki.db import * @@ -249,6 +250,7 @@ class EditDeck(QDialog): ui.dialogs.open("CardList", self) self.drawTags() self.updateFilterLabel() + restoreGeom(self, "editor") self.show() self.selectLastCard() @@ -638,4 +640,5 @@ where id in (%s)""" % ",".join([ QDialog.accept(self) def reject(self): + saveGeom(self, "editor") self.accept() diff --git a/ankiqt/ui/deckproperties.py b/ankiqt/ui/deckproperties.py index 7464afe2c..4969d8ff2 100644 --- a/ankiqt/ui/deckproperties.py +++ b/ankiqt/ui/deckproperties.py @@ -143,6 +143,12 @@ class DeckProperties(QDialog): ui.utils.showWarning(_("Please add another model first."), parent=self) return + if self.d.s.scalar("select 1 from sources where id=:id", + id=model.source): + ui.utils.showWarning(_("This model is used by deck source:\n" + "%s\nYou will need to remove the source " + "first.") % hexifyID(model.source)) + return count = self.d.modelUseCount(model) if count: if not ui.utils.askUser( diff --git a/ankiqt/ui/graphs.py b/ankiqt/ui/graphs.py index b58664840..2520ab55a 100644 --- a/ankiqt/ui/graphs.py +++ b/ankiqt/ui/graphs.py @@ -6,12 +6,13 @@ from PyQt4.QtCore import * import sys import anki, anki.graphs, anki.utils from ankiqt import ui +from ankiqt.ui.utils import saveGeom, restoreGeom from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas from matplotlib import rc rc('font', **{'sans-serif': 'Arial', 'serif': 'Arial', - 'size': 20.0}) + 'size': 14.0}) rc('legend', fontsize=14.0) class AnkiFigureCanvas (FigureCanvas): @@ -29,7 +30,7 @@ class AnkiFigureCanvas (FigureCanvas): def sizeHint(self): w, h = self.get_width_height() - return QSize(w, h) + return QSize(w+30, h+30) def minimumSizeHint(self): return QSize(10, 10) @@ -123,6 +124,7 @@ class IntervalGraph(QDialog): self.setAttribute(Qt.WA_DeleteOnClose) def reject(self): + saveGeom(self, "graphs") ui.dialogs.close("Graphs") QDialog.reject(self) @@ -130,11 +132,14 @@ def intervalGraph(parent, deck): dg = anki.graphs.DeckGraphs(deck) # dialog setup d = IntervalGraph(parent) - d.setWindowTitle(_("Deck graphs")) - if sys.platform.startswith("darwin"): - d.setMinimumSize(740, 680) + d.setWindowTitle(_("Deck Graphs")) + if parent.config.get('graphsGeom'): + restoreGeom(d, "graphs") else: - d.setMinimumSize(670, 715) + if sys.platform.startswith("darwin"): + d.setMinimumSize(740, 680) + else: + d.setMinimumSize(670, 715) scroll = QScrollArea(d) topBox = QVBoxLayout(d) topBox.addWidget(scroll) diff --git a/ankiqt/ui/utils.py b/ankiqt/ui/utils.py index 807201b51..41ea606f9 100644 --- a/ankiqt/ui/utils.py +++ b/ankiqt/ui/utils.py @@ -65,3 +65,12 @@ def getSaveFile(parent, title, dir, key, ext): parent): return None return file + +def saveGeom(widget, key): + key += "Geom" + ankiqt.mw.config[key] = widget.saveGeometry() + +def restoreGeom(widget, key): + key += "Geom" + if ankiqt.mw.config.get(key): + widget.restoreGeometry(ankiqt.mw.config[key]) diff --git a/designer/deckproperties.ui b/designer/deckproperties.ui index 159662e4a..5c63d8b4f 100644 --- a/designer/deckproperties.ui +++ b/designer/deckproperties.ui @@ -86,6 +86,9 @@ p, li { white-space: pre-wrap; } &Add Source + + false + @@ -93,6 +96,9 @@ p, li { white-space: pre-wrap; } &Delete Source + + false +