|
|
@ -74,14 +74,17 @@ class TimebotMainWindow(QWidget): |
|
|
|
self.text_box_status = QLabel() |
|
|
|
self.text_box_status = QLabel() |
|
|
|
self.text_box_hours_present_area = HoursPresentLabelArea(parent=self) |
|
|
|
self.text_box_hours_present_area = HoursPresentLabelArea(parent=self) |
|
|
|
self.btn_update_status = QPushButton("Refresh Status") |
|
|
|
self.btn_update_status = QPushButton("Refresh Status") |
|
|
|
|
|
|
|
self.btn_smart_punch = QPushButton("Smart Punch") |
|
|
|
|
|
|
|
|
|
|
|
layout = QVBoxLayout() |
|
|
|
layout = QVBoxLayout() |
|
|
|
layout.addWidget(self.text_box_status) |
|
|
|
layout.addWidget(self.text_box_status) |
|
|
|
layout.addWidget(self.text_box_hours_present_area) |
|
|
|
layout.addWidget(self.text_box_hours_present_area) |
|
|
|
layout.addWidget(self.btn_update_status) |
|
|
|
layout.addWidget(self.btn_update_status) |
|
|
|
|
|
|
|
layout.addWidget(self.btn_smart_punch) |
|
|
|
self.setLayout(layout) |
|
|
|
self.setLayout(layout) |
|
|
|
|
|
|
|
|
|
|
|
self.btn_update_status.clicked.connect(self.update_status) |
|
|
|
self.btn_update_status.clicked.connect(self.update_status) |
|
|
|
|
|
|
|
self.btn_smart_punch.clicked.connect(self.smart_punch) |
|
|
|
|
|
|
|
|
|
|
|
self.status_timer_time = timeparse(refresh_interval) * 1000 |
|
|
|
self.status_timer_time = timeparse(refresh_interval) * 1000 |
|
|
|
self.status_timer = QTimer() |
|
|
|
self.status_timer = QTimer() |
|
|
@ -117,7 +120,7 @@ class TimebotMainWindow(QWidget): |
|
|
|
self.status_thread = QThread() |
|
|
|
self.status_thread = QThread() |
|
|
|
self.status_worker = TimebotApiWorker(self, self.timebot) |
|
|
|
self.status_worker = TimebotApiWorker(self, self.timebot) |
|
|
|
self.status_worker.moveToThread(self.status_thread) |
|
|
|
self.status_worker.moveToThread(self.status_thread) |
|
|
|
self.status_thread.started.connect(self.status_worker.run) |
|
|
|
self.status_thread.started.connect(self.status_worker.run_status) |
|
|
|
self.status_worker.finished.connect(self.status_thread.quit) |
|
|
|
self.status_worker.finished.connect(self.status_thread.quit) |
|
|
|
self.status_worker.finished.connect(self.status_worker.deleteLater) |
|
|
|
self.status_worker.finished.connect(self.status_worker.deleteLater) |
|
|
|
self.status_thread.finished.connect(self.status_thread.deleteLater) |
|
|
|
self.status_thread.finished.connect(self.status_thread.deleteLater) |
|
|
@ -127,6 +130,13 @@ class TimebotMainWindow(QWidget): |
|
|
|
self.status_thread.start() |
|
|
|
self.status_thread.start() |
|
|
|
self.update_status_started() |
|
|
|
self.update_status_started() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def smart_punch(self): |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
self.timebot.smart_punch() |
|
|
|
|
|
|
|
self.update_status() |
|
|
|
|
|
|
|
except Exception as e: |
|
|
|
|
|
|
|
self.error_msg_show(str(e)) |
|
|
|
|
|
|
|
|
|
|
|
def get_password(self, callback: callable = None): |
|
|
|
def get_password(self, callback: callable = None): |
|
|
|
if self.timebot.mobatime_api.password is not None: |
|
|
|
if self.timebot.mobatime_api.password is not None: |
|
|
|
return |
|
|
|
return |
|
|
@ -182,7 +192,7 @@ class TimebotApiWorker(QObject): |
|
|
|
self.tmw = tmw |
|
|
|
self.tmw = tmw |
|
|
|
self.timebot = timebot |
|
|
|
self.timebot = timebot |
|
|
|
|
|
|
|
|
|
|
|
def run(self): |
|
|
|
def run_status(self): |
|
|
|
try: |
|
|
|
try: |
|
|
|
self.tmw.present = self.timebot.present |
|
|
|
self.tmw.present = self.timebot.present |
|
|
|
self.tmw.update_hours_present(override=self.timebot.get_hours_present()) |
|
|
|
self.tmw.update_hours_present(override=self.timebot.get_hours_present()) |
|
|
|