Redesign UI, part I
This commit is contained in:
@@ -282,6 +282,9 @@ std::optional<BCDataValue> BCDataManager::makeDataValue( BCDevice::ID deviceID,
|
|||||||
|
|
||||||
static BCValueTypeMap s_bcDataTypes
|
static BCValueTypeMap s_bcDataTypes
|
||||||
{
|
{
|
||||||
|
{ "Byte", new BCValueTypeWord( "", 1.5625F) },
|
||||||
|
{ "Word", new BCValueTypeWord( "", 1.5625F) },
|
||||||
|
|
||||||
{ "Float", new BCValueTypeWord( "", 1.5625F) },
|
{ "Float", new BCValueTypeWord( "", 1.5625F) },
|
||||||
{ "Percent",new BCValueTypeWord( "%", 1.5625 ) },
|
{ "Percent",new BCValueTypeWord( "%", 1.5625 ) },
|
||||||
{ "KWh", new BCValueTypeWord( "kwh", 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<BCDataValue> newValue;
|
||||||
|
|
||||||
std::optional<quint64> IDVal = s_bcValueEnum.keyToValue64( params.ID.toLatin1().constData() );
|
std::optional<quint64> IDVal = s_bcValueEnum.keyToValue64( params.ID.toLatin1().constData() );
|
||||||
|
qDebug() << " --- should create: " << params.Label << ": " << params.UnitType;
|
||||||
if( IDVal.has_value() )
|
if( IDVal.has_value() )
|
||||||
{
|
{
|
||||||
|
|
||||||
if( s_bcDataTypes.contains( params.UnitType ) )
|
if( s_bcDataTypes.contains( params.UnitType ) )
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -338,10 +343,9 @@ std::optional<BCDataValue> BCDataManager::makeDataValue( BCDevice::ID deviceID,
|
|||||||
*/
|
*/
|
||||||
newValue->label = params.Label;
|
newValue->label = params.Label;
|
||||||
newValue->defaultValue = params.Default;
|
newValue->defaultValue = params.Default;
|
||||||
/*
|
|
||||||
|
|
||||||
//qDebug() << " --- created: " << params.Label;
|
qDebug() << " --- created: " << params.Label;
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,33 @@ QVariant BCDataModel::headerData(int section, Qt::Orientation orientation, int r
|
|||||||
|
|
||||||
QVariant BCDataModel::data(const QModelIndex& index, int role) const
|
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 row = index.row();
|
||||||
|
int col = index.column();
|
||||||
if (!index.isValid() || row >= _valueList.size())
|
if (!index.isValid() || row >= _valueList.size())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
@@ -98,7 +124,12 @@ QVariant BCDataModel::data(const QModelIndex& index, int role) const
|
|||||||
entry.rowInModel = row;
|
entry.rowInModel = row;
|
||||||
|
|
||||||
if (role == Qt::DisplayRole || role == Qt::EditRole)
|
if (role == Qt::DisplayRole || role == Qt::EditRole)
|
||||||
|
{
|
||||||
|
if( col == 0 )
|
||||||
|
return entry.label;
|
||||||
|
else if( col == 1 )
|
||||||
return entry.visibleValue;
|
return entry.visibleValue;
|
||||||
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,12 @@ BCMainWindow::BCMainWindow(QWidget *parent)
|
|||||||
_valueManager.loadXmlBikeData();
|
_valueManager.loadXmlBikeData();
|
||||||
auto model = _valueManager.getModel( BCDevice::ID::Console );
|
auto model = _valueManager.getModel( BCDevice::ID::Console );
|
||||||
if( model)
|
if( model)
|
||||||
|
{
|
||||||
_valueView->setModel( *model );
|
_valueView->setModel( *model );
|
||||||
|
_valueView->resizeColumnsToContents();
|
||||||
|
//_valueView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BCItemDelegate* _delegate = new BCItemDelegate( _valueView);
|
BCItemDelegate* _delegate = new BCItemDelegate( _valueView);
|
||||||
//_delegate = new AnimatedDelegate(_valueView );
|
//_delegate = new AnimatedDelegate(_valueView );
|
||||||
@@ -66,6 +71,7 @@ BCMainWindow::BCMainWindow(QWidget *parent)
|
|||||||
connect( _connectButton, &QPushButton::clicked, transmitter, &BCTransmitter::onToggleConnectionState );
|
connect( _connectButton, &QPushButton::clicked, transmitter, &BCTransmitter::onToggleConnectionState );
|
||||||
connect( _syncButton, &QPushButton::clicked, &_valueManager, &BCDataManager::onSyncFromDevice );
|
connect( _syncButton, &QPushButton::clicked, &_valueManager, &BCDataManager::onSyncFromDevice );
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BCMainWindow::~BCMainWindow()
|
BCMainWindow::~BCMainWindow()
|
||||||
|
|||||||
@@ -14,13 +14,17 @@
|
|||||||
<string>BCMainWindow</string>
|
<string>BCMainWindow</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="_centralwidget">
|
<widget class="QWidget" name="_centralwidget">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QSplitter" name="splitter">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Orientation::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<widget class="QFrame" name="_controlFrame">
|
<widget class="QFrame" name="_controlFrame">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::Shape::StyledPanel</enum>
|
<enum>QFrame::Shape::StyledPanel</enum>
|
||||||
</property>
|
</property>
|
||||||
@@ -43,8 +47,8 @@
|
|||||||
<widget class="QPushButton" name="_connectButton">
|
<widget class="QPushButton" name="_connectButton">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>20</x>
|
<x>10</x>
|
||||||
<y>140</y>
|
<y>180</y>
|
||||||
<width>171</width>
|
<width>171</width>
|
||||||
<height>51</height>
|
<height>51</height>
|
||||||
</rect>
|
</rect>
|
||||||
@@ -78,20 +82,9 @@
|
|||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</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>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
<widget class="QTableView" name="_valueView">
|
<widget class="QTableView" name="_valueView">
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::Shape::NoFrame</enum>
|
<enum>QFrame::Shape::NoFrame</enum>
|
||||||
@@ -102,51 +95,22 @@
|
|||||||
<property name="alternatingRowColors">
|
<property name="alternatingRowColors">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="showGrid">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="gridStyle">
|
||||||
|
<enum>Qt::PenStyle::NoPen</enum>
|
||||||
|
</property>
|
||||||
|
<attribute name="horizontalHeaderStretchLastSection">
|
||||||
|
<bool>true</bool>
|
||||||
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QStatusBar" name="_statusbar"/>
|
<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">
|
<action name="_actionPimp">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset>
|
<iconset>
|
||||||
|
|||||||
@@ -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>
|
|
||||||
@@ -13,6 +13,8 @@
|
|||||||
#include <QGraphicsDropShadowEffect>
|
#include <QGraphicsDropShadowEffect>
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
#include "sliderdelegate.h"
|
||||||
|
|
||||||
|
|
||||||
// Fluent Design Demo Widget
|
// Fluent Design Demo Widget
|
||||||
class FluentWidgetDemo : public QWidget {
|
class FluentWidgetDemo : public QWidget {
|
||||||
|
|||||||
@@ -26,7 +26,6 @@
|
|||||||
#include <QStyleOptionSlider>
|
#include <QStyleOptionSlider>
|
||||||
#include <QGraphicsDropShadowEffect>
|
#include <QGraphicsDropShadowEffect>
|
||||||
|
|
||||||
#include "sliderdelegate.h"
|
|
||||||
|
|
||||||
class TableViewDemo : public QWidget
|
class TableViewDemo : public QWidget
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user