forked from Sepanta/console-emulator
Compare commits
23 Commits
Author | SHA1 | Date |
---|---|---|
|
15998c6b25 | 8 months ago |
|
ed46cbed6f | 9 months ago |
|
06228358f4 | 9 months ago |
|
2781bc5f13 | 10 months ago |
|
881a6e8986 | 12 months ago |
|
7c3de270ee | 12 months ago |
|
208abc7138 | 12 months ago |
|
a3a411d325 | 12 months ago |
|
ac8322f347 | 12 months ago |
|
28785c93fa | 1 year ago |
|
7a6190159b | 1 year ago |
|
e0849692f4 | 1 year ago |
|
da3dedef1c | 1 year ago |
|
9023678656 | 1 year ago |
|
f556b108f5 | 1 year ago |
|
55650dccbb | 1 year ago |
|
c3ceb47b41 | 1 year ago |
|
6a7cb62011 | 1 year ago |
|
a7de368ccc | 1 year ago |
|
06cf192488 | 1 year ago |
|
4d6254ff05 | 1 year ago |
|
ab9fcdd18b | 1 year ago |
|
091e380a82 | 2 years ago |
25 changed files with 1053 additions and 101 deletions
@ -0,0 +1,20 @@ |
|||
#ifndef DATABASEMANAGER_H |
|||
#define DATABASEMANAGER_H |
|||
|
|||
#include <QSqlDatabase> |
|||
#include <QDebug> |
|||
|
|||
class DatabaseManager |
|||
{ |
|||
private: |
|||
QSqlDatabase _db; |
|||
|
|||
public: |
|||
DatabaseManager(const QString& databasePath); |
|||
~DatabaseManager(); |
|||
|
|||
QList<QVariant> getProbeIds(); |
|||
QList<QVariant> getProbeNames(); |
|||
}; |
|||
|
|||
#endif //DATABASEMANAGER_H
|
@ -0,0 +1,29 @@ |
|||
#ifndef DropDown_H |
|||
#define DropDown_H |
|||
|
|||
#define PROTOCOL_LENGTH 8 |
|||
#define MESSAGE_DIRECTION 0x00 |
|||
#define DropDownDataLength 0x02 |
|||
#define DropDownType 0x03 |
|||
#define ProbA 0x00 |
|||
#define ProbB 0x01 |
|||
#define ProbNC 0x02 |
|||
#define TIME_TAG 0x00 |
|||
|
|||
#include "Led.h" |
|||
|
|||
class DropDown |
|||
{ |
|||
private: |
|||
char _functionCode; |
|||
Led _led; |
|||
|
|||
public: |
|||
DropDown(char functionCode); |
|||
DropDown(char functionCode, char ledFunctionCode); |
|||
|
|||
Led* getLed(); |
|||
QByteArray select(int value); |
|||
}; |
|||
|
|||
#endif //DropDown_H
|
@ -0,0 +1,69 @@ |
|||
#include "model/DatabaseManager.h" |
|||
|
|||
#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()) |
|||
{ |
|||
_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; |
|||
} |
@ -0,0 +1,38 @@ |
|||
#include "model/DropDown.h" |
|||
|
|||
/*************************************************************************************************/ |
|||
DropDown::DropDown(char functionCode) |
|||
{ |
|||
_functionCode = functionCode; |
|||
} |
|||
|
|||
/*************************************************************************************************/ |
|||
DropDown::DropDown(char functionCode, char ledFunctionCode) : |
|||
_led(ledFunctionCode) |
|||
{ |
|||
_functionCode = functionCode; |
|||
} |
|||
|
|||
/*************************************************************************************************/ |
|||
Led* DropDown::getLed() |
|||
{ |
|||
return &_led; |
|||
} |
|||
|
|||
/*************************************************************************************************/ |
|||
QByteArray DropDown::select(int value) |
|||
{ |
|||
QByteArray arr; |
|||
|
|||
arr.resize(PROTOCOL_LENGTH); |
|||
arr[0] = MESSAGE_DIRECTION; |
|||
arr[1] = DropDownDataLength; |
|||
arr[2] = DropDownType; |
|||
arr[3] = _functionCode; |
|||
arr[4] = static_cast<char>(value >> PROTOCOL_LENGTH); |
|||
arr[5] = static_cast<char>(value); |
|||
arr[6] = TIME_TAG; |
|||
arr[7] = TIME_TAG; |
|||
|
|||
return arr; |
|||
} |
@ -0,0 +1,378 @@ |
|||
import QtQuick 2.0 |
|||
import QtQuick.Controls 2.13 |
|||
import QtGraphicalEffects 1.13 |
|||
|
|||
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 |
|||
|
|||
Button { |
|||
id: button |
|||
|
|||
width: Const.macroButton |
|||
height: Const.macroButton * 2 |
|||
implicitWidth: width |
|||
implicitHeight: height |
|||
//========================================= |
|||
property var name |
|||
property var nameLed: name + "Led" |
|||
|
|||
MvvmBinding { |
|||
viewModel: mainView.viewModel |
|||
viewProperty: "down" |
|||
viewModelProperty: name |
|||
type: MvvmBinding.OneWayToViewModel |
|||
} |
|||
|
|||
MvvmBinding { |
|||
viewModel: mainView.viewModel |
|||
viewProperty: "colorMode" |
|||
viewModelProperty: nameLed |
|||
} |
|||
|
|||
//========================================= |
|||
property var image: "" |
|||
property var radius: Math.min(width / 2, height / 2) |
|||
property var timeToPress: 100 |
|||
property var border: 6 |
|||
|
|||
property var colorMode: 0 // 0->None; 1->White; 2->Green; 3->Yellow |
|||
property color lightColor: getColor() |
|||
property color lightGlow: getColorGlow() |
|||
|
|||
signal pressed |
|||
signal released |
|||
|
|||
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 |
|||
} |
|||
} |
|||
|
|||
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 |
|||
} |
|||
} |
|||
|
|||
contentItem: Item { |
|||
id: content |
|||
anchors.fill: parent |
|||
z: 1 |
|||
|
|||
Item { |
|||
property var factor: button.state |
|||
== "Pressed" ? Const.imageScalePressed : Const.imageScale |
|||
property var elevator: button.state == "Pressed" ? 3 : 0 |
|||
|
|||
anchors.horizontalCenter: parent.horizontalCenter |
|||
y: (parent.height * (1 - factor)) / 2 + elevator |
|||
width: parent.width * factor |
|||
height: parent.height * factor |
|||
|
|||
Behavior on y { |
|||
NumberAnimation { |
|||
duration: timeToPress |
|||
easing.type: Easing.InOutQuad |
|||
} |
|||
} |
|||
|
|||
Behavior on width { |
|||
NumberAnimation { |
|||
duration: timeToPress |
|||
easing.type: Easing.InOutQuad |
|||
} |
|||
} |
|||
|
|||
Behavior on height { |
|||
NumberAnimation { |
|||
duration: timeToPress |
|||
easing.type: Easing.InOutQuad |
|||
} |
|||
} |
|||
|
|||
Image { |
|||
id: img |
|||
anchors.fill: parent |
|||
source: image |
|||
fillMode: Image.PreserveAspectFit |
|||
antialiasing: true |
|||
smooth: true |
|||
} |
|||
|
|||
ColorOverlay { |
|||
anchors.fill: img |
|||
source: img |
|||
color: button.state == "Pressed" ? Theme.current.textSelected : Theme.current.text |
|||
antialiasing: true |
|||
smooth: true |
|||
} |
|||
} |
|||
} |
|||
|
|||
background: Item { |
|||
width: parent.width |
|||
height: parent.height |
|||
|
|||
Rectangle { |
|||
id: backLightGlow |
|||
property var diffusion: Theme.current.glowRaduis |
|||
width: backLight.width + diffusion |
|||
height: backLight.height + diffusion |
|||
radius: width / 2 |
|||
anchors.horizontalCenter: backLight.horizontalCenter |
|||
y: -diffusion / 4 |
|||
color: Theme.current.background |
|||
border { |
|||
width: diffusion / 2 |
|||
color: Theme.current.background |
|||
} |
|||
} |
|||
|
|||
Rectangle { |
|||
anchors.fill: backLightGlow |
|||
|
|||
color: "transparent" |
|||
layer.enabled: true |
|||
layer.effect: OpacityMask { |
|||
maskSource: backLightGlow |
|||
} |
|||
|
|||
Rectangle { |
|||
width: parent.width |
|||
height: parent.height |
|||
radius: parent.radius |
|||
color: "transparent" |
|||
|
|||
RadialGradient { |
|||
anchors.fill: parent |
|||
gradient: Gradient { |
|||
GradientStop { |
|||
position: 0.0 |
|||
color: lightGlow |
|||
} |
|||
GradientStop { |
|||
position: 0.5 * (backLight.width - backLightGlow.diffusion |
|||
/ backLightGlow.width) |
|||
color: lightGlow |
|||
} |
|||
GradientStop { |
|||
position: 0.5 |
|||
color: "transparent" |
|||
} |
|||
GradientStop { |
|||
position: 1.0 |
|||
color: "transparent" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
Rectangle { |
|||
id: backLight |
|||
width: parent.width + 4 |
|||
height: parent.height + 4 |
|||
radius: width / 2 |
|||
color: lightColor |
|||
anchors.top: parent.top |
|||
anchors.horizontalCenter: parent.horizontalCenter |
|||
} |
|||
|
|||
Rectangle { |
|||
id: background |
|||
anchors.fill: parent |
|||
radius: button.radius |
|||
color: Theme.current.button |
|||
|
|||
Behavior on color { |
|||
ColorAnimation { |
|||
duration: timeToPress |
|||
easing.type: Easing.InOutQuad |
|||
} |
|||
} |
|||
} |
|||
|
|||
Item { |
|||
id: coloredRing |
|||
width: parent.width |
|||
height: parent.height |
|||
|
|||
Rectangle { |
|||
id: lightRing |
|||
width: parent.width |
|||
height: parent.height |
|||
radius: width / 2 |
|||
color: "transparent" |
|||
border { |
|||
color: background.color |
|||
width: button.border |
|||
} |
|||
} |
|||
|
|||
Item { |
|||
id: borderGrad |
|||
implicitWidth: parent.width |
|||
implicitHeight: parent.height |
|||
anchors.fill: parent |
|||
|
|||
layer.enabled: true |
|||
layer.effect: OpacityMask { |
|||
maskSource: lightRing |
|||
} |
|||
|
|||
Rectangle { |
|||
width: parent.width |
|||
height: parent.height |
|||
color: background.color |
|||
|
|||
LinearGradient { |
|||
id: linGrad |
|||
anchors.fill: parent |
|||
start: Qt.point(0, parent.height) |
|||
end: Qt.point(0, 0) |
|||
gradient: Gradient { |
|||
GradientStop { |
|||
id: buttonDown |
|||
position: 0 |
|||
color: Theme.current.shadow |
|||
|
|||
Behavior on color { |
|||
ColorAnimation { |
|||
duration: timeToPress |
|||
easing.type: Easing.InOutQuad |
|||
} |
|||
} |
|||
} |
|||
|
|||
GradientStop { |
|||
id: buttonUp |
|||
position: 1 |
|||
color: Theme.current.light |
|||
|
|||
Behavior on color { |
|||
ColorAnimation { |
|||
duration: timeToPress |
|||
easing.type: Easing.InOutQuad |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
MouseArea { |
|||
hoverEnabled: true |
|||
anchors.fill: background |
|||
onEntered: { |
|||
button.state = "Hovering" |
|||
} |
|||
|
|||
onExited: { |
|||
button.state = "" |
|||
} |
|||
|
|||
onPressed: { |
|||
button.state = "Pressed" |
|||
button.pressed() |
|||
} |
|||
|
|||
onReleased: { |
|||
button.released() |
|||
if (containsMouse) |
|||
button.state = "Hovering" |
|||
else |
|||
button.state = "" |
|||
} |
|||
} |
|||
} |
|||
|
|||
Item { |
|||
id: hoverLight |
|||
implicitWidth: parent.width |
|||
implicitHeight: parent.height |
|||
anchors.fill: parent |
|||
|
|||
layer.enabled: true |
|||
layer.effect: OpacityMask { |
|||
maskSource: background |
|||
} |
|||
|
|||
Rectangle { |
|||
id: hoverGlow |
|||
width: 2 * parent.width |
|||
height: parent.height |
|||
x: -2 * parent.width |
|||
color: "transparent" |
|||
|
|||
HoverGlow {} |
|||
} |
|||
} |
|||
|
|||
states: [ |
|||
State { |
|||
name: "Hovering" |
|||
PropertyChanges { |
|||
target: hoverGlow |
|||
x: 0 |
|||
} |
|||
}, |
|||
|
|||
State { |
|||
name: "Pressed" |
|||
PropertyChanges { |
|||
target: background |
|||
color: Theme.current.buttonSelected |
|||
} |
|||
|
|||
PropertyChanges { |
|||
target: buttonUp |
|||
color: Theme.current.shadow |
|||
} |
|||
|
|||
PropertyChanges { |
|||
target: buttonDown |
|||
color: Theme.current.light |
|||
} |
|||
} |
|||
] |
|||
|
|||
transitions: [ |
|||
Transition { |
|||
from: "" |
|||
to: "Hovering" |
|||
NumberAnimation { |
|||
properties: "x" |
|||
duration: 500 |
|||
easing.type: Easing.OutQuad |
|||
} |
|||
} |
|||
] |
|||
} |
@ -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 |
|||
} |
|||
} |
@ -0,0 +1,94 @@ |
|||
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" |
|||
|
|||
GridLayout { |
|||
x: 20 |
|||
y: 50 |
|||
rowSpacing: 30 |
|||
columns: 4 |
|||
|
|||
property var widthOfBtns: 130 |
|||
property var probeList: [] |
|||
|
|||
Item { |
|||
Layout.fillWidth: true |
|||
implicitHeight: Const.macroButton * 2 |
|||
ProbeButton { |
|||
anchors.centerIn: parent |
|||
implicitWidth: width * 1.25 |
|||
name: "slot4" |
|||
image: "qrc:/icons/topLeft/probe.png" |
|||
} |
|||
} |
|||
Item { |
|||
Layout.fillWidth: true |
|||
implicitHeight: Const.macroButton * 2 |
|||
ProbeButton { |
|||
anchors.centerIn: parent |
|||
implicitWidth: width * 1.25 |
|||
name: "slot3" |
|||
image: "qrc:/icons/topLeft/probe.png" |
|||
} |
|||
} |
|||
Item { |
|||
Layout.fillWidth: true |
|||
implicitHeight: Const.macroButton * 2 |
|||
ProbeButton { |
|||
anchors.centerIn: parent |
|||
implicitWidth: width * 1.25 |
|||
name: "slot2" |
|||
image: "qrc:/icons/topLeft/probe.png" |
|||
} |
|||
} |
|||
Item { |
|||
Layout.fillWidth: true |
|||
implicitHeight: Const.macroButton * 2 |
|||
ProbeButton { |
|||
anchors.centerIn: parent |
|||
implicitWidth: width * 1.25 |
|||
name: "slot1" |
|||
image: "qrc:/icons/topLeft/probe.png" |
|||
} |
|||
} |
|||
|
|||
MvvmBinding { |
|||
viewModel: mainView.viewModel |
|||
viewProperty: "probeList" |
|||
viewModelProperty: "probeList" |
|||
} |
|||
|
|||
DropDownWithDisable { |
|||
viewModelProperty: "currentSelectedProbe4" |
|||
model: probeList |
|||
width: widthOfBtns |
|||
isProbeEnableProperty: "isProbeSelectionEnable4" |
|||
} |
|||
|
|||
DropDownWithDisable { |
|||
viewModelProperty: "currentSelectedProbe3" |
|||
model: probeList |
|||
width: widthOfBtns |
|||
isProbeEnableProperty: "isProbeSelectionEnable3" |
|||
} |
|||
DropDownWithDisable { |
|||
viewModelProperty: "currentSelectedProbe2" |
|||
model: probeList |
|||
width: widthOfBtns |
|||
isProbeEnableProperty: "isProbeSelectionEnable2" |
|||
} |
|||
DropDownWithDisable { |
|||
viewModelProperty: "currentSelectedProbe1" |
|||
model: probeList |
|||
width: widthOfBtns |
|||
isProbeEnableProperty: "isProbeSelectionEnable1" |
|||
} |
|||
} |
Loading…
Reference in new issue