mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 00:12:25 -04:00
add another toolbar at the bottom
This commit is contained in:
parent
bea1e60fc8
commit
b745567bb3
9 changed files with 93 additions and 32 deletions
|
@ -4,11 +4,11 @@
|
|||
import os, sys
|
||||
from aqt.qt import *
|
||||
|
||||
appName="Anki"
|
||||
appVersion="2.0-alpha2"
|
||||
appWebsite="http://ankisrs.net/"
|
||||
appHelpSite="http://ankisrs.net/docs/dev/"
|
||||
appDonate="http://ankisrs.net/support/"
|
||||
appShared="http://test.ankiweb.net/shared/decks/"
|
||||
mw = None # set on init
|
||||
|
||||
moduleDir = os.path.split(os.path.dirname(os.path.abspath(__file__)))[0]
|
||||
|
|
|
@ -1415,21 +1415,22 @@ Are you sure you want to continue?""")):
|
|||
######################################################################
|
||||
|
||||
class BrowserToolbar(Toolbar):
|
||||
always = [
|
||||
["setDeck", "Move to Deck"],
|
||||
["addTags", "Add Tags"],
|
||||
["remTags", "Remove Tags"],
|
||||
]
|
||||
|
||||
def __init__(self, mw, web, browser):
|
||||
self.browser = browser
|
||||
Toolbar.__init__(self, mw, web)
|
||||
|
||||
def _centerLinks(self):
|
||||
links = [
|
||||
["setDeck", _("Move to Deck")],
|
||||
["addTags", _("Add Tags")],
|
||||
["remTags", _("Remove Tags")],
|
||||
]
|
||||
return self._linkHTML(links)
|
||||
|
||||
def draw(self):
|
||||
mark = self.browser.isMarked()
|
||||
pause = self.browser.isSuspended()
|
||||
links = self.always[:]
|
||||
self.centerLinks = links
|
||||
def borderImg(link, icon, on):
|
||||
if on:
|
||||
fmt = '''\
|
||||
|
|
|
@ -3,13 +3,15 @@
|
|||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
|
||||
from aqt.qt import *
|
||||
from aqt.utils import askUser, getOnlyText
|
||||
from aqt.utils import askUser, getOnlyText, openLink
|
||||
import aqt
|
||||
|
||||
class DeckBrowser(object):
|
||||
|
||||
def __init__(self, mw):
|
||||
self.mw = mw
|
||||
self.web = mw.web
|
||||
self.bottom = aqt.toolbar.BottomBar(mw, mw.bottomWeb)
|
||||
|
||||
def show(self, _init=True):
|
||||
if _init:
|
||||
|
@ -28,18 +30,10 @@ class DeckBrowser(object):
|
|||
self._selDeck(arg)
|
||||
elif cmd == "opts":
|
||||
self._showOptions(arg)
|
||||
elif cmd == "download":
|
||||
self.mw.onGetSharedDeck()
|
||||
elif cmd == "new":
|
||||
self.mw.onNew()
|
||||
elif cmd == "shared":
|
||||
self._onShared()
|
||||
elif cmd == "import":
|
||||
self.mw.onImport()
|
||||
elif cmd == "opensel":
|
||||
self.mw.onOpen()
|
||||
elif cmd == "synced":
|
||||
self.mw.onOpenOnline()
|
||||
elif cmd == "refresh":
|
||||
self.refresh()
|
||||
|
||||
def _selDeck(self, did):
|
||||
self.mw.col.decks.select(did)
|
||||
|
@ -74,6 +68,7 @@ body { margin: 1em; }
|
|||
self.web.stdHtml(self._body%dict(
|
||||
title=_("Decks"),
|
||||
tree=tree), css=css)
|
||||
self._drawButtons()
|
||||
|
||||
def _renderDeckTree(self, nodes, depth=0):
|
||||
if not nodes:
|
||||
|
@ -136,3 +131,22 @@ body { margin: 1em; }
|
|||
Are you sure you wish to delete all of the cards in %s?""")%deck['name']):
|
||||
self.mw.col.decks.rem(did, True)
|
||||
self.show()
|
||||
|
||||
# Top buttons
|
||||
######################################################################
|
||||
|
||||
def _drawButtons(self):
|
||||
links = [
|
||||
["shared", _("Get Shared")],
|
||||
["import", _("Import File")],
|
||||
]
|
||||
buf = ""
|
||||
for b in links:
|
||||
buf += "<button onclick='py.link(\"%s\");'>%s</button>" % tuple(b)
|
||||
self.bottom.draw(buf)
|
||||
self.bottom.web.setFixedHeight(32)
|
||||
self.bottom.web.setLinkHandler(self._linkHandler)
|
||||
|
||||
def _onShared(self):
|
||||
print "fixme: check & warn if schema modified first"
|
||||
openLink(aqt.appShared)
|
||||
|
|
10
aqt/main.py
10
aqt/main.py
|
@ -326,12 +326,20 @@ title="%s">%s</button>''' % (
|
|||
self.web.setObjectName("mainText")
|
||||
self.web.setFocusPolicy(Qt.WheelFocus)
|
||||
self.web.setMinimumWidth(400)
|
||||
# bottom area
|
||||
sweb = self.bottomWeb = aqt.webview.AnkiWebView()
|
||||
#sweb.hide()
|
||||
sweb.setFixedHeight(100)
|
||||
sweb.setObjectName("bottomWeb")
|
||||
sweb.setFocusPolicy(Qt.WheelFocus)
|
||||
sweb.stdHtml("foo")
|
||||
# add in a layout
|
||||
self.mainLayout = QVBoxLayout()
|
||||
self.mainLayout.setContentsMargins(0,0,0,0)
|
||||
self.mainLayout.setSpacing(0)
|
||||
self.mainLayout.addWidget(tweb)
|
||||
self.mainLayout.addWidget(self.web)
|
||||
self.mainLayout.addWidget(sweb)
|
||||
self.form.centralwidget.setLayout(self.mainLayout)
|
||||
|
||||
def closeAllWindows(self):
|
||||
|
@ -738,7 +746,7 @@ Please choose a new deck name:"""))
|
|||
self.enableDeckMenuItems(enabled=False)
|
||||
|
||||
def updateTitleBar(self):
|
||||
self.setWindowTitle(aqt.appName)
|
||||
self.setWindowTitle("Anki")
|
||||
|
||||
# Auto update
|
||||
##########################################################################
|
||||
|
|
|
@ -7,6 +7,7 @@ from aqt.qt import *
|
|||
from anki.consts import NEW_CARDS_RANDOM
|
||||
from anki.hooks import addHook
|
||||
from aqt.utils import showInfo
|
||||
import aqt
|
||||
|
||||
class Overview(object):
|
||||
"Deck overview."
|
||||
|
@ -14,6 +15,7 @@ class Overview(object):
|
|||
def __init__(self, mw):
|
||||
self.mw = mw
|
||||
self.web = mw.web
|
||||
self.bottom = aqt.toolbar.BottomBar(mw, mw.bottomWeb)
|
||||
addHook("reset", self.refresh)
|
||||
|
||||
def show(self):
|
||||
|
@ -23,8 +25,9 @@ class Overview(object):
|
|||
|
||||
def refresh(self):
|
||||
self._renderPage()
|
||||
self._renderBottom()
|
||||
|
||||
# Handlers
|
||||
# Handlers
|
||||
############################################################
|
||||
|
||||
def _keyHandler(self, evt):
|
||||
|
@ -127,4 +130,8 @@ h3 { margin-bottom: 0; }
|
|||
td { font-size: 14px; }
|
||||
"""
|
||||
|
||||
# Bottom area
|
||||
######################################################################
|
||||
|
||||
def _renderBottom(self):
|
||||
self.bottom.draw("hello")
|
||||
|
|
|
@ -23,6 +23,7 @@ class Reviewer(object):
|
|||
self.state = None
|
||||
self.keep = False
|
||||
self._setupStatus()
|
||||
self.bottom = aqt.toolbar.BottomBar(mw, mw.bottomWeb)
|
||||
addHook("leech", self.onLeech)
|
||||
|
||||
def show(self):
|
||||
|
|
|
@ -25,22 +25,24 @@ class Toolbar(object):
|
|||
# Available links
|
||||
######################################################################
|
||||
|
||||
centerLinks = [
|
||||
["decks", "Decks"],
|
||||
["study", "Study"],
|
||||
["add", "Add"],
|
||||
["browse", "Browse"],
|
||||
]
|
||||
|
||||
rightIcons = [
|
||||
["stats", "qrc:/icons/view-statistics.png"],
|
||||
["sync", "qrc:/icons/view-refresh.png"],
|
||||
]
|
||||
|
||||
def _centerLinks(self):
|
||||
links = [
|
||||
["decks", _("Decks")],
|
||||
["study", _("Study")],
|
||||
["add", _("Add")],
|
||||
["browse", _("Browse")],
|
||||
]
|
||||
return self._linkHTML(links)
|
||||
|
||||
def _linkHTML(self, links):
|
||||
buf = ""
|
||||
for ln, name in self.centerLinks:
|
||||
buf += '<a class=hitem href="%s">%s</a>' % (ln, _(name))
|
||||
for ln, name in links:
|
||||
buf += '<a class=hitem href="%s">%s</a>' % (ln, name)
|
||||
buf += " "*3
|
||||
return buf
|
||||
|
||||
|
@ -89,12 +91,16 @@ margin:0;
|
|||
background: -webkit-gradient(linear, left top, left bottom,
|
||||
from(#ddd), to(#fff));
|
||||
font-weight: bold;
|
||||
height: 10px;
|
||||
margin-bottom: 1px;
|
||||
border-bottom: 1px solid #aaa;
|
||||
}
|
||||
|
||||
body { margin: 0; padding: 0; }
|
||||
body {
|
||||
margin: 0; padding: 0;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
|
||||
* { -webkit-user-drag: none; }
|
||||
|
||||
.hitem { display: inline-block; padding: 4px; padding-right: 6px;
|
||||
text-decoration: none; color: #000;
|
||||
|
@ -104,3 +110,27 @@ background: #333;
|
|||
color: #fff;
|
||||
}
|
||||
"""
|
||||
|
||||
class BottomBar(Toolbar):
|
||||
|
||||
_css = Toolbar._css + """
|
||||
#header {
|
||||
background: -webkit-gradient(linear, left top, left bottom,
|
||||
from(#fff), to(#ddd));
|
||||
border-bottom: 0;
|
||||
border-top: 1px solid #aaa;
|
||||
font-weight: normal;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
"""
|
||||
|
||||
_centerBody = """
|
||||
<center><table width=100%% height=100%% id=header><tr><td align=center>
|
||||
%s</td></tr></table></center>
|
||||
"""
|
||||
|
||||
def draw(self, buf):
|
||||
self.web.show()
|
||||
self.web.stdHtml(
|
||||
self._centerBody % buf,
|
||||
self._css)
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 831 B After Width: | Height: | Size: 3.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
Loading…
Reference in a new issue