Add Platform::screenSizeFor(window), removes more asQWidget() usage

This commit is contained in:
Sergio Martins
2022-04-21 22:10:59 +01:00
parent 3f97845c9c
commit 8015e49bee
8 changed files with 32 additions and 23 deletions

View File

@@ -22,6 +22,7 @@
#include <QQuickWindow>
#include <QGuiApplication>
#include <QWindow>
#include <QScreen>
using namespace KDDockWidgets;
@@ -86,6 +87,18 @@ int Platform_qtquick::screenNumberFor(View *view) const
return -1;
}
QSize Platform_qtquick::screenSizeFor(View *view) const
{
if (auto item = qobject_cast<QQuickItem *>(view->asQObject())) {
if (QWindow *qtwindow = item->window())
if (QScreen *screen = qtwindow->screen())
return screen->size();
}
return {};
}
#ifdef DOCKS_DEVELOPER_MODE
void Platform_qtquick::tests_initTests() const