Browse Source

Merge pull request 'add-probes' (#2) from add-probes into develop

Reviewed-on: #2
develop
miladS 1 year ago
parent
commit
208abc7138
  1. 38
      logic/include/model/ButtonHelper.h
  2. 16
      logic/include/model/Console.h
  3. 2
      logic/include/model/DataSender.h
  4. 17
      logic/include/model/DatabaseManager.h
  5. 10
      logic/include/model/FunctionCodes.h
  6. 5
      logic/include/network/UdpDataSender.h
  7. 45
      logic/include/viewModel/MainViewModel.h
  8. 11
      logic/include/viewModel/utils/Property.h
  9. 7
      logic/logic.pro
  10. 67
      logic/src/model/DatabaseManager.cpp
  11. 36
      logic/src/network/UdpDataSender.cpp
  12. 65
      logic/src/viewModel/MainViewModel.cpp
  13. 6
      test/TestDataSender.h
  14. 2
      test/test.pro
  15. 75
      ui/emulator/elements/ProbeButton.qml
  16. 46
      ui/emulator/items/DropDownWithDisable.qml
  17. 87
      ui/emulator/items/TopLeftTop.qml
  18. 2
      ui/ui.pro
  19. 1
      ui/ui.qrc

38
logic/include/model/ButtonHelper.h

@ -24,9 +24,9 @@ public: \
Q_SIGNAL void SMALL_NAME ## LedChanged(char value)
/*************************************************************************************************/
#define PUSH_BUTTON_NO_LED(CAPITAL_NAME, SMALL_NAME, FUNC_CODE) \
#define PUSH_BUTTON_PROBE_SLOT(CAPITAL_NAME, SMALL_NAME, SLOT_NUMBER) \
private: \
PushButton _ ## SMALL_NAME{FUNC_CODE}; \
PushButton _ ## SMALL_NAME{SLOT_NUMBER}; \
void init ## CAPITAL_NAME() \
{ \
connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData); \
@ -37,19 +37,20 @@ public: \
void press ## CAPITAL_NAME() \
{ \
auto arr = _ ## SMALL_NAME.press(); \
_dataSender->send(arr); \
arr[5] = static_cast<char>(this->selectedProbe ## SLOT_NUMBER); \
_dataSender->sendProbeSlots(arr); \
emit changeProbeSelectionEnable ## SLOT_NUMBER(); \
} \
void release ## CAPITAL_NAME() \
{ \
auto arr = _ ## SMALL_NAME.release(); \
_dataSender->send(arr); \
} \
Q_SIGNAL void SMALL_NAME ## LedChanged(char value)
Q_SIGNAL void SMALL_NAME ## LedChanged(char value); \
Q_SIGNAL void changeProbeSelectionEnable ## SLOT_NUMBER()
/*************************************************************************************************/
#define ROTARY_BUTTON(CAPITAL_NAME, SMALL_NAME, FUNC_CODE, LED_FUNC_CODE) \
#define PUSH_BUTTON_NO_LED(CAPITAL_NAME, SMALL_NAME, FUNC_CODE) \
private: \
RotaryButton _ ## SMALL_NAME{FUNC_CODE, LED_FUNC_CODE}; \
PushButton _ ## SMALL_NAME {FUNC_CODE}; \
void init ## CAPITAL_NAME() \
{ \
connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData); \
@ -57,17 +58,22 @@ private: \
SIGNAL(SMALL_NAME ## LedChanged(char))); \
} \
public: \
void rotate ## CAPITAL_NAME(int value) \
void press ## CAPITAL_NAME() \
{ \
auto arr = _ ## SMALL_NAME.rotate(value); \
auto arr = _ ## SMALL_NAME.press(); \
_dataSender->send(arr); \
} \
void release ## CAPITAL_NAME() \
{ \
auto arr = _ ## SMALL_NAME.release(); \
_dataSender->send(arr); \
} \
Q_SIGNAL void SMALL_NAME ## LedChanged(char value)
/*************************************************************************************************/
#define ROTARY_BUTTON_NO_LED(CAPITAL_NAME, SMALL_NAME, FUNC_CODE) \
#define ROTARY_BUTTON(CAPITAL_NAME, SMALL_NAME, FUNC_CODE, LED_FUNC_CODE) \
private: \
RotaryButton _ ## SMALL_NAME{FUNC_CODE}; \
RotaryButton _ ## SMALL_NAME{FUNC_CODE, LED_FUNC_CODE}; \
void init ## CAPITAL_NAME() \
{ \
connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData); \
@ -83,9 +89,9 @@ public: \
Q_SIGNAL void SMALL_NAME ## LedChanged(char value)
/*************************************************************************************************/
#define DROP_DOWN(CAPITAL_NAME, SMALL_NAME, FUNC_CODE, LED_FUNC_CODE) \
#define ROTARY_BUTTON_NO_LED(CAPITAL_NAME, SMALL_NAME, FUNC_CODE) \
private: \
DropDown _ ## SMALL_NAME{FUNC_CODE, LED_FUNC_CODE}; \
RotaryButton _ ## SMALL_NAME{FUNC_CODE}; \
void init ## CAPITAL_NAME() \
{ \
connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData); \
@ -93,9 +99,9 @@ private: \
SIGNAL(SMALL_NAME ## LedChanged(char))); \
} \
public: \
void select ## CAPITAL_NAME(int value) \
void rotate ## CAPITAL_NAME(int value) \
{ \
auto arr = _ ## SMALL_NAME.select(value); \
auto arr = _ ## SMALL_NAME.rotate(value); \
_dataSender->send(arr); \
} \
Q_SIGNAL void SMALL_NAME ## LedChanged(char value)

16
logic/include/model/Console.h

@ -14,7 +14,6 @@
#include "FunctionCodes.h"
#include "PushButton.h"
#include "RotaryButton.h"
#include "DropDown.h"
#include "DataSender.h"
#include "Logger.h"
@ -23,11 +22,11 @@ class Console : public QObject
{
Q_OBJECT
//Slotes
DROP_DOWN(Slot1, slot1, SLOT1_FC, static_cast<char>(SLOT1_LED_FC));
DROP_DOWN(Slot2, slot2, SLOT2_FC, static_cast<char>(SLOT2_LED_FC));
DROP_DOWN(Slot3, slot3, SLOT3_FC, static_cast<char>(SLOT3_LED_FC));
DROP_DOWN(Slot4, slot4, SLOT4_FC, static_cast<char>(SLOT4_LED_FC));
//Probe slotes
PUSH_BUTTON_PROBE_SLOT(Slot1, slot1, 1);
PUSH_BUTTON_PROBE_SLOT(Slot2, slot2, 2);
PUSH_BUTTON_PROBE_SLOT(Slot3, slot3, 3);
PUSH_BUTTON_PROBE_SLOT(Slot4, slot4, 4);
//PushButton with LED
PUSH_BUTTON(Dual, dual, DUAL_FC, static_cast<char>(DUAL_LED_FC));
@ -118,6 +117,11 @@ private:
public:
Console();
int selectedProbe1 = 0;
int selectedProbe2 = 0;
int selectedProbe3 = 0;
int selectedProbe4 = 0;
void injectDataSender(DataSender* sender);
void injectLogger(Logger* logger);
void hasValidDataFormat(const QByteArray& data);

2
logic/include/model/DataSender.h

@ -10,12 +10,14 @@ class DataSender : public QObject
public:
virtual void send(const QByteArray& data) = 0;
virtual void sendProbeSlots(const QByteArray& data) = 0;
virtual ~DataSender()
{
}
signals:
void dataReady(const QByteArray& data);
void probeSlotsDataReady(const QByteArray& data);
};
#endif //DATASENDER_H

17
logic/include/model/DatabaseManager.h

@ -1,13 +1,20 @@
#ifndef DatabaseManager_H
#define DatabaseManager_H
#ifndef DATABASEMANAGER_H
#define DATABASEMANAGER_H
#include <QSqlDatabase>
#include <QDebug>
class DatabaseManager
{
private:
char _functionCode;
QSqlDatabase _db;
public:
DatabaseManager(char functionCode);
DatabaseManager(const QString& databasePath);
~DatabaseManager();
QList<QVariant> getProbeIds();
QList<QVariant> getProbeNames();
};
#endif //DatabaseManager_H
#endif //DATABASEMANAGER_H

10
logic/include/model/FunctionCodes.h

@ -1,16 +1,6 @@
#ifndef FUNCTIONCODES_H
#define FUNCTIONCODES_H
//Probes and LED of probes
#define SLOT1_FC 0x01
#define SLOT2_FC 0x09
#define SLOT3_FC 0x19
#define SLOT4_FC 0x18
#define SLOT1_LED_FC 0x20
#define SLOT2_LED_FC 0x27
#define SLOT3_LED_FC 0x30
#define SLOT4_LED_FC 0x48
//Buttons
#define DUAL_FC 0x1D
#define QUAD_FC 0x1C

5
logic/include/network/UdpDataSender.h

@ -10,18 +10,21 @@ class UdpDataSender : public DataSender
Q_OBJECT
private:
QUdpSocket* _socket;
QUdpSocket* _socketDashboard;
QUdpSocket* _socketProbeSlots;
public:
UdpDataSender();
~UdpDataSender() override;
void send(const QByteArray& data) override;
void sendProbeSlots(const QByteArray& data) override;
//uncrustify off
public slots:
//uncrustify on
void read();
void readProbeSlots();
};
#endif //UDPDATASENDER_H

45
logic/include/viewModel/MainViewModel.h

@ -20,11 +20,23 @@ class MainViewModel : public QtMvvm::ViewModel
MVVM_PROPERTY(int, stepInc, 1)
MVVM_PROPERTY(int, stepDec, -1)
//Slots
DROP_DOWN_PROPERTY(slot1, Slot1, LED_OFF)
DROP_DOWN_PROPERTY(slot2, Slot2, LED_OFF)
DROP_DOWN_PROPERTY(slot3, Slot3, LED_OFF)
DROP_DOWN_PROPERTY(slot4, Slot4, LED_OFF)
//Probes
BUTTON_LED_PROPERTY(slot1, Slot1, false, LED_COLOR_GREEN)
BUTTON_LED_PROPERTY(slot2, Slot2, false, LED_COLOR_WHITE)
BUTTON_LED_PROPERTY(slot3, Slot3, false, LED_COLOR_WHITE)
BUTTON_LED_PROPERTY(slot4, Slot4, false, LED_COLOR_WHITE)
MVVM_PROPERTY(QList<QVariant>, probeList, {})
MVVM_PROPERTY(int, currentSelectedProbe1, 0)
MVVM_PROPERTY(int, currentSelectedProbe2, 0)
MVVM_PROPERTY(int, currentSelectedProbe3, 0)
MVVM_PROPERTY(int, currentSelectedProbe4, 0)
MVVM_PROPERTY(bool, isProbeSelectionEnable1, false)
MVVM_PROPERTY(bool, isProbeSelectionEnable2, true)
MVVM_PROPERTY(bool, isProbeSelectionEnable3, true)
MVVM_PROPERTY(bool, isProbeSelectionEnable4, true)
//Top Left
BUTTON_LED_PROPERTY(patient, Patient, false, LED_OFF)
@ -141,23 +153,11 @@ class MainViewModel : public QtMvvm::ViewModel
JOYSTICK_PROPERTY(js4, Js4)
JOYSTICK_PROPERTY(js5, Js5)
//Probes
//BUTTON_LED_PROPERTY(probe1, Probe1, false, LED_OFF)
//BUTTON_LED_PROPERTY(probe2, Probe2, false, LED_OFF)
//BUTTON_LED_PROPERTY(probe3, Probe3, false, LED_OFF)
//BUTTON_LED_PROPERTY(probe4, Probe4, false, LED_OFF)
MVVM_PROPERTY(QList<QVariant>, probeList, QList<QVariant>({"Pouya", "Mamad"}))
MVVM_PROPERTY(int, currentSelectedProbe1, 0)
MVVM_PROPERTY(int, currentSelectedProbe2, 0)
MVVM_PROPERTY(int, currentSelectedProbe3, 0)
MVVM_PROPERTY(int, currentSelectedProbe4, 0)
public:
Q_INVOKABLE explicit MainViewModel(QObject* parent = nullptr);
private:
const QString _dbPath = "database/ProbeProperties.db";
signals:
void ledChanged(char value);
@ -165,10 +165,10 @@ signals:
//uncrustify off
public slots:
//Probes
// LED_SLOT(slot1)
// LED_SLOT(slot2)
// LED_SLOT(slot3)
// LED_SLOT(slot4)
LED_SLOT(slot1)
LED_SLOT(slot2)
LED_SLOT(slot3)
LED_SLOT(slot4)
//Top Left
LED_SLOT(patient)
@ -235,7 +235,6 @@ public slots:
LED_SLOT(focusCenter)
LED_SLOT(depthBottom)
LED_SLOT(focusBottom)
//uncrustify on
};

