From 265b59817314c313a363614560edd56953da2b49 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 22 Mar 2011 13:09:34 +0900 Subject: [PATCH] various layout tweaks --- aqt/deckbrowser.py | 19 ++++++++++------- aqt/main.py | 19 ++++++++++------- aqt/overview.py | 51 +++++++++++++++++++++++++--------------------- aqt/reviewer.py | 18 ++++------------ 4 files changed, 56 insertions(+), 51 deletions(-) diff --git a/aqt/deckbrowser.py b/aqt/deckbrowser.py index 6028d9ef3..bef8906cf 100644 --- a/aqt/deckbrowser.py +++ b/aqt/deckbrowser.py @@ -62,14 +62,14 @@ class DeckBrowser(object): # instead we have a html one under the deck list def _toolbar(self): items = [ - ("download", _("Download Shared")), + ("download", _("Download")), ("new", _("Create")), - ("import", _("Import")), +# ("import", _("Import")), ("opensel", _("Open")), - ("synced", _("Synced")), +# ("synced", _("Synced")), ("refresh", _("Refresh")), ] - h = " | ".join(["%s" % row for row in items]) + h = "".join(["%s" % row for row in items]) return h # Event handlers @@ -125,6 +125,7 @@ a.deck { color: #000; text-decoration: none; font-size: 100%; } td.opts { text-align: right; white-space: nowrap; } td.menu { text-align: center; } a { font-size: 80%; } +.extra { font-size: 90%; } """ _body = """ @@ -132,10 +133,12 @@ a { font-size: 80%; }

%(title)s

%(tb)s

- +
%(rows)s
+

