Simplify MyForm.setStatusIcon()
This commit is contained in:
parent
b16105f254
commit
14340540ae
|
@ -1760,10 +1760,13 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
def setStatusIcon(self, color):
|
def setStatusIcon(self, color):
|
||||||
_notifications_enabled = not config.getboolean(
|
_notifications_enabled = not config.getboolean(
|
||||||
'bitmessagesettings', 'hidetrayconnectionnotifications')
|
'bitmessagesettings', 'hidetrayconnectionnotifications')
|
||||||
if color == 'red':
|
if color not in ('red', 'yellow', 'green'):
|
||||||
|
return
|
||||||
|
|
||||||
self.pushButtonStatusIcon.setIcon(
|
self.pushButtonStatusIcon.setIcon(
|
||||||
QtGui.QIcon(":/newPrefix/images/redicon.png"))
|
QtGui.QIcon(":/newPrefix/images/%sicon.png" % color))
|
||||||
state.statusIconColor = 'red'
|
state.statusIconColor = color
|
||||||
|
if color == 'red':
|
||||||
# if the connection is lost then show a notification
|
# if the connection is lost then show a notification
|
||||||
if self.connected and _notifications_enabled:
|
if self.connected and _notifications_enabled:
|
||||||
self.notifierShow(
|
self.notifierShow(
|
||||||
|
@ -1794,12 +1797,14 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
self.actionStatus.setText(_translate(
|
self.actionStatus.setText(_translate(
|
||||||
"MainWindow", "Not Connected"))
|
"MainWindow", "Not Connected"))
|
||||||
self.setTrayIconFile("can-icon-24px-red.png")
|
self.setTrayIconFile("can-icon-24px-red.png")
|
||||||
if color == 'yellow':
|
return
|
||||||
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.clearMessage()
|
self.statusbar.clearMessage()
|
||||||
self.pushButtonStatusIcon.setIcon(
|
|
||||||
QtGui.QIcon(":/newPrefix/images/yellowicon.png"))
|
|
||||||
state.statusIconColor = 'yellow'
|
|
||||||
# if a new connection has been established then show a notification
|
# if a new connection has been established then show a notification
|
||||||
if not self.connected and _notifications_enabled:
|
if not self.connected and _notifications_enabled:
|
||||||
self.notifierShow(
|
self.notifierShow(
|
||||||
|
@ -1811,24 +1816,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
if self.actionStatus is not None:
|
if self.actionStatus is not None:
|
||||||
self.actionStatus.setText(_translate(
|
self.actionStatus.setText(_translate(
|
||||||
"MainWindow", "Connected"))
|
"MainWindow", "Connected"))
|
||||||
self.setTrayIconFile("can-icon-24px-yellow.png")
|
self.setTrayIconFile("can-icon-24px-%s.png" % color)
|
||||||
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.clearMessage()
|
|
||||||
self.pushButtonStatusIcon.setIcon(
|
|
||||||
QtGui.QIcon(":/newPrefix/images/greenicon.png"))
|
|
||||||
state.statusIconColor = 'green'
|
|
||||||
if not self.connected and _notifications_enabled:
|
|
||||||
self.notifierShow(
|
|
||||||
'Bitmessage',
|
|
||||||
_translate("MainWindow", "Connected"),
|
|
||||||
sound.SOUND_CONNECTION_GREEN)
|
|
||||||
self.connected = True
|
|
||||||
|
|
||||||
if self.actionStatus is not None:
|
|
||||||
self.actionStatus.setText(_translate(
|
|
||||||
"MainWindow", "Connected"))
|
|
||||||
self.setTrayIconFile("can-icon-24px-green.png")
|
|
||||||
|
|
||||||
def initTrayIcon(self, iconFileName, app):
|
def initTrayIcon(self, iconFileName, app):
|
||||||
self.currentTrayIconFileName = iconFileName
|
self.currentTrayIconFileName = iconFileName
|
||||||
|
|
Reference in New Issue
Block a user