qtquick: Implement View::isVisible/setVisible
This commit is contained in:
@@ -22,6 +22,7 @@ View_qtquick::View_qtquick(KDDockWidgets::Controller *controller, Type type,
|
||||
, View(controller, type, this)
|
||||
{
|
||||
qApp->installEventFilter(this);
|
||||
setVisible(false);
|
||||
|
||||
// setSize(800, 800);
|
||||
}
|
||||
|
||||
@@ -105,11 +105,12 @@ public:
|
||||
|
||||
bool isVisible() const override
|
||||
{
|
||||
return {};
|
||||
return QQuickItem::isVisible();
|
||||
}
|
||||
|
||||
void setVisible(bool) override
|
||||
void setVisible(bool is) override
|
||||
{
|
||||
QQuickItem::setVisible(is);
|
||||
}
|
||||
|
||||
void move(int x, int y) override
|
||||
@@ -165,8 +166,8 @@ public:
|
||||
}
|
||||
|
||||
// Mimic QWidget::setParent(), hide widget when setting parent
|
||||
if (!parentItem)
|
||||
setVisible(false);
|
||||
// if (!parentItem) // TODOv2: Why was this if needed, QWidget hides unconditionally
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
void raiseAndActivate() override
|
||||
|
||||
@@ -50,6 +50,33 @@ TEST_CASE("View::setParent()")
|
||||
delete rootView2;
|
||||
}
|
||||
|
||||
TEST_CASE("View::isVisible")
|
||||
{
|
||||
auto rootView = Platform::instance()->tests_createView();
|
||||
CHECK(!rootView->isVisible());
|
||||
|
||||
rootView->setVisible(true);
|
||||
CHECK(rootView->isVisible());
|
||||
|
||||
// Changing parent will make it hide
|
||||
auto view2 = Platform::instance()->tests_createView();
|
||||
view2->setVisible(true);
|
||||
CHECK(view2->isVisible());
|
||||
view2->setParent(rootView);
|
||||
CHECK(!view2->isVisible());
|
||||
|
||||
view2->setVisible(true);
|
||||
|
||||
// Hiding the parent should hide the children
|
||||
CHECK(view2->isVisible());
|
||||
CHECK(rootView->isVisible());
|
||||
rootView->setVisible(false);
|
||||
CHECK(!view2->isVisible());
|
||||
CHECK(!rootView->isVisible());
|
||||
|
||||
delete rootView;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int exitCode = 0;
|
||||
|
||||
Reference in New Issue
Block a user