Fix highlight when widget has QSizePolicy::Maximum
Multisplitter::rectForDrop() was only using QWidget::maximumSize(), which doesn't need to be set. Also fix the case where the dropped widget be a complete multisplitter
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
#include "FrameworkWidgetFactory.h"
|
||||
#include "LayoutSaver.h"
|
||||
#include "multisplitter/Widget_qwidget.h"
|
||||
#include "DropArea_p.h"
|
||||
|
||||
#include <QScopedValueRollback>
|
||||
|
||||
@@ -428,12 +429,20 @@ Layouting::ItemContainer *MultiSplitter::rootItem() const
|
||||
}
|
||||
|
||||
QRect MultiSplitter::rectForDrop(const QWidgetOrQuick *widget, Location location,
|
||||
const Layouting::Item *relativeTo) const
|
||||
const Layouting::Item *relativeTo) const
|
||||
{
|
||||
Layouting::Item item(nullptr);
|
||||
item.setSize(widget->size());
|
||||
item.setMinSize(Layouting::Widget_qwidget::widgetMinSize(widget));
|
||||
item.setMaxSizeHint(widget->maximumSize());
|
||||
|
||||
if (auto fw = qobject_cast<const FloatingWindow*>(widget)) {
|
||||
Layouting::ItemContainer *root = fw->dropArea()->rootItem();
|
||||
item.setSize(root->size());
|
||||
item.setMinSize(root->minSize());
|
||||
item.setMaxSizeHint(root->maxSizeHint());
|
||||
} else {
|
||||
item.setSize(widget->size());
|
||||
item.setMinSize(Layouting::Widget_qwidget::widgetMinSize(widget));
|
||||
item.setMaxSizeHint(Layouting::Widget_qwidget::widgetMaxSize(widget));
|
||||
}
|
||||
|
||||
Layouting::ItemContainer *container = relativeTo ? relativeTo->parentContainer()
|
||||
: m_rootItem;
|
||||
|
||||
@@ -5433,12 +5433,28 @@ void TestDocks::tst_maximumSizePolicy()
|
||||
auto oldFw = dock1->window();
|
||||
dock1->close();
|
||||
dock1->show();
|
||||
auto oldFw2 = dock1->window();
|
||||
|
||||
QVERIFY(dock1->window()->height() <= maxHeight + 20); // + 20 as the floating window is a bit bigger, due to margins etc.
|
||||
QVERIFY(dock1->height() <= maxHeight);
|
||||
|
||||
auto m1 = createMainWindow();
|
||||
auto dock2 = createDockWidget("dock2", new QWidget());
|
||||
m1->addDockWidget(dock2, Location_OnTop);
|
||||
m1->resize(2000, 3000);
|
||||
|
||||
// Make the floating window big, and see if the suggested highlight is still small
|
||||
dock1->window()->resize(QSize(dock1->width(), 800));
|
||||
|
||||
const QRect highlightRect = m1->multiSplitter()->rectForDrop(dock1->window(), Location_OnBottom, nullptr);
|
||||
QVERIFY(highlightRect.height() <= maxHeight + 20);
|
||||
|
||||
// Now drop it, and check too
|
||||
m1->addDockWidget(dock1, Location_OnBottom);
|
||||
QVERIFY(dock1->height() <= maxHeight);
|
||||
|
||||
delete oldFw;
|
||||
delete dock1->window();
|
||||
delete oldFw2;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
||||
Reference in New Issue
Block a user