%(extra)s +
""" @@ -144,6 +147,8 @@ a { font-size: 80%; } buf = "" css = self.mw.sharedCSS + self._css max=len(self._decks)-1 + buf += "%s" % _("Due") + buf += "%s" % _("New") for c, deck in enumerate(self._decks): buf += self._deckRow(c, max, deck) self.web.stdHtml(self._body%dict( @@ -208,8 +213,8 @@ a { font-size: 80%; } buf += "%s▼" % ( c, "Options") buf += "" - if c != max: - buf += "
" + # if c != max: + # buf += "
" return buf def _summary(self): diff --git a/aqt/main.py b/aqt/main.py index 8c67c9d7c..c0e3cb81a 100755 --- a/aqt/main.py +++ b/aqt/main.py @@ -151,23 +151,28 @@ class AnkiQt(QMainWindow): ########################################################################## sharedCSS = """ -body { background-color: #eee; margin-top: 1em; } +body { +background: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#bbb)); +margin: 1em; } a:hover { background-color: #aaa; } -a.but { font-size: 80%; padding: 3; background-color: #ccc; +.but { font-size: 80%; padding: 3; background-color: #bbb; border-radius: 2px; color: #000; margin: 0 5 0 5; text-decoration: none; display: inline-block; } -a.but:focus { background-color: #aaa; } +.but:focus, .but:hover { background-color: #aaa; } +.gbut { background-color: #7c7; } +.gbut:hover, .gbut:focus { background-color: #5a5; } h1 { margin-bottom: 0.2em; } -hr { margin:5 0 5 0; border:0; height:1px; background-color:#ddd; } +hr { margin:5 0 5 0; border:0; height:1px; background-color:#ccc; } """ - def button(self, link, name, key=None): + def button(self, link, name, key=None, class_=""): + class_ = "but "+ class_ if key: key = _("Shortcut key: %s") % key else: key = "" - return '%s' % ( - key, link, name) + return '%s' % ( + class_, key, link, name) # Signal handling ########################################################################## diff --git a/aqt/overview.py b/aqt/overview.py index 1c7b9d4f8..5e514f24b 100644 --- a/aqt/overview.py +++ b/aqt/overview.py @@ -57,22 +57,29 @@ class Overview(object): css = self.mw.sharedCSS + self._overviewCSS fc = self._ovForecast() tbl = self._overviewTable() + but = self.mw.button + buts = (but("list", _("Deck List"), "d") + + but("refr", _("Refresh"), "r") + + but("opts", _("Study Options"), "o")) self.web.stdHtml(self._overviewBody % dict( title=_("Overview"), table=tbl, - fcsub=_("Due over next two weeks"), + fcsub=_("Reviews over next two weeks"), fcdata=fc, + buts=buts, opts=self._ovOpts(), ), css) _overviewBody = """

%(title)s

+%(buts)s +

%(table)s -


+

%(fcsub)s -
+

%(opts)s

@@ -81,7 +88,7 @@ $(function () { var d = %(fcdata)s; if (d) { $.plot($("#placeholder"), [ - { data: d, bars: { show: true, barWidth: 0.8 } } + { data: d, bars: { show: true, barWidth: 0.8 }, color: "#0c0" } ], { xaxis: { ticks: [[0.4, "Today"]] } }); @@ -94,8 +101,8 @@ $(function () { """ _overviewCSS = """ -.due { text-align: right; color: green; } -.new { text-align: right; color: blue; } +.due { text-align: right; } +.new { text-align: right; } .sub { font-size: 80%; color: #555; } """ @@ -110,32 +117,30 @@ $(function () { buf += line % ( "%s" % _("Selected Groups"), counts[0], counts[1], - but("studysel", _("Study"), "1") + + but("studysel", _("Study"), "1", "gbut") + but("cramsel", _("Cram"), "3")) buf += line % ( _("Whole Deck"), counts[2], counts[3], - but("studyall", _("Study"), "2") + + but("studyall", _("Study"), "2", "gbut") + but("cramall", _("Cram"), "4")) buf += "" return buf def _ovOpts(self): - if self.mw.deck.qconf['newCardOrder'] == NEW_CARDS_RANDOM: - ord = _("random") - else: - ord = _("order added") - but = self.mw.button - buf = """ - - - -
%s%s%s
%s%s%s
""" % ( - _("New cards per day"), self.mw.deck.qconf['newPerDay'], - but("opts", _("Study Options"), "o"), - _("New card order"), ord, - but("list", "◀"+_("Deck List"), "d")) - return buf + return "" +# if self.mw.deck.qconf['newCardOrder'] == NEW_CARDS_RANDOM: +# ord = _("random") +# else: +# ord = _("order added") +# buf = """ +# +# +# +#
%s%s
%s%s
""" % ( +# _("New cards per day"), self.mw.deck.qconf['newPerDay'], +# _("New card order"), ord) +# return buf # Data ########################################################################## diff --git a/aqt/reviewer.py b/aqt/reviewer.py index 3a4b3bf48..7899fe0a8 100644 --- a/aqt/reviewer.py +++ b/aqt/reviewer.py @@ -6,17 +6,12 @@ import time, os, stat, shutil, difflib, simplejson import unicodedata as ucd from PyQt4.QtCore import * from PyQt4.QtGui import * -from anki.consts import NEW_CARDS_RANDOM from anki.utils import fmtTimeSpan, stripHTML from anki.hooks import addHook, runHook, runFilter from anki.sound import playFromText from aqt.utils import mungeQA, getBase import aqt -failedCharColour = "#FF0000" -passedCharColour = "#00FF00" -futureWarningColour = "#FF0000" - class Reviewer(object): "Manage reviews. Maintains a separate state." @@ -28,7 +23,6 @@ class Reviewer(object): # self.onLoadFinished) def show(self): - self._setupToolbar() self._reset() # State control @@ -192,6 +186,10 @@ class Reviewer(object): # Question and answer ########################################################################## + failedCharColour = "#FF0000" + passedCharColour = "#00FF00" + futureWarningColour = "#FF0000" + def center(self, str, height=40): if not self.main.config['splitQA']: return "
" + str + "
" @@ -365,11 +363,3 @@ class Reviewer(object): "Tell the user the deck is finished." self.main.mainWin.congratsLabel.setText( self.main.deck.deckFinishedMsg()) - - # Toolbar - ########################################################################## - - def _setupToolbar(self): - if not self.mw.config['showToolbar']: - return - self.mw.form.toolBar.show()