diff --git a/doc/cascadia/SettingsSchema.md b/doc/cascadia/SettingsSchema.md index 53622113d..04028569f 100644 --- a/doc/cascadia/SettingsSchema.md +++ b/doc/cascadia/SettingsSchema.md @@ -19,6 +19,7 @@ Properties listed below affect the entire window, regardless of the profile sett | `snapToGridOnResize` | Optional | Boolean | `false` | When set to `true`, the window will snap to the nearest character boundary on resize. When `false`, the window will resize "smoothly" | | `tabWidthMode` | Optional | String | `equal` | Sets the width of the tabs. Possible values: `"equal"`, `"titleLength"` | | `wordDelimiters` | Optional | String |  /\()"'-:,.;<>~!@#$%^&*|+=[]{}~?│
_(`│` is `U+2502 BOX DRAWINGS LIGHT VERTICAL`)_ | Determines the delimiters used in a double click selection. | +| `confirmCloseAllTabs` | Optional | Boolean | `true` | When set to `true` closing a window with multiple tabs open WILL require confirmation. When set to `false` closing a window with multiple tabs open WILL NOT require confirmation. | ## Profiles Properties listed below are specific to each unique profile. diff --git a/doc/cascadia/profiles.schema.json b/doc/cascadia/profiles.schema.json index d7365cf77..b1278d2ea 100644 --- a/doc/cascadia/profiles.schema.json +++ b/doc/cascadia/profiles.schema.json @@ -355,6 +355,11 @@ "default": " ./\\()\"'-:,.;<>~!@#$%^&*|+=[]{}~?│", "description": "Determines the delimiters used in a double click selection.", "type": "string" + }, + "confirmCloseAllTabs": { + "default": true, + "description": " When set to `true` closing a window with multiple tabs open WILL require confirmation. When set to `false` closing a window with multiple tabs open WILL NOT require confirmation.", + "type":"boolean" } }, "required": [ diff --git a/src/cascadia/TerminalApp/GlobalAppSettings.cpp b/src/cascadia/TerminalApp/GlobalAppSettings.cpp index 7c41ba6ea..9284da908 100644 --- a/src/cascadia/TerminalApp/GlobalAppSettings.cpp +++ b/src/cascadia/TerminalApp/GlobalAppSettings.cpp @@ -33,6 +33,7 @@ static constexpr std::string_view ShowTabsInTitlebarKey{ "showTabsInTitlebar" }; static constexpr std::string_view WordDelimitersKey{ "wordDelimiters" }; static constexpr std::string_view CopyOnSelectKey{ "copyOnSelect" }; static constexpr std::string_view LaunchModeKey{ "launchMode" }; +static constexpr std::string_view ConfirmCloseAllKey{ "confirmCloseAllTabs" }; static constexpr std::string_view SnapToGridOnResizeKey{ "snapToGridOnResize" }; static constexpr std::wstring_view DefaultLaunchModeValue{ L"default" }; static constexpr std::wstring_view MaximizedLaunchModeValue{ L"maximized" }; @@ -45,6 +46,7 @@ GlobalAppSettings::GlobalAppSettings() : _colorSchemes{}, _defaultProfile{}, _alwaysShowTabs{ true }, + _confirmCloseAllTabs{ true }, _initialRows{ DEFAULT_ROWS }, _initialCols{ DEFAULT_COLS }, _rowsToScroll{ DEFAULT_ROWSTOSCROLL }, @@ -158,6 +160,15 @@ void GlobalAppSettings::SetLaunchMode(const LaunchMode launchMode) { _launchMode = launchMode; } +bool GlobalAppSettings::GetConfirmCloseAllTabs() const noexcept +{ + return _confirmCloseAllTabs; +} + +void GlobalAppSettings::SetConfirmCloseAllTabs(const bool confirmCloseAllTabs) noexcept +{ + _confirmCloseAllTabs = confirmCloseAllTabs; +} #pragma region ExperimentalSettings bool GlobalAppSettings::GetShowTabsInTitlebar() const noexcept @@ -223,6 +234,7 @@ Json::Value GlobalAppSettings::ToJson() const jsonObject[JsonKey(RequestedThemeKey)] = winrt::to_string(_SerializeTheme(_requestedTheme)); jsonObject[JsonKey(TabWidthModeKey)] = winrt::to_string(_SerializeTabWidthMode(_tabWidthMode)); jsonObject[JsonKey(KeybindingsKey)] = _keybindings->ToJson(); + jsonObject[JsonKey(ConfirmCloseAllKey)] = _confirmCloseAllTabs; jsonObject[JsonKey(SnapToGridOnResizeKey)] = _SnapToGridOnResize; return jsonObject; @@ -253,6 +265,10 @@ void GlobalAppSettings::LayerJson(const Json::Value& json) { _alwaysShowTabs = alwaysShowTabs.asBool(); } + if (auto confirmCloseAllTabs{ json[JsonKey(ConfirmCloseAllKey)] }) + { + _confirmCloseAllTabs = confirmCloseAllTabs.asBool(); + } if (auto initialRows{ json[JsonKey(InitialRowsKey)] }) { _initialRows = initialRows.asInt(); diff --git a/src/cascadia/TerminalApp/GlobalAppSettings.h b/src/cascadia/TerminalApp/GlobalAppSettings.h index 4831a62c5..738aace24 100644 --- a/src/cascadia/TerminalApp/GlobalAppSettings.h +++ b/src/cascadia/TerminalApp/GlobalAppSettings.h @@ -50,6 +50,9 @@ public: bool GetShowTitleInTitlebar() const noexcept; void SetShowTitleInTitlebar(const bool showTitleInTitlebar) noexcept; + bool GetConfirmCloseAllTabs() const noexcept; + void SetConfirmCloseAllTabs(const bool confirmCloseAllTabs) noexcept; + void SetRequestedTheme(const winrt::Windows::UI::Xaml::ElementTheme requestedTheme) noexcept; void SetTabWidthMode(const winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode tabWidthMode); @@ -99,6 +102,7 @@ private: bool _showStatusline; bool _alwaysShowTabs; bool _showTitleInTitlebar; + bool _confirmCloseAllTabs; bool _showTabsInTitlebar; std::wstring _wordDelimiters; diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp index 2b27ce8a0..bc85e5da2 100644 --- a/src/cascadia/TerminalApp/TerminalPage.cpp +++ b/src/cascadia/TerminalApp/TerminalPage.cpp @@ -997,7 +997,7 @@ namespace winrt::TerminalApp::implementation // than one tab opened, show a warning dialog. void TerminalPage::CloseWindow() { - if (_tabs.size() > 1) + if (_tabs.size() > 1 && _settings->GlobalSettings().GetConfirmCloseAllTabs()) { _ShowCloseWarningDialog(); } diff --git a/src/cascadia/TerminalApp/defaults.json b/src/cascadia/TerminalApp/defaults.json index 14a84fb1d..eae4b27c6 100644 --- a/src/cascadia/TerminalApp/defaults.json +++ b/src/cascadia/TerminalApp/defaults.json @@ -10,6 +10,7 @@ "tabWidthMode": "equal", "snapToGridOnResize": false, "wordDelimiters": " /\\()\"'-.,:;<>~!@#$%^&*|+=[]{}~?\u2502", + "confirmCloseAllTabs": true, "profiles": [