mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
save geometry of other windows, prevent deletion of shared models
This commit is contained in:
parent
ec932d6f39
commit
ea666975f9
7 changed files with 41 additions and 7 deletions
|
@ -5,6 +5,7 @@ from PyQt4.QtGui import *
|
||||||
from PyQt4.QtCore import *
|
from PyQt4.QtCore import *
|
||||||
import ankiqt
|
import ankiqt
|
||||||
from anki.utils import parseTags, joinTags
|
from anki.utils import parseTags, joinTags
|
||||||
|
from ankiqt.ui.utils import saveGeom, restoreGeom
|
||||||
|
|
||||||
class ActiveTagsChooser(QDialog):
|
class ActiveTagsChooser(QDialog):
|
||||||
|
|
||||||
|
@ -16,7 +17,7 @@ class ActiveTagsChooser(QDialog):
|
||||||
self.connect(self.dialog.buttonBox, SIGNAL("helpRequested()"),
|
self.connect(self.dialog.buttonBox, SIGNAL("helpRequested()"),
|
||||||
self.onHelp)
|
self.onHelp)
|
||||||
self.rebuildTagList()
|
self.rebuildTagList()
|
||||||
|
restoreGeom(self, "activeTags")
|
||||||
|
|
||||||
def rebuildTagList(self):
|
def rebuildTagList(self):
|
||||||
self.tags = self.parent.deck.allTags()
|
self.tags = self.parent.deck.allTags()
|
||||||
|
@ -47,6 +48,7 @@ class ActiveTagsChooser(QDialog):
|
||||||
self.parent.deck.suspended = joinTags(suspended + ["Suspended"])
|
self.parent.deck.suspended = joinTags(suspended + ["Suspended"])
|
||||||
self.parent.deck.setModified()
|
self.parent.deck.setModified()
|
||||||
self.parent.reset()
|
self.parent.reset()
|
||||||
|
saveGeom(self, "activeTags")
|
||||||
QDialog.accept(self)
|
QDialog.accept(self)
|
||||||
|
|
||||||
def onHelp(self):
|
def onHelp(self):
|
||||||
|
|
|
@ -9,6 +9,7 @@ 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
|
||||||
|
from ankiqt.ui.utils import saveGeom, restoreGeom
|
||||||
from ankiqt import ui
|
from ankiqt import ui
|
||||||
|
|
||||||
class AddCards(QDialog):
|
class AddCards(QDialog):
|
||||||
|
@ -25,6 +26,7 @@ class AddCards(QDialog):
|
||||||
self.setupStatus()
|
self.setupStatus()
|
||||||
self.modelChanged(self.parent.deck.currentModel)
|
self.modelChanged(self.parent.deck.currentModel)
|
||||||
self.addedItems = 0
|
self.addedItems = 0
|
||||||
|
restoreGeom(self, "add")
|
||||||
self.show()
|
self.show()
|
||||||
ui.dialogs.open("AddCards", self)
|
ui.dialogs.open("AddCards", self)
|
||||||
|
|
||||||
|
@ -117,6 +119,7 @@ class AddCards(QDialog):
|
||||||
ui.dialogs.close("AddCards")
|
ui.dialogs.close("AddCards")
|
||||||
self.parent.deck.s.flush()
|
self.parent.deck.s.flush()
|
||||||
self.parent.moveToState("auto")
|
self.parent.moveToState("auto")
|
||||||
|
saveGeom(self, "add")
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -12,6 +12,7 @@ from anki.cards import cardsTable, Card
|
||||||
from anki.facts import factsTable, fieldsTable, Fact
|
from anki.facts import factsTable, fieldsTable, Fact
|
||||||
from anki.utils import fmtTimeSpan, parseTags, findTag, addTags, deleteTags, \
|
from anki.utils import fmtTimeSpan, parseTags, findTag, addTags, deleteTags, \
|
||||||
stripHTML
|
stripHTML
|
||||||
|
from ankiqt.ui.utils import saveGeom, restoreGeom
|
||||||
from anki.errors import *
|
from anki.errors import *
|
||||||
from anki.db import *
|
from anki.db import *
|
||||||
|
|
||||||
|
@ -249,6 +250,7 @@ class EditDeck(QDialog):
|
||||||
ui.dialogs.open("CardList", self)
|
ui.dialogs.open("CardList", self)
|
||||||
self.drawTags()
|
self.drawTags()
|
||||||
self.updateFilterLabel()
|
self.updateFilterLabel()
|
||||||
|
restoreGeom(self, "editor")
|
||||||
self.show()
|
self.show()
|
||||||
self.selectLastCard()
|
self.selectLastCard()
|
||||||
|
|
||||||
|
@ -638,4 +640,5 @@ where id in (%s)""" % ",".join([
|
||||||
QDialog.accept(self)
|
QDialog.accept(self)
|
||||||
|
|
||||||
def reject(self):
|
def reject(self):
|
||||||
|
saveGeom(self, "editor")
|
||||||
self.accept()
|
self.accept()
|
||||||
|
|
|
@ -143,6 +143,12 @@ class DeckProperties(QDialog):
|
||||||
ui.utils.showWarning(_("Please add another model first."),
|
ui.utils.showWarning(_("Please add another model first."),
|
||||||
parent=self)
|
parent=self)
|
||||||
return
|
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)
|
count = self.d.modelUseCount(model)
|
||||||
if count:
|
if count:
|
||||||
if not ui.utils.askUser(
|
if not ui.utils.askUser(
|
||||||
|
|
|
@ -6,12 +6,13 @@ from PyQt4.QtCore import *
|
||||||
import sys
|
import sys
|
||||||
import anki, anki.graphs, anki.utils
|
import anki, anki.graphs, anki.utils
|
||||||
from ankiqt import ui
|
from ankiqt import ui
|
||||||
|
from ankiqt.ui.utils import saveGeom, restoreGeom
|
||||||
|
|
||||||
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
|
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
|
||||||
from matplotlib import rc
|
from matplotlib import rc
|
||||||
rc('font', **{'sans-serif': 'Arial',
|
rc('font', **{'sans-serif': 'Arial',
|
||||||
'serif': 'Arial',
|
'serif': 'Arial',
|
||||||
'size': 20.0})
|
'size': 14.0})
|
||||||
rc('legend', fontsize=14.0)
|
rc('legend', fontsize=14.0)
|
||||||
|
|
||||||
class AnkiFigureCanvas (FigureCanvas):
|
class AnkiFigureCanvas (FigureCanvas):
|
||||||
|
@ -29,7 +30,7 @@ class AnkiFigureCanvas (FigureCanvas):
|
||||||
|
|
||||||
def sizeHint(self):
|
def sizeHint(self):
|
||||||
w, h = self.get_width_height()
|
w, h = self.get_width_height()
|
||||||
return QSize(w, h)
|
return QSize(w+30, h+30)
|
||||||
|
|
||||||
def minimumSizeHint(self):
|
def minimumSizeHint(self):
|
||||||
return QSize(10, 10)
|
return QSize(10, 10)
|
||||||
|
@ -123,6 +124,7 @@ class IntervalGraph(QDialog):
|
||||||
self.setAttribute(Qt.WA_DeleteOnClose)
|
self.setAttribute(Qt.WA_DeleteOnClose)
|
||||||
|
|
||||||
def reject(self):
|
def reject(self):
|
||||||
|
saveGeom(self, "graphs")
|
||||||
ui.dialogs.close("Graphs")
|
ui.dialogs.close("Graphs")
|
||||||
QDialog.reject(self)
|
QDialog.reject(self)
|
||||||
|
|
||||||
|
@ -130,7 +132,10 @@ def intervalGraph(parent, deck):
|
||||||
dg = anki.graphs.DeckGraphs(deck)
|
dg = anki.graphs.DeckGraphs(deck)
|
||||||
# dialog setup
|
# dialog setup
|
||||||
d = IntervalGraph(parent)
|
d = IntervalGraph(parent)
|
||||||
d.setWindowTitle(_("Deck graphs"))
|
d.setWindowTitle(_("Deck Graphs"))
|
||||||
|
if parent.config.get('graphsGeom'):
|
||||||
|
restoreGeom(d, "graphs")
|
||||||
|
else:
|
||||||
if sys.platform.startswith("darwin"):
|
if sys.platform.startswith("darwin"):
|
||||||
d.setMinimumSize(740, 680)
|
d.setMinimumSize(740, 680)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -65,3 +65,12 @@ def getSaveFile(parent, title, dir, key, ext):
|
||||||
parent):
|
parent):
|
||||||
return None
|
return None
|
||||||
return file
|
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])
|
||||||
|
|
|
@ -86,6 +86,9 @@ p, li { white-space: pre-wrap; }
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>&Add Source</string>
|
<string>&Add Source</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="autoDefault" >
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
@ -93,6 +96,9 @@ p, li { white-space: pre-wrap; }
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>&Delete Source</string>
|
<string>&Delete Source</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="autoDefault" >
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
Loading…
Reference in a new issue