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.numberOfPubkeysProcessed = 0
|
||||
|
||||
#Below this point, it would be good if all of the necessary global data structures were initialized.
|
||||
|
||||
self.rerenderComboBoxSendFrom()
|
||||
|
||||
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("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)
|
||||
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.singleListenerThread.start()
|
||||
#QtCore.QObject.connect(self.singleListenerThread, QtCore.SIGNAL("passObjectThrough(PyQt_PyObject)"), self.connectObjectToSignals)
|
||||
self.rerenderComboBoxSendFrom()
|
||||
|
||||
|
||||
#self.singleCleanerThread = singleCleaner()
|
||||
#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
|
||||
#Show or hide the application window after clicking an item within the tray icon or, on Windows, the try icon itself.
|
||||
def appIndicatorShowOrHideWindow(self):
|
||||
if not self.actionShow.isChecked():
|
||||
self.hide()
|
||||
self.setWindowState(self.windowState() & QtCore.Qt.WindowMinimized)
|
||||
else:
|
||||
self.show()
|
||||
self.setWindowState(self.windowState() & QtCore.Qt.WindowMaximized)
|
||||
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:
|
||||
self.show()
|
||||
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
|
||||
def appIndicatorSend(self):
|
||||
self.appIndicatorShow()
|
||||
self.actionShow.setChecked(True)
|
||||
self.appIndicatorShowOrHideWindow()
|
||||
self.ui.tabWidget.setCurrentIndex(1)
|
||||
|
||||
# Show the program window and select subscriptions tab
|
||||
def appIndicatorSubscribe(self):
|
||||
self.appIndicatorShow()
|
||||
self.actionShow.setChecked(True)
|
||||
self.appIndicatorShowOrHideWindow()
|
||||
self.ui.tabWidget.setCurrentIndex(4)
|
||||
|
||||
# Show the program window and select the address book tab
|
||||
def appIndicatorAddressBook(self):
|
||||
self.appIndicatorShow()
|
||||
self.actionShow.setChecked(True)
|
||||
self.appIndicatorShowOrHideWindow()
|
||||
self.ui.tabWidget.setCurrentIndex(5)
|
||||
|
||||
# create application indicator
|
||||
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()
|
||||
|
||||
self.actionStatus = QtGui.QAction('Not Connected',m,checkable=False)
|
||||
|
@ -516,8 +507,9 @@ class MyForm(QtGui.QMainWindow):
|
|||
# show bitmessage
|
||||
self.actionShow = QtGui.QAction('Show Bitmessage',m,checkable=True)
|
||||
self.actionShow.setChecked(True)
|
||||
self.actionShow.triggered.connect(self.appIndicatorShowBitmessage)
|
||||
m.addAction(self.actionShow)
|
||||
self.actionShow.triggered.connect(self.appIndicatorShowOrHideWindow)
|
||||
if not sys.platform[0:3] == 'win':
|
||||
m.addAction(self.actionShow)
|
||||
|
||||
# Send
|
||||
actionSend = QtGui.QAction('Send',m,checkable=False)
|
||||
|
@ -541,8 +533,12 @@ class MyForm(QtGui.QMainWindow):
|
|||
|
||||
# Quit
|
||||
m.addAction("Quit", self.close)
|
||||
app.tray.setContextMenu(m)
|
||||
app.tray.show()
|
||||
self.tray.setContextMenu(m)
|
||||
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):
|
||||
if event.key() == QtCore.Qt.Key_Delete:
|
||||
|
@ -591,11 +587,15 @@ class MyForm(QtGui.QMainWindow):
|
|||
os.startfile(shared.appdata + 'keys.dat')
|
||||
|
||||
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 event.type() == QtCore.QEvent.WindowStateChange:
|
||||
if self.windowState() & QtCore.Qt.WindowMinimized:
|
||||
self.hide()
|
||||
self.trayIcon.show()
|
||||
|
||||
#self.trayIcon.show() #This may have been obsoleted by https://github.com/Bitmessage/PyBitmessage/issues/135
|
||||
#self.hidden = True
|
||||
if 'win32' in sys.platform or 'win64' in sys.platform:
|
||||
self.setWindowFlags(Qt.ToolTip)
|
||||
|
@ -606,7 +606,10 @@ class MyForm(QtGui.QMainWindow):
|
|||
|
||||
def __icon_activated(self, reason):
|
||||
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.setWindowFlags(Qt.Window)
|
||||
self.show()
|
||||
|
@ -621,7 +624,7 @@ class MyForm(QtGui.QMainWindow):
|
|||
#self.setWindowFlags(Qt.Window)
|
||||
#self.show()
|
||||
self.setWindowState(self.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive)
|
||||
self.activateWindow()
|
||||
self.activateWindow()"""
|
||||
|
||||
def incrementNumberOfMessagesProcessed(self):
|
||||
self.numberOfMessagesProcessed += 1
|
||||
|
@ -685,22 +688,22 @@ class MyForm(QtGui.QMainWindow):
|
|||
if color == 'red':
|
||||
self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/redicon.png"))
|
||||
shared.statusIconColor = 'red'
|
||||
if self.actionStatus != None:
|
||||
self.actionStatus.setText('Not Connected')
|
||||
#if self.actionStatus != None:
|
||||
self.actionStatus.setText('Not Connected')
|
||||
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.':
|
||||
self.statusBar().showMessage('')
|
||||
self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/yellowicon.png"))
|
||||
shared.statusIconColor = 'yellow'
|
||||
if self.actionStatus != None:
|
||||
self.actionStatus.setText('Connection Ok')
|
||||
#if self.actionStatus != None:
|
||||
self.actionStatus.setText('Connected')
|
||||
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.':
|
||||
self.statusBar().showMessage('')
|
||||
self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/greenicon.png"))
|
||||
shared.statusIconColor = 'green'
|
||||
if self.actionStatus != None:
|
||||
self.actionStatus.setText('Connection Good')
|
||||
#if self.actionStatus != None:
|
||||
self.actionStatus.setText('Connected')
|
||||
|
||||
def updateSentItemStatusByHash(self,toRipe,textToDisplay):
|
||||
for i in range(self.ui.tableWidgetSent.rowCount()):
|
||||
|
@ -1402,7 +1405,8 @@ class MyForm(QtGui.QMainWindow):
|
|||
else:
|
||||
event.ignore()'''
|
||||
shared.doCleanShutdown()
|
||||
self.trayIcon.hide()
|
||||
#self.trayIcon.hide()
|
||||
self.tray.hide()
|
||||
self.statusBar().showMessage('All done. Closing user interface...')
|
||||
event.accept()
|
||||
shared.printLock.acquire()
|
||||
|
@ -2037,20 +2041,12 @@ class UISignaler(QThread):
|
|||
sys.stderr.write('Command sent to UISignaler not recognized: %s\n' % command)
|
||||
|
||||
|
||||
|
||||
def run():
|
||||
app = QtGui.QApplication(sys.argv)
|
||||
app.setStyleSheet("QStatusBar::item { border: 0px solid black }")
|
||||
myapp = MyForm()
|
||||
myapp.show()
|
||||
if shared.config.getboolean('bitmessagesettings', 'startintray'):
|
||||
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)
|
||||
if sys.platform[0:3] == 'win':
|
||||
myapp.setWindowFlags(Qt.ToolTip)
|
||||
myapp.createAppIndicator(app)
|
||||
|
||||
sys.exit(app.exec_())
|
||||
|
|
Loading…
Reference in New Issue
Block a user