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
Convert script editor dialog to SingletonDialog #1852
Convert script editor dialog to SingletonDialog #1852
Conversation
23bb31b
to
e00ac02
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally found enough time and had the head free to look at the code, and actually also test run it on Linux and macOS.
First off: This patch looks good and the important parts work.
On macOS there is an issue with window position:
- Open the script editor dialog first
- Then open options dialog
Kind of unexpected the script editor now stays behind options.It is in front of options when opening it from options. So there seems to be some issue with the reparenting. Not yet sure what to do about this.
But one thing we actually should change in some way: If you have the script editor open and either then open or close the options dialog you loose all pending changes you had in the dialog, it completely resets.
I understand why this happens when one closes options, because this also closes the dialog and you have code to reopen it. I don't yet fully understand why this happens when options get opened. But in both cases we should ensure somehow that the unsaved state does not get lost.
Also I wonder if the dialog really needs to fully close when closing options. Maybe we can unparent it before the options actually close?
Perhaps we need to close it and re-open it from Options. It's disappointing that the re-parenting doesn't work.
I think it's forcing a
I tried that and closing Options still destroys the script editor dialog object (without closing it so that the class still thinks there is an active dialog). It appears that when the parent is set to Options, the script editor dialog gets added to the list of objects to clean up, but changing the parent doesn't remove it from the list. That's why I ended up closing it when Options is closed. I agree that it would be best if we could keep it open, but I haven't found a way to do that. |
I made a couple of changes to avoid doing a full reload when changing parents, and everything seems to be working here on my Windows 7 system. It now retains changes in progress when opening and closing Options. Unfortunately, I don't think this will resolve the window placement issue on the mac. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to get this working on macOS, without success so far. What I notice is that the parent change on the dialog happens before the options dialog is actually visible, and I think that's the culprit.
So to fix this I tried moving the handling to OptionsDialog
by implementing openEvent
and also overwriting open
. But both did not give any better result. The only thing I achieved was that then the script editor also showed up behind options on Windows.
Strangely when I did remove the parent change when opening options the dialog properly came to front when triggered by the button in renaming options.
Currently I am out of ideas what to try :(
You may have already tried this, but I just pushed a commit that moves the call to open the script editor from the main window to Options (which seems to work well here on my Win 7 system). It may be a case of the origin of the call affecting things. |
I found a reproducible exception while testing:
|
Just a quick update that this does still not work on macOS. I haven't found the time yet to experiment here in depth. |
When you're testing, you might try changing Line 507 of
I'm kind of grasping at straws here, but it sounds like it might be promising. Sorry I can't test it here, but I don't have access to a macos system. |
I tracked the events triggered when opening the OptionsDialog object to try to identify the latest event to use for triggering the re-parenting of the ScriptEditorDialog. It appears that the The list of triggered events on my Windows 7 system when opening and then closing OptionsDialog is:
Most of the events between EDIT: I used a simple class that I threw together to look after logging the events to a file, in case you want to try logging the events generated on the macos to confirm the order. The class can be found at: |
@rdswift I tried again to get the workflow of having the script editor dialog open first, then opening options on macOS running. No matter what I tried, the script editor stays behind options. One can interact with it (at least as far as it is visible), but cannot get it to front. I also tried making the window modal before re-parenting. Then it was in front, but exclusive and one could not interact with options. Changing modal back after showing the window does not change this. Changing it back before showing has no effect, resulting in the original behavior. Not really sure what to do about this. |
That's disappointing. Perhaps as a really ugly hack we could close the script editor then reopen it again, but that would likely not allow us to save any unsaved changes first. I'll do some experimenting to see if I can come up with anything better. |
I wonder if the answer might lay in https://doc.qt.io/qt-5/macos-issues.html#using-native-cocoa-panels ? |
@rdswift I had no luck with getting this to work on macOS. I was hopeful about your latest patches, but they did not work. Also it is not solely a timing issue as I had first thought, delaying the opening does not work. I found not way to get the script editor show up in front of the option dialog if the script editor is opened earlier. I tend toward just accepting this as a known issue on macOS. @zas What do you think? |
Well, if this patch improves user experience on all platforms but on macos, I'd say it is still an improvement, and should be merged. |
Ok, in this case let's merge, but we should skip the last three commits. I can test this one more time and then merge this locally, and also add the ticket. |
Darn. I had high hopes for that solution. I'm all out of suggestions.
I'll roll back to commit 265704a and rebase to get rid of the conflicts then. |
367786d
to
0277ac7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I added PICARD-2249 about the macOS dialog issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm
Summary
Problem
When the file naming script editor is open from the main screen, the user is unable to open the Settings dialog. This is not intuitive behavior.
Solution
Convert the file naming script editor to a
SingletonDialog
and switch its parent setting to match the currently active window (main screen or settings dialog).Action