This commit is contained in:
Your Name
2024-04-27 02:52:10 -05:00
parent 43dcaeb3cd
commit bad184b0a5
130 changed files with 13562 additions and 2217 deletions

View File

@@ -18,4 +18,6 @@ fi
apt-get update
apt-get install -y python3-pyqt5
pip3 install termqt
pip3 install termqt
apt-get install python3-pyqt5.qtwebengine
pip3 install pywayland

View File

@@ -4,8 +4,8 @@ set -x
# Test: sudo mount -o remount,rw /; cp /usr/comma/bg.org /usr/comma/bg.jpg; bash shell/set_logo.sh
# Check if md5sum of /usr/comma/bg.jpg is not equal to md5sum of /data/openpilot/shell/bg.jpg
if [ "$(md5sum /usr/comma/bg.jpg | awk '{print $1}')" != "$(md5sum /data/openpilot/shell/bg.jpg | awk '{print $1}')" ]; then
# Check if md5sum of /usr/comma/bg.jpg is not equal to md5sum of /data/openpilot/system/clearpilot/startup_logo/bg.jpg
if [ "$(md5sum /usr/comma/bg.jpg | awk '{print $1}')" != "$(md5sum /data/openpilot/system/clearpilot/startup_logo/bg.jpg | awk '{print $1}')" ]; then
# If /usr/comma/bg.org does not exist
if [ ! -f /usr/comma/bg.org ]; then
@@ -25,22 +25,22 @@ if [ "$(md5sum /usr/comma/bg.jpg | awk '{print $1}')" != "$(md5sum /data/openpil
# If /usr/comma/bg.org does exist
if [ -f /usr/comma/bg.org ]; then
sudo cp -f /data/openpilot/shell/bg.jpg /usr/comma/bg.jpg
sudo cp -f /data/openpilot/system/clearpilot/startup_logo/bg.jpg /usr/comma/bg.jpg
fi
# If file /usr/comma/revert_logo.sh does not exist
if [ "$(md5sum /data/openpilot/shell/revert_logo.sh | awk '{print $1}')" != "$(md5sum /usr/comma/revert_logo.sh | awk '{print $1}')" ]; then
sudo cp /data/openpilot/shell/revert_logo.sh /usr/comma/revert_logo.sh
if [ "$(md5sum /data/openpilot/system/clearpilot/startup_logo/revert_logo.sh | awk '{print $1}')" != "$(md5sum /usr/comma/revert_logo.sh | awk '{print $1}')" ]; then
sudo cp /data/openpilot/system/clearpilot/startup_logo/revert_logo.sh /usr/comma/revert_logo.sh
fi
if [ "$(md5sum md5sum /usr/comma/comma.sh | awk '{print $1}')" != "$(md5sum /data/openpilot/shell/usr_comma_comma.sh | awk '{print $1}')" ]; then
if [ "$(md5sum md5sum /usr/comma/comma.sh | awk '{print $1}')" != "$(md5sum /data/openpilot/system/clearpilot/startup_logo/usr_comma_comma.sh | awk '{print $1}')" ]; then
if [[ "$(md5sum /usr/comma/comma.sh | awk '{print $1}')" == "ddbac0b46dd02efd672a0ef31ca426cf" ]]; then
if [ ! -f /usr/comma/comma.org ]; then
sudo cp /usr/comma/comma.sh /usr/comma/comma.org
fi
fi
if [-f /usr/comma/comma.org ]; then
sudo cp /data/openpilot/shell/usr_comma_comma.sh /usr/comma/comma.sh
if [ -f /usr/comma/comma.org ]; then
sudo cp /data/openpilot/system/clearpilot/startup_logo/usr_comma_comma.sh /usr/comma/comma.sh
echo updated comma.sh
fi
fi

View File

@@ -0,0 +1 @@
sudo su comma -c "python3 shell.py \"echo hello; sleep 5\"

View File

@@ -2,7 +2,7 @@ import os
import sys
import signal
from PyQt5.QtWidgets import QApplication, QWidget, QHBoxLayout, QGraphicsView, QGraphicsScene
from PyQt5.QtCore import Qt, QUrl, QPointF, QTimer
from PyQt5.QtCore import Qt, QUrl, QPointF, QTimer, QObject, QEvent
from PyQt5.QtGui import QCursor, QPixmap, QTransform
from PyQt5.QtWebEngineWidgets import QWebEngineView
@@ -10,23 +10,125 @@ webview = None
def on_load_finished(arg):
global webview
if arg: # Check if the page load was successful
webview.setZoomFactor(2)
nothing=0
# if arg: # Check if the page load was successful
# webview.setZoomFactor(2)
class RotatedWindow(QWidget):
class MouseEventFilter(QObject):
def __init__(self, target, width, height):
super().__init__()
def eventFilter(self, obj, event):
if event.type() in [QEvent.MouseButtonPress, QEvent.MouseButtonRelease, QEvent.MouseMove]:
print("Mouse event blocked:", event.type())
return True # Block event propagation
return False # Other events are not blocked
class MouseEventFilter2(QObject):
def __init__(self, target, width, height):
super().__init__()
self.target = target
self.width = width
self.height = height
def eventFilter(self, obj, event):
if event.type() in [QEvent.MouseButtonPress, QEvent.MouseButtonRelease, QEvent.MouseMove]:
# Calculate new coordinates (90 degrees rotation)
new_x = event.y()
new_y = self.width - event.x() - 1
print (new_x, new_y)
# Create a new event with the transformed coordinates
new_event = QEvent(event.type())
new_event.setButtons(event.buttons())
new_event.setButton(event.button())
new_event.setGlobalPos(event.globalPos())
new_event.setLocalPos(QPointF(new_x, new_y))
new_event.setWindowPos(QPointF(new_x, new_y))
new_event.setScreenPos(QPointF(new_x, new_y))
# Send event to the target
# QApplication.sendEvent(self.target, new_event)
print (event)
return True
# print (event)
return False
class MyWebView(QWebEngineView):
def __init__(self, parent=None):
super().__init__(parent)
self.rotation_angle = 90
self.cursor_rotation_timer = QTimer(self)
self.cursor_rotation_timer.timeout.connect(self.rotateCursor)
self.cursor_rotation_timer.start(1000) # Rotate the cursor every 1 second
self.is_custom_event = False # Flag to indicate a custom event
def rotateCursor(self):
current_cursor = self.cursor()
pixmap = current_cursor.pixmap()
rotated_pixmap = pixmap.transformed(QTransform().rotate(self.rotation_angle))
rotated_cursor = QCursor(rotated_pixmap)
self.setCursor(rotated_cursor)
def rotateMouseEvent(self, event):
original_pos = event.localPos()
rotated_pos = QPointF(original_pos.y(), self.width() - original_pos.x())
# Create a new QMouseEvent with the rotated coordinates
rotated_event = QMouseEvent(event.type(), rotated_pos, event.button(), event.buttons(), event.modifiers())
# Mark as custom to prevent recursion
self.is_custom_event = True
QApplication.sendEvent(self, rotated_event)
self.is_custom_event = False
def mousePressEvent(self, event):
print(event)
if not self.is_custom_event: # Check if it's a native event
self.rotateMouseEvent(event)
def mouseReleaseEvent(self, event):
if not self.is_custom_event: # Check if it's a native event
self.rotateMouseEvent(event)
class BetterWebView2(QWebEngineView):
def __init__(self):
super().__init__()
self.load(QUrl('http://www.example.com'))
QApplication.processEvents() # Process pending events to ensure children are created
self.eventsReceiverWidget = None
for obj in self.children():
widget = self.findChild(QWidget, obj.objectName())
if widget:
self.eventsReceiverWidget = widget
break
if self.eventsReceiverWidget:
self.eventsReceiverWidget.installEventFilter(self)
def eventFilter(self, source, event):
if source == self.eventsReceiverWidget and event.type() == QEvent.MouseButtonPress:
print("Mouse Button Pressed!")
return super().eventFilter(source, event)
class TransparentOverlay(QWidget):
def __init__(self, parent=None):
super().__init__(parent)
self.setWindowFlags(Qt.Window | Qt.FramelessWindowHint)
self.setAttribute(Qt.WA_TransparentForMouseEvents)
self.setStyleSheet("background:transparent;")
# self.setStyleSheet("background:black;")
def mousePressEvent(self, event):
print("Mouse event captured and discarded")
class BetterWebView(QWebEngineView):
def __init__(self):
super().__init__()
self.load(QUrl('http://www.example.com'))
QApplication.processEvents() # Process pending events to ensure children are created
# self.install_filters(self) # Install filters starting from the web view itself
# self.overlay = TransparentOverlay(self)
# self.overlay.resize(self.size())
def install_filters(self, widget):
if isinstance(widget, QWidget): # Check if it's a QWidget to be able to receive events
widget.installEventFilter(self)
for child in widget.children(): # Recursively apply to all children
self.install_filters(child)
def eventFilter(self, source, event):
if isinstance(source, QWidget) and event.type() == QEvent.MouseButtonPress:
print(f"Mouse Button Pressed in widget: {source}")
return super().eventFilter(source, event)
def create_webview_app():
global webview
@@ -40,31 +142,41 @@ def create_webview_app():
# Application setup
app = QApplication(sys.argv)
desktop = QApplication.desktop()
screen_geometry = desktop.availableGeometry(desktop.primaryScreen())
window = RotatedWindow()
sg = desktop.availableGeometry(desktop.primaryScreen())
window = QWidget()
window.setWindowTitle("Qt WebView Example")
window.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)
window.setGeometry(0, 0, screen_geometry.height(), screen_geometry.width())
window.setStyleSheet("background-color: white;")
window.setGeometry(0, 0, sg.height(), sg.width())
window.setStyleSheet("background-color: black;")
window.showFullScreen()
scene = QGraphicsScene()
view = QGraphicsView(scene, window)
view.setGeometry(0, 0, window.width(), window.height())
view.setGeometry(0, 0, sg.width(), sg.height())
view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
# Create WebView
webview = QWebEngineView()
# webview = MyWebView()
webview = BetterWebView()
webview.load(QUrl("https://cdpn.io/yananas/fullpage/rwvZvY"))
webview.setGeometry(0, 0, window.width(), window.height())
webview.setGeometry(0, 0, sg.width(), sg.height())
webview.loadFinished.connect(on_load_finished)
white_box = QWidget()
white_box.setGeometry(0, 0, sg.width(), sg.height())
white_box.setStyleSheet("background-color: blue;")
filter = MouseEventFilter(white_box, sg.height(), sg.width())
white_box.installEventFilter(filter)
white_box.setAttribute(Qt.WA_TransparentForMouseEvents, False)
# Add WebView to the scene
proxy_webview = scene.addWidget(webview)
proxy_webview = scene.addWidget(white_box)
view.setScene(scene)
view.rotate(window.rotation_angle) # Rotate the view by 90 degrees
view.rotate(90) # Rotate the view by 90 degrees
# Layout setup
window_layout = QHBoxLayout(window)
@@ -81,4 +193,4 @@ def main():
sys.exit(exit_code)
if __name__ == "__main__":
main()
main()

View File

@@ -0,0 +1 @@
sudo su comma -c "nice python3 webview.py"