mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -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
|
||||
information, etc."""
|
||||
|
||||
def __init__(self, parent, widget, deck=None):
|
||||
def __init__(self, parent, widget, deck=None, colour=""):
|
||||
self.widget = widget
|
||||
self.parent = parent
|
||||
self.deck = deck
|
||||
self.colour = colour
|
||||
self.fact = None
|
||||
self.fontChanged = False
|
||||
self.setupFields()
|
||||
|
@ -65,6 +66,10 @@ class FactEditor(object):
|
|||
self.iconsBox.addItem(QSpacerItem(20,20, QSizePolicy.Expanding))
|
||||
# button styles for mac
|
||||
self.plastiqueStyle = QStyleFactory.create("plastique")
|
||||
self.widget.setStyle(self.plastiqueStyle)
|
||||
self.widget.setStyleSheet("""
|
||||
%s
|
||||
#fieldsArea { border: 0px; margin-top: 4px; }""" % self.colour)
|
||||
# bold
|
||||
self.bold = QPushButton()
|
||||
self.bold.setCheckable(True)
|
||||
|
@ -110,7 +115,7 @@ class FactEditor(object):
|
|||
self.foregroundFrame.setAutoFillBackground(True)
|
||||
hbox = QHBoxLayout()
|
||||
hbox.addWidget(self.foregroundFrame)
|
||||
hbox.setMargin(0)
|
||||
hbox.setMargin(1)
|
||||
self.foreground.setLayout(hbox)
|
||||
self.iconsBox.addWidget(self.foreground)
|
||||
self.foreground.setStyle(self.plastiqueStyle)
|
||||
|
@ -343,6 +348,8 @@ class FactEditor(object):
|
|||
self.italic.setChecked(w.fontItalic())
|
||||
self.underline.setChecked(w.fontUnderline())
|
||||
self.foregroundFrame.setPalette(QPalette(w.textColor()))
|
||||
self.foregroundFrame.setStyleSheet("* {background-color: %s}" %
|
||||
unicode(w.textColor().name()))
|
||||
|
||||
def resetFormatButtons(self):
|
||||
self.bold.setChecked(False)
|
||||
|
|
|
@ -799,8 +799,10 @@ To upgrade an old deck, download Anki 0.9.8.7."""))
|
|||
|
||||
def setupEditor(self):
|
||||
self.mainWin.fieldsArea.hide()
|
||||
self.mainWin.fieldsArea.setFlat(True)
|
||||
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.onFactInvalid = self.onFactInvalid
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import anki, anki.utils
|
|||
from anki.sound import playFromText, stripSounds
|
||||
from anki.latex import renderLatex, stripLatex
|
||||
from anki.utils import stripHTML
|
||||
import types, time, re, os
|
||||
import types, time, re, os, urllib, sys
|
||||
from ankiqt import ui
|
||||
|
||||
# Views - define the way a user is prompted for questions, etc
|
||||
|
@ -112,8 +112,15 @@ class View(object):
|
|||
def munge(self, txt):
|
||||
txt = renderLatex(self.main.deck, txt)
|
||||
txt = stripSounds(txt)
|
||||
txt = re.sub(
|
||||
'img src="(.*?)"', 'img src="file://%s/\\1"' % os.getcwd(), txt)
|
||||
def quote(match):
|
||||
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
|
||||
|
||||
def drawQuestion(self, nosound=False):
|
||||
|
|
|
@ -202,6 +202,9 @@
|
|||
<property name="title" >
|
||||
<string>Current Card</string>
|
||||
</property>
|
||||
<property name="flat" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
|
@ -213,7 +216,10 @@
|
|||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title" >
|
||||
<string>Current &Fact</string>
|
||||
<string/>
|
||||
</property>
|
||||
<property name="flat" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
Loading…
Reference in a new issue