From 884e8e903eeeaba6a1dcb2a88e8ea23826955bc2 Mon Sep 17 00:00:00 2001 From: sourceworx Date: Fri, 3 Apr 2026 22:28:07 +0200 Subject: [PATCH] Fixed build process. --- BionxControl.pro | 4 +- CMakeLists.txt | 11 +++-- Dockerfile | 18 ++++----- ...4-toolchain.cmake => armhf-toolchain.cmake | 16 ++++---- bcmainwindow.cpp | 6 +-- bcthemeswitchbutton.cpp => bcthemebutton.cpp | 12 +++--- bcthemeswitchbutton.h => bcthemebutton.h | 4 +- build_and_deploy.sh | 40 +++++++++++++++++++ main.cpp | 15 ++++++- resources/bc_light.qss | 6 +++ runme.sh | 0 runme.txt | 11 ++--- 12 files changed, 100 insertions(+), 43 deletions(-) rename aarch64-toolchain.cmake => armhf-toolchain.cmake (62%) rename bcthemeswitchbutton.cpp => bcthemebutton.cpp (83%) rename bcthemeswitchbutton.h => bcthemebutton.h (92%) create mode 100755 build_and_deploy.sh create mode 100644 runme.sh diff --git a/BionxControl.pro b/BionxControl.pro index cd74c38..dab3051 100644 --- a/BionxControl.pro +++ b/BionxControl.pro @@ -19,7 +19,7 @@ SOURCES += \ bcdriver.cpp \ bcdriverstatewidget.cpp \ bcdrivertinycan.cpp \ - bcthemeswitchbutton.cpp \ + bcthemebutton.cpp \ bctoggleswitch.cpp \ bctransmitter.cpp \ bcvalue.cpp \ @@ -40,7 +40,7 @@ HEADERS += \ bcdriverstatewidget.h \ bcdrivertinycan.h \ bcmainwindow.h \ - bcthemeswitchbutton.h \ + bcthemebutton.h \ bctoggleswitch.h \ bctransmitter.h \ bcvalue.h \ diff --git a/CMakeLists.txt b/CMakeLists.txt index f6e3e24..66afb32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,10 +28,16 @@ qt_add_executable(BionxControl WIN32 MACOSX_BUNDLE bcvaluemodel.cpp bcvaluemodel.h bcvalueslider.cpp bcvalueslider.h bcvalueslider.ui bcxmlloader.cpp bcxmlloader.h - libwin/can_drv_win.c - libwin/mhs_can_drv.c main.cpp ) + +# Plattformspezifische CAN-Treiber einbinden +if(WIN32) + target_sources(BionxControl PRIVATE libwin/can_drv_win.c) +elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") + target_sources(BionxControl PRIVATE libwin/mhs_can_drv.c) +endif() + target_include_directories(BionxControl PRIVATE . libwin @@ -129,4 +135,3 @@ install(TARGETS BionxControl BUNDLE DESTINATION . RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) - diff --git a/Dockerfile b/Dockerfile index 52624f1..acd29e2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,15 +4,15 @@ FROM debian:trixie # Verhindert interaktive Prompts während der Installation ENV DEBIAN_FRONTEND=noninteractive -# 1. Multiarch für arm64 aktivieren -RUN dpkg --add-architecture arm64 && \ +# 1. Multiarch für armhf aktivieren +RUN dpkg --add-architecture armhf && \ apt-get update && \ apt-get upgrade -y -# 2. Host-Build-Tools und Cross-Compiler installieren +# 2. Host-Build-Tools und Cross-Compiler für 32-Bit installieren RUN apt-get install -y \ build-essential \ - crossbuild-essential-arm64 \ + crossbuild-essential-armhf \ cmake \ ninja-build \ git \ @@ -24,12 +24,12 @@ RUN apt-get install -y \ qt6-tools-dev-tools \ qt6-svg-dev -# 4. Qt6 Bibliotheken für das TARGET (arm64) installieren +# 4. Qt6 Bibliotheken für das TARGET (armhf) installieren RUN apt-get install -y \ - qt6-base-dev:arm64 \ - libglvnd-dev:arm64 \ - qt6-svg-dev:arm64 - + qt6-base-dev:armhf \ + libglvnd-dev:armhf \ + qt6-svg-dev:armhf + # Aufräumen RUN apt-get clean && rm -rf /var/lib/apt/lists/* diff --git a/aarch64-toolchain.cmake b/armhf-toolchain.cmake similarity index 62% rename from aarch64-toolchain.cmake rename to armhf-toolchain.cmake index cf27c13..6c23004 100644 --- a/aarch64-toolchain.cmake +++ b/armhf-toolchain.cmake @@ -1,23 +1,23 @@ # Name des Zielsystems set(CMAKE_SYSTEM_NAME Linux) -set(CMAKE_SYSTEM_PROCESSOR aarch64) +set(CMAKE_SYSTEM_PROCESSOR arm) -# Die Cross-Compiler aus dem Debian-Paket -set(CMAKE_C_COMPILER /usr/bin/aarch64-linux-gnu-gcc) -set(CMAKE_CXX_COMPILER /usr/bin/aarch64-linux-gnu-g++) +# Die Cross-Compiler aus dem Debian-Paket für 32-Bit (armhf) +set(CMAKE_C_COMPILER /usr/bin/arm-linux-gnueabihf-gcc) +set(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabihf-g++) # Wo das System nach Bibliotheken und Headern suchen soll (Sysroot) set(CMAKE_SYSROOT /) -# Pfade für pkg-config anpassen, damit es die arm64 .pc Dateien findet +# Pfade für pkg-config anpassen, damit es die armhf .pc Dateien findet set(ENV{PKG_CONFIG_DIR} "") -set(ENV{PKG_CONFIG_LIBDIR} "/usr/lib/aarch64-linux-gnu/pkgconfig:/usr/share/pkgconfig") +set(ENV{PKG_CONFIG_LIBDIR} "/usr/lib/arm-linux-gnueabihf/pkgconfig:/usr/share/pkgconfig") set(ENV{PKG_CONFIG_SYSROOT_DIR} ${CMAKE_SYSROOT}) # Suchverhalten für find_package(), find_library() etc. set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) # Programme (wie moc) auf dem Host suchen -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) # Libs nur im Target (arm64) suchen -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) # Header nur im Target (arm64) suchen +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) # Libs nur im Target (armhf) suchen +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) # Header nur im Target (armhf) suchen set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) # CMake-Pakete nur im Target suchen # *** WICHTIG FÜR QT6 *** diff --git a/bcmainwindow.cpp b/bcmainwindow.cpp index f609e51..1e4df70 100644 --- a/bcmainwindow.cpp +++ b/bcmainwindow.cpp @@ -34,7 +34,7 @@ #include #include -#include +#include #include #include #include @@ -189,9 +189,9 @@ void BCMainWindow::initStatusBar() _statusBar->addPermanentWidget(conState); conState->installEventFilter(this); - BCThemeSwitchButton* themeBtn = new BCThemeSwitchButton(this); + BCThemeButton* themeBtn = new BCThemeButton(this); _statusBar->addPermanentWidget(themeBtn); - connect(themeBtn, &BCThemeSwitchButton::themeChanged, this, [this](bool isDark) + connect(themeBtn, &BCThemeButton::themeChanged, this, [this](bool isDark) { QString message = isDark ? "using DarkMode." : "using LightMode."; onShowMessage( message ); diff --git a/bcthemeswitchbutton.cpp b/bcthemebutton.cpp similarity index 83% rename from bcthemeswitchbutton.cpp rename to bcthemebutton.cpp index f88b101..7bcdcea 100644 --- a/bcthemeswitchbutton.cpp +++ b/bcthemebutton.cpp @@ -30,10 +30,10 @@ ***************************************************************************/ -#include +#include -BCThemeSwitchButton::BCThemeSwitchButton(QWidget *parent ) +BCThemeButton::BCThemeButton(QWidget *parent ) : QPushButton(parent) { // Visuelles Setup: Flach, keine Ränder, Hand-Cursor @@ -42,7 +42,7 @@ BCThemeSwitchButton::BCThemeSwitchButton(QWidget *parent ) setFixedSize( 24, 24 ); updateIcon(); - connect(this, &QPushButton::clicked, this, &BCThemeSwitchButton::toggleMode); + connect(this, &QPushButton::clicked, this, &BCThemeButton::toggleMode); } @@ -50,7 +50,7 @@ BCThemeSwitchButton::BCThemeSwitchButton(QWidget *parent ) * @brief Setzt den DarkMode */ -void BCThemeSwitchButton::setDarkMode( bool isDark ) +void BCThemeButton::setDarkMode( bool isDark ) { _isDarkMode = !isDark; toggleMode(); @@ -61,7 +61,7 @@ void BCThemeSwitchButton::setDarkMode( bool isDark ) * @brief Schaltet den akutellen Mode um. */ -void BCThemeSwitchButton::toggleMode() +void BCThemeButton::toggleMode() { _isDarkMode = !_isDarkMode; updateIcon(); @@ -73,7 +73,7 @@ void BCThemeSwitchButton::toggleMode() * @brief Icon & Tooltip anpassen */ -void BCThemeSwitchButton::updateIcon() +void BCThemeButton::updateIcon() { setText(_isDarkMode ? "🌙" : "☀️"); setToolTip(_isDarkMode ? "Use LightMode" : "Use DarkMode"); diff --git a/bcthemeswitchbutton.h b/bcthemebutton.h similarity index 92% rename from bcthemeswitchbutton.h rename to bcthemebutton.h index fe12fe6..17c116b 100644 --- a/bcthemeswitchbutton.h +++ b/bcthemebutton.h @@ -43,13 +43,13 @@ * zu wechseln */ -class BCThemeSwitchButton : public QPushButton +class BCThemeButton : public QPushButton { Q_OBJECT public: - explicit BCThemeSwitchButton(QWidget *parent = nullptr); + explicit BCThemeButton(QWidget *parent = nullptr); void setDarkMode( bool isDark ); signals: diff --git a/build_and_deploy.sh b/build_and_deploy.sh new file mode 100755 index 0000000..de67043 --- /dev/null +++ b/build_and_deploy.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# Bricht das Skript ab, falls ein Befehl (z. B. der Build) fehlschlägt +set -e + +# --- Variablen (Bitte anpassen!) --- +IMAGE_NAME="qt-cross-rpi" +# Trage hier den genauen Namen deines fertig kompilierten Executables ein: +BINARY_NAME="BionxControl" +TARGET_USER="chris" +TARGET_IP="192.168.0.106" +TARGET_DIR="/home/chris/projects/BionxControl" +# Den Namen der Toolchain aus deiner Vorlage oder der zuvor erstellten Datei +TOOLCHAIN_FILE="armhf-toolchain.cmake" + +echo "=== 1. Baue das Docker-Image ===" +docker build -t ${IMAGE_NAME} . + +echo "=== 2. Kompiliere das Projekt im Container ===" +# Wir führen die Build-Befehle direkt im Container aus, anstatt interaktiv zu starten. +# Das -it flag wurde entfernt, da wir es als Skript ausführen. +docker run --rm -v "$(pwd):/workspace" ${IMAGE_NAME} bash -c " + echo 'Bereinige altes Build-Verzeichnis...' + rm -rf dockerbuild + + mkdir dockerbuild + cd dockerbuild + + echo 'Führe CMake aus...' + cmake -DCMAKE_TOOLCHAIN_FILE=../${TOOLCHAIN_FILE} -G Ninja .. + + echo 'Starte Build (Ninja)...' + ninja +" + +echo "=== 3. Deploy auf den Raspberry Pi via scp ===" +# Kopiert das neu gebaute Binary auf die Zielmaschine +scp "dockerbuild/${BINARY_NAME}" "${TARGET_USER}@${TARGET_IP}:${TARGET_DIR}" + +echo "=== Deployment erfolgreich abgeschlossen! ===" diff --git a/main.cpp b/main.cpp index 1308b34..58ee69f 100644 --- a/main.cpp +++ b/main.cpp @@ -31,6 +31,7 @@ #include +#include #include #include @@ -45,9 +46,19 @@ int main(int argc, char *argv[]) QApplication app(argc, argv); + BCMainWindow mainWindow; + + if (QSysInfo::machineHostName() == "BionxControl") + { + mainWindow.setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); + mainWindow.showFullScreen(); + } + else + { + // Normaler Fenster-Modus (z. B. für die Entwicklung auf dem Desktop) + mainWindow.show(); + } - BCMainWindow w; - w.show(); return app.exec(); diff --git a/resources/bc_light.qss b/resources/bc_light.qss index 0ce6558..31b57ae 100644 --- a/resources/bc_light.qss +++ b/resources/bc_light.qss @@ -7,6 +7,7 @@ /* Text: #000000, #1f1f1f */ /* Borders: #e1e1e1, #d1d1d1 */ + /* === QWidget Base === */ QWidget { background-color: #f3f3f3; @@ -250,3 +251,8 @@ QLineEdit:disabled { color: #a0a0a0; border: 1px solid #e1e1e1; } + + +QSlider { + background: hotpink; +} diff --git a/runme.sh b/runme.sh new file mode 100644 index 0000000..e69de29 diff --git a/runme.txt b/runme.txt index 7d52b7d..eebd48a 100644 --- a/runme.txt +++ b/runme.txt @@ -1,14 +1,9 @@ docker build -t qt-cross-rpi . -// eigentlich: docker buildx build --platform linux/arm64 -t qt-cross-rpi --load . docker run --rm -it -v "$(pwd):/workspace" qt-cross-rpi bash -# 1. Erstelle einen separaten Build-Ordner und wechsle dorthin + mkdir build cd build - -# 2. Konfiguriere das Projekt mit CMake und deiner Toolchain-Datei für aarch64 -cmake -DCMAKE_TOOLCHAIN_FILE=../aarch64-toolchain.cmake -G Ninja .. - -# 3. Starte den Kompiliervorgang -ninja \ No newline at end of file +cmake -DCMAKE_TOOLCHAIN_FILE=../arm32-toolchain.cmake -G Ninja .. +ninja