mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
edit current, hide 'close' button on osx
This commit is contained in:
parent
61cdea4865
commit
9da0a83735
15 changed files with 145 additions and 67 deletions
|
@ -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)
|
||||
|
|
|
@ -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'])
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -81,7 +81,6 @@ class AnkiQt(QMainWindow):
|
|||
self.setupDeckBrowser()
|
||||
self.setupOverview()
|
||||
self.setupReviewer()
|
||||
self.setupEditor()
|
||||
|
||||
# State machine
|
||||
##########################################################################
|
||||
|
@ -254,10 +253,6 @@ title="%s">%s</button>''' % (
|
|||
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
|
||||
|
|
|
@ -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_()
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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_()
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>743</width>
|
||||
<height>727</height>
|
||||
<width>453</width>
|
||||
<height>366</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
|
73
designer/editcurrent.ui
Normal file
73
designer/editcurrent.ui
Normal file
|
@ -0,0 +1,73 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Dialog</class>
|
||||
<widget class="QDialog" name="Dialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>12</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QWidget" name="fieldsArea" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Save</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>Dialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>Dialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
|
@ -96,20 +96,20 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="opts">
|
||||
<property name="text">
|
||||
<string>&Options...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3" rowspan="2">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
|
||||
<set>QDialogButtonBox::Close|QDialogButtonBox::Help</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="opts">
|
||||
<property name="text">
|
||||
<string>&Options...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -123,7 +123,6 @@
|
|||
<tabstop>selNone</tabstop>
|
||||
<tabstop>rename</tabstop>
|
||||
<tabstop>delete_2</tabstop>
|
||||
<tabstop>opts</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
|
|
|
@ -115,7 +115,7 @@
|
|||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -143,7 +143,7 @@
|
|||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
|
||||
<set>QDialogButtonBox::Close|QDialogButtonBox::Help</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
Loading…
Reference in a new issue