Merge PR #385: Add ID to the thing config page

This commit is contained in:
Jenkins nymea 2020-06-08 11:34:49 +02:00
commit 6f2986d3ce
4 changed files with 42 additions and 42 deletions

View File

@ -130,7 +130,7 @@ Interfaces::Interfaces(QObject *parent) : QAbstractListModel(parent)
addInterface("extendedevcharger", tr("EV chargers"), {"evcharger"}); addInterface("extendedevcharger", tr("EV chargers"), {"evcharger"});
addStateType("extendedevcharger", "maxChargingCurrent", QVariant::UInt, true, tr("Maximum charging current"), tr("Maximum charging current changed"), tr("Set maximum charging current")); addStateType("extendedevcharger", "maxChargingCurrent", QVariant::UInt, true, tr("Maximum charging current"), tr("Maximum charging current changed"), tr("Set maximum charging current"));
addInterface("heating", tr("Heatings")); addInterface("heating", tr("Heating"));
addStateType("heating", "power", QVariant::Bool, true, tr("Heating enabled"), tr("Heating enabled changed"), tr("Enable heating")); addStateType("heating", "power", QVariant::Bool, true, tr("Heating enabled"), tr("Heating enabled changed"), tr("Enable heating"));
addInterface("extendedheating", tr("Heatings"), {"heating"}); addInterface("extendedheating", tr("Heatings"), {"heating"});

View File

@ -30,6 +30,9 @@
#include "platformhelper.h" #include "platformhelper.h"
#include <QApplication>
#include <QClipboard>
PlatformHelper::PlatformHelper(QObject *parent) : QObject(parent) PlatformHelper::PlatformHelper(QObject *parent) : QObject(parent)
{ {
@ -85,3 +88,13 @@ void PlatformHelper::setBottomPanelColor(const QColor &color)
emit bottomPanelColorChanged(); emit bottomPanelColorChanged();
} }
} }
void PlatformHelper::toClipBoard(const QString &text)
{
QApplication::clipboard()->setText(text);
}
QString PlatformHelper::fromClipBoard()
{
return QApplication::clipboard()->text();
}

View File

@ -85,6 +85,9 @@ public:
Q_INVOKABLE virtual void vibrate(HapticsFeedback feedbackType) = 0; Q_INVOKABLE virtual void vibrate(HapticsFeedback feedbackType) = 0;
Q_INVOKABLE virtual void toClipBoard(const QString &text);
Q_INVOKABLE virtual QString fromClipBoard();
signals: signals:
void permissionsRequestFinished(); void permissionsRequestFinished();
void screenTimeoutChanged(); void screenTimeoutChanged();

View File

@ -110,42 +110,36 @@ SettingsPageBase {
} }
} }
SettingsPageSectionHeader {
Label {
Layout.fillWidth: true
Layout.margins: app.margins
text: qsTr("Information") text: qsTr("Information")
color: app.accentColor
} }
RowLayout {
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins NymeaListItemDelegate {
Label { Layout.fillWidth: true
text: qsTr("Vendor:") text: qsTr("Vendor:")
Layout.fillWidth: true subText: engine.deviceManager.vendors.getVendor(root.deviceClass.vendorId).displayName
} progressive: false
Label {
text: engine.deviceManager.vendors.getVendor(root.deviceClass.vendorId).displayName
}
} }
RowLayout { NymeaListItemDelegate {
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins Layout.fillWidth: true
Label { text: qsTr("Type:")
text: qsTr("Type:") subText: root.deviceClass.displayName
Layout.fillWidth: true progressive: false
} }
Label { NymeaListItemDelegate {
text: root.deviceClass.displayName Layout.fillWidth: true
text: qsTr("ID:")
subText: root.device.id.toString().replace(/[{}]/g, "")
progressive: false
onClicked: {
PlatformHelper.toClipBoard(root.device.id.toString().replace(/[{}]/g, ""));
ToolTip.show(qsTr("ID copied to clipboard"), 500);
} }
} }
Label { SettingsPageSectionHeader {
Layout.fillWidth: true
Layout.leftMargin: app.margins
Layout.rightMargin: app.margins
Layout.topMargin: app.margins
text: qsTr("Parameters") text: qsTr("Parameters")
color: app.accentColor visible: root.device.params.count > 0
visible: root.deviceClass.paramTypes.count > 0
} }
Repeater { Repeater {
@ -158,13 +152,8 @@ SettingsPageBase {
} }
} }
Label { SettingsPageSectionHeader {
Layout.fillWidth: true
Layout.leftMargin: app.margins
Layout.rightMargin: app.margins
Layout.topMargin: app.margins
text: qsTr("Input/Output Connections") text: qsTr("Input/Output Connections")
color: app.accentColor
visible: ioModel.count > 0 visible: ioModel.count > 0
} }
@ -224,13 +213,8 @@ SettingsPageBase {
} }
Label { SettingsPageSectionHeader {
Layout.fillWidth: true
Layout.leftMargin: app.margins
Layout.rightMargin: app.margins
Layout.topMargin: app.margins
text: qsTr("Settings") text: qsTr("Settings")
color: app.accentColor
visible: root.deviceClass.settingsTypes.count > 0 visible: root.deviceClass.settingsTypes.count > 0
} }