Ongoing GUI updates.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
QT += core gui
|
QT += core gui svg
|
||||||
|
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||||
|
|
||||||
@@ -12,7 +12,8 @@ QMAKE_CXXFLAGS += -std=c++23
|
|||||||
|
|
||||||
INCLUDEPATH += . libwin
|
INCLUDEPATH += . libwin
|
||||||
|
|
||||||
linux:contains(QT_ARCH, arm.*) {
|
linux:contains(QT_ARCH, arm.*)
|
||||||
|
{
|
||||||
message("Konfiguration für Raspberry Pi (ARM) erkannt.")
|
message("Konfiguration für Raspberry Pi (ARM) erkannt.")
|
||||||
|
|
||||||
# 1. Header-Dateien (z.B. für bcm2835.h oder eigene Treiber)
|
# 1. Header-Dateien (z.B. für bcm2835.h oder eigene Treiber)
|
||||||
|
|||||||
@@ -45,12 +45,16 @@ BCDeviceView::BCDeviceView(QWidget *parent)
|
|||||||
_itemDelegate = new BCAnimatedDelegate( _valueModel.getValueList(), this);
|
_itemDelegate = new BCAnimatedDelegate( _valueModel.getValueList(), this);
|
||||||
setItemDelegate( _itemDelegate );
|
setItemDelegate( _itemDelegate );
|
||||||
|
|
||||||
|
qDebug() << " --- View size I: " << this->size();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void BCDeviceView::setDeviceID( BCDevice::ID deviceID )
|
void BCDeviceView::setDeviceID( BCDevice::ID deviceID )
|
||||||
{
|
{
|
||||||
|
qDebug() << " --- View size II: " << this->size();
|
||||||
|
|
||||||
_devideID = deviceID;
|
_devideID = deviceID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
11
bcdriver.cpp
11
bcdriver.cpp
@@ -36,6 +36,9 @@
|
|||||||
#include <bcdriver.h>
|
#include <bcdriver.h>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gibt den Treiberstatus zurück.
|
||||||
|
*/
|
||||||
|
|
||||||
BCDriver::DriverState BCDriver::getDriverState() const
|
BCDriver::DriverState BCDriver::getDriverState() const
|
||||||
{
|
{
|
||||||
@@ -63,6 +66,9 @@ BCDriver::DriverStateResult BCDriverDummy::loadAndStartDriver()
|
|||||||
/// -----------------------------------------------------------------------------------
|
/// -----------------------------------------------------------------------------------
|
||||||
/// -----------------------------------------------------------------------------------
|
/// -----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gibt ein Zufallsbyte zurück.
|
||||||
|
*/
|
||||||
|
|
||||||
TransmitResult BCDriverDummy::readRawByte( uint32_t deviceID, uint8_t registerID ) const
|
TransmitResult BCDriverDummy::readRawByte( uint32_t deviceID, uint8_t registerID ) const
|
||||||
{
|
{
|
||||||
@@ -73,6 +79,11 @@ TransmitResult BCDriverDummy::readRawByte( uint32_t deviceID, uint8_t registerID
|
|||||||
return myRandomByte;
|
return myRandomByte;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Simuliert erfolgreiches scheiben. Tut nix.
|
||||||
|
*/
|
||||||
|
|
||||||
TransmitResult BCDriverDummy::writeRawByte( uint32_t deviceID, uint8_t registerID, uint8_t value ) const
|
TransmitResult BCDriverDummy::writeRawByte( uint32_t deviceID, uint8_t registerID, uint8_t value ) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(deviceID)
|
Q_UNUSED(deviceID)
|
||||||
|
|||||||
30
bcdriver.h
30
bcdriver.h
@@ -37,36 +37,6 @@
|
|||||||
#include <expected>
|
#include <expected>
|
||||||
#include <bcvalue.h>
|
#include <bcvalue.h>
|
||||||
|
|
||||||
/*
|
|
||||||
int32_t CanInitDriver(char *options);
|
|
||||||
void CanDownDriver(void);
|
|
||||||
int32_t CanSetOptions(char *options);
|
|
||||||
int32_t CanDeviceOpen(uint32_t index, char *parameter);
|
|
||||||
int32_t CanDeviceClose(uint32_t index);
|
|
||||||
|
|
||||||
int32_t CanSetMode(uint32_t index, unsigned char can_op_mode, uint16_t can_command);
|
|
||||||
|
|
||||||
int32_t CanTransmit(uint32_t index, struct TCanMsg *msg, int32_t count);
|
|
||||||
void CanTransmitClear(uint32_t index);
|
|
||||||
uint32_t CanTransmitGetCount(uint32_t index);
|
|
||||||
int32_t CanTransmitSet(uint32_t index, uint16_t cmd, uint32_t time);
|
|
||||||
int32_t CanReceive(uint32_t index, struct TCanMsg *msg, int32_t count);
|
|
||||||
void CanReceiveClear(uint32_t index);
|
|
||||||
uint32_t CanReceiveGetCount(uint32_t index);
|
|
||||||
|
|
||||||
int32_t CanSetSpeed(uint32_t index, uint16_t speed);
|
|
||||||
int32_t CanSetSpeedUser(uint32_t index, uint32_t value);
|
|
||||||
char* CanDrvInfo(void);
|
|
||||||
char* CanDrvHwInfo(uint32_t index);
|
|
||||||
int32_t CanSetFilter(uint32_t index, struct TMsgFilter *msg_filter);
|
|
||||||
int32_t CanGetDeviceStatus(uint32_t index, struct TDeviceStatus *status);
|
|
||||||
void CanSetPnPEventCallback(void (DRV_CALLBACK_TYPE *event)(uint32_t index, int32_t status));
|
|
||||||
void CanSetStatusEventCallback(void (DRV_CALLBACK_TYPE *event) (uint32_t index, struct TDeviceStatus *device_status) );
|
|
||||||
void CanSetRxEventCallback(void (DRV_CALLBACK_TYPE *event)(uint32_t index, struct TCanMsg *msg, int32_t count) );
|
|
||||||
|
|
||||||
void CanSetEvents( uint16_t events );
|
|
||||||
uint32_t CanEventStatus(void);
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct CBCItem;
|
struct CBCItem;
|
||||||
class BCDriverStatus;
|
class BCDriverStatus;
|
||||||
|
|||||||
@@ -37,12 +37,48 @@
|
|||||||
|
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
|
// Unter Windows steht der Treibername in der registry
|
||||||
static const char* cMHS_DRIVERNAME = NULL;
|
static const char* cMHS_DRIVERNAME = NULL;
|
||||||
#elif defined(Q_OS_LINUX)
|
#elif defined(Q_OS_LINUX)
|
||||||
// Linux-spezifischer Code (z.B. /proc Filesystem, D-Bus)
|
// Unter linux(artigen) muss der Treibername explizit mit übergeben werden
|
||||||
static const char* cMHS_DRIVERNAME = "libmhstcan.so";
|
static const char* cMHS_DRIVERNAME = "libmhstcan.so";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
// TinyCan C-Api
|
||||||
|
// -------------
|
||||||
|
|
||||||
|
int32_t CanInitDriver(char *options);
|
||||||
|
void CanDownDriver(void);
|
||||||
|
int32_t CanSetOptions(char *options);
|
||||||
|
int32_t CanDeviceOpen(uint32_t index, char *parameter);
|
||||||
|
int32_t CanDeviceClose(uint32_t index);
|
||||||
|
|
||||||
|
int32_t CanSetMode(uint32_t index, unsigned char can_op_mode, uint16_t can_command);
|
||||||
|
|
||||||
|
int32_t CanTransmit(uint32_t index, struct TCanMsg *msg, int32_t count);
|
||||||
|
void CanTransmitClear(uint32_t index);
|
||||||
|
uint32_t CanTransmitGetCount(uint32_t index);
|
||||||
|
int32_t CanTransmitSet(uint32_t index, uint16_t cmd, uint32_t time);
|
||||||
|
int32_t CanReceive(uint32_t index, struct TCanMsg *msg, int32_t count);
|
||||||
|
void CanReceiveClear(uint32_t index);
|
||||||
|
uint32_t CanReceiveGetCount(uint32_t index);
|
||||||
|
|
||||||
|
int32_t CanSetSpeed(uint32_t index, uint16_t speed);
|
||||||
|
int32_t CanSetSpeedUser(uint32_t index, uint32_t value);
|
||||||
|
char* CanDrvInfo(void);
|
||||||
|
char* CanDrvHwInfo(uint32_t index);
|
||||||
|
int32_t CanSetFilter(uint32_t index, struct TMsgFilter *msg_filter);
|
||||||
|
int32_t CanGetDeviceStatus(uint32_t index, struct TDeviceStatus *status);
|
||||||
|
void CanSetPnPEventCallback(void (DRV_CALLBACK_TYPE *event)(uint32_t index, int32_t status));
|
||||||
|
void CanSetStatusEventCallback(void (DRV_CALLBACK_TYPE *event) (uint32_t index, struct TDeviceStatus *device_status) );
|
||||||
|
void CanSetRxEventCallback(void (DRV_CALLBACK_TYPE *event)(uint32_t index, struct TCanMsg *msg, int32_t count) );
|
||||||
|
|
||||||
|
void CanSetEvents( uint16_t events );
|
||||||
|
uint32_t CanEventStatus(void);
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Destruktor. Entlädt den CAN-Bus Treiber wieder.
|
* @brief Destruktor. Entlädt den CAN-Bus Treiber wieder.
|
||||||
*/
|
*/
|
||||||
@@ -76,8 +112,6 @@ BCDriver::DriverStateResult BCDriverTinyCan::loadDriver()
|
|||||||
{
|
{
|
||||||
auto callLoadDriver = [&]() -> DriverStateResult
|
auto callLoadDriver = [&]() -> DriverStateResult
|
||||||
{
|
{
|
||||||
qDebug() << " -- Hier!";
|
|
||||||
//if( ::LoadDriver( NULL ) < 0 )
|
|
||||||
if( ::LoadDriver( cMHS_DRIVERNAME ) < 0 )
|
if( ::LoadDriver( cMHS_DRIVERNAME ) < 0 )
|
||||||
return std::unexpected(QString("Driver Error: 'LoadDriver'"));
|
return std::unexpected(QString("Driver Error: 'LoadDriver'"));
|
||||||
_driverState = DriverState::Loaded;
|
_driverState = DriverState::Loaded;
|
||||||
@@ -126,19 +160,20 @@ BCDriver::DriverStateResult BCDriverTinyCan::loadDriver()
|
|||||||
.and_then( callInitDriver )
|
.and_then( callInitDriver )
|
||||||
.and_then( callOpenDevice );
|
.and_then( callOpenDevice );
|
||||||
|
|
||||||
// success:
|
// in Fehlerfall ist der Errorstring gesetzt,
|
||||||
if(newDriverState)
|
// der interne _driverstate ist
|
||||||
{
|
// irgendwo unter DriverState::Opened
|
||||||
// return 'DriverState::Opened'
|
|
||||||
return _driverState;
|
|
||||||
}
|
|
||||||
// return driver error message,
|
|
||||||
// _driverState ist irgendwo unter DriverState::Opened
|
|
||||||
return newDriverState;
|
return newDriverState;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// __fix
|
|
||||||
|
/**
|
||||||
|
* @brief Um mit dem Bionx eBike reden zu können, müssen wir
|
||||||
|
* die Console in den Slave-Mode setzen.
|
||||||
|
* @return Fehlerstring oder DriverState::DeviceReady
|
||||||
|
*/
|
||||||
|
|
||||||
BCDriver::DriverStateResult BCDriverTinyCan::setConsoleSlaveMode()
|
BCDriver::DriverStateResult BCDriverTinyCan::setConsoleSlaveMode()
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -164,7 +199,6 @@ BCDriver::DriverStateResult BCDriverTinyCan::setConsoleSlaveMode()
|
|||||||
|
|
||||||
unsigned int retry = cTimeOuts;
|
unsigned int retry = cTimeOuts;
|
||||||
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
writeRawByte( console, slaveFlag, 1 );
|
writeRawByte( console, slaveFlag, 1 );
|
||||||
@@ -192,6 +226,7 @@ void BCDriverTinyCan::resetDriver()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief BCDriverTinyCan::readRawByte
|
* @brief BCDriverTinyCan::readRawByte
|
||||||
* Kapselt den Treiberzugiff über die legacy C-Api. Liest ein byte, gibt dieses im std::expected aber
|
* Kapselt den Treiberzugiff über die legacy C-Api. Liest ein byte, gibt dieses im std::expected aber
|
||||||
|
|||||||
139
bcguihelpers.cpp
139
bcguihelpers.cpp
@@ -32,16 +32,18 @@
|
|||||||
|
|
||||||
#include <bcguihelpers.h>
|
#include <bcguihelpers.h>
|
||||||
|
|
||||||
|
|
||||||
BCThemeSwitchButton::BCThemeSwitchButton(QWidget *parent )
|
BCThemeSwitchButton::BCThemeSwitchButton(QWidget *parent )
|
||||||
: QPushButton(parent), _isDarkMode(true)
|
: QPushButton(parent)
|
||||||
{
|
{
|
||||||
// 1. Visuelles Setup: Flach, keine Ränder, Hand-Cursor
|
// Visuelles Setup: Flach, keine Ränder, Hand-Cursor
|
||||||
setFlat(true);
|
setFlat(true);
|
||||||
setCursor(Qt::PointingHandCursor);
|
setCursor(Qt::PointingHandCursor);
|
||||||
setFixedSize(24, 24); // Kleiner Footprint im StatusBar
|
setFixedSize(24, 24); // Kleiner Footprint im StatusBar
|
||||||
|
|
||||||
// CSS: Transparent, damit es sich nahtlos in den StatusBar einfügt
|
// CSS: Transparent, damit es sich nahtlos in den StatusBar einfügt
|
||||||
// Schriftgröße etwas erhöhen, damit die Emojis gut erkennbar sind
|
// Schriftgröße etwas erhöhen, damit die Emojis gut erkennbar sind
|
||||||
|
/*
|
||||||
setStyleSheet(R"(
|
setStyleSheet(R"(
|
||||||
QPushButton {
|
QPushButton {
|
||||||
border: none;
|
border: none;
|
||||||
@@ -53,17 +55,30 @@ BCThemeSwitchButton::BCThemeSwitchButton(QWidget *parent )
|
|||||||
border-radius: 24px;
|
border-radius: 24px;
|
||||||
}
|
}
|
||||||
)");
|
)");
|
||||||
|
*/
|
||||||
// 2. Initialer Status (Startet im Dark Mode -> zeigt Mond)
|
// Initialer Status (Startet im Dark Mode -> zeigt Mond)
|
||||||
updateIcon();
|
updateIcon();
|
||||||
|
|
||||||
// 3. Klick verbinden
|
|
||||||
connect(this, &QPushButton::clicked, this, &BCThemeSwitchButton::toggle);
|
connect(this, &QPushButton::clicked, this, &BCThemeSwitchButton::toggle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Setzt den DarkMode
|
||||||
|
*/
|
||||||
|
|
||||||
void BCThemeSwitchButton::toggle()
|
void BCThemeSwitchButton::setDarkMode( bool isDark )
|
||||||
|
{
|
||||||
|
_isDarkMode = !isDark;
|
||||||
|
toggleMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Schaltet den akutellen Mode um.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void BCThemeSwitchButton::toggleMode()
|
||||||
{
|
{
|
||||||
_isDarkMode = !_isDarkMode;
|
_isDarkMode = !_isDarkMode;
|
||||||
updateIcon();
|
updateIcon();
|
||||||
@@ -71,13 +86,17 @@ void BCThemeSwitchButton::toggle()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Icon & Tooltip anpassen
|
||||||
|
*/
|
||||||
|
|
||||||
void BCThemeSwitchButton::updateIcon()
|
void BCThemeSwitchButton::updateIcon()
|
||||||
{
|
{
|
||||||
// Logik:
|
// Logik:
|
||||||
// Ist Dark Mode an? Zeige Mond (oder Sonne, je nach Geschmack).
|
// Ist Dark Mode an? Zeige Mond (oder Sonne, je nach Geschmack).
|
||||||
// Hier: Zeige das Symbol des AKTUELLEN Modus.
|
// Hier: Zeige das Symbol des AKTUELLEN Modus.
|
||||||
setText(_isDarkMode ? "🌙" : "☀️");
|
setText(_isDarkMode ? "🌙" : "☀️");
|
||||||
setToolTip(_isDarkMode ? "Switch to Light Mode" : "Switch to Dark Mode");
|
setToolTip(_isDarkMode ? "Zum LightMode wechseln" : "Zum DarkMode wechseln");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -85,22 +104,20 @@ void BCThemeSwitchButton::updateIcon()
|
|||||||
/// -----------------------------------------------------------------------------------
|
/// -----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Hilfswidget: Zeigt den DriverState als Icon an.
|
||||||
|
*/
|
||||||
|
|
||||||
BCDriverStateWidget::BCDriverStateWidget(QWidget* parent)
|
BCDriverStateWidget::BCDriverStateWidget(QWidget* parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||||
layout->setContentsMargins(10, 2, 10, 2);
|
layout->setContentsMargins(10, 2, 10, 2);
|
||||||
layout->setSpacing(8);
|
//layout->setSpacing(8);
|
||||||
|
|
||||||
_label = new QLabel(this);
|
|
||||||
_label->setStyleSheet("font-weight: 500;"); // Medium weight
|
|
||||||
|
|
||||||
_led = new QLabel(this);
|
_led = new QLabel(this);
|
||||||
_led->setFixedSize(12, 12);
|
_led->setFixedSize(12, 12);
|
||||||
|
|
||||||
layout->addWidget(_label);
|
|
||||||
layout->addWidget(_led);
|
layout->addWidget(_led);
|
||||||
|
|
||||||
// Startzustand
|
// Startzustand
|
||||||
@@ -115,31 +132,11 @@ void BCDriverStateWidget::onDriverStateChanged(BCDriver::DriverState state, cons
|
|||||||
{
|
{
|
||||||
_state = state;
|
_state = state;
|
||||||
qDebug() << " --- StateWidget: " << state << " - " << customMessage;
|
qDebug() << " --- StateWidget: " << state << " - " << customMessage;
|
||||||
// Standard-Texte, falls keine Nachricht übergeben wurde
|
|
||||||
QString text = customMessage;
|
|
||||||
if (text.isEmpty())
|
|
||||||
{
|
|
||||||
switch (_state)
|
|
||||||
{
|
|
||||||
case BCDriver::DriverState::DeviceReady:
|
|
||||||
text = "Device Ready";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BCDriver::DriverState::Error:
|
|
||||||
text = "Driver Error";
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
text = "Not Present";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_label->setText(text);
|
|
||||||
|
|
||||||
updateStyle();
|
updateStyle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
void BCDriverStateWidget::updateStyle()
|
void BCDriverStateWidget::updateStyle()
|
||||||
{
|
{
|
||||||
QString ledStyle;
|
QString ledStyle;
|
||||||
@@ -181,8 +178,76 @@ void BCDriverStateWidget::updateStyle()
|
|||||||
|
|
||||||
setToolTip(toolTipText);
|
setToolTip(toolTipText);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
void BCDriverStateWidget::updateStyle()
|
||||||
|
{
|
||||||
|
QString ledStyle;
|
||||||
|
QString toolTipText;
|
||||||
|
/*
|
||||||
|
NotPresent,
|
||||||
|
Error,
|
||||||
|
Loaded,
|
||||||
|
Initialized,
|
||||||
|
Opened, // bis hierher: dll vorhanden, Treiber geladen
|
||||||
|
DeviceReady
|
||||||
|
*/
|
||||||
|
switch (_state)
|
||||||
|
{
|
||||||
|
case BCDriver::DriverState::NotPresent:
|
||||||
|
// FLUENT GRAY (Neutral)
|
||||||
|
// Wir machen es dunkelgrau mit hellem Rand -> "Ausgeschaltet"-Look
|
||||||
|
ledStyle = "background-color: #3B3B3B; border: 1px solid #606060;";
|
||||||
|
toolTipText = "Treiber nicht geladen.";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BCDriver::DriverState::Error:
|
||||||
|
// FLUENT RED (Critical)
|
||||||
|
ledStyle = "background-color: #C42B1C; border: 1px solid #A80000;";
|
||||||
|
toolTipText = "Fehler beim Laden des Treibers.";
|
||||||
|
break;
|
||||||
|
|
||||||
|
// hier: dll vorhanden, Treiber geladen
|
||||||
|
case BCDriver::DriverState::Loaded:
|
||||||
|
case BCDriver::DriverState::Initialized:
|
||||||
|
case BCDriver::DriverState::Opened:
|
||||||
|
// FLUENT RED (Critical)
|
||||||
|
ledStyle = "background-color: #FF8C00; border: 1px solid #A80000;";
|
||||||
|
toolTipText = "Fehler beim Laden des Treibers.";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BCDriver::DriverState::DeviceReady:
|
||||||
|
// FLUENT GREEN (Success)
|
||||||
|
ledStyle = "background-color: #107C10; border: 1px solid #0E600E;";
|
||||||
|
toolTipText = "Verbindung erfolgreich hergestellt.";
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Styles anwenden (immer rund machen)
|
||||||
|
_led->setStyleSheet(ledStyle + "border-radius: 6px;");
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Textfarbe setzen
|
||||||
|
_setStyleSheet(QString("color: %1; font-weight: %2;")
|
||||||
|
.arg(labelColor)
|
||||||
|
.arg(_state == BCDriver::DriverState::DeviceReady ? "bold" : "normal"));
|
||||||
|
*/
|
||||||
|
setToolTip(toolTipText);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BCDriverStateWidget::mouseReleaseEvent(QMouseEvent* event)
|
||||||
|
{
|
||||||
|
qDebug() << " --- RELAASE!";
|
||||||
|
|
||||||
|
if (event->button() == Qt::LeftButton)
|
||||||
|
{
|
||||||
|
qDebug() << " --- MOO?!";
|
||||||
|
|
||||||
|
emit clicked();
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget::mouseReleaseEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -36,10 +36,16 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
|
||||||
#include <bcdriver.h>
|
#include <bcdriver.h>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Einfaches Buttonwidget, um zwischen Dark- und Lightmode
|
||||||
|
* zu wechseln
|
||||||
|
*/
|
||||||
|
|
||||||
class BCThemeSwitchButton : public QPushButton
|
class BCThemeSwitchButton : public QPushButton
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -47,6 +53,7 @@ class BCThemeSwitchButton : public QPushButton
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
explicit BCThemeSwitchButton(QWidget *parent = nullptr);
|
explicit BCThemeSwitchButton(QWidget *parent = nullptr);
|
||||||
|
void setDarkMode( bool isDark );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
@@ -54,13 +61,13 @@ signals:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void toggle();
|
void toggleMode();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void updateIcon();
|
void updateIcon();
|
||||||
|
|
||||||
bool _isDarkMode;
|
bool _isDarkMode{false};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -70,6 +77,11 @@ private:
|
|||||||
/// -----------------------------------------------------------------------------------
|
/// -----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Einfaches Widget, um den Zustand des TinyCan Native
|
||||||
|
* Drivers anzuzeigen.
|
||||||
|
*/
|
||||||
|
|
||||||
class BCDriverStateWidget : public QWidget
|
class BCDriverStateWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -84,12 +96,16 @@ public slots:
|
|||||||
// 'customMessage' ist optional. Wenn leer, wird ein Standardtext genommen.
|
// 'customMessage' ist optional. Wenn leer, wird ein Standardtext genommen.
|
||||||
void onDriverStateChanged(BCDriver::DriverState state, const QString& customMessage = QString());
|
void onDriverStateChanged(BCDriver::DriverState state, const QString& customMessage = QString());
|
||||||
|
|
||||||
private:
|
signals:
|
||||||
|
|
||||||
|
void clicked();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
void updateStyle();
|
void updateStyle();
|
||||||
|
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||||
|
|
||||||
QLabel* _led;
|
QLabel* _led;
|
||||||
QLabel* _label;
|
|
||||||
BCDriver::DriverState _state;
|
BCDriver::DriverState _state;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#include "qassert.h"
|
#include "qassert.h"
|
||||||
@@ -119,6 +119,7 @@ void BCMainWindow::initMainWindow()
|
|||||||
configureAction(_batteryButton, _batteryAction, BCDevice::ID::Battery );
|
configureAction(_batteryButton, _batteryAction, BCDevice::ID::Battery );
|
||||||
//configureAction(_pimpButton, _pimpAction, BCDevice::ID::Pimp );
|
//configureAction(_pimpButton, _pimpAction, BCDevice::ID::Pimp );
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
bool m_isDarkMode = false;
|
bool m_isDarkMode = false;
|
||||||
QString icon = m_isDarkMode ? "☀️" : "🌙";
|
QString icon = m_isDarkMode ? "☀️" : "🌙";
|
||||||
@@ -165,23 +166,74 @@ void BCMainWindow::initMainWindow()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// 2. Bild für den Zustand UNCHECKED (Off) hinzufügen
|
||||||
|
// Das ist das Symbol, wenn NICHT verbunden ist (z.B. ein Stecker)
|
||||||
|
connectIcon.addFile(":/icons/plug_disconnected.svg", QSize(), QIcon::Normal, QIcon::Off);
|
||||||
|
|
||||||
|
// 3. Bild für den Zustand CHECKED (On) hinzufügen
|
||||||
|
// Das ist das Symbol, wenn verbunden IST (z.B. Stecker in Dose)
|
||||||
|
connectIcon.addFile(":/icons/plug_connected.svg", QSize(), QIcon::Normal, QIcon::On);
|
||||||
|
*/
|
||||||
|
|
||||||
void BCMainWindow::initStatusBar()
|
void BCMainWindow::initStatusBar()
|
||||||
{
|
{
|
||||||
QStatusBar *statBar = statusBar();
|
QStatusBar *statBar = statusBar();
|
||||||
|
|
||||||
BCDriverStateWidget* connector = new BCDriverStateWidget(this);
|
BCDriverStateWidget* conState = new BCDriverStateWidget(this);
|
||||||
connect( &_transmitter, &BCTransmitter::driverStateChanged, connector, &BCDriverStateWidget::onDriverStateChanged );
|
connect( &_transmitter, &BCTransmitter::driverStateChanged, conState, &BCDriverStateWidget::onDriverStateChanged );
|
||||||
statBar->addPermanentWidget(connector);
|
connect( conState, &BCDriverStateWidget::clicked, _connectAction, &QAction::trigger );
|
||||||
|
|
||||||
statBar->showMessage("Ready");
|
statBar->addPermanentWidget(conState);
|
||||||
BCThemeSwitchButton *themeBtn = new BCThemeSwitchButton(this);
|
conState->installEventFilter(this);
|
||||||
|
|
||||||
|
BCThemeSwitchButton* themeBtn = new BCThemeSwitchButton(this);
|
||||||
statBar->addPermanentWidget(themeBtn);
|
statBar->addPermanentWidget(themeBtn);
|
||||||
connect(themeBtn, &BCThemeSwitchButton::themeChanged, this, [this](bool isDark)
|
connect(themeBtn, &BCThemeSwitchButton::themeChanged, this, [this](bool isDark)
|
||||||
{
|
{
|
||||||
QString message = isDark ? "Dark Mode Activated" : "Light Mode Activated";
|
QString message = isDark ? "Dark Mode Activated" : "Light Mode Activated";
|
||||||
statusBar()->showMessage( message, 3000);
|
statusBar()->showMessage( message, 3000);
|
||||||
|
setApplicationStyleSheet( isDark ? ":/claude_dark_mode.qss"_L1 : ":/claude_light_mode.qss"_L1 );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Wir starten im light mode
|
||||||
|
//themeBtn->setDarkMode( false );
|
||||||
|
|
||||||
|
statBar->showMessage("Ready");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
bool BCMainWindow::eventFilter(QObject *obj, QEvent *event)
|
||||||
|
{
|
||||||
|
if (obj == myWidget && event->type() == QEvent::MouseButtonRelease) {
|
||||||
|
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
|
||||||
|
if (mouseEvent->button() == Qt::LeftButton) {
|
||||||
|
myAction->trigger();
|
||||||
|
return true; // Event wurde verarbeitet
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QObject::eventFilter(obj, event);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Setzt das Stylesheet, hier: Dark- oder Lightmode
|
||||||
|
* @param path Der Pfad zuum Stylesheet
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool BCMainWindow::setApplicationStyleSheet( QAnyStringView path )
|
||||||
|
{
|
||||||
|
QFile styleFile( path.toString() );
|
||||||
|
if (styleFile.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
|
{
|
||||||
|
QString style = styleFile.readAll();
|
||||||
|
qApp->setStyleSheet(style);
|
||||||
|
styleFile.close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
qWarning() << "Konnte Stylesheet nicht laden:" << styleFile.errorString();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -195,6 +247,10 @@ void BCMainWindow::setHeaderLabel( const QString& headerText)
|
|||||||
_headerLabel->setText( " BionxControl: " + headerText );
|
_headerLabel->setText( " BionxControl: " + headerText );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BCMainWindow::onShowMessage( const QString& message, int timeOut )
|
||||||
|
{
|
||||||
|
_statusbar->showMessage( message, timeOut );
|
||||||
|
}
|
||||||
|
|
||||||
void BCMainWindow::autoConnect()
|
void BCMainWindow::autoConnect()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -60,10 +60,12 @@ public slots:
|
|||||||
void onConnectButtonToggled(bool active );
|
void onConnectButtonToggled(bool active );
|
||||||
void onDriverStateChanged( BCDriver::DriverState state, const QString& message="" );
|
void onDriverStateChanged( BCDriver::DriverState state, const QString& message="" );
|
||||||
|
|
||||||
// Slots für Rückmeldungen vom Runner
|
// Slots für Rückmeldungen vom Transmitter
|
||||||
void onValueUpdated( BCDevice::ID deviceID, int index, BCValue::State state, const QString& newValue="" );
|
void onValueUpdated( BCDevice::ID deviceID, int index, BCValue::State state, const QString& newValue="" );
|
||||||
void onSyncDeviceView();
|
void onSyncDeviceView();
|
||||||
|
|
||||||
|
void onShowMessage( const QString& message, int timeOut=3000);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
// Internes Signal, um Daten an den Worker Thread zu senden
|
// Internes Signal, um Daten an den Worker Thread zu senden
|
||||||
@@ -71,10 +73,13 @@ signals:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
bool setApplicationStyleSheet( QAnyStringView path );
|
||||||
void initMainWindow();
|
void initMainWindow();
|
||||||
void initStatusBar();
|
void initStatusBar();
|
||||||
void autoConnect();
|
void autoConnect();
|
||||||
|
|
||||||
|
//bool eventFilter(QObject *obj, QEvent *event) override;
|
||||||
|
|
||||||
BCXmlLoader _dataManager;
|
BCXmlLoader _dataManager;
|
||||||
|
|
||||||
// Wir brauchen eine Verbindung zwischen den Views
|
// Wir brauchen eine Verbindung zwischen den Views
|
||||||
|
|||||||
@@ -19,6 +19,9 @@
|
|||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true"/>
|
||||||
|
</property>
|
||||||
<widget class="QWidget" name="_centralwidget">
|
<widget class="QWidget" name="_centralwidget">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
@@ -169,13 +172,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="fitzeButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Fitze</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -318,7 +314,11 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QStatusBar" name="_statusbar"/>
|
<widget class="QStatusBar" name="_statusbar">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">background-color: #DADADA</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
<action name="_pimpAction">
|
<action name="_pimpAction">
|
||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
|||||||
@@ -44,11 +44,9 @@ BCTransmitter::BCTransmitter(QObject *parent)
|
|||||||
{
|
{
|
||||||
//_canDriver = new BCDriverTinyCan{this};
|
//_canDriver = new BCDriverTinyCan{this};
|
||||||
_canDriver = &_dummyDriver;
|
_canDriver = &_dummyDriver;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Steuert die Verbindung mit dem 'echten' CAN-Bus Treiber.
|
* @brief Steuert die Verbindung mit dem 'echten' CAN-Bus Treiber.
|
||||||
* @param connect true: Vesuche den CAN-Bus Treiber zu laden und zu verbinden
|
* @param connect true: Vesuche den CAN-Bus Treiber zu laden und zu verbinden
|
||||||
@@ -59,6 +57,10 @@ void BCTransmitter::onToggleDriverConnection( bool connect )
|
|||||||
{
|
{
|
||||||
qDebug() << " --- onToggleDriverConnection: " << connect;
|
qDebug() << " --- onToggleDriverConnection: " << connect;
|
||||||
// FIX! Ende der current op abwarten!
|
// FIX! Ende der current op abwarten!
|
||||||
|
BCDriver::DriverState state = connect ? BCDriver::DriverState::DeviceReady : BCDriver::DriverState::NotPresent;
|
||||||
|
const QString& message = connect ? "Trying to connect" : " FAILED";
|
||||||
|
emit driverStateChanged(state, message);
|
||||||
|
return;
|
||||||
|
|
||||||
// Hier sind wir noch in GUI Thread
|
// Hier sind wir noch in GUI Thread
|
||||||
QMutexLocker locker(&_mutex);
|
QMutexLocker locker(&_mutex);
|
||||||
@@ -69,7 +71,7 @@ void BCTransmitter::onToggleDriverConnection( bool connect )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BCTransmitter::onStartNativeDirver()
|
void BCTransmitter::onStartNativeDriver()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public slots:
|
|||||||
void onToggleDriverConnection( bool connect );
|
void onToggleDriverConnection( bool connect );
|
||||||
void onEnqueueValue(BCValuePtrConst value );
|
void onEnqueueValue(BCValuePtrConst value );
|
||||||
void onProcessValue();
|
void onProcessValue();
|
||||||
void onStartNativeDirver();
|
void onStartNativeDriver();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
17
main.cpp
17
main.cpp
@@ -39,31 +39,14 @@
|
|||||||
|
|
||||||
#include <bcmainwindow.h>
|
#include <bcmainwindow.h>
|
||||||
|
|
||||||
#include <expected>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool setApplicationStyleSheet( QAnyStringView path )
|
|
||||||
{
|
|
||||||
QFile styleFile( path.toString() );
|
|
||||||
if (styleFile.open(QIODevice::ReadOnly | QIODevice::Text))
|
|
||||||
{
|
|
||||||
QString style = styleFile.readAll();
|
|
||||||
qApp->setStyleSheet(style);
|
|
||||||
styleFile.close();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
qWarning() << "Konnte Stylesheet nicht laden:" << styleFile.errorString();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
//setApplicationStyleSheet( ":/claude_light_mode.qss"_L1 );
|
|
||||||
/*
|
/*
|
||||||
app.setStyleSheet(R"(
|
app.setStyleSheet(R"(
|
||||||
QWidget {
|
QWidget {
|
||||||
|
|||||||
Reference in New Issue
Block a user