Skip to content

Commit

Permalink
Added *Unsupported* for backwards compat on config of KBM
Browse files Browse the repository at this point in the history
  • Loading branch information
jefflord committed Feb 2, 2024
1 parent d01117c commit 77f60e3
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
45 changes: 38 additions & 7 deletions src/modules/keyboardmanager/common/MappingConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,13 @@ bool MappingConfiguration::LoadSingleKeyToTextRemaps(const json::JsonObject& jso
{
auto originalKey = it.GetObjectW().GetNamedString(KeyboardManagerConstants::OriginalKeysSettingName);
auto newText = it.GetObjectW().GetNamedString(KeyboardManagerConstants::NewTextSettingName);

// undo dummy data for backwards compatibility
if (newText == L"*Unsupported*")
{
newText == L"";
}

AddSingleKeyToTextRemap(std::stoul(originalKey.c_str()), newText.c_str());
}
catch (...)
Expand Down Expand Up @@ -214,6 +221,12 @@ bool MappingConfiguration::LoadAppSpecificShortcutRemaps(const json::JsonObject&
auto targetApp = it.GetObjectW().GetNamedString(KeyboardManagerConstants::TargetAppSettingName);
auto operationType = it.GetObjectW().GetNamedNumber(KeyboardManagerConstants::ShortcutOperationType, 0);

// undo dummy data for backwards compatibility
if (newRemapText == L"*Unsupported*")
{
newRemapText == L"";
}

// check Shortcut::OperationType
if (operationType == 1)
{
Expand All @@ -227,12 +240,12 @@ bool MappingConfiguration::LoadAppSpecificShortcutRemaps(const json::JsonObject&

auto tempShortcut = Shortcut(newRemapKeys.c_str());
tempShortcut.operationType = Shortcut::OperationType::RunProgram;
tempShortcut.runProgramFilePath = runProgramFilePath;
tempShortcut.runProgramFilePath = runProgramFilePath;
tempShortcut.runProgramArgs = runProgramArgs;
tempShortcut.runProgramStartInDir = runProgramStartInDir;
tempShortcut.elevationLevel = static_cast<Shortcut::ElevationLevel>(runProgramElevationLevel);
tempShortcut.alreadyRunningAction = static_cast<Shortcut::ProgramAlreadyRunningAction>(runProgramAlreadyRunningAction);
tempShortcut.startWindowType = static_cast<Shortcut::StartWindowType>(runProgramStartWindowType);
tempShortcut.startWindowType = static_cast<Shortcut::StartWindowType>(runProgramStartWindowType);

AddAppSpecificShortcut(targetApp.c_str(), Shortcut(originalKeys.c_str(), static_cast<DWORD>(secondKeyOfChord)), tempShortcut);
}
Expand Down Expand Up @@ -303,6 +316,12 @@ bool MappingConfiguration::LoadShortcutRemaps(const json::JsonObject& jsonData,
auto newRemapText = it.GetObjectW().GetNamedString(KeyboardManagerConstants::NewTextSettingName, {});
auto operationType = it.GetObjectW().GetNamedNumber(KeyboardManagerConstants::ShortcutOperationType, 0);

// undo dummy data for backwards compatibility
if (newRemapText == L"*Unsupported*")
{
newRemapText == L"";
}

// check Shortcut::OperationType
if (operationType == 1)
{
Expand All @@ -323,7 +342,7 @@ bool MappingConfiguration::LoadShortcutRemaps(const json::JsonObject& jsonData,
tempShortcut.elevationLevel = static_cast<Shortcut::ElevationLevel>(runProgramElevationLevel);
tempShortcut.alreadyRunningAction = static_cast<Shortcut::ProgramAlreadyRunningAction>(runProgramAlreadyRunningAction);
tempShortcut.startWindowType = static_cast<Shortcut::StartWindowType>(runProgramStartWindowType);

AddOSLevelShortcut(Shortcut(originalKeys.c_str(), static_cast<DWORD>(secondKeyOfChord)), tempShortcut);
}
else if (operationType == 2)
Expand Down Expand Up @@ -482,7 +501,7 @@ bool MappingConfiguration::SaveSettingsToFile()
// For shortcut to shortcut remapping
else if (it.second.targetShortcut.index() == 1)
{
auto targetShortcut = std::get<Shortcut>(it.second.targetShortcut);
auto targetShortcut = std::get<Shortcut>(it.second.targetShortcut);

if (targetShortcut.operationType == Shortcut::OperationType::RunProgram)
{
Expand All @@ -495,7 +514,10 @@ bool MappingConfiguration::SaveSettingsToFile()

keys.SetNamedValue(KeyboardManagerConstants::RunProgramFilePathSettingName, json::value(targetShortcut.runProgramFilePath));
keys.SetNamedValue(KeyboardManagerConstants::RunProgramArgsSettingName, json::value(targetShortcut.runProgramArgs));
keys.SetNamedValue(KeyboardManagerConstants::RunProgramStartInDirSettingName, json::value(targetShortcut.runProgramStartInDir));
keys.SetNamedValue(KeyboardManagerConstants::RunProgramStartInDirSettingName, json::value(targetShortcut.runProgramStartInDir));

// we need to add this dummy data for backwards compatibility
keys.SetNamedValue(KeyboardManagerConstants::NewTextSettingName, json::value(L"*Unsupported*"));
}
else if (targetShortcut.operationType == Shortcut::OperationType::OpenURI)
{
Expand All @@ -504,6 +526,9 @@ bool MappingConfiguration::SaveSettingsToFile()
keys.SetNamedValue(KeyboardManagerConstants::ShortcutOperationType, json::value(static_cast<unsigned int>(targetShortcut.operationType)));

keys.SetNamedValue(KeyboardManagerConstants::ShortcutOpenURI, json::value(targetShortcut.uriToOpen));

// we need to add this dummy data for backwards compatibility
keys.SetNamedValue(KeyboardManagerConstants::NewTextSettingName, json::value(L"*Unsupported*"));
}
else
{
Expand Down Expand Up @@ -545,7 +570,7 @@ bool MappingConfiguration::SaveSettingsToFile()
// For shortcut to shortcut remapping
else if (itKeys.second.targetShortcut.index() == 1)
{
auto targetShortcut = std::get<Shortcut>(itKeys.second.targetShortcut);
auto targetShortcut = std::get<Shortcut>(itKeys.second.targetShortcut);

if (targetShortcut.operationType == Shortcut::OperationType::RunProgram)
{
Expand All @@ -558,7 +583,10 @@ bool MappingConfiguration::SaveSettingsToFile()

keys.SetNamedValue(KeyboardManagerConstants::RunProgramFilePathSettingName, json::value(targetShortcut.runProgramFilePath));
keys.SetNamedValue(KeyboardManagerConstants::RunProgramArgsSettingName, json::value(targetShortcut.runProgramArgs));
keys.SetNamedValue(KeyboardManagerConstants::RunProgramStartInDirSettingName, json::value(targetShortcut.runProgramStartInDir));
keys.SetNamedValue(KeyboardManagerConstants::RunProgramStartInDirSettingName, json::value(targetShortcut.runProgramStartInDir));

// we need to add this dummy data for backwards compatibility
keys.SetNamedValue(KeyboardManagerConstants::NewTextSettingName, json::value(L"*Unsupported*"));
}
else if (targetShortcut.operationType == Shortcut::OperationType::OpenURI)
{
Expand All @@ -567,6 +595,9 @@ bool MappingConfiguration::SaveSettingsToFile()
keys.SetNamedValue(KeyboardManagerConstants::ShortcutOperationType, json::value(static_cast<unsigned int>(targetShortcut.operationType)));

keys.SetNamedValue(KeyboardManagerConstants::ShortcutOpenURI, json::value(targetShortcut.uriToOpen));

// we need to add this dummy data for backwards compatibility
keys.SetNamedValue(KeyboardManagerConstants::NewTextSettingName, json::value(L"*Unsupported*"));
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/settings-ui/Settings.UI.Library/KeysDataModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public List<string> GetMappedNewRemapKeys(int runProgramMaxLength)
}
}

return string.IsNullOrEmpty(NewRemapString) ? MapKeys(NewRemapKeys) : new List<string> { NewRemapString };
return (string.IsNullOrEmpty(NewRemapString) || NewRemapString == "*Unsupported*") ? MapKeys(NewRemapKeys) : new List<string> { NewRemapString };
}

// Instead of doing something fancy pants, we 'll just display the RunProgramFilePath data when it's IsRunProgram
Expand Down

1 comment on commit 77f60e3

@github-actions
Copy link

Choose a reason for hiding this comment

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

@check-spelling-bot Report

🔴 Please review

See the 📜action log or 📝 job summary for details.

Unrecognized words (29)
BIF
BROWSEINFO
CKBH
CLOSE'ing
cmdow
commdlg
EDITSINGLESHORTCUT
FILEMUSTEXIST
Lencode
LPITEMIDLIST
lpstr
NEWDIALOGSTYLE
ofn
OPENFILENAME
PATHMUSTEXIST
PATHTOPROGRAM
pids
PROCESSENTRY
Procses
RETURNONLYFSDIRS
ritchielawrence
runasuser
SNAPPROCESS
tlhelp
Toolhelp
URIEXAMPLE
URIOr
urlmon
wcsicmp
Previously acknowledged words that are now absent COMMANDTITLE OOBEPT 🫥
To accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands

... in a clone of the git@github.com:jefflord/PowerToys.git repository
on the launch-apps-3350 branch (ℹ️ how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.22/apply.pl' |
perl - 'https://github.com/jefflord/PowerToys/actions/runs/7756197266/attempts/1'
Available 📚 dictionaries could cover words (expected and unrecognized) not in the 📘 dictionary

This includes both expected items (1845) from .github/actions/spell-check/expect.txt and unrecognized words (29)

Dictionary Entries Covers Uniquely
cspell:r/src/r.txt 543 1 1
cspell:cpp/src/people.txt 23 1
cspell:cpp/src/ecosystem.txt 51 1

Consider adding them (in .github/workflows/spelling2.yml) for uses: check-spelling/check-spelling@v0.0.22 in its with:

      with:
        extra_dictionaries:
          cspell:r/src/r.txt
          cspell:cpp/src/people.txt
          cspell:cpp/src/ecosystem.txt

To stop checking additional dictionaries, add (in .github/workflows/spelling2.yml) for uses: check-spelling/check-spelling@v0.0.22 in its with:

check_extra_dictionaries: ''
If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Please sign in to comment.