Skip to content

Commit

Permalink
Rename 'requestedTheme' to 'theme' (#5265)
Browse files Browse the repository at this point in the history
## Summary of the Pull Request

Renames the `requestedTheme` global setting to `theme`. Propagates updates to...
- schema
- doc
- defaults.json
- universal-defaults.json
 
## PR Checklist
* [X] Closes #5264 

## Validation Steps Performed
| `theme` | Success? |
|--|--|
| `system` | ✔ |
| `light` | ✔ |
| `dark` | ✔ |

But we really know that `dark` is the one we care about here 😉
  • Loading branch information
carlos-zamora committed Apr 7, 2020
1 parent a9c9714 commit 7c7db79
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion doc/cascadia/SettingsSchema.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Properties listed below affect the entire window, regardless of the profile sett
| `initialRows` | _Required_ | Integer | `30` | The number of rows displayed in the window upon first load. |
| `launchMode` | Optional | String | `default` | Defines whether the Terminal will launch as maximized or not. Possible values: `"default"`, `"maximized"` |
| `rowsToScroll` | Optional | Integer | `system` | The number of rows to scroll at a time with the mouse wheel. This will override the system setting if the value is not zero or "system". |
| `requestedTheme` | _Required_ | String | `system` | Sets the theme of the application. Possible values: `"light"`, `"dark"`, `"system"` |
| `theme` | _Required_ | String | `system` | Sets the theme of the application. Possible values: `"light"`, `"dark"`, `"system"` |
| `showTerminalTitleInTitlebar` | _Required_ | Boolean | `true` | When set to `true`, titlebar displays the title of the selected tab. When set to `false`, titlebar displays "Windows Terminal". |
| `showTabsInTitlebar` | Optional | Boolean | `true` | When set to `true`, the tabs are moved into the titlebar and the titlebar disappears. When set to `false`, the titlebar sits above the tabs. |
| `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" |
Expand Down
2 changes: 1 addition & 1 deletion doc/cascadia/profiles.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@
},
"type": "array"
},
"requestedTheme": {
"theme": {
"default": "system",
"description": "Sets the theme of the application.",
"enum": [
Expand Down
8 changes: 4 additions & 4 deletions src/cascadia/TerminalApp/AppLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ namespace winrt::TerminalApp::implementation
_root->Loaded({ this, &AppLogic::_OnLoaded });
_root->Create();

_ApplyTheme(_settings->GlobalSettings().GetRequestedTheme());
_ApplyTheme(_settings->GlobalSettings().GetTheme());

TraceLoggingWrite(
g_hTerminalAppProvider,
Expand Down Expand Up @@ -293,7 +293,7 @@ namespace winrt::TerminalApp::implementation
// details here, but it does have the desired effect.
// It's not enough to set the theme on the dialog alone.
auto themingLambda{ [this](const Windows::Foundation::IInspectable& sender, const RoutedEventArgs&) {
auto theme{ _settings->GlobalSettings().GetRequestedTheme() };
auto theme{ _settings->GlobalSettings().GetTheme() };
auto element{ sender.try_as<winrt::Windows::UI::Xaml::FrameworkElement>() };
while (element)
{
Expand Down Expand Up @@ -545,7 +545,7 @@ namespace winrt::TerminalApp::implementation
LoadSettings();
}

return _settings->GlobalSettings().GetRequestedTheme();
return _settings->GlobalSettings().GetTheme();
}

bool AppLogic::GetShowTabsInTitlebar()
Expand Down Expand Up @@ -726,7 +726,7 @@ namespace winrt::TerminalApp::implementation
co_await winrt::resume_foreground(_root->Dispatcher());

// Refresh the UI theme
_ApplyTheme(_settings->GlobalSettings().GetRequestedTheme());
_ApplyTheme(_settings->GlobalSettings().GetTheme());
}

// Method Description:
Expand Down
18 changes: 9 additions & 9 deletions src/cascadia/TerminalApp/GlobalAppSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static constexpr std::string_view InitialColsKey{ "initialCols" };
static constexpr std::string_view RowsToScrollKey{ "rowsToScroll" };
static constexpr std::string_view InitialPositionKey{ "initialPosition" };
static constexpr std::string_view ShowTitleInTitlebarKey{ "showTerminalTitleInTitlebar" };
static constexpr std::string_view RequestedThemeKey{ "requestedTheme" };
static constexpr std::string_view ThemeKey{ "theme" };
static constexpr std::string_view TabWidthModeKey{ "tabWidthMode" };
static constexpr std::wstring_view EqualTabWidthModeValue{ L"equal" };
static constexpr std::wstring_view TitleLengthTabWidthModeValue{ L"titleLength" };
Expand Down Expand Up @@ -63,7 +63,7 @@ GlobalAppSettings::GlobalAppSettings() :
_initialY{},
_showTitleInTitlebar{ true },
_showTabsInTitlebar{ true },
_requestedTheme{ ElementTheme::Default },
_theme{ ElementTheme::Default },
_tabWidthMode{ TabViewWidthMode::Equal },
_wordDelimiters{ DEFAULT_WORD_DELIMITERS },
_copyOnSelect{ false },
Expand Down Expand Up @@ -121,14 +121,14 @@ void GlobalAppSettings::SetShowTitleInTitlebar(const bool showTitleInTitlebar) n
_showTitleInTitlebar = showTitleInTitlebar;
}

ElementTheme GlobalAppSettings::GetRequestedTheme() const noexcept
ElementTheme GlobalAppSettings::GetTheme() const noexcept
{
return _requestedTheme;
return _theme;
}

void GlobalAppSettings::SetRequestedTheme(const ElementTheme requestedTheme) noexcept
void GlobalAppSettings::SetTheme(const ElementTheme theme) noexcept
{
_requestedTheme = requestedTheme;
_theme = theme;
}

TabViewWidthMode GlobalAppSettings::GetTabWidthMode() const noexcept
Expand Down Expand Up @@ -246,7 +246,7 @@ Json::Value GlobalAppSettings::ToJson() const
jsonObject[JsonKey(WordDelimitersKey)] = winrt::to_string(_wordDelimiters);
jsonObject[JsonKey(CopyOnSelectKey)] = _copyOnSelect;
jsonObject[JsonKey(LaunchModeKey)] = winrt::to_string(_SerializeLaunchMode(_launchMode));
jsonObject[JsonKey(RequestedThemeKey)] = winrt::to_string(_SerializeTheme(_requestedTheme));
jsonObject[JsonKey(ThemeKey)] = winrt::to_string(_SerializeTheme(_theme));
jsonObject[JsonKey(TabWidthModeKey)] = winrt::to_string(_SerializeTabWidthMode(_tabWidthMode));
jsonObject[JsonKey(KeybindingsKey)] = _keybindings->ToJson();
jsonObject[JsonKey(ConfirmCloseAllKey)] = _confirmCloseAllTabs;
Expand Down Expand Up @@ -316,9 +316,9 @@ void GlobalAppSettings::LayerJson(const Json::Value& json)
_launchMode = _ParseLaunchMode(GetWstringFromJson(launchMode));
}

if (auto requestedTheme{ json[JsonKey(RequestedThemeKey)] })
if (auto theme{ json[JsonKey(ThemeKey)] })
{
_requestedTheme = _ParseTheme(GetWstringFromJson(requestedTheme));
_theme = _ParseTheme(GetWstringFromJson(theme));
}

if (auto tabWidthMode{ json[JsonKey(TabWidthModeKey)] })
Expand Down
10 changes: 4 additions & 6 deletions src/cascadia/TerminalApp/GlobalAppSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ class TerminalApp::GlobalAppSettings final
bool GetConfirmCloseAllTabs() const noexcept;
void SetConfirmCloseAllTabs(const bool confirmCloseAllTabs) noexcept;

void SetRequestedTheme(const winrt::Windows::UI::Xaml::ElementTheme requestedTheme) noexcept;
winrt::Windows::UI::Xaml::ElementTheme GetTheme() const noexcept;
void SetTheme(const winrt::Windows::UI::Xaml::ElementTheme requestedTheme) noexcept;

winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode GetTabWidthMode() const noexcept;
void SetTabWidthMode(const winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode tabWidthMode);

bool GetShowTabsInTitlebar() const noexcept;
Expand All @@ -73,10 +75,6 @@ class TerminalApp::GlobalAppSettings final
winrt::TerminalApp::LaunchMode GetLaunchMode() const noexcept;
void SetLaunchMode(const winrt::TerminalApp::LaunchMode launchMode);

winrt::Windows::UI::Xaml::ElementTheme GetRequestedTheme() const noexcept;

winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode GetTabWidthMode() const noexcept;

bool DebugFeaturesEnabled() const noexcept;

Json::Value ToJson() const;
Expand Down Expand Up @@ -112,7 +110,7 @@ class TerminalApp::GlobalAppSettings final
bool _showTabsInTitlebar;
std::wstring _wordDelimiters;
bool _copyOnSelect;
winrt::Windows::UI::Xaml::ElementTheme _requestedTheme;
winrt::Windows::UI::Xaml::ElementTheme _theme;
winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode _tabWidthMode;

winrt::TerminalApp::LaunchMode _launchMode;
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalApp/defaults-universal.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"defaultProfile": "{550ce7b8-d500-50ad-8a1a-c400c3262db3}",
"initialCols": 120,
"initialRows": 30,
"requestedTheme": "system",
"theme": "system",
"showTabsInTitlebar": false,
"showTerminalTitleInTitlebar": true,
"wordDelimiters": " /\\()\"'-.,:;<>~!@#$%^&*|+=[]{}~?\u2502",
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalApp/defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"initialCols": 120,
"initialRows": 30,
"requestedTheme": "system",
"theme": "system",
"showTabsInTitlebar": true,
"showTerminalTitleInTitlebar": true,
"tabWidthMode": "equal",
Expand Down

1 comment on commit 7c7db79

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New misspellings found, please review:

  • ecma
To accept these changes, run the following commands
remove_obsolete_words=$(mktemp)
echo '#!/usr/bin/perl -ni
my $re=join "|", qw('"
APPLOGIC
Impl
Spc
trackpads
unicodechar
ve
XY
"');
next if /^($re)(?:$| .*)/;
print;' > $remove_obsolete_words
chmod +x $remove_obsolete_words
for file in .github/actions/spell-check/whitelist/alphabet.txt .github/actions/spell-check/whitelist/web.txt .github/actions/spell-check/whitelist/whitelist.txt; do $remove_obsolete_words $file; done
rm $remove_obsolete_words
(
echo "
applogic
ecma
impl
xy
"
) | sort -u -f | perl -ne 'next unless /./; print' > new_whitelist.txt && mv new_whitelist.txt '.github/actions/spell-check/whitelist/7c7db797823f97a50e5a78ea5bda982c171039fb.txt'
✏️ Contributor please read this
  • If the items listed above are names, please add them to .github/actions/spell-check/dictionary/names.txt.
  • If they're APIs, you can add them to a file in .github/actions/spell-check/dictionary/.
  • If they're just things you're using, please add them to an appropriate file in .github/actions/spell-check/whitelist/.
  • If you need to use a specific token in one place and it shouldn't generally be used, you can
    add an item in an appropriate file in .github/actions/spell-check/patterns/.

See the README.md in each directory for more information.

⚠️ Reviewers

At present, the action that triggered this message will not show its ❌ in this PR unless the branch is within this repository.
Thus, you should make sure that this comment has been addressed before encouraging the merge bot to merge this PR.

Please sign in to comment.