Give Auto Complete menu some time to disappear
This commit is contained in:
parent
90317143fb
commit
3872ddb36a
|
@ -3,6 +3,8 @@
|
||||||
#include <QtWidgets/QGraphicsDropShadowEffect>
|
#include <QtWidgets/QGraphicsDropShadowEffect>
|
||||||
#include <QtWidgets/QVBoxLayout>
|
#include <QtWidgets/QVBoxLayout>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QDebug>
|
||||||
#include "qtmaterialflatbutton.h"
|
#include "qtmaterialflatbutton.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -50,7 +52,7 @@ void QtMaterialAutoCompletePrivate::init()
|
||||||
menuLayout->setContentsMargins(0, 0, 0, 0);
|
menuLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
menuLayout->setSpacing(0);
|
menuLayout->setSpacing(0);
|
||||||
|
|
||||||
QObject::connect(q, SIGNAL(textChanged(QString)), q, SLOT(updateResults(QString)));
|
QObject::connect(q, SIGNAL(textEdited(QString)), q, SLOT(updateResults(QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -86,7 +88,7 @@ void QtMaterialAutoComplete::updateResults(QString text)
|
||||||
QString lookup(trimmed.toLower());
|
QString lookup(trimmed.toLower());
|
||||||
QStringList::iterator i;
|
QStringList::iterator i;
|
||||||
for (i = d->dataSource.begin(); i != d->dataSource.end(); ++i) {
|
for (i = d->dataSource.begin(); i != d->dataSource.end(); ++i) {
|
||||||
if (i->toLower().startsWith(lookup)) {
|
if (i->toLower().indexOf(lookup) != -1) {
|
||||||
results.push_back(*i);
|
results.push_back(*i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,7 +174,13 @@ bool QtMaterialAutoComplete::eventFilter(QObject *watched, QEvent *event)
|
||||||
switch (event->type())
|
switch (event->type())
|
||||||
{
|
{
|
||||||
case QEvent::MouseButtonPress: {
|
case QEvent::MouseButtonPress: {
|
||||||
d->menu->hide();
|
QTimer::singleShot(300, this, [=](){
|
||||||
|
d->menu->hide();
|
||||||
|
});
|
||||||
|
QtMaterialFlatButton *widget;
|
||||||
|
if ((widget = static_cast<QtMaterialFlatButton *>(watched))) {
|
||||||
|
setText(widget->text());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue