mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-19 20:44:16 +02:00
Fix the Selection properties panel losing the height the user gave it
The panel shrank to its title bar whenever the selection had nothing it could edit (a click on an empty spot, several elements, a mix of items): its content layout used QLayout::SetMaximumSize, and an empty vertical layout's maximum height is 0. The other right-hand panels took the room, and when an element was selected again the panels were split again from their size hints, so the height the user had dragged the panel to was lost (reported by ankostis in #1439). With the default size constraint the panel keeps its height and stays blank while there is nothing to edit. The element, wire, text and shape editors draw the same: their screenshots in a 730-860 px tall panel are pixel-identical before and after. Test: tst_selectionpanelheight (on master the height goes from 560 to 19 px). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
<widget class="QWidget" name="dockWidgetContents">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMaximumSize</enum>
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
|
||||
@@ -279,6 +279,10 @@ qet_add_app_test(tst_imagehandleescape tst_imagehandleescape.cpp)
|
||||
# pixels and position; an <image> with no picture does not stop the others.
|
||||
qet_add_app_test(tst_folioimageload tst_folioimageload.cpp)
|
||||
|
||||
# The Selection properties panel keeps the height the user gave it when the
|
||||
# selection has nothing to edit for a moment (#1439).
|
||||
qet_add_app_test(tst_selectionpanelheight tst_selectionpanelheight.cpp)
|
||||
|
||||
# SVG export with smaller pictures (--svg-small-pictures, the export dialog's
|
||||
# option): a picture drawn at a tenth of its size is stored at four times
|
||||
# that, a small one whole; without the option every picture is whole.
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#include "qetapptest.h"
|
||||
|
||||
#include "projectview.h"
|
||||
#include "qetgraphicsitem/element.h"
|
||||
|
||||
#include <QDockWidget>
|
||||
|
||||
// The Selection properties panel keeps the height the user gave it when the
|
||||
// selection has nothing it can edit for a moment (#1439). It used to shrink
|
||||
// to its title bar, the other panels took the room, and an element selected
|
||||
// again brought the panel back at its default height.
|
||||
class tst_selectionpanelheight : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
QTemporaryDir m_dir;
|
||||
|
||||
private slots:
|
||||
void keepsUserHeight()
|
||||
{
|
||||
QETDiagramEditor *editor = QetAppTest::editor();
|
||||
QVERIFY(editor);
|
||||
// Tall enough to leave the panels room to be resized: at a
|
||||
// usual height every right-hand panel is at its minimum
|
||||
editor->resize(1600, 1500);
|
||||
editor->show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(editor));
|
||||
|
||||
// A copy: opening a project leaves a lock file beside it
|
||||
const QString copy = m_dir.filePath("p.qet");
|
||||
QVERIFY(QFile::copy(QFINDTESTDATA("fixtures/ten_sequential_numbers.qet"), copy));
|
||||
QVERIFY(editor->openAndAddProject(copy, false));
|
||||
Diagram *diagram = editor->currentProjectView()->currentDiagram()->diagram();
|
||||
Element *element = nullptr;
|
||||
for (QGraphicsItem *qgi : diagram->items())
|
||||
if (qgi->type() == Element::Type)
|
||||
element = static_cast<Element *>(qgi);
|
||||
QVERIFY(element);
|
||||
|
||||
auto panel = editor->findChild<QDockWidget *>("diagram_properties_editor_dock_widget");
|
||||
QVERIFY(panel);
|
||||
|
||||
// The panel follows the selection through a queued connection
|
||||
auto select = [&](Element *e) {
|
||||
diagram->clearSelection();
|
||||
if (e)
|
||||
e->setSelected(true);
|
||||
QTest::qWait(200);
|
||||
};
|
||||
|
||||
select(element);
|
||||
const int start = panel->height();
|
||||
// What dragging the separator above the panel does
|
||||
editor->resizeDocks({panel}, {start + 150}, Qt::Vertical);
|
||||
QTest::qWait(200);
|
||||
const int user = panel->height();
|
||||
QVERIFY2(user > start, "the panel could not be made taller");
|
||||
|
||||
select(nullptr);
|
||||
QCOMPARE(panel->height(), user);
|
||||
select(element);
|
||||
QCOMPARE(panel->height(), user);
|
||||
}
|
||||
};
|
||||
|
||||
QET_APP_TEST_MAIN(tst_selectionpanelheight)
|
||||
|
||||
#include "tst_selectionpanelheight.moc"
|
||||
Reference in New Issue
Block a user