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

Gui: Allow to unset modified state #13200

Merged
merged 1 commit into from Apr 2, 2024

Conversation

yorikvanhavre
Copy link
Member

@yorikvanhavre yorikvanhavre commented Mar 28, 2024

GuiDocuments have a "Modified" attribute that says if the doc has been modified or not (and prints an * in the titlebar). This attribute is read-only in the python interface (only getter is defined).

With NativeIFC, we are handling IFC files natively in FreeCAD, so all file loading/saving is done inside the module already, there is no more saving to .FCStd files. Last bit missing, not be annoyed by FreeCAD that the document has not been saved.

So this implements a resetModified() python method to unset the Modified flag.

I considered making the Modified attribute writable (implement a setter), but I'm not sure... People could play wrongly with that and they would loose the warning to save the file when closing FreeCAD. I thought maybe more interesting to implement a specific method, so people would be more aware of what they are doing and would be less prone to reset the modified state accidentally.

Not sure if that makes sense... What do you think @wwmayer ? @adrianinsaval ?

EDIT Following Werner's suggestion, this now sets the Modified attribute as read/write (previously read-only)

@github-actions github-actions bot added the Core Issue or PR touches core sections (App, Gui, Base) of FreeCAD label Mar 28, 2024
@wwmayer
Copy link
Contributor

wwmayer commented Mar 28, 2024

You can use Gui.getMainWindow().setWindowModified(False)

@yorikvanhavre
Copy link
Member Author

oh excellent! this is unneeded then.
thanks Werner!

@yorikvanhavre
Copy link
Member Author

Actually that does not solve the problem, using setWindowModified() does not really mark the document as saved, only the window title... so the MDI tab still has the asterisk, and the warning still appear when closing the document...

I'll reopen this issue for now

@yorikvanhavre yorikvanhavre reopened this Mar 29, 2024
@wwmayer
Copy link
Contributor

wwmayer commented Mar 29, 2024

Shouldn't the method be called setModified() that accepts a boolean argument? This way it's consistent with the C++ API and also allows it to set the modified flag if needed.

@yorikvanhavre
Copy link
Member Author

Yes you are right... That was my first question and I was hesitating in doing that, but indeed since it's generally done elsewhere in FreeCAD it seems safe to do it here. I'll refactor this PR

@yorikvanhavre yorikvanhavre reopened this Apr 2, 2024
@yorikvanhavre yorikvanhavre marked this pull request as ready for review April 2, 2024 11:53
@wwmayer wwmayer merged commit 988e867 into FreeCAD:main Apr 2, 2024
10 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core Issue or PR touches core sections (App, Gui, Base) of FreeCAD
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants