Visual Cleanups.
This commit is contained in:
@@ -52,6 +52,9 @@ BCMainWindow::BCMainWindow(QWidget *parent)
|
||||
|
||||
setupUi(this);
|
||||
|
||||
// den pimp-my-ride-button schalten wir vorerst aus.
|
||||
_pimpButton->hide();
|
||||
|
||||
// Wir schreiben den 'initMainWindow()' Aufruf mit Hilfe des
|
||||
// timers in die Event-Queue, damit er erst ausgeführt wird,
|
||||
// wenn das Fenster sichtbar ist.
|
||||
@@ -74,17 +77,6 @@ BCMainWindow::~BCMainWindow()
|
||||
_worker.wait(); // Warten bis Thread wirklich fertig ist
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Setzt den Headerlabel ( == die Device-Bezeichnung )
|
||||
* @param headerLabel Der headerLabel
|
||||
*/
|
||||
|
||||
void BCMainWindow::setHeaderLabel( const QString& headerText)
|
||||
{
|
||||
_headerLabel->setText( " BionxControl: " + headerText );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialisiert alle Komponenten des MainWindows.
|
||||
*/
|
||||
@@ -95,63 +87,62 @@ void BCMainWindow::initMainWindow()
|
||||
// Lambda um die buttons mit ihren Actions zu verbinden
|
||||
auto configureAction = [&]( QToolButton* button, QAction* action, BCDevice::ID deviceID )
|
||||
{
|
||||
|
||||
// Action an den Button binden
|
||||
button->setDefaultAction( action);
|
||||
|
||||
// new way: die DeviceID muss aber explizit vom Lambda eingefanden werden.
|
||||
connect( action, &QAction::triggered, this, [this,deviceID]()
|
||||
{
|
||||
onShowDevicePanel( deviceID );
|
||||
});
|
||||
{
|
||||
onShowDevicePanel( deviceID );
|
||||
});
|
||||
|
||||
if( _devicePanels.contains(deviceID) )
|
||||
{
|
||||
BCDeviceView* currentPanel = _devicePanels[deviceID];
|
||||
// ... und ihre device ID
|
||||
currentPanel->setDeviceID( deviceID );
|
||||
// Wenn ein Device (entspricht einem Datenmodel) fertig eingelesen wurde,
|
||||
// wird es weitergereicht.
|
||||
// Problem: alle Panels bekommen alle Datenmodelle angeboten.
|
||||
connect( &_dataManager, &BCXmlLoader::valueListReady, currentPanel, &BCDeviceView::onValueListReady );
|
||||
}
|
||||
{
|
||||
BCDeviceView* currentPanel = _devicePanels[deviceID];
|
||||
// ... und ihre device ID
|
||||
currentPanel->setDeviceID( deviceID );
|
||||
// Wenn ein Device (entspricht einem Datenmodel) fertig eingelesen wurde,
|
||||
// wird es weitergereicht.
|
||||
// Problem: alle Panels bekommen alle Datenmodelle angeboten.
|
||||
connect( &_dataManager, &BCXmlLoader::valueListReady, currentPanel, &BCDeviceView::onValueListReady );
|
||||
}
|
||||
};
|
||||
|
||||
// Wir wollen die Devices den Views zuordnen können
|
||||
_devicePanels[BCDevice::ID::Console] = _consolePanel;
|
||||
_devicePanels[BCDevice::ID::Battery] = _batteryPanel;
|
||||
_devicePanels[BCDevice::ID::Motor] = _motorPanel;
|
||||
_devicePanels[BCDevice::ID::Pimp] = _pimpPanel;
|
||||
//_devicePanels[BCDevice::ID::Pimp] = _pimpPanel;
|
||||
|
||||
// Die actions an die Buttons binden
|
||||
// Die actions an die Buttons binden
|
||||
configureAction(_motorButton, _motorAction, BCDevice::ID::Motor );
|
||||
configureAction(_consoleButton, _consoleAction, BCDevice::ID::Console );
|
||||
configureAction(_batteryButton, _batteryAction, BCDevice::ID::Battery );
|
||||
configureAction(_pimpButton, _pimpAction, BCDevice::ID::Pimp );
|
||||
//configureAction(_pimpButton, _pimpAction, BCDevice::ID::Pimp );
|
||||
|
||||
/*
|
||||
bool m_isDarkMode = false;
|
||||
QString icon = m_isDarkMode ? "☀️" : "🌙";
|
||||
fitzeButton->setText(icon);
|
||||
|
||||
QString style = QString(
|
||||
"QPushButton {"
|
||||
" background-color: %1;"
|
||||
" border: 1px solid %2;"
|
||||
" border-radius: 6px;"
|
||||
" font-size: 12pt;"
|
||||
" padding: 0px;"
|
||||
"}"
|
||||
"QPushButton:hover {"
|
||||
" background-color: %3;"
|
||||
"}"
|
||||
).arg(m_isDarkMode ? "#2B2B2B" : "#FFFFFF")
|
||||
.arg(m_isDarkMode ? "#3F3F3F" : "#E1DFDD")
|
||||
.arg(m_isDarkMode ? "#3A3A3A" : "#F9F9F9");
|
||||
"QPushButton {"
|
||||
" background-color: %1;"
|
||||
" border: 1px solid %2;"
|
||||
" border-radius: 6px;"
|
||||
" font-size: 12pt;"
|
||||
" padding: 0px;"
|
||||
"}"
|
||||
"QPushButton:hover {"
|
||||
" background-color: %3;"
|
||||
"}"
|
||||
).arg(m_isDarkMode ? "#2B2B2B" : "#FFFFFF")
|
||||
.arg(m_isDarkMode ? "#3F3F3F" : "#E1DFDD")
|
||||
.arg(m_isDarkMode ? "#3A3A3A" : "#F9F9F9");
|
||||
|
||||
fitzeButton->setStyleSheet(style);
|
||||
|
||||
// besser: model::emit dataChanged
|
||||
// also: emit dataChanged(index, index, {Qt::DisplayRole, Qt::EditRole, ValueRole});
|
||||
*/
|
||||
// besser: model::emit dataChanged
|
||||
// also: emit dataChanged(index, index, {Qt::DisplayRole, Qt::EditRole, ValueRole});
|
||||
connect( _connectButton, &QToolButton::clicked, &_transmitter, &BCTransmitter::onToggleConnectionState );
|
||||
connect( _syncButton, &QToolButton::clicked, this, &BCMainWindow::onSyncDeviceView );
|
||||
connect( &_transmitter, &BCTransmitter::valueUpdated, this, &BCMainWindow::onValueUpdated );
|
||||
@@ -161,18 +152,19 @@ void BCMainWindow::initMainWindow()
|
||||
|
||||
connect(this, &BCMainWindow::requestValueUpdate, &_transmitter, &BCTransmitter::enqueueValue);
|
||||
connect(&_worker, &QThread::finished, &_transmitter, &QObject::deleteLater);
|
||||
connect( &_transmitter, &BCTransmitter::driverStateChanged, this, &BCMainWindow::onDriverStateChanged );
|
||||
|
||||
// transmitter starten
|
||||
_worker.start();
|
||||
|
||||
// die Daten des eBikes laden
|
||||
_dataManager.loadXmlBikeData(":/bikeinfo.xml"_L1);
|
||||
_consoleAction->trigger();
|
||||
|
||||
connect( &_transmitter, &BCTransmitter::driverStateChanged, this, &BCMainWindow::onDriverStateChanged );
|
||||
|
||||
//_consoleAction->trigger();
|
||||
_batteryAction->trigger();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void BCMainWindow::initStatusBar()
|
||||
{
|
||||
// __fix
|
||||
@@ -203,6 +195,17 @@ void BCMainWindow::initStatusBar()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Setzt den Headerlabel ( == die Device-Bezeichnung )
|
||||
* @param headerLabel Der headerLabel
|
||||
*/
|
||||
|
||||
void BCMainWindow::setHeaderLabel( const QString& headerText)
|
||||
{
|
||||
_headerLabel->setText( " BionxControl: " + headerText );
|
||||
}
|
||||
|
||||
|
||||
void BCMainWindow::autoConnect()
|
||||
{
|
||||
// __fix!
|
||||
|
||||
Reference in New Issue
Block a user