mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
fix images on win32, display bugs
This commit is contained in:
parent
42835617de
commit
9f2572d6ef
4 changed files with 29 additions and 7 deletions
|
@ -16,10 +16,11 @@ class FactEditor(object):
|
||||||
Extra widgets can be added to 'fieldsGrid' to represent card-specific
|
Extra widgets can be added to 'fieldsGrid' to represent card-specific
|
||||||
information, etc."""
|
information, etc."""
|
||||||
|
|
||||||
def __init__(self, parent, widget, deck=None):
|
def __init__(self, parent, widget, deck=None, colour=""):
|
||||||
self.widget = widget
|
self.widget = widget
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.deck = deck
|
self.deck = deck
|
||||||
|
self.colour = colour
|
||||||
self.fact = None
|
self.fact = None
|
||||||
self.fontChanged = False
|
self.fontChanged = False
|
||||||
self.setupFields()
|
self.setupFields()
|
||||||
|
@ -65,6 +66,10 @@ class FactEditor(object):
|
||||||
self.iconsBox.addItem(QSpacerItem(20,20, QSizePolicy.Expanding))
|
self.iconsBox.addItem(QSpacerItem(20,20, QSizePolicy.Expanding))
|
||||||
# button styles for mac
|
# button styles for mac
|
||||||
self.plastiqueStyle = QStyleFactory.create("plastique")
|
self.plastiqueStyle = QStyleFactory.create("plastique")
|
||||||
|
self.widget.setStyle(self.plastiqueStyle)
|
||||||
|
self.widget.setStyleSheet("""
|
||||||
|
%s
|
||||||
|
#fieldsArea { border: 0px; margin-top: 4px; }""" % self.colour)
|
||||||
# bold
|
# bold
|
||||||
self.bold = QPushButton()
|
self.bold = QPushButton()
|
||||||
self.bold.setCheckable(True)
|
self.bold.setCheckable(True)
|
||||||
|
@ -110,7 +115,7 @@ class FactEditor(object):
|
||||||
self.foregroundFrame.setAutoFillBackground(True)
|
self.foregroundFrame.setAutoFillBackground(True)
|
||||||
hbox = QHBoxLayout()
|
hbox = QHBoxLayout()
|
||||||
hbox.addWidget(self.foregroundFrame)
|
hbox.addWidget(self.foregroundFrame)
|
||||||
hbox.setMargin(0)
|
hbox.setMargin(1)
|
||||||
self.foreground.setLayout(hbox)
|
self.foreground.setLayout(hbox)
|
||||||
self.iconsBox.addWidget(self.foreground)
|
self.iconsBox.addWidget(self.foreground)
|
||||||
self.foreground.setStyle(self.plastiqueStyle)
|
self.foreground.setStyle(self.plastiqueStyle)
|
||||||
|
@ -343,6 +348,8 @@ class FactEditor(object):
|
||||||
self.italic.setChecked(w.fontItalic())
|
self.italic.setChecked(w.fontItalic())
|
||||||
self.underline.setChecked(w.fontUnderline())
|
self.underline.setChecked(w.fontUnderline())
|
||||||
self.foregroundFrame.setPalette(QPalette(w.textColor()))
|
self.foregroundFrame.setPalette(QPalette(w.textColor()))
|
||||||
|
self.foregroundFrame.setStyleSheet("* {background-color: %s}" %
|
||||||
|
unicode(w.textColor().name()))
|
||||||
|
|
||||||
def resetFormatButtons(self):
|
def resetFormatButtons(self):
|
||||||
self.bold.setChecked(False)
|
self.bold.setChecked(False)
|
||||||
|
|
|
@ -799,8 +799,10 @@ To upgrade an old deck, download Anki 0.9.8.7."""))
|
||||||
|
|
||||||
def setupEditor(self):
|
def setupEditor(self):
|
||||||
self.mainWin.fieldsArea.hide()
|
self.mainWin.fieldsArea.hide()
|
||||||
|
self.mainWin.fieldsArea.setFlat(True)
|
||||||
self.editor = ui.facteditor.FactEditor(
|
self.editor = ui.facteditor.FactEditor(
|
||||||
self, self.mainWin.fieldsArea, self.deck)
|
self, self.mainWin.fieldsArea, self.deck,
|
||||||
|
colour="* { background-color: #fff; }\n")
|
||||||
self.editor.onFactValid = self.onFactValid
|
self.editor.onFactValid = self.onFactValid
|
||||||
self.editor.onFactInvalid = self.onFactInvalid
|
self.editor.onFactInvalid = self.onFactInvalid
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import anki, anki.utils
|
||||||
from anki.sound import playFromText, stripSounds
|
from anki.sound import playFromText, stripSounds
|
||||||
from anki.latex import renderLatex, stripLatex
|
from anki.latex import renderLatex, stripLatex
|
||||||
from anki.utils import stripHTML
|
from anki.utils import stripHTML
|
||||||
import types, time, re, os
|
import types, time, re, os, urllib, sys
|
||||||
from ankiqt import ui
|
from ankiqt import ui
|
||||||
|
|
||||||
# Views - define the way a user is prompted for questions, etc
|
# Views - define the way a user is prompted for questions, etc
|
||||||
|
@ -112,8 +112,15 @@ class View(object):
|
||||||
def munge(self, txt):
|
def munge(self, txt):
|
||||||
txt = renderLatex(self.main.deck, txt)
|
txt = renderLatex(self.main.deck, txt)
|
||||||
txt = stripSounds(txt)
|
txt = stripSounds(txt)
|
||||||
txt = re.sub(
|
def quote(match):
|
||||||
'img src="(.*?)"', 'img src="file://%s/\\1"' % os.getcwd(), txt)
|
if sys.platform.startswith("win32"):
|
||||||
|
prefix = "file:///"
|
||||||
|
else:
|
||||||
|
prefix = "file://"
|
||||||
|
return 'img src="%s%s"' % (
|
||||||
|
prefix, os.path.join(self.main.deck.mediaDir(),
|
||||||
|
unicode(match.group(1))))
|
||||||
|
txt = re.sub('img src="(.*?)"', quote, txt)
|
||||||
return txt
|
return txt
|
||||||
|
|
||||||
def drawQuestion(self, nosound=False):
|
def drawQuestion(self, nosound=False):
|
||||||
|
|
|
@ -202,6 +202,9 @@
|
||||||
<property name="title" >
|
<property name="title" >
|
||||||
<string>Current Card</string>
|
<string>Current Card</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="flat" >
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0" >
|
<item row="0" column="0" >
|
||||||
|
@ -213,7 +216,10 @@
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="title" >
|
<property name="title" >
|
||||||
<string>Current &Fact</string>
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="flat" >
|
||||||
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
Loading…
Reference in a new issue