drop the tray

This commit is contained in:
Damien Elmes 2011-03-27 12:52:04 +09:00
parent 204cd3c824
commit 73edb5eb28
4 changed files with 0 additions and 110 deletions

View file

@ -52,7 +52,6 @@ defaultConf = {
'showProgress': True, 'showProgress': True,
'showTimer': True, 'showTimer': True,
'showToolbar': True, 'showToolbar': True,
'showTrayIcon': False,
'splitQA': True, 'splitQA': True,
'stripHTML': True, 'stripHTML': True,
'studyOptionsTab': 0, 'studyOptionsTab': 0,

View file

@ -67,7 +67,6 @@ class AnkiQt(QMainWindow):
self.setupStyle() self.setupStyle()
self.setupProxy() self.setupProxy()
self.setupSound() self.setupSound()
self.setupTray()
self.setupMenus() self.setupMenus()
self.setupToolbar() self.setupToolbar()
self.setupProgress() self.setupProgress()
@ -360,10 +359,6 @@ counts are %d %d %d
else: else:
self.form.noticeFrame.setShown(False) self.form.noticeFrame.setShown(False)
def setupTray(self):
import aqt.tray
self.trayIcon = aqt.tray.AnkiTrayIcon(self)
# Deck loading & saving: backend # Deck loading & saving: backend
########################################################################## ##########################################################################

View file

@ -209,7 +209,6 @@ class Preferences(QDialog):
self.dialog.colourTimes.setChecked(self.config['colourTimes']) self.dialog.colourTimes.setChecked(self.config['colourTimes'])
self.dialog.showEstimates.setChecked(not self.config['suppressEstimates']) self.dialog.showEstimates.setChecked(not self.config['suppressEstimates'])
self.dialog.showStudyOptions.setChecked(self.config['showStudyScreen']) self.dialog.showStudyOptions.setChecked(self.config['showStudyScreen'])
self.dialog.showTray.setChecked(self.config['showTrayIcon'])
self.dialog.showTimer.setChecked(self.config['showTimer']) self.dialog.showTimer.setChecked(self.config['showTimer'])
self.dialog.showDivider.setChecked(self.config['qaDivider']) self.dialog.showDivider.setChecked(self.config['qaDivider'])
self.dialog.splitQA.setChecked(self.config['splitQA']) self.dialog.splitQA.setChecked(self.config['splitQA'])
@ -223,7 +222,6 @@ class Preferences(QDialog):
def updateAdvanced(self): def updateAdvanced(self):
self.config['colourTimes'] = self.dialog.colourTimes.isChecked() self.config['colourTimes'] = self.dialog.colourTimes.isChecked()
self.config['showTrayIcon'] = self.dialog.showTray.isChecked()
self.config['showTimer'] = self.dialog.showTimer.isChecked() self.config['showTimer'] = self.dialog.showTimer.isChecked()
self.config['suppressEstimates'] = not self.dialog.showEstimates.isChecked() self.config['suppressEstimates'] = not self.dialog.showEstimates.isChecked()
self.config['showStudyScreen'] = self.dialog.showStudyOptions.isChecked() self.config['showStudyScreen'] = self.dialog.showStudyOptions.isChecked()

View file

@ -1,102 +0,0 @@
# Copyright: Richard Colley <richard.colley@rcolley.com>
# License: GNU GPL, version 3 or later; http://www.gnu.org/copyleft/gpl.html
from PyQt4 import QtGui, QtCore
from anki.hooks import addHook
Qt = QtCore.Qt
class AnkiTrayIcon(QtCore.QObject):
"""
Enable minimize to tray
"""
def __init__(self, mw):
QtCore.QObject.__init__(self, mw)
self.mw = mw
self.anki_visible = True
self.tray_hidden = []
self.last_focus = None
if (QtGui.QSystemTrayIcon.isSystemTrayAvailable() and
mw.config['showTrayIcon']):
self.ti = QtGui.QSystemTrayIcon(mw)
self.ti.setObjectName("trayIcon")
if self.ti:
QtGui.QApplication.setQuitOnLastWindowClosed(False)
addHook("quit", self.onQuit)
self.ti.setIcon(QtGui.QIcon(":/icons/anki.png"))
self.ti.setToolTip("Anki")
# hook signls, and Anki state changes
mw.addView(self)
mw.connect(self.ti, QtCore.SIGNAL("activated(QSystemTrayIcon::ActivationReason)"),lambda i: self.activated(i))
mw.connect(self.ti, QtCore.SIGNAL("messageClicked()"), lambda : self.messageClicked())
mw.connect(self.mw.app, QtCore.SIGNAL("focusChanged(QWidget*,QWidget*)"), self.focusChanged)
self.ti.show()
def showAll(self):
for w in self.tray_hidden:
if w.isWindow() and w.isHidden():
w.showNormal()
active = self.last_focus or self.mw
active.raise_()
active.activateWindow()
self.anki_visible = True
self.tray_hidden = []
self.updateTooltip()
def hideAll(self):
self.tray_hidden = []
activeWindow = QtGui.QApplication.activeModalWidget()
for w in QtGui.QApplication.topLevelWidgets():
if w.isWindow() and not w.isHidden():
if not w.children():
continue
w.hide()
self.tray_hidden.append(w)
self.anki_visible = False
self.updateTooltip()
def activated(self, reason):
if self.anki_visible:
self.hideAll()
else:
self.showAll()
def messageClicked(self):
if not self.anki_visible:
self.showAll()
def focusChanged(self, old, now):
if now == None:
self.last_focus = old
def setToolTip(self, message):
self.ti.setToolTip(message)
def showMessage(self, message):
if self.ti.supportsMessages():
self.ti.showMessage("Anki", message)
def setState(self, state):
self.state = state
self.updateTooltip()
def updateTooltip(self):
state = self.state
if self.mw.deck:
name = self.mw.deck.name()
else:
name = "Anki"
msg = name + ":\n"
if state == "deckFinished":
msg += _("Today's reviews are finished")
elif self.mw.deck:
msg += _("Cards are waiting")
msg += "\n\n"
if self.anki_visible:
msg += _("Click to hide Anki")
else:
msg += _("Click to show Anki")
self.setToolTip(msg)
def onQuit(self):
self.ti.deleteLater()