cutter/src/utils/Configuration.h

88 lines
1.9 KiB
C
Raw Normal View History

#ifndef CONFIGURATION_H
#define CONFIGURATION_H
#include <QSettings>
#include <QFont>
2018-03-04 17:42:02 +00:00
#include <Cutter.h>
#define Config() (Configuration::instance())
2017-10-15 07:14:05 +00:00
#define ConfigColor(x) Config()->getColor(x)
class Configuration : public QObject
{
Q_OBJECT
private:
QSettings s;
static Configuration *mPtr;
2017-12-03 12:10:09 +00:00
void loadInitial();
2017-11-20 11:23:37 +00:00
// Colors
void loadDefaultTheme();
void loadDarkTheme();
void setColor(const QString &name, const QColor &color);
2017-10-15 07:14:05 +00:00
2018-02-12 12:22:53 +00:00
// Images
QString logoFile;
// Asm Options
void applySavedAsmOptions();
public:
// Functions
Configuration();
2018-03-21 20:32:32 +00:00
static Configuration *instance();
2017-12-03 12:10:09 +00:00
void resetAll();
// Fonts
const QFont getFont() const;
void setFont(const QFont &font);
2017-10-15 07:14:05 +00:00
// Colors
const QColor getColor(const QString &name) const;
2017-11-20 11:23:37 +00:00
void setDarkTheme(bool set);
2018-03-21 20:32:32 +00:00
bool getDarkTheme()
{
return s.value("dark").toBool();
}
2017-10-15 07:14:05 +00:00
2018-02-12 12:22:53 +00:00
// Images
QString getLogoFile();
// Asm Options
void resetToDefaultAsmOptions();
2017-12-19 16:00:42 +00:00
// Graph
2018-03-21 20:32:32 +00:00
int getGraphBlockMaxChars() const
{
return s.value("graph.maxcols", 50).toInt();
}
void setGraphBlockMaxChars(int ch)
{
s.setValue("graph.maxcols", ch);
}
2017-12-19 16:00:42 +00:00
QString getCurrentTheme() const { return s.value("theme", "solarized").toString(); }
void setColorTheme(QString theme);
/*!
* \brief Get the value of a config var either from r2 or settings, depending on the key.
*/
QVariant getConfigVar(const QString &key);
bool getConfigBool(const QString &key);
int getConfigInt(const QString &key);
QString getConfigString(const QString &key);
/*!
* \brief Set the value of a config var either to r2 or settings, depending on the key.
*/
void setConfig(const QString &key, const QVariant &value);
signals:
void fontsUpdated();
2017-11-20 11:23:37 +00:00
void colorsUpdated();
};
#endif // CONFIGURATION_H