option to restore default values of device configuration
Some checks failed
Build / PC_Application_Ubuntu (push) Has been cancelled
Build / PC_Application_RPi5 (push) Has been cancelled
Build / PC_Application_Windows (push) Has been cancelled
Build / PC_Application_OSX (push) Has been cancelled
Build / PC_Application_OSX_13 (push) Has been cancelled
Build / Embedded_Firmware (push) Has been cancelled
HIL_Tests / Get_Repository (push) Has been cancelled
Unit_Tests / Tests (push) Has been cancelled
HIL_Tests / PC_Application_RPi5 (push) Has been cancelled
HIL_Tests / Embedded_Firmware (push) Has been cancelled
HIL_Tests / HIL (push) Has been cancelled

This commit is contained in:
Jan Käberich 2025-11-15 19:22:15 +01:00
parent b6718c57b2
commit 64791e6d4e
6 changed files with 24 additions and 1 deletions

View file

@ -1,6 +1,9 @@
#include "deviceconfigurationdialogv1.h"
#include "ui_deviceconfigurationdialogv1.h"
#include <QPushButton>
#include "CustomWidgets/informationbox.h"
DeviceConfigurationDialogV1::DeviceConfigurationDialogV1(LibreVNADriver &dev, QWidget *parent) :
QDialog(parent),
ui(new Ui::DeviceConfigurationDialogV1),
@ -56,6 +59,10 @@ DeviceConfigurationDialogV1::DeviceConfigurationDialogV1(LibreVNADriver &dev, QW
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, [=](){
reject();
});
connect(ui->buttonBox->button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked, this, [=](){
resetDevice();
this->dev.sendWithoutPayload(Protocol::PacketType::RequestDeviceConfiguration);
});
}
DeviceConfigurationDialogV1::~DeviceConfigurationDialogV1()
@ -84,3 +91,12 @@ void DeviceConfigurationDialogV1::updateDevice()
p.deviceConfig.V1.PLLSettlingDelay = ui->PLLSettlingDelay->value();
dev.SendPacket(p);
}
void DeviceConfigurationDialogV1::resetDevice()
{
dev.sendWithoutPayload(Protocol::PacketType::ResetDeviceConfiguration, [=](LibreVNADriver::TransmissionResult res){
if(res != LibreVNADriver::TransmissionResult::Ack) {
InformationBox::ShowError("Error", "Failed to reset device configuration");
}
});
}

View file

@ -20,6 +20,7 @@ public:
private:
void updateGUI(const Protocol::DeviceConfig &c);
void updateDevice();
void resetDevice();
Ui::DeviceConfigurationDialogV1 *ui;
LibreVNADriver &dev;

View file

@ -164,7 +164,7 @@
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok|QDialogButtonBox::StandardButton::RestoreDefaults</set>
</property>
</widget>
</item>