mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
fix reading update, update colour button in all fact editor instances
This commit is contained in:
parent
1c515a4e39
commit
95d907333e
1 changed files with 12 additions and 5 deletions
|
@ -13,7 +13,7 @@ import anki.sound
|
||||||
from ankiqt import ui
|
from ankiqt import ui
|
||||||
import ankiqt
|
import ankiqt
|
||||||
from ankiqt.ui.utils import mungeQA, saveGeom, restoreGeom
|
from ankiqt.ui.utils import mungeQA, saveGeom, restoreGeom
|
||||||
from anki.hooks import addHook, removeHook
|
from anki.hooks import addHook, removeHook, runHook
|
||||||
from sqlalchemy.exceptions import InvalidRequestError
|
from sqlalchemy.exceptions import InvalidRequestError
|
||||||
|
|
||||||
clozeColour = "#0000ff"
|
clozeColour = "#0000ff"
|
||||||
|
@ -40,10 +40,12 @@ class FactEditor(object):
|
||||||
self.lastCloze = None
|
self.lastCloze = None
|
||||||
addHook("deckClosed", self.deckClosedHook)
|
addHook("deckClosed", self.deckClosedHook)
|
||||||
addHook("guiReset", self.refresh)
|
addHook("guiReset", self.refresh)
|
||||||
|
addHook("colourChanged", self.colourChanged)
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
removeHook("deckClosed", self.deckClosedHook)
|
removeHook("deckClosed", self.deckClosedHook)
|
||||||
removeHook("guiReset", self.refresh)
|
addHook("colourChanged", self.colourChanged)
|
||||||
|
removeHook("colourChanged", self.colourChanged)
|
||||||
|
|
||||||
def setFact(self, fact, noFocus=False, check=False):
|
def setFact(self, fact, noFocus=False, check=False):
|
||||||
"Make FACT the current fact."
|
"Make FACT the current fact."
|
||||||
|
@ -462,6 +464,7 @@ class FactEditor(object):
|
||||||
self.saveFields()
|
self.saveFields()
|
||||||
field = self.widgets[widget]
|
field = self.widgets[widget]
|
||||||
self.fact.focusLost(field)
|
self.fact.focusLost(field)
|
||||||
|
self.fact.setModified(textChanged=True)
|
||||||
self.loadFields(font=False)
|
self.loadFields(font=False)
|
||||||
|
|
||||||
def onTextChanged(self):
|
def onTextChanged(self):
|
||||||
|
@ -614,6 +617,10 @@ class FactEditor(object):
|
||||||
self.foregroundFrame.setStyleSheet("* {background-color: %s}" %
|
self.foregroundFrame.setStyleSheet("* {background-color: %s}" %
|
||||||
txtcol)
|
txtcol)
|
||||||
|
|
||||||
|
def colourChanged(self):
|
||||||
|
recent = ankiqt.mw.config['recentColours']
|
||||||
|
self._updateForegroundButton(recent[-1])
|
||||||
|
|
||||||
def setForeground(self, w=None):
|
def setForeground(self, w=None):
|
||||||
recent = ankiqt.mw.config['recentColours']
|
recent = ankiqt.mw.config['recentColours']
|
||||||
if not w:
|
if not w:
|
||||||
|
@ -626,14 +633,14 @@ class FactEditor(object):
|
||||||
recent = ankiqt.mw.config['recentColours']
|
recent = ankiqt.mw.config['recentColours']
|
||||||
last = recent.pop()
|
last = recent.pop()
|
||||||
recent.insert(0, last)
|
recent.insert(0, last)
|
||||||
self._updateForegroundButton(recent[-1])
|
runHook("colourChanged")
|
||||||
self.setForeground()
|
self.setForeground()
|
||||||
|
|
||||||
def nextForeground(self):
|
def nextForeground(self):
|
||||||
recent = ankiqt.mw.config['recentColours']
|
recent = ankiqt.mw.config['recentColours']
|
||||||
last = recent.pop(0)
|
last = recent.pop(0)
|
||||||
recent.append(last)
|
recent.append(last)
|
||||||
self._updateForegroundButton(recent[-1])
|
runHook("colourChanged")
|
||||||
self.setForeground()
|
self.setForeground()
|
||||||
|
|
||||||
def selectForeground(self):
|
def selectForeground(self):
|
||||||
|
@ -643,10 +650,10 @@ class FactEditor(object):
|
||||||
self.parent)
|
self.parent)
|
||||||
if new.isValid():
|
if new.isValid():
|
||||||
txtcol = unicode(new.name())
|
txtcol = unicode(new.name())
|
||||||
self._updateForegroundButton(txtcol)
|
|
||||||
if txtcol in recent:
|
if txtcol in recent:
|
||||||
recent.remove(txtcol)
|
recent.remove(txtcol)
|
||||||
recent.append(txtcol)
|
recent.append(txtcol)
|
||||||
|
runHook("colourChanged")
|
||||||
self.setForeground(w)
|
self.setForeground(w)
|
||||||
|
|
||||||
def insertLatex(self):
|
def insertLatex(self):
|
||||||
|
|
Loading…
Reference in a new issue