Add Sensor settings dialog
This commit is contained in:
parent
09f7e55b4e
commit
2fbfd1d458
6 changed files with 221 additions and 0 deletions
|
|
@ -4,6 +4,8 @@
|
|||
#include <QHeaderView>
|
||||
#include <QScroller>
|
||||
|
||||
#include "sensorsettingsdialog.h"
|
||||
|
||||
SensorListWidget::SensorListWidget(const bool showHidden, QWidget *parent): QTableWidget(parent),
|
||||
showHidden_(showHidden)
|
||||
{
|
||||
|
|
@ -15,12 +17,31 @@ SensorListWidget::SensorListWidget(const bool showHidden, QWidget *parent): QTab
|
|||
setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
sensorsChanged(std::vector<Sensor>());
|
||||
verticalHeader()->hide();
|
||||
|
||||
connect(this, &QTableWidget::doubleClicked, this, &SensorListWidget::onDoubleClick);
|
||||
}
|
||||
|
||||
SensorListWidget::SensorListWidget(SensorStore& sensorStore, const bool showHidden,
|
||||
QWidget* parent): QTableWidget (parent), showHidden_(showHidden)
|
||||
{
|
||||
sensorsChanged(*(sensorStore.getSensors()));
|
||||
connect(this, &QTableWidget::doubleClicked, this, &SensorListWidget::onDoubleClick);
|
||||
}
|
||||
|
||||
void SensorListWidget::onDoubleClick(const QModelIndex &index)
|
||||
{
|
||||
if(index.isValid())
|
||||
{
|
||||
const Sensor& sensor = getSensorForIndex(index);
|
||||
SensorSettingsDialog diag(sensor, this);
|
||||
if(diag.exec())
|
||||
{
|
||||
Sensor updatedSensor = sensor;
|
||||
updatedSensor.name = diag.getName();
|
||||
updatedSensor.hidden = diag.getHidden();
|
||||
globalSensors.sensorGotState(updatedSensor, SENSOR_UPDATE_USER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SensorListWidget::sensorsChanged(std::vector<Sensor> sensors)
|
||||
|
|
|
|||
|
|
@ -30,4 +30,6 @@ public slots:
|
|||
|
||||
void sensorsChanged(std::vector<Sensor> sensors);
|
||||
|
||||
private slots:
|
||||
void onDoubleClick(const QModelIndex &index);
|
||||
};
|
||||
|
|
|
|||
29
src/ui/sensorsettingsdialog.cpp
Normal file
29
src/ui/sensorsettingsdialog.cpp
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#include "sensorsettingsdialog.h"
|
||||
#include "ui_sensorsettingsdialog.h"
|
||||
|
||||
SensorSettingsDialog::SensorSettingsDialog(const Sensor& sensor, QWidget* parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::SensorSettingsDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->label_typeValue->setText(QString::number(sensor.type));
|
||||
ui->label_idValue->setText(QString::number(sensor.id));
|
||||
ui->lineEdit_Name->setText(sensor.name);
|
||||
ui->checkBox_Hidden->setChecked(sensor.hidden);
|
||||
}
|
||||
|
||||
SensorSettingsDialog::~SensorSettingsDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
QString SensorSettingsDialog::getName() const
|
||||
{
|
||||
return ui->lineEdit_Name->text();
|
||||
}
|
||||
|
||||
bool SensorSettingsDialog::getHidden() const
|
||||
{
|
||||
return ui->checkBox_Hidden->isChecked();
|
||||
}
|
||||
27
src/ui/sensorsettingsdialog.h
Normal file
27
src/ui/sensorsettingsdialog.h
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#ifndef SENSORSETTINGSDIALOG_H
|
||||
#define SENSORSETTINGSDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "sensors/sensor.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class SensorSettingsDialog;
|
||||
}
|
||||
|
||||
class SensorSettingsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SensorSettingsDialog(const Sensor& sensor, QWidget* parent = nullptr);
|
||||
~SensorSettingsDialog();
|
||||
|
||||
QString getName() const;
|
||||
bool getHidden() const;
|
||||
|
||||
private:
|
||||
Ui::SensorSettingsDialog* ui;
|
||||
};
|
||||
|
||||
#endif // SENSORSETTINGSDIALOG_H
|
||||
139
src/ui/sensorsettingsdialog.ui
Normal file
139
src/ui/sensorsettingsdialog.ui
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SensorSettingsDialog</class>
|
||||
<widget class="QDialog" name="SensorSettingsDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>150</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Sensor Settings</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_Type">
|
||||
<property name="text">
|
||||
<string>Type:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_typeValue">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_Id">
|
||||
<property name="text">
|
||||
<string>Id:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_idValue">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_Name">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_Name">
|
||||
<property name="text">
|
||||
<string></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_Hidden">
|
||||
<property name="text">
|
||||
<string>Hidden:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QCheckBox" name="checkBox_Hidden">
|
||||
<property name="text">
|
||||
<string></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>SensorSettingsDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>SensorSettingsDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
Loading…
Add table
Add a link
Reference in a new issue