remember window size for deck&model selection (#931)

This commit is contained in:
Damien Elmes 2013-09-20 14:51:12 +09:00
parent 2fff30db2f
commit 7eabc36468
3 changed files with 7 additions and 4 deletions

View File

@ -76,7 +76,7 @@ class DeckChooser(QHBoxLayout):
ret = StudyDeck( ret = StudyDeck(
self.mw, current=current, accept=_("Choose"), self.mw, current=current, accept=_("Choose"),
title=_("Choose Deck"), help="addingnotes", title=_("Choose Deck"), help="addingnotes",
cancel=False, parent=self.widget) cancel=False, parent=self.widget, geomKey="selectDeck")
self.deck.setText(ret.name) self.deck.setText(ret.name)
def selectedId(self): def selectedId(self):

View File

@ -69,7 +69,7 @@ class ModelChooser(QHBoxLayout):
self.mw, names=nameFunc, self.mw, names=nameFunc,
accept=_("Choose"), title=_("Choose Note Type"), accept=_("Choose"), title=_("Choose Note Type"),
help="_notes", current=current, parent=self.widget, help="_notes", current=current, parent=self.widget,
buttons=[edit], cancel=True) buttons=[edit], cancel=True, geomKey="selectModel")
if not ret.name: if not ret.name:
return return
m = self.deck.models.byName(ret.name) m = self.deck.models.byName(ret.name)

View File

@ -4,13 +4,13 @@
from aqt.qt import * from aqt.qt import *
import aqt import aqt
from aqt.utils import showInfo, openHelp, getOnlyText, shortcut from aqt.utils import showInfo, openHelp, getOnlyText, shortcut, restoreGeom, saveGeom
from anki.hooks import addHook, remHook from anki.hooks import addHook, remHook
class StudyDeck(QDialog): class StudyDeck(QDialog):
def __init__(self, mw, names=None, accept=None, title=None, def __init__(self, mw, names=None, accept=None, title=None,
help="studydeck", current=None, cancel=True, help="studydeck", current=None, cancel=True,
parent=None, dyn=False, buttons=[]): parent=None, dyn=False, buttons=[], geomKey="default"):
QDialog.__init__(self, parent or mw) QDialog.__init__(self, parent or mw)
self.mw = mw self.mw = mw
self.form = aqt.forms.studydeck.Ui_Dialog() self.form = aqt.forms.studydeck.Ui_Dialog()
@ -18,6 +18,8 @@ class StudyDeck(QDialog):
self.form.filter.installEventFilter(self) self.form.filter.installEventFilter(self)
self.cancel = cancel self.cancel = cancel
addHook('reset', self.onReset) addHook('reset', self.onReset)
self.geomKey = "studyDeck-"+geomKey
restoreGeom(self, self.geomKey)
if not cancel: if not cancel:
self.form.buttonBox.removeButton( self.form.buttonBox.removeButton(
self.form.buttonBox.button(QDialogButtonBox.Cancel)) self.form.buttonBox.button(QDialogButtonBox.Cancel))
@ -106,6 +108,7 @@ class StudyDeck(QDialog):
self.redraw(self.filt, self.focus) self.redraw(self.filt, self.focus)
def accept(self): def accept(self):
saveGeom(self, self.geomKey)
remHook('reset', self.onReset) remHook('reset', self.onReset)
row = self.form.list.currentRow() row = self.form.list.currentRow()
if row < 0: if row < 0: