mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-14 22:42:14 -07:00
Use SettingsManager
This commit is contained in:
parent
af2370425f
commit
f5080424a6
2 changed files with 7 additions and 8 deletions
|
|
@ -4,7 +4,7 @@
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
CardCounterSettings::CardCounterSettings(const QString &settingsPath, QObject *parent)
|
CardCounterSettings::CardCounterSettings(const QString &settingsPath, QObject *parent)
|
||||||
: QObject(parent), m_settings(new QSettings(settingsPath + "global.ini", QSettings::IniFormat))
|
: SettingsManager(settingsPath + "global.ini", parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -12,10 +12,10 @@ void CardCounterSettings::setColor(int counterId, const QColor &color)
|
||||||
{
|
{
|
||||||
QString key = QString("cards/counters/%1/color").arg(counterId);
|
QString key = QString("cards/counters/%1/color").arg(counterId);
|
||||||
|
|
||||||
if (m_settings->value(key).value<QColor>() == color)
|
if (settings.value(key).value<QColor>() == color)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_settings->setValue(key, color);
|
settings.setValue(key, color);
|
||||||
emit colorChanged(counterId, color);
|
emit colorChanged(counterId, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -35,7 +35,7 @@ QColor CardCounterSettings::color(int counterId) const
|
||||||
defaultColor = QColor::fromHsv(h, s, v);
|
defaultColor = QColor::fromHsv(h, s, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_settings->value(QString("cards/counters/%1/color").arg(counterId), defaultColor).value<QColor>();
|
return settings.value(QString("cards/counters/%1/color").arg(counterId), defaultColor).value<QColor>();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CardCounterSettings::displayName(int counterId) const
|
QString CardCounterSettings::displayName(int counterId) const
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,14 @@
|
||||||
#ifndef CARD_COUNTER_SETTINGS_H
|
#ifndef CARD_COUNTER_SETTINGS_H
|
||||||
#define CARD_COUNTER_SETTINGS_H
|
#define CARD_COUNTER_SETTINGS_H
|
||||||
|
|
||||||
|
#include "settings_manager.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
class QSettings;
|
class QSettings;
|
||||||
class QColor;
|
class QColor;
|
||||||
|
|
||||||
class CardCounterSettings : public QObject
|
class CardCounterSettings : public SettingsManager
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
@ -22,9 +24,6 @@ public slots:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void colorChanged(int counterId, const QColor &color);
|
void colorChanged(int counterId, const QColor &color);
|
||||||
|
|
||||||
private:
|
|
||||||
QSettings *m_settings;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CARD_COUNTER_SETTINGS_H
|
#endif // CARD_COUNTER_SETTINGS_H
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue