3
3
import inspect
4
4
from PyQt5 import QtWidgets , QtCore , QtGui
5
5
from uptime import boottime
6
+ from TardisUtil import TardisOptions
6
7
7
8
8
9
class TardisDiff (QtWidgets .QMainWindow ):
@@ -11,9 +12,10 @@ def __init__(self):
11
12
super (TardisDiff , self ).__init__ ()
12
13
self .diff = 0
13
14
self .clipboard = QtWidgets .QApplication .clipboard ()
14
- # Set hotkeys
15
+ # Set hot keys
15
16
QtWidgets .QShortcut (QtGui .QKeySequence ("Ctrl+Shift+C" ), self ,
16
17
self .setClipboard )
18
+ self .options = TardisOptions ()
17
19
18
20
# Get directory path
19
21
# From: http://stackoverflow.com/questions/3718657/how-to-properly-determine-current-script-directory-in-python/22881871#22881871
@@ -30,7 +32,7 @@ def __init__(self):
30
32
self .initUI ()
31
33
32
34
def initUI (self ):
33
- #Create and initialize UI elements
35
+ # Create and initialize UI elements
34
36
self .contentWidget = QtWidgets .QWidget ()
35
37
self .gridLayout = QtWidgets .QGridLayout (self .contentWidget )
36
38
self .formLayout = QtWidgets .QFormLayout ()
@@ -48,7 +50,7 @@ def initUI(self):
48
50
self .label_breakTime .setText ("Break Time:" )
49
51
self .label_timeDiff .setText ("Difference" )
50
52
self .label_timeDiffOut .setText ("" )
51
- self .timeEdit1 .setTime (self .getBootTimeAsQTime ())
53
+ self .timeEdit1 .setTime (self .getStartTime ())
52
54
self .timeEdit2 .setTime (QtCore .QTime .currentTime ())
53
55
54
56
#Set relations
@@ -100,24 +102,17 @@ def setClipboard(self):
100
102
self .clipboard .setText (str (self .diff ))
101
103
self .statusBar ().showMessage ("Copied to clipboard." )
102
104
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 ():
104
112
return QtCore .QDateTime (boottime ()).time ()
105
113
106
114
107
115
def 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
- '''
121
116
app = QtWidgets .QApplication (sys .argv )
122
117
ed = TardisDiff ()
123
118
sys .exit (app .exec_ ())
0 commit comments