11
logic/include/viewModel/utils/Property.h

@ -77,16 +77,5 @@
NAME ## Led(static_cast<int>(value)); \
} \
/**************************************************************************************************/
#define DROP_DOWN_PROPERTY(NAME, CAP_NAME, LED_DEF_VAL) \
MVVM_PROPERTY_CUSTOM(bool, NAME, false) \
void NAME ## Handle() { \
if(NAME()) \
{ \
panel->select ## CAP_NAME('stepDec()'); \
} \
} \
//uncrustify on
#endif //PROPERTY_H

7
logic/logic.pro

@ -1,6 +1,7 @@
TEMPLATE = lib
QT += mvvmcore network
QT += mvvmcore network sql
# Creating a static library is typically more efficient. You can still create a shared library if you want to
CONFIG += c++14 static
@ -9,10 +10,10 @@ TARGET = logic
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += $$files(src/*.cpp, true) \
src/model/DropDown.cpp
HEADERS += $$files(include/*.h, true) \
include/model/DropDown.h
INCLUDEPATH += $$PWD/include/

67
logic/src/model/DatabaseManager.cpp

@ -1,6 +1,69 @@
#include "model/DatabaseManager.h"
DatabaseManager::DatabaseManager(char functionCode)
#include <QDebug>
#include <QSqlQuery>
#include <QSqlError>
DatabaseManager::DatabaseManager(const QString& databasePath)
{
_db = QSqlDatabase::addDatabase("QSQLITE");
_db.setDatabaseName(databasePath);
if(!_db.open())
{
qDebug() << "Error: " << _db.lastError().text();
}
}
/*************************************************************************************************/
DatabaseManager::~DatabaseManager()
{
if(_db.isOpen())
{
_functionCode = functionCode;
_db.close();
}
}
/*************************************************************************************************/
QList<QVariant> DatabaseManager::getProbeIds()
{
QList<QVariant> globalIds;
QSqlQuery query;
if(query.exec("SELECT globalId FROM Probe"))
{
while(query.next())
{
QString globalId = query.value(0).toString();
globalIds.append(QVariant(globalId));
}
}
else
{
qDebug() << "Error executing query: " << query.lastError().text();
}
return globalIds;
}
/*************************************************************************************************/
QList<QVariant> DatabaseManager::getProbeNames()
{
QList<QVariant> names;
QSqlQuery query;
if(query.exec("SELECT name FROM Probe"))
{
while(query.next())
{
QString name = query.value(0).toString();
names.append(QVariant(name));
}
}
else
{
qDebug() << "Error executing query: " << query.lastError().text();
}
return names;
}

36
logic/src/network/UdpDataSender.cpp

@ -4,31 +4,51 @@
void UdpDataSender::send(const QByteArray& data)
{
_socket->writeDatagram(data, QHostAddress::LocalHost, 5446);
_socketDashboard->writeDatagram(data, QHostAddress::LocalHost, 5446);
}
/*************************************************************************************************/
void UdpDataSender::sendProbeSlots(const QByteArray& data)
{
_socketProbeSlots->writeDatagram(data, QHostAddress::LocalHost, 5450);
}
/*************************************************************************************************/
void UdpDataSender::read()
{
char data[DATAGRAM_SIZE];
int cnt = _socket->readDatagram(data, DATAGRAM_SIZE);
int cnt = _socketDashboard->readDatagram(data, DATAGRAM_SIZE);
QByteArray a(data, cnt);
emit dataReady(a);
}
/*************************************************************************************************/
UdpDataSender::UdpDataSender()
void UdpDataSender::readProbeSlots()
{
_socket = new QUdpSocket();
char data[DATAGRAM_SIZE];
int cnt = _socketProbeSlots->readDatagram(data, DATAGRAM_SIZE);
QByteArray a(data, cnt);
emit probeSlotsDataReady(a);
}
_socket->bind(QHostAddress::Any, 5445);
/*************************************************************************************************/
UdpDataSender::UdpDataSender()
{
_socketDashboard = new QUdpSocket();
_socketDashboard->bind(QHostAddress::Any, 5445);
connect(_socketDashboard, SIGNAL(readyRead()), this, SLOT(read()));
connect(_socket, SIGNAL(readyRead()), this, SLOT(read()));
_socketProbeSlots = new QUdpSocket();
_socketProbeSlots->bind(QHostAddress::Any, 5449);
connect(_socketProbeSlots, SIGNAL(readyRead()), this, SLOT(readProbeSlots()));
}
/*************************************************************************************************/
UdpDataSender::~UdpDataSender()
{
_socket->close();
delete _socket;
_socketDashboard->close();
delete _socketDashboard;
_socketProbeSlots->close();
delete _socketProbeSlots;
}

65
logic/src/viewModel/MainViewModel.cpp

@ -5,12 +5,13 @@
#include "model/Console.h"
#include "logger/ConsoleLogger.h"
#include "network/UdpDataSender.h"
#include "model/DatabaseManager.h"
#define US_HOME_PATH "US_HOME"
#define CONNECT_LED(NAME) \
connect(panel, SIGNAL(NAME ## LedChanged(char)), this, SLOT(NAME ## LedHandle(char)));
MainViewModel::MainViewModel(QObject* parent) :
ViewModel(parent)
MainViewModel::MainViewModel(QObject* parent) : ViewModel(parent)
{
panel = new Console;
auto network = new UdpDataSender;
@ -19,12 +20,64 @@ MainViewModel::MainViewModel(QObject* parent) :
panel->injectLogger(logger);
connect(network, &UdpDataSender::dataReady, panel, &Console::newData);
connect(network, &UdpDataSender::probeSlotsDataReady, panel, &Console::newData);
QString databasePath = QString("%1/%2").arg(qgetenv(US_HOME_PATH), _dbPath);
DatabaseManager manager(databasePath);
QList<QVariant> globalNames = manager.getProbeNames();
//probeList(QList<QVariant>({"prb A fromcpp", "prb B fromcpp"}));
probeList(QList<QVariant>(globalNames));
//Current Selected Probes
connect(this, &MainViewModel::currentSelectedProbe1Changed, [ = ]()
{
panel->selectedProbe1 = currentSelectedProbe1();
});
connect(this, &MainViewModel::currentSelectedProbe2Changed, [ = ]()
{
panel->selectedProbe2 = currentSelectedProbe2();
});
connect(this, &MainViewModel::currentSelectedProbe3Changed, [ = ]()
{
panel->selectedProbe3 = currentSelectedProbe3();
});
connect(this, &MainViewModel::currentSelectedProbe4Changed, [ = ]()
{
panel->selectedProbe4 = currentSelectedProbe4();
});
//Enable and disable changes in probe selection box
connect(panel, &Console::changeProbeSelectionEnable1, [ = ]()
{
this->isProbeSelectionEnable1(!this->isProbeSelectionEnable1());
this->slot1Led(this->isProbeSelectionEnable1() ? LED_COLOR_WHITE : LED_COLOR_GREEN);
});
connect(panel, &Console::changeProbeSelectionEnable2, [ = ]()
{
this->isProbeSelectionEnable2(!this->isProbeSelectionEnable2());
this->slot2Led(this->isProbeSelectionEnable2() ? LED_COLOR_WHITE : LED_COLOR_GREEN);
});
connect(panel, &Console::changeProbeSelectionEnable3, [ = ]()
{
this->isProbeSelectionEnable3(!this->isProbeSelectionEnable3());
this->slot3Led(this->isProbeSelectionEnable3() ? LED_COLOR_WHITE : LED_COLOR_GREEN);
});
connect(panel, &Console::changeProbeSelectionEnable4, [ = ]()
{
this->isProbeSelectionEnable4(!this->isProbeSelectionEnable4());
this->slot4Led(this->isProbeSelectionEnable4() ? LED_COLOR_WHITE : LED_COLOR_GREEN);
});
//connect(this, );
//Add Probes in 4 Slots
//CONNECT_LED(slot1)
//CONNECT_LED(slot2)
//CONNECT_LED(slot3)
//CONNECT_LED(slot4)
CONNECT_LED(slot1)
CONNECT_LED(slot2)
CONNECT_LED(slot3)
CONNECT_LED(slot4)
//Top Left
CONNECT_LED(patient)

6
test/TestDataSender.h

@ -7,11 +7,17 @@ class TestDataSender : public DataSender
{
public:
QByteArray consoleData;
QByteArray slotData;
void send(const QByteArray& data) override
{
consoleData = data;
}
void sendProbeSlots(const QByteArray& data) override
{
slotData = data;
}
};
#endif //TESTDATASENDER_H

2
test/test.pro

@ -1,5 +1,5 @@
QT += testlib
QT -= gui
QT -= gui mvvmcore network sql
CONFIG += qt console warn_on depend_includepath testcase
CONFIG -= app_bundle

75
ui/emulator/elements/ProbeButton.qml

@ -6,7 +6,6 @@ import "qrc:/theme"
import "qrc:/const"
import "qrc:/emulator/components"
import de.skycoder42.QtMvvm.Core 1.0
import de.skycoder42.QtMvvm.Quick 1.0
import com.example.consoleemulator 1.0
@ -14,6 +13,10 @@ import com.example.consoleemulator 1.0
Button {
id: button
width: Const.macroButton
height: Const.macroButton * 2
implicitWidth: width
implicitHeight: height
//=========================================
property var name
property var nameLed: name + "Led"
@ -30,9 +33,8 @@ Button {
viewProperty: "colorMode"
viewModelProperty: nameLed
}
//=========================================
//=========================================
property var image: ""
property var radius: Math.min(width / 2, height / 2)
property var timeToPress: 100
@ -45,41 +47,47 @@ Button {
signal pressed
signal released
implicitWidth: width
implicitHeight: height
onPressed: { button.down = true }
onReleased: { button.down = false }
onPressed: {
button.down = true
}
onReleased: {
button.down = false
}
function getColor() {
switch (colorMode) {
case(0): return Theme.current.none
case(1): return Theme.current.white
case(2): return Theme.current.green
case(3): return Theme.current.yellow
case (0):
return Theme.current.none
case (1):
return Theme.current.white
case (2):
return Theme.current.green
case (3):
return Theme.current.yellow
}
}
function getColorGlow() {
switch (colorMode) {
case(0): return Theme.current.noneGlow
case(1): return Theme.current.whiteGlow
case(2): return Theme.current.greenGlow
case(3): return Theme.current.yellowGlow
case (0):
return Theme.current.noneGlow
case (1):
return Theme.current.whiteGlow
case (2):
return Theme.current.greenGlow
case (3):
return Theme.current.yellowGlow
}
}
width: Const.macroButton
height: Const.macroButton*2
contentItem: Item {
id: content
anchors.fill: parent
z: 1
Item {
property var factor: button.state == "Pressed" ?
Const.imageScalePressed : Const.imageScale
property var factor: button.state
== "Pressed" ? Const.imageScalePressed : Const.imageScale
property var elevator: button.state == "Pressed" ? 3 : 0
anchors.horizontalCenter: parent.horizontalCenter
@ -164,13 +172,23 @@ Button {
RadialGradient {
anchors.fill: parent
gradient: Gradient {
GradientStop { position: 0.0; color: lightGlow }
GradientStop {
position: 0.5 * (backLight.width - backLightGlow.diffusion / backLightGlow.width)
position: 0.0
color: lightGlow
}
GradientStop { position: 0.5; color: "transparent" }
GradientStop { position: 1.0; color: "transparent" }
GradientStop {
position: 0.5 * (backLight.width - backLightGlow.diffusion
/ backLightGlow.width)
color: lightGlow
}
GradientStop {
position: 0.5
color: "transparent"
}
GradientStop {
position: 1.0
color: "transparent"
}
}
}
}
@ -224,8 +242,7 @@ Button {
anchors.fill: parent
layer.enabled: true
layer.effect:
OpacityMask {
layer.effect: OpacityMask {
maskSource: lightRing
}
@ -349,7 +366,8 @@ Button {
transitions: [
Transition {
from: ""; to: "Hovering"
from: ""
to: "Hovering"
NumberAnimation {
properties: "x"
duration: 500
@ -358,4 +376,3 @@ Button {
}
]
}

46
ui/emulator/items/DropDownWithDisable.qml

@ -0,0 +1,46 @@
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"
Item {
id: root
implicitWidth: width
implicitHeight: 25
property var isDisable: false
property var viewModelProperty
property var isProbeEnableProperty
property alias model: idComobBox.model
ComboBox {
id: idComobBox
visible: isDisable
model: probeList
width: parent.width
implicitWidth: width
implicitHeight: parent.height
MvvmBinding {
viewModel: mainView.viewModel
viewProperty: "currentIndex"
viewModelProperty: root.viewModelProperty
}
}
Text {
visible: !isDisable
text: idComobBox.currentText
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
}
MvvmBinding {
viewModel: mainView.viewModel
viewProperty: "isDisable"
viewModelProperty: isProbeEnableProperty
}
}

87
ui/emulator/items/TopLeftTop.qml

@ -11,77 +11,84 @@ import "qrc:/const"
import "qrc:/qtmvvm/views"
GridLayout {
x: 70
x: 20
y: 50
rowSpacing: 36
rowSpacing: 30
columns: 4
property var widthOfBtns: 130
property var probeList: []
Item {
Layout.fillWidth: true
implicitHeight: Const.macroButton * 2
ProbeButton {
name: "probe1"
anchors.centerIn: parent
implicitWidth: width * 1.25
name: "slot4"
image: "qrc:/icons/topLeft/probe.png"
}
}
Item {
Layout.fillWidth: true
implicitHeight: Const.macroButton * 2
ProbeButton {
name: "probe2"
anchors.centerIn: parent
implicitWidth: width * 1.25
name: "slot3"
image: "qrc:/icons/topLeft/probe.png"
}
}
Item {
Layout.fillWidth: true
implicitHeight: Const.macroButton * 2
ProbeButton {
name: "probe3"
anchors.centerIn: parent
implicitWidth: width * 1.25
name: "slot2"
image: "qrc:/icons/topLeft/probe.png"
}
}
Item {
Layout.fillWidth: true
implicitHeight: Const.macroButton * 2
ProbeButton {
name: "probe4"
anchors.centerIn: parent
implicitWidth: width * 1.25
name: "slot1"
image: "qrc:/icons/topLeft/probe.png"
}
property var widthOfBtns: 130
property var probeList: []
}
MvvmBinding {
viewModel: mainView.viewModel
viewProperty: "probeList"
viewModelProperty: "probeList"
}
ComboBox {
DropDownWithDisable {
viewModelProperty: "currentSelectedProbe4"
model: probeList
width: widthOfBtns
implicitWidth: width
implicitHeight: 25
MvvmBinding {
viewModel: mainView.viewModel
viewProperty: "currentIndex"
viewModelProperty: "currentSelectedProbe1"
isProbeEnableProperty: "isProbeSelectionEnable4"
}
}
ComboBox {
DropDownWithDisable {
viewModelProperty: "currentSelectedProbe3"
model: probeList
width: widthOfBtns
implicitWidth: width
implicitHeight: 25
MvvmBinding {
viewModel: mainView.viewModel
viewProperty: "currentIndex"
viewModelProperty: "currentSelectedProbe2"
isProbeEnableProperty: "isProbeSelectionEnable3"
}
}
ComboBox {
DropDownWithDisable {
viewModelProperty: "currentSelectedProbe2"
model: probeList
width: widthOfBtns
implicitWidth: width
implicitHeight: 25
MvvmBinding {
viewModel: mainView.viewModel
viewProperty: "currentIndex"
viewModelProperty: "currentSelectedProbe3"
}
isProbeEnableProperty: "isProbeSelectionEnable2"
}
ComboBox {
DropDownWithDisable {
viewModelProperty: "currentSelectedProbe1"
model: probeList
width: widthOfBtns
implicitWidth: width
implicitHeight: 25
MvvmBinding {
viewModel: mainView.viewModel
viewProperty: "currentIndex"
viewModelProperty: "currentSelectedProbe4"
}
isProbeEnableProperty: "isProbeSelectionEnable1"
}
}

2
ui/ui.pro

@ -1,6 +1,6 @@
TEMPLATE = app
QT += quick mvvmquick
QT += quick mvvmquick network sql
CONFIG += c++14
TARGET = ConsoleEmulator

1
ui/ui.qrc

@ -97,6 +97,7 @@
<file>emulator/items/Setting.qml</file>
<file>emulator/items/TopLeftTop.qml</file>
<file>emulator/elements/ProbeButton.qml</file>
<file>emulator/items/DropDownWithDisable.qml</file>
</qresource>
<qresource prefix="/qtmvvm/views">
<file>MainView.qml</file>

Loading…
Cancel
Save