diff --git a/bcdrivertinycan.cpp b/bcdrivertinycan.cpp index ee50659..d9e6edd 100644 --- a/bcdrivertinycan.cpp +++ b/bcdrivertinycan.cpp @@ -146,11 +146,7 @@ uint32_t BCDriverTinyCan::readRawByte( uint32_t deviceID, uint8_t registerID ) c if( getState() != DriverState::Ready) throw BCException( "readRawValue error: driver not loaded." ); - //uint32_t result = transmitter.readRawValue( deviceID, registerID ); - - //value.fromValue( myRandomByte ); - - TCanMsg msg; + ::TCanMsg msg; // msg verpacken msg.MsgFlags = 0L; @@ -218,7 +214,7 @@ void BCDriverTinyCan::writeRawByte( uint32_t deviceID, uint8_t registerID ,uint8 qDebug() << " --- BCDriverTinyCan writeRawValue: " << value; return; - struct TCanMsg msg; + ::TCanMsg msg; int timeout_count = cTIMEOUT_COUNT; msg.MsgFlags = 0L; diff --git a/bctransmitter.cpp b/bctransmitter.cpp index 29db2d3..9ed82b6 100644 --- a/bctransmitter.cpp +++ b/bctransmitter.cpp @@ -38,8 +38,8 @@ BCTransmitter::BCTransmitter(QObject *parent) : QObject(parent), _isBusy(false) { - //_canDriver = new BCDriverTinyCan{this}; - _canDriver = new BCDriverDummy{this}; + _canDriver = new BCDriverTinyCan{this}; + //_canDriver = new BCDriverDummy{this}; } diff --git a/doc/BF_BikeInformation.docx b/doc/BF_BikeInformation.docx index 1f6a6a1..791d50d 100644 Binary files a/doc/BF_BikeInformation.docx and b/doc/BF_BikeInformation.docx differ diff --git a/doc/fancy_switch/.qtcreator/fancy_switch.pro.user b/doc/fancy_switch/.qtcreator/fancy_switch.pro.user new file mode 100644 index 0000000..88025fa --- /dev/null +++ b/doc/fancy_switch/.qtcreator/fancy_switch.pro.user @@ -0,0 +1,224 @@ + + + + + + EnvironmentId + {350f6538-4791-42f9-b43d-6ea1a7b22b7b} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + true + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 1 + 80 + true + true + 1 + 0 + false + true + false + 2 + true + true + 0 + 8 + true + false + 1 + true + true + true + *.md, *.MD, Makefile + false + true + true + + + + ProjectExplorer.Project.PluginSettings + + + true + false + true + true + true + true + + false + + + 0 + true + + true + true + Builtin.DefaultTidyAndClazy + 16 + true + + + + true + + 0 + + + + ProjectExplorer.Project.Target.0 + + Desktop + true + Desktop Qt 6.10.1 MinGW 64-bit + Desktop Qt 6.10.1 MinGW 64-bit + qt.qt6.6101.win64_mingw_kit + 0 + 0 + 0 + + 0 + C:\syncMePlease\projects.now\fancy_switch\build\Desktop_Qt_6_10_1_MinGW_64_bit-Debug + C:/syncMePlease/projects.now/fancy_switch/build/Desktop_Qt_6_10_1_MinGW_64_bit-Debug + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + 0 + true + + 2 + + false + -e cpu-cycles --call-graph "dwarf,4096" -F 250 + + Qt4ProjectManager.Qt4RunConfiguration: + C:/syncMePlease/projects.now/fancy_switch/fancy_switch.pro + false + + true + true + true + %{RunConfig:Executable:Path} + + 1 + 2 + + 1 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + 0 + true + + 2 + + false + -e cpu-cycles --call-graph "dwarf,4096" -F 250 + + Qt4ProjectManager.Qt4RunConfiguration: + C:/syncMePlease/projects.now/fancy_switch/fancy_switch.pro + false + + true + true + true + %{RunConfig:Executable:Path} + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + Version + 22 + + diff --git a/doc/fancy_switch/fancy_switch.pro b/doc/fancy_switch/fancy_switch.pro new file mode 100644 index 0000000..02d18d9 --- /dev/null +++ b/doc/fancy_switch/fancy_switch.pro @@ -0,0 +1,26 @@ +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +CONFIG += c++17 + +# You can make your code fail to compile if it uses deprecated APIs. +# In order to do so, uncomment the following line. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +SOURCES += \ + main.cpp \ + mainwindow.cpp \ + themetogglewidget.cpp + +HEADERS += \ + mainwindow.h \ + themetogglewidget.h + +FORMS += \ + mainwindow.ui + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/doc/fancy_switch/main.cpp b/doc/fancy_switch/main.cpp new file mode 100644 index 0000000..02e873c --- /dev/null +++ b/doc/fancy_switch/main.cpp @@ -0,0 +1,54 @@ +// ============================================================================ +// main.cpp - Vollständiges Beispiel +// ============================================================================ + + +#include +#include +#include +#include +#include + +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QMainWindow window; + window.setWindowTitle("Theme Toggle Demo"); + window.resize(600, 400); + + // Central Widget + QWidget* central = new QWidget(); + QVBoxLayout* layout = new QVBoxLayout(central); + + QLabel* label = new QLabel("Toggle theme using the button in the status bar →"); + label->setAlignment(Qt::AlignCenter); + label->setStyleSheet("font-size: 14pt;"); + layout->addWidget(label); + + window.setCentralWidget(central); + + // StatusBar mit Theme Toggle + QStatusBar* statusBar = window.statusBar(); + statusBar->showMessage("Ready"); + + ThemeToggleWidget* themeToggle = new ThemeToggleWidget(); + statusBar->addPermanentWidget(themeToggle); + + // Optional: Speichere Theme-Einstellung + QObject::connect(themeToggle, &ThemeToggleWidget::themeChanged, + [](bool isDark) { + // Settings speichern + // QSettings settings; + // settings.setValue("theme/darkMode", isDark); + qDebug() << "Theme:" << (isDark ? "Dark" : "Light"); + }); + + window.show(); + + return app.exec(); +} + diff --git a/doc/fancy_switch/mainwindow.cpp b/doc/fancy_switch/mainwindow.cpp new file mode 100644 index 0000000..0a4a1cf --- /dev/null +++ b/doc/fancy_switch/mainwindow.cpp @@ -0,0 +1 @@ +#include "mainwindow.h" diff --git a/doc/fancy_switch/mainwindow.h b/doc/fancy_switch/mainwindow.h new file mode 100644 index 0000000..01e2c23 --- /dev/null +++ b/doc/fancy_switch/mainwindow.h @@ -0,0 +1,122 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +// MainWindow.h +#include +#include +#include +#include "ThemeToggleWidget.h" + +#include + + + +class MainWindow : public QMainWindow { + Q_OBJECT + +public: + MainWindow(QWidget* parent = nullptr) : QMainWindow(parent) { + setupUI(); + setupStatusBar(); + } + +private: + void setupUI() { + // Dein UI Setup + setWindowTitle("My Application"); + resize(800, 600); + } + + void setupStatusBar() { + QStatusBar* statusBar = this->statusBar(); + statusBar->setSizeGripEnabled(true); + + // Theme Toggle Widget rechts hinzufügen + ThemeToggleWidget* themeToggle = new ThemeToggleWidget(this); + statusBar->addPermanentWidget(themeToggle); + + // Optional: Reagiere auf Theme-Änderungen + connect(themeToggle, &ThemeToggleWidget::themeChanged, + this, &MainWindow::onThemeChanged); + + // Status-Message links + statusBar->showMessage("Ready"); + } + +private slots: + void onThemeChanged(bool isDarkMode) { + qDebug() << "Theme changed to:" << (isDarkMode ? "Dark" : "Light"); + + // Hier kannst du zusätzliche Aktionen durchführen: + // - Icons aktualisieren + // - Custom Widgets neu zeichnen + // - Settings speichern + } +}; + + +// ============================================================================ +// Alternative: Mit QAction für Menu/Toolbar +// ============================================================================ + +/* +class MainWindowB : public MainWindow +{ + Q_OBJECT + +public: + MainWindowB(QWidget* parent = nullptr) : MainWindow(parent) + { + //setupUI(); + setupThemeToggle(); + } + +private: + void setupThemeToggle() + { + // Als QAction (kann in Menu UND StatusBar) + m_themeAction = new QAction(this); + m_themeAction->setText("🌙"); // Initial: Dark Mode Icon + m_themeAction->setToolTip("Toggle Dark/Light Mode"); + + connect(m_themeAction, &QAction::triggered, this, &MainWindowB::toggleTheme); + + // In Toolbar + QToolBar* toolbar = addToolBar("Main"); + toolbar->addAction(m_themeAction); + + // UND in StatusBar + QPushButton* statusBarThemeBtn = new QPushButton("🌙", this); + statusBarThemeBtn->setFixedSize(32, 24); + statusBarThemeBtn->setFlat(true); + statusBarThemeBtn->setCursor(Qt::PointingHandCursor); + connect(statusBarThemeBtn, &QPushButton::clicked, this, &MainWindowB::toggleTheme); + + statusBar()->addPermanentWidget(statusBarThemeBtn); + } + +private slots: + void toggleTheme() + { + m_isDarkMode = !m_isDarkMode; + + QString icon = m_isDarkMode ? "☀️" : "🌙"; + m_themeAction->setText(icon); + + // Theme anwenden... + if (m_isDarkMode) + { + applyDarkTheme(); + } else { + applyLightTheme(); + } + } + +private: + bool m_isDarkMode = true; + QAction* m_themeAction; +}; +*/ + + +#endif // MAINWINDOW_H diff --git a/doc/fancy_switch/mainwindow.ui b/doc/fancy_switch/mainwindow.ui new file mode 100644 index 0000000..becc91c --- /dev/null +++ b/doc/fancy_switch/mainwindow.ui @@ -0,0 +1,31 @@ + + + MainWindow + + + + 0 + 0 + 800 + 600 + + + + MainWindow + + + + + + 0 + 0 + 800 + 18 + + + + + + + + diff --git a/doc/fancy_switch/themetogglewidget.cpp b/doc/fancy_switch/themetogglewidget.cpp new file mode 100644 index 0000000..e265e8b --- /dev/null +++ b/doc/fancy_switch/themetogglewidget.cpp @@ -0,0 +1,2 @@ +#include "themetogglewidget.h" + diff --git a/doc/fancy_switch/themetogglewidget.h b/doc/fancy_switch/themetogglewidget.h new file mode 100644 index 0000000..c525fcc --- /dev/null +++ b/doc/fancy_switch/themetogglewidget.h @@ -0,0 +1,278 @@ +// ThemeToggleWidget.h +#ifndef THEMETOGGLEWIDGET_H +#define THEMETOGGLEWIDGET_H + +#include +#include +#include +#include +#include +#include +#include +#include + +class ThemeToggleWidget : public QWidget +{ + Q_OBJECT + Q_PROPERTY(int position READ position WRITE setPosition) + +public: + + explicit ThemeToggleWidget(QWidget* parent = nullptr) + : QWidget(parent), m_isDarkMode(true), m_position(0) { + + setupUI(); + applyDarkTheme(); + + } + + bool isDarkMode() const { return m_isDarkMode; } + + void setDarkMode(bool dark) + { + if (m_isDarkMode != dark) + { + m_isDarkMode = dark; + animateToggle(); + applyTheme(); + emit themeChanged(m_isDarkMode); + } + } + +signals: + + void themeChanged(bool isDarkMode); + +private slots: + + void toggleTheme() + { + setDarkMode(!m_isDarkMode); + } + +public: + + void setupUI() + { + QHBoxLayout* layout = new QHBoxLayout(this); + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(0); + + // Toggle Button + m_toggleButton = new QPushButton(this); + m_toggleButton->setFixedSize(64, 28); + m_toggleButton->setCursor(Qt::PointingHandCursor); + m_toggleButton->setFlat(true); + + connect(m_toggleButton, &QPushButton::clicked, this, &ThemeToggleWidget::toggleTheme); + + layout->addWidget(m_toggleButton); + + setFixedSize(64, 28); + } + + void paintEvent(QPaintEvent*) override + { + qDebug() << " --- paint!"; + + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing); + + int thumbX = 2 + m_position; + /* + // Track background + QColor trackColor = m_isDarkMode ? QColor(0x3A3A3A) : QColor(0xE1DFDD); + painter.setPen(Qt::NoPen); + painter.setBrush(trackColor); + painter.drawRoundedRect(rect(), 14, 14); + + // Animated thumb + int thumbX = 2 + m_position; + QColor thumbColor = m_isDarkMode ? QColor(0x1F1F1F) : QColor(0xFFFFFF); + + // Shadow + painter.setBrush(QColor(0, 0, 0, 30)); + painter.drawEllipse(thumbX + 1, 3, 22, 22); + + // Thumb + painter.setBrush(thumbColor); + painter.drawEllipse(thumbX, 2, 24, 24); + + + // Icon on thumb + painter.setPen(m_isDarkMode ? QColor(0xFFD700) : QColor(0xFFA500)); + QFont iconFont = font(); + iconFont.setPointSize(12); + painter.setFont(iconFont); +*/ + + QString icon = "FITZ!";// m_isDarkMode ? "🌙" : "☀️"; + painter.drawText(QRect(0, 2, 24, 24), Qt::AlignLeft, icon); + } + + int position() const { return m_position; } + void setPosition(int pos) { + m_position = pos; + update(); + } + + void animateToggle() + { + QPropertyAnimation* anim = new QPropertyAnimation(this, "position"); + anim->setDuration(200); + anim->setEasingCurve(QEasingCurve::InOutQuad); + anim->setStartValue(m_position); + anim->setEndValue(m_isDarkMode ? 36 : 0); + anim->start(QAbstractAnimation::DeleteWhenStopped); + } + + void applyTheme() + { + if (m_isDarkMode) { + applyDarkTheme(); + } else { + applyLightTheme(); + } + } + + void applyDarkTheme() + { + QFile file(":/styles/fluent_dark.qss"); + if (file.open(QFile::ReadOnly)) { + qApp->setStyleSheet(file.readAll()); + } else { + // Fallback: Inline Dark Theme + qApp->setStyleSheet(R"( + * { + background-color: #202020; + color: #FFFFFF; + } + QPushButton { + background-color: #2B2B2B; + border: 1px solid #3F3F3F; + border-radius: 4px; + padding: 6px 16px; + } + QPushButton:hover { + background-color: #3A3A3A; + } + QStatusBar { + background-color: #2B2B2B; + color: #B0B0B0; + border-top: 1px solid #3F3F3F; + } + )"); + } + } + + void applyLightTheme() { + QFile file(":/styles/fluent_light.qss"); + if (file.open(QFile::ReadOnly)) { + qApp->setStyleSheet(file.readAll()); + } else { + // Fallback: Inline Light Theme + qApp->setStyleSheet(R"( + * { + background-color: #F3F3F3; + color: #000000; + } + QPushButton { + background-color: #FFFFFF; + border: 1px solid #E1DFDD; + border-radius: 4px; + padding: 6px 16px; + } + QPushButton:hover { + background-color: #F9F9F9; + } + QStatusBar { + background-color: #FFFFFF; + color: #605E5C; + border-top: 1px solid #E1DFDD; + } + )"); + } + } + + bool m_isDarkMode; + int m_position; + QPushButton* m_toggleButton; +}; + +// ============================================================================ +// Alternative: Kompaktere Version ohne Animation +// ============================================================================ + +class SimpleThemeToggle : public QPushButton +{ + Q_OBJECT + +public: + explicit SimpleThemeToggle(QWidget* parent = nullptr) + : QPushButton(parent), m_isDarkMode(true) { + + setFixedSize(48, 28); + setCursor(Qt::PointingHandCursor); + setFlat(true); + updateIcon(); + + connect(this, &QPushButton::clicked, this, &SimpleThemeToggle::toggleTheme); + + // Tooltip + setToolTip("Toggle Dark/Light Mode"); + } + + bool isDarkMode() const { return m_isDarkMode; } + +signals: + void themeChanged(bool isDarkMode); + +private slots: + void toggleTheme() { + m_isDarkMode = !m_isDarkMode; + updateIcon(); + applyTheme(); + emit themeChanged(m_isDarkMode); + } + +private: + + void updateIcon() + { + QString icon = m_isDarkMode ? "☀️" : "🌙"; + setText(icon); + + // Style + QString style = QString( + "QPushButton {" + " background-color: %1;" + " border: 1px solid %2;" + " border-radius: 14px;" + " font-size: 16pt;" + " padding: 0px;" + "}" + "QPushButton:hover {" + " background-color: %3;" + "}" + ).arg(m_isDarkMode ? "#2B2B2B" : "#FFFFFF") + .arg(m_isDarkMode ? "#3F3F3F" : "#E1DFDD") + .arg(m_isDarkMode ? "#3A3A3A" : "#F9F9F9"); + + setStyleSheet(style); + } + + void applyTheme() + { + if (m_isDarkMode) { + // Dark theme + qApp->setStyleSheet("* { background-color: #202020; color: #FFFFFF; }"); + } else { + // Light theme + qApp->setStyleSheet("* { background-color: #F3F3F3; color: #000000; }"); + } + } + + bool m_isDarkMode; +}; + +#endif diff --git a/doc/~$_ConsoleInformation.docx b/doc/~$_ConsoleInformation.docx deleted file mode 100644 index fcd1843..0000000 Binary files a/doc/~$_ConsoleInformation.docx and /dev/null differ