Add Platform::focusedView() and respective signal
Implemented as QGuiApplication::focusObjectChanged() for Qt, other frontends will have their own impl.
This commit is contained in:
@@ -11,10 +11,14 @@
|
||||
|
||||
#include "Platform_qtwidgets.h"
|
||||
#include "KDDockWidgets.h"
|
||||
|
||||
#include "qtwidgets/DebugWindow_p.h"
|
||||
#include "qtwidgets/views/ViewWrapper_qtwidgets.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include <memory.h>
|
||||
|
||||
static KDDockWidgets::Platform_qtwidgets s_platformQtWidgets;
|
||||
|
||||
using namespace KDDockWidgets;
|
||||
@@ -27,6 +31,11 @@ Platform_qtwidgets::Platform_qtwidgets()
|
||||
dv->show();
|
||||
}
|
||||
#endif
|
||||
|
||||
qApp->connect(qApp, &QGuiApplication::focusObjectChanged, qApp, [this](QObject *obj) {
|
||||
ViewWrapper *wrapper = new Views::ViewWrapper_qtwidgets(obj);
|
||||
focusedViewChanged.emit(std::shared_ptr<ViewWrapper>(wrapper));
|
||||
});
|
||||
}
|
||||
|
||||
Platform_qtwidgets::~Platform_qtwidgets()
|
||||
@@ -42,3 +51,13 @@ bool Platform_qtwidgets::hasActivePopup() const
|
||||
{
|
||||
return qApp->activePopupWidget() != nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<ViewWrapper> Platform_qtwidgets::focusedView() const
|
||||
{
|
||||
if (auto w = qobject_cast<QWidget *>(qApp->focusObject())) {
|
||||
ViewWrapper *wrapper = new Views::ViewWrapper_qtwidgets(w);
|
||||
return std::shared_ptr<ViewWrapper>(wrapper);
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user