From 43dcaeb3cd33f175921da05fb8a9b18bab90b84d Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 27 Apr 2024 00:48:30 -0500 Subject: [PATCH] wip --- openpilot/update.sh | 0 system/clearpilot/tools/webview.py | 84 ++++++++++++++++++++++++++++++ update.sh | 35 +++++++++++++ 3 files changed, 119 insertions(+) create mode 100644 openpilot/update.sh create mode 100644 system/clearpilot/tools/webview.py create mode 100644 update.sh diff --git a/openpilot/update.sh b/openpilot/update.sh new file mode 100644 index 0000000..e69de29 diff --git a/system/clearpilot/tools/webview.py b/system/clearpilot/tools/webview.py new file mode 100644 index 0000000..2adc8e0 --- /dev/null +++ b/system/clearpilot/tools/webview.py @@ -0,0 +1,84 @@ +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.QtGui import QCursor, QPixmap, QTransform +from PyQt5.QtWebEngineWidgets import QWebEngineView + +webview = None + +def on_load_finished(arg): + global webview + if arg: # Check if the page load was successful + webview.setZoomFactor(2) + +class RotatedWindow(QWidget): + 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 + + 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 create_webview_app(): + global webview + + # Set environment for Wayland + os.environ["XDG_RUNTIME_DIR"] = "/var/tmp/weston" + os.environ["WAYLAND_DISPLAY"] = "wayland-0" + os.environ["QT_QPA_PLATFORM"] = "wayland" + os.environ["QT_WAYLAND_SHELL_INTEGRATION"] = "wl-shell" + + # Application setup + app = QApplication(sys.argv) + desktop = QApplication.desktop() + screen_geometry = desktop.availableGeometry(desktop.primaryScreen()) + + window = RotatedWindow() + 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.showFullScreen() + + scene = QGraphicsScene() + view = QGraphicsView(scene, window) + view.setGeometry(0, 0, window.width(), window.height()) + view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + + # Create WebView + webview = QWebEngineView() + webview.load(QUrl("https://cdpn.io/yananas/fullpage/rwvZvY")) + webview.setGeometry(0, 0, window.width(), window.height()) + webview.loadFinished.connect(on_load_finished) + + # Add WebView to the scene + proxy_webview = scene.addWidget(webview) + view.setScene(scene) + view.rotate(window.rotation_angle) # Rotate the view by 90 degrees + + # Layout setup + window_layout = QHBoxLayout(window) + window_layout.addWidget(view) + window_layout.setContentsMargins(0, 0, 0, 0) + window.setLayout(window_layout) + + return app, window + +def main(): + signal.signal(signal.SIGINT, signal.SIG_DFL) # Enable Ctrl+C to terminate the application + app, window = create_webview_app() + exit_code = app.exec_() + sys.exit(exit_code) + +if __name__ == "__main__": + main() diff --git a/update.sh b/update.sh new file mode 100644 index 0000000..d695b76 --- /dev/null +++ b/update.sh @@ -0,0 +1,35 @@ + +# Set branch to your target branch +branch="clearpilot" + +# Fetch the latest changes from the remote repository for the target branch +git fetch origin "$branch" + +# Check if the local branch is behind the remote branch +LOCAL=$(git rev-parse "@{0}") +REMOTE=$(git rev-parse "origin/$branch") + +if [ "$LOCAL" != "$REMOTE" ]; then + echo "Local branch is behind; updating." + + # Checkout the target branch forcefully, ignoring submodules as in the Python example + git checkout --force --no-recurse-submodules -B "$branch" "origin/$branch" + + # Reset the local changes hard, clean the directory including untracked files and directories, + # and ensure submodules are in sync, updated, and also reset hard + git reset --hard + git clean -xdff + git submodule sync + git submodule update --init --recursive + git submodule foreach --recursive git reset --hard + + echo "Repository and submodules have been updated and cleaned." + + # Run git cleanup in the repository directory + git gc + git lfs prune + + echo "Repository cleanup has been completed." +else + echo "Already at the latest version; no update needed." +fi \ No newline at end of file