| 26 | using namespace Konsole; |
| 27 | |
| 28 | KeyBindingEditor::KeyBindingEditor(QWidget *parent) |
| 29 | : QDialog(parent) |
| 30 | , _ui(nullptr) |
| 31 | , _translator(new KeyboardTranslator(QString())) |
| 32 | , _isNewTranslator(false) |
| 33 | { |
| 34 | auto layout = new QVBoxLayout; |
| 35 | |
| 36 | auto mainWidget = new QWidget(this); |
| 37 | layout->addWidget(mainWidget); |
| 38 | |
| 39 | auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); |
| 40 | buttonBox->button(QDialogButtonBox::Cancel)->setDefault(true); |
| 41 | layout->addWidget(buttonBox); |
| 42 | |
| 43 | setLayout(layout); |
| 44 | |
| 45 | connect(buttonBox, &QDialogButtonBox::accepted, this, &Konsole::KeyBindingEditor::accept); |
| 46 | connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); |
| 47 | |
| 48 | setAttribute(Qt::WA_DeleteOnClose); |
| 49 | |
| 50 | _ui = new Ui::KeyBindingEditor(); |
| 51 | _ui->setupUi(mainWidget); |
| 52 | |
| 53 | // description edit |
| 54 | _ui->descriptionEdit->setPlaceholderText(i18nc("@label:textbox", "Enter descriptive label")); |
| 55 | connect(_ui->descriptionEdit, &QLineEdit::textChanged, this, &Konsole::KeyBindingEditor::setTranslatorDescription); |
| 56 | // filter edit |
| 57 | connect(_ui->filterEdit, &QLineEdit::textChanged, this, &Konsole::KeyBindingEditor::filterRows); |
| 58 | |
| 59 | // key bindings table |
| 60 | _ui->keyBindingTable->setColumnCount(2); |
| 61 | |
| 62 | QStringList labels; |
| 63 | labels << i18n("Key Combination") << i18n("Output"); |
| 64 | |
| 65 | _ui->keyBindingTable->setHorizontalHeaderLabels(labels); |
| 66 | _ui->keyBindingTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); |
| 67 | |
| 68 | _ui->keyBindingTable->verticalHeader()->hide(); |
| 69 | _ui->keyBindingTable->setSelectionBehavior(QAbstractItemView::SelectRows); |
| 70 | |
| 71 | // add and remove buttons |
| 72 | _ui->addEntryButton->setIcon(QIcon::fromTheme(QStringLiteral("list-add"))); |
| 73 | _ui->removeEntryButton->setIcon(QIcon::fromTheme(QStringLiteral("list-remove"))); |
| 74 | |
| 75 | connect(_ui->removeEntryButton, &QPushButton::clicked, this, &Konsole::KeyBindingEditor::removeSelectedEntry); |
| 76 | connect(_ui->addEntryButton, &QPushButton::clicked, this, &Konsole::KeyBindingEditor::addNewEntry); |
| 77 | |
| 78 | // test area |
| 79 | _ui->testAreaInputEdit->installEventFilter(this); |
| 80 | } |
| 81 | |
| 82 | KeyBindingEditor::~KeyBindingEditor() |
| 83 | { |
nothing calls this directly
no test coverage detected