Fixed actions.
This commit is contained in:
@@ -74,16 +74,25 @@ void BCMainWindow::initData()
|
|||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
auto configureAction = [&]( QToolButton* button, QAction* action, BCDevice::ID deviceID )
|
auto configureAction = [&]( QToolButton* button, QAction* action, BCDevice::ID deviceID, const QString& panelTitle="" )
|
||||||
{
|
{
|
||||||
|
// Action an den Button binden
|
||||||
button->setDefaultAction( action);
|
button->setDefaultAction( action);
|
||||||
|
// old school, not used
|
||||||
connect( action, &QAction::triggered, this, &BCMainWindow::onActionButtonTriggered );
|
connect( action, &QAction::triggered, this, &BCMainWindow::onActionButtonTriggered );
|
||||||
connect( action, &QAction::toggled, this, &BCMainWindow::onActionButtonToggled );
|
connect( action, &QAction::toggled, this, &BCMainWindow::onActionButtonToggled );
|
||||||
// new way
|
// new way: die DeviceID muss aber explizit vom Lambda eingefanden werden.
|
||||||
connect( action, &QAction::triggered, this, [&]
|
connect( action, &QAction::triggered, this, [this,deviceID]()
|
||||||
{
|
{
|
||||||
onShowDevicePanel( deviceID );
|
onShowDevicePanel( deviceID );
|
||||||
});
|
});
|
||||||
|
// den Panels ihren title geben
|
||||||
|
if( _devicePanels.contains(deviceID) )
|
||||||
|
{
|
||||||
|
_devicePanels[deviceID]->setHeaderText( panelTitle );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Wir wollen die Devices den Views zuordnen können
|
// Wir wollen die Devices den Views zuordnen können
|
||||||
@@ -92,10 +101,10 @@ void BCMainWindow::initData()
|
|||||||
_devicePanels[BCDevice::ID::Motor] = _motorPanel;
|
_devicePanels[BCDevice::ID::Motor] = _motorPanel;
|
||||||
|
|
||||||
// Die actions an die Buttons binden
|
// Die actions an die Buttons binden
|
||||||
configureAction(_motorButton, _motorAction, BCDevice::ID::Motor );
|
configureAction(_motorButton, _motorAction, BCDevice::ID::Motor, "Motor Settings"_L1 );
|
||||||
configureAction(_consoleButton, _consoleAction, BCDevice::ID::Console );
|
configureAction(_consoleButton, _consoleAction, BCDevice::ID::Console, "Console Settings"_L1 );
|
||||||
configureAction(_batteryButton, _batteryAction, BCDevice::ID::Battery );
|
configureAction(_batteryButton, _batteryAction, BCDevice::ID::Battery, "Battery Settings"_L1 );
|
||||||
configureAction(_pimpButton, _pimpAction, BCDevice::ID::Pimp );
|
configureAction(_pimpButton, _pimpAction, BCDevice::ID::Pimp, "Pimp my Ride"_L1 );
|
||||||
|
|
||||||
|
|
||||||
// Die Daten und auch die Datenmodelle für die Views werden
|
// Die Daten und auch die Datenmodelle für die Views werden
|
||||||
@@ -162,20 +171,25 @@ void BCMainWindow::onShowDevicePanel( BCDevice::ID deviceID )
|
|||||||
qDebug() << " --- onShowDevicePanel:" << deviceID;
|
qDebug() << " --- onShowDevicePanel:" << deviceID;
|
||||||
if( _devicePanels.contains( deviceID ) )
|
if( _devicePanels.contains( deviceID ) )
|
||||||
{
|
{
|
||||||
//const BCValueList& newValueList = _dataManager.getCurrentValueList();
|
BCDevicePanel* nxtPanel = _devicePanels[deviceID];
|
||||||
//_devicePanels[deviceID]->setValueList( newValueList );
|
if( nxtPanel != _currentPanel )
|
||||||
|
{
|
||||||
|
_stackedWidget->setCurrentWidget( nxtPanel );
|
||||||
|
_currentPanel = nxtPanel;
|
||||||
|
// knopf auch abschalten?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BCMainWindow::onActionButtonTriggered( bool checked)
|
void BCMainWindow::onActionButtonTriggered( bool checked)
|
||||||
{
|
{
|
||||||
qDebug() << " --- onActionButtonTriggered: " << checked;
|
//qDebug() << " --- onActionButtonTriggered: " << checked;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BCMainWindow::onActionButtonToggled( bool checked)
|
void BCMainWindow::onActionButtonToggled( bool checked)
|
||||||
{
|
{
|
||||||
qDebug() << " --- onActionButtonToggled: " << checked;
|
//qDebug() << " --- onActionButtonToggled: " << checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ protected:
|
|||||||
|
|
||||||
using BCDevicePanels = QMap<BCDevice::ID, BCDevicePanel*>;
|
using BCDevicePanels = QMap<BCDevice::ID, BCDevicePanel*>;
|
||||||
BCDevicePanels _devicePanels;
|
BCDevicePanels _devicePanels;
|
||||||
|
BCDevicePanel* _currentPanel{};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -131,7 +131,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QStackedWidget" name="_controlWidget">
|
<widget class="QStackedWidget" name="_stackedWidget">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>200</width>
|
<width>200</width>
|
||||||
@@ -139,7 +139,7 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>3</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="BCDevicePanel" name="_consolePanel"/>
|
<widget class="BCDevicePanel" name="_consolePanel"/>
|
||||||
<widget class="BCDevicePanel" name="_motorPanel"/>
|
<widget class="BCDevicePanel" name="_motorPanel"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user