mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
various layout tweaks
This commit is contained in:
parent
7604fa3797
commit
265b598173
4 changed files with 56 additions and 51 deletions
|
@ -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(["<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
|
||||
|
||||
# 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%; }
|
|||
<h1>%(title)s</h1>
|
||||
%(tb)s
|
||||
<p>
|
||||
<table cellspacing=0 cellpadding=0 width=90%%>
|
||||
<table cellspacing=0 cellpadding=3 width=100%%>
|
||||
%(rows)s
|
||||
</table>
|
||||
<div class="extra">
|
||||
%(extra)s
|
||||
</div>
|
||||
</center>
|
||||
"""
|
||||
|
||||
|
@ -144,6 +147,8 @@ a { font-size: 80%; }
|
|||
buf = ""
|
||||
css = self.mw.sharedCSS + self._css
|
||||
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):
|
||||
buf += self._deckRow(c, max, deck)
|
||||
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▼</a></td>" % (
|
||||
c, "Options")
|
||||
buf += "</tr>"
|
||||
if c != max:
|
||||
buf += "<tr><td colspan=4><hr noshade></td></tr>"
|
||||
# if c != max:
|
||||
# buf += "<tr><td colspan=4><hr noshade></td></tr>"
|
||||
return buf
|
||||
|
||||
def _summary(self):
|
||||
|
|
19
aqt/main.py
19
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 '<a class=but title="%s" href="%s">%s</a>' % (
|
||||
key, link, name)
|
||||
return '<a class="%s" title="%s" href="%s">%s</a>' % (
|
||||
class_, key, link, name)
|
||||
|
||||
# Signal handling
|
||||
##########################################################################
|
||||
|
|
|
@ -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 = """
|
||||
<center>
|
||||
<h1>%(title)s</h1>
|
||||
%(buts)s
|
||||
<p>
|
||||
%(table)s
|
||||
<hr>
|
||||
<p>
|
||||
<div id="placeholder" style="width:350px; height:100px;"></div>
|
||||
<span class=sub>%(fcsub)s</span>
|
||||
<hr class=sub>
|
||||
<p>
|
||||
%(opts)s
|
||||
</center>
|
||||
|
||||
|
@ -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 % (
|
||||
"<a href=chgrp>%s</a>" % _("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 += "</table>"
|
||||
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 = """
|
||||
<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><td align=right rowspan=1>%s</td></tr>
|
||||
</table>""" % (
|
||||
_("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 = """
|
||||
# <table width=400>
|
||||
# <tr><td><b>%s</b></td><td align=center>%s</td></tr>
|
||||
# <tr><td><b>%s</b></td><td align=center>%s</td></tr>
|
||||
# </table>""" % (
|
||||
# _("New cards per day"), self.mw.deck.qconf['newPerDay'],
|
||||
# _("New card order"), ord)
|
||||
# return buf
|
||||
|
||||
# Data
|
||||
##########################################################################
|
||||
|
|
|
@ -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 "<center>" + str + "</center>"
|
||||
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue