diff --git a/aqt/addcards.py b/aqt/addcards.py
index f75049e1e..ad43e1c37 100644
--- a/aqt/addcards.py
+++ b/aqt/addcards.py
@@ -19,23 +19,27 @@ import aqt.editor, aqt.modelchooser
class AddCards(QDialog):
def __init__(self, mw):
- windParent = None
QDialog.__init__(self, mw)
self.mw = mw
self.form = aqt.forms.addcards.Ui_Dialog()
self.form.setupUi(self)
- self.setWindowModality(Qt.WindowModal)
+ #self.setWindowModality(Qt.WindowModal)
self.setWindowTitle(_("Add"))
+ self.setMinimumHeight(400)
+ self.setMinimumWidth(500)
self.setupChooser()
self.setupEditor()
self.setupButtons()
self.onReset()
self.history = []
self.forceClose = False
- restoreGeom(self, "add")
+ #restoreGeom(self, "add")
addHook('reset', self.onReset)
self.setupNewFact()
- self.show()
+ self.open()
+
+ def focusOutEvent(self, evt):
+ print "focus lost"
def setupEditor(self):
self.editor = aqt.editor.Editor(self.mw, self.form.fieldsArea)
diff --git a/aqt/deckopts.py b/aqt/deckopts.py
index b787c351f..2694749d5 100644
--- a/aqt/deckopts.py
+++ b/aqt/deckopts.py
@@ -5,6 +5,7 @@ from PyQt4.QtGui import *
from PyQt4.QtCore import *
import sys, re
import aqt
+from aqt.utils import maybeHideClose
class DeckOptions(QDialog):
@@ -22,6 +23,7 @@ class DeckOptions(QDialog):
self.form.buttonBox.button(QDialogButtonBox.Close).setAutoDefault(False)
self.connect(self.form.buttonBox, SIGNAL("helpRequested()"),
self.helpRequested)
+ maybeHideClose(self.form.buttonBox)
# syncing
self.form.doSync.setChecked(self.d.syncingEnabled())
self.form.mediaURL.setText(self.d.conf['mediaURL'])
diff --git a/aqt/editcurrent.py b/aqt/editcurrent.py
index a683c7b1a..c1795f81a 100644
--- a/aqt/editcurrent.py
+++ b/aqt/editcurrent.py
@@ -2,44 +2,37 @@
# -*- coding: utf-8 -*-
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
- # get a fact for testing
- #fact = self.mw.deck.getFact(3951)
- #self.editor.setFact(fact)
+from PyQt4.QtGui import *
+from PyQt4.QtCore import *
+import aqt.editor
+from aqt.utils import saveGeom, restoreGeom
-class EditCurrent(object):
+class EditCurrent(QDialog):
def __init__(self, mw):
+ QDialog.__init__(self, mw)
self.mw = mw
+ self.form = aqt.forms.editcurrent.Ui_Dialog()
+ self.form.setupUi(self)
+ self.setWindowModality(Qt.WindowModal)
+ self.setWindowTitle(_("Edit Current"))
+ self.setMinimumHeight(400)
+ self.setMinimumWidth(500)
+ self.connect(self.form.buttonBox.button(QDialogButtonBox.Save),
+ SIGNAL("clicked()"),
+ self.onSave)
+ self.connect(self,
+ SIGNAL("rejected()"),
+ self.onSave)
+ self.editor = aqt.editor.Editor(self.mw, self.form.fieldsArea)
+ self.editor.setFact(self.mw.reviewer.card.fact())
+ restoreGeom(self, "editcurrent")
+ self.show()
- def _editCurrentState(self, oldState):
- if self.lastState == "editCurrentFact":
- return self.moveToState("saveEdit")
- self.form.actionRepeatAudio.setEnabled(False)
- self.deck.db.flush()
- self.showEditor()
-
- def _saveEditState(self, oldState):
- self.form.actionRepeatAudio.setEnabled(True)
- self.editor.saveFieldsNow()
- self.form.buttonStack.show()
- return self.reset()
-
- # Edit current fact
- ##########################################################################
-
- def setupEditor(self):
- print "setupeditor"
- return
- self.editor = aqt.facteditor.FactEditor(
- self, self.form.fieldsArea, self.deck)
- self.editor.clayout.setShortcut("")
- self.editor.resetOnEdit = False
- # editor
- self.connect(self.form.saveEditorButton, SIGNAL("clicked()"),
- lambda: self.moveToState("saveEdit"))
-
- def showEditor(self):
- self.form.buttonStack.hide()
- self.switchToEditScreen()
- self.editor.setFact(self.currentCard.fact)
- self.editor.card = self.currentCard
+ def onSave(self):
+ self.editor.saveNow()
+ self.editor.setFact(None)
+ self.mw.reviewer.card.load()
+ self.mw.reviewer.showQuestion()
+ saveGeom(self, "editcurrent")
+ self.close()
diff --git a/aqt/groups.py b/aqt/groups.py
index 44811dd76..7c3f8a3be 100644
--- a/aqt/groups.py
+++ b/aqt/groups.py
@@ -5,7 +5,7 @@
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import aqt
-from aqt.utils import showInfo, getOnlyText
+from aqt.utils import showInfo, getOnlyText, maybeHideClose
COLNAME = 0
COLOPTS = 1
@@ -78,6 +78,7 @@ class Groups(QDialog):
self.connect(self.form.buttonBox,
SIGNAL("helpRequested()"),
lambda: aqt.openHelp("Groups"))
+ maybeHideClose(box)
def onSelectAll(self):
for i in self.items:
diff --git a/aqt/main.py b/aqt/main.py
index cc28dcfb1..703263a88 100755
--- a/aqt/main.py
+++ b/aqt/main.py
@@ -81,7 +81,6 @@ class AnkiQt(QMainWindow):
self.setupDeckBrowser()
self.setupOverview()
self.setupReviewer()
- self.setupEditor()
# State machine
##########################################################################
@@ -254,10 +253,6 @@ title="%s">%s''' % (
from aqt.reviewer import Reviewer
self.reviewer = Reviewer(self)
- def setupEditor(self):
- from aqt.editcurrent import EditCurrent
- self.editor = EditCurrent(self)
-
# Upgrading from previous versions
##########################################################################
@@ -671,7 +666,8 @@ Debug info:\n%s""") % traceback.format_exc(), help="DeckErrors")
aqt.dialogs.open("Browser", self)
def onEditCurrent(self):
- self.moveToState("editCurrentFact")
+ from aqt.editcurrent import EditCurrent
+ EditCurrent(self)
def setupCardStats(self):
import aqt.stats
diff --git a/aqt/models.py b/aqt/models.py
index 4723ae7e4..6b2563d46 100644
--- a/aqt/models.py
+++ b/aqt/models.py
@@ -3,7 +3,7 @@
from PyQt4.QtGui import *
from PyQt4.QtCore import *
-from aqt.utils import showInfo, askUser, getText
+from aqt.utils import showInfo, askUser, getText, maybeHideClose
import aqt.modelchooser, aqt.clayout
class Models(QDialog):
@@ -17,6 +17,7 @@ class Models(QDialog):
self.form.setupUi(self)
self.connect(self.form.buttonBox, SIGNAL("helpRequested()"),
lambda: aqt.openHelp("Models"))
+ maybeHideClose(self.form.buttonBox)
self.setupModels()
self.exec_()
diff --git a/aqt/reviewer.py b/aqt/reviewer.py
index 662182abc..cb0113553 100644
--- a/aqt/reviewer.py
+++ b/aqt/reviewer.py
@@ -138,12 +138,12 @@ $(".ansbut").focus();
def _initWeb(self):
self.web.stdHtml(self._revHtml % dict(
showans=_("Show Answer")), self._styles(),
- loadCB=lambda x: self._showQuestion())
+ loadCB=lambda x: self.showQuestion())
# Showing the question (and preparing answer)
##########################################################################
- def _showQuestion(self):
+ def showQuestion(self):
# fixme: timeboxing
# fixme: timer
self.state = "question"
diff --git a/aqt/stats.py b/aqt/stats.py
index 57686e500..52ef6bc53 100644
--- a/aqt/stats.py
+++ b/aqt/stats.py
@@ -6,7 +6,7 @@ from PyQt4.QtGui import *
from PyQt4.QtCore import *
import os, tempfile
from aqt.webview import AnkiWebView
-from aqt.utils import saveGeom, restoreGeom
+from aqt.utils import saveGeom, restoreGeom, maybeHideClose
from anki.hooks import addHook
import aqt
@@ -88,6 +88,7 @@ class DeckStats(QDialog):
c(f.year, s, lambda: self.changePeriod(1))
c(f.life, s, lambda: self.changePeriod(2))
c(f.web, SIGNAL("loadFinished(bool)"), self.loadFin)
+ maybeHideClose(self.form.buttonBox)
self.refresh()
self.exec_()
diff --git a/aqt/studyopts.py b/aqt/studyopts.py
index d1d2961af..5241d3887 100644
--- a/aqt/studyopts.py
+++ b/aqt/studyopts.py
@@ -4,6 +4,7 @@
from PyQt4.QtCore import *
from PyQt4.QtGui import *
+from aqt.utils import maybeHideClose
import datetime, time, aqt
class StudyOptions(QDialog):
@@ -14,9 +15,6 @@ class StudyOptions(QDialog):
self.form.setupUi(self)
self.setup()
self.load()
- self.connect(self.form.buttonBox,
- SIGNAL("helpRequested()"),
- lambda: aqt.openHelp("StudyOptions"))
self.exec_()
def setup(self):
@@ -27,6 +25,10 @@ class StudyOptions(QDialog):
0, QStringList(c.newCardSchedulingLabels().values()))
self.form.revOrder.insertItems(
0, QStringList(c.revCardOrderLabels().values()))
+ self.connect(self.form.buttonBox,
+ SIGNAL("helpRequested()"),
+ lambda: aqt.openHelp("StudyOptions"))
+ maybeHideClose(self.form.buttonBox)
def load(self):
f = self.form
diff --git a/aqt/utils.py b/aqt/utils.py
index 96829d515..1ee67e21b 100644
--- a/aqt/utils.py
+++ b/aqt/utils.py
@@ -308,5 +308,11 @@ def shortcut(key):
return re.sub("(?i)ctrl", "Command", key)
return key
+def maybeHideClose(bbox):
+ if isMac:
+ b = bbox.button(QDialogButtonBox.Close)
+ if b:
+ bbox.removeButton(b)
+
isMac = sys.platform.startswith("darwin")
isWin = sys.platform.startswith("win32")
diff --git a/designer/addcards.ui b/designer/addcards.ui
index 3a78739aa..19b57956c 100644
--- a/designer/addcards.ui
+++ b/designer/addcards.ui
@@ -6,8 +6,8 @@
0
0
- 743
- 727
+ 453
+ 366
diff --git a/designer/editcurrent.ui b/designer/editcurrent.ui
new file mode 100644
index 000000000..a23de8bb3
--- /dev/null
+++ b/designer/editcurrent.ui
@@ -0,0 +1,73 @@
+
+
+ Dialog
+
+
+
+ 0
+ 0
+ 400
+ 300
+
+
+
+ Dialog
+
+
+
+ 3
+
+
+ 12
+
+ -
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Save
+
+
+
+
+
+
+
+
+ buttonBox
+ accepted()
+ Dialog
+ accept()
+
+
+ 248
+ 254
+
+
+ 157
+ 274
+
+
+
+
+ buttonBox
+ rejected()
+ Dialog
+ reject()
+
+
+ 316
+ 260
+
+
+ 286
+ 274
+
+
+
+
+
diff --git a/designer/groups.ui b/designer/groups.ui
index 0e41efccd..90a19eda0 100644
--- a/designer/groups.ui
+++ b/designer/groups.ui
@@ -96,20 +96,20 @@
- -
-
-
- &Options...
-
-
-
-
Qt::Vertical
- QDialogButtonBox::Help|QDialogButtonBox::Ok
+ QDialogButtonBox::Close|QDialogButtonBox::Help
+
+
+
+ -
+
+
+ &Options...
@@ -123,7 +123,6 @@
selNone
rename
delete_2
- opts
buttonBox
diff --git a/designer/stats.ui b/designer/stats.ui
index b6d4dc1b2..611558784 100644
--- a/designer/stats.ui
+++ b/designer/stats.ui
@@ -115,7 +115,7 @@
Qt::Horizontal
- QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+ QDialogButtonBox::Close
diff --git a/designer/studyopts.ui b/designer/studyopts.ui
index 18474667f..113927c58 100644
--- a/designer/studyopts.ui
+++ b/designer/studyopts.ui
@@ -143,7 +143,7 @@
Qt::Vertical
- QDialogButtonBox::Help|QDialogButtonBox::Ok
+ QDialogButtonBox::Close|QDialogButtonBox::Help