various layout tweaks

This commit is contained in:
Damien Elmes 2011-03-22 13:09:34 +09:00
parent 7604fa3797
commit 265b598173
4 changed files with 56 additions and 51 deletions

View file

@ -62,14 +62,14 @@ class DeckBrowser(object):
# instead we have a html one under the deck list # instead we have a html one under the deck list
def _toolbar(self): def _toolbar(self):
items = [ items = [
("download", _("Download Shared")), ("download", _("Download")),
("new", _("Create")), ("new", _("Create")),
("import", _("Import")), # ("import", _("Import")),
("opensel", _("Open")), ("opensel", _("Open")),
("synced", _("Synced")), # ("synced", _("Synced")),
("refresh", _("Refresh")), ("refresh", _("Refresh")),
] ]
h = " | ".join(["<a class=tb href=%s>%s</a>" % row for row in items]) h = "".join(["<a class=but href=%s>%s</a>" % row for row in items])
return h return h
# Event handlers # 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.opts { text-align: right; white-space: nowrap; }
td.menu { text-align: center; } td.menu { text-align: center; }
a { font-size: 80%; } a { font-size: 80%; }
.extra { font-size: 90%; }
""" """
_body = """ _body = """
@ -132,10 +133,12 @@ a { font-size: 80%; }
<h1>%(title)s</h1> <h1>%(title)s</h1>
%(tb)s %(tb)s
<p> <p>
<table cellspacing=0 cellpadding=0 width=90%%> <table cellspacing=0 cellpadding=3 width=100%%>
%(rows)s %(rows)s
</table> </table>
<div class="extra">
%(extra)s %(extra)s
</div>
</center> </center>
""" """
@ -144,6 +147,8 @@ a { font-size: 80%; }
buf = "" buf = ""
css = self.mw.sharedCSS + self._css css = self.mw.sharedCSS + self._css
max=len(self._decks)-1 max=len(self._decks)-1
buf += "<tr><th></th><th align=right>%s</th>" % _("Due")
buf += "<th align=right>%s</th><th></th></tr>" % _("New")
for c, deck in enumerate(self._decks): for c, deck in enumerate(self._decks):
buf += self._deckRow(c, max, deck) buf += self._deckRow(c, max, deck)
self.web.stdHtml(self._body%dict( self.web.stdHtml(self._body%dict(
@ -208,8 +213,8 @@ a { font-size: 80%; }
buf += "<td class=opts><a class=but href='opts:%d'>%s&#9660;</a></td>" % ( buf += "<td class=opts><a class=but href='opts:%d'>%s&#9660;</a></td>" % (
c, "Options") c, "Options")
buf += "</tr>" buf += "</tr>"
if c != max: # if c != max:
buf += "<tr><td colspan=4><hr noshade></td></tr>" # buf += "<tr><td colspan=4><hr noshade></td></tr>"
return buf return buf
def _summary(self): def _summary(self):

View file

@ -151,23 +151,28 @@ class AnkiQt(QMainWindow):
########################################################################## ##########################################################################
sharedCSS = """ 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: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: border-radius: 2px; color: #000; margin: 0 5 0 5; text-decoration:
none; display: inline-block; } 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; } 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: if key:
key = _("Shortcut key: %s") % key key = _("Shortcut key: %s") % key
else: else:
key = "" key = ""
return '<a class=but title="%s" href="%s">%s</a>' % ( return '<a class="%s" title="%s" href="%s">%s</a>' % (
key, link, name) class_, key, link, name)
# Signal handling # Signal handling
########################################################################## ##########################################################################

View file

@ -57,22 +57,29 @@ class Overview(object):
css = self.mw.sharedCSS + self._overviewCSS css = self.mw.sharedCSS + self._overviewCSS
fc = self._ovForecast() fc = self._ovForecast()
tbl = self._overviewTable() 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( self.web.stdHtml(self._overviewBody % dict(
title=_("Overview"), title=_("Overview"),
table=tbl, table=tbl,
fcsub=_("Due over next two weeks"), fcsub=_("Reviews over next two weeks"),
fcdata=fc, fcdata=fc,
buts=buts,
opts=self._ovOpts(), opts=self._ovOpts(),
), css) ), css)
_overviewBody = """ _overviewBody = """
<center> <center>
<h1>%(title)s</h1> <h1>%(title)s</h1>
%(buts)s
<p>
%(table)s %(table)s
<hr> <p>
<div id="placeholder" style="width:350px; height:100px;"></div> <div id="placeholder" style="width:350px; height:100px;"></div>
<span class=sub>%(fcsub)s</span> <span class=sub>%(fcsub)s</span>
<hr class=sub> <p>
%(opts)s %(opts)s
</center> </center>
@ -81,7 +88,7 @@ $(function () {
var d = %(fcdata)s; var d = %(fcdata)s;
if (d) { if (d) {
$.plot($("#placeholder"), [ $.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"]] } xaxis: { ticks: [[0.4, "Today"]] }
}); });
@ -94,8 +101,8 @@ $(function () {
""" """
_overviewCSS = """ _overviewCSS = """
.due { text-align: right; color: green; } .due { text-align: right; }
.new { text-align: right; color: blue; } .new { text-align: right; }
.sub { font-size: 80%; color: #555; } .sub { font-size: 80%; color: #555; }
""" """
@ -110,32 +117,30 @@ $(function () {
buf += line % ( buf += line % (
"<a href=chgrp>%s</a>" % _("Selected Groups"), "<a href=chgrp>%s</a>" % _("Selected Groups"),
counts[0], counts[1], counts[0], counts[1],
but("studysel", _("Study"), "1") + but("studysel", _("Study"), "1", "gbut") +
but("cramsel", _("Cram"), "3")) but("cramsel", _("Cram"), "3"))
buf += line % ( buf += line % (
_("Whole Deck"), _("Whole Deck"),
counts[2], counts[3], counts[2], counts[3],
but("studyall", _("Study"), "2") + but("studyall", _("Study"), "2", "gbut") +
but("cramall", _("Cram"), "4")) but("cramall", _("Cram"), "4"))
buf += "</table>" buf += "</table>"
return buf return buf
def _ovOpts(self): def _ovOpts(self):
if self.mw.deck.qconf['newCardOrder'] == NEW_CARDS_RANDOM: return ""
ord = _("random") # if self.mw.deck.qconf['newCardOrder'] == NEW_CARDS_RANDOM:
else: # ord = _("random")
ord = _("order added") # else:
but = self.mw.button # ord = _("order added")
buf = """ # buf = """
<table width=400> # <table width=400>
<tr><td><b>%s</b></td><td align=center>%s</td><td align=right rowspan=1>%s</td></tr> # <tr><td><b>%s</b></td><td align=center>%s</td></tr>
<tr><td><b>%s</b></td><td align=center>%s</td><td align=right rowspan=1>%s</td></tr> # <tr><td><b>%s</b></td><td align=center>%s</td></tr>
</table>""" % ( # </table>""" % (
_("New cards per day"), self.mw.deck.qconf['newPerDay'], # _("New cards per day"), self.mw.deck.qconf['newPerDay'],
but("opts", _("Study Options"), "o"), # _("New card order"), ord)
_("New card order"), ord, # return buf
but("list", "&#x25C0;"+_("Deck List"), "d"))
return buf
# Data # Data
########################################################################## ##########################################################################

View file

@ -6,17 +6,12 @@ import time, os, stat, shutil, difflib, simplejson
import unicodedata as ucd import unicodedata as ucd
from PyQt4.QtCore import * from PyQt4.QtCore import *
from PyQt4.QtGui import * from PyQt4.QtGui import *
from anki.consts import NEW_CARDS_RANDOM
from anki.utils import fmtTimeSpan, stripHTML from anki.utils import fmtTimeSpan, stripHTML
from anki.hooks import addHook, runHook, runFilter from anki.hooks import addHook, runHook, runFilter
from anki.sound import playFromText from anki.sound import playFromText
from aqt.utils import mungeQA, getBase from aqt.utils import mungeQA, getBase
import aqt import aqt
failedCharColour = "#FF0000"
passedCharColour = "#00FF00"
futureWarningColour = "#FF0000"
class Reviewer(object): class Reviewer(object):
"Manage reviews. Maintains a separate state." "Manage reviews. Maintains a separate state."
@ -28,7 +23,6 @@ class Reviewer(object):
# self.onLoadFinished) # self.onLoadFinished)
def show(self): def show(self):
self._setupToolbar()
self._reset() self._reset()
# State control # State control
@ -192,6 +186,10 @@ class Reviewer(object):
# Question and answer # Question and answer
########################################################################## ##########################################################################
failedCharColour = "#FF0000"
passedCharColour = "#00FF00"
futureWarningColour = "#FF0000"
def center(self, str, height=40): def center(self, str, height=40):
if not self.main.config['splitQA']: if not self.main.config['splitQA']:
return "<center>" + str + "</center>" return "<center>" + str + "</center>"
@ -365,11 +363,3 @@ class Reviewer(object):
"Tell the user the deck is finished." "Tell the user the deck is finished."
self.main.mainWin.congratsLabel.setText( self.main.mainWin.congratsLabel.setText(
self.main.deck.deckFinishedMsg()) self.main.deck.deckFinishedMsg())
# Toolbar
##########################################################################
def _setupToolbar(self):
if not self.mw.config['showToolbar']:
return
self.mw.form.toolBar.show()