Skip to content

Commit 1434054

Browse files
author
Lee Miller
committed
Simplify MyForm.setStatusIcon()
1 parent b16105f commit 1434054

File tree

1 file changed

+25
-37
lines changed

1 file changed

+25
-37
lines changed

src/bitmessageqt/__init__.py

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,10 +1760,13 @@ def __icon_activated(self, reason):
17601760
def setStatusIcon(self, color):
17611761
_notifications_enabled = not config.getboolean(
17621762
'bitmessagesettings', 'hidetrayconnectionnotifications')
1763+
if color not in ('red', 'yellow', 'green'):
1764+
return
1765+
1766+
self.pushButtonStatusIcon.setIcon(
1767+
QtGui.QIcon(":/newPrefix/images/%sicon.png" % color))
1768+
state.statusIconColor = color
17631769
if color == 'red':
1764-
self.pushButtonStatusIcon.setIcon(
1765-
QtGui.QIcon(":/newPrefix/images/redicon.png"))
1766-
state.statusIconColor = 'red'
17671770
# if the connection is lost then show a notification
17681771
if self.connected and _notifications_enabled:
17691772
self.notifierShow(
@@ -1794,41 +1797,26 @@ def setStatusIcon(self, color):
17941797
self.actionStatus.setText(_translate(
17951798
"MainWindow", "Not Connected"))
17961799
self.setTrayIconFile("can-icon-24px-red.png")
1797-
if color == 'yellow':
1798-
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.':
1799-
self.statusbar.clearMessage()
1800-
self.pushButtonStatusIcon.setIcon(
1801-
QtGui.QIcon(":/newPrefix/images/yellowicon.png"))
1802-
state.statusIconColor = 'yellow'
1803-
# if a new connection has been established then show a notification
1804-
if not self.connected and _notifications_enabled:
1805-
self.notifierShow(
1806-
'Bitmessage',
1807-
_translate("MainWindow", "Connected"),
1808-
sound.SOUND_CONNECTED)
1809-
self.connected = True
1810-
1811-
if self.actionStatus is not None:
1812-
self.actionStatus.setText(_translate(
1813-
"MainWindow", "Connected"))
1814-
self.setTrayIconFile("can-icon-24px-yellow.png")
1815-
if color == 'green':
1816-
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.':
1817-
self.statusbar.clearMessage()
1818-
self.pushButtonStatusIcon.setIcon(
1819-
QtGui.QIcon(":/newPrefix/images/greenicon.png"))
1820-
state.statusIconColor = 'green'
1821-
if not self.connected and _notifications_enabled:
1822-
self.notifierShow(
1823-
'Bitmessage',
1824-
_translate("MainWindow", "Connected"),
1825-
sound.SOUND_CONNECTION_GREEN)
1826-
self.connected = True
1800+
return
18271801

1828-
if self.actionStatus is not None:
1829-
self.actionStatus.setText(_translate(
1830-
"MainWindow", "Connected"))
1831-
self.setTrayIconFile("can-icon-24px-green.png")
1802+
if self.statusbar.currentMessage() == (
1803+
"Warning: You are currently not connected. Bitmessage will do"
1804+
" the work necessary to send the message but it won't send"
1805+
" until you connect."
1806+
):
1807+
self.statusbar.clearMessage()
1808+
# if a new connection has been established then show a notification
1809+
if not self.connected and _notifications_enabled:
1810+
self.notifierShow(
1811+
'Bitmessage',
1812+
_translate("MainWindow", "Connected"),
1813+
sound.SOUND_CONNECTED)
1814+
self.connected = True
1815+
1816+
if self.actionStatus is not None:
1817+
self.actionStatus.setText(_translate(
1818+
"MainWindow", "Connected"))
1819+
self.setTrayIconFile("can-icon-24px-%s.png" % color)
18321820

18331821
def initTrayIcon(self, iconFileName, app):
18341822
self.currentTrayIconFileName = iconFileName

0 commit comments

Comments
 (0)