Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing page size in first page to wide screen will reset after app relaunch #710

Open
sriharshachilakapati opened this issue Nov 26, 2022 · 2 comments
Labels

Comments

@sriharshachilakapati
Copy link

Steps to reproduce:

  1. Create a new document. First page will be in 4:3 regular by default.
  2. Write something on it.
  3. Change page size to Wide (16:9) from the menu.
  4. See changes in the UI.
  5. Save the document and quit.
  6. Reopen OpenBoard.
  7. Find page size set back to 4:3 in old document.

Can also be verified by exporting the document in BRD format and opening page000.svg and it will have ub:nominal-size="1280x960" where-as it should actually be ub:nominal-size="1696x960"

Running OpenBoard 1.6.4 on Manjaro Linux, installed from FlatHub. Would be happy to share a sample document for reproducing if required.

@letsfindaway
Copy link
Collaborator

Thanks for reporting.

Confirmed and reproducible.

@letsfindaway
Copy link
Collaborator

letsfindaway commented Nov 27, 2022

Changing the page size is not considered to be a modification of the page and does therefore not trigger saving the page before leaving. As soon as you make some modification to the page after changing the size, the scene is persisted and the new page size is correctly saved.

So the issue only appears if you modify the page size only and nothing else.

My proposal is to modify the following piece of code:

void UBBoardController::setPageSize(QSize newSize)
{
if (mActiveScene->nominalSize() != newSize)
{
mActiveScene->setNominalSize(newSize);
saveViewState();
updateSystemScaleFactor();
updatePageSizeState();
adjustDisplayViews();
QDateTime now = QDateTime::currentDateTime();
selectedDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(now));
UBSettings::settings()->pageSize->set(newSize);
}
}

Add after line 2061:

        mActiveScene->setModified(true);

Edit: a better way would be to move this to UBGraphicsScene as follows:

void UBGraphicsScene::setNominalSize(const QSize& pSize)
{
    if (nominalSize() != pSize)
    {
        mNominalSize = pSize;
        setModified(true);    // modifying the size modifies the scene

        // force redrawing the background
        foreach(QGraphicsView* view, views())
        {
            view->resetCachedContent();
        }

        if(mDocument)
            mDocument->setDefaultDocumentSize(pSize);
    }
}

This makes setting the flag more local. Additionally I added a resetCachedContent to immediately redraw the page size rectangle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants