Skip to content

Commit

Permalink
Merge pull request #11 from cryzed/master
Browse files Browse the repository at this point in the history
Improve closing behavior (See #10)
  • Loading branch information
DoTheEvo committed May 9, 2016
2 parents a212064 + 96e5ac5 commit 3060155
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions angrysearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,11 +618,11 @@ def keyPressEvent(self, event):
if type(event) == Qg.QKeyEvent:
# ESC
if event.key() == 16777216:
sys.exit(app.exec_())
self.close()
# CTRL + Q
if event.key() == 81:
if event.modifiers() == Qc.Qt.ControlModifier:
sys.exit(app.exec_())
self.close()
# F6 KEY
if event.key() == 16777269:
self.center.search_input.selectAll()
Expand Down Expand Up @@ -736,6 +736,9 @@ def closeEvent(self, event):
self.settings.setValue('conditional_mounts_for_autoupdate', '')
if not self.settings.contains('notifications'):
self.settings.setValue('notifications', True)

# Tray icon needs to be hidden, so that the main window instance automatically deletes it when closing.
self.tray_icon.hide()
event.accept()

def init_GUI(self):
Expand Down Expand Up @@ -814,7 +817,7 @@ def make_sys_tray(self):
menu.addAction('v0.9.7')
menu.addSeparator()
exitAction = menu.addAction('Quit')
exitAction.triggered.connect(sys.exit)
exitAction.triggered.connect(self.close)

self.tray_icon = Qw.QSystemTrayIcon()
self.tray_icon.setIcon(self.icon)
Expand All @@ -828,7 +831,7 @@ def sys_tray_clicking(self, reason):
reason == Qw.QSystemTrayIcon.Trigger):
self.show()
elif (reason == Qw.QSystemTrayIcon.MiddleClick):
Qc.QCoreApplication.instance().quit()
self.close()

def get_tray_icon(self):
base64_data = '''iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABHN
Expand Down

0 comments on commit 3060155

Please sign in to comment.