minimiseonclose option to minimize the application when the window is closed

This commit is contained in:
fuzzgun 2013-05-13 14:02:10 +01:00
parent 8973d348ad
commit d154e2495c
2 changed files with 28 additions and 10 deletions

View File

@ -3813,6 +3813,7 @@ if __name__ == "__main__":
shared.config.set('bitmessagesettings','messagesencrypted','false') shared.config.set('bitmessagesettings','messagesencrypted','false')
shared.config.set('bitmessagesettings','defaultnoncetrialsperbyte',str(shared.networkDefaultProofOfWorkNonceTrialsPerByte)) shared.config.set('bitmessagesettings','defaultnoncetrialsperbyte',str(shared.networkDefaultProofOfWorkNonceTrialsPerByte))
shared.config.set('bitmessagesettings','defaultpayloadlengthextrabytes',str(shared.networkDefaultPayloadLengthExtraBytes)) shared.config.set('bitmessagesettings','defaultpayloadlengthextrabytes',str(shared.networkDefaultPayloadLengthExtraBytes))
shared.config.set('bitmessagesettings','minimizeonclose','true')
if storeConfigFilesInSameDirectoryAsProgramByDefault: if storeConfigFilesInSameDirectoryAsProgramByDefault:
#Just use the same directory as the program and forget about the appdata folder #Just use the same directory as the program and forget about the appdata folder

View File

@ -73,7 +73,7 @@ class MyForm(QtGui.QMainWindow):
traySignal = "activated(QSystemTrayIcon::ActivationReason)" traySignal = "activated(QSystemTrayIcon::ActivationReason)"
QtCore.QObject.connect(self.trayIcon, QtCore.SIGNAL(traySignal), self.__icon_activated) QtCore.QObject.connect(self.trayIcon, QtCore.SIGNAL(traySignal), self.__icon_activated)
menu = QtGui.QMenu() menu = QtGui.QMenu()
self.exitAction = menu.addAction("Exit", self.close) self.exitAction = menu.addAction("Exit", self.quit)
self.trayIcon.setContextMenu(menu) self.trayIcon.setContextMenu(menu)
#I'm currently under the impression that Mac users have different expectations for the tray icon. They don't necessairly expect it to open the main window when clicked and they still expect a program showing a tray icon to also be in the dock. #I'm currently under the impression that Mac users have different expectations for the tray icon. They don't necessairly expect it to open the main window when clicked and they still expect a program showing a tray icon to also be in the dock.
if 'darwin' in sys.platform: if 'darwin' in sys.platform:
@ -82,7 +82,7 @@ class MyForm(QtGui.QMainWindow):
self.ui.labelSendBroadcastWarning.setVisible(False) self.ui.labelSendBroadcastWarning.setVisible(False)
#FILE MENU and other buttons #FILE MENU and other buttons
QtCore.QObject.connect(self.ui.actionExit, QtCore.SIGNAL("triggered()"), self.close) QtCore.QObject.connect(self.ui.actionExit, QtCore.SIGNAL("triggered()"), self.quit)
QtCore.QObject.connect(self.ui.actionManageKeys, QtCore.SIGNAL("triggered()"), self.click_actionManageKeys) QtCore.QObject.connect(self.ui.actionManageKeys, QtCore.SIGNAL("triggered()"), self.click_actionManageKeys)
QtCore.QObject.connect(self.ui.actionRegenerateDeterministicAddresses, QtCore.SIGNAL("triggered()"), self.click_actionRegenerateDeterministicAddresses) QtCore.QObject.connect(self.ui.actionRegenerateDeterministicAddresses, QtCore.SIGNAL("triggered()"), self.click_actionRegenerateDeterministicAddresses)
QtCore.QObject.connect(self.ui.pushButtonNewAddress, QtCore.SIGNAL("clicked()"), self.click_NewAddressDialog) QtCore.QObject.connect(self.ui.pushButtonNewAddress, QtCore.SIGNAL("clicked()"), self.click_NewAddressDialog)
@ -569,7 +569,7 @@ class MyForm(QtGui.QMainWindow):
m.addAction(actionSeparator) m.addAction(actionSeparator)
# Quit # Quit
m.addAction("Quit", self.close) m.addAction("Quit", self.quit)
self.app.tray.setContextMenu(m) self.app.tray.setContextMenu(m)
self.app.tray.show() self.app.tray.show()
@ -1566,25 +1566,42 @@ class MyForm(QtGui.QMainWindow):
else: else:
print 'new address dialog box rejected' print 'new address dialog box rejected'
def closeEvent(self, event):
# Quit selected from menu or application indicator
def quit(self):
'''quit_msg = "Are you sure you want to exit Bitmessage?" '''quit_msg = "Are you sure you want to exit Bitmessage?"
reply = QtGui.QMessageBox.question(self, 'Message', reply = QtGui.QMessageBox.question(self, 'Message',
quit_msg, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) quit_msg, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
if reply == QtGui.QMessageBox.Yes: if reply is QtGui.QMessageBox.No:
event.accept() return
else: '''
event.ignore()'''
shared.doCleanShutdown() shared.doCleanShutdown()
# unregister the messaging system # unregister the messaging system
if self.mmapp is not None: if self.mmapp is not None:
self.mmapp.unregister() self.mmapp.unregister()
self.trayIcon.hide() self.trayIcon.hide()
self.statusBar().showMessage('All done. Closing user interface...') self.statusBar().showMessage('All done. Closing user interface...')
event.accept()
print 'Done. (passed event.accept())'
os._exit(0) os._exit(0)
# window close event
def closeEvent(self, event):
self.appIndicatorHide()
minimizeonclose = True
try:
minimizeonclose = shared.config.getboolean('bitmessagesettings', 'minimizeonclose')
except Exception:
print 'Is there a minimizeonclose entry in keys.dat?'
if minimizeonclose:
# minimize the application
event.ignore()
else:
# quit the application
event.accept()
self.quit()
def on_action_InboxMessageForceHtml(self): def on_action_InboxMessageForceHtml(self):
currentInboxRow = self.ui.tableWidgetInbox.currentRow() currentInboxRow = self.ui.tableWidgetInbox.currentRow()
lines = self.ui.tableWidgetInbox.item(currentInboxRow,2).data(Qt.UserRole).toPyObject().split('\n') lines = self.ui.tableWidgetInbox.item(currentInboxRow,2).data(Qt.UserRole).toPyObject().split('\n')