Got appIndicator working on Windows. Surly needs to be retested on Linux and OSX.
This commit is contained in:
parent
52fd21733f
commit
1b810667fd
|
@ -424,10 +424,6 @@ class MyForm(QtGui.QMainWindow):
|
||||||
self.numberOfBroadcastsProcessed = 0
|
self.numberOfBroadcastsProcessed = 0
|
||||||
self.numberOfPubkeysProcessed = 0
|
self.numberOfPubkeysProcessed = 0
|
||||||
|
|
||||||
#Below this point, it would be good if all of the necessary global data structures were initialized.
|
|
||||||
|
|
||||||
self.rerenderComboBoxSendFrom()
|
|
||||||
|
|
||||||
self.UISignalThread = UISignaler()
|
self.UISignalThread = UISignaler()
|
||||||
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("writeNewAddressToTable(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.writeNewAddressToTable)
|
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("writeNewAddressToTable(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.writeNewAddressToTable)
|
||||||
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("updateStatusBar(PyQt_PyObject)"), self.updateStatusBar)
|
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("updateStatusBar(PyQt_PyObject)"), self.updateStatusBar)
|
||||||
|
@ -442,67 +438,62 @@ class MyForm(QtGui.QMainWindow):
|
||||||
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("setStatusIcon(PyQt_PyObject)"), self.setStatusIcon)
|
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("setStatusIcon(PyQt_PyObject)"), self.setStatusIcon)
|
||||||
self.UISignalThread.start()
|
self.UISignalThread.start()
|
||||||
|
|
||||||
#self.connectToStream(1)
|
#Below this point, it would be good if all of the necessary global data structures were initialized.
|
||||||
|
|
||||||
#self.singleListenerThread = singleListener()
|
self.rerenderComboBoxSendFrom()
|
||||||
#self.singleListenerThread.start()
|
|
||||||
#QtCore.QObject.connect(self.singleListenerThread, QtCore.SIGNAL("passObjectThrough(PyQt_PyObject)"), self.connectObjectToSignals)
|
|
||||||
|
|
||||||
|
#Show or hide the application window after clicking an item within the tray icon or, on Windows, the try icon itself.
|
||||||
#self.singleCleanerThread = singleCleaner()
|
def appIndicatorShowOrHideWindow(self):
|
||||||
#self.singleCleanerThread.start()
|
|
||||||
#QtCore.QObject.connect(self.singleCleanerThread, QtCore.SIGNAL("updateSentItemStatusByHash(PyQt_PyObject,PyQt_PyObject)"), self.updateSentItemStatusByHash)
|
|
||||||
#QtCore.QObject.connect(self.singleCleanerThread, QtCore.SIGNAL("updateStatusBar(PyQt_PyObject)"), self.updateStatusBar)
|
|
||||||
|
|
||||||
#self.workerThread = singleWorker()
|
|
||||||
#self.workerThread.start()
|
|
||||||
#QtCore.QObject.connect(self.workerThread, QtCore.SIGNAL("updateSentItemStatusByHash(PyQt_PyObject,PyQt_PyObject)"), self.updateSentItemStatusByHash)
|
|
||||||
#QtCore.QObject.connect(self.workerThread, QtCore.SIGNAL("updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"), self.updateSentItemStatusByAckdata)
|
|
||||||
#QtCore.QObject.connect(self.workerThread, QtCore.SIGNAL("updateStatusBar(PyQt_PyObject)"), self.updateStatusBar)
|
|
||||||
|
|
||||||
# an appindicator action which indicates the connection status
|
|
||||||
actionStatus = None
|
|
||||||
|
|
||||||
# an appindicator action which shows of hides the program window
|
|
||||||
actionShow = None
|
|
||||||
|
|
||||||
# show the application window
|
|
||||||
def appIndicatorShow(self):
|
|
||||||
if self.actionShow == None:
|
|
||||||
return
|
|
||||||
self.actionShow.setChecked(True)
|
|
||||||
self.show()
|
|
||||||
self.setWindowState(self.windowState() & QtCore.Qt.WindowMaximized)
|
|
||||||
|
|
||||||
# application indicator show or hide
|
|
||||||
def appIndicatorShowBitmessage(self):
|
|
||||||
if self.actionShow == None:
|
|
||||||
return
|
|
||||||
if not self.actionShow.isChecked():
|
if not self.actionShow.isChecked():
|
||||||
self.hide()
|
self.hide()
|
||||||
self.setWindowState(self.windowState() & QtCore.Qt.WindowMinimized)
|
else:
|
||||||
|
if sys.platform[0:3] == 'win':
|
||||||
|
self.setWindowFlags(Qt.Window)
|
||||||
|
self.show()
|
||||||
|
self.setWindowState(self.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive)
|
||||||
|
self.activateWindow()
|
||||||
else:
|
else:
|
||||||
self.show()
|
self.show()
|
||||||
self.setWindowState(self.windowState() & QtCore.Qt.WindowMaximized)
|
self.setWindowState(self.windowState() & QtCore.Qt.WindowMaximized)
|
||||||
|
#Here is what I believe might be required for darwin:
|
||||||
|
#self.setWindowState(self.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive)
|
||||||
|
#self.activateWindow()
|
||||||
|
|
||||||
|
"""# application indicator show or hide
|
||||||
|
def appIndicatorShowBitmessage(self):
|
||||||
|
#if self.actionShow == None:
|
||||||
|
# return
|
||||||
|
print self.actionShow.isChecked()
|
||||||
|
if not self.actionShow.isChecked():
|
||||||
|
self.hide()
|
||||||
|
#self.setWindowState(self.windowState() & QtCore.Qt.WindowMinimized)
|
||||||
|
else:
|
||||||
|
self.appIndicatorShowOrHideWindow()"""
|
||||||
|
|
||||||
# Show the program window and select send tab
|
# Show the program window and select send tab
|
||||||
def appIndicatorSend(self):
|
def appIndicatorSend(self):
|
||||||
self.appIndicatorShow()
|
self.actionShow.setChecked(True)
|
||||||
|
self.appIndicatorShowOrHideWindow()
|
||||||
self.ui.tabWidget.setCurrentIndex(1)
|
self.ui.tabWidget.setCurrentIndex(1)
|
||||||
|
|
||||||
# Show the program window and select subscriptions tab
|
# Show the program window and select subscriptions tab
|
||||||
def appIndicatorSubscribe(self):
|
def appIndicatorSubscribe(self):
|
||||||
self.appIndicatorShow()
|
self.actionShow.setChecked(True)
|
||||||
|
self.appIndicatorShowOrHideWindow()
|
||||||
self.ui.tabWidget.setCurrentIndex(4)
|
self.ui.tabWidget.setCurrentIndex(4)
|
||||||
|
|
||||||
# Show the program window and select the address book tab
|
# Show the program window and select the address book tab
|
||||||
def appIndicatorAddressBook(self):
|
def appIndicatorAddressBook(self):
|
||||||
self.appIndicatorShow()
|
self.actionShow.setChecked(True)
|
||||||
|
self.appIndicatorShowOrHideWindow()
|
||||||
self.ui.tabWidget.setCurrentIndex(5)
|
self.ui.tabWidget.setCurrentIndex(5)
|
||||||
|
|
||||||
# create application indicator
|
# create application indicator
|
||||||
def createAppIndicator(self,app):
|
def createAppIndicator(self,app):
|
||||||
app.tray = QSystemTrayIcon(QtGui.QIcon("images/can-icon-24px.png"), app)
|
self.tray = QSystemTrayIcon(QtGui.QIcon("images/can-icon-24px.png"), app)
|
||||||
|
if sys.platform[0:3] == 'win':
|
||||||
|
traySignal = "activated(QSystemTrayIcon::ActivationReason)"
|
||||||
|
QtCore.QObject.connect(self.tray, QtCore.SIGNAL(traySignal), self.__icon_activated)
|
||||||
m = QMenu()
|
m = QMenu()
|
||||||
|
|
||||||
self.actionStatus = QtGui.QAction('Not Connected',m,checkable=False)
|
self.actionStatus = QtGui.QAction('Not Connected',m,checkable=False)
|
||||||
|
@ -516,7 +507,8 @@ class MyForm(QtGui.QMainWindow):
|
||||||
# show bitmessage
|
# show bitmessage
|
||||||
self.actionShow = QtGui.QAction('Show Bitmessage',m,checkable=True)
|
self.actionShow = QtGui.QAction('Show Bitmessage',m,checkable=True)
|
||||||
self.actionShow.setChecked(True)
|
self.actionShow.setChecked(True)
|
||||||
self.actionShow.triggered.connect(self.appIndicatorShowBitmessage)
|
self.actionShow.triggered.connect(self.appIndicatorShowOrHideWindow)
|
||||||
|
if not sys.platform[0:3] == 'win':
|
||||||
m.addAction(self.actionShow)
|
m.addAction(self.actionShow)
|
||||||
|
|
||||||
# Send
|
# Send
|
||||||
|
@ -541,8 +533,12 @@ class MyForm(QtGui.QMainWindow):
|
||||||
|
|
||||||
# Quit
|
# Quit
|
||||||
m.addAction("Quit", self.close)
|
m.addAction("Quit", self.close)
|
||||||
app.tray.setContextMenu(m)
|
self.tray.setContextMenu(m)
|
||||||
app.tray.show()
|
self.tray.show()
|
||||||
|
if shared.config.getboolean('bitmessagesettings', 'startintray'):
|
||||||
|
self.hide()
|
||||||
|
#myapp.trayIcon.show()#This option seems to have been obsoleted by https://github.com/Bitmessage/PyBitmessage/pull/133/files
|
||||||
|
self.actionShow.setChecked(False)
|
||||||
|
|
||||||
def tableWidgetInboxKeyPressEvent(self,event):
|
def tableWidgetInboxKeyPressEvent(self,event):
|
||||||
if event.key() == QtCore.Qt.Key_Delete:
|
if event.key() == QtCore.Qt.Key_Delete:
|
||||||
|
@ -591,11 +587,15 @@ class MyForm(QtGui.QMainWindow):
|
||||||
os.startfile(shared.appdata + 'keys.dat')
|
os.startfile(shared.appdata + 'keys.dat')
|
||||||
|
|
||||||
def changeEvent(self, event):
|
def changeEvent(self, event):
|
||||||
|
if event.type() == QtCore.QEvent.WindowStateChange:
|
||||||
|
if self.windowState() & QtCore.Qt.WindowMinimized:
|
||||||
|
self.actionShow.setChecked(False)
|
||||||
if shared.config.getboolean('bitmessagesettings', 'minimizetotray') and not 'darwin' in sys.platform:
|
if shared.config.getboolean('bitmessagesettings', 'minimizetotray') and not 'darwin' in sys.platform:
|
||||||
if event.type() == QtCore.QEvent.WindowStateChange:
|
if event.type() == QtCore.QEvent.WindowStateChange:
|
||||||
if self.windowState() & QtCore.Qt.WindowMinimized:
|
if self.windowState() & QtCore.Qt.WindowMinimized:
|
||||||
self.hide()
|
self.hide()
|
||||||
self.trayIcon.show()
|
|
||||||
|
#self.trayIcon.show() #This may have been obsoleted by https://github.com/Bitmessage/PyBitmessage/issues/135
|
||||||
#self.hidden = True
|
#self.hidden = True
|
||||||
if 'win32' in sys.platform or 'win64' in sys.platform:
|
if 'win32' in sys.platform or 'win64' in sys.platform:
|
||||||
self.setWindowFlags(Qt.ToolTip)
|
self.setWindowFlags(Qt.ToolTip)
|
||||||
|
@ -606,7 +606,10 @@ class MyForm(QtGui.QMainWindow):
|
||||||
|
|
||||||
def __icon_activated(self, reason):
|
def __icon_activated(self, reason):
|
||||||
if reason == QtGui.QSystemTrayIcon.Trigger:
|
if reason == QtGui.QSystemTrayIcon.Trigger:
|
||||||
if 'linux' in sys.platform:
|
self.actionShow.setChecked(not self.actionShow.isChecked())
|
||||||
|
self.appIndicatorShowOrHideWindow()
|
||||||
|
|
||||||
|
"""if 'linux' in sys.platform:
|
||||||
self.trayIcon.hide()
|
self.trayIcon.hide()
|
||||||
self.setWindowFlags(Qt.Window)
|
self.setWindowFlags(Qt.Window)
|
||||||
self.show()
|
self.show()
|
||||||
|
@ -621,7 +624,7 @@ class MyForm(QtGui.QMainWindow):
|
||||||
#self.setWindowFlags(Qt.Window)
|
#self.setWindowFlags(Qt.Window)
|
||||||
#self.show()
|
#self.show()
|
||||||
self.setWindowState(self.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive)
|
self.setWindowState(self.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive)
|
||||||
self.activateWindow()
|
self.activateWindow()"""
|
||||||
|
|
||||||
def incrementNumberOfMessagesProcessed(self):
|
def incrementNumberOfMessagesProcessed(self):
|
||||||
self.numberOfMessagesProcessed += 1
|
self.numberOfMessagesProcessed += 1
|
||||||
|
@ -685,22 +688,22 @@ class MyForm(QtGui.QMainWindow):
|
||||||
if color == 'red':
|
if color == 'red':
|
||||||
self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/redicon.png"))
|
self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/redicon.png"))
|
||||||
shared.statusIconColor = 'red'
|
shared.statusIconColor = 'red'
|
||||||
if self.actionStatus != None:
|
#if self.actionStatus != None:
|
||||||
self.actionStatus.setText('Not Connected')
|
self.actionStatus.setText('Not Connected')
|
||||||
if color == 'yellow':
|
if color == 'yellow':
|
||||||
if self.statusBar().currentMessage() == 'Warning: You are currently not connected. Bitmessage will do the work necessary to send the message but it won\'t send until you connect.':
|
if self.statusBar().currentMessage() == 'Warning: You are currently not connected. Bitmessage will do the work necessary to send the message but it won\'t send until you connect.':
|
||||||
self.statusBar().showMessage('')
|
self.statusBar().showMessage('')
|
||||||
self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/yellowicon.png"))
|
self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/yellowicon.png"))
|
||||||
shared.statusIconColor = 'yellow'
|
shared.statusIconColor = 'yellow'
|
||||||
if self.actionStatus != None:
|
#if self.actionStatus != None:
|
||||||
self.actionStatus.setText('Connection Ok')
|
self.actionStatus.setText('Connected')
|
||||||
if color == 'green':
|
if color == 'green':
|
||||||
if self.statusBar().currentMessage() == 'Warning: You are currently not connected. Bitmessage will do the work necessary to send the message but it won\'t send until you connect.':
|
if self.statusBar().currentMessage() == 'Warning: You are currently not connected. Bitmessage will do the work necessary to send the message but it won\'t send until you connect.':
|
||||||
self.statusBar().showMessage('')
|
self.statusBar().showMessage('')
|
||||||
self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/greenicon.png"))
|
self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/greenicon.png"))
|
||||||
shared.statusIconColor = 'green'
|
shared.statusIconColor = 'green'
|
||||||
if self.actionStatus != None:
|
#if self.actionStatus != None:
|
||||||
self.actionStatus.setText('Connection Good')
|
self.actionStatus.setText('Connected')
|
||||||
|
|
||||||
def updateSentItemStatusByHash(self,toRipe,textToDisplay):
|
def updateSentItemStatusByHash(self,toRipe,textToDisplay):
|
||||||
for i in range(self.ui.tableWidgetSent.rowCount()):
|
for i in range(self.ui.tableWidgetSent.rowCount()):
|
||||||
|
@ -1402,7 +1405,8 @@ class MyForm(QtGui.QMainWindow):
|
||||||
else:
|
else:
|
||||||
event.ignore()'''
|
event.ignore()'''
|
||||||
shared.doCleanShutdown()
|
shared.doCleanShutdown()
|
||||||
self.trayIcon.hide()
|
#self.trayIcon.hide()
|
||||||
|
self.tray.hide()
|
||||||
self.statusBar().showMessage('All done. Closing user interface...')
|
self.statusBar().showMessage('All done. Closing user interface...')
|
||||||
event.accept()
|
event.accept()
|
||||||
shared.printLock.acquire()
|
shared.printLock.acquire()
|
||||||
|
@ -2037,20 +2041,12 @@ class UISignaler(QThread):
|
||||||
sys.stderr.write('Command sent to UISignaler not recognized: %s\n' % command)
|
sys.stderr.write('Command sent to UISignaler not recognized: %s\n' % command)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
app = QtGui.QApplication(sys.argv)
|
app = QtGui.QApplication(sys.argv)
|
||||||
app.setStyleSheet("QStatusBar::item { border: 0px solid black }")
|
app.setStyleSheet("QStatusBar::item { border: 0px solid black }")
|
||||||
myapp = MyForm()
|
myapp = MyForm()
|
||||||
myapp.show()
|
myapp.show()
|
||||||
if shared.config.getboolean('bitmessagesettings', 'startintray'):
|
if sys.platform[0:3] == 'win':
|
||||||
myapp.hide()
|
|
||||||
myapp.trayIcon.show()
|
|
||||||
#self.hidden = True
|
|
||||||
#self.setWindowState(self.windowState() & QtCore.Qt.WindowMinimized)
|
|
||||||
#self.hide()
|
|
||||||
if 'win32' in sys.platform or 'win64' in sys.platform:
|
|
||||||
myapp.setWindowFlags(Qt.ToolTip)
|
myapp.setWindowFlags(Qt.ToolTip)
|
||||||
myapp.createAppIndicator(app)
|
myapp.createAppIndicator(app)
|
||||||
|
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
||||||
|
|
Reference in New Issue
Block a user