Skip to content

Commit

Permalink
强制刷新widget
Browse files Browse the repository at this point in the history
  • Loading branch information
ElluIFX committed Oct 14, 2023
1 parent c6563c5 commit 9511756
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
21 changes: 10 additions & 11 deletions Client/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from PySide6.QtMultimedia import *
from PySide6.QtMultimediaWidgets import *
from PySide6.QtWidgets import *
from server import KVM_Server, add_auth_user, count_auth_users
from server import FPSCounter, KVM_Server, add_auth_user, count_auth_users
from ui import (
device_setup_dialog_ui,
indicator_ui,
Expand Down Expand Up @@ -252,6 +252,7 @@ def __init__(self, parent=None):
self.camera_info = None
self.audio_opened = False
self.device_connected = False
self.fpsc = FPSCounter()

# 子窗口
self.device_setup_dialog = MyDeviceSetupDialog()
Expand Down Expand Up @@ -839,14 +840,13 @@ def camera_error_occurred(self, error, string):
self.videoWidget.hide()
self.disconnect_label.show()
self.setWindowTitle("USB KVM Client")
logger.error(error_s)
self.check_device_status()
QMessageBox.critical(self, self.tr("Device Error"), error_s)

def frame_changed(self, frame: QVideoFrame):
# self.image = frame.toImage()
# self.image_event.set()
pass
self.videoWidget.videoSink().setVideoFrame(frame)
self.videoWidget.update()
self.videoWidget.repaint()

# 初始化指定配置视频设备
def setup_device(self):
Expand Down Expand Up @@ -908,12 +908,10 @@ def setup_device(self):

self.capture_session = QMediaCaptureSession()
self.capture_session.setCamera(self.camera)
# self.capture_session.setVideoSink(self.videoWidget.videoSink())
self.capture_session.setVideoOutput(self.videoWidget)
# self.video_sink = QVideoSink()
# self.video_sink.videoFrameChanged.connect(self.frame_changed)
# self.video_sink.setVideoFrame(self.videoWidget)
# self.capture_session.setVideoSink(self.video_sink)
self.video_sink = QVideoSink()
self.capture_session.setVideoSink(self.video_sink)
# self.capture_session.setVideoOutput(self.videoWidget)
self.video_sink.videoFrameChanged.connect(self.frame_changed)

self.image_capture = QImageCapture(self.camera)
self.capture_session.setImageCapture(self.image_capture)
Expand Down Expand Up @@ -1917,6 +1915,7 @@ def mouseMoveEvent(self, event):
def mouse_report_timeout(self):
if self._new_mouse_report:
self._hid_signal.emit(mouse_buffer)
self._new_mouse_report = False

scan_to_b2 = {
0x001D: 1, # Left Control
Expand Down
4 changes: 2 additions & 2 deletions Client/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def check_auth_secret():
return False


class fps_counter:
class FPSCounter:
def __init__(self, max_sample=40) -> None:
self.t = time.perf_counter()
self.max_sample = max_sample
Expand Down Expand Up @@ -175,7 +175,7 @@ def reset(self):
self.t = time.perf_counter()


fpc = fps_counter()
fpc = FPSCounter()


class KVM_Server(QObject):
Expand Down

0 comments on commit 9511756

Please sign in to comment.