diff --git a/src/private/multisplitter/Item.cpp b/src/private/multisplitter/Item.cpp index b3182967..24f1783f 100644 --- a/src/private/multisplitter/Item.cpp +++ b/src/private/multisplitter/Item.cpp @@ -1189,9 +1189,16 @@ QRect ItemContainer::suggestedDropRect(QSize minSize, const Item *relativeTo, Lo const int count = sizes.count(); if (relativeTo && count == 1) { - // If it's the only item then the result is that it's relative to the whole layout - // So simplify our code - relativeTo = nullptr; + + // When the container only has one item we can do some simplifications + + if (isRoot()) { + // Means the result is relative to the whole window + relativeTo = nullptr; + } else { + // Do it relative to this container instead + return parentContainer()->suggestedDropRect(minSize, this, loc); + } } if (relativeTo) { diff --git a/src/private/multisplitter/tests/tst_multisplitter.cpp b/src/private/multisplitter/tests/tst_multisplitter.cpp index c4e63542..6aad0155 100644 --- a/src/private/multisplitter/tests/tst_multisplitter.cpp +++ b/src/private/multisplitter/tests/tst_multisplitter.cpp @@ -185,6 +185,7 @@ private Q_SLOTS: void tst_ensureEnoughSize(); void tst_turnIntoPlaceholder(); void tst_suggestedRect(); + void tst_suggestedRect2(); void tst_insertAnotherRoot(); void tst_misc1(); void tst_misc2(); @@ -829,6 +830,23 @@ void TestMultiSplitter::tst_suggestedRect() QVERIFY(serializeDeserializeTest(root)); } +void TestMultiSplitter::tst_suggestedRect2() +{ + // Tests a bug where the inner drop locations didn't work when there was a nested container + // Like container >> container >> Item + + auto root1 = createRoot(); + auto root2 = createRoot(); + + const QSize minSize(100, 100); + Item *item = createItem(); + + root2->insertItem(item, Location_OnRight); + root1->insertItem(root2.get(), Location_OnRight); + + QVERIFY(item->parentContainer()->suggestedDropRect(minSize, item, Location_OnRight).isValid()); +} + void TestMultiSplitter::tst_insertAnotherRoot() { {