mirror of
https://github.com/leozide/leocad
synced 2025-01-29 20:34:50 +01:00
Handle return key events in the search edit.
This commit is contained in:
parent
d39ec689a5
commit
bb8e85d2c1
2 changed files with 21 additions and 1 deletions
|
@ -8,8 +8,8 @@ lcSetsDatabaseDialog::lcSetsDatabaseDialog(QWidget* Parent)
|
|||
ui(new Ui::lcSetsDatabaseDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->SearchEdit->installEventFilter(this);
|
||||
|
||||
connect(ui->SearchEdit, SIGNAL(returnPressed()), this, SLOT(on_SearchButton_clicked()));
|
||||
connect(ui->SetsTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(accept()));
|
||||
connect(this, SIGNAL(finished(int)), this, SLOT(Finished(int)));
|
||||
connect(&mNetworkManager, SIGNAL(finished(QNetworkReply*)), SLOT(DownloadFinished(QNetworkReply*)));
|
||||
|
@ -34,6 +34,24 @@ QString lcSetsDatabaseDialog::GetSetDescription() const
|
|||
return Current ? Current->text(1) : QString();
|
||||
}
|
||||
|
||||
bool lcSetsDatabaseDialog::eventFilter(QObject* Object, QEvent* Event)
|
||||
{
|
||||
if (Event->type() == QEvent::KeyPress)
|
||||
{
|
||||
QKeyEvent* KeyEvent = static_cast<QKeyEvent*>(Event);
|
||||
|
||||
int Key = KeyEvent->key();
|
||||
if (Key == Qt::Key_Return || Key == Qt::Key_Enter)
|
||||
{
|
||||
KeyEvent->accept();
|
||||
on_SearchButton_clicked();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return QDialog::eventFilter(Object, Event);
|
||||
}
|
||||
|
||||
void lcSetsDatabaseDialog::accept()
|
||||
{
|
||||
QTreeWidgetItem* Current = ui->SetsTree->currentItem();
|
||||
|
|
|
@ -23,6 +23,8 @@ public:
|
|||
return mInventory;
|
||||
}
|
||||
|
||||
virtual bool eventFilter(QObject* Object, QEvent* Event) override;
|
||||
|
||||
public slots:
|
||||
void DownloadFinished(QNetworkReply* Reply);
|
||||
void on_SearchButton_clicked();
|
||||
|
|
Loading…
Add table
Reference in a new issue