diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2023-05-09 15:34:38 +0200 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-05-09 15:34:38 +0200 |
| commit | 780aca2622d907320a1cf462390f192fb3ae4b31 (patch) | |
| tree | c7843a5ebe0620d8f97ae7ba86ba6f5d06ffc167 /proto-osc/dialog.cpp | |
| parent | c1de1499775d47a574bd52d07acbb269845fb75b (diff) | |
| parent | 051fb2f94f6364b80219a3c671bb953d2e54a140 (diff) | |
Merge branch 'master' into trackhat-sensor-v2
Diffstat (limited to 'proto-osc/dialog.cpp')
| -rw-r--r-- | proto-osc/dialog.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/proto-osc/dialog.cpp b/proto-osc/dialog.cpp new file mode 100644 index 00000000..54bf6885 --- /dev/null +++ b/proto-osc/dialog.cpp @@ -0,0 +1,38 @@ +#include "dialog.hpp" +#include <QHostAddress> +#include <QPalette> + +void osc_dialog::host_address_edited(const QString& str) +{ + bool bad = QHostAddress{str}.isNull(); + auto pal = pal_; + for (auto role : { QPalette::Highlight, QPalette::Window }) + if (bad) + pal.setColor(role, Qt::red); + ui.address->setPalette(pal); +} + +osc_dialog::osc_dialog() : + pal_{palette()} +{ + ui.setupUi( this ); + + tie_setting(s.address, ui.address); + tie_setting(s.port, ui.port); + connect(ui.buttonBox, &QDialogButtonBox::accepted, this, &osc_dialog::doOK); + connect(ui.buttonBox, &QDialogButtonBox::rejected, this, &osc_dialog::doCancel); + connect(ui.address, &QLineEdit::textChanged, this, &osc_dialog::host_address_edited); + host_address_edited(ui.address->text()); +} + +void osc_dialog::save() { s.b->save(); } +void osc_dialog::reload() { s.b->reload(); } + +void osc_dialog::doOK() { s.b->save(); close(); } +void osc_dialog::doCancel() { close(); } + +void osc_dialog::register_protocol(IProtocol*) {} +void osc_dialog::unregister_protocol() {} + +bool osc_dialog::embeddable() noexcept { return true; } +void osc_dialog::set_buttons_visible(bool x) noexcept { ui.buttonBox->setVisible(x); } |
