wip
This commit is contained in:
0
openpilot/update.sh
Normal file
0
openpilot/update.sh
Normal file
84
system/clearpilot/tools/webview.py
Normal file
84
system/clearpilot/tools/webview.py
Normal file
@@ -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()
|
||||||
35
update.sh
Normal file
35
update.sh
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user