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

Settings save on application exit does not work on macOS #4601

Open
slicerbot opened this issue Mar 13, 2020 · 6 comments
Open

Settings save on application exit does not work on macOS #4601

slicerbot opened this issue Mar 13, 2020 · 6 comments
Milestone

Comments

@slicerbot
Copy link
Collaborator

This issue was created automatically from an original Mantis Issue. Further discussion may take place here.

@slicerbot slicerbot added this to the Slicer 4.11.0 milestone Mar 13, 2020
@lassoan
Copy link
Contributor

lassoan commented Mar 26, 2020

@pieper can you still reproduce this? (it works well on Windows)

@pieper
Copy link
Member

pieper commented Mar 26, 2020

Yes, definitely still an issue on mac.

@jcfr
Copy link
Member

jcfr commented Mar 26, 2020

Relevant code is here for saving the settings:

QSettings settings;
settings.beginGroup("MainWindow");
bool restore = settings.value("RestoreGeometry", false).toBool();
if (restore)
{
settings.setValue("geometry", q->saveGeometry());
settings.setValue("windowState", q->saveState());
settings.setValue("layout", this->LayoutManager->layout());
}
settings.endGroup();
Self::writeRecentlyLoadedFiles(this->RecentlyLoadedFileProperties);

and here for reading them:

settings.beginGroup("MainWindow");
q->setToolButtonStyle(settings.value("ShowToolButtonText").toBool()
? Qt::ToolButtonTextUnderIcon : Qt::ToolButtonIconOnly);
bool restore = settings.value("RestoreGeometry", false).toBool();
if (restore)
{
q->restoreGeometry(settings.value("geometry").toByteArray());
q->restoreState(settings.value("windowState").toByteArray());
this->LayoutManager->setLayout(settings.value("layout").toInt());
}
settings.endGroup();

@jamesobutler
Copy link
Contributor

I tested using latest nightly and indeed it doesn’t appear to work on macOS. After the main window loads in the python interactor I did slicer.util.mainWindow().restoreGeometry(qt.QSettings().value("MainWindow/geometry")) which does restore it though.

Can anyone confirm if this is also an issue on Linux as well?

https://doc.qt.io/archives/qt-5.10/restoring-geometry.html

On X11, this might not work because an invisible window does not have a frame yet. The window manager will decorate the window later. When this happens, the window shifts towards the bottom/right corner of the screen depending on the size of the decoration frame. Although X provides a way to avoid this shift, some window managers fail to implement this feature.

@pieper
Copy link
Member

pieper commented Jun 5, 2020

On linux the geometry restores correctly for me (2020-06-05 slicer, ubuntu 18.04, openbox window manager).

@jamesobutler jamesobutler changed the title Settings save on application exit does not work Settings save on application exit does not work on macOS Apr 8, 2021
@pieper pieper removed their assignment Apr 9, 2021
@lassoan
Copy link
Contributor

lassoan commented Sep 14, 2021

The issue seems to be with restore. The geometry is restored on macOS using the script only after the application has started up completely.

@sjh26 sjh26 modified the milestones: Slicer 4.13, Slicer 5.1 Dec 14, 2021
@lassoan lassoan modified the milestones: Slicer 5.1, Backlog Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

6 participants