From 93731bf4f47f7101f10298c42fbacf88592013f7 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 13 Dec 2008 16:45:42 +0900 Subject: [PATCH] make thai hack optional, move some adv options into first tab --- ankiqt/config.py | 1 + ankiqt/ui/preferences.py | 2 + ankiqt/ui/utils.py | 2 - ankiqt/ui/view.py | 11 ++++- designer/preferences.ui | 96 ++++++++++++++++++++++++---------------- 5 files changed, 70 insertions(+), 42 deletions(-) diff --git a/ankiqt/config.py b/ankiqt/config.py index 217ff9dc0..e1bb001ce 100644 --- a/ankiqt/config.py +++ b/ankiqt/config.py @@ -69,6 +69,7 @@ class Config(dict): 'qaDivider': True, 'splitQA': True, 'sortIndex': 0, + 'addZeroSpace': True, } for (k,v) in fields.items(): if not self.has_key(k): diff --git a/ankiqt/ui/preferences.py b/ankiqt/ui/preferences.py index 2b1be60bf..8024e5eb1 100644 --- a/ankiqt/ui/preferences.py +++ b/ankiqt/ui/preferences.py @@ -175,6 +175,7 @@ class Preferences(QDialog): self.dialog.scrollToAnswer.setChecked(self.config['scrollToAnswer']) self.dialog.showDivider.setChecked(self.config['qaDivider']) self.dialog.splitQA.setChecked(self.config['splitQA']) + self.dialog.addZeroSpace.setChecked(self.config['addZeroSpace']) self.dialog.toolbarIconSize.setText(str(self.config['iconSize'])) def updateAdvanced(self): @@ -192,6 +193,7 @@ class Preferences(QDialog): self.config['scrollToAnswer'] = self.dialog.scrollToAnswer.isChecked() self.config['qaDivider'] = self.dialog.showDivider.isChecked() self.config['splitQA'] = self.dialog.splitQA.isChecked() + self.config['addZeroSpace'] = self.dialog.addZeroSpace.isChecked() i = 32 try: i = int(self.dialog.toolbarIconSize.text()) diff --git a/ankiqt/ui/utils.py b/ankiqt/ui/utils.py index 89c606e30..aaa45667a 100644 --- a/ankiqt/ui/utils.py +++ b/ankiqt/ui/utils.py @@ -184,6 +184,4 @@ def mungeQA(deck, txt): create=True), match).encode("utf-8")), "utf-8") return 'img src="%s"' % src txt = re.sub('img src="(.*?)"', quote, txt) - # hack to fix thai presentation issues - txt = txt.replace("", "​") return txt diff --git a/ankiqt/ui/view.py b/ankiqt/ui/view.py index cc60bbd69..981fdf1b8 100644 --- a/ankiqt/ui/view.py +++ b/ankiqt/ui/view.py @@ -138,7 +138,7 @@ class View(object): height = 35 else: height = 45 - self.write(self.center(mungeQA(self.main.deck, q), height)) + self.write(self.center(self.mungeQA(self.main.deck, q), height)) if self.state != self.oldState and not nosound: playFromText(q) @@ -146,10 +146,17 @@ class View(object): "Show the answer." a = self.main.currentCard.htmlAnswer() self.write(self.center('' + - mungeQA(self.main.deck, a))) + self.mungeQA(self.main.deck, a))) if self.state != self.oldState: playFromText(a) + def mungeQA(self, deck, txt): + txt = mungeQA(deck, txt) + # hack to fix thai presentation issues + if self.main.config['addZeroSpace']: + txt = txt.replace("", "​") + return txt + def onLoadFinished(self): if self.state == "showAnswer": if self.main.config['scrollToAnswer']: diff --git a/designer/preferences.ui b/designer/preferences.ui index 1ab582337..91a02510a 100644 --- a/designer/preferences.ui +++ b/designer/preferences.ui @@ -6,7 +6,7 @@ 0 0 322 - 438 + 417 @@ -15,6 +15,9 @@ + + Qt::StrongFocus + 0 @@ -24,13 +27,16 @@ 0 0 306 - 372 + 351 Display + + 6 + @@ -67,8 +73,11 @@ 0 + + Qt::TabFocus + - <h1>Fonts & Colours</h1> + <h1>Display</h1> false @@ -153,6 +162,34 @@ + + + + Qt::Horizontal + + + + + + + Show divider between question and answer + + + + + + + Put space between question and answer + + + + + + + Don't show next time before answer + + + @@ -174,7 +211,7 @@ 0 0 306 - 372 + 351 @@ -362,7 +399,7 @@ 0 0 306 - 372 + 351 @@ -392,66 +429,52 @@ - - - - Hide next interval when showing answer buttons - - - - - - - Show last card's question/answer - - - - - - Show last card's interval - - - - Show toolbar on startup - + Tall buttons (for touchscreen) - + Show tray icon - + Scroll down to the answer when showing answer - - + + - Show divider between question and answer + Show last card's interval - - + + - Put space between question and answer + Show last card's question/answer + + + + + + + Add hidden char to text (fixes Thai on OSX) @@ -531,15 +554,12 @@ syncOnClose simpleToolbar showTimer - suppressEstimates showLastCardContent showLastCardInterval showToolbar tallButtons showTray scrollToAnswer - showDivider - splitQA toolbarIconSize buttonBox