mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 09:05:10 -07:00
[Settings] Shuffle some settings around (#7084)
* [Settings] Shuffle some settings around Took 21 minutes Took 1 hour 25 minutes * [Settings] Camel case everything * Revert debug schema change * Add new classes * Fix card counters writing to global * Fix CI tests * Fix Windows CI * interface() is a protected keyword for MSVC Took 5 minutes Took 5 seconds * [Settings] Keep menu settings on the appearance settings page Leave the 'Menu settings' group box on the appearance settings page for now; relocating it to the user interface settings page will be done in a separate PR. Took 6 minutes --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
bf6b2a90bc
commit
adf574e038
79 changed files with 1899 additions and 1123 deletions
|
|
@ -35,66 +35,100 @@ static void migrateSoundSettings(const QString &settingsPath, QSettings &globalI
|
|||
QSettings soundIni(settingsPath + "sound.ini", QSettings::IniFormat);
|
||||
soundIni.setValue("sound/enabled", globalIni.value("sound/enabled", false));
|
||||
soundIni.setValue("sound/theme", globalIni.value("sound/theme"));
|
||||
soundIni.setValue("sound/mastervolume", globalIni.value("sound/mastervolume", 100));
|
||||
soundIni.setValue("sound/masterVolume", globalIni.value("sound/mastervolume", 100));
|
||||
}
|
||||
|
||||
static void migrateGameSettings(const QString &settingsPath, QSettings &globalIni)
|
||||
{
|
||||
bool hasGameKeys = false;
|
||||
globalIni.beginGroup("game");
|
||||
if (!globalIni.childKeys().isEmpty()) {
|
||||
hasGameKeys = true;
|
||||
}
|
||||
QStringList gameKeys = globalIni.childKeys();
|
||||
globalIni.endGroup();
|
||||
const QMap<QString, QString> gameKeyMap = {
|
||||
{"game/maxplayers", "game/maxPlayers"},
|
||||
{"game/gamedescription", "game/gameDescription"},
|
||||
{"game/gametypes", "game/gameTypes"},
|
||||
{"game/onlybuddies", "game/onlyBuddies"},
|
||||
{"game/onlyregistered", "game/onlyRegistered"},
|
||||
{"game/spectatorsallowed", "game/spectatorsAllowed"},
|
||||
{"game/spectatorsneedpassword", "game/spectatorsNeedPassword"},
|
||||
{"game/spectatorscantalk", "game/spectatorsCanTalk"},
|
||||
{"game/spectatorscanseeeverything", "game/spectatorsCanSeeEverything"},
|
||||
{"game/creategameasspectator", "game/createGameAsSpectator"},
|
||||
{"game/defaultstartinglifetotal", "game/defaultStartingLifeTotal"},
|
||||
{"game/sharedecklistsonload", "game/shareDecklistsOnLoad"},
|
||||
{"game/remembergamesettings", "game/rememberGameSettings"},
|
||||
{"localgameoptions/maxplayers", "localgameoptions/maxPlayers"},
|
||||
{"localgameoptions/startinglifetotal", "localgameoptions/startingLifeTotal"},
|
||||
{"localgameoptions/remembersettings", "localgameoptions/rememberSettings"},
|
||||
};
|
||||
|
||||
globalIni.beginGroup("localgameoptions");
|
||||
if (!globalIni.childKeys().isEmpty()) {
|
||||
hasGameKeys = true;
|
||||
bool hasAny = false;
|
||||
for (auto it = gameKeyMap.constBegin(); it != gameKeyMap.constEnd(); ++it) {
|
||||
if (globalIni.contains(it.key())) {
|
||||
hasAny = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
QStringList localGameKeys = globalIni.childKeys();
|
||||
globalIni.endGroup();
|
||||
|
||||
if (!hasGameKeys) {
|
||||
if (!hasAny) {
|
||||
return;
|
||||
}
|
||||
|
||||
QSettings gameIni(settingsPath + "game.ini", QSettings::IniFormat);
|
||||
for (const auto &key : gameKeys) {
|
||||
if (key == "maxfontsize") {
|
||||
continue;
|
||||
for (auto it = gameKeyMap.constBegin(); it != gameKeyMap.constEnd(); ++it) {
|
||||
if (globalIni.contains(it.key())) {
|
||||
gameIni.setValue(it.value(), globalIni.value(it.key()));
|
||||
}
|
||||
gameIni.setValue("game/" + key, globalIni.value("game/" + key));
|
||||
}
|
||||
for (const auto &key : localGameKeys) {
|
||||
gameIni.setValue("localgameoptions/" + key, globalIni.value("localgameoptions/" + key));
|
||||
}
|
||||
}
|
||||
|
||||
static void migrateChatSettings(const QString &settingsPath, QSettings &globalIni)
|
||||
{
|
||||
globalIni.beginGroup("chat");
|
||||
QStringList chatKeys = globalIni.childKeys();
|
||||
globalIni.endGroup();
|
||||
|
||||
if (chatKeys.isEmpty()) {
|
||||
const QMap<QString, QString> chatKeyMap = {
|
||||
{"chat/mention", "chat/mention"},
|
||||
{"chat/mentioncompleter", "chat/mentionCompleter"},
|
||||
{"chat/mentioncolor", "chat/mentionColor"},
|
||||
{"chat/highlightcolor", "chat/highlightColor"},
|
||||
{"chat/mentionforeground", "chat/mentionForeground"},
|
||||
{"chat/highlightforeground", "chat/highlightForeground"},
|
||||
{"chat/ignore_unregistered", "chat/ignoreUnregistered"},
|
||||
{"chat/ignore_unregistered_messages", "chat/ignoreUnregisteredMessages"},
|
||||
{"chat/ignore_nonbuddy_messages", "chat/ignoreNonBuddyMessages"},
|
||||
{"chat/showmessagepopups", "chat/showMessagePopups"},
|
||||
{"chat/showmentionpopups", "chat/showMentionPopups"},
|
||||
{"chat/roomhistory", "chat/roomHistory"},
|
||||
{"chat/highlightwords", "chat/highlightWords"},
|
||||
// Legacy highlight words lived under [personal], but the chat settings
|
||||
// class reads them from [chat]
|
||||
{"personal/highlightWords", "chat/highlightWords"},
|
||||
};
|
||||
bool hasAny = false;
|
||||
for (auto it = chatKeyMap.constBegin(); it != chatKeyMap.constEnd(); ++it) {
|
||||
if (globalIni.contains(it.key())) {
|
||||
hasAny = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasAny) {
|
||||
return;
|
||||
}
|
||||
|
||||
QSettings chatIni(settingsPath + "chat.ini", QSettings::IniFormat);
|
||||
for (const auto &key : chatKeys) {
|
||||
chatIni.setValue("chat/" + key, globalIni.value("chat/" + key));
|
||||
for (auto it = chatKeyMap.constBegin(); it != chatKeyMap.constEnd(); ++it) {
|
||||
if (globalIni.contains(it.key())) {
|
||||
chatIni.setValue(it.value(), globalIni.value(it.key()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void migrateCacheStorageSettings(const QString &settingsPath, QSettings &globalIni)
|
||||
{
|
||||
const QStringList cacheKeys = {"personal/pixmapCacheSize", "personal/networkCacheSize", "personal/redirectCacheTtl",
|
||||
"personal/cardPictureLoaderCacheMethod",
|
||||
"personal/localCardImageStorageNamingScheme"};
|
||||
const QMap<QString, QString> cacheStorageKeyMap = {
|
||||
{"personal/pixmapCacheSize", "cache_storage/pixmapCacheSize"},
|
||||
{"personal/networkCacheSize", "cache_storage/networkCacheSize"},
|
||||
{"personal/redirectCacheTtl", "cache_storage/redirectCacheTtl"},
|
||||
{"personal/cardPictureLoaderCacheMethod", "cache_storage/cardPictureLoaderCacheMethod"},
|
||||
{"personal/localCardImageStorageNamingScheme", "cache_storage/localCardImageStorageNamingScheme"},
|
||||
};
|
||||
bool hasAny = false;
|
||||
for (const auto &key : cacheKeys) {
|
||||
if (globalIni.contains(key)) {
|
||||
for (auto it = cacheStorageKeyMap.constBegin(); it != cacheStorageKeyMap.constEnd(); ++it) {
|
||||
if (globalIni.contains(it.key())) {
|
||||
hasAny = true;
|
||||
break;
|
||||
}
|
||||
|
|
@ -104,9 +138,9 @@ static void migrateCacheStorageSettings(const QString &settingsPath, QSettings &
|
|||
}
|
||||
|
||||
QSettings cacheStorageIni(settingsPath + "cache_storage.ini", QSettings::IniFormat);
|
||||
for (const auto &key : cacheKeys) {
|
||||
if (globalIni.contains(key)) {
|
||||
cacheStorageIni.setValue(key, globalIni.value(key));
|
||||
for (auto it = cacheStorageKeyMap.constBegin(); it != cacheStorageKeyMap.constEnd(); ++it) {
|
||||
if (globalIni.contains(it.key())) {
|
||||
cacheStorageIni.setValue(it.value(), globalIni.value(it.key()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -120,9 +154,9 @@ static void migrateUpdatesSettings(const QString &settingsPath, QSettings &globa
|
|||
{"personal/cardUpdateCheckInterval", "updates/cardUpdateCheckInterval"},
|
||||
{"personal/lastCardUpdateCheck", "updates/lastCardUpdateCheck"},
|
||||
{"personal/alwaysEnableNewSets", "updates/alwaysEnableNewSets"},
|
||||
{"personal/updatenotification", "updates/updatenotification"},
|
||||
{"personal/newversionnotification", "updates/newversionnotification"},
|
||||
{"personal/updatereleasechannel", "updates/updatereleasechannel"},
|
||||
{"personal/updatenotification", "updates/updateNotification"},
|
||||
{"personal/newversionnotification", "updates/newVersionNotification"},
|
||||
{"personal/updatereleasechannel", "updates/updateReleaseChannel"},
|
||||
};
|
||||
bool hasAny = false;
|
||||
for (auto it = updateKeyMap.constBegin(); it != updateKeyMap.constEnd(); ++it) {
|
||||
|
|
@ -145,19 +179,7 @@ static void migrateUpdatesSettings(const QString &settingsPath, QSettings &globa
|
|||
|
||||
static void migratePersonalSettings(const QString &settingsPath, QSettings &globalIni)
|
||||
{
|
||||
const QStringList personalRootKeys = {"personal/lang", "personal/highlightWords"};
|
||||
const QMap<QString, QString> personalKeyMap = {
|
||||
{"theme/name", "personal/themeName"},
|
||||
{"personal/clientid", "personal/clientid"},
|
||||
{"personal/clientversion", "personal/clientversion"},
|
||||
{"personal/keepalive", "personal/keepalive"},
|
||||
{"personal/timeout", "personal/timeout"},
|
||||
{"personal/picturedownload", "personal/picturedownload"},
|
||||
{"personal/showStatusBar", "personal/showStatusBar"},
|
||||
{"game/maxfontsize", "game/maxfontsize"},
|
||||
{"personal/downloadspoilers", "personal/downloadspoilers"},
|
||||
};
|
||||
const QStringList homeKeys = {"home/background", "home/background/shuffleTimer", "home/background/displayCardName"};
|
||||
const QStringList personalRootKeys = {"personal/lang"};
|
||||
const QStringList tipKeys = {"tipOfDay/showTips", "tipOfDay/seenTips"};
|
||||
|
||||
bool hasAny = false;
|
||||
|
|
@ -166,16 +188,6 @@ static void migratePersonalSettings(const QString &settingsPath, QSettings &glob
|
|||
hasAny = true;
|
||||
}
|
||||
}
|
||||
for (auto it = personalKeyMap.constBegin(); it != personalKeyMap.constEnd(); ++it) {
|
||||
if (globalIni.contains(it.key())) {
|
||||
hasAny = true;
|
||||
}
|
||||
}
|
||||
for (const auto &key : homeKeys) {
|
||||
if (globalIni.contains(key)) {
|
||||
hasAny = true;
|
||||
}
|
||||
}
|
||||
for (const auto &key : tipKeys) {
|
||||
if (globalIni.contains(key)) {
|
||||
hasAny = true;
|
||||
|
|
@ -191,16 +203,6 @@ static void migratePersonalSettings(const QString &settingsPath, QSettings &glob
|
|||
personalIni.setValue(key, globalIni.value(key));
|
||||
}
|
||||
}
|
||||
for (auto it = personalKeyMap.constBegin(); it != personalKeyMap.constEnd(); ++it) {
|
||||
if (globalIni.contains(it.key())) {
|
||||
personalIni.setValue(it.value(), globalIni.value(it.key()));
|
||||
}
|
||||
}
|
||||
for (const auto &key : homeKeys) {
|
||||
if (globalIni.contains(key)) {
|
||||
personalIni.setValue(key, globalIni.value(key));
|
||||
}
|
||||
}
|
||||
for (const auto &key : tipKeys) {
|
||||
if (globalIni.contains(key)) {
|
||||
personalIni.setValue(key, globalIni.value(key));
|
||||
|
|
@ -210,39 +212,33 @@ static void migratePersonalSettings(const QString &settingsPath, QSettings &glob
|
|||
|
||||
static void migrateCardsDisplaySettings(const QString &settingsPath, QSettings &globalIni)
|
||||
{
|
||||
const QStringList cardsRootKeys = {
|
||||
"cards/displaycardnames",
|
||||
"cards/roundcardcorners",
|
||||
"cards/overrideallcardartwithpersonalpreference",
|
||||
"cards/bumpsetswithcardsindecktotop",
|
||||
"cards/printingselectorsortorder",
|
||||
"cards/printingselectorcardsize",
|
||||
"cards/includerebalancedcards",
|
||||
"cards/printingselectornavigationbuttonsvisible",
|
||||
"cards/tapanimation",
|
||||
"cards/autorotatesidewayslayoutcards",
|
||||
"cards/scaleCards",
|
||||
"cards/verticalCardOverlapPercent",
|
||||
"cards/cardinfoviewmode",
|
||||
const QMap<QString, QString> cardsKeyMap = {
|
||||
{"cards/displaycardnames", "cards/displayCardNames"},
|
||||
{"cards/roundcardcorners", "cards/roundCardCorners"},
|
||||
{"cards/overrideallcardartwithpersonalpreference", "cards/overrideAllCardArtWithPersonalPreference"},
|
||||
{"cards/bumpsetswithcardsindecktotop", "cards/bumpSetsWithCardsInDeckToTop"},
|
||||
{"cards/includerebalancedcards", "cards/includerebalancedcards"},
|
||||
{"cards/tapanimation", "cards/tapAnimation"},
|
||||
{"cards/autorotatesidewayslayoutcards", "cards/autoRotateSidewaysLayoutCards"},
|
||||
{"cards/scaleCards", "cards/scaleCards"},
|
||||
{"cards/verticalCardOverlapPercent", "cards/verticalCardOverlapPercent"},
|
||||
{"cards/cardinfoviewmode", "cards/cardInfoViewMode"},
|
||||
{"cards/printingselectorsortorder", "cards/printingSelector/sortOrder"},
|
||||
{"cards/printingselectornavigationbuttonsvisible", "cards/printingSelector/navigationButtonsVisible"},
|
||||
{"cards/printingselectorcardsize", "cards/cardSize/printingSelector"},
|
||||
{"interface/visualdeckstoragecardsize", "cards/cardSize/visualDeckStorage"},
|
||||
{"interface/visualdatabasedisplaycardsize", "cards/cardSize/visualDatabaseDisplay"},
|
||||
{"interface/visualdeckeditorcardsize", "cards/cardSize/visualDeckEditor"},
|
||||
{"interface/edhreccardsize", "cards/cardSize/edhrec"},
|
||||
{"interface/archidektpreviewsize", "cards/cardSize/archidektPreview"},
|
||||
{"interface/visualdeckeditorsamplehandsize", "cards/cardSize/sampleHandSize"},
|
||||
};
|
||||
const QStringList cardsInterfaceKeys = {"interface/deckeditorbannercardcomboboxvisible",
|
||||
"interface/deckeditortagswidgetvisible"};
|
||||
const QStringList menuKeys = {"menu/showshortcuts", "menu/showgameselectorfiltertoolbar"};
|
||||
|
||||
bool hasAny = false;
|
||||
for (const auto &key : cardsRootKeys) {
|
||||
if (globalIni.contains(key)) {
|
||||
hasAny = true;
|
||||
}
|
||||
}
|
||||
for (const auto &key : cardsInterfaceKeys) {
|
||||
if (globalIni.contains(key)) {
|
||||
hasAny = true;
|
||||
}
|
||||
}
|
||||
for (const auto &key : menuKeys) {
|
||||
if (globalIni.contains(key)) {
|
||||
for (auto it = cardsKeyMap.constBegin(); it != cardsKeyMap.constEnd(); ++it) {
|
||||
if (globalIni.contains(it.key())) {
|
||||
hasAny = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasAny) {
|
||||
|
|
@ -250,60 +246,71 @@ static void migrateCardsDisplaySettings(const QString &settingsPath, QSettings &
|
|||
}
|
||||
|
||||
QSettings cardsIni(settingsPath + "cards_display.ini", QSettings::IniFormat);
|
||||
for (const auto &key : cardsRootKeys) {
|
||||
if (globalIni.contains(key)) {
|
||||
cardsIni.setValue(key, globalIni.value(key));
|
||||
for (auto it = cardsKeyMap.constBegin(); it != cardsKeyMap.constEnd(); ++it) {
|
||||
if (globalIni.contains(it.key())) {
|
||||
cardsIni.setValue(it.value(), globalIni.value(it.key()));
|
||||
}
|
||||
}
|
||||
for (const auto &key : cardsInterfaceKeys) {
|
||||
if (globalIni.contains(key)) {
|
||||
cardsIni.setValue(key, globalIni.value(key));
|
||||
}
|
||||
|
||||
static void migrateCardCounterSettings(const QString &settingsPath, QSettings &globalIni)
|
||||
{
|
||||
QStringList counterKeys;
|
||||
const QStringList allKeys = globalIni.allKeys();
|
||||
for (const auto &key : allKeys) {
|
||||
if (key.startsWith("cards/counters/")) {
|
||||
counterKeys.append(key);
|
||||
}
|
||||
}
|
||||
for (const auto &key : menuKeys) {
|
||||
if (globalIni.contains(key)) {
|
||||
cardsIni.setValue(key, globalIni.value(key));
|
||||
}
|
||||
if (counterKeys.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QSettings countersIni(settingsPath + "card_counters.ini", QSettings::IniFormat);
|
||||
for (const auto &key : counterKeys) {
|
||||
countersIni.setValue(key, globalIni.value(key));
|
||||
}
|
||||
}
|
||||
|
||||
static void migrateInterfaceSettings(const QString &settingsPath, QSettings &globalIni)
|
||||
{
|
||||
const QStringList interfaceRootKeys = {
|
||||
"interface/usetearoffmenus",
|
||||
"interface/cardViewInitialRowsMax",
|
||||
"interface/cardViewExpandedRowsMax",
|
||||
"interface/closeEmptyCardView",
|
||||
"interface/focusCardViewSearchBar",
|
||||
"interface/keepGameChatFocus",
|
||||
"interface/notificationsenabled",
|
||||
"interface/specnotificationsenabled",
|
||||
"interface/buddyconnectnotificationsenabled",
|
||||
"interface/doubleclicktoplay",
|
||||
"interface/clickPlaysAllSelected",
|
||||
"interface/playtostack",
|
||||
"interface/doNotDeleteArrowsInSubPhases",
|
||||
"interface/startinghandsize",
|
||||
"interface/annotatetokens",
|
||||
"interface/showlassoselectioncount",
|
||||
"interface/showpersistentselectioncount",
|
||||
"interface/showsubtypeselectiontally",
|
||||
"interface/leftjustified",
|
||||
"interface/min_players_multicolumn",
|
||||
"interface/knownmissingfeatures",
|
||||
const QMap<QString, QString> interfaceKeyMap = {
|
||||
{"interface/usetearoffmenus", "interface/useTearOffMenus"},
|
||||
{"interface/cardViewInitialRowsMax", "interface/cardViewInitialRowsMax"},
|
||||
{"interface/cardViewExpandedRowsMax", "interface/cardViewExpandedRowsMax"},
|
||||
{"interface/closeEmptyCardView", "interface/closeEmptyCardView"},
|
||||
{"interface/focusCardViewSearchBar", "interface/focusCardViewSearchBar"},
|
||||
{"interface/keepGameChatFocus", "interface/keepGameChatFocus"},
|
||||
{"interface/doubleclicktoplay", "interface/doubleClickToPlay"},
|
||||
{"interface/clickPlaysAllSelected", "interface/clickPlaysAllSelected"},
|
||||
{"interface/playtostack", "interface/playToStack"},
|
||||
{"interface/doNotDeleteArrowsInSubPhases", "interface/doNotDeleteArrowsInSubPhases"},
|
||||
{"interface/startinghandsize", "interface/startingHandSize"},
|
||||
{"interface/annotatetokens", "interface/annotateTokens"},
|
||||
{"interface/showlassoselectioncount", "interface/showLassoSelectionCount"},
|
||||
{"interface/showpersistentselectioncount", "interface/showPersistentSelectionCount"},
|
||||
{"interface/tallyType", "interface/tallyType"},
|
||||
{"interface/leftjustified", "interface/leftJustified"},
|
||||
{"interface/min_players_multicolumn", "interface/minPlayersMulticolumn"},
|
||||
{"hand/horizontal", "hand/horizontal"},
|
||||
{"table/invert_vertical", "table/invertVertical"},
|
||||
{"replay/rewindBufferingMs", "replay/rewindBufferingMs"},
|
||||
{"replay/fastForwardSpeed", "replay/fastForwardSpeed"},
|
||||
{"zoneview/groupby", "zoneview/groupBy"},
|
||||
{"zoneview/sortby", "zoneview/sortBy"},
|
||||
{"zoneview/pileview", "zoneview/pileView"},
|
||||
{"personal/showStatusBar", "interface/showStatusBar"},
|
||||
{"menu/showshortcuts", "interface/showShortcuts"},
|
||||
{"menu/showgameselectorfiltertoolbar", "interface/showGameSelectorFilterToolbar"},
|
||||
{"interface/notificationsenabled", "interface/notifications/enabled"},
|
||||
{"interface/specnotificationsenabled", "interface/notifications/spectatorsEnabled"},
|
||||
{"interface/buddyconnectnotificationsenabled", "interface/notifications/buddyConnectEnabled"},
|
||||
};
|
||||
const QStringList interfaceSubKeys = {
|
||||
"hand/horizontal", "table/invert_vertical", "editor/openDeckInNewTab", "replay/rewindBufferingMs",
|
||||
"appearance/styleUserList", "zoneview/groupby", "zoneview/sortby", "zoneview/pileview"};
|
||||
bool hasAny = false;
|
||||
for (const auto &key : interfaceRootKeys) {
|
||||
if (globalIni.contains(key)) {
|
||||
hasAny = true;
|
||||
}
|
||||
}
|
||||
for (const auto &key : interfaceSubKeys) {
|
||||
if (globalIni.contains(key)) {
|
||||
for (auto it = interfaceKeyMap.constBegin(); it != interfaceKeyMap.constEnd(); ++it) {
|
||||
if (globalIni.contains(it.key())) {
|
||||
hasAny = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasAny) {
|
||||
|
|
@ -311,63 +318,159 @@ static void migrateInterfaceSettings(const QString &settingsPath, QSettings &glo
|
|||
}
|
||||
|
||||
QSettings interfaceIni(settingsPath + "interface.ini", QSettings::IniFormat);
|
||||
for (const auto &key : interfaceRootKeys) {
|
||||
if (globalIni.contains(key)) {
|
||||
interfaceIni.setValue(key, globalIni.value(key));
|
||||
for (auto it = interfaceKeyMap.constBegin(); it != interfaceKeyMap.constEnd(); ++it) {
|
||||
if (globalIni.contains(it.key())) {
|
||||
interfaceIni.setValue(it.value(), globalIni.value(it.key()));
|
||||
}
|
||||
}
|
||||
for (const auto &key : interfaceSubKeys) {
|
||||
if (globalIni.contains(key)) {
|
||||
interfaceIni.setValue(key, globalIni.value(key));
|
||||
}
|
||||
|
||||
static void migrateDownloadSettings(const QString &settingsPath, QSettings &globalIni)
|
||||
{
|
||||
const QMap<QString, QString> downloadKeyMap = {
|
||||
{"personal/picturedownload", "downloads/pictureDownload"},
|
||||
{"personal/downloadspoilers", "downloads/downloadSpoilers"},
|
||||
};
|
||||
bool hasAny = false;
|
||||
for (auto it = downloadKeyMap.constBegin(); it != downloadKeyMap.constEnd(); ++it) {
|
||||
if (globalIni.contains(it.key())) {
|
||||
hasAny = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasAny) {
|
||||
return;
|
||||
}
|
||||
|
||||
QSettings downloadsIni(settingsPath + "downloads.ini", QSettings::IniFormat);
|
||||
for (auto it = downloadKeyMap.constBegin(); it != downloadKeyMap.constEnd(); ++it) {
|
||||
if (globalIni.contains(it.key())) {
|
||||
downloadsIni.setValue(it.value(), globalIni.value(it.key()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void migrateAppearanceSettings(const QString &settingsPath, QSettings &globalIni)
|
||||
{
|
||||
const QMap<QString, QString> appearanceKeyMap = {
|
||||
{"theme/name", "appearance/themeName"},
|
||||
{"game/maxfontsize", "appearance/maxFontSize"},
|
||||
{"home/background", "appearance/homeTabBackgroundSource"},
|
||||
{"home/background/shuffleTimer", "appearance/homeTabBackgroundShuffleFrequency"},
|
||||
{"home/background/displayCardName", "appearance/homeTabDisplayCardName"},
|
||||
{"appearance/styleUserList", "appearance/styleUserList"},
|
||||
};
|
||||
bool hasAny = false;
|
||||
for (auto it = appearanceKeyMap.constBegin(); it != appearanceKeyMap.constEnd(); ++it) {
|
||||
if (globalIni.contains(it.key())) {
|
||||
hasAny = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasAny) {
|
||||
return;
|
||||
}
|
||||
|
||||
QSettings appearanceIni(settingsPath + "appearance.ini", QSettings::IniFormat);
|
||||
for (auto it = appearanceKeyMap.constBegin(); it != appearanceKeyMap.constEnd(); ++it) {
|
||||
if (globalIni.contains(it.key())) {
|
||||
appearanceIni.setValue(it.value(), globalIni.value(it.key()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void migrateNetworkSettings(const QString &settingsPath, QSettings &globalIni)
|
||||
{
|
||||
const QMap<QString, QString> networkKeyMap = {
|
||||
{"personal/clientid", "network/clientId"},
|
||||
{"personal/clientversion", "network/clientVersion"},
|
||||
{"personal/keepalive", "network/keepAlive"},
|
||||
{"personal/timeout", "network/timeout"},
|
||||
{"interface/knownmissingfeatures", "network/knownMissingFeatures"},
|
||||
};
|
||||
bool hasAny = false;
|
||||
for (auto it = networkKeyMap.constBegin(); it != networkKeyMap.constEnd(); ++it) {
|
||||
if (globalIni.contains(it.key())) {
|
||||
hasAny = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasAny) {
|
||||
return;
|
||||
}
|
||||
|
||||
QSettings networkIni(settingsPath + "network.ini", QSettings::IniFormat);
|
||||
for (auto it = networkKeyMap.constBegin(); it != networkKeyMap.constEnd(); ++it) {
|
||||
if (globalIni.contains(it.key())) {
|
||||
networkIni.setValue(it.value(), globalIni.value(it.key()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void migratePathsSettings(const QString &settingsPath, QSettings &globalIni)
|
||||
{
|
||||
globalIni.beginGroup("paths");
|
||||
QStringList pathsKeys = globalIni.childKeys();
|
||||
globalIni.endGroup();
|
||||
if (pathsKeys.isEmpty()) {
|
||||
const QMap<QString, QString> pathsKeyMap = {
|
||||
{"paths/decks", "paths/decks"},
|
||||
{"paths/filters", "paths/filters"},
|
||||
{"paths/replays", "paths/replays"},
|
||||
{"paths/pics", "paths/pics"},
|
||||
{"paths/custompics", "paths/customPics"},
|
||||
{"paths/themes", "paths/themes"},
|
||||
{"paths/carddatabase", "paths/cardDatabase"},
|
||||
{"paths/customsets", "paths/customSets"},
|
||||
{"paths/tokendatabase", "paths/tokenDatabase"},
|
||||
{"paths/spoilerdatabase", "paths/spoilerDatabase"},
|
||||
{"paths/redirects", "paths/redirects"},
|
||||
};
|
||||
bool hasAny = false;
|
||||
for (auto it = pathsKeyMap.constBegin(); it != pathsKeyMap.constEnd(); ++it) {
|
||||
if (globalIni.contains(it.key())) {
|
||||
hasAny = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasAny) {
|
||||
return;
|
||||
}
|
||||
|
||||
QSettings pathsIni(settingsPath + "paths.ini", QSettings::IniFormat);
|
||||
for (const auto &key : pathsKeys) {
|
||||
pathsIni.setValue("paths/" + key, globalIni.value("paths/" + key));
|
||||
for (auto it = pathsKeyMap.constBegin(); it != pathsKeyMap.constEnd(); ++it) {
|
||||
if (globalIni.contains(it.key())) {
|
||||
pathsIni.setValue(it.value(), globalIni.value(it.key()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void migrateVisualDeckStorageSettings(const QString &settingsPath, QSettings &globalIni)
|
||||
{
|
||||
const QStringList vdsKeys = {"interface/visualdeckstoragecardsize",
|
||||
"interface/visualdeckstoragesortingorder",
|
||||
"interface/visualdeckstorageshowfolders",
|
||||
"interface/visualdeckstorageshowtagfilter",
|
||||
"interface/visualdeckstoragedefaulttagslist",
|
||||
"interface/visualdeckstoragesearchfoldernames",
|
||||
"interface/visualdeckstorageshowcoloridentity",
|
||||
"interface/visualdeckstorageshowbannercardcombobox",
|
||||
"interface/visualdeckstorageshowtagsondeckpreviews",
|
||||
"interface/visualdeckstoragedrawunusedcoloridentities",
|
||||
"interface/visualdeckstorageunusedcoloridentitiesopacity",
|
||||
"interface/visualdeckstoragetooltiptype",
|
||||
"interface/visualdeckstoragepromptforconversion",
|
||||
"interface/visualdeckstoragealwaysconvert",
|
||||
"interface/visualdeckstorageingame",
|
||||
"interface/visualdeckstorageselectionanimation",
|
||||
"interface/defaultDeckEditorType",
|
||||
"interface/visualdatabasedisplayfiltertomostrecentsetsenabled",
|
||||
"interface/visualdatabasedisplayfiltertomostrecentsetsamount",
|
||||
"interface/visualdeckeditorsamplehandsize",
|
||||
"interface/visualdeckeditorcardsize",
|
||||
"interface/visualdatabasedisplaycardsize",
|
||||
"interface/edhreccardsize",
|
||||
"interface/archidektpreviewsize"};
|
||||
const QMap<QString, QString> vdsKeyMap = {
|
||||
{"interface/visualdeckstoragesortingorder", "interface/visualDeckStorage/sortingOrder"},
|
||||
{"interface/visualdeckstorageshowfolders", "interface/visualDeckStorage/showFolders"},
|
||||
{"interface/visualdeckstorageshowtagfilter", "interface/visualDeckStorage/showTagFilter"},
|
||||
{"interface/visualdeckstoragedefaulttagslist", "interface/visualDeckStorage/defaultTagsList"},
|
||||
{"interface/visualdeckstoragesearchfoldernames", "interface/visualDeckStorage/searchFolderNames"},
|
||||
{"interface/visualdeckstorageshowcoloridentity", "interface/visualDeckStorage/showColorIdentity"},
|
||||
{"interface/visualdeckstorageshowbannercardcombobox", "interface/visualDeckStorage/showBannerCardComboBox"},
|
||||
{"interface/visualdeckstorageshowtagsondeckpreviews", "interface/visualDeckStorage/showTagsOnDeckPreviews"},
|
||||
{"interface/visualdeckstoragedrawunusedcoloridentities",
|
||||
"interface/visualDeckStorage/drawUnusedColorIdentities"},
|
||||
{"interface/visualdeckstorageunusedcoloridentitiesopacity",
|
||||
"interface/visualDeckStorage/unusedColorIdentitiesOpacity"},
|
||||
{"interface/visualdeckstoragetooltiptype", "interface/visualDeckStorage/tooltipType"},
|
||||
{"interface/visualdeckstoragepromptforconversion", "interface/visualDeckStorage/promptForConversion"},
|
||||
{"interface/visualdeckstoragealwaysconvert", "interface/visualDeckStorage/alwaysConvert"},
|
||||
{"interface/visualdeckstorageingame", "interface/visualDeckStorage/inGame"},
|
||||
{"interface/visualdeckstorageselectionanimation", "interface/visualDeckStorage/selectionAnimation"},
|
||||
{"interface/visualdatabasedisplayfiltertomostrecentsetsenabled",
|
||||
"interface/visualDatabaseDisplay/filterToMostRecentSetsEnabled"},
|
||||
{"interface/visualdatabasedisplayfiltertomostrecentsetsamount",
|
||||
"interface/visualDatabaseDisplay/filterToMostRecentSetsAmount"},
|
||||
};
|
||||
bool hasAny = false;
|
||||
for (const auto &key : vdsKeys) {
|
||||
if (globalIni.contains(key)) {
|
||||
for (auto it = vdsKeyMap.constBegin(); it != vdsKeyMap.constEnd(); ++it) {
|
||||
if (globalIni.contains(it.key())) {
|
||||
hasAny = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasAny) {
|
||||
|
|
@ -375,9 +478,36 @@ static void migrateVisualDeckStorageSettings(const QString &settingsPath, QSetti
|
|||
}
|
||||
|
||||
QSettings vdsIni(settingsPath + "visual_deck_storage.ini", QSettings::IniFormat);
|
||||
for (const auto &key : vdsKeys) {
|
||||
if (globalIni.contains(key)) {
|
||||
vdsIni.setValue(key, globalIni.value(key));
|
||||
for (auto it = vdsKeyMap.constBegin(); it != vdsKeyMap.constEnd(); ++it) {
|
||||
if (globalIni.contains(it.key())) {
|
||||
vdsIni.setValue(it.value(), globalIni.value(it.key()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void migrateDeckEditorSettings(const QString &settingsPath, QSettings &globalIni)
|
||||
{
|
||||
const QMap<QString, QString> deckEditorKeyMap = {
|
||||
{"editor/openDeckInNewTab", "deckeditor/openDeckInNewTab"},
|
||||
{"interface/deckeditorbannercardcomboboxvisible", "deckeditor/bannerCardComboBoxVisible"},
|
||||
{"interface/deckeditortagswidgetvisible", "deckeditor/tagsWidgetVisible"},
|
||||
{"interface/defaultDeckEditorType", "deckeditor/defaultDeckEditorType"},
|
||||
};
|
||||
bool hasAny = false;
|
||||
for (auto it = deckEditorKeyMap.constBegin(); it != deckEditorKeyMap.constEnd(); ++it) {
|
||||
if (globalIni.contains(it.key())) {
|
||||
hasAny = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasAny) {
|
||||
return;
|
||||
}
|
||||
|
||||
QSettings deckEditorIni(settingsPath + "deck_editor.ini", QSettings::IniFormat);
|
||||
for (auto it = deckEditorKeyMap.constBegin(); it != deckEditorKeyMap.constEnd(); ++it) {
|
||||
if (globalIni.contains(it.key())) {
|
||||
deckEditorIni.setValue(it.value(), globalIni.value(it.key()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -395,9 +525,9 @@ static void migrateLegacySets(const QString &settingsPath)
|
|||
QSettings cardDbIni(settingsPath + "cardDatabase.ini", QSettings::IniFormat);
|
||||
for (const auto &shortName : groups) {
|
||||
legacySetting.beginGroup(shortName);
|
||||
cardDbIni.setValue("sets/" + shortName + "/sortkey", legacySetting.value("sortkey"));
|
||||
cardDbIni.setValue("sets/" + shortName + "/sortKey", legacySetting.value("sortkey"));
|
||||
cardDbIni.setValue("sets/" + shortName + "/enabled", legacySetting.value("enabled"));
|
||||
cardDbIni.setValue("sets/" + shortName + "/isknown", legacySetting.value("isknown"));
|
||||
cardDbIni.setValue("sets/" + shortName + "/isKnown", legacySetting.value("isknown"));
|
||||
legacySetting.endGroup();
|
||||
}
|
||||
legacySetting.endGroup();
|
||||
|
|
@ -413,13 +543,30 @@ static void migrateLegacyServers(const QString &settingsPath)
|
|||
return;
|
||||
}
|
||||
|
||||
const QMap<QString, QString> serverKeyMap = {
|
||||
{"previoushostlogin", "previousHostLogin"},
|
||||
{"previoushosts", "previousHosts"},
|
||||
{"previoushostName", "previousHostName"},
|
||||
{"auto_connect", "autoConnect"},
|
||||
{"fphostname", "fpHostName"},
|
||||
{"fpport", "fpPort"},
|
||||
{"fpplayername", "fpPlayerName"},
|
||||
{"save_debug_log", "saveDebugLog"},
|
||||
};
|
||||
|
||||
QSettings serversIni(settingsPath + "servers.ini", QSettings::IniFormat);
|
||||
serversIni.setValue("server/previoushostlogin", legacySetting.value("previoushostlogin"));
|
||||
serversIni.setValue("server/previoushosts", legacySetting.value("previoushosts"));
|
||||
serversIni.setValue("server/auto_connect", legacySetting.value("auto_connect"));
|
||||
serversIni.setValue("server/fphostname", legacySetting.value("fphostname"));
|
||||
serversIni.setValue("server/fpport", legacySetting.value("fpport"));
|
||||
serversIni.setValue("server/fpplayername", legacySetting.value("fpplayername"));
|
||||
for (auto it = serverKeyMap.constBegin(); it != serverKeyMap.constEnd(); ++it) {
|
||||
if (legacySetting.contains(it.key())) {
|
||||
serversIni.setValue("server/" + it.value(), legacySetting.value(it.key()));
|
||||
}
|
||||
}
|
||||
|
||||
legacySetting.beginGroup("server_details");
|
||||
const QStringList detailsKeys = legacySetting.allKeys();
|
||||
for (const auto &key : detailsKeys) {
|
||||
serversIni.setValue("server/server_details/" + key, legacySetting.value(key));
|
||||
}
|
||||
legacySetting.endGroup();
|
||||
legacySetting.endGroup();
|
||||
}
|
||||
|
||||
|
|
@ -454,9 +601,36 @@ static void migrateLegacyGameFilters(const QString &settingsPath)
|
|||
return;
|
||||
}
|
||||
|
||||
const QMap<QString, QString> filterKeyMap = {
|
||||
{"hide_buddies_only_games", "hideBuddiesOnlyGames"},
|
||||
{"hide_full_games", "hideFullGames"},
|
||||
{"hide_games_that_started", "hideGamesThatStarted"},
|
||||
{"hide_password_protected_games", "hidePasswordProtectedGames"},
|
||||
{"hide_ignored_user_games", "hideIgnoredUserGames"},
|
||||
{"hide_not_buddy_created_games", "hideNotBuddyCreatedGames"},
|
||||
{"hide_open_decklist_games", "hideOpenDecklistGames"},
|
||||
{"game_name_filter", "gameNameFilter"},
|
||||
{"creator_name_filter", "creatorNameFilter"},
|
||||
{"min_players", "minPlayers"},
|
||||
{"max_players", "maxPlayers"},
|
||||
{"max_game_age_time", "maxGameAgeTime"},
|
||||
{"show_only_if_spectators_can_watch", "showOnlyIfSpectatorsCanWatch"},
|
||||
{"show_spectator_password_protected", "showSpectatorPasswordProtected"},
|
||||
{"show_only_if_spectators_can_chat", "showOnlyIfSpectatorsCanChat"},
|
||||
{"show_only_if_spectators_can_see_hands", "showOnlyIfSpectatorsCanSeeHands"},
|
||||
};
|
||||
|
||||
QSettings filtersIni(settingsPath + "gamefilters.ini", QSettings::IniFormat);
|
||||
for (auto it = filterKeyMap.constBegin(); it != filterKeyMap.constEnd(); ++it) {
|
||||
if (legacySetting.contains(it.key())) {
|
||||
filtersIni.setValue("filter_games/" + it.value(), legacySetting.value(it.key()));
|
||||
}
|
||||
}
|
||||
const QString gameTypePrefix = "game_type/";
|
||||
for (const auto &key : keys) {
|
||||
filtersIni.setValue("filter_games/" + key, legacySetting.value(key));
|
||||
if (key.startsWith(gameTypePrefix)) {
|
||||
filtersIni.setValue("filter_games/gameType/" + key.mid(gameTypePrefix.size()), legacySetting.value(key));
|
||||
}
|
||||
}
|
||||
legacySetting.endGroup();
|
||||
}
|
||||
|
|
@ -503,10 +677,15 @@ bool SettingsMigration::migrateSettingsFromGlobalIni(const QString &settingsPath
|
|||
migrateCacheStorageSettings(settingsPath, globalIni);
|
||||
migrateUpdatesSettings(settingsPath, globalIni);
|
||||
migratePersonalSettings(settingsPath, globalIni);
|
||||
migrateDownloadSettings(settingsPath, globalIni);
|
||||
migrateCardsDisplaySettings(settingsPath, globalIni);
|
||||
migrateCardCounterSettings(settingsPath, globalIni);
|
||||
migrateInterfaceSettings(settingsPath, globalIni);
|
||||
migrateAppearanceSettings(settingsPath, globalIni);
|
||||
migrateNetworkSettings(settingsPath, globalIni);
|
||||
migratePathsSettings(settingsPath, globalIni);
|
||||
migrateVisualDeckStorageSettings(settingsPath, globalIni);
|
||||
migrateDeckEditorSettings(settingsPath, globalIni);
|
||||
|
||||
QFile::remove(settingsPath + "global.ini.old");
|
||||
QFile::rename(settingsPath + "global.ini", settingsPath + "global.ini.old");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue