19#include <QDialogButtonBox>
20#include <QNetworkInterface>
25#include "ui_networksettingsdialog.h"
36const QString NetworkSettingsDialog::QSTR_ADDRESS_IPV4 = QStringLiteral(
"225.0.0.37");
37const QString NetworkSettingsDialog::QSTR_ADDRESS_IPV6 = QStringLiteral(
"ff12::37");
39NetworkSettingsDialog::NetworkSettingsDialog(
const bool forInput, QWidget *parent) :
41 ui(new Ui::NetworkSettingsDialog),
45 connect(ui->buttonBox->button(QDialogButtonBox::RestoreDefaults), &QPushButton::pressed,
46 this, &NetworkSettingsDialog::restoreDefaults);
47 connect(ui->checkIPv6, &QCheckBox::toggled,
this, &NetworkSettingsDialog::toggledIPv6);
57NetworkSettingsDialog::~NetworkSettingsDialog()
59 if (m_driver !=
nullptr) {
69void NetworkSettingsDialog::accept()
72 if (m_driver !=
nullptr) {
74 QVariant varStatus = m_driver->property(
"status");
75 if (varStatus.isValid()) {
76 title = varStatus.toBool() ? tr(
"Network Initialized") : tr(
"Network Initialization Failed");
77 QVariant varDiag = m_driver->property(
"diagnostics");
78 if (varDiag.isValid()) {
79 QString text = varDiag.toStringList().join(QChar::LineFeed).trimmed();
80 if (varStatus.toBool()) {
81 if (!text.isEmpty()) {
82 QMessageBox::information(
this, title, text);
85 QMessageBox::critical(
this, title, text);
94void NetworkSettingsDialog::showEvent(QShowEvent *event)
100void NetworkSettingsDialog::readSettings()
102 SettingsFactory settings;
103 settings->beginGroup(
"Network");
104 QString ifaceName = settings->value(
"interface", QString()).toString();
105 bool ipv6 = settings->value(
"ipv6",
false).toBool();
106 QString address = settings->value(
"address", ipv6 ? QSTR_ADDRESS_IPV6 : QSTR_ADDRESS_IPV4).toString();
107 settings->endGroup();
109 ui->txtAddress->setText(address);
110 ui->checkIPv6->setChecked(ipv6);
111 ui->comboInterface->addItem(tr(
"Any"),
"");
112 foreach(
const QNetworkInterface& iface, QNetworkInterface::allInterfaces() ) {
113 if ( iface.isValid() &&
114 iface.flags().testFlag(QNetworkInterface::CanMulticast) &&
115 iface.flags().testFlag(QNetworkInterface::IsUp) &&
116 iface.flags().testFlag(QNetworkInterface::IsRunning) &&
117 !iface.flags().testFlag(QNetworkInterface::IsLoopBack) ) {
118 QString name = iface.name();
119 QString text = iface.humanReadableName();
120 ui->comboInterface->addItem(text, name);
121 if (name == ifaceName) {
122 ui->comboInterface->setCurrentText(text);
126 chkInitialization(settings.getQSettings());
129void NetworkSettingsDialog::writeSettings()
131 SettingsFactory settings;
132 QString networkAddr = ui->txtAddress->text();
133 QString networkIface = ui->comboInterface->currentData().toString();
134 bool ipv6 = ui->checkIPv6->isChecked();
136 settings->beginGroup(
"Network");
137 settings->setValue(
"address", networkAddr);
138 settings->setValue(
"interface", networkIface);
139 settings->setValue(
"ipv6", ipv6);
140 settings->endGroup();
143 chkInitialization(settings.getQSettings());
146void NetworkSettingsDialog::chkInitialization(
QSettings *settings)
148 if (m_driver !=
nullptr) {
153 d->initialize(settings);
158 d->initialize(settings);
161 QVariant varStatus = m_driver->property(
"status");
162 if (varStatus.isValid()) {
163 ui->lblStatusText->clear();
164 ui->lblStatusText->setText(varStatus.toBool() ? tr(
"Ready") : tr(
"Failed") );
165 ui->lblStatusIcon->setPixmap(varStatus.toBool() ? QPixmap(
":/checked.png") : QPixmap(
":/error.png") );
170void NetworkSettingsDialog::restoreDefaults()
172 ui->checkIPv6->setChecked(
false);
173 ui->txtAddress->setText(QSTR_ADDRESS_IPV4);
174 ui->comboInterface->setCurrentText(tr(
"Any"));
177void NetworkSettingsDialog::toggledIPv6(
bool checked)
179 ui->txtAddress->setText(checked ? QSTR_ADDRESS_IPV6 : QSTR_ADDRESS_IPV4);
BackendManager class declaration.
The QSettings class provides persistent platform-independent application settings.
The BackendManager class manages lists of dynamic and static backends for applications based on drums...
MIDIOutput * outputBackendByName(const QString name)
outputBackendByName
MIDIInput * inputBackendByName(const QString name)
inputBackendByName
virtual void close()=0
close the MIDI port
QPair< QString, QVariant > MIDIConnection
MIDIConnection represents a connection identifier.
Declaration of the Network configuration dialog.
SettingsFactory class declaration.