Move DockWidgetBase::eventFilter() into the private class
Fixes issue #151 where the user is overriding eventFilter too and getting into some edge cases. Could be worked around in user code, but it's always good to have less protected and private API in public classes.
This commit is contained in:
@@ -52,7 +52,6 @@ DockWidgetBase::DockWidgetBase(const QString &name, Options options,
|
||||
qWarning() << Q_FUNC_INFO << "Name can't be null";
|
||||
|
||||
setAttribute(Qt::WA_PendingMoveEvent, false);
|
||||
qApp->installEventFilter(this);
|
||||
}
|
||||
|
||||
DockWidgetBase::~DockWidgetBase()
|
||||
@@ -541,16 +540,6 @@ void DockWidgetBase::updateFloatAction()
|
||||
d->updateFloatAction();
|
||||
}
|
||||
|
||||
bool DockWidgetBase::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
const bool isWindowActivate = event->type() == QEvent::WindowActivate;
|
||||
const bool isWindowDeactivate = event->type() == QEvent::WindowDeactivate;
|
||||
if ((isWindowActivate || isWindowDeactivate) && watched == window())
|
||||
Q_EMIT windowActiveAboutToChange(isWindowActivate);
|
||||
|
||||
return QWidgetAdapter::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
QPoint DockWidgetBase::Private::defaultCenterPosForFloating()
|
||||
{
|
||||
MainWindowBase::List mainWindows = DockRegistry::self()->mainwindows();
|
||||
@@ -562,6 +551,16 @@ QPoint DockWidgetBase::Private::defaultCenterPosForFloating()
|
||||
return mw->geometry().center();
|
||||
}
|
||||
|
||||
bool DockWidgetBase::Private::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
const bool isWindowActivate = event->type() == QEvent::WindowActivate;
|
||||
const bool isWindowDeactivate = event->type() == QEvent::WindowDeactivate;
|
||||
if ((isWindowActivate || isWindowDeactivate) && watched == q->window())
|
||||
Q_EMIT q->windowActiveAboutToChange(isWindowActivate);
|
||||
|
||||
return QObject::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
void DockWidgetBase::Private::updateTitle()
|
||||
{
|
||||
if (q->isFloating())
|
||||
|
||||
Reference in New Issue
Block a user