From 54a8cd9b4f53782db065990556851c95c23c138d Mon Sep 17 00:00:00 2001 From: Page Asgardius Date: Tue, 27 Aug 2024 12:50:56 -0700 Subject: [PATCH] touchscreen --- videoplayer.py | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/videoplayer.py b/videoplayer.py index 9361543..39d2893 100644 --- a/videoplayer.py +++ b/videoplayer.py @@ -1,4 +1,6 @@ import sys +import time +import threading from PyQt6.QtWidgets import QApplication, QMainWindow, QHBoxLayout, QVBoxLayout, QWidget, QPushButton, QSlider from PyQt6.QtMultimedia import QMediaPlayer, QAudioOutput from PyQt6.QtMultimediaWidgets import QVideoWidget @@ -8,7 +10,8 @@ from PyQt6.QtCore import QUrl, Qt, QEvent class VideoPlayer(QMainWindow): def __init__(self): super().__init__() - self.fswindow = False + self.fswindow = 0 + self.dclick = False self.setWindowTitle("Video Player") self.setGeometry(100, 100, 640, 480) @@ -103,19 +106,37 @@ class VideoPlayer(QMainWindow): if not self.fswindow: self.slider.setRange(0, duration) + def toglefs(self): + if not self.fswindow == 0: + self.showNormal() + if self.fswindow == 1: + self.showMaximized() + self.set_layout() + self.fswindow = 0 + else: + if self.isMaximized(): + self.fswindow = 1 + print("maximized") + else: + self.fswindow = 2 + self.showFullScreen() + self.setCentralWidget(self.video_widget) + def dclickthr(self): + self.dclick = True + print(self.dclick) + time.sleep(0.5) + self.dclick = False + print(self.dclick) + def eventFilter(self, obj, event): - if event.type() == QEvent.Type.MouseButtonDblClick: - #print('two left') - if self.fswindow: - self.showNormal() - self.set_layout() - self.fswindow = False - + if event.type() == 3: + if self.dclick: + self.toglefs() else: - self.showFullScreen() - self.fswindow = True - self.setCentralWidget(self.video_widget) + dclickth = threading.Thread(target=self.dclickthr, name="Double Click") + dclickth.start() + #print(event.type()) return True