qtquick: Implement View::rootView()
This commit is contained in:
@@ -11,9 +11,11 @@
|
||||
|
||||
#include "View_qtquick.h"
|
||||
#include "private/Utils_p.h"
|
||||
#include "ViewWrapper_qtquick.h"
|
||||
|
||||
#include <QGuiApplication>
|
||||
|
||||
using namespace KDDockWidgets;
|
||||
using namespace KDDockWidgets::Views;
|
||||
|
||||
namespace KDDockWidgets::Views {
|
||||
@@ -347,5 +349,13 @@ void View_qtquick::setSize(int w, int h)
|
||||
QQuickItem::setSize(QSizeF(w, h));
|
||||
}
|
||||
|
||||
std::shared_ptr<ViewWrapper> View_qtquick::rootView() const
|
||||
{
|
||||
if (Window::Ptr window = windowHandle())
|
||||
return window->rootView();
|
||||
|
||||
qWarning() << Q_FUNC_INFO << "No window present";
|
||||
return {};
|
||||
}
|
||||
|
||||
#include "View_qtquick.moc"
|
||||
|
||||
@@ -413,11 +413,7 @@ public:
|
||||
return child ? asQQuickWrapper(child) : nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<ViewWrapper> rootView() const override
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
std::shared_ptr<ViewWrapper> rootView() const override;
|
||||
std::shared_ptr<ViewWrapper> parentView() const override
|
||||
{
|
||||
auto p = QQuickItem::parentItem();
|
||||
|
||||
@@ -68,14 +68,16 @@ TEST_CASE("View::setParent()")
|
||||
delete rootView2;
|
||||
}
|
||||
|
||||
TEST_CASE("View::windowHandle(),Window::rootView()")
|
||||
TEST_CASE("View::windowHandle,rootView,Window::rootView")
|
||||
{
|
||||
auto rootView = Platform::instance()->tests_createView();
|
||||
auto childView = Platform::instance()->tests_createView(false, rootView);
|
||||
auto childView = Platform::instance()->tests_createView(true, rootView);
|
||||
|
||||
auto window = rootView->windowHandle();
|
||||
REQUIRE(window);
|
||||
CHECK_EQ(window->handle(), childView->windowHandle()->handle());
|
||||
CHECK(rootView->rootView()->equals(rootView));
|
||||
CHECK(childView->rootView()->equals(rootView));
|
||||
|
||||
REQUIRE(window->rootView());
|
||||
CHECK(window->rootView()->equals(rootView));
|
||||
|
||||
Reference in New Issue
Block a user