def _onTreeDeckRenameLeaf(self, item): mw.checkpoint(_("Rename Deck")) from aqt.utils import showWarning from anki.errors import DeckRenameError self.browser._lastSearchTxt = "" sel = mw.col.decks.byName(item.fullname) try: path, leaf = item.fullname.rsplit('::', 1) newName = path + '::' + getOnlyText(_("New deck name:"), default=leaf) except ValueError: newName = getOnlyText(_("New deck name:"), default=item.fullname) newName = newName.replace('"', "") if not newName or newName == item.fullname: return newName = unicodedata.normalize("NFC", newName) deck = mw.col.decks.get(sel["id"]) try: mw.col.decks.rename(deck, newName) except DeckRenameError as e: return showWarning(e.description) self._swapHighlight(item.type, item.fullname, newName) self._saveDecks() # self.highlight('deck',newName) mw.show() mw.reset(True)
def minimize(self): """ Should minimize (hide) the window. """ mw.hide() # example usage of showInfo utility # uncomment to see, the window is really hidden #showInfo("Hidden window!") # we should add an icon in notification area to allow unhiding windows # then we will be able to remove show call mw.show() return 0
def alwaysOnTop(): windowFlags = mw.windowFlags() windowFlags ^= Qt.WindowStaysOnTopHint mw.setWindowFlags(windowFlags) mw.show()
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()