-
-
Notifications
You must be signed in to change notification settings - Fork 362
wxGUI/main_window: fix close map notebook page #2072
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
wxGUI/main_window: fix close map notebook page #2072
Conversation
Only in single window mode.
There is also #1789. |
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 directly push my changes into your PR @tmszi but it did not work, so I am putting it here. You can test it, when you switch map notebook tabs and then close the given map notebook tab it should close the right display tab - for me it works good.
I would place pgnum_dict (cause map display index can be different from display tab index):
main_window/frame.py:
def CanCloseDisplay(askIfSaveWorkspace):
"""Callback to check if user wants to close display.
Map Display index can be different from index in Display tab."""
pgnum_dict = {}
pgnum_dict["display"] = self.notebookLayers.GetPageIndex(page)
pgnum_dict["mapnotebook"] = self.mapnotebook.GetPageIndex(mapdisplay)
name = self.notebookLayers.GetPageText(pgnum_dict["display"])
caption = _("Close Map Display {}").format(name)
if not askIfSaveWorkspace or (
askIfSaveWorkspace and self.workspace_manager.CanClosePage(caption)
):
return pgnum_dict
return None
def _closePageNoEvent(self, pgnum_dict):
"""Close page and destroy map display without
generating notebook page closing event"""
self.notebookLayers.Unbind(FN.EVT_FLATNOTEBOOK_PAGE_CLOSING)
self.notebookLayers.DeletePage(pgnum_dict["display"])
self.notebookLayers.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CLOSING, self.OnCBPageClosing)
self.mapnotebook.DeletePage(pgnum_dict["mapnotebook"])
mapdisp/frame.py:
def OnCloseWindow(self, event, askIfSaveWorkspace=True):
"""Window closed.
Also close associated layer tree page
"""
Debug.msg(2, "MapPanel.OnCloseWindow()")
if self.canCloseDisplayCallback:
pgnum_dict = self.canCloseDisplayCallback(askIfSaveWorkspace=askIfSaveWorkspace)
if pgnum_dict["display"] is not None:
self.CleanUp()
if pgnum_dict["display"] > -1:
self.closingDisplay.emit(pgnum_dict=pgnum_dict)
# Destroy is called when notebook page is deleted
else:
self.CleanUp()
self.Destroy()
I have tested the Close current mapdisplay and Close all mapdisplays from Settings and it works also good after above-shared changes. @tmszi please could you also update a list of shorcuts so that the map notebook page can be also closed by CTRL+W shortcut? |
To avoid incorrectly closing the map notebook page, if the pages of the map notebook change position by dragging and dropping.
All right, I've applied and tested your changes, and it's working as expected :-).
Yes, you're right. |
When the map display notebook page has a vector/raster map displayed and the page is closed, and pressed the Cancel button in the Close Map Display dialog, canCloseDisplayCallback function return None not dict value.
The keyboard shortcut Ctrl+W (close map notebook page) works for me without any changes. |
It is one thing and the second one is the problem when you switch map notebook tabs. I tried to incorporate some changes that repair closing when someone switch map notebook pages. Feel free to comment. I think that the whole concept of closing events is a bit strange (we talked about it with @petrasovaa a longer time ago but actually I am not sure what was the result?).
Right, I have tested all functionalities - normal closing, closing from settings, and CTRL+W shortcut and all works for me as expected :-) |
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 just realize that I have used outdated terminology, still living in the time when the Layers tab was called Display, even though it was my own idea to rename the Display back to Layers :-) Please @tmszi could you just replace "Display" with "Layers"? Sorry for the confusion. :-)
…ored in the dict Fixes closing the map display notebook layers tree page in multi window mode.
This commit ce0586d solve bug with closing map display notebook layers tree page in multi window mode. |
Yes I could. Do you mean name of layers notebook page and name of the map display notebook page (e.g. Map Display 1 -> Map Layers 1)? Default: Expected: |
No, no, sorry, I did not express well, I meant just to have the terminology correct according to #1927. So, in the code to change the Display tab name to Layers tab name, e.g. pgnum_dict["layers"]. But it is a detail, if you prefer to let it as it is e.g. pgnum_dict["display"], it is okay. :-) |
I have looked that you put a good explanation of the dictionary into the docs, so you can let it as it is probably. :-) |
Yes, you're right. I changed the display dictionary key name to layers in this commit fee16af. |
Only in single window mode. * wxGUI/main_window: fix getting correct map notebook page index To avoid incorrectly closing the map notebook page, if the pages of the map notebook change position by dragging and dropping. * wxGUI/mapdisp: fix checking pgnum_dict variable if it's None When the map display notebook page has a vector/raster map displayed and the page is closed, and pressed the Cancel button in the Close Map Display dialog, canCloseDisplayCallback function return None not dict value. * wxGUI/lmgr: actual closed map display notebook layers tree page is stored in the dict Fixes closing the map display notebook layers tree page in multi window mode. Co-authored-by: Linda Kladivova <[email protected]>
Only in single window mode. * wxGUI/main_window: fix getting correct map notebook page index To avoid incorrectly closing the map notebook page, if the pages of the map notebook change position by dragging and dropping. * wxGUI/mapdisp: fix checking pgnum_dict variable if it's None When the map display notebook page has a vector/raster map displayed and the page is closed, and pressed the Cancel button in the Close Map Display dialog, canCloseDisplayCallback function return None not dict value. * wxGUI/lmgr: actual closed map display notebook layers tree page is stored in the dict Fixes closing the map display notebook layers tree page in multi window mode. Co-authored-by: Linda Kladivova <[email protected]>
Only in single window mode. * wxGUI/main_window: fix getting correct map notebook page index To avoid incorrectly closing the map notebook page, if the pages of the map notebook change position by dragging and dropping. * wxGUI/mapdisp: fix checking pgnum_dict variable if it's None When the map display notebook page has a vector/raster map displayed and the page is closed, and pressed the Cancel button in the Close Map Display dialog, canCloseDisplayCallback function return None not dict value. * wxGUI/lmgr: actual closed map display notebook layers tree page is stored in the dict Fixes closing the map display notebook layers tree page in multi window mode. Co-authored-by: Linda Kladivova <[email protected]>
Describe the bug
Closing the map notebook page ends with an error message.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Closing the map notebook page should work without an error message.
System description:
Additional context
Only in single window mode.