From 06cf192488ee2ac5a0d259fcda59a3ac25fbbf51 Mon Sep 17 00:00:00 2001 From: pouya Date: Sat, 27 Jan 2024 17:54:46 +0330 Subject: [PATCH] Add probe selection dropDown menue --- logic/include/viewModel/MainViewModel.h | 3 +- ui/emulator/items/TopLeftTop.qml | 71 ++++++++++++++++++++++--- 2 files changed, 67 insertions(+), 7 deletions(-) diff --git a/logic/include/viewModel/MainViewModel.h b/logic/include/viewModel/MainViewModel.h index 7549d70..1cd073a 100644 --- a/logic/include/viewModel/MainViewModel.h +++ b/logic/include/viewModel/MainViewModel.h @@ -4,6 +4,7 @@ #include #include "utils/Property.h" #include "model/Console.h" +#include #define LED_OFF 0x00 #define LED_COLOR_WHITE 0x01 @@ -140,7 +141,7 @@ class MainViewModel : public QtMvvm::ViewModel //BUTTON_LED_PROPERTY(probe3, Probe3, false, LED_OFF) //BUTTON_LED_PROPERTY(probe4, Probe4, false, LED_OFF) - MVVM_PROPERTY(QList, probeList, QList()) + MVVM_PROPERTY(QList, probeList, QList({"Pouya", "Mamad"})) MVVM_PROPERTY(int, currentSelectedProbe1, 0) MVVM_PROPERTY(int, currentSelectedProbe2, 0) diff --git a/ui/emulator/items/TopLeftTop.qml b/ui/emulator/items/TopLeftTop.qml index 151e32e..34462ab 100644 --- a/ui/emulator/items/TopLeftTop.qml +++ b/ui/emulator/items/TopLeftTop.qml @@ -1,28 +1,87 @@ import QtQuick 2.0 import QtQuick.Layouts 1.13 +import QtQuick.Controls 2.12 +import de.skycoder42.QtMvvm.Core 1.0 +import de.skycoder42.QtMvvm.Quick 1.0 +import com.example.consoleemulator 1.0 import "qrc:/emulator/elements" import "qrc:/emulator/components" import "qrc:/const" +import "qrc:/qtmvvm/views" -RowLayout { +GridLayout { x: 70 y: 50 - spacing: 36 + rowSpacing: 36 + columns: 4 + ProbeButton { - name: "probe" + name: "probe1" image: "qrc:/icons/topLeft/probe.png" } ProbeButton { - name: "probe" + name: "probe2" image: "qrc:/icons/topLeft/probe.png" } ProbeButton { - name: "probe" + name: "probe3" image: "qrc:/icons/topLeft/probe.png" } ProbeButton { - name: "probe" + name: "probe4" image: "qrc:/icons/topLeft/probe.png" } + property var widthOfBtns: 130 + property var probeList: [] + + MvvmBinding { + viewModel: mainView.viewModel + viewProperty: "probeList" + viewModelProperty: "probeList" + } + ComboBox { + model: probeList + width: widthOfBtns + implicitWidth: width + implicitHeight: 25 + MvvmBinding { + viewModel: mainView.viewModel + viewProperty: "currentIndex" + viewModelProperty: "currentSelectedProbe1" + } + } + ComboBox { + model: probeList + width: widthOfBtns + implicitWidth: width + implicitHeight: 25 + MvvmBinding { + viewModel: mainView.viewModel + viewProperty: "currentIndex" + viewModelProperty: "currentSelectedProbe2" + } + } + ComboBox { + model: probeList + width: widthOfBtns + implicitWidth: width + implicitHeight: 25 + MvvmBinding { + viewModel: mainView.viewModel + viewProperty: "currentIndex" + viewModelProperty: "currentSelectedProbe3" + } + } + ComboBox { + model: probeList + width: widthOfBtns + implicitWidth: width + implicitHeight: 25 + MvvmBinding { + viewModel: mainView.viewModel + viewProperty: "currentIndex" + viewModelProperty: "currentSelectedProbe4" + } + } }