refactor: ScreenSettingsDialog, do not use auto connect slots
This commit is contained in:
@ -64,6 +64,13 @@ ScreenSettingsDialog::ScreenSettingsDialog(QWidget *parent, Screen *screen, cons
|
||||
ui->chkFixNumLock->setChecked(m_screen->fix(NumLock));
|
||||
ui->chkFixScrollLock->setChecked(m_screen->fix(ScrollLock));
|
||||
ui->chkFixXTest->setChecked(m_screen->fix(XTest));
|
||||
|
||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &ScreenSettingsDialog::accept);
|
||||
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &ScreenSettingsDialog::reject);
|
||||
connect(ui->btnAddAlias, &QPushButton::clicked, this, &ScreenSettingsDialog::addAlias);
|
||||
connect(ui->btnRemoveAlias, &QPushButton::clicked, this, &ScreenSettingsDialog::removeAlias);
|
||||
connect(ui->lineAddAlias, &QLineEdit::textChanged, this, &ScreenSettingsDialog::checkNewAliasName);
|
||||
connect(ui->listAliases, &QListWidget::itemSelectionChanged, this, &ScreenSettingsDialog::aliasSelected);
|
||||
}
|
||||
|
||||
void ScreenSettingsDialog::accept()
|
||||
@ -115,7 +122,7 @@ void ScreenSettingsDialog::accept()
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void ScreenSettingsDialog::on_btnAddAlias_clicked()
|
||||
void ScreenSettingsDialog::addAlias()
|
||||
{
|
||||
if (!ui->lineAddAlias->text().isEmpty() &&
|
||||
ui->listAliases->findItems(ui->lineAddAlias->text(), Qt::MatchFixedString).isEmpty()) {
|
||||
@ -124,18 +131,18 @@ void ScreenSettingsDialog::on_btnAddAlias_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenSettingsDialog::on_lineAddAlias_textChanged(const QString &text)
|
||||
{
|
||||
ui->btnAddAlias->setEnabled(!text.isEmpty() && ui->lblAliasError->text().isEmpty());
|
||||
}
|
||||
|
||||
void ScreenSettingsDialog::on_btnRemoveAlias_clicked()
|
||||
void ScreenSettingsDialog::removeAlias()
|
||||
{
|
||||
QList<QListWidgetItem *> items = ui->listAliases->selectedItems();
|
||||
qDeleteAll(items);
|
||||
}
|
||||
|
||||
void ScreenSettingsDialog::on_listAliases_itemSelectionChanged()
|
||||
void ScreenSettingsDialog::checkNewAliasName(const QString &text)
|
||||
{
|
||||
ui->btnAddAlias->setEnabled(!text.isEmpty() && ui->lblAliasError->text().isEmpty());
|
||||
}
|
||||
|
||||
void ScreenSettingsDialog::aliasSelected()
|
||||
{
|
||||
ui->btnRemoveAlias->setEnabled(!ui->listAliases->selectedItems().isEmpty());
|
||||
}
|
||||
|
||||
@ -31,10 +31,10 @@ public Q_SLOTS:
|
||||
void accept() override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void on_btnAddAlias_clicked();
|
||||
void on_btnRemoveAlias_clicked();
|
||||
void on_lineAddAlias_textChanged(const QString &text);
|
||||
void on_listAliases_itemSelectionChanged();
|
||||
void addAlias();
|
||||
void removeAlias();
|
||||
void checkNewAliasName(const QString &text);
|
||||
void aliasSelected();
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui::ScreenSettingsDialog> ui;
|
||||
|
||||
@ -704,38 +704,5 @@
|
||||
<tabstop>btnRemoveAlias</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>ScreenSettingsDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>231</x>
|
||||
<y>548</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>ScreenSettingsDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>299</x>
|
||||
<y>548</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
Reference in New Issue
Block a user