33import inspect
44from PyQt5 import QtWidgets , QtCore , QtGui
55from uptime import boottime
6+ from TardisUtil import TardisOptions
67
78
89class TardisDiff (QtWidgets .QMainWindow ):
@@ -11,9 +12,10 @@ def __init__(self):
1112 super (TardisDiff , self ).__init__ ()
1213 self .diff = 0
1314 self .clipboard = QtWidgets .QApplication .clipboard ()
14- # Set hotkeys
15+ # Set hot keys
1516 QtWidgets .QShortcut (QtGui .QKeySequence ("Ctrl+Shift+C" ), self ,
1617 self .setClipboard )
18+ self .options = TardisOptions ()
1719
1820 # Get directory path
1921 # From: http://stackoverflow.com/questions/3718657/how-to-properly-determine-current-script-directory-in-python/22881871#22881871
@@ -30,7 +32,7 @@ def __init__(self):
3032 self .initUI ()
3133
3234 def initUI (self ):
33- #Create and initialize UI elements
35+ # Create and initialize UI elements
3436 self .contentWidget = QtWidgets .QWidget ()
3537 self .gridLayout = QtWidgets .QGridLayout (self .contentWidget )
3638 self .formLayout = QtWidgets .QFormLayout ()
@@ -48,7 +50,7 @@ def initUI(self):
4850 self .label_breakTime .setText ("Break Time:" )
4951 self .label_timeDiff .setText ("Difference" )
5052 self .label_timeDiffOut .setText ("" )
51- self .timeEdit1 .setTime (self .getBootTimeAsQTime ())
53+ self .timeEdit1 .setTime (self .getStartTime ())
5254 self .timeEdit2 .setTime (QtCore .QTime .currentTime ())
5355
5456 #Set relations
@@ -100,24 +102,17 @@ def setClipboard(self):
100102 self .clipboard .setText (str (self .diff ))
101103 self .statusBar ().showMessage ("Copied to clipboard." )
102104
103- def getBootTimeAsQTime (self ):
105+ def getStartTime (self ):
106+ return TardisDiff .getBootTimeAsQTime ()\
107+ if self .options .isStartTimeAuto ()\
108+ else QtCore .QTime .fromString (self .options .getStartTime ())
109+
110+ @staticmethod
111+ def getBootTimeAsQTime ():
104112 return QtCore .QDateTime (boottime ()).time ()
105113
106114
107115def main ():
108- '''
109- myappid = 'net.xerael.tardisdiff'
110- if sys.platform == "win32":
111- """
112- This is for collapsing on the task bar on windows 7/8 and using
113- the application icon on the task bar instead of the python icon
114- if running using a python executable.
115-
116- See:
117- http://stackoverflow.com/questions/1551605/how-to-set-applications-taskbar-icon-in-windows-7
118- """
119- ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
120- '''
121116 app = QtWidgets .QApplication (sys .argv )
122117 ed = TardisDiff ()
123118 sys .exit (app .exec_ ())
0 commit comments