Skip to content

Commit

Permalink
honor confirm close settings when quitting (napari#4700)
Browse files Browse the repository at this point in the history
* honor confirm close settings on quit

* update string

* Update napari/settings/_application.py

Co-authored-by: Grzegorz Bokota <[email protected]>

* Update napari/settings/_application.py

Co-authored-by: Grzegorz Bokota <[email protected]>

Co-authored-by: Grzegorz Bokota <[email protected]>
  • Loading branch information
tlambert03 and Czaki authored Jun 16, 2022
1 parent 6a6776a commit 640484c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 3 additions & 0 deletions napari/_qt/menus/file_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ def __init__(self, window: 'Window'):
self.update()

def _close_app(self):
if not get_settings().application.confirm_close_window:
self._win._qt_window.close(quit_app=True)
return
message = QMessageBox(
QMessageBox.Icon.Warning,
trans._("Close application?"),
Expand Down
6 changes: 2 additions & 4 deletions napari/settings/_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from ..utils._base import _DEFAULT_LOCALE
from ..utils.events.custom_types import conint
from ..utils.events.evented_model import EventedModel
from ..utils.interactions import Shortcut
from ..utils.notifications import NotificationSeverity
from ..utils.translations import trans
from ._constants import LoopMode
Expand Down Expand Up @@ -158,10 +157,9 @@ class ApplicationSettings(EventedModel):
)
confirm_close_window: bool = Field(
default=True,
title=trans._("Confirm window closing"),
title=trans._("Confirm window or application closing"),
description=trans._(
"Ask for confirmation before closing window with {shortcut}",
shortcut=Shortcut("Control-W").platform,
"Ask for confirmation before closing a napari window or application (all napari windows).",
),
)

Expand Down

0 comments on commit 640484c

Please sign in to comment.