/* SPDX-FileCopyrightText: 2013 Jan Grulich SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "settingwidget.h" #include "bssidcombobox.h" #include "hwaddrcombobox.h" #include "passwordfield.h" #include "ssidcombobox.h" #include #include #include #include #include #include #include #include SettingWidget::SettingWidget(const NetworkManager::Setting::Ptr &setting, QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f) , m_type(setting->name()) { } SettingWidget::SettingWidget(const NetworkManager::Setting::Ptr &setting, const QStringList &hints, QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f) , m_hints(hints) , m_type(setting->name()) { } SettingWidget::~SettingWidget() = default; void SettingWidget::loadConfig(const NetworkManager::Setting::Ptr &setting) { Q_UNUSED(setting); } void SettingWidget::loadSecrets(const NetworkManager::Setting::Ptr &setting) { Q_UNUSED(setting); } void SettingWidget::watchChangedSetting() { // Attempt to connect to all widgets representing various configurations // to notify about setting change /************ Qt Widgets ************/ // Connect all QLineEdit widgets const QList lineEdits = findChildren(); for (QLineEdit *lineedit : lineEdits) { connect(lineedit, &QLineEdit::textChanged, this, &SettingWidget::settingChanged); } // Connect all QComboBox widgets const QList comboboxes = findChildren(); for (QComboBox *combobox : comboboxes) { connect(combobox, QOverload::of(&QComboBox::currentIndexChanged), this, &SettingWidget::settingChanged); connect(combobox, &QComboBox::currentTextChanged, this, &SettingWidget::settingChanged); } // Connect all QCheckBox widgets const QList checkboxes = findChildren(); for (QCheckBox *checkbox : checkboxes) { connect(checkbox, &QCheckBox::stateChanged, this, &SettingWidget::settingChanged); } // Connect all QPushButton widgets const QList pushbuttons = findChildren(); for (QPushButton *pushbutton : pushbuttons) { connect(pushbutton, &QPushButton::clicked, this, &SettingWidget::settingChanged); } // Connect all QSpinBox widgets const QList spinboxes = findChildren(); for (QSpinBox *spinbox : spinboxes) { connect(spinbox, QOverload::of(&QSpinBox::valueChanged), this, &SettingWidget::settingChanged); } // Connect all KUrlRequester widgets const QList urlrequesters = findChildren(); for (KUrlRequester *urlrequester : urlrequesters) { connect(urlrequester, &KUrlRequester::textChanged, this, &SettingWidget::settingChanged); connect(urlrequester, &KUrlRequester::urlSelected, this, &SettingWidget::settingChanged); } // Connect all QTableView widgets const QList tableviews = findChildren(); for (QTableView *tableview : tableviews) { connect(tableview, &QTableView::clicked, this, &SettingWidget::settingChanged); } // Connect all QGroupBox widgets const QList groupBoxes = findChildren(); for (QGroupBox *box : groupBoxes) { connect(box, &QGroupBox::toggled, this, &SettingWidget::settingChanged); } /********** OUR CUSTOM WIDGETS **********/ // Connect all PasswordField widgets const QList passwordfields = findChildren(); for (PasswordField *passwordfield : passwordfields) { connect(passwordfield, &PasswordField::textChanged, this, &SettingWidget::settingChanged); connect(passwordfield, &PasswordField::passwordOptionChanged, this, &SettingWidget::settingChanged); } // Connect all HwAddrComboBox widgets const QList hwAddrcomboboxes = findChildren(); for (HwAddrComboBox *combobox : hwAddrcomboboxes) { connect(combobox, &HwAddrComboBox::hwAddressChanged, this, &SettingWidget::settingChanged); } // Connect all SssidComboBox widgets const QList ssidcomboboxes = findChildren(); for (SsidComboBox *combobox : ssidcomboboxes) { connect(combobox, &SsidComboBox::ssidChanged, this, &SettingWidget::settingChanged); } // Connect all BssidComboBox widgets const QList bssidcomboboxes = findChildren(); for (BssidComboBox *combobox : bssidcomboboxes) { connect(combobox, &BssidComboBox::bssidChanged, this, &SettingWidget::settingChanged); } } QString SettingWidget::type() const { return m_type; } void SettingWidget::slotWidgetChanged() { Q_EMIT validChanged(isValid()); } #include "moc_settingwidget.cpp"