Added DockWidget::windowActiveChanged() signal

Tracking the top-level window's 'isActiveWindow' property is difficult
since the dock widget's top-level window is changing all the time
when docking and undocking. So added a convenience signal
This commit is contained in:
Sergio Martins
2020-11-09 13:33:44 +00:00
parent 7faaf2cc69
commit b93f115b53
3 changed files with 21 additions and 1 deletions

View File

@@ -148,6 +148,7 @@ 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()
@@ -596,6 +597,16 @@ 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)
Q_EMIT windowActiveChanged(isWindowActivate);
return QWidgetAdapter::eventFilter(watched, event);
}
QPoint DockWidgetBase::Private::defaultCenterPosForFloating()
{
MainWindowBase::List mainWindows = DockRegistry::self()->mainwindows();