diff --git a/app/qml/main.qml b/app/qml/main.qml index 9e17f9ad..7dfcbc80 100644 --- a/app/qml/main.qml +++ b/app/qml/main.qml @@ -165,6 +165,10 @@ ApplicationWindow { project.uiState.value("mainSplitViewState"))) panelSplitView.restoreState(project.uiState.base64ToBinary( project.uiState.value("panelSplitViewState"))) + } else { + // We should still restore the default sizes for all other cases, though. + // We only need to restore panelSplitView's preferredWidth, as mainSplitView fills. + panelSplitView.SplitView.preferredWidth = panelSplitView.defaultPreferredWidth } } } @@ -224,8 +228,10 @@ ApplicationWindow { implicitHeight: 4 } + readonly property int defaultPreferredWidth: 240 + SplitView.minimumWidth: 200 - SplitView.preferredWidth: 240 + SplitView.preferredWidth: defaultPreferredWidth SplitView.maximumWidth: window.width / 3 Ui.ColourPanel { diff --git a/tests/auto/tst_app.cpp b/tests/auto/tst_app.cpp index 3e032352..d4d9e49c 100644 --- a/tests/auto/tst_app.cpp +++ b/tests/auto/tst_app.cpp @@ -65,6 +65,7 @@ private Q_SLOTS: void recentFiles(); void newProjectSizeFromClipboard_data(); void newProjectSizeFromClipboard(); + void splitViewStateAcrossProjects(); // Tools, misc. void animationPlayback_data(); @@ -246,7 +247,6 @@ void tst_App::repeatedNewProject() { QFETCH(ProjectTypeVector, projectTypes); - int i = -1; foreach (auto projectType, projectTypes) { // Shouldn't crash on repeated opening of new projects. QVERIFY2(createNewProject(projectType), failureMessage); @@ -770,6 +770,35 @@ void tst_App::newProjectSizeFromClipboard() QTRY_VERIFY(!newImageProjectPopup->property("visible").toBool()); } +void tst_App::splitViewStateAcrossProjects() +{ + QVERIFY2(createNewLayeredImageProject(), failureMessage); + + // Make the panel split item larger. + QPointer mainSplitView = window->findChild("mainSplitView"); + QVERIFY(mainSplitView); + QPointer panelSplitView = window->findChild("panelSplitView"); + QVERIFY(panelSplitView); + const qreal defaultPanelSplitItemWidth = panelSplitView->width(); + QPointer mainSplitViewHandle = findSplitViewHandle("mainSplitView", 0); + QVERIFY(mainSplitViewHandle); + const QPoint mainSplitViewHandleCentreAfterMoving = QPoint( + mainSplitView->width() / 2, mainSplitView->height() / 2); + QVERIFY2(dragSplitViewHandle("mainSplitView", 0, mainSplitViewHandleCentreAfterMoving), failureMessage); + const qreal resizedPanelSplitItemWidth = panelSplitView->width(); + QVERIFY(resizedPanelSplitItemWidth > defaultPanelSplitItemWidth); + + // Save the project with the new split size. + QVERIFY(layeredImageProject->canSave()); + const QUrl saveUrl = QUrl::fromLocalFile(tempProjectDir->path() + QLatin1String("/splitViewStateAcrossProjects.slp")); + layeredImageProject->saveAs(saveUrl); + QVERIFY(!layeredImageProject->hasUnsavedChanges()); + + // Create a new project. It should have the default panel split item size. + QVERIFY2(createNewLayeredImageProject(), failureMessage); + QCOMPARE(panelSplitView->width(), defaultPanelSplitItemWidth); +} + void tst_App::animationPlayback_data() { addImageProjectTypes(); @@ -888,7 +917,6 @@ void tst_App::animationPlayback() // Save. const QUrl saveUrl = QUrl::fromLocalFile(tempProjectDir->path() + QLatin1String("/animationStuffSaved.slp")); layeredImageProject->saveAs(saveUrl); - QVERIFY_NO_CREATION_ERRORS_OCCURRED(); QVERIFY(!layeredImageProject->hasUnsavedChanges()); // Close. diff --git a/tests/shared/testhelper.cpp b/tests/shared/testhelper.cpp index baa3af3b..80be6357 100644 --- a/tests/shared/testhelper.cpp +++ b/tests/shared/testhelper.cpp @@ -1995,13 +1995,6 @@ bool TestHelper::updateVariables(bool isNewProject, Project::Type projectType) return false; if (isNewProject) { - // If we're not loading a saved project (where we'd want to use the saved split sizes), - // return the SplitView back to roughly its original size. - // It doesn't matter if it's not perfect, it's just important that it's not already - // at its max width so that the tests can resize it. - if (!dragSplitViewHandle("mainSplitView", 0, QPoint(window->width() - 240, window->height() / 2))) - return false; - // Restore the colour panel's contentY to the default. QQuickItem *colourPanelFlickable = window->findChild("colourPanelFlickable"); VERIFY(colourPanelFlickable);