DockRegistry doesn't depend on QtWidgets anymore

This commit is contained in:
Sergio Martins
2022-05-29 20:14:25 +01:00
parent fe87380d83
commit 85f02d8ceb
2 changed files with 4 additions and 31 deletions

View File

@@ -26,8 +26,6 @@
#include "controllers/DockWidget.h"
#include "controllers/DockWidget_p.h"
#include "qtwidgets/views/Frame_qtwidgets.h"
#include <QPointer>
#include <QDebug>
#include <QGuiApplication>
@@ -670,9 +668,10 @@ bool DockRegistry::eventFilter(QObject *watched, QEvent *event)
}
} else if (event->type() == QEvent::MouseButtonPress) {
// When clicking on a MDI Frame we raise the window
if (auto frameView = firstParentOfType<Views::Frame_qtwidgets>(watched)) {
if (frameView->frame()->isMDI())
frameView->raise();
if (Controller *c = View::firstParentOfType(watched, Type::Frame)) {
auto frame = static_cast<Frame*>(c);
if (frame->isMDI())
frame->view()->raise();
}
// The following code is for hididng the overlay

View File

@@ -269,32 +269,6 @@ inline bool scalingFactorIsSupported(qreal factor)
#endif
}
template<typename T>
inline T *firstParentOfType(const QObject *child)
{
auto p = const_cast<QObject *>(child);
while (p) {
if (auto candidate = qobject_cast<T *>(p))
return candidate;
if (qobject_cast<const QWindow *>(p)) {
// Ignore QObject hierarchies spanning though multiple windows
return nullptr;
}
#ifdef KDDOCKWIDGETS_QTWIDGETS
// Ignore QObject hierarchies spanning though multiple windows
if (auto w = qobject_cast<QWidget *>(p))
if (w->isWindow())
return nullptr;
#endif
p = p->parent();
}
return nullptr;
}
};
#endif