diff --git a/RecordVideo.py b/RecordVideo.py index 583d59f..7c557fb 100644 --- a/RecordVideo.py +++ b/RecordVideo.py @@ -299,11 +299,11 @@ class RecordVideo(): print('first run_time:%s' % run_time) print('now:%s' % now.strftime(time_format)) - # qual_days = 1 - (now - run_time_obj).days + qual_days = 91 - (now - run_time_obj).days # print('qualified days:%d' % (qual_days)) - qual_hours = (now - run_time_obj).total_seconds() // 3600 - # if qual_days > 0: - if 5 - qual_hours > 0: + # qual_hours = (now - run_time_obj).total_seconds() // 3600 + if qual_days > 0: + # if 5 - qual_hours > 0: qualified = True CloseKey(key) diff --git a/RecordWindow.py b/RecordWindow.py index 424e242..12a3845 100644 --- a/RecordWindow.py +++ b/RecordWindow.py @@ -39,9 +39,12 @@ class RecordWindow(QtWidgets.QWidget): self.rti = RecordTrayIcon(self) self.rti.update_state(self.recording, self.record_type) - self.rc = RecordConfig() - self.file_dir = self.rc.config.get('record','file_dir') + self.sc = Shortcut() + + self.update_setting(True) + # self.rc = RecordConfig() + # self.file_dir = self.rc.config.get('record','file_dir') # self.debugCameraAction.triggered.connect(self.rv.debug_camera) def closeEvent(self, event): @@ -352,7 +355,11 @@ class RecordWindow(QtWidgets.QWidget): if changed: print('update setting..') self.rv.load_config() + + self.rc = RecordConfig() + self.load_shortcut() + self.file_dir = self.rc.config.get('record','file_dir') '''' 鼠标拖动窗体 @@ -392,33 +399,37 @@ class RecordWindow(QtWidgets.QWidget): ''' + def load_shortcut(self): + + self.sc.clear() + + camera_key_group = self.rc.config.get('shortcut','camera') + screen_key_group = self.rc.config.get('shortcut','screen') + stop_record_key_group = self.rc.config.get('shortcut','stop') + + camera_shortcut = [int(key) for key in camera_key_group.split(',')] + screen_shortcut = [int(key) for key in screen_key_group.split(',')] + stop_shortcut = [int(key) for key in stop_record_key_group.split(',')] + + print('camera shortcut: %s' % camera_shortcut) + print('screen shortcut: %s' % screen_shortcut) + print('stop shortcut: %s' % stop_shortcut) + + if camera_key_group: + self.sc.add(1, camera_shortcut, lambda: self.record(RecordType.Camera)) + if screen_key_group: + self.sc.add(2, screen_shortcut, lambda: self.record(RecordType.Screen)) + if stop_record_key_group: + self.sc.add(3, stop_shortcut, self.stop_record) + + def monitor_shortcut(self): if self.rv.check_run_state(): - sc = Shortcut() - - camera_key_group = self.rc.config.get('shortcut','camera') - screen_key_group = self.rc.config.get('shortcut','screen') - stop_record_key_group = self.rc.config.get('shortcut','stop') - - camera_shortcut = [int(key) for key in camera_key_group.split(',')] - screen_shortcut = [int(key) for key in screen_key_group.split(',')] - stop_shortcut = [int(key) for key in stop_record_key_group.split(',')] - - print('camera shortcut: %s' % camera_shortcut) - print('screen shortcut: %s' % screen_shortcut) - print('stop shortcut: %s' % stop_shortcut) - - if camera_key_group: - sc.add(1, camera_shortcut, lambda: self.record(RecordType.Camera)) - if screen_key_group: - sc.add(2, screen_shortcut, lambda: self.record(RecordType.Screen)) - if stop_record_key_group: - sc.add(3, stop_shortcut, self.stop_record) - - - sc.monitor() + self.load_shortcut() + + self.sc.monitor() else: question = QMessageBox(self) diff --git a/SettingWindow.py b/SettingWindow.py index 809fb5f..e9b6d87 100644 --- a/SettingWindow.py +++ b/SettingWindow.py @@ -403,9 +403,9 @@ class SettingWindow(QDialog): # print(camera_device_name) #快捷键 - record_camera_key_group_name = '(' +self.le_start_record_camera_shortcut.text()+ ')' - record_screen_key_group_name = '(' +self.le_start_record_screen_shortcut.text()+ ')' - record_stop_key_group_name = '(' +self.le_start_stop_exit_shortcut.text()+ ')' + record_camera_key_group_name = self.le_start_record_camera_shortcut.text() + record_screen_key_group_name = self.le_start_record_screen_shortcut.text() + record_stop_key_group_name = self.le_start_stop_exit_shortcut.text() # print(record_camera_key_group_name) #录制 @@ -438,6 +438,7 @@ class SettingWindow(QDialog): conf.set(record_section_name,'threads', str(threads)) self.rc.write() + #通知主窗口更新设置 self.update_setting.emit(self.changed) self.changed = False self.update_state() diff --git a/Shortcut.py b/Shortcut.py index 2e01c33..2d249c7 100644 --- a/Shortcut.py +++ b/Shortcut.py @@ -22,6 +22,10 @@ class Shortcut(): HOTKEYS[key_group_id] = key_group ACTIONS[key_group_id] = action + + def clear(self): + HOTKEYS.clear() + ACTIONS.clear() def KeyDownEvent(self, event): global KEY_STATUS diff --git a/configByLinxiao.ini b/configByLinxiao.ini index 8853499..1dc87a5 100644 --- a/configByLinxiao.ini +++ b/configByLinxiao.ini @@ -5,15 +5,15 @@ screen_device_name = @device_sw_{860BB310-5D01-11D0-BD3B-00A0C911CE86}\{4EA69364 system_voice_device_name = @device_sw_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\{8E146464-DB61-4309-AFA1-3578E927E935} [shortcut] -camera = (160,162,164,65) -screen = (160,162,164,66) -stop = (160,162,164,67) +camera = 160,162,164,65 +screen = 160,162,164,66 +stop = 160,162,164,67 [record] -resolution = 1280x1024 +resolution = 1920x1080 vcodec = libx264 frame_rate = 30.0 -file_dir = C:/Users/lv/ctest/record-camera-and-screen +file_dir = C:\Users\lv\ctest\record-camera-and-screen threads = 4 [author]