Skip to content

Commit

Permalink
Merge pull request #640 from stevencohn/629-upgrade-settings
Browse files Browse the repository at this point in the history
upgrade settings
  • Loading branch information
stevencohn authored Sep 29, 2022
2 parents d0c2ecd + 169b8ca commit 62b474f
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
49 changes: 49 additions & 0 deletions OneMore/Commands/Settings/ContextMenuSheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,54 @@ public override bool CollectSettings()

return updated;
}



/// <summary>
/// Temporary upgrade to rename resource IDs in the settings file
/// Created in v5.1.0. To be removed a few versions after that.
/// </summary>
/// <param name="provider"></param>
public static void UpgradESettings(SettingsProvider provider)
{
var exchange = new System.Collections.Generic.Dictionary<string, string>
{
{ "ribFootnoteButton", "ribAddFootnoteButton" },
{ "ribNoSpellCheckButton", "ribDisableSpellCheckButton" },
{ "ribSpellCheckButton", "ribEnableSpellCheckButton" },
{ "ribReplaceButton", "ribSearchAndReplaceButton" },
{ "ribTocButton", "ribInsertTocButton" },
{ "ribCalendarButton", "ribInsertCalendarButton" },
{ "ribBoxButton", "ribInsertBoxButton" },
{ "ribCodeBlockButton", "ribInsertCodeBlockButton" },
{ "ribInfoBlockButton", "ribInsertInfoBlockButton" },
{ "ribInsertInfoBlockButton", "ribInsertWarnBlockButton" },
{ "ribExpandButton", "ribInsertExpandButton" },
{ "ribGrayStatusButton", "ribInsertGrayStatusButton" },
{ "ribRedStatusButton", "ribInsertRedStatusButton" },
{ "ribYellowStatusButton", "ribInsertYellowStatusButton" },
{ "ribGreenStatusButton", "ribInsertGreenStatusButton" },
{ "ribBlueStatusButton", "ribInsertBlueStatusButton" }
};

var collection = provider.GetCollection("ContextMenuSheet");
var updated = false;

exchange.ForEach(item =>
{
if (collection.Contains(item.Key))
{
collection.Remove(item.Key);
collection.Add(item.Value, true);
updated = true;
}
});

if (updated)
{
provider.SetCollection(collection);
provider.Save();
}
}
}
}
4 changes: 4 additions & 0 deletions OneMore/Commands/Settings/SettingsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ public SettingsProvider()
)
);
}
else
{
ContextMenuSheet.UpgradESettings(this);
}
}


Expand Down

0 comments on commit 62b474f

Please sign in to comment.