Skip to content
Permalink
Browse files

check key press event.(refs #79)

  • Loading branch information...
haraki committed Jun 19, 2019
1 parent c1b1157 commit 345bdc5809fe6bc2710d7d27e4dc7135b1c98c41
Showing with 39 additions and 0 deletions.
  1. +30 −0 bookmarkeditdialog.cpp
  2. +1 −0 bookmarkeditdialog.h
  3. +8 −0 bookmarkeditdialog.ui
@@ -1,6 +1,7 @@
#include <QFileDialog>
#include <QPushButton>
#include <QStyle>
#include <QKeyEvent>
#include <QDebug>
#include "bookmarkeditdialog.h"
#include "ui_bookmarkeditdialog.h"
@@ -66,6 +67,35 @@ void BookmarkEditDialog::on_selectPathToolButton_clicked()
checkNamePathEmpty();
}

void BookmarkEditDialog::keyPressEvent(QKeyEvent *e)
{
switch(e->key())
{
case Qt::Key_N:
ui->nameLineEdit->setFocus();

e->accept();

break;

case Qt::Key_Return:
if(ui->buttonBox->button(QDialogButtonBox::Ok)->isEnabled())
{
accept();

e->accept();
}
break;

case Qt::Key_Escape:
reject();

e->accept();

break;
}
}

void BookmarkEditDialog::checkNamePathEmpty()
{
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!ui->nameLineEdit->text().isEmpty() && !ui->pathLineEdit->text().isEmpty());
@@ -29,6 +29,7 @@ private slots:
void on_selectPathToolButton_clicked();

private:
void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
void checkNamePathEmpty();

Ui::BookmarkEditDialog *ui;
@@ -40,6 +40,9 @@
<property name="text">
<string>...</string>
</property>
<property name="shortcut">
<string>P</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
@@ -57,6 +60,11 @@
</item>
</layout>
</widget>
<tabstops>
<tabstop>nameLineEdit</tabstop>
<tabstop>selectPathToolButton</tabstop>
<tabstop>pathLineEdit</tabstop>
</tabstops>
<resources/>
<connections>
<connection>

0 comments on commit 345bdc5

Please sign in to comment.
You can’t perform that action at this time.