Redesign UI, part I

This commit is contained in:
2025-12-24 15:43:50 +01:00
parent 19aa6518c2
commit 029e9d2909
7 changed files with 134 additions and 358 deletions

View File

@@ -282,6 +282,9 @@ std::optional<BCDataValue> BCDataManager::makeDataValue( BCDevice::ID deviceID,
static BCValueTypeMap s_bcDataTypes
{
{ "Byte", new BCValueTypeWord( "", 1.5625F) },
{ "Word", new BCValueTypeWord( "", 1.5625F) },
{ "Float", new BCValueTypeWord( "", 1.5625F) },
{ "Percent",new BCValueTypeWord( "%", 1.5625 ) },
{ "KWh", new BCValueTypeWord( "kwh", 1.5625 ) },
@@ -323,8 +326,10 @@ std::optional<BCDataValue> BCDataManager::makeDataValue( BCDevice::ID deviceID,
std::optional<BCDataValue> newValue;
std::optional<quint64> IDVal = s_bcValueEnum.keyToValue64( params.ID.toLatin1().constData() );
qDebug() << " --- should create: " << params.Label << ": " << params.UnitType;
if( IDVal.has_value() )
{
if( s_bcDataTypes.contains( params.UnitType ) )
{
@@ -338,10 +343,9 @@ std::optional<BCDataValue> BCDataManager::makeDataValue( BCDevice::ID deviceID,
*/
newValue->label = params.Label;
newValue->defaultValue = params.Default;
/*
//qDebug() << " --- created: " << params.Label;
*/
qDebug() << " --- created: " << params.Label;
}
}

View File

@@ -90,7 +90,33 @@ QVariant BCDataModel::headerData(int section, Qt::Orientation orientation, int r
QVariant BCDataModel::data(const QModelIndex& index, int role) const
{
/*
if (!index.isValid() || index.row() >= static_cast<int>(m_items.size()))
return QVariant();
const auto& item = m_items.at(index.row());
if (role == Qt::DisplayRole) {
switch (index.column()) {
case 0: return item.id;
case 1: return item.name;
case 2: {
// Hier nutzen wir QLocale für das Komma!
return QLocale(QLocale::German).toString(item.value, 'f', 2);
}
}
}
// Bonus: Rechtsbündig für Zahlen
if (role == Qt::TextAlignmentRole && (index.column() == 0 || index.column() == 2)) {
return Qt::AlignRight | Qt::AlignVCenter;
}
return QVariant();
*/
int row = index.row();
int col = index.column();
if (!index.isValid() || row >= _valueList.size())
return QVariant();
@@ -98,7 +124,12 @@ QVariant BCDataModel::data(const QModelIndex& index, int role) const
entry.rowInModel = row;
if (role == Qt::DisplayRole || role == Qt::EditRole)
return entry.visibleValue;
{
if( col == 0 )
return entry.label;
else if( col == 1 )
return entry.visibleValue;
}
return QVariant();
}

View File

@@ -43,7 +43,12 @@ BCMainWindow::BCMainWindow(QWidget *parent)
_valueManager.loadXmlBikeData();
auto model = _valueManager.getModel( BCDevice::ID::Console );
if( model)
{
_valueView->setModel( *model );
_valueView->resizeColumnsToContents();
//_valueView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
}
BCItemDelegate* _delegate = new BCItemDelegate( _valueView);
//_delegate = new AnimatedDelegate(_valueView );
@@ -66,6 +71,7 @@ BCMainWindow::BCMainWindow(QWidget *parent)
connect( _connectButton, &QPushButton::clicked, transmitter, &BCTransmitter::onToggleConnectionState );
connect( _syncButton, &QPushButton::clicked, &_valueManager, &BCDataManager::onSyncFromDevice );
}
BCMainWindow::~BCMainWindow()

View File

@@ -14,139 +14,103 @@
<string>BCMainWindow</string>
</property>
<widget class="QWidget" name="_centralwidget">
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<widget class="QFrame" name="_controlFrame">
<property name="frameShape">
<enum>QFrame::Shape::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Raised</enum>
</property>
<widget class="QPushButton" name="_syncButton">
<property name="geometry">
<rect>
<x>30</x>
<y>50</y>
<width>171</width>
<height>51</height>
</rect>
</property>
<property name="text">
<string>Sync</string>
</property>
</widget>
<widget class="QPushButton" name="_connectButton">
<property name="geometry">
<rect>
<x>20</x>
<y>140</y>
<width>171</width>
<height>51</height>
</rect>
</property>
<property name="text">
<string>Connect</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
<widget class="QToolButton" name="_motorlButton">
<property name="geometry">
<rect>
<x>70</x>
<y>240</y>
<width>71</width>
<height>71</height>
</rect>
</property>
<property name="text">
<string>...</string>
</property>
<property name="iconSize">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QFrame" name="_controlFrame">
<property name="minimumSize">
<size>
<width>64</width>
<height>64</height>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="autoRaise">
<property name="frameShape">
<enum>QFrame::Shape::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Raised</enum>
</property>
<widget class="QPushButton" name="_syncButton">
<property name="geometry">
<rect>
<x>30</x>
<y>50</y>
<width>171</width>
<height>51</height>
</rect>
</property>
<property name="text">
<string>Sync</string>
</property>
</widget>
<widget class="QPushButton" name="_connectButton">
<property name="geometry">
<rect>
<x>10</x>
<y>180</y>
<width>171</width>
<height>51</height>
</rect>
</property>
<property name="text">
<string>Connect</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
<widget class="QToolButton" name="_motorlButton">
<property name="geometry">
<rect>
<x>70</x>
<y>240</y>
<width>71</width>
<height>71</height>
</rect>
</property>
<property name="text">
<string>...</string>
</property>
<property name="iconSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</widget>
</item>
<item>
<widget class="QTableView" name="_valueView">
<property name="frameShape">
<enum>QFrame::Shape::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Plain</enum>
</property>
<property name="alternatingRowColors">
<bool>false</bool>
</property>
<property name="showGrid">
<bool>false</bool>
</property>
<property name="gridStyle">
<enum>Qt::PenStyle::NoPen</enum>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</property>
</attribute>
</widget>
<widget class="QToolButton" name="toolButton_2">
<property name="geometry">
<rect>
<x>50</x>
<y>320</y>
<width>22</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</widget>
<widget class="QTableView" name="_valueView">
<property name="frameShape">
<enum>QFrame::Shape::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Plain</enum>
</property>
<property name="alternatingRowColors">
<bool>false</bool>
</property>
</widget>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QStatusBar" name="_statusbar"/>
<widget class="QToolBar" name="toolBar">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>toolBar</string>
</property>
<property name="movable">
<bool>false</bool>
</property>
<property name="iconSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="floatable">
<bool>true</bool>
</property>
<attribute name="toolBarArea">
<enum>LeftToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="_actionMotor"/>
<addaction name="_actionBattery"/>
<addaction name="_actionConsole"/>
<addaction name="_actionConnect"/>
</widget>
<action name="_actionPimp">
<property name="icon">
<iconset>

View File

@@ -1,230 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BCMainWindow</class>
<widget class="QMainWindow" name="BCMainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>BCMainWindow</string>
</property>
<widget class="QWidget" name="_centralwidget">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<widget class="QFrame" name="_controlFrame">
<property name="frameShape">
<enum>QFrame::Shape::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Raised</enum>
</property>
<widget class="QPushButton" name="_syncButton">
<property name="geometry">
<rect>
<x>30</x>
<y>50</y>
<width>171</width>
<height>51</height>
</rect>
</property>
<property name="text">
<string>Sync</string>
</property>
</widget>
<widget class="QPushButton" name="_connectButton">
<property name="geometry">
<rect>
<x>10</x>
<y>180</y>
<width>171</width>
<height>51</height>
</rect>
</property>
<property name="text">
<string>Connect</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
<widget class="QToolButton" name="_motorlButton">
<property name="geometry">
<rect>
<x>70</x>
<y>240</y>
<width>71</width>
<height>71</height>
</rect>
</property>
<property name="text">
<string>...</string>
</property>
<property name="iconSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
<widget class="QToolButton" name="toolButton_2">
<property name="geometry">
<rect>
<x>50</x>
<y>320</y>
<width>22</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</widget>
<widget class="QTableView" name="_valueView">
<property name="frameShape">
<enum>QFrame::Shape::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Plain</enum>
</property>
<property name="alternatingRowColors">
<bool>false</bool>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QStatusBar" name="_statusbar"/>
<widget class="QToolBar" name="toolBar">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>toolBar</string>
</property>
<property name="movable">
<bool>false</bool>
</property>
<property name="iconSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="floatable">
<bool>true</bool>
</property>
<attribute name="toolBarArea">
<enum>LeftToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="_actionMotor"/>
<addaction name="_actionBattery"/>
<addaction name="_actionConsole"/>
<addaction name="_actionConnect"/>
</widget>
<action name="_actionPimp">
<property name="icon">
<iconset>
<normaloff>:restart.png</normaloff>:restart.png</iconset>
</property>
<property name="text">
<string>pimp</string>
</property>
<property name="toolTip">
<string>Pimp my Ride</string>
</property>
</action>
<action name="_actionMotor">
<property name="icon">
<iconset>
<normaloff>:bionx_motor.png</normaloff>:bionx_motor.png</iconset>
</property>
<property name="text">
<string>motor</string>
</property>
<property name="toolTip">
<string>Show motor settings</string>
</property>
</action>
<action name="_actionBattery">
<property name="icon">
<iconset>
<normaloff>:bionx_akku.png</normaloff>:bionx_akku.png</iconset>
</property>
<property name="text">
<string>battery</string>
</property>
<property name="toolTip">
<string>Show battery settings</string>
</property>
</action>
<action name="_actionConsole">
<property name="icon">
<iconset>
<normaloff>:bionx_console.png</normaloff>:bionx_console.png</iconset>
</property>
<property name="text">
<string>console</string>
</property>
<property name="toolTip">
<string>Show console settings</string>
</property>
</action>
<action name="_actionExit">
<property name="icon">
<iconset>
<normaloff>:exit.png</normaloff>:exit.png</iconset>
</property>
<property name="text">
<string>Exit</string>
</property>
<property name="toolTip">
<string>Exit</string>
</property>
</action>
<action name="_actionConnect">
<property name="icon">
<iconset resource="bionxcontrol.qrc">
<normaloff>:/connected.png</normaloff>:/connected.png</iconset>
</property>
<property name="text">
<string>connect</string>
</property>
<property name="toolTip">
<string>connect to bike</string>
</property>
<property name="menuRole">
<enum>QAction::MenuRole::TextHeuristicRole</enum>
</property>
</action>
</widget>
<resources>
<include location="bionxcontrol.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -13,6 +13,8 @@
#include <QGraphicsDropShadowEffect>
#include "mainwindow.h"
#include "sliderdelegate.h"
// Fluent Design Demo Widget
class FluentWidgetDemo : public QWidget {

View File

@@ -26,7 +26,6 @@
#include <QStyleOptionSlider>
#include <QGraphicsDropShadowEffect>
#include "sliderdelegate.h"
class TableViewDemo : public QWidget
{