diff --git a/aqt/about.py b/aqt/about.py index ccf6e19bd..3755aea85 100644 --- a/aqt/about.py +++ b/aqt/about.py @@ -32,6 +32,9 @@ Suba, and Xtru. Anki icon by Alex Fraser (CC GNU GPL) Deck icon by Laurent Baumann (CC BY-NC-SA 3.0) +Deck browser icons from: +http://led24.de/iconset +http://p.yusukekamiyamane.com/ Other icons under LGPL or public domain. """ diff --git a/aqt/deckbrowser.py b/aqt/deckbrowser.py index f2246c85e..0fb566ecd 100644 --- a/aqt/deckbrowser.py +++ b/aqt/deckbrowser.py @@ -62,7 +62,6 @@ body { margin: 1em; } _body = """
-

%(title)s

%(tree)s
@@ -98,12 +97,10 @@ body { margin: 1em; } return buf def _dueImg(self, due, new): - if due and new: - i = "both" - elif due: - i = "green" + if due: + i = "clock-icon" elif new: - i = "blue" + i = "plus-circle" else: i = "none" return '' % i diff --git a/aqt/main.py b/aqt/main.py index fec4bddfd..6c8263b94 100755 --- a/aqt/main.py +++ b/aqt/main.py @@ -15,7 +15,7 @@ from anki.utils import stripHTML, checksum, isWin, isMac from anki.hooks import runHook, addHook, removeHook import anki.consts -import aqt, aqt.progress, aqt.webview +import aqt, aqt.progress, aqt.webview, aqt.toolbar from aqt.utils import saveGeom, restoreGeom, showInfo, showWarning, \ saveState, restoreState, getOnlyText, askUser, GetTextDialog, \ askUserDialog, applyStyles, getText, showText, showCritical, getFile @@ -182,8 +182,10 @@ Are you sure?"""): restoreState(self, "mainWindow") else: self.resize(500, 400) + # toolbar needs to be retranslated + self.toolbar.draw() + # show and raise window for osx self.show() - # raise window for osx self.activateWindow() self.raise_() # maybe sync @@ -312,14 +314,23 @@ title="%s">%s''' % ( # main window self.form = aqt.forms.main.Ui_MainWindow() self.form.setupUi(self) - self.web = aqt.webview.AnkiWebView(self.form.centralwidget) + # toolbar + tweb = aqt.webview.AnkiWebView() + tweb.setObjectName("toolbarWeb") + tweb.setFocusPolicy(Qt.WheelFocus) + tweb.setFixedHeight(32) + self.toolbar = aqt.toolbar.Toolbar(self, tweb) + # main area + self.web = aqt.webview.AnkiWebView() self.web.setObjectName("mainText") self.web.setFocusPolicy(Qt.WheelFocus) + # add in a layout self.mainLayout = QVBoxLayout() - self.mainLayout.addWidget(self.web) self.mainLayout.setContentsMargins(0,0,0,0) + self.mainLayout.setSpacing(0) + self.mainLayout.addWidget(tweb) + self.mainLayout.addWidget(self.web) self.form.centralwidget.setLayout(self.mainLayout) - addHook("undoEnd", self.maybeEnableUndo) def closeAllWindows(self): aqt.dialogs.closeAll() @@ -607,6 +618,7 @@ Debug info:\n%s""") % traceback.format_exc(), help="DeckErrors") aqt.studyopts.StudyOptions(self) def onOverview(self): + self.col.reset() self.moveToState("overview") def onGroups(self, parent=None): diff --git a/aqt/overview.py b/aqt/overview.py index 39e894e02..91746c3bf 100644 --- a/aqt/overview.py +++ b/aqt/overview.py @@ -67,25 +67,7 @@ class Overview(object): shareLink = 'Reviews and Updates' else: shareLink = "" - header = """ - - - - - -
-""" #% deck['name'] - + header = "" self.web.stdHtml(self._overviewBody % dict( title=_("Overview"), table=tbl, @@ -134,29 +116,6 @@ $(function () { .sub { font-size: 80%; color: #555; } .smallLink { font-size: 12px; } h3 { margin-bottom: 0; } -#headerSpace { height: 22px; } -#header { -z-index: 100; -position: fixed; -height: 22px; -font-size: 12px; -margin:0; -background: -webkit-gradient(linear, left top, left bottom, -from(#ddd), to(#fff)); -border-bottom: 1px solid #ccc; -font-weight: bold; -} -body { margin: 0; } -.deck { } -.hitem { display: inline-block; padding: 4px; padding-right: 6px; -text-decoration: none; color: #000; -} -.hborder { border: 1px solid #ddd; } -.hitem:hover { -background: #333; -color: #fff; -} -.icon { padding-top: 2px; } """ def _overviewTable(self): diff --git a/aqt/reviewer.py b/aqt/reviewer.py index a20dd6e48..f6cd5e54f 100644 --- a/aqt/reviewer.py +++ b/aqt/reviewer.py @@ -526,6 +526,7 @@ div#filler { ########################################################################## def _setupStatus(self): + return self._statusWidgets = [] sb = self.mw.form.statusbar def addWgt(w, stretch=0): diff --git a/aqt/toolbar.py b/aqt/toolbar.py new file mode 100644 index 000000000..d748f9b5a --- /dev/null +++ b/aqt/toolbar.py @@ -0,0 +1,102 @@ +# Copyright: Damien Elmes +# -*- coding: utf-8 -*- +# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html + +from aqt.qt import * +from aqt.webview import AnkiWebView + +class Toolbar(object): + + def __init__(self, mw, web): + self.mw = mw + self.web = web + self.web.page().mainFrame().setScrollBarPolicy( + Qt.Vertical, Qt.ScrollBarAlwaysOff) + self.web.setLinkHandler(self._linkHandler) + self.draw() + + def draw(self): + body = self._body % (self._centerLinks(), self._rightIcons()) + self.web.stdHtml(body, self._css) + + # 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): + buf = "" + for ln, name in self.centerLinks: + buf += '%s' % (ln, _(name)) + return buf + + def _rightIcons(self): + buf = "" + for ln, icon in self.rightIcons: + buf += '' % ( + ln, icon) + return buf + + # Link handling + ###################################################################### + + def _linkHandler(self, l): + if l == "anki": + self.showMenu() + elif l == "decks": + self.mw.moveToState("deckBrowser") + elif l == "study": + self.mw.onOverview() + elif l == "add": + self.mw.onAddCard() + elif l == "browse": + self.mw.onBrowse() + elif l == "stats": + self.mw.onStats() + elif l == "sync": + self.mw.onSync() + + # HTML & CSS + ###################################################################### + + _body = """ + + + + + + +""" + + _css = """ +#header { +font-size: 12px; +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; } + +.hitem { display: inline-block; padding: 4px; padding-right: 6px; +text-decoration: none; color: #000; +} +.hitem:hover { +background: #333; +color: #fff; +} +""" diff --git a/aqt/webview.py b/aqt/webview.py index b03a179ed..5016b4b19 100644 --- a/aqt/webview.py +++ b/aqt/webview.py @@ -28,8 +28,8 @@ class Bridge(QObject): class AnkiWebPage(QWebPage): - def __init__(self, parent, jsErr): - QWebPage.__init__(self, parent) + def __init__(self, jsErr): + QWebPage.__init__(self) self._jsErr = jsErr def javaScriptConsoleMessage(self, msg, line, srcID): self._jsErr(msg, line, srcID) @@ -38,11 +38,11 @@ class AnkiWebPage(QWebPage): ########################################################################## class AnkiWebView(QWebView): - def __init__(self, parent): - QWebView.__init__(self, parent) + def __init__(self): + QWebView.__init__(self) self.setObjectName("mainText") self._bridge = Bridge() - self._page = AnkiWebPage(parent, self._jsErr) + self._page = AnkiWebPage(self._jsErr) self._loadFinishedCB = None self.setPage(self._page) self.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks) diff --git a/designer/icons.qrc b/designer/icons.qrc index afc539d1d..a6a9f8855 100644 --- a/designer/icons.qrc +++ b/designer/icons.qrc @@ -3,6 +3,8 @@ icons/blue.png icons/both.png icons/green.png + icons/clock-icon.png + icons/plus-circle.png icons/none.png icons/edit-find 2.png icons/edit-find-replace.png diff --git a/designer/icons/clock-icon.png b/designer/icons/clock-icon.png new file mode 100644 index 000000000..0d2cab138 Binary files /dev/null and b/designer/icons/clock-icon.png differ diff --git a/designer/icons/plus-circle.png b/designer/icons/plus-circle.png new file mode 100644 index 000000000..2d0bc6365 Binary files /dev/null and b/designer/icons/plus-circle.png differ diff --git a/designer/main.ui b/designer/main.ui index decb72d08..877751f04 100644 --- a/designer/main.ui +++ b/designer/main.ui @@ -137,11 +137,6 @@ - - - true - -