diff --git a/.qtcreator/BionxControl.pro.user.23a63a0 b/.qtcreator/BionxControl.pro.user.23a63a0
new file mode 100644
index 0000000..8ad83e6
--- /dev/null
+++ b/.qtcreator/BionxControl.pro.user.23a63a0
@@ -0,0 +1,226 @@
+
+
+
+
+
+ EnvironmentId
+ {23a63a0b-7f48-446f-a5f4-d5b7f38a6fae}
+
+
+ ProjectExplorer.Project.ActiveTarget
+ 0
+
+
+ ProjectExplorer.Project.EditorSettings
+
+ true
+ true
+ true
+
+ Cpp
+
+ CppGlobal
+
+
+
+ QmlJS
+
+ QmlJSGlobal
+
+
+ 2
+ UTF-8
+ false
+ 4
+ false
+ 0
+ 80
+ true
+ true
+ 1
+ 0
+ false
+ true
+ false
+ 2
+ true
+ true
+ 0
+ 8
+ true
+ false
+ 1
+ false
+ true
+ true
+ *.md, *.MD, Makefile
+ false
+ true
+ true
+
+
+
+ ProjectExplorer.Project.PluginSettings
+
+
+ true
+ false
+ true
+ true
+ true
+ true
+
+ false
+
+
+ 0
+ true
+
+ true
+ true
+ Builtin.DefaultTidyAndClazy
+ 8
+ true
+
+
+
+ true
+
+ 0
+
+
+
+ ProjectExplorer.Project.Target.0
+
+ Desktop
+ true
+ Desktop
+ Desktop
+ {fad1a024-ac8c-47cf-928f-6229932645bf}
+ 0
+ 0
+ 0
+
+ 0
+ ./build/%{Asciify:%{Kit:FileSystemName}-%{BuildConfig:Name}}
+ build/Desktop-Debug
+
+
+ true
+ QtProjectManager.QMakeBuildStep
+ false
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+
+ 2
+ Build
+ Build
+ ProjectExplorer.BuildSteps.Build
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+ clean
+
+ 1
+ Clean
+ Clean
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ false
+
+ Debug
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 0
+ 0
+
+
+ 0
+ Deploy
+ Deploy
+ ProjectExplorer.BuildSteps.Deploy
+
+ 1
+
+ false
+ ProjectExplorer.DefaultDeployConfiguration
+
+ 1
+
+ true
+ true
+ 0
+ true
+
+
+ 2
+
+ false
+ -e cpu-cycles --call-graph dwarf,4096 -F 250
+
+ Qt4ProjectManager.Qt4RunConfiguration:
+ /mnt/c/projects/BionxControl/BionxControl.pro
+ false
+
+ true
+ true
+ true
+ %{RunConfig:Executable:Path}
+
+ 1
+ 2
+
+ 1
+
+
+ 0
+ Deploy
+ Deploy
+ ProjectExplorer.BuildSteps.Deploy
+
+ 1
+
+ false
+ ProjectExplorer.DefaultDeployConfiguration
+
+ 1
+
+ true
+ true
+ 0
+ true
+
+
+ 2
+
+ false
+ -e cpu-cycles --call-graph dwarf,4096 -F 250
+
+ Qt4ProjectManager.Qt4RunConfiguration:
+ /mnt/c/projects/BionxControl/BionxControl.pro
+ false
+
+ true
+ true
+ true
+ %{RunConfig:Executable:Path}
+
+ 1
+
+
+
+ ProjectExplorer.Project.TargetCount
+ 1
+
+
+ Version
+ 22
+
+
diff --git a/.qtcreator/BionxControl.pro.user.628da39 b/.qtcreator/BionxControl.pro.user.628da39
new file mode 100644
index 0000000..a456c51
--- /dev/null
+++ b/.qtcreator/BionxControl.pro.user.628da39
@@ -0,0 +1,860 @@
+
+
+
+
+
+ EnvironmentId
+ {628da395-74db-4105-8489-c4b4db698d13}
+
+
+ ProjectExplorer.Project.ActiveTarget
+ 0
+
+
+ ProjectExplorer.Project.EditorSettings
+
+ true
+ true
+ true
+
+ Cpp
+
+ CppGlobal
+
+
+
+ QmlJS
+
+ QmlJSGlobal
+
+
+ 2
+ UTF-8
+ false
+ 4
+ false
+ 0
+ 80
+ true
+ true
+ 1
+ 0
+ false
+ true
+ false
+ 2
+ true
+ true
+ 0
+ 8
+ true
+ false
+ 1
+ true
+ true
+ true
+ *.md, *.MD, Makefile
+ false
+ true
+ true
+
+
+
+ ProjectExplorer.Project.PluginSettings
+
+
+ true
+ false
+ true
+ true
+ true
+ true
+
+ false
+
+
+ 0
+ true
+
+ true
+ true
+ Builtin.DefaultTidyAndClazy
+ 8
+ true
+
+
+
+ true
+
+ 0
+
+
+
+ ProjectExplorer.Project.Target.0
+
+ Desktop
+ true
+ Desktop Qt 6.11.0 MinGW 64-bit
+ Desktop Qt 6.11.0 MinGW 64-bit
+ qt.qt6.6110.win64_mingw_kit
+ 0
+ 0
+ 0
+
+ 0
+ C:\projects\BionxControl\build\Desktop_Qt_6_11_0_MinGW_64_bit-Debug
+ C:/projects/BionxControl/build/Desktop_Qt_6_11_0_MinGW_64_bit-Debug
+
+
+ true
+ QtProjectManager.QMakeBuildStep
+ false
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+
+ 2
+ Build
+ Build
+ ProjectExplorer.BuildSteps.Build
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+ clean
+
+ 1
+ Clean
+ Clean
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ false
+
+ Debug
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 0
+ 0
+
+
+ 0
+ Deploy
+ Deploy
+ ProjectExplorer.BuildSteps.Deploy
+
+ 1
+
+ false
+ ProjectExplorer.DefaultDeployConfiguration
+
+ 1
+
+ true
+ true
+ 0
+ true
+
+
+
+ 2
+
+ false
+ -e cpu-cycles --call-graph "dwarf,4096" -F 250
+
+ Qt4ProjectManager.Qt4RunConfiguration:
+ C:/projects/BionxControl/BionxControl.pro
+ false
+
+ true
+ true
+ true
+ %{RunConfig:Executable:Path}
+
+ 1
+ 2
+
+ 1
+
+
+ 0
+ Deploy
+ Deploy
+ ProjectExplorer.BuildSteps.Deploy
+
+ 1
+
+ false
+ ProjectExplorer.DefaultDeployConfiguration
+
+ 1
+
+ true
+ true
+ 0
+ true
+
+
+
+ 2
+
+ false
+ -e cpu-cycles --call-graph "dwarf,4096" -F 250
+
+ Qt4ProjectManager.Qt4RunConfiguration:
+ C:/projects/BionxControl/BionxControl.pro
+ false
+
+ true
+ true
+ true
+ %{RunConfig:Executable:Path}
+
+ 1
+
+
+
+ ProjectExplorer.Project.Target.1
+
+ Desktop
+ true
+ Desktop Qt 6.11.0 MSVC2022 64bit
+ Desktop Qt 6.11.0 MSVC2022 64bit
+ qt.qt6.6110.win64_msvc2022_64_kit
+ 0
+ 0
+ 0
+
+ 0
+ C:\projects\BionxControl\build\Desktop_Qt_6_11_0_MSVC2022_64bit-Debug
+ C:/projects/BionxControl/build/Desktop_Qt_6_11_0_MSVC2022_64bit-Debug
+
+
+ true
+ QtProjectManager.QMakeBuildStep
+ false
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+
+ 2
+ Build
+ Build
+ ProjectExplorer.BuildSteps.Build
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+ clean
+
+ 1
+ Clean
+ Clean
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ false
+
+ Debug
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 0
+ 0
+
+
+ 0
+ Deploy
+ Deploy
+ ProjectExplorer.BuildSteps.Deploy
+
+ 1
+
+ false
+ ProjectExplorer.DefaultDeployConfiguration
+
+ 1
+
+ true
+ true
+ 0
+ true
+
+
+
+ 2
+
+ false
+ -e cpu-cycles --call-graph "dwarf,4096" -F 250
+
+ Qt4ProjectManager.Qt4RunConfiguration:
+ C:/projects/BionxControl/BionxControl.pro
+ false
+
+ true
+ true
+ true
+ %{RunConfig:Executable:Path}
+
+ 1
+ 2
+
+ 1
+
+
+ 0
+ Deploy
+ Deploy
+ ProjectExplorer.BuildSteps.Deploy
+
+ 1
+
+ false
+ ProjectExplorer.DefaultDeployConfiguration
+
+ 1
+
+ true
+ true
+ 0
+ true
+
+
+
+ 2
+
+ false
+ -e cpu-cycles --call-graph "dwarf,4096" -F 250
+
+ Qt4ProjectManager.Qt4RunConfiguration:
+ C:/projects/BionxControl/BionxControl.pro
+ false
+
+ true
+ true
+ true
+ %{RunConfig:Executable:Path}
+
+ 1
+
+
+
+ ProjectExplorer.Project.Target.2
+
+ Desktop
+ true
+ Desktop Qt 6.11.0 llvm-mingw 64-bit
+ Desktop Qt 6.11.0 llvm-mingw 64-bit
+ qt.qt6.6110.win64_llvm_mingw_kit
+ 0
+ 0
+ 0
+
+ 0
+ C:\projects\BionxControl\build\Desktop_Qt_6_11_0_llvm_mingw_64_bit-Debug
+ C:/projects/BionxControl/build/Desktop_Qt_6_11_0_llvm_mingw_64_bit-Debug
+
+
+ true
+ QtProjectManager.QMakeBuildStep
+ false
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+
+ 2
+ Build
+ Build
+ ProjectExplorer.BuildSteps.Build
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+ clean
+
+ 1
+ Clean
+ Clean
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ false
+
+ Debug
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 0
+ 0
+
+
+ 0
+ Deploy
+ Deploy
+ ProjectExplorer.BuildSteps.Deploy
+
+ 1
+
+ false
+ ProjectExplorer.DefaultDeployConfiguration
+
+ 1
+
+ true
+ true
+ 0
+ true
+
+
+
+ 2
+
+ false
+ -e cpu-cycles --call-graph "dwarf,4096" -F 250
+
+ ProjectExplorer.CustomExecutableRunConfiguration
+
+ false
+
+ true
+ true
+ %{RunConfig:Executable:Path}
+
+ 1
+ 2
+
+ 1
+
+
+ 0
+ Deploy
+ Deploy
+ ProjectExplorer.BuildSteps.Deploy
+
+ 1
+
+ false
+ ProjectExplorer.DefaultDeployConfiguration
+
+ 1
+
+ true
+ true
+ 0
+ true
+
+
+
+ 2
+
+ false
+ -e cpu-cycles --call-graph "dwarf,4096" -F 250
+
+ ProjectExplorer.CustomExecutableRunConfiguration
+
+ false
+
+ true
+ true
+ %{RunConfig:Executable:Path}
+
+ 1
+
+
+
+ ProjectExplorer.Project.Target.3
+
+ Desktop
+ true
+ Desktop Qt 6.10.1 MinGW 64-bit
+ Desktop Qt 6.10.1 MinGW 64-bit
+ qt.qt6.6101.win64_mingw_kit
+ 0
+ 0
+ 0
+
+ 0
+ C:\projects\BionxControl\build\Desktop_Qt_6_10_1_MinGW_64_bit-Debug
+ C:/projects/BionxControl/build/Desktop_Qt_6_10_1_MinGW_64_bit-Debug
+
+
+ true
+ QtProjectManager.QMakeBuildStep
+ false
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+
+ 2
+ Build
+ Build
+ ProjectExplorer.BuildSteps.Build
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+ clean
+
+ 1
+ Clean
+ Clean
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ false
+
+ Debug
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 0
+ 0
+
+
+ 0
+ Deploy
+ Deploy
+ ProjectExplorer.BuildSteps.Deploy
+
+ 1
+
+ false
+ ProjectExplorer.DefaultDeployConfiguration
+
+ 1
+
+ true
+ true
+ 0
+ true
+
+
+ 2
+
+ false
+ -e cpu-cycles --call-graph "dwarf,4096" -F 250
+
+ Qt4ProjectManager.Qt4RunConfiguration:
+ C:/projects/BionxControl/BionxControl.pro
+ false
+
+ true
+ true
+ true
+ %{RunConfig:Executable:Path}
+
+ 1
+ 2
+
+ 1
+
+
+ 0
+ Deploy
+ Deploy
+ ProjectExplorer.BuildSteps.Deploy
+
+ 1
+
+ false
+ ProjectExplorer.DefaultDeployConfiguration
+
+ 1
+
+ true
+ true
+ 0
+ true
+
+
+ 2
+
+ false
+ -e cpu-cycles --call-graph "dwarf,4096" -F 250
+
+ Qt4ProjectManager.Qt4RunConfiguration:
+ C:/projects/BionxControl/BionxControl.pro
+ false
+
+ true
+ true
+ true
+ %{RunConfig:Executable:Path}
+
+ 1
+
+
+
+ ProjectExplorer.Project.Target.4
+
+ Desktop
+ true
+ Desktop Qt 6.10.1 llvm-mingw 64-bit
+ Desktop Qt 6.10.1 llvm-mingw 64-bit
+ qt.qt6.6101.win64_llvm_mingw_kit
+ 0
+ 0
+ 0
+
+ 0
+ C:\projects\BionxControl\build\Desktop_Qt_6_10_1_llvm_mingw_64_bit-Debug
+ C:/projects/BionxControl/build/Desktop_Qt_6_10_1_llvm_mingw_64_bit-Debug
+
+
+ true
+ QtProjectManager.QMakeBuildStep
+ false
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+
+ 2
+ Build
+ Build
+ ProjectExplorer.BuildSteps.Build
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+ clean
+
+ 1
+ Clean
+ Clean
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ false
+
+ Debug
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 0
+ 0
+
+
+ 0
+ Deploy
+ Deploy
+ ProjectExplorer.BuildSteps.Deploy
+
+ 1
+
+ false
+ ProjectExplorer.DefaultDeployConfiguration
+
+ 1
+
+ true
+ true
+ 0
+ true
+
+
+ 2
+
+ false
+ -e cpu-cycles --call-graph "dwarf,4096" -F 250
+
+ Qt4ProjectManager.Qt4RunConfiguration:
+ C:/projects/BionxControl/BionxControl.pro
+ false
+
+ true
+ true
+ true
+ %{RunConfig:Executable:Path}
+
+ 1
+ 2
+
+ 1
+
+
+ 0
+ Deploy
+ Deploy
+ ProjectExplorer.BuildSteps.Deploy
+
+ 1
+
+ false
+ ProjectExplorer.DefaultDeployConfiguration
+
+ 1
+
+ true
+ true
+ 0
+ true
+
+
+ 2
+
+ false
+ -e cpu-cycles --call-graph "dwarf,4096" -F 250
+
+ Qt4ProjectManager.Qt4RunConfiguration:
+ C:/projects/BionxControl/BionxControl.pro
+ false
+
+ true
+ true
+ true
+ %{RunConfig:Executable:Path}
+
+ 1
+
+
+
+ ProjectExplorer.Project.Target.5
+
+ Desktop
+ true
+ Desktop Qt 6.10.1 MSVC2022 64bit
+ Desktop Qt 6.10.1 MSVC2022 64bit
+ qt.qt6.6101.win64_msvc2022_64_kit
+ 0
+ 0
+ 0
+
+ 0
+ C:\projects\BionxControl\build\Desktop_Qt_6_10_1_MSVC2022_64bit-Debug
+ C:/projects/BionxControl/build/Desktop_Qt_6_10_1_MSVC2022_64bit-Debug
+
+
+ true
+ QtProjectManager.QMakeBuildStep
+ false
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+
+ 2
+ Build
+ Build
+ ProjectExplorer.BuildSteps.Build
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+ clean
+
+ 1
+ Clean
+ Clean
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ false
+
+ Debug
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 0
+ 0
+
+
+ 0
+ Deploy
+ Deploy
+ ProjectExplorer.BuildSteps.Deploy
+
+ 1
+
+ false
+ ProjectExplorer.DefaultDeployConfiguration
+
+ 1
+
+ true
+ true
+ 0
+ true
+
+
+ 2
+
+ false
+ -e cpu-cycles --call-graph "dwarf,4096" -F 250
+
+ Qt4ProjectManager.Qt4RunConfiguration:
+ C:/projects/BionxControl/BionxControl.pro
+ false
+
+ true
+ true
+ true
+ %{RunConfig:Executable:Path}
+
+ 1
+ 2
+
+ 1
+
+
+ 0
+ Deploy
+ Deploy
+ ProjectExplorer.BuildSteps.Deploy
+
+ 1
+
+ false
+ ProjectExplorer.DefaultDeployConfiguration
+
+ 1
+
+ true
+ true
+ 0
+ true
+
+
+ 2
+
+ false
+ -e cpu-cycles --call-graph "dwarf,4096" -F 250
+
+ Qt4ProjectManager.Qt4RunConfiguration:
+ C:/projects/BionxControl/BionxControl.pro
+ false
+
+ true
+ true
+ true
+ %{RunConfig:Executable:Path}
+
+ 1
+
+
+
+ ProjectExplorer.Project.TargetCount
+ 6
+
+
+ Version
+ 22
+
+
diff --git a/BionxControl.vcxproj b/BionxControl.vcxproj
index a31ff55..2878469 100644
--- a/BionxControl.vcxproj
+++ b/BionxControl.vcxproj
@@ -38,11 +38,11 @@
- 6.11.0_msvc2022_64
+ msvc2022x64Qt6
core;gui;widgets;svg
- 6.11.0_msvc2022_64
+ msvc2022x64Qt6
core;gui;widgets;svg
@@ -83,7 +83,8 @@
MaxSpeed
_WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;NDEBUG;QT_NO_DEBUG;%(PreprocessorDefinitions)
false
-
+
+
MultiThreadedDLL
true
true
diff --git a/bcdeviceview.cpp b/bcdeviceview.cpp
index 26e5b69..4383afa 100644
--- a/bcdeviceview.cpp
+++ b/bcdeviceview.cpp
@@ -27,7 +27,7 @@
(at your option) any later version.
@see https://github.com/bikemike/bionx-bikeinfo
- ***************************************************************************/
+ **************************************************************************/
#include
@@ -47,6 +47,13 @@ BCDeviceView::BCDeviceView(QWidget *parent)
_itemDelegate = new BCValueDelegate( _valueModel.getValueList(), this);
setItemDelegateForColumn( 1, _itemDelegate );
setStyleSheet("padding-left: 8px;");
+
+ // Verbindet den einfachen Klick direkt mit dem Editier-Befehl
+ connect(this, &QAbstractItemView::clicked, this, [this](const QModelIndex &index) {
+ edit(index);
+ });
+
+ setEditTriggers(QAbstractItemView::NoEditTriggers);
}
diff --git a/bcmainwindow.ui b/bcmainwindow.ui
index 1884bc4..d8ae6fe 100644
--- a/bcmainwindow.ui
+++ b/bcmainwindow.ui
@@ -245,7 +245,7 @@
0
- 2
+ 1
@@ -257,6 +257,9 @@
0
+
+ QAbstractItemView::EditTrigger::NoEditTriggers
+
false
@@ -286,6 +289,9 @@
0
+
+ QAbstractItemView::EditTrigger::NoEditTriggers
+
false
@@ -315,6 +321,12 @@
0
+
+ QAbstractItemView::EditTrigger::NoEditTriggers
+
+
+ QAbstractItemView::SelectionBehavior::SelectRows
+
false
diff --git a/bctoggleswitch.cpp b/bctoggleswitch.cpp
index 2178046..fc611d0 100644
--- a/bctoggleswitch.cpp
+++ b/bctoggleswitch.cpp
@@ -44,7 +44,9 @@ BCToggleSwitch::BCToggleSwitch(QWidget *parent)
{
setCheckable(true);
setCursor(Qt::PointingHandCursor);
- setFixedSize(44, 22); // Standardgröße
+
+ // Widget ist jetzt mit setGeometry / Layouts skalierbar
+ setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
// Animation initialisieren
m_animation = new QPropertyAnimation(this, "position", this);
@@ -77,30 +79,38 @@ QSize BCToggleSwitch::sizeHint() const
return QSize(44, 22);
}
+QSize BCToggleSwitch::minimumSizeHint() const
+{
+ return QSize(30, 16);
+}
+
void BCToggleSwitch::paintEvent(QPaintEvent *)
{
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing);
- // Option A: Nutze die Standard-Hintergrundfarbe des aktuellen Qt-Themes
- p.fillRect(rect(), palette().window());
+ QRect ownRect = rect();
+
+ // Standard-Hintergrundfarbe des aktuellen Qt-Themes
+ p.fillRect(ownRect, palette().window());
// Auf deaktivierten Zustand prüfen und die statische Methode aufrufen
if (!isEnabled()) {
- paintToggleIndicator(&p, rect(), isChecked(), m_position, palette());
+ paintToggleIndicator(&p, ownRect, isChecked(), m_position, palette());
return;
}
- // --- Farben ---
- // Tipp: In einem echten Projekt diese Farben als const statics
- // oder aus der QPalette laden.
- QColor offBorderColor = QColor(0x8D8D8D);
- QColor offKnobColor = QColor(0x5D5D5D);
- QColor onColor = QColor(0x0078D4); // Fluent Blue
- QColor white = Qt::white;
+ // --- Farben aus der aktuellen Palette ---
+ QColor onColor = palette().color(QPalette::Highlight);
+ QColor offBorderColor = palette().color(QPalette::Mid);
+ QColor offKnobColor = palette().color(QPalette::Dark);
+ QColor knobOnColor = palette().color(QPalette::HighlightedText);
- QRectF rect = this->rect();
- qreal radius = rect.height() / 2.0;
+ // Proportionale Werte aus der Widget-Höhe ableiten
+ qreal h = ownRect.height();
+ qreal radius = h / 2.0;
+ qreal penW = qMax(1.0, h / 14.0); // Strichstärke skaliert mit
+ qreal padding = qMax(2.0, h * 0.14); // Innenabstand skaliert mit
// 1. Hintergrund (Track) zeichnen
p.setPen(Qt::NoPen);
@@ -109,7 +119,7 @@ void BCToggleSwitch::paintEvent(QPaintEvent *)
{
// AN-Zustand: Hintergrund gefüllt
p.setBrush(onColor);
- p.drawRoundedRect(rect, radius, radius);
+ p.drawRoundedRect(ownRect, radius, radius);
}
else
{
@@ -118,28 +128,29 @@ void BCToggleSwitch::paintEvent(QPaintEvent *)
// Hover-Status prüfen
if (underMouse())
- p.setPen(QPen(offBorderColor.darker(120), 1.5));
+ p.setPen(QPen(offBorderColor.darker(120), penW));
else
- p.setPen(QPen(offBorderColor, 1.5));
+ p.setPen(QPen(offBorderColor, penW));
// Rechteck etwas verkleinern, damit der Rahmen nicht abgeschnitten wird
- p.drawRoundedRect(rect.adjusted(1, 1, -1, -1), radius - 1, radius - 1);
+ qreal inset = penW / 2.0;
+ p.drawRoundedRect(QRectF(ownRect).adjusted(inset, inset, -inset, -inset),
+ radius - inset, radius - inset);
}
// 2. Knopf (Thumb) zeichnen
- qreal padding = 3.0;
- qreal knobDiameter = rect.height() - (2 * padding);
+ qreal knobDiameter = h - (2 * padding);
// Interpolation der Position
qreal startX = padding;
- qreal endX = rect.width() - knobDiameter - padding;
+ qreal endX = ownRect.width() - knobDiameter - padding;
qreal currentX = startX + (m_position * (endX - startX));
QRectF knobRect(currentX, padding, knobDiameter, knobDiameter);
if (isChecked() || m_position > 0.5f)
{
- p.setBrush(white);
+ p.setBrush(knobOnColor);
}
else
{
@@ -155,18 +166,17 @@ void BCToggleSwitch::paintEvent(QPaintEvent *)
void BCToggleSwitch::paintToggleIndicator(QPainter* p, const QRect& rect, bool isChecked, float position, const QPalette& palette)
{
- // --- Farben für den deaktivierten Zustand ---
- QColor disabledBorderColor = palette.color(QPalette::Disabled, QPalette::Window);
- if (!disabledBorderColor.isValid() || disabledBorderColor == Qt::black) {
- disabledBorderColor = QColor(0xCCCCCC); // Fallback auf ein neutrales Hellgrau
- }
-
- QColor disabledKnobColor = QColor(0xAAAAAA);
- QColor disabledOnColor = QColor(0x99C2E3); // Entsättigtes, blasses "Fluent Blue"
- QColor white = QColor(0xF0F0F0); // Leicht abgedunkeltes Weiß
+ // --- Farben für den deaktivierten Zustand aus der Palette ---
+ QColor disabledBorderColor = palette.color(QPalette::Disabled, QPalette::Mid);
+ QColor disabledKnobColor = palette.color(QPalette::Disabled, QPalette::Dark);
+ QColor disabledOnColor = palette.color(QPalette::Disabled, QPalette::Highlight);
+ QColor disabledKnobOnColor = palette.color(QPalette::Disabled, QPalette::HighlightedText);
QRectF r(rect);
- qreal radius = r.height() / 2.0;
+ qreal h = r.height();
+ qreal radius = h / 2.0;
+ qreal penW = qMax(1.0, h / 14.0);
+ qreal padding = qMax(2.0, h * 0.14);
// 1. Hintergrund (Track) zeichnen
p->setPen(Qt::NoPen);
@@ -181,18 +191,18 @@ void BCToggleSwitch::paintToggleIndicator(QPainter* p, const QRect& rect, bool i
{
// AUS-Zustand (deaktiviert)
p->setBrush(Qt::NoBrush);
- p->setPen(QPen(disabledBorderColor, 1.5));
- // Rechteck etwas verkleinern, damit der Rahmen nicht abgeschnitten wird
- p->drawRoundedRect(r.adjusted(1, 1, -1, -1), radius - 1, radius - 1);
+ p->setPen(QPen(disabledBorderColor, penW));
+ qreal inset = penW / 2.0;
+ p->drawRoundedRect(r.adjusted(inset, inset, -inset, -inset),
+ radius - inset, radius - inset);
}
// 2. Knopf (Thumb) zeichnen
- qreal padding = 3.0;
- qreal knobDiameter = r.height() - (2 * padding);
+ qreal knobDiameter = h - (2 * padding);
// X- und Y-Offsets des übergebenen Rects berücksichtigen!
- qreal startX = r.x() + padding;
- qreal endX = r.x() + r.width() - knobDiameter - padding;
+ qreal startX = r.x() + padding;
+ qreal endX = r.x() + r.width() - knobDiameter - padding;
qreal currentX = startX + (position * (endX - startX));
QRectF knobRect(currentX, r.y() + padding, knobDiameter, knobDiameter);
@@ -201,7 +211,7 @@ void BCToggleSwitch::paintToggleIndicator(QPainter* p, const QRect& rect, bool i
if (isChecked || position > 0.5f)
{
- p->setBrush(white);
+ p->setBrush(disabledKnobOnColor);
}
else
{
@@ -209,8 +219,8 @@ void BCToggleSwitch::paintToggleIndicator(QPainter* p, const QRect& rect, bool i
}
p->drawEllipse(knobRect);
-
}
+
void BCToggleSwitch::enterEvent(QEnterEvent *event)
{
update(); // Für Hover-Effekt neu zeichnen
diff --git a/bctoggleswitch.h b/bctoggleswitch.h
index 38cab0d..0f694e6 100644
--- a/bctoggleswitch.h
+++ b/bctoggleswitch.h
@@ -21,6 +21,7 @@ public:
void setPosition(float pos);
QSize sizeHint() const override;
+ QSize minimumSizeHint() const override;
// Statische Methode zum Zeichnen des passiven/deaktivierten Zustands
static void paintToggleIndicator(QPainter* p, const QRect& rect, bool isChecked, float position, const QPalette& palette);
diff --git a/bcvaluedelegate.cpp b/bcvaluedelegate.cpp
index 1687119..678faa8 100644
--- a/bcvaluedelegate.cpp
+++ b/bcvaluedelegate.cpp
@@ -67,8 +67,18 @@ QWidget* BCValueDelegate::createEditor(QWidget *parent, const QStyleOptionViewIt
if( bcValue.isBoolean() )
{
- auto* toogleSwitch = new BCToggleSwitch{parent};
- return toogleSwitch;
+ auto* toggleSwitch = new BCToggleSwitch{parent};
+ toggleSwitch->setChecked(bcValue.isChecked() );
+
+ // Signal für sofortige Updates
+ connect(toggleSwitch, &BCToggleSwitch::toggled, this, [this, toggleSwitch](bool checked)
+ {
+ qDebug() << "--- toggled: " << checked;
+ // Commit data sofort bei Änderung
+ emit const_cast(this)->commitData(toggleSwitch);
+ });
+
+ return toggleSwitch;
}
BCValue::ValueRange params;
@@ -86,6 +96,7 @@ QWidget* BCValueDelegate::createEditor(QWidget *parent, const QStyleOptionViewIt
emit const_cast(this)->commitData(valueSlider);
});
+ /*
// Signal für sofortige Updates
connect(valueSlider, &BCValueSlider::valueCommited, this, [this, valueSlider](int newValue)
{
@@ -93,6 +104,7 @@ QWidget* BCValueDelegate::createEditor(QWidget *parent, const QStyleOptionViewIt
// Commit data sofort bei Änderung
emit const_cast(this)->commitData(valueSlider);
});
+ */
return valueSlider;
}
@@ -112,34 +124,44 @@ void BCValueDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionVi
Q_UNUSED(index)
const BCValue& bcValue = *(_valueList[ index.row()].get());
- QRect editorRect;
+ QRect editorRect = bcValue.isBoolean() ? adjustEditorRect(option.rect, 0, 6, -130, -6) : adjustEditorRect(option.rect, 0, 0, 8, 0);
+
+ /*
if( !bcValue.isBoolean())
{
- editorRect = clipToSliderRect( option.rect );
+ editorRect = adjustEditorRect( option.rect,0,0,8,0 );
}
else
{
- editorRect = option.rect.adjusted(option.rect.width() - cTextBlockOffset,4,0,0);
+ editorRect = adjustEditorRect(option.rect, 0, 6, -130, -6);
}
+ */
+
editor->setGeometry(editorRect);
}
void BCValueDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex& index) const
{
- if( index.column() == 1)
- {
- // Daten vom Editor zurück ins Model speichern (Beim Schließen)
- BCValueSlider* slider = qobject_cast(editor);
- if (slider)
- {
- int value = slider->value();
- model->setData(index, value, Qt::EditRole);
- }
+ if (index.column() != 1)
return;
- }
- QStyledItemDelegate::setModelData(editor, model, index);
+ QVariant reValue;
+
+ const BCValue& bcValue = *(_valueList[index.row()].get());
+ if (bcValue.isBoolean())
+ {
+ if (BCToggleSwitch* toggleSswitch = qobject_cast(editor))
+ reValue = toggleSswitch->isChecked() ? 1 : 0;
+ }
+ else
+ {
+ if (BCValueSlider* slider = qobject_cast(editor))
+ reValue = slider->value();
+ }
+
+ model->setData(index, reValue, Qt::EditRole);
+ return;
}
@@ -152,7 +174,7 @@ void BCValueDelegate::paint(QPainter *painter, const QStyleOptionViewItem& optio
QStyleOptionViewItem opt = option;
initStyleOption(&opt, index);
- const BCValue& bcValue = *(_valueList[ index.row()].get());
+ const BCValue& bcValue = *(_valueList[ index.row()].get());
if( bcValue.isBoolean() )
{
@@ -208,56 +230,29 @@ void BCValueDelegate::paintBooleanValue( QPainter *painter, const QStyleOptionVi
text, // Der zu zeichnende String
textRole // Die ermittelte Farb-Rolle
);
- return;
-/*
- // 1. Standard-Optionen für die Zelle holen
- QStyleOptionViewItem opt = option;
- //initStyleOption(&opt, index);
-
- // 2. Den originalen Text ('0' oder '1') ausblenden, damit er nicht hinter der Checkbox steht
- opt.text = "";
-
- // Zuerst den Hintergrund der Zelle zeichnen (wichtig für Selektions-Farben etc.)
- // Wir übergeben nullptr für das Widget, da QStyledItemDelegate ohnehin unabhängig zeichnet
- QApplication::style()->drawControl(QStyle::CE_ItemViewItem, &opt, painter, nullptr);
-
-
- // 4. Optionen für die Checkbox konfigurieren
- QStyleOptionButton cbOpt;
- cbOpt.state = isChecked ? QStyle::State_On : QStyle::State_Off;
- cbOpt.state |= QStyle::State_Enabled; // Damit die Checkbox nicht ausgegraut/deaktiviert aussieht
-
- // 5. Größe und Position berechnen (Zentriert in der Zelle)
- // Wir fragen das System nach der korrekten Größe für eine Checkbox
- QRect checkRect = QApplication::style()->subElementRect(QStyle::SE_CheckBoxIndicator, &cbOpt, nullptr);
-
- // Checkbox exakt in der Mitte des zur Verfügung stehenden Zellenbereichs platzieren
- cbOpt.rect = QStyle::alignedRect(option.direction, Qt::AlignLeft| Qt::AlignVCenter, checkRect.size(), option.rect);
-
- // 6. Die native Checkbox zeichnen
- QApplication::style()->drawPrimitive(QStyle::PE_IndicatorCheckBox, &cbOpt, painter, nullptr);
-*/
+
}
-QRect BCValueDelegate::clipToSliderRect( const QRect& rect, int buttonOffset ) const
+QRect BCValueDelegate::adjustEditorRect( const QRect& rect, int x1, int y1, int x2, int y2 ) const
{
return rect.adjusted
(
- rect.width() - cTextBlockOffset, // Von rechts: cTextBlockOffset (==130) px (Breite der Progress Bar)
- 0, // Oben: kein Offset
- -buttonOffset, // Rechts: 8px Padding
- 0 // Unten: kein Offset
+ rect.width() - cTextBlockOffset + x1, // Von rechts: cTextBlockOffset (==130) px (Breite der Progress Bar)
+ y1, // Oben: kein Offset
+ x2, // Rechts: 8px Padding
+ y2 // Unten: kein Offset
);
}
+// option.rect.adjusted(option.rect.width() - cTextBlockOffset,4,0,0);
+
/**
* @brief Zeichnet der 'Sliderindicator', also den Anteil des Gesamtwerts als Fortschrittsbalken
*/
void BCValueDelegate::paintPlainSliderIndicator(QPainter* painter, const QRect& rect, double ratio )const
{
- QRect sliderRect = clipToSliderRect( rect, 35 );
- //BCValueSliderOld::paintSliderIndicator(painter, sliderRect, ratio );
+ QRect sliderRect = adjustEditorRect( rect, 0, 0, -35, 0 );
// Kleinen Slider-Indikator zeichnen
painter->save();
painter->setRenderHint(QPainter::Antialiasing);
diff --git a/bcvaluedelegate.h b/bcvaluedelegate.h
index 2776de3..367492b 100644
--- a/bcvaluedelegate.h
+++ b/bcvaluedelegate.h
@@ -73,7 +73,7 @@ protected:
void paintPlainSliderIndicator(QPainter* painter, const QRect& rect, double ratio ) const;
void paintBooleanValue( QPainter *painter, const QStyleOptionViewItem& option, const BCValue& bcValue ) const;
- QRect clipToSliderRect(const QRect& rect, int buttonOffset = 0) const;
+ QRect adjustEditorRect(const QRect& rect, int x1, int y1, int x2, int y2) const;
const BCValueList& _valueList;
BCDeviceView* _view{};
diff --git a/bcvaluemodel.cpp b/bcvaluemodel.cpp
index d984700..821f432 100644
--- a/bcvaluemodel.cpp
+++ b/bcvaluemodel.cpp
@@ -160,7 +160,7 @@ QVariant BCValueModel::data(const QModelIndex& index, int role) const
Qt::ItemFlags BCValueModel::flags(const QModelIndex& index) const
{
- Qt::ItemFlags flag = Qt::NoItemFlags|Qt::ItemNeverHasChildren;
+ Qt::ItemFlags flag = Qt::NoItemFlags | Qt::ItemNeverHasChildren;// | Qt::ItemIsSelectable;
// die label spalte lässt sich nicht editieren
if (!index.isValid() || index.column() == 0 )
return flag;
@@ -190,7 +190,7 @@ bool BCValueModel::setData(const QModelIndex& index, const QVariant& variant, in
{
if( variant.toInt() == 42)
{
- //emit makeSimonHappy();
+ emit makeSimonHappy();
}
// QUARK!
value->setRawValue( variant.toInt() );