def onFullScreen(): if not mw.isFullScreen(): mw.setWindowState(mw.windowState() | Qt.WindowFullScreen) if HIDE_MENU_BAR: mw.menuBar().hide() custom_undo.setEnabled(True) else: mw.setWindowState(mw.windowState() ^ Qt.WindowFullScreen) mw.menuBar().show() custom_undo.setEnabled(False)
def add_same_day_spacing_to_menu(): global menu_added menu_added += 1 if not menu_added > 1: try: m = mw.menuView except: mlabel_ger = u"&Kartenreihenfolge" mlabel_en = u"&Study" mw.menuView = QMenu(mlabel_ger if German else mlabel_en) action = mw.menuBar().insertMenu(mw.form.menuTools.menuAction(), mw.menuView) m = mw.menuView label_ger = u'Zusammengehörende Karten direkt nacheinander abfragen' label_en = u'change scheduler - no same-day spacing for siblings/show due siblings in order' a = m.addAction(label_ger if German else label_en) a.setCheckable(True) a.setChecked(nospacing) a.toggled.connect(toggleSameDaySpacing)
self.webHtml = html self.onHtml() def toolbarCb(self, html): self.toolbarHtml = html self.onHtml() def bottomCb(self, html): self.bottomHtml = html self.onHtml() def onHtml(self): if self.webHtml != None and self.toolbarHtml != None and self.bottomHtml != None: html = self.toolbarHtml + "\n" + self.webHtml + "\n" + self.bottomHtml showText(html, title="WebView HTML", minWidth=600, minHeight=600) self.clear() mw.debugHtml = DebugHtml() debugMenu = mw.menuBar().addMenu("Debug") action = QAction("Show Deck JSON", mw) action.triggered.connect(showDeckJson) #mw.form.menuTools.addAction(action) debugMenu.addAction(action) action2 = QAction("Show WebView HTML", mw) action2.triggered.connect(mw.debugHtml.requestHtml) #mw.form.menuTools.addAction(action2) debugMenu.addAction(action2)
Anki addons: https://groups.google.com/forum/?hl=en#!forum/anki-addons """ from PyQt4.QtCore import SIGNAL from PyQt4.QtGui import QMenu from anki.hooks import wrap from aqt import mw from aqt.main import AnkiQt __author__ = 'Steve' def hide_toolbar_reviewing(self, oldState): self.toolbar.web.hide() def show_toolbar_not_reviewing(self, state, *args): #Rather than tracking the state of the toolbar's visibility #leave it to Qt to handle. m self.toolbar.web.show() AnkiQt._reviewState = wrap(AnkiQt._reviewState, hide_toolbar_reviewing, "after") AnkiQt.moveToState = wrap(AnkiQt.moveToState, show_toolbar_not_reviewing, "before") toolbar_menu = QMenu("Tool&bar") action = mw.menuBar().insertMenu(mw.form.menuTools.menuAction(), toolbar_menu) #Not really the intended purpose of link_handlers, but good enough for key, value in iter(sorted(mw.toolbar.link_handlers.items())): a = toolbar_menu.addAction(key.title()) a.connect(a, SIGNAL("triggered()"), value)
def NO_bottomHTML(self): #deac if not self.mode: mw.menuBar().hide() mw.toolbar.web.hide() mw.setWindowFlags(Qt.CustomizeWindowHint | Qt.Window) mw.show() mw.activateWindow() return """ <style> body{font-family: 'Microsoft YaHei UI', serif;} .timer {font-family: 'Microsoft YaHei UI', serif; color: #f0545e;font-weight: bold;font-size:15pt; padding-left: 5px; padding-right: 5px; white-space: nowrap; } </style> <table width=100%% cellspacing=0 cellpadding=0> <tr> <td align=left valign=center width = 20%%> <table > <tr> <td width=50 align=center valign=center class=stat> <input type=image value = "%(r)s" onclick="py.link('decks');" src="qrc:/icon/tomato.png" width=32 height=32 /> </td> <td width=50 align=center valign=center class=stat> %(timer)s </td> <tr> </table> </td> <td align=center valign=top id=middle width = 60%%> </td> <td align=left valign=center width = 20%%> <span></span> </td> </tr> </table> <script> var time = %(time)d; var maxTime = -1; $(function () { $("#ansbut").focus(); updateTime(); setInterval(function () { time+=1;maxTime -= 1; updateTime() }, 1000); }); var updateTime = function () { if (maxTime<0) { return; } // maxTime = Math.max(maxTime, time); var m = Math.floor(maxTime / 60); var s = maxTime %% 60; if (s < 10) { s = "0" + s; } var e = $("#time"); if (time==maxTime){ py.link('half_time') } if (!maxTime) { e.html("<font color=red>" + m + ":" + s + "</font>"); py.link('timeout') } else { e.text(m + ":" + s); } } function showQuestion(txt, maxTime_) { // much faster than jquery's .html() $("#middle")[0].innerHTML = txt; $("#ansbut").focus(); time = 0; maxTime = maxTime_; } function showAnswer(txt) { $("#middle")[0].innerHTML = txt; $("#defease").focus(); } function stopTimer(maxTime_){ $("#time").text(""); maxTime = maxTime_; } </script> """ % dict(r=_2("RETURN"), timer="<span id=time class=timer></span>" , rem=self._remaining(), time=self.card.timeTaken() // 1000) return super(anki_reviewer, self)._bottomHTML()
def restore_layouts(self): mw.menuBar().show() mw.setWindowFlags(Qt.Window) mw.show() mw.activateWindow() mw.toolbar.web.show()