diff --git a/example/widgetExplorer/CMakeLists.txt b/example/widgetExplorer/CMakeLists.txt index 2171f52..785518c 100644 --- a/example/widgetExplorer/CMakeLists.txt +++ b/example/widgetExplorer/CMakeLists.txt @@ -14,6 +14,9 @@ target_sources(${PROJECT_NAME} devicewindow.h devicewindow.ui main.cpp + metadatadialog.h + metadatadialog.cpp + metadatadialog.ui widgetexplorer.cpp widgetexplorer.h ) diff --git a/example/widgetExplorer/devicewindow.cpp b/example/widgetExplorer/devicewindow.cpp index 47e2493..13ab4da 100644 --- a/example/widgetExplorer/devicewindow.cpp +++ b/example/widgetExplorer/devicewindow.cpp @@ -1,4 +1,5 @@ #include "devicewindow.h" +#include "metadatadialog.h" #include "ui_devicewindow.h" #include @@ -20,6 +21,15 @@ DeviceWindow::DeviceWindow(QWidget *parent) ui->widgetView->setSortingEnabled(true); ui->widgetView->sortByColumn(WidgetModel::Column::PortName, Qt::SortOrder::AscendingOrder); + // model connections + connect(ui->actionParameter, &QAction::triggered, + this, [this]() { + auto selected = ui->widgetView->currentIndex(); + if (!selected.isValid()) + return; + MetadataDialog dlg(selected.data(Qt::EditRole).value(), this); + dlg.exec(); + }); // action connections connect(ui->actionAbout, &QAction::triggered, this, [this](){ diff --git a/example/widgetExplorer/metadatadialog.cpp b/example/widgetExplorer/metadatadialog.cpp new file mode 100644 index 0000000..c8e55b2 --- /dev/null +++ b/example/widgetExplorer/metadatadialog.cpp @@ -0,0 +1,47 @@ +#include "metadatadialog.h" +#include "ui_metadatadialog.h" +#include +#include + +MetadataDialog::MetadataDialog(DmxWidget *device, QWidget *parent) + : QDialog(parent) + , ui(new Ui::MetadataDialog) + , dev(device) +{ + ui->setupUi(this); + + ui->breakSpinBox->setSingleStep(ENTTEC::Pro::DMX_BREAK_INTERVAL); + ui->breakSpinBox->setMinimum(ENTTEC::Pro::DMX_BREAK_INTERVAL * ENTTEC::Pro::DMX_BREAK_MIN); + ui->breakSpinBox->setMaximum(ENTTEC::Pro::DMX_BREAK_INTERVAL * ENTTEC::Pro::DMX_BREAK_MAX); + ui->breakSpinBox->setValue(device->txBreakTime()); + + ui->mabSpinBox->setSingleStep(ENTTEC::Pro::DMX_MAB_INTERVAL); + ui->mabSpinBox->setMinimum(ENTTEC::Pro::DMX_MAB_INTERVAL * ENTTEC::Pro::DMX_MAB_MIN); + ui->mabSpinBox->setMaximum(ENTTEC::Pro::DMX_MAB_INTERVAL * ENTTEC::Pro::DMX_MAB_MAX); + ui->mabSpinBox->setValue(device->txMabTime()); + + ui->rateSpinBox->setSingleStep(1); + ui->rateSpinBox->setMinimum(0); // zero rate for fastest tx possible + ui->rateSpinBox->setMaximum(ENTTEC::Pro::DMX_RATE_MAX); + ui->rateSpinBox->setValue(device->txRate()); + + connect(ui->buttonBox->button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked, + this, [this](){ + ui->breakSpinBox->setValue(17 * ENTTEC::Pro::DMX_BREAK_INTERVAL); // match OEM + ui->mabSpinBox->setValue(10 * ENTTEC::Pro::DMX_MAB_INTERVAL); // match OEM + ui->rateSpinBox->setValue(40); // match OEM + }); + + connect(this, &QDialog::accepted, this, [this](){ + dev->setTxBreakTime(ui->breakSpinBox->value()); + dev->setTxMabTime(ui->mabSpinBox->value()); + dev->setTxRate(ui->rateSpinBox->value()); + dev->setParameters(); + }); + +} + +MetadataDialog::~MetadataDialog() +{ + delete ui; +} diff --git a/example/widgetExplorer/metadatadialog.h b/example/widgetExplorer/metadatadialog.h new file mode 100644 index 0000000..79b6588 --- /dev/null +++ b/example/widgetExplorer/metadatadialog.h @@ -0,0 +1,22 @@ +#pragma once + +#include +#include + +namespace Ui { +class MetadataDialog; +} + +class MetadataDialog : public QDialog +{ + Q_OBJECT + +public: + explicit MetadataDialog(DmxWidget *device, QWidget *parent = nullptr); + ~MetadataDialog(); + +private: + Ui::MetadataDialog *ui; + DmxWidget * dev; +}; + diff --git a/example/widgetExplorer/metadatadialog.ui b/example/widgetExplorer/metadatadialog.ui new file mode 100644 index 0000000..2bf85eb --- /dev/null +++ b/example/widgetExplorer/metadatadialog.ui @@ -0,0 +1,130 @@ + + + MetadataDialog + + + + 0 + 0 + 467 + 151 + + + + Dialog + + + + + + The BREAK generated by a transmitter is defined as a mark-to-space transition followed by a low of this duration, followed by a low to high transition. + + + QAbstractSpinBox::CorrectToNearestValue + + + μs + + + 1 + + + 10.670000000000000 + + + + + + + The MARK separating the BREAK and the START Code + + + MAB Time + + + + + + + The MARK separating the BREAK and the START Code + + + μs + + + 1 + + + + + + + Rate + + + + + + + fps + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::RestoreDefaults + + + + + + + The BREAK indicates the start of a new packet. + + + Break Time + + + + + + + + + buttonBox + accepted() + MetadataDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + MetadataDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + +