mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
move the toolback into the browser screen
This commit is contained in:
parent
045d92238d
commit
3f1ed1a566
1 changed files with 40 additions and 13 deletions
|
@ -17,16 +17,21 @@ body { background-color: #eee; }
|
||||||
.sub { color: #555; }
|
.sub { color: #555; }
|
||||||
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:#ddd; }
|
||||||
a:hover { background-color: #aaa; }
|
a:hover { background-color: #aaa; }
|
||||||
a { color: #000; text-decoration: none; }
|
a.deck { color: #000; text-decoration: none; }
|
||||||
.num { text-align: right; padding: 0 5 0 5; }
|
.num { text-align: right; padding: 0 5 0 5; }
|
||||||
td.opts { text-align: right; white-space: nowrap; }
|
td.opts { text-align: right; white-space: nowrap; }
|
||||||
a.opts { font-size: 80%; padding: 2; background-color: #ccc; border-radius: 2px; }
|
a.opts { font-size: 80%; padding: 2; background-color: #ccc; border-radius: 2px; }
|
||||||
|
td.menu { text-align: center; }
|
||||||
|
a.tb { font-size: 80%; text-decoration: none; }
|
||||||
|
h1 { margin-bottom: 0.2em; }
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_body = """
|
_body = """
|
||||||
<center>
|
<center>
|
||||||
<div id="outer">
|
<div id="outer">
|
||||||
<h1>%(title)s</h1>
|
<h1>%(title)s</h1>
|
||||||
|
%(tb)s
|
||||||
|
<p>
|
||||||
<table cellspacing=0 cellpadding=0 width=90%%>
|
<table cellspacing=0 cellpadding=0 width=90%%>
|
||||||
%(rows)s
|
%(rows)s
|
||||||
</table>
|
</table>
|
||||||
|
@ -42,8 +47,6 @@ class DeckBrowser(object):
|
||||||
self.web = mw.web
|
self.web = mw.web
|
||||||
self._browserLastRefreshed = 0
|
self._browserLastRefreshed = 0
|
||||||
self._decks = []
|
self._decks = []
|
||||||
mw.connect(mw.form.actionRefreshDeckBrowser, SIGNAL("activated()"),
|
|
||||||
self.refresh)
|
|
||||||
addHook("deckClosing", self.onClose)
|
addHook("deckClosing", self.onClose)
|
||||||
|
|
||||||
def show(self, _init=True):
|
def show(self, _init=True):
|
||||||
|
@ -80,26 +83,48 @@ class DeckBrowser(object):
|
||||||
# Toolbar
|
# Toolbar
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
# we don't use the top toolbar
|
||||||
def _setupToolbar(self):
|
def _setupToolbar(self):
|
||||||
self.mw.form.toolBar.hide()
|
self.mw.form.toolBar.hide()
|
||||||
return
|
|
||||||
tb.addAction(frm.actionDownloadSharedDeck)
|
# instead we have a html one under the deck list
|
||||||
tb.addAction(frm.actionNew)
|
def _toolbar(self):
|
||||||
tb.addAction(frm.actionOpen)
|
items = [
|
||||||
tb.addAction(frm.actionImport)
|
("download", _("Download Shared")),
|
||||||
tb.addAction(frm.actionOpenOnline)
|
("new", _("Create")),
|
||||||
tb.addAction(frm.actionRefreshDeckBrowser)
|
("import", _("Import")),
|
||||||
|
("opensel", _("Open")),
|
||||||
|
("synced", _("Synced")),
|
||||||
|
("refresh", _("Refresh")),
|
||||||
|
]
|
||||||
|
h = " | ".join(["<a class=tb href=%s>%s</a>" % row for row in items])
|
||||||
|
return h
|
||||||
|
|
||||||
# Event handlers
|
# Event handlers
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
def _linkHandler(self, url):
|
def _linkHandler(self, url):
|
||||||
|
if ":" in url:
|
||||||
(cmd, arg) = url.split(":")
|
(cmd, arg) = url.split(":")
|
||||||
|
else:
|
||||||
|
cmd = url
|
||||||
if cmd == "open":
|
if cmd == "open":
|
||||||
deck = self._decks[int(arg)]
|
deck = self._decks[int(arg)]
|
||||||
self._loadDeck(deck)
|
self._loadDeck(deck)
|
||||||
elif cmd == "opts":
|
elif cmd == "opts":
|
||||||
self._optsForRow(int(arg))
|
self._optsForRow(int(arg))
|
||||||
|
elif cmd == "download":
|
||||||
|
self.mw.onGetSharedDeck()
|
||||||
|
elif cmd == "new":
|
||||||
|
self.mw.onNew()
|
||||||
|
elif cmd == "import":
|
||||||
|
self.mw.onImport()
|
||||||
|
elif cmd == "opensel":
|
||||||
|
self.mw.onOpen()
|
||||||
|
elif cmd == "synced":
|
||||||
|
self.mw.onOpenOnline()
|
||||||
|
elif cmd == "refresh":
|
||||||
|
self.refresh()
|
||||||
|
|
||||||
def _keyHandler(self, evt):
|
def _keyHandler(self, evt):
|
||||||
txt = evt.text()
|
txt = evt.text()
|
||||||
|
@ -130,6 +155,7 @@ class DeckBrowser(object):
|
||||||
self.web.stdHtml(_body%dict(
|
self.web.stdHtml(_body%dict(
|
||||||
title=_("Decks"),
|
title=_("Decks"),
|
||||||
rows=buf,
|
rows=buf,
|
||||||
|
tb=self._toolbar(),
|
||||||
extra="<p>%s<p>%s" % (
|
extra="<p>%s<p>%s" % (
|
||||||
self._summary(),
|
self._summary(),
|
||||||
_("Click a deck to open it, or type a number."))),
|
_("Click a deck to open it, or type a number."))),
|
||||||
|
@ -139,7 +165,8 @@ class DeckBrowser(object):
|
||||||
title=_("Welcome!"),
|
title=_("Welcome!"),
|
||||||
rows="<tr><td align=center>%s</td></tr>"%_(
|
rows="<tr><td align=center>%s</td></tr>"%_(
|
||||||
"Click <b>Download</b> to get started."),
|
"Click <b>Download</b> to get started."),
|
||||||
extra=""),
|
extra="",
|
||||||
|
tb=self._toolbar()),
|
||||||
_css)
|
_css)
|
||||||
|
|
||||||
def _deckRow(self, c, max, deck):
|
def _deckRow(self, c, max, deck):
|
||||||
|
@ -153,7 +180,7 @@ class DeckBrowser(object):
|
||||||
# name/link
|
# name/link
|
||||||
buf += "<td>%s<b>%s</b></td>" % (
|
buf += "<td>%s<b>%s</b></td>" % (
|
||||||
accelName(deck),
|
accelName(deck),
|
||||||
"<a href='open:%d'>%s</a>"%(c, deck['name']))
|
"<a class=deck href='open:%d'>%s</a>"%(c, deck['name']))
|
||||||
# due
|
# due
|
||||||
col = '<td class=num><b><font color=#0000ff>%s</font></b></td>'
|
col = '<td class=num><b><font color=#0000ff>%s</font></b></td>'
|
||||||
if deck['due'] > 0:
|
if deck['due'] > 0:
|
||||||
|
|
Loading…
Reference in a new issue