[Workman-svn] SF.net SVN: workman:[43] trunk/src
An unobtrusive time-tracking program for self-employed people
Status: Pre-Alpha
Brought to you by:
jmsilva
|
From: <jm...@us...> - 2011-10-21 00:58:39
|
Revision: 43
http://workman.svn.sourceforge.net/workman/?rev=43&view=rev
Author: jmsilva
Date: 2011-10-21 00:58:33 +0000 (Fri, 21 Oct 2011)
Log Message:
-----------
Confirmation on quitting.
Modified Paths:
--------------
trunk/src/gui/main_window.py
trunk/src/workman.py
Modified: trunk/src/gui/main_window.py
===================================================================
--- trunk/src/gui/main_window.py 2011-10-21 00:58:22 UTC (rev 42)
+++ trunk/src/gui/main_window.py 2011-10-21 00:58:33 UTC (rev 43)
@@ -25,6 +25,7 @@
from compiled_ui import Ui_mainWindow
from PyQt4 import QtGui, QtCore
+import time
class MainWindow(Ui_mainWindow, QtGui.QMainWindow):
@@ -109,9 +110,11 @@
self.trayIcon.showMessage(self.tr("Work session ended"),
self.tr("The work session has ended."))
self.show()
+ return True
else:
self.trayIcon.showMessage(self.tr("End of session canceled"),
self.tr("Time is still being tracked"))
+ return False
def startBreak(self, showMessage = True):
@@ -134,8 +137,38 @@
self.setVisible(not self.isVisible())
def quit(self):
- #TODO confirmation
- QtGui.qApp.exit()
+ """Displays a confirmation dialog and quits the program,
+ if the user so chooses"""
+ title = self.tr('Quitting Workman')
+ text = self.tr('Are you sure you want to quit?')
+ buttons = QtGui.QMessageBox.Yes | QtGui.QMessageBox.No
+ icon = QtGui.QMessageBox.Question
+ activeSession = False
+ if self.dataStore.activeSession is not None:
+ text = self.tr('A work session is in progress ' +
+ 'and will be ended if you choose to quit.\n\n') + text
+ icon = QtGui.QMessageBox.Warning
+ activeSession = True
+
+ result = QtGui.QMessageBox(icon, title, text, buttons).exec_()
+ if result == QtGui.QMessageBox.Yes:
+ if activeSession:
+ if self.endSession() == False:
+ self.trayIcon.showMessage(self.tr("End of session canceled"),
+ self.tr("Time is still being tracked"))
+ else:
+ QtGui.qApp.closeAllWindows()
+ self.trayIcon.show()
+ self.trayIcon.showMessage(self.tr("Work session ended"),
+ self.tr("The work session has ended.\n Quitting..."))
+ self.trayIcon.setContextMenu(None)
+ self.trayIcon.disconnect(self.trayIcon,
+ QtCore.SIGNAL('activated(QSystemTrayIcon::ActivationReason)'),
+ self.iconActivated)
+ QUIT_TIMEOUT = 5000 # in ms
+ QtCore.QTimer.singleShot(QUIT_TIMEOUT, QtGui.qApp, QtCore.SLOT('quit()'))
+ else:
+ QtGui.qApp.quit()
def iconActivated(self, reason):
if reason != QtGui.QSystemTrayIcon.Context:
Modified: trunk/src/workman.py
===================================================================
--- trunk/src/workman.py 2011-10-21 00:58:22 UTC (rev 42)
+++ trunk/src/workman.py 2011-10-21 00:58:33 UTC (rev 43)
@@ -243,6 +243,7 @@
from gui.main_window import MainWindow
from gui.wizard import Wizard
app = QtGui.QApplication(sys.argv)
+ app.setQuitOnLastWindowClosed(False)
data = DataStore(None)
y = Wizard()
y.exec_()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|