Refactred settings to use settingscache & ini files
This commit is contained in:
parent
9c28cdd1f5
commit
c8d59eec5e
29 changed files with 780 additions and 241 deletions
|
@ -98,6 +98,12 @@ SET(cockatrice_SOURCES
|
||||||
src/sequenceEdit/sequenceedit.cpp
|
src/sequenceEdit/sequenceedit.cpp
|
||||||
src/sequenceEdit/shortcutstab.cpp
|
src/sequenceEdit/shortcutstab.cpp
|
||||||
src/lineeditcompleter.cpp
|
src/lineeditcompleter.cpp
|
||||||
|
src/settings/settingsmanager.cpp
|
||||||
|
src/settings/carddatabasesettings.cpp
|
||||||
|
src/settings/serverssettings.cpp
|
||||||
|
src/settings/messagesettings.cpp
|
||||||
|
src/settings/gamefilterssettings.cpp
|
||||||
|
src/settings/layoutssettings.cpp
|
||||||
${VERSION_STRING_CPP}
|
${VERSION_STRING_CPP}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include <QDirIterator>
|
#include <QDirIterator>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QSettings>
|
|
||||||
#include <QSvgRenderer>
|
#include <QSvgRenderer>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
@ -50,46 +49,29 @@ QString CardSet::getCorrectedShortName() const
|
||||||
return invalidFileNames.contains(shortName) ? shortName + "_" : shortName;
|
return invalidFileNames.contains(shortName) ? shortName + "_" : shortName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CardSet::loadSetOptions()
|
||||||
|
{
|
||||||
|
sortKey = settingsCache->cardDatabase().getSortKey(shortName);
|
||||||
|
enabled = settingsCache->cardDatabase().isEnabled(shortName);
|
||||||
|
isknown = settingsCache->cardDatabase().isKnown(shortName);
|
||||||
|
}
|
||||||
|
|
||||||
void CardSet::setSortKey(unsigned int _sortKey)
|
void CardSet::setSortKey(unsigned int _sortKey)
|
||||||
{
|
{
|
||||||
sortKey = _sortKey;
|
sortKey = _sortKey;
|
||||||
|
settingsCache->cardDatabase().setSortKey(shortName,_sortKey);
|
||||||
QSettings settings;
|
|
||||||
settings.beginGroup("sets");
|
|
||||||
settings.beginGroup(shortName);
|
|
||||||
settings.setValue("sortkey", sortKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CardSet::loadSetOptions()
|
|
||||||
{
|
|
||||||
QSettings settings;
|
|
||||||
settings.beginGroup("sets");
|
|
||||||
settings.beginGroup(shortName);
|
|
||||||
|
|
||||||
sortKey = settings.value("sortkey", 0).toInt();
|
|
||||||
enabled = settings.value("enabled", false).toBool();
|
|
||||||
isknown = settings.value("isknown", false).toBool();
|
|
||||||
// qDebug() << "load set" << shortName << "key" << sortKey;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardSet::setEnabled(bool _enabled)
|
void CardSet::setEnabled(bool _enabled)
|
||||||
{
|
{
|
||||||
enabled = _enabled;
|
enabled = _enabled;
|
||||||
|
settingsCache->cardDatabase().setEnabled(shortName,_enabled);
|
||||||
QSettings settings;
|
|
||||||
settings.beginGroup("sets");
|
|
||||||
settings.beginGroup(shortName);
|
|
||||||
settings.setValue("enabled", enabled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardSet::setIsKnown(bool _isknown)
|
void CardSet::setIsKnown(bool _isknown)
|
||||||
{
|
{
|
||||||
isknown = _isknown;
|
isknown = _isknown;
|
||||||
|
settingsCache->cardDatabase().setIsKnown(shortName,_isknown);
|
||||||
QSettings settings;
|
|
||||||
settings.beginGroup("sets");
|
|
||||||
settings.beginGroup(shortName);
|
|
||||||
settings.setValue("isknown", isknown);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class SetList::KeyCompareFunctor {
|
class SetList::KeyCompareFunctor {
|
||||||
|
@ -1253,4 +1235,4 @@ bool CardDatabase::hasDetectedFirstRun()
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#include <QSettings>
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
|
@ -11,25 +10,23 @@
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "dlg_connect.h"
|
#include "dlg_connect.h"
|
||||||
|
#include "settingscache.h"
|
||||||
|
|
||||||
DlgConnect::DlgConnect(QWidget *parent)
|
DlgConnect::DlgConnect(QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
QSettings settings;
|
|
||||||
settings.beginGroup("server");
|
|
||||||
|
|
||||||
previousHostButton = new QRadioButton(tr("Previous Host"), this);
|
previousHostButton = new QRadioButton(tr("Previous Host"), this);
|
||||||
|
|
||||||
previousHosts = new QComboBox(this);
|
previousHosts = new QComboBox(this);
|
||||||
previousHosts->installEventFilter(new DeleteHighlightedItemWhenShiftDelPressedEventFilter);
|
previousHosts->installEventFilter(new DeleteHighlightedItemWhenShiftDelPressedEventFilter);
|
||||||
QStringList previousHostList = settings.value("previoushosts").toStringList();
|
|
||||||
|
QStringList previousHostList = settingsCache->servers().getPreviousHostList();
|
||||||
if (previousHostList.isEmpty()) {
|
if (previousHostList.isEmpty()) {
|
||||||
previousHostList << "cockatrice.woogerworks.com";
|
previousHostList << "cockatrice.woogerworks.com";
|
||||||
previousHostList << "vps.poixen.com";
|
previousHostList << "vps.poixen.com";
|
||||||
previousHostList << "chickatrice.net";
|
previousHostList << "chickatrice.net";
|
||||||
}
|
}
|
||||||
previousHosts->addItems(previousHostList);
|
previousHosts->addItems(previousHostList);
|
||||||
previousHosts->setCurrentIndex(settings.value("previoushostindex").toInt());
|
previousHosts->setCurrentIndex(settingsCache->servers().getPrevioushostindex());
|
||||||
|
|
||||||
newHostButton = new QRadioButton(tr("New Host"), this);
|
newHostButton = new QRadioButton(tr("New Host"), this);
|
||||||
|
|
||||||
|
@ -39,28 +36,28 @@ DlgConnect::DlgConnect(QWidget *parent)
|
||||||
hostLabel->setBuddy(hostEdit);
|
hostLabel->setBuddy(hostEdit);
|
||||||
|
|
||||||
portLabel = new QLabel(tr("&Port:"));
|
portLabel = new QLabel(tr("&Port:"));
|
||||||
portEdit = new QLineEdit(settings.value("port", "4747").toString());
|
portEdit = new QLineEdit(settingsCache->servers().getPort("4747"));
|
||||||
portLabel->setBuddy(portEdit);
|
portLabel->setBuddy(portEdit);
|
||||||
|
|
||||||
playernameLabel = new QLabel(tr("Player &name:"));
|
playernameLabel = new QLabel(tr("Player &name:"));
|
||||||
playernameEdit = new QLineEdit(settings.value("playername", "Player").toString());
|
playernameEdit = new QLineEdit(settingsCache->servers().getPlayerName("Player"));
|
||||||
playernameLabel->setBuddy(playernameEdit);
|
playernameLabel->setBuddy(playernameEdit);
|
||||||
|
|
||||||
passwordLabel = new QLabel(tr("P&assword:"));
|
passwordLabel = new QLabel(tr("P&assword:"));
|
||||||
passwordEdit = new QLineEdit(settings.value("password").toString());
|
passwordEdit = new QLineEdit(settingsCache->servers().getPassword());
|
||||||
passwordLabel->setBuddy(passwordEdit);
|
passwordLabel->setBuddy(passwordEdit);
|
||||||
passwordEdit->setEchoMode(QLineEdit::Password);
|
passwordEdit->setEchoMode(QLineEdit::Password);
|
||||||
|
|
||||||
savePasswordCheckBox = new QCheckBox(tr("&Save password"));
|
savePasswordCheckBox = new QCheckBox(tr("&Save password"));
|
||||||
savePasswordCheckBox->setChecked(settings.value("save_password", 1).toInt());
|
savePasswordCheckBox->setChecked(settingsCache->servers().getSavePassword());
|
||||||
|
|
||||||
autoConnectCheckBox = new QCheckBox(tr("A&uto connect at start"));
|
autoConnectCheckBox = new QCheckBox(tr("A&uto connect at start"));
|
||||||
if(savePasswordCheckBox->isChecked())
|
if(savePasswordCheckBox->isChecked())
|
||||||
{
|
{
|
||||||
autoConnectCheckBox->setChecked(settings.value("auto_connect", 0).toInt());
|
autoConnectCheckBox->setChecked(settingsCache->servers().getAutoConnect());
|
||||||
autoConnectCheckBox->setEnabled(true);
|
autoConnectCheckBox->setEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
settings.setValue("auto_connect", 0);
|
settingsCache->servers().setAutoConnect(0);
|
||||||
autoConnectCheckBox->setChecked(0);
|
autoConnectCheckBox->setChecked(0);
|
||||||
autoConnectCheckBox->setEnabled(false);
|
autoConnectCheckBox->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
@ -98,7 +95,7 @@ DlgConnect::DlgConnect(QWidget *parent)
|
||||||
connect(previousHostButton, SIGNAL(toggled(bool)), this, SLOT(previousHostSelected(bool)));
|
connect(previousHostButton, SIGNAL(toggled(bool)), this, SLOT(previousHostSelected(bool)));
|
||||||
connect(newHostButton, SIGNAL(toggled(bool)), this, SLOT(newHostSelected(bool)));
|
connect(newHostButton, SIGNAL(toggled(bool)), this, SLOT(newHostSelected(bool)));
|
||||||
|
|
||||||
if (settings.value("previoushostlogin", 1).toInt())
|
if (settingsCache->servers().getPreviousHostLogin())
|
||||||
previousHostButton->setChecked(true);
|
previousHostButton->setChecked(true);
|
||||||
else
|
else
|
||||||
newHostButton->setChecked(true);
|
newHostButton->setChecked(true);
|
||||||
|
@ -133,14 +130,12 @@ void DlgConnect::passwordSaved(int state)
|
||||||
|
|
||||||
void DlgConnect::actOk()
|
void DlgConnect::actOk()
|
||||||
{
|
{
|
||||||
QSettings settings;
|
settingsCache->servers().setPort(portEdit->text());
|
||||||
settings.beginGroup("server");
|
settingsCache->servers().setPlayerName(playernameEdit->text());
|
||||||
settings.setValue("port", portEdit->text());
|
settingsCache->servers().setPassword(savePasswordCheckBox->isChecked() ? passwordEdit->text() : QString());
|
||||||
settings.setValue("playername", playernameEdit->text());
|
settingsCache->servers().setSavePassword(savePasswordCheckBox->isChecked() ? 1 : 0);
|
||||||
settings.setValue("password", savePasswordCheckBox->isChecked() ? passwordEdit->text() : QString());
|
settingsCache->servers().setAutoConnect(autoConnectCheckBox->isChecked() ? 1 : 0);
|
||||||
settings.setValue("save_password", savePasswordCheckBox->isChecked() ? 1 : 0);
|
settingsCache->servers().setPreviousHostLogin(previousHostButton->isChecked() ? 1 : 0);
|
||||||
settings.setValue("auto_connect", autoConnectCheckBox->isChecked() ? 1 : 0);
|
|
||||||
settings.setValue("previoushostlogin", previousHostButton->isChecked() ? 1 : 0);
|
|
||||||
|
|
||||||
QStringList hostList;
|
QStringList hostList;
|
||||||
if (newHostButton->isChecked())
|
if (newHostButton->isChecked())
|
||||||
|
@ -151,9 +146,8 @@ void DlgConnect::actOk()
|
||||||
if(!previousHosts->itemText(i).trimmed().isEmpty())
|
if(!previousHosts->itemText(i).trimmed().isEmpty())
|
||||||
hostList << previousHosts->itemText(i);
|
hostList << previousHosts->itemText(i);
|
||||||
|
|
||||||
settings.setValue("previoushosts", hostList);
|
settingsCache->servers().setPreviousHostList(hostList);
|
||||||
settings.setValue("previoushostindex", previousHosts->currentIndex());
|
settingsCache->servers().setPrevioushostindex(previousHosts->currentIndex());
|
||||||
settings.endGroup();
|
|
||||||
|
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
|
@ -165,12 +159,8 @@ QString DlgConnect::getHost() const {
|
||||||
|
|
||||||
void DlgConnect::actCancel()
|
void DlgConnect::actCancel()
|
||||||
{
|
{
|
||||||
QSettings settings;
|
settingsCache->servers().setSavePassword(savePasswordCheckBox->isChecked() ? 1 : 0);
|
||||||
settings.beginGroup("server");
|
settingsCache->servers().setAutoConnect( autoConnectCheckBox->isChecked() ? 1 : 0);
|
||||||
settings.setValue("save_password", savePasswordCheckBox->isChecked() ? 1 : 0);
|
|
||||||
settings.setValue("auto_connect", autoConnectCheckBox->isChecked() ? 1 : 0);
|
|
||||||
settings.endGroup();
|
|
||||||
|
|
||||||
reject();
|
reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,21 +3,19 @@
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QSettings>
|
|
||||||
|
|
||||||
|
#include "settingscache.h"
|
||||||
#include "dlg_edit_password.h"
|
#include "dlg_edit_password.h"
|
||||||
|
|
||||||
DlgEditPassword::DlgEditPassword(QWidget *parent)
|
DlgEditPassword::DlgEditPassword(QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
QSettings settings;
|
|
||||||
settings.beginGroup("server");
|
|
||||||
|
|
||||||
oldPasswordLabel = new QLabel(tr("Old password:"));
|
oldPasswordLabel = new QLabel(tr("Old password:"));
|
||||||
oldPasswordEdit = new QLineEdit();
|
oldPasswordEdit = new QLineEdit();
|
||||||
|
|
||||||
if(settings.value("save_password", 1).toInt())
|
if(settingsCache->servers().getSavePassword())
|
||||||
oldPasswordEdit->setText(settings.value("password").toString());
|
oldPasswordEdit->setText(settingsCache->servers().getPassword());
|
||||||
|
|
||||||
oldPasswordLabel->setBuddy(oldPasswordEdit);
|
oldPasswordLabel->setBuddy(oldPasswordEdit);
|
||||||
oldPasswordEdit->setEchoMode(QLineEdit::Password);
|
oldPasswordEdit->setEchoMode(QLineEdit::Password);
|
||||||
|
@ -62,12 +60,8 @@ void DlgEditPassword::actOk()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSettings settings;
|
|
||||||
settings.beginGroup("server");
|
|
||||||
// always save the password so it will be picked up by the connect dialog
|
// always save the password so it will be picked up by the connect dialog
|
||||||
settings.setValue("password", newPasswordEdit->text());
|
settingsCache->servers().setPassword(newPasswordEdit->text());
|
||||||
settings.endGroup();
|
|
||||||
|
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#include <QSettings>
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QSettings>
|
|
||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
|
|
||||||
DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes, const GamesProxyModel *_gamesProxyModel, QWidget *parent)
|
DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes, const GamesProxyModel *_gamesProxyModel, QWidget *parent)
|
||||||
|
@ -17,9 +16,6 @@ DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes, const Ga
|
||||||
allGameTypes(_allGameTypes),
|
allGameTypes(_allGameTypes),
|
||||||
gamesProxyModel(_gamesProxyModel)
|
gamesProxyModel(_gamesProxyModel)
|
||||||
{
|
{
|
||||||
QSettings settings;
|
|
||||||
settings.beginGroup("filter_games");
|
|
||||||
|
|
||||||
unavailableGamesVisibleCheckBox = new QCheckBox(tr("Show &unavailable games"));
|
unavailableGamesVisibleCheckBox = new QCheckBox(tr("Show &unavailable games"));
|
||||||
unavailableGamesVisibleCheckBox->setChecked(gamesProxyModel->getUnavailableGamesVisible());
|
unavailableGamesVisibleCheckBox->setChecked(gamesProxyModel->getUnavailableGamesVisible());
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#include <QSettings>
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
|
@ -14,23 +13,20 @@
|
||||||
DlgRegister::DlgRegister(QWidget *parent)
|
DlgRegister::DlgRegister(QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
QSettings settings;
|
|
||||||
settings.beginGroup("server");
|
|
||||||
|
|
||||||
hostLabel = new QLabel(tr("&Host:"));
|
hostLabel = new QLabel(tr("&Host:"));
|
||||||
hostEdit = new QLineEdit(settings.value("hostname", "cockatrice.woogerworks.com").toString());
|
hostEdit = new QLineEdit(settingsCache->servers().getHostname("cockatrice.woogerworks.com"));
|
||||||
hostLabel->setBuddy(hostEdit);
|
hostLabel->setBuddy(hostEdit);
|
||||||
|
|
||||||
portLabel = new QLabel(tr("&Port:"));
|
portLabel = new QLabel(tr("&Port:"));
|
||||||
portEdit = new QLineEdit(settings.value("port", "4747").toString());
|
portEdit = new QLineEdit(settingsCache->servers().getPort("4747"));
|
||||||
portLabel->setBuddy(portEdit);
|
portLabel->setBuddy(portEdit);
|
||||||
|
|
||||||
playernameLabel = new QLabel(tr("Player &name:"));
|
playernameLabel = new QLabel(tr("Player &name:"));
|
||||||
playernameEdit = new QLineEdit(settings.value("playername", "Player").toString());
|
playernameEdit = new QLineEdit(settingsCache->servers().getPlayerName("Player"));
|
||||||
playernameLabel->setBuddy(playernameEdit);
|
playernameLabel->setBuddy(playernameEdit);
|
||||||
|
|
||||||
passwordLabel = new QLabel(tr("P&assword:"));
|
passwordLabel = new QLabel(tr("P&assword:"));
|
||||||
passwordEdit = new QLineEdit(settings.value("password").toString());
|
passwordEdit = new QLineEdit(settingsCache->servers().getPassword());
|
||||||
passwordLabel->setBuddy(passwordEdit);
|
passwordLabel->setBuddy(passwordEdit);
|
||||||
passwordEdit->setEchoMode(QLineEdit::Password);
|
passwordEdit->setEchoMode(QLineEdit::Password);
|
||||||
|
|
||||||
|
@ -119,14 +115,11 @@ void DlgRegister::actOk()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSettings settings;
|
settingsCache->servers().setHostName(hostEdit->text());
|
||||||
settings.beginGroup("server");
|
settingsCache->servers().setPort(portEdit->text());
|
||||||
settings.setValue("hostname", hostEdit->text());
|
settingsCache->servers().setPlayerName(playernameEdit->text());
|
||||||
settings.setValue("port", portEdit->text());
|
|
||||||
settings.setValue("playername", playernameEdit->text());
|
|
||||||
// always save the password so it will be picked up by the connect dialog
|
// always save the password so it will be picked up by the connect dialog
|
||||||
settings.setValue("password", passwordEdit->text());
|
settingsCache->servers().setPassword(passwordEdit->text());
|
||||||
settings.endGroup();
|
|
||||||
|
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QSettings>
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
|
@ -632,12 +631,11 @@ MessagesSettingsPage::MessagesSettingsPage()
|
||||||
highlightGroupBox = new QGroupBox;
|
highlightGroupBox = new QGroupBox;
|
||||||
highlightGroupBox->setLayout(highlightNotice);
|
highlightGroupBox->setLayout(highlightNotice);
|
||||||
|
|
||||||
QSettings settings;
|
|
||||||
messageList = new QListWidget;
|
messageList = new QListWidget;
|
||||||
settings.beginGroup("messages");
|
|
||||||
int count = settings.value("count", 0).toInt();
|
int count = settingsCache->messages().getCount();
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
messageList->addItem(settings.value(QString("msg%1").arg(i)).toString());
|
messageList->addItem(settingsCache->messages().getMessageAt(i));
|
||||||
|
|
||||||
aAdd = new QAction(this);
|
aAdd = new QAction(this);
|
||||||
aAdd->setIcon(QIcon(":/resources/increment.svg"));
|
aAdd->setIcon(QIcon(":/resources/increment.svg"));
|
||||||
|
@ -709,11 +707,9 @@ void MessagesSettingsPage::updateHighlightPreview() {
|
||||||
|
|
||||||
void MessagesSettingsPage::storeSettings()
|
void MessagesSettingsPage::storeSettings()
|
||||||
{
|
{
|
||||||
QSettings settings;
|
settingsCache->messages().setCount(messageList->count());
|
||||||
settings.beginGroup("messages");
|
|
||||||
settings.setValue("count", messageList->count());
|
|
||||||
for (int i = 0; i < messageList->count(); i++)
|
for (int i = 0; i < messageList->count(); i++)
|
||||||
settings.setValue(QString("msg%1").arg(i), messageList->item(i)->text());
|
settingsCache->messages().setMessageAt(i, messageList->item(i)->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesSettingsPage::actAdd()
|
void MessagesSettingsPage::actAdd()
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#include "gamesmodel.h"
|
#include "gamesmodel.h"
|
||||||
#include "pb/serverinfo_game.pb.h"
|
#include "pb/serverinfo_game.pb.h"
|
||||||
#include "pixmapgenerator.h"
|
#include "pixmapgenerator.h"
|
||||||
|
#include "settingscache.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QSettings>
|
|
||||||
#include <QCryptographicHash>
|
|
||||||
|
|
||||||
enum GameListColumn {ROOM, CREATED, DESCRIPTION, CREATOR, GAME_TYPE, RESTRICTIONS, PLAYERS, SPECTATORS};
|
enum GameListColumn {ROOM, CREATED, DESCRIPTION, CREATOR, GAME_TYPE, RESTRICTIONS, PLAYERS, SPECTATORS};
|
||||||
|
|
||||||
|
@ -283,19 +283,17 @@ void GamesProxyModel::resetFilterParameters()
|
||||||
|
|
||||||
void GamesProxyModel::loadFilterParameters(const QMap<int, QString> &allGameTypes)
|
void GamesProxyModel::loadFilterParameters(const QMap<int, QString> &allGameTypes)
|
||||||
{
|
{
|
||||||
QSettings settings;
|
|
||||||
settings.beginGroup("filter_games");
|
|
||||||
|
|
||||||
unavailableGamesVisible = settings.value("unavailable_games_visible", false).toBool();
|
unavailableGamesVisible = settingsCache->gameFilters().isUnavailableGamesVisible();
|
||||||
showPasswordProtectedGames = settings.value("show_password_protected_games", true).toBool();
|
showPasswordProtectedGames = settingsCache->gameFilters().isShowPasswordProtectedGames();
|
||||||
gameNameFilter = settings.value("game_name_filter", "").toString();
|
gameNameFilter = settingsCache->gameFilters().getGameNameFilter();
|
||||||
maxPlayersFilterMin = settings.value("min_players", 1).toInt();
|
maxPlayersFilterMin = settingsCache->gameFilters().getMinPlayers();
|
||||||
maxPlayersFilterMax = settings.value("max_players", DEFAULT_MAX_PLAYERS_MAX).toInt();
|
maxPlayersFilterMax = settingsCache->gameFilters().getMaxPlayers();
|
||||||
|
|
||||||
QMapIterator<int, QString> gameTypesIterator(allGameTypes);
|
QMapIterator<int, QString> gameTypesIterator(allGameTypes);
|
||||||
while (gameTypesIterator.hasNext()) {
|
while (gameTypesIterator.hasNext()) {
|
||||||
gameTypesIterator.next();
|
gameTypesIterator.next();
|
||||||
if (settings.value("game_type/" + hashGameType(gameTypesIterator.value()), false).toBool()) {
|
if (settingsCache->gameFilters().isGameTypeEnabled(gameTypesIterator.value())){
|
||||||
gameTypeFilter.insert(gameTypesIterator.key());
|
gameTypeFilter.insert(gameTypesIterator.key());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -305,28 +303,19 @@ void GamesProxyModel::loadFilterParameters(const QMap<int, QString> &allGameType
|
||||||
|
|
||||||
void GamesProxyModel::saveFilterParameters(const QMap<int, QString> &allGameTypes)
|
void GamesProxyModel::saveFilterParameters(const QMap<int, QString> &allGameTypes)
|
||||||
{
|
{
|
||||||
QSettings settings;
|
settingsCache->gameFilters().setUnavailableGamesVisible(unavailableGamesVisible);
|
||||||
settings.beginGroup("filter_games");
|
settingsCache->gameFilters().setShowPasswordProtectedGames(showPasswordProtectedGames);
|
||||||
|
settingsCache->gameFilters().setGameNameFilter(gameNameFilter);
|
||||||
settings.setValue("unavailable_games_visible", unavailableGamesVisible);
|
|
||||||
settings.setValue(
|
|
||||||
"show_password_protected_games",
|
|
||||||
showPasswordProtectedGames
|
|
||||||
);
|
|
||||||
settings.setValue("game_name_filter", gameNameFilter);
|
|
||||||
|
|
||||||
QMapIterator<int, QString> gameTypeIterator(allGameTypes);
|
QMapIterator<int, QString> gameTypeIterator(allGameTypes);
|
||||||
while (gameTypeIterator.hasNext()) {
|
while (gameTypeIterator.hasNext()) {
|
||||||
gameTypeIterator.next();
|
gameTypeIterator.next();
|
||||||
|
bool enabled = gameTypeFilter.contains(gameTypeIterator.key());
|
||||||
settings.setValue(
|
settingsCache->gameFilters().setGameTypeEnabled(gameTypeIterator.value(),enabled);
|
||||||
"game_type/" + hashGameType(gameTypeIterator.value()),
|
|
||||||
gameTypeFilter.contains(gameTypeIterator.key())
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.setValue("min_players", maxPlayersFilterMin);
|
settingsCache->gameFilters().setMinPlayers(maxPlayersFilterMin);
|
||||||
settings.setValue("max_players", maxPlayersFilterMax);
|
settingsCache->gameFilters().setMaxPlayers(maxPlayersFilterMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GamesProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &/*sourceParent*/) const
|
bool GamesProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &/*sourceParent*/) const
|
||||||
|
@ -367,7 +356,3 @@ bool GamesProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &/*sourc
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GamesProxyModel::hashGameType(const QString &gameType) const {
|
|
||||||
return QCryptographicHash::hash(gameType.toUtf8(), QCryptographicHash::Md5).toHex();
|
|
||||||
}
|
|
||||||
|
|
|
@ -52,13 +52,7 @@ private:
|
||||||
QSet<int> gameTypeFilter;
|
QSet<int> gameTypeFilter;
|
||||||
int maxPlayersFilterMin, maxPlayersFilterMax;
|
int maxPlayersFilterMin, maxPlayersFilterMax;
|
||||||
|
|
||||||
static const int DEFAULT_MAX_PLAYERS_MAX = 99;
|
static const int DEFAULT_MAX_PLAYERS_MAX = 99;
|
||||||
|
|
||||||
/*
|
|
||||||
* The game type might contain special characters, so to use it in
|
|
||||||
* QSettings we just hash it.
|
|
||||||
*/
|
|
||||||
QString hashGameType(const QString &gameType) const;
|
|
||||||
public:
|
public:
|
||||||
GamesProxyModel(QObject *parent = 0, ServerInfo_User *_ownUser = 0);
|
GamesProxyModel(QObject *parent = 0, ServerInfo_User *_ownUser = 0);
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QLibraryInfo>
|
#include <QLibraryInfo>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QSettings>
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
#include "color.h"
|
#include "color.h"
|
||||||
#include "deck_loader.h"
|
#include "deck_loader.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include <QSettings>
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
@ -832,12 +831,10 @@ void Player::initSayMenu()
|
||||||
{
|
{
|
||||||
sayMenu->clear();
|
sayMenu->clear();
|
||||||
|
|
||||||
QSettings settings;
|
int count = settingsCache->messages().getCount();
|
||||||
settings.beginGroup("messages");
|
|
||||||
int count = settings.value("count", 0).toInt();
|
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
QAction *newAction = new QAction(settings.value(QString("msg%1").arg(i)).toString(), this);
|
QAction *newAction = new QAction(settingsCache->messages().getMessageAt(i), this);
|
||||||
if (i <= 10){
|
if (i <= 10){
|
||||||
newAction->setShortcut(QKeySequence("Ctrl+" + QString::number((i + 1) % 10)));
|
newAction->setShortcut(QKeySequence("Ctrl+" + QString::number((i + 1) % 10)));
|
||||||
}
|
}
|
||||||
|
|
36
cockatrice/src/settings/carddatabasesettings.cpp
Normal file
36
cockatrice/src/settings/carddatabasesettings.cpp
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
#include "carddatabasesettings.h"
|
||||||
|
|
||||||
|
CardDatabaseSettings::CardDatabaseSettings(QString settingPath, QObject *parent)
|
||||||
|
: SettingsManager(settingPath+"cardDatabase.ini", parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CardDatabaseSettings::setSortKey(QString shortName, unsigned int sortKey)
|
||||||
|
{
|
||||||
|
setValue(sortKey,"sortkey", "sets", shortName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CardDatabaseSettings::setEnabled(QString shortName, bool enabled)
|
||||||
|
{
|
||||||
|
setValue(enabled, "enabled", "sets", shortName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CardDatabaseSettings::setIsKnown(QString shortName, bool isknown)
|
||||||
|
{
|
||||||
|
setValue(isknown, "isknown", "sets", shortName);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CardDatabaseSettings::getSortKey(QString shortName)
|
||||||
|
{
|
||||||
|
return getValue("sortkey", "sets", shortName).toUInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CardDatabaseSettings::isEnabled(QString shortName)
|
||||||
|
{
|
||||||
|
return getValue("enabled", "sets", shortName).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CardDatabaseSettings::isKnown(QString shortName)
|
||||||
|
{
|
||||||
|
return getValue("isknown", "sets", shortName).toBool();
|
||||||
|
}
|
34
cockatrice/src/settings/carddatabasesettings.h
Normal file
34
cockatrice/src/settings/carddatabasesettings.h
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#ifndef CARDDATABASESETTINGS_H
|
||||||
|
#define CARDDATABASESETTINGS_H
|
||||||
|
|
||||||
|
#include "settingsmanager.h"
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
|
class CardDatabaseSettings : public SettingsManager
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
friend class SettingsCache;
|
||||||
|
public:
|
||||||
|
void setSortKey(QString shortName, unsigned int sortKey);
|
||||||
|
void setEnabled(QString shortName, bool enabled);
|
||||||
|
void setIsKnown(QString shortName, bool isknown);
|
||||||
|
|
||||||
|
unsigned int getSortKey(QString shortName);
|
||||||
|
bool isEnabled(QString shortName);
|
||||||
|
bool isKnown(QString shortName);
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
private:
|
||||||
|
CardDatabaseSettings(QString settingPath, QObject *parent = 0);
|
||||||
|
CardDatabaseSettings( const CardDatabaseSettings& /*other*/ );
|
||||||
|
CardDatabaseSettings( CardDatabaseSettings& /*other*/ );
|
||||||
|
CardDatabaseSettings( volatile const CardDatabaseSettings& /*other*/ );
|
||||||
|
CardDatabaseSettings( volatile CardDatabaseSettings& /*other*/ );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CARDDATABASESETTINGS_H
|
88
cockatrice/src/settings/gamefilterssettings.cpp
Normal file
88
cockatrice/src/settings/gamefilterssettings.cpp
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
#include "gamefilterssettings.h"
|
||||||
|
#include <QCryptographicHash>
|
||||||
|
|
||||||
|
GameFiltersSettings::GameFiltersSettings(QString settingPath, QObject *parent)
|
||||||
|
: SettingsManager(settingPath+"gamefilters.ini", parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The game type might contain special characters, so to use it in
|
||||||
|
* QSettings we just hash it.
|
||||||
|
*/
|
||||||
|
QString GameFiltersSettings::hashGameType(const QString &gameType) const
|
||||||
|
{
|
||||||
|
return QCryptographicHash::hash(gameType.toUtf8(), QCryptographicHash::Md5).toHex();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameFiltersSettings::setUnavailableGamesVisible(bool enabled)
|
||||||
|
{
|
||||||
|
setValue(enabled, "unavailable_games_visible","filter_games");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GameFiltersSettings::isUnavailableGamesVisible()
|
||||||
|
{
|
||||||
|
QVariant previous = getValue("unavailable_games_visible","filter_games");
|
||||||
|
return previous == QVariant() ? false : previous.toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameFiltersSettings::setShowPasswordProtectedGames(bool show)
|
||||||
|
{
|
||||||
|
setValue(show, "show_password_protected_games","filter_games");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GameFiltersSettings::isShowPasswordProtectedGames()
|
||||||
|
{
|
||||||
|
QVariant previous = getValue("show_password_protected_games","filter_games");
|
||||||
|
return previous == QVariant() ? true : previous.toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameFiltersSettings::setGameNameFilter(QString gameName)
|
||||||
|
{
|
||||||
|
setValue(gameName, "game_name_filter","filter_games");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString GameFiltersSettings::getGameNameFilter()
|
||||||
|
{
|
||||||
|
return getValue("game_name_filter","filter_games").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameFiltersSettings::setMinPlayers(int min)
|
||||||
|
{
|
||||||
|
setValue(min, "min_players","filter_games");
|
||||||
|
}
|
||||||
|
|
||||||
|
int GameFiltersSettings::getMinPlayers()
|
||||||
|
{
|
||||||
|
QVariant previous = getValue("min_players","filter_games");
|
||||||
|
return previous == QVariant() ? 1 : previous.toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameFiltersSettings::setMaxPlayers(int max)
|
||||||
|
{
|
||||||
|
setValue(max, "max_players","filter_games");
|
||||||
|
}
|
||||||
|
|
||||||
|
int GameFiltersSettings::getMaxPlayers()
|
||||||
|
{
|
||||||
|
QVariant previous = getValue("max_players","filter_games");
|
||||||
|
return previous == QVariant() ? 99 : previous.toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameFiltersSettings::setGameTypeEnabled(QString gametype, bool enabled)
|
||||||
|
{
|
||||||
|
setValue(enabled, "game_type/"+hashGameType(gametype),"filter_games");
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameFiltersSettings::setGameHashedTypeEnabled(QString gametypeHASHED, bool enabled)
|
||||||
|
{
|
||||||
|
setValue(enabled, gametypeHASHED,"filter_games");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GameFiltersSettings::isGameTypeEnabled(QString gametype)
|
||||||
|
{
|
||||||
|
QVariant previous = getValue("game_type/"+hashGameType(gametype),"filter_games");
|
||||||
|
return previous == QVariant() ? false : previous.toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
39
cockatrice/src/settings/gamefilterssettings.h
Normal file
39
cockatrice/src/settings/gamefilterssettings.h
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
#ifndef GAMEFILTERSSETTINGS_H
|
||||||
|
#define GAMEFILTERSSETTINGS_H
|
||||||
|
|
||||||
|
#include "settingsmanager.h"
|
||||||
|
|
||||||
|
class GameFiltersSettings : public SettingsManager
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
friend class SettingsCache;
|
||||||
|
public:
|
||||||
|
bool isUnavailableGamesVisible();
|
||||||
|
bool isShowPasswordProtectedGames();
|
||||||
|
QString getGameNameFilter();
|
||||||
|
int getMinPlayers();
|
||||||
|
int getMaxPlayers();
|
||||||
|
bool isGameTypeEnabled(QString gametype);
|
||||||
|
|
||||||
|
void setUnavailableGamesVisible(bool enabled);
|
||||||
|
void setShowPasswordProtectedGames(bool show);
|
||||||
|
void setGameNameFilter(QString gameName);
|
||||||
|
void setMinPlayers(int min);
|
||||||
|
void setMaxPlayers(int max);
|
||||||
|
void setGameTypeEnabled(QString gametype, bool enabled);
|
||||||
|
void setGameHashedTypeEnabled(QString gametypeHASHED, bool enabled);
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
private:
|
||||||
|
GameFiltersSettings(QString settingPath,QObject *parent = 0);
|
||||||
|
GameFiltersSettings( const GameFiltersSettings& /*other*/ );
|
||||||
|
GameFiltersSettings( GameFiltersSettings& /*other*/ );
|
||||||
|
GameFiltersSettings( volatile const GameFiltersSettings& /*other*/ );
|
||||||
|
GameFiltersSettings( volatile GameFiltersSettings& /*other*/ );
|
||||||
|
|
||||||
|
QString hashGameType(const QString &gameType) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GAMEFILTERSSETTINGS_H
|
59
cockatrice/src/settings/layoutssettings.cpp
Normal file
59
cockatrice/src/settings/layoutssettings.cpp
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
#include "layoutssettings.h"
|
||||||
|
|
||||||
|
LayoutsSettings::LayoutsSettings(QString settingPath, QObject *parent)
|
||||||
|
: SettingsManager(settingPath+"layouts.ini", parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const QByteArray LayoutsSettings::getDeckEditorLayoutState()
|
||||||
|
{
|
||||||
|
return getValue("layouts/deckEditor_state").toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LayoutsSettings::setDeckEditorLayoutState(const QByteArray &value)
|
||||||
|
{
|
||||||
|
setValue(value,"layouts/deckEditor_state");
|
||||||
|
}
|
||||||
|
|
||||||
|
const QByteArray LayoutsSettings::getDeckEditorGeometry()
|
||||||
|
{
|
||||||
|
return getValue("layouts/deckEditor_geometry").toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LayoutsSettings::setDeckEditorGeometry(const QByteArray &value)
|
||||||
|
{
|
||||||
|
setValue(value,"layouts/deckEditor_geometry");
|
||||||
|
}
|
||||||
|
|
||||||
|
const QSize LayoutsSettings::getDeckEditorCardSize()
|
||||||
|
{
|
||||||
|
QVariant previous = getValue("layouts/deckEditor_CardSize");
|
||||||
|
return previous == QVariant() ? QSize(250,500) : previous.toSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LayoutsSettings::setDeckEditorCardSize(const QSize &value)
|
||||||
|
{
|
||||||
|
setValue(value,"layouts/deckEditor_CardSize");
|
||||||
|
}
|
||||||
|
|
||||||
|
const QSize LayoutsSettings::getDeckEditorDeckSize()
|
||||||
|
{
|
||||||
|
QVariant previous = getValue("layouts/deckEditor_DeckSize");
|
||||||
|
return previous == QVariant() ? QSize(250,360) : previous.toSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LayoutsSettings::setDeckEditorDeckSize(const QSize &value)
|
||||||
|
{
|
||||||
|
setValue(value,"layouts/deckEditor_DeckSize");
|
||||||
|
}
|
||||||
|
|
||||||
|
const QSize LayoutsSettings::getDeckEditorFilterSize()
|
||||||
|
{
|
||||||
|
QVariant previous = getValue("layouts/deckEditor_FilterSize");
|
||||||
|
return previous == QVariant() ? QSize(250,250) : previous.toSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LayoutsSettings::setDeckEditorFilterSize(const QSize &value)
|
||||||
|
{
|
||||||
|
setValue(value,"layouts/deckEditor_FilterSize");
|
||||||
|
}
|
36
cockatrice/src/settings/layoutssettings.h
Normal file
36
cockatrice/src/settings/layoutssettings.h
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
#ifndef LAYOUTSSETTINGS_H
|
||||||
|
#define LAYOUTSSETTINGS_H
|
||||||
|
|
||||||
|
#include "settingsmanager.h"
|
||||||
|
#include <QSize>
|
||||||
|
|
||||||
|
class LayoutsSettings : public SettingsManager
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
friend class SettingsCache;
|
||||||
|
public:
|
||||||
|
|
||||||
|
void setDeckEditorLayoutState(const QByteArray &value);
|
||||||
|
void setDeckEditorGeometry(const QByteArray &value);
|
||||||
|
void setDeckEditorCardSize(const QSize &value);
|
||||||
|
void setDeckEditorDeckSize(const QSize &value);
|
||||||
|
void setDeckEditorFilterSize(const QSize &value);
|
||||||
|
|
||||||
|
const QByteArray getDeckEditorLayoutState();
|
||||||
|
const QByteArray getDeckEditorGeometry();
|
||||||
|
const QSize getDeckEditorCardSize();
|
||||||
|
const QSize getDeckEditorDeckSize();
|
||||||
|
const QSize getDeckEditorFilterSize();
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
private:
|
||||||
|
LayoutsSettings(QString settingPath,QObject *parent = 0);
|
||||||
|
LayoutsSettings( const LayoutsSettings& /*other*/ );
|
||||||
|
LayoutsSettings( LayoutsSettings& /*other*/ );
|
||||||
|
LayoutsSettings( volatile const LayoutsSettings& /*other*/ );
|
||||||
|
LayoutsSettings( volatile LayoutsSettings& /*other*/ );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LAYOUTSSETTINGS_H
|
26
cockatrice/src/settings/messagesettings.cpp
Normal file
26
cockatrice/src/settings/messagesettings.cpp
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#include "messagesettings.h"
|
||||||
|
|
||||||
|
MessageSettings::MessageSettings(QString settingPath, QObject *parent)
|
||||||
|
: SettingsManager(settingPath+"messages.ini",parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QString MessageSettings::getMessageAt(int index)
|
||||||
|
{
|
||||||
|
return getValue(QString("msg%1").arg(index),"messages").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
int MessageSettings::getCount()
|
||||||
|
{
|
||||||
|
return getValue("count", "messages").toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessageSettings::setCount(int count)
|
||||||
|
{
|
||||||
|
setValue(count,"count","messages");
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessageSettings::setMessageAt(int index, QString message)
|
||||||
|
{
|
||||||
|
setValue(message,QString("msg%1").arg(index),"messages");
|
||||||
|
}
|
29
cockatrice/src/settings/messagesettings.h
Normal file
29
cockatrice/src/settings/messagesettings.h
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#ifndef MESSAGESETTINGS_H
|
||||||
|
#define MESSAGESETTINGS_H
|
||||||
|
|
||||||
|
#include "settingsmanager.h"
|
||||||
|
|
||||||
|
class MessageSettings : public SettingsManager
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
friend class SettingsCache;
|
||||||
|
|
||||||
|
public:
|
||||||
|
int getCount();
|
||||||
|
QString getMessageAt(int index);
|
||||||
|
|
||||||
|
void setCount(int count);
|
||||||
|
void setMessageAt(int index, QString message);
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
private:
|
||||||
|
MessageSettings(QString settingPath, QObject *parent = 0);
|
||||||
|
MessageSettings( const MessageSettings& /*other*/ );
|
||||||
|
MessageSettings( MessageSettings& /*other*/ );
|
||||||
|
MessageSettings( volatile const MessageSettings& /*other*/ );
|
||||||
|
MessageSettings( volatile MessageSettings& /*other*/ );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MESSAGESETTINGS_H
|
102
cockatrice/src/settings/serverssettings.cpp
Normal file
102
cockatrice/src/settings/serverssettings.cpp
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
#include "serverssettings.h"
|
||||||
|
|
||||||
|
ServersSettings::ServersSettings(QString settingPath, QObject *parent)
|
||||||
|
: SettingsManager(settingPath+"servers.ini", parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServersSettings::setPreviousHostLogin(int previous)
|
||||||
|
{
|
||||||
|
setValue(previous, "previoushostlogin", "server");
|
||||||
|
}
|
||||||
|
|
||||||
|
int ServersSettings::getPreviousHostLogin()
|
||||||
|
{
|
||||||
|
QVariant previous = getValue("previoushostlogin", "server");
|
||||||
|
return previous == QVariant() ? 1 : previous.toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServersSettings::setPreviousHostList(QStringList list)
|
||||||
|
{
|
||||||
|
setValue(list, "previoushosts", "server");
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList ServersSettings::getPreviousHostList()
|
||||||
|
{
|
||||||
|
return getValue("previoushosts", "server").toStringList();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServersSettings::setPrevioushostindex(int index)
|
||||||
|
{
|
||||||
|
setValue(index, "previoushostindex", "server");
|
||||||
|
}
|
||||||
|
|
||||||
|
int ServersSettings::getPrevioushostindex()
|
||||||
|
{
|
||||||
|
return getValue("previoushostindex", "server").toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServersSettings::setHostName(QString hostname)
|
||||||
|
{
|
||||||
|
setValue(hostname, "hostname", "server");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ServersSettings::getHostname(QString defaultHost)
|
||||||
|
{
|
||||||
|
QVariant hostname = getValue("hostname","server");
|
||||||
|
return hostname == QVariant() ? defaultHost : hostname.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServersSettings::setPort(QString port)
|
||||||
|
{
|
||||||
|
setValue(port, "port", "server");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ServersSettings::getPort(QString defaultPort)
|
||||||
|
{
|
||||||
|
QVariant port = getValue("port","server");
|
||||||
|
return port == QVariant() ? defaultPort : port.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServersSettings::setPlayerName(QString playerName)
|
||||||
|
{
|
||||||
|
setValue(playerName, "playername", "server");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ServersSettings::getPlayerName(QString defaultName)
|
||||||
|
{
|
||||||
|
QVariant name = getValue("playername", "server");
|
||||||
|
return name == QVariant() ? defaultName : name.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServersSettings::setPassword(QString password)
|
||||||
|
{
|
||||||
|
setValue(password, "password", "server");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ServersSettings::getPassword()
|
||||||
|
{
|
||||||
|
return getValue("password", "server").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServersSettings::setSavePassword(int save)
|
||||||
|
{
|
||||||
|
setValue(save, "save_password", "server");
|
||||||
|
}
|
||||||
|
|
||||||
|
int ServersSettings::getSavePassword()
|
||||||
|
{
|
||||||
|
QVariant save = getValue("save_password", "server");
|
||||||
|
return save == QVariant() ? 1 : save.toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServersSettings::setAutoConnect(int autoconnect)
|
||||||
|
{
|
||||||
|
setValue(autoconnect, "auto_connect", "server");
|
||||||
|
}
|
||||||
|
|
||||||
|
int ServersSettings::getAutoConnect()
|
||||||
|
{
|
||||||
|
QVariant autoconnect = getValue("auto_connect", "server");
|
||||||
|
return autoconnect == QVariant() ? 0 : autoconnect.toInt();
|
||||||
|
}
|
44
cockatrice/src/settings/serverssettings.h
Normal file
44
cockatrice/src/settings/serverssettings.h
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
#ifndef SERVERSSETTINGS_H
|
||||||
|
#define SERVERSSETTINGS_H
|
||||||
|
|
||||||
|
#include "settingsmanager.h"
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class ServersSettings : public SettingsManager
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
friend class SettingsCache;
|
||||||
|
|
||||||
|
public:
|
||||||
|
int getPreviousHostLogin();
|
||||||
|
QStringList getPreviousHostList();
|
||||||
|
int getPrevioushostindex();
|
||||||
|
QString getHostname(QString defaultHost = "");
|
||||||
|
QString getPort(QString defaultPort = "");
|
||||||
|
QString getPlayerName(QString defaultName = "");
|
||||||
|
QString getPassword();
|
||||||
|
int getSavePassword();
|
||||||
|
int getAutoConnect();
|
||||||
|
|
||||||
|
void setPreviousHostLogin(int previous);
|
||||||
|
void setPreviousHostList(QStringList list);
|
||||||
|
void setPrevioushostindex(int index);
|
||||||
|
void setHostName(QString hostname);
|
||||||
|
void setPort(QString port);
|
||||||
|
void setPlayerName(QString playerName);
|
||||||
|
void setPassword(QString password);
|
||||||
|
void setSavePassword(int save);
|
||||||
|
void setAutoConnect(int autoconnect);
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
private:
|
||||||
|
ServersSettings(QString settingPath,QObject *parent = 0);
|
||||||
|
ServersSettings( const ServersSettings& /*other*/ );
|
||||||
|
ServersSettings( ServersSettings& /*other*/ );
|
||||||
|
ServersSettings( volatile const ServersSettings& /*other*/ );
|
||||||
|
ServersSettings( volatile ServersSettings& /*other*/ );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SERVERSSETTINGS_H
|
43
cockatrice/src/settings/settingsmanager.cpp
Normal file
43
cockatrice/src/settings/settingsmanager.cpp
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
#include "settingsmanager.h"
|
||||||
|
|
||||||
|
SettingsManager::SettingsManager(QString settingPath, QObject *parent)
|
||||||
|
: QObject(parent),
|
||||||
|
settings(settingPath, QSettings::IniFormat)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsManager::setValue(QVariant value, QString name, QString group, QString subGroup)
|
||||||
|
{
|
||||||
|
if(!group.isEmpty())
|
||||||
|
settings.beginGroup(group);
|
||||||
|
|
||||||
|
if(!subGroup.isEmpty())
|
||||||
|
settings.beginGroup(subGroup);
|
||||||
|
|
||||||
|
settings.setValue(name, value);
|
||||||
|
|
||||||
|
if(!subGroup.isEmpty())
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
if(!group.isEmpty())
|
||||||
|
settings.endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant SettingsManager::getValue(QString name, QString group, QString subGroup)
|
||||||
|
{
|
||||||
|
if(!group.isEmpty())
|
||||||
|
settings.beginGroup(group);
|
||||||
|
|
||||||
|
if(!subGroup.isEmpty())
|
||||||
|
settings.beginGroup(subGroup);
|
||||||
|
|
||||||
|
QVariant value = settings.value(name);
|
||||||
|
|
||||||
|
if(!subGroup.isEmpty())
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
if(!group.isEmpty())
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
25
cockatrice/src/settings/settingsmanager.h
Normal file
25
cockatrice/src/settings/settingsmanager.h
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#ifndef SETTINGSMANAGER_H
|
||||||
|
#define SETTINGSMANAGER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
|
class SettingsManager : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
SettingsManager(QString settingPath, QObject *parent = 0);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QSettings settings;
|
||||||
|
QVariant getValue(QString name, QString group = "", QString subGroup = "" );
|
||||||
|
void setValue(QVariant value, QString name, QString group = "", QString subGroup = "" );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SETTINGSMANAGER_H
|
|
@ -1,5 +1,6 @@
|
||||||
#include "settingscache.h"
|
#include "settingscache.h"
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <QFile>
|
||||||
#if QT_VERSION >= 0x050000
|
#if QT_VERSION >= 0x050000
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#else
|
#else
|
||||||
|
@ -11,7 +12,7 @@ QString SettingsCache::getSettingsPath()
|
||||||
QString file = "";
|
QString file = "";
|
||||||
|
|
||||||
#ifndef PORTABLE_BUILD
|
#ifndef PORTABLE_BUILD
|
||||||
#if QT_VERSION >= 0x050000
|
#if QT_VERSION >= 0x050000
|
||||||
file = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
|
file = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
|
||||||
#else
|
#else
|
||||||
file = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
file = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
||||||
|
@ -19,17 +20,117 @@ QString SettingsCache::getSettingsPath()
|
||||||
file.append("/settings/");
|
file.append("/settings/");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return file;
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsCache::translateLegacySettings()
|
||||||
|
{
|
||||||
|
//NOTE Please remove this legacy setting translation after 2016-9-1 (+1 year after creation)
|
||||||
|
|
||||||
|
//Layouts
|
||||||
|
QFile layoutFile(getSettingsPath()+"layouts/deckLayout.ini");
|
||||||
|
if(layoutFile.exists())
|
||||||
|
if(layoutFile.copy(getSettingsPath()+"layouts.ini"))
|
||||||
|
layoutFile.remove();
|
||||||
|
|
||||||
|
QStringList usedKeys;
|
||||||
|
QSettings legacySetting;
|
||||||
|
|
||||||
|
//Sets
|
||||||
|
legacySetting.beginGroup("sets");
|
||||||
|
QStringList setsGroups = legacySetting.childGroups();
|
||||||
|
for(int i = 0; i < setsGroups.size(); i++){
|
||||||
|
legacySetting.beginGroup(setsGroups.at(i));
|
||||||
|
cardDatabase().setEnabled(setsGroups.at(i), legacySetting.value("enabled").toBool());
|
||||||
|
cardDatabase().setIsKnown(setsGroups.at(i), legacySetting.value("isknown").toBool());
|
||||||
|
cardDatabase().setSortKey(setsGroups.at(i), legacySetting.value("sortkey").toUInt());
|
||||||
|
legacySetting.endGroup();
|
||||||
|
}
|
||||||
|
QStringList setsKeys = legacySetting.allKeys();
|
||||||
|
for (int i = 0; i < setsKeys.size(); ++i) {
|
||||||
|
usedKeys.append("sets/"+setsKeys.at(i));
|
||||||
|
}
|
||||||
|
legacySetting.endGroup();
|
||||||
|
|
||||||
|
//Servers
|
||||||
|
legacySetting.beginGroup("server");
|
||||||
|
servers().setPreviousHostLogin(legacySetting.value("previoushostlogin").toInt());
|
||||||
|
servers().setPreviousHostList(legacySetting.value("previoushosts").toStringList());
|
||||||
|
servers().setPrevioushostindex(legacySetting.value("previoushostindex").toInt());
|
||||||
|
servers().setHostName(legacySetting.value("hostname").toString());
|
||||||
|
servers().setPort(legacySetting.value("port").toString());
|
||||||
|
servers().setPlayerName(legacySetting.value("playername").toString());
|
||||||
|
servers().setPassword(legacySetting.value("password").toString());
|
||||||
|
servers().setSavePassword(legacySetting.value("save_password").toInt());
|
||||||
|
servers().setAutoConnect(legacySetting.value("auto_connect").toInt());
|
||||||
|
usedKeys.append(legacySetting.allKeys());
|
||||||
|
QStringList allKeysServer = legacySetting.allKeys();
|
||||||
|
for (int i = 0; i < allKeysServer.size(); ++i) {
|
||||||
|
usedKeys.append("server/"+allKeysServer.at(i));
|
||||||
|
}
|
||||||
|
legacySetting.endGroup();
|
||||||
|
|
||||||
|
//Messages
|
||||||
|
legacySetting.beginGroup("messages");
|
||||||
|
QStringList allMessages = legacySetting.allKeys();
|
||||||
|
for (int i = 0; i < allMessages.size(); ++i) {
|
||||||
|
if(allMessages.at(i) != "count"){
|
||||||
|
QString temp = allMessages.at(i);
|
||||||
|
int index = temp.remove("msg").toInt();
|
||||||
|
messages().setMessageAt(index,legacySetting.value(allMessages.at(i)).toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
messages().setCount(legacySetting.value("count").toInt());
|
||||||
|
QStringList allKeysmessages = legacySetting.allKeys();
|
||||||
|
for (int i = 0; i < allKeysmessages.size(); ++i) {
|
||||||
|
usedKeys.append("messages/"+allKeysmessages.at(i));
|
||||||
|
}
|
||||||
|
legacySetting.endGroup();
|
||||||
|
|
||||||
|
//Game filters
|
||||||
|
legacySetting.beginGroup("filter_games");
|
||||||
|
gameFilters().setUnavailableGamesVisible(legacySetting.value("unavailable_games_visible").toBool());
|
||||||
|
gameFilters().setShowPasswordProtectedGames(legacySetting.value("show_password_protected_games").toBool());
|
||||||
|
gameFilters().setGameNameFilter(legacySetting.value("game_name_filter").toString());
|
||||||
|
gameFilters().setMinPlayers(legacySetting.value("min_players").toInt());
|
||||||
|
gameFilters().setMaxPlayers(legacySetting.value("max_players").toInt());
|
||||||
|
|
||||||
|
QStringList allFilters = legacySetting.allKeys();
|
||||||
|
for (int i = 0; i < allFilters.size(); ++i) {
|
||||||
|
if(allFilters.at(i).startsWith("game_type")){
|
||||||
|
gameFilters().setGameTypeEnabled(allFilters.at(i), legacySetting.value(allFilters.at(i)).toBool());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QStringList allKeysfilter_games = legacySetting.allKeys();
|
||||||
|
for (int i = 0; i < allKeysfilter_games.size(); ++i) {
|
||||||
|
usedKeys.append("filter_games/"+allKeysfilter_games.at(i));
|
||||||
|
}
|
||||||
|
legacySetting.endGroup();
|
||||||
|
|
||||||
|
QStringList allLegacyKeys = legacySetting.allKeys();
|
||||||
|
for (int i = 0; i < allLegacyKeys.size(); ++i) {
|
||||||
|
if(usedKeys.contains(allLegacyKeys.at(i)))
|
||||||
|
continue;
|
||||||
|
settings->setValue(allLegacyKeys.at(i), legacySetting.value(allLegacyKeys.at(i)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsCache::SettingsCache()
|
SettingsCache::SettingsCache()
|
||||||
{
|
{
|
||||||
settings = new QSettings(this);
|
QString settingsPath = getSettingsPath();
|
||||||
shortcutsSettings = new ShortcutsSettings(getSettingsPath(),this);
|
settings = new QSettings(settingsPath+"global.ini", QSettings::IniFormat, this);
|
||||||
|
shortcutsSettings = new ShortcutsSettings(settingsPath,this);
|
||||||
|
cardDatabaseSettings = new CardDatabaseSettings(settingsPath,this);
|
||||||
|
serversSettings = new ServersSettings(settingsPath,this);
|
||||||
|
messageSettings = new MessageSettings(settingsPath,this);
|
||||||
|
gameFiltersSettings = new GameFiltersSettings(settingsPath, this);
|
||||||
|
layoutsSettings = new LayoutsSettings(settingsPath, this);
|
||||||
|
|
||||||
|
if(!QFile(settingsPath+"global.ini").exists())
|
||||||
|
translateLegacySettings();
|
||||||
|
|
||||||
lang = settings->value("personal/lang").toString();
|
lang = settings->value("personal/lang").toString();
|
||||||
keepalive = settings->value("personal/keepalive", 5).toInt();
|
keepalive = settings->value("personal/keepalive", 5).toInt();
|
||||||
|
|
||||||
deckPath = settings->value("paths/decks").toString();
|
deckPath = settings->value("paths/decks").toString();
|
||||||
replaysPath = settings->value("paths/replays").toString();
|
replaysPath = settings->value("paths/replays").toString();
|
||||||
picsPath = settings->value("paths/pics").toString();
|
picsPath = settings->value("paths/pics").toString();
|
||||||
|
@ -119,17 +220,6 @@ SettingsCache::SettingsCache()
|
||||||
spectatorsCanTalk = settings->value("game/spectatorscantalk", false).toBool();
|
spectatorsCanTalk = settings->value("game/spectatorscantalk", false).toBool();
|
||||||
spectatorsCanSeeEverything = settings->value("game/spectatorscanseeeverything", false).toBool();
|
spectatorsCanSeeEverything = settings->value("game/spectatorscanseeeverything", false).toBool();
|
||||||
clientID = settings->value("personal/clientid", "notset").toString();
|
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) {
|
void SettingsCache::setCardInfoViewMode(const int _viewMode) {
|
||||||
|
@ -502,56 +592,6 @@ QStringList SettingsCache::getCountries() const
|
||||||
return countries;
|
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)
|
void SettingsCache::setGameDescription(const QString _gameDescription)
|
||||||
{
|
{
|
||||||
gameDescription = _gameDescription;
|
gameDescription = _gameDescription;
|
||||||
|
|
|
@ -5,6 +5,11 @@
|
||||||
#include <QSize>
|
#include <QSize>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include "shortcutssettings.h"
|
#include "shortcutssettings.h"
|
||||||
|
#include "settings/carddatabasesettings.h"
|
||||||
|
#include "settings/serverssettings.h"
|
||||||
|
#include "settings/messagesettings.h"
|
||||||
|
#include "settings/gamefilterssettings.h"
|
||||||
|
#include "settings/layoutssettings.h"
|
||||||
|
|
||||||
// the falbacks are used for cards without a muid
|
// the falbacks are used for cards without a muid
|
||||||
#define PIC_URL_DEFAULT "http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=!cardid!&type=card"
|
#define PIC_URL_DEFAULT "http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=!cardid!&type=card"
|
||||||
|
@ -48,6 +53,12 @@ signals:
|
||||||
private:
|
private:
|
||||||
QSettings *settings;
|
QSettings *settings;
|
||||||
ShortcutsSettings *shortcutsSettings;
|
ShortcutsSettings *shortcutsSettings;
|
||||||
|
CardDatabaseSettings *cardDatabaseSettings;
|
||||||
|
ServersSettings *serversSettings;
|
||||||
|
MessageSettings *messageSettings;
|
||||||
|
GameFiltersSettings *gameFiltersSettings;
|
||||||
|
LayoutsSettings *layoutsSettings;
|
||||||
|
|
||||||
QByteArray mainWindowGeometry;
|
QByteArray mainWindowGeometry;
|
||||||
QString lang;
|
QString lang;
|
||||||
QString deckPath, replaysPath, picsPath, cardDatabasePath, tokenDatabasePath;
|
QString deckPath, replaysPath, picsPath, cardDatabasePath, tokenDatabasePath;
|
||||||
|
@ -103,10 +114,8 @@ private:
|
||||||
bool spectatorsCanTalk;
|
bool spectatorsCanTalk;
|
||||||
bool spectatorsCanSeeEverything;
|
bool spectatorsCanSeeEverything;
|
||||||
int keepalive;
|
int keepalive;
|
||||||
QByteArray deckEditorLayoutState, deckEditorGeometry;
|
|
||||||
QSize deckEditorFilterSize, deckEditorDeckSize, deckEditorCardSize;
|
|
||||||
QString getSettingsPath();
|
QString getSettingsPath();
|
||||||
|
void translateLegacySettings();
|
||||||
public:
|
public:
|
||||||
SettingsCache();
|
SettingsCache();
|
||||||
const QByteArray &getMainWindowGeometry() const { return mainWindowGeometry; }
|
const QByteArray &getMainWindowGeometry() const { return mainWindowGeometry; }
|
||||||
|
@ -180,19 +189,13 @@ public:
|
||||||
bool getSpectatorsCanSeeEverything() const { return spectatorsCanSeeEverything; }
|
bool getSpectatorsCanSeeEverything() const { return spectatorsCanSeeEverything; }
|
||||||
int getKeepAlive() const { return keepalive; }
|
int getKeepAlive() const { return keepalive; }
|
||||||
void setClientID(QString clientID);
|
void setClientID(QString clientID);
|
||||||
QString getClientID() { return clientID; }
|
QString getClientID() { return clientID; }
|
||||||
QByteArray getDeckEditorLayoutState() const { return deckEditorLayoutState; }
|
|
||||||
void setDeckEditorLayoutState(const QByteArray &value);
|
|
||||||
QByteArray getDeckEditorGeometry() const { return deckEditorGeometry; }
|
|
||||||
void setDeckEditorGeometry(const QByteArray &value);
|
|
||||||
QSize getDeckEditorCardSize() const { return deckEditorCardSize; }
|
|
||||||
void setDeckEditorCardSize(const QSize &value);
|
|
||||||
QSize getDeckEditorDeckSize() const { return deckEditorDeckSize; }
|
|
||||||
void setDeckEditorDeckSize(const QSize &value);
|
|
||||||
QSize getDeckEditorFilterSize() const { return deckEditorFilterSize; }
|
|
||||||
void setDeckEditorFilterSize(const QSize &value);
|
|
||||||
ShortcutsSettings& shortcuts() const { return *shortcutsSettings; }
|
ShortcutsSettings& shortcuts() const { return *shortcutsSettings; }
|
||||||
|
CardDatabaseSettings& cardDatabase() const { return *cardDatabaseSettings; }
|
||||||
|
ServersSettings& servers() const { return *serversSettings; }
|
||||||
|
MessageSettings& messages() const { return *messageSettings; }
|
||||||
|
GameFiltersSettings& gameFilters() const { return *gameFiltersSettings; }
|
||||||
|
LayoutsSettings& layouts() const { return *layoutsSettings; }
|
||||||
public slots:
|
public slots:
|
||||||
void setMainWindowGeometry(const QByteArray &_mainWindowGeometry);
|
void setMainWindowGeometry(const QByteArray &_mainWindowGeometry);
|
||||||
void setLang(const QString &_lang);
|
void setLang(const QString &_lang);
|
||||||
|
|
|
@ -494,21 +494,21 @@ void TabDeckEditor::refreshShortcuts()
|
||||||
|
|
||||||
void TabDeckEditor::loadLayout()
|
void TabDeckEditor::loadLayout()
|
||||||
{
|
{
|
||||||
MainWindow->restoreState(settingsCache->getDeckEditorLayoutState());
|
MainWindow->restoreState(settingsCache->layouts().getDeckEditorLayoutState());
|
||||||
MainWindow->restoreGeometry(settingsCache->getDeckEditorGeometry());
|
MainWindow->restoreGeometry(settingsCache->layouts().getDeckEditorGeometry());
|
||||||
|
|
||||||
btnCard->setChecked(!cardInfoDock->isHidden());
|
btnCard->setChecked(!cardInfoDock->isHidden());
|
||||||
btnFilter->setChecked(!filterDock->isHidden());
|
btnFilter->setChecked(!filterDock->isHidden());
|
||||||
btnDeck->setChecked(!deckDock->isHidden());
|
btnDeck->setChecked(!deckDock->isHidden());
|
||||||
|
|
||||||
cardInfoDock->setMinimumSize(settingsCache->getDeckEditorCardSize());
|
cardInfoDock->setMinimumSize(settingsCache->layouts().getDeckEditorCardSize());
|
||||||
cardInfoDock->setMaximumSize(settingsCache->getDeckEditorCardSize());
|
cardInfoDock->setMaximumSize(settingsCache->layouts().getDeckEditorCardSize());
|
||||||
|
|
||||||
filterDock->setMinimumSize(settingsCache->getDeckEditorFilterSize());
|
filterDock->setMinimumSize(settingsCache->layouts().getDeckEditorFilterSize());
|
||||||
filterDock->setMaximumSize(settingsCache->getDeckEditorFilterSize());
|
filterDock->setMaximumSize(settingsCache->layouts().getDeckEditorFilterSize());
|
||||||
|
|
||||||
deckDock->setMinimumSize(settingsCache->getDeckEditorDeckSize());
|
deckDock->setMinimumSize(settingsCache->layouts().getDeckEditorDeckSize());
|
||||||
deckDock->setMaximumSize(settingsCache->getDeckEditorDeckSize());
|
deckDock->setMaximumSize(settingsCache->layouts().getDeckEditorDeckSize());
|
||||||
|
|
||||||
QTimer::singleShot(100, this, SLOT(freeDocksSize()));
|
QTimer::singleShot(100, this, SLOT(freeDocksSize()));
|
||||||
}
|
}
|
||||||
|
@ -1009,11 +1009,11 @@ bool TabDeckEditor::eventFilter(QObject * o, QEvent * e)
|
||||||
btnFilter->setChecked(false);
|
btnFilter->setChecked(false);
|
||||||
}
|
}
|
||||||
if( o == this && e->type() == QEvent::Hide){
|
if( o == this && e->type() == QEvent::Hide){
|
||||||
settingsCache->setDeckEditorLayoutState(MainWindow->saveState());
|
settingsCache->layouts().setDeckEditorLayoutState(MainWindow->saveState());
|
||||||
settingsCache->setDeckEditorGeometry(MainWindow->saveGeometry());
|
settingsCache->layouts().setDeckEditorGeometry(MainWindow->saveGeometry());
|
||||||
settingsCache->setDeckEditorCardSize(cardInfoDock->size());
|
settingsCache->layouts().setDeckEditorCardSize(cardInfoDock->size());
|
||||||
settingsCache->setDeckEditorFilterSize(filterDock->size());
|
settingsCache->layouts().setDeckEditorFilterSize(filterDock->size());
|
||||||
settingsCache->setDeckEditorDeckSize(deckDock->size());
|
settingsCache->layouts().setDeckEditorDeckSize(deckDock->size());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
#define SERVER_DATABASE_INTERFACE_H
|
#define SERVER_DATABASE_INTERFACE_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSettings>
|
|
||||||
|
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
|
|
||||||
class Server_DatabaseInterface : public QObject {
|
class Server_DatabaseInterface : public QObject {
|
||||||
|
|
|
@ -14,6 +14,12 @@ SET(oracle_SOURCES
|
||||||
../cockatrice/src/carddatabase.cpp
|
../cockatrice/src/carddatabase.cpp
|
||||||
../cockatrice/src/settingscache.cpp
|
../cockatrice/src/settingscache.cpp
|
||||||
../cockatrice/src/shortcutssettings.cpp
|
../cockatrice/src/shortcutssettings.cpp
|
||||||
|
../cockatrice/src/settings/carddatabasesettings.cpp
|
||||||
|
../cockatrice/src/settings/serverssettings.cpp
|
||||||
|
../cockatrice/src/settings/settingsmanager.cpp
|
||||||
|
../cockatrice/src/settings/messagesettings.cpp
|
||||||
|
../cockatrice/src/settings/gamefilterssettings.cpp
|
||||||
|
../cockatrice/src/settings/layoutssettings.cpp
|
||||||
../cockatrice/src/qt-json/json.cpp
|
../cockatrice/src/qt-json/json.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue