| 22 | ScreenSettingsDialog::~ScreenSettingsDialog() = default; |
| 23 | |
| 24 | ScreenSettingsDialog::ScreenSettingsDialog(QWidget *parent, Screen *screen, const ScreenList *screens) |
| 25 | : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), |
| 26 | ui{std::make_unique<Ui::ScreenSettingsDialog>()}, |
| 27 | m_screen(screen) |
| 28 | { |
| 29 | |
| 30 | ui->setupUi(this); |
| 31 | ui->buttonBox->button(QDialogButtonBox::Cancel)->setFocus(); |
| 32 | |
| 33 | ui->lineNameEdit->setText(m_screen->name()); |
| 34 | |
| 35 | const auto valNameError = new validators::ValidationError(this, ui->lblNameError); |
| 36 | const auto valName = new validators::ScreenNameValidator(ui->lineNameEdit, valNameError, screens); |
| 37 | ui->lineNameEdit->setValidator(valName); |
| 38 | |
| 39 | const auto valAliasError = new validators::ValidationError(this, ui->lblAliasError); |
| 40 | const auto valAlias = new validators::AliasValidator(ui->lineAddAlias, valAliasError); |
| 41 | ui->lineAddAlias->setValidator(valAlias); |
| 42 | |
| 43 | for (int i = 0; i < m_screen->aliases().count(); i++) |
| 44 | new QListWidgetItem(m_screen->aliases()[i], ui->listAliases); |
| 45 | |
| 46 | ui->comboShift->setCurrentIndex(m_screen->modifier(static_cast<int>(Shift))); |
| 47 | ui->comboCtrl->setCurrentIndex(m_screen->modifier(static_cast<int>(Ctrl))); |
| 48 | ui->comboAlt->setCurrentIndex(m_screen->modifier(static_cast<int>(Alt))); |
| 49 | ui->comboMeta->setCurrentIndex(m_screen->modifier(static_cast<int>(Meta))); |
| 50 | ui->comboSuper->setCurrentIndex(m_screen->modifier(static_cast<int>(Super))); |
| 51 | |
| 52 | ui->chkDeadTopLeft->setChecked(m_screen->switchCorner(static_cast<int>(TopLeft))); |
| 53 | ui->chkDeadTopRight->setChecked(m_screen->switchCorner(static_cast<int>(TopRight))); |
| 54 | ui->chkDeadBottomLeft->setChecked(m_screen->switchCorner(static_cast<int>(BottomLeft))); |
| 55 | ui->chkDeadBottomRight->setChecked(m_screen->switchCorner(static_cast<int>(BottomRight))); |
| 56 | ui->sbSwitchCornerSize->setValue(m_screen->switchCornerSize()); |
| 57 | |
| 58 | ui->chkFixCapsLock->setChecked(m_screen->fix(CapsLock)); |
| 59 | ui->chkFixNumLock->setChecked(m_screen->fix(NumLock)); |
| 60 | ui->chkFixScrollLock->setChecked(m_screen->fix(ScrollLock)); |
| 61 | ui->chkFixXTest->setChecked(m_screen->fix(XTest)); |
| 62 | |
| 63 | connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &ScreenSettingsDialog::accept); |
| 64 | connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &ScreenSettingsDialog::reject); |
| 65 | connect(ui->btnAddAlias, &QPushButton::clicked, this, &ScreenSettingsDialog::addAlias); |
| 66 | connect(ui->btnRemoveAlias, &QPushButton::clicked, this, &ScreenSettingsDialog::removeAlias); |
| 67 | connect(ui->lineAddAlias, &QLineEdit::textChanged, this, &ScreenSettingsDialog::checkNewAliasName); |
| 68 | connect(ui->listAliases, &QListWidget::itemSelectionChanged, this, &ScreenSettingsDialog::aliasSelected); |
| 69 | } |
| 70 | |
| 71 | void ScreenSettingsDialog::accept() |
| 72 | { |
nothing calls this directly
no test coverage detected