diff --git a/ankiqt/ui/facteditor.py b/ankiqt/ui/facteditor.py index cce1b0a63..2acbf9fda 100644 --- a/ankiqt/ui/facteditor.py +++ b/ankiqt/ui/facteditor.py @@ -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) diff --git a/ankiqt/ui/main.py b/ankiqt/ui/main.py index 069d8f205..8e3674f1c 100644 --- a/ankiqt/ui/main.py +++ b/ankiqt/ui/main.py @@ -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 diff --git a/ankiqt/ui/view.py b/ankiqt/ui/view.py index 35fce56bd..a58122129 100644 --- a/ankiqt/ui/view.py +++ b/ankiqt/ui/view.py @@ -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): diff --git a/designer/cardlist.ui b/designer/cardlist.ui index 9701dc281..3701f04e7 100644 --- a/designer/cardlist.ui +++ b/designer/cardlist.ui @@ -202,6 +202,9 @@ Current Card + + false + @@ -213,7 +216,10 @@ - Current &Fact + + + + true