mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-01-14 22:13:48 -08:00
merged with master
This commit is contained in:
@@ -1,11 +1,34 @@
|
||||
#include "settingscache.h"
|
||||
#include <QSettings>
|
||||
#if QT_VERSION >= 0x050000
|
||||
#include <QStandardPaths>
|
||||
#else
|
||||
#include <QDesktopServices>
|
||||
#endif
|
||||
|
||||
QString SettingsCache::getSettingsPath()
|
||||
{
|
||||
QString file = "";
|
||||
|
||||
#ifndef PORTABLE_BUILD
|
||||
#if QT_VERSION >= 0x050000
|
||||
file = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
|
||||
#else
|
||||
file = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
||||
#endif
|
||||
file.append("/settings/");
|
||||
#endif
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
SettingsCache::SettingsCache()
|
||||
{
|
||||
settings = new QSettings(this);
|
||||
shortcutsSettings = new ShortcutsSettings(getSettingsPath(),this);
|
||||
|
||||
lang = settings->value("personal/lang").toString();
|
||||
keepalive = settings->value("personal/keepalive", 5).toInt();
|
||||
|
||||
deckPath = settings->value("paths/decks").toString();
|
||||
replaysPath = settings->value("paths/replays").toString();
|
||||
@@ -42,6 +65,7 @@ SettingsCache::SettingsCache()
|
||||
spectatorNotificationsEnabled = settings->value("interface/specnotificationsenabled", false).toBool();
|
||||
doubleClickToPlay = settings->value("interface/doubleclicktoplay", true).toBool();
|
||||
playToStack = settings->value("interface/playtostack", false).toBool();
|
||||
annotateTokens = settings->value("interface/annotatetokens", false).toBool();
|
||||
cardInfoMinimized = settings->value("interface/cardinfominimized", 0).toInt();
|
||||
tabGameSplitterSizes = settings->value("interface/tabgame_splittersizes").toByteArray();
|
||||
displayCardNames = settings->value("cards/displaycardnames", true).toBool();
|
||||
@@ -50,8 +74,11 @@ SettingsCache::SettingsCache()
|
||||
minPlayersForMultiColumnLayout = settings->value("interface/min_players_multicolumn", 5).toInt();
|
||||
tapAnimation = settings->value("cards/tapanimation", true).toBool();
|
||||
chatMention = settings->value("chat/mention", true).toBool();
|
||||
chatMentionCompleter = settings->value("chat/mentioncompleter", true).toBool();
|
||||
chatMentionForeground = settings->value("chat/mentionforeground", true).toBool();
|
||||
chatHighlightForeground = settings->value("chat/highlightforeground", true).toBool();
|
||||
chatMentionColor = settings->value("chat/mentioncolor", "A6120D").toString();
|
||||
chatHighlightColor = settings->value("chat/highlightcolor", "A6120D").toString();
|
||||
|
||||
zoneViewSortByName = settings->value("zoneview/sortbyname", true).toBool();
|
||||
zoneViewSortByType = settings->value("zoneview/sortbytype", true).toBool();
|
||||
@@ -77,6 +104,29 @@ SettingsCache::SettingsCache()
|
||||
masterVolume = settings->value("sound/mastervolume", 100).toInt();
|
||||
|
||||
cardInfoViewMode = settings->value("cards/cardinfoviewmode", 0).toInt();
|
||||
highlightWords = settings->value("personal/highlightWords", QString()).toString();
|
||||
gameDescription = settings->value("game/gamedescription","").toString();
|
||||
maxPlayers = settings->value("game/maxplayers", 2).toInt();
|
||||
gameTypes = settings->value("game/gametypes","").toString();
|
||||
onlyBuddies = settings->value("game/onlybuddies", false).toBool();
|
||||
onlyRegistered = settings->value("game/onlyregistered", true).toBool();
|
||||
spectatorsAllowed = settings->value("game/spectatorsallowed", true).toBool();
|
||||
spectatorsNeedPassword = settings->value("game/spectatorsneedpassword", false).toBool();
|
||||
spectatorsCanTalk = settings->value("game/spectatorscantalk", false).toBool();
|
||||
spectatorsCanSeeEverything = settings->value("game/spectatorscanseeeverything", false).toBool();
|
||||
rememberGameSettings = settings->value("game/remembergamesettings", true).toBool();
|
||||
clientID = settings->value("personal/clientid", "notset").toString();
|
||||
|
||||
QString file = getSettingsPath();
|
||||
file.append("layouts/deckLayout.ini");
|
||||
|
||||
QSettings layout_settings(file , QSettings::IniFormat);
|
||||
deckEditorLayoutState = layout_settings.value("layouts/deckEditor_state").toByteArray();
|
||||
deckEditorGeometry = layout_settings.value("layouts/deckEditor_geometry").toByteArray();
|
||||
|
||||
deckEditorCardSize = layout_settings.value("layouts/deckEditor_CardSize", QSize(250,500)).toSize();
|
||||
deckEditorFilterSize = layout_settings.value("layouts/deckEditor_FilterSize", QSize(250,250)).toSize();
|
||||
deckEditorDeckSize = layout_settings.value("layouts/deckEditor_DeckSize", QSize(250,360)).toSize();
|
||||
}
|
||||
|
||||
void SettingsCache::setCardInfoViewMode(const int _viewMode) {
|
||||
@@ -84,6 +134,11 @@ void SettingsCache::setCardInfoViewMode(const int _viewMode) {
|
||||
settings->setValue("cards/cardinfoviewmode", cardInfoViewMode);
|
||||
}
|
||||
|
||||
void SettingsCache::setHighlightWords(const QString &_highlightWords) {
|
||||
highlightWords = _highlightWords;
|
||||
settings->setValue("personal/highlightWords", highlightWords);
|
||||
}
|
||||
|
||||
void SettingsCache::setMasterVolume(int _masterVolume) {
|
||||
masterVolume = _masterVolume;
|
||||
settings->setValue("sound/mastervolume", masterVolume);
|
||||
@@ -219,6 +274,12 @@ void SettingsCache::setPlayToStack(int _playToStack)
|
||||
settings->setValue("interface/playtostack", playToStack);
|
||||
}
|
||||
|
||||
void SettingsCache::setAnnotateTokens(int _annotateTokens)
|
||||
{
|
||||
annotateTokens = _annotateTokens;
|
||||
settings->setValue("interface/annotatetokens", annotateTokens);
|
||||
}
|
||||
|
||||
void SettingsCache::setCardInfoMinimized(int _cardInfoMinimized)
|
||||
{
|
||||
cardInfoMinimized = _cardInfoMinimized;
|
||||
@@ -270,16 +331,33 @@ void SettingsCache::setChatMention(int _chatMention) {
|
||||
settings->setValue("chat/mention", chatMention);
|
||||
}
|
||||
|
||||
void SettingsCache::setChatMentionCompleter(const int _enableMentionCompleter)
|
||||
{
|
||||
chatMentionCompleter = _enableMentionCompleter;
|
||||
settings->setValue("chat/mentioncompleter", chatMentionCompleter);
|
||||
emit chatMentionCompleterChanged();
|
||||
}
|
||||
|
||||
void SettingsCache::setChatMentionForeground(int _chatMentionForeground) {
|
||||
chatMentionForeground = _chatMentionForeground;
|
||||
settings->setValue("chat/mentionforeground", chatMentionForeground);
|
||||
}
|
||||
|
||||
void SettingsCache::setChatHighlightForeground(int _chatHighlightForeground) {
|
||||
chatHighlightForeground = _chatHighlightForeground;
|
||||
settings->setValue("chat/highlightforeground", chatHighlightForeground);
|
||||
}
|
||||
|
||||
void SettingsCache::setChatMentionColor(const QString &_chatMentionColor) {
|
||||
chatMentionColor = _chatMentionColor;
|
||||
settings->setValue("chat/mentioncolor", chatMentionColor);
|
||||
}
|
||||
|
||||
void SettingsCache::setChatHighlightColor(const QString &_chatHighlightColor) {
|
||||
chatHighlightColor = _chatHighlightColor;
|
||||
settings->setValue("chat/highlightcolor", chatHighlightColor);
|
||||
}
|
||||
|
||||
void SettingsCache::setZoneViewSortByName(int _zoneViewSortByName)
|
||||
{
|
||||
zoneViewSortByName = _zoneViewSortByName;
|
||||
@@ -354,3 +432,151 @@ void SettingsCache::setPixmapCacheSize(const int _pixmapCacheSize)
|
||||
settings->setValue("personal/pixmapCacheSize", pixmapCacheSize);
|
||||
emit pixmapCacheSizeChanged(pixmapCacheSize);
|
||||
}
|
||||
|
||||
void SettingsCache::setClientID(QString _clientID)
|
||||
{
|
||||
clientID = _clientID;
|
||||
settings->setValue("personal/clientid", clientID);
|
||||
}
|
||||
|
||||
QStringList SettingsCache::getCountries() const
|
||||
{
|
||||
static QStringList countries = QStringList()
|
||||
<< "ad" << "ae" << "af" << "ag" << "ai" << "al" << "am" << "ao" << "aq" << "ar"
|
||||
<< "as" << "at" << "au" << "aw" << "ax" << "az" << "ba" << "bb" << "bd" << "be"
|
||||
<< "bf" << "bg" << "bh" << "bi" << "bj" << "bl" << "bm" << "bn" << "bo" << "bq"
|
||||
<< "br" << "bs" << "bt" << "bv" << "bw" << "by" << "bz" << "ca" << "cc" << "cd"
|
||||
<< "cf" << "cg" << "ch" << "ci" << "ck" << "cl" << "cm" << "cn" << "co" << "cr"
|
||||
<< "cu" << "cv" << "cw" << "cx" << "cy" << "cz" << "de" << "dj" << "dk" << "dm"
|
||||
<< "do" << "dz" << "ec" << "ee" << "eg" << "eh" << "er" << "es" << "et" << "fi"
|
||||
<< "fj" << "fk" << "fm" << "fo" << "fr" << "ga" << "gb" << "gd" << "ge" << "gf"
|
||||
<< "gg" << "gh" << "gi" << "gl" << "gm" << "gn" << "gp" << "gq" << "gr" << "gs"
|
||||
<< "gt" << "gu" << "gw" << "gy" << "hk" << "hm" << "hn" << "hr" << "ht" << "hu"
|
||||
<< "id" << "ie" << "il" << "im" << "in" << "io" << "iq" << "ir" << "is" << "it"
|
||||
<< "je" << "jm" << "jo" << "jp" << "ke" << "kg" << "kh" << "ki" << "km" << "kn"
|
||||
<< "kp" << "kr" << "kw" << "ky" << "kz" << "la" << "lb" << "lc" << "li" << "lk"
|
||||
<< "lr" << "ls" << "lt" << "lu" << "lv" << "ly" << "ma" << "mc" << "md" << "me"
|
||||
<< "mf" << "mg" << "mh" << "mk" << "ml" << "mm" << "mn" << "mo" << "mp" << "mq"
|
||||
<< "mr" << "ms" << "mt" << "mu" << "mv" << "mw" << "mx" << "my" << "mz" << "na"
|
||||
<< "nc" << "ne" << "nf" << "ng" << "ni" << "nl" << "no" << "np" << "nr" << "nu"
|
||||
<< "nz" << "om" << "pa" << "pe" << "pf" << "pg" << "ph" << "pk" << "pl" << "pm"
|
||||
<< "pn" << "pr" << "ps" << "pt" << "pw" << "py" << "qa" << "re" << "ro" << "rs"
|
||||
<< "ru" << "rw" << "sa" << "sb" << "sc" << "sd" << "se" << "sg" << "sh" << "si"
|
||||
<< "sj" << "sk" << "sl" << "sm" << "sn" << "so" << "sr" << "ss" << "st" << "sv"
|
||||
<< "sx" << "sy" << "sz" << "tc" << "td" << "tf" << "tg" << "th" << "tj" << "tk"
|
||||
<< "tl" << "tm" << "tn" << "to" << "tr" << "tt" << "tv" << "tw" << "tz" << "ua"
|
||||
<< "ug" << "um" << "us" << "uy" << "uz" << "va" << "vc" << "ve" << "vg" << "vi"
|
||||
<< "vn" << "vu" << "wf" << "ws" << "ye" << "yt" << "za" << "zm" << "zw";
|
||||
|
||||
return countries;
|
||||
}
|
||||
|
||||
void SettingsCache::setDeckEditorLayoutState(const QByteArray &value)
|
||||
{
|
||||
deckEditorLayoutState = value;
|
||||
|
||||
QString file = getSettingsPath();
|
||||
file.append("layouts/deckLayout.ini");
|
||||
QSettings layout_settings(file , QSettings::IniFormat);
|
||||
layout_settings.setValue("layouts/deckEditor_state",value);
|
||||
}
|
||||
|
||||
void SettingsCache::setDeckEditorGeometry(const QByteArray &value)
|
||||
{
|
||||
deckEditorGeometry = value;
|
||||
|
||||
QString file = getSettingsPath();
|
||||
file.append("layouts/deckLayout.ini");
|
||||
QSettings layout_settings(file , QSettings::IniFormat);
|
||||
layout_settings.setValue("layouts/deckEditor_geometry",value);
|
||||
}
|
||||
|
||||
void SettingsCache::setDeckEditorCardSize(const QSize &value)
|
||||
{
|
||||
deckEditorCardSize = value;
|
||||
|
||||
QString file = getSettingsPath();
|
||||
file.append("layouts/deckLayout.ini");
|
||||
QSettings layout_settings(file , QSettings::IniFormat);
|
||||
layout_settings.setValue("layouts/deckEditor_CardSize",value);
|
||||
}
|
||||
|
||||
void SettingsCache::setDeckEditorDeckSize(const QSize &value)
|
||||
{
|
||||
deckEditorDeckSize = value;
|
||||
|
||||
QString file = getSettingsPath();
|
||||
file.append("layouts/deckLayout.ini");
|
||||
QSettings layout_settings(file , QSettings::IniFormat);
|
||||
layout_settings.setValue("layouts/deckEditor_DeckSize",value);
|
||||
}
|
||||
|
||||
void SettingsCache::setDeckEditorFilterSize(const QSize &value)
|
||||
{
|
||||
deckEditorFilterSize = value;
|
||||
|
||||
QString file = getSettingsPath();
|
||||
file.append("layouts/deckLayout.ini");
|
||||
QSettings layout_settings(file , QSettings::IniFormat);
|
||||
layout_settings.setValue("layouts/deckEditor_FilterSize",value);
|
||||
}
|
||||
|
||||
void SettingsCache::setGameDescription(const QString _gameDescription)
|
||||
{
|
||||
gameDescription = _gameDescription;
|
||||
settings->setValue("game/gamedescription", gameDescription);
|
||||
}
|
||||
|
||||
void SettingsCache::setMaxPlayers(const int _maxPlayers)
|
||||
{
|
||||
maxPlayers = _maxPlayers;
|
||||
settings->setValue("game/maxplayers", maxPlayers);
|
||||
}
|
||||
|
||||
void SettingsCache::setGameTypes(const QString _gameTypes)
|
||||
{
|
||||
gameTypes = _gameTypes;
|
||||
settings->setValue("game/gametypes", gameTypes);
|
||||
}
|
||||
|
||||
void SettingsCache::setOnlyBuddies(const bool _onlyBuddies)
|
||||
{
|
||||
onlyBuddies = _onlyBuddies;
|
||||
settings->setValue("game/onlybuddies", onlyBuddies);
|
||||
}
|
||||
|
||||
void SettingsCache::setOnlyRegistered(const bool _onlyRegistered)
|
||||
{
|
||||
onlyRegistered = _onlyRegistered;
|
||||
settings->setValue("game/onlyregistered", onlyRegistered);
|
||||
}
|
||||
|
||||
void SettingsCache::setSpectatorsAllowed(const bool _spectatorsAllowed)
|
||||
{
|
||||
spectatorsAllowed = _spectatorsAllowed;
|
||||
settings->setValue("game/spectatorsallowed", spectatorsAllowed);
|
||||
}
|
||||
|
||||
void SettingsCache::setSpectatorsNeedPassword(const bool _spectatorsNeedPassword)
|
||||
{
|
||||
spectatorsNeedPassword = _spectatorsNeedPassword;
|
||||
settings->setValue("game/spectatorsneedpassword", spectatorsNeedPassword);
|
||||
}
|
||||
|
||||
void SettingsCache::setSpectatorsCanTalk(const bool _spectatorsCanTalk)
|
||||
{
|
||||
spectatorsCanTalk = _spectatorsCanTalk;
|
||||
settings->setValue("game/spectatorscantalk", spectatorsCanTalk);
|
||||
}
|
||||
|
||||
void SettingsCache::setSpectatorsCanSeeEverything(const bool _spectatorsCanSeeEverything)
|
||||
{
|
||||
spectatorsCanSeeEverything = _spectatorsCanSeeEverything;
|
||||
settings->setValue("game/spectatorscanseeeverything", spectatorsCanSeeEverything);
|
||||
}
|
||||
|
||||
void SettingsCache::setRememberGameSettings(const bool _rememberGameSettings)
|
||||
{
|
||||
rememberGameSettings = _rememberGameSettings;
|
||||
settings->setValue("game/remembergamesettings", rememberGameSettings);
|
||||
}
|
||||
Reference in New Issue
Block a user