2017-10-14 09:35:49 +00:00
|
|
|
#ifndef CONFIGURATION_H
|
|
|
|
#define CONFIGURATION_H
|
|
|
|
|
|
|
|
#include <QSettings>
|
|
|
|
#include <QFont>
|
2018-03-04 17:42:02 +00:00
|
|
|
#include <Cutter.h>
|
2017-10-14 09:35:49 +00:00
|
|
|
|
|
|
|
#define Config() (Configuration::instance())
|
2017-10-15 07:14:05 +00:00
|
|
|
#define ConfigColor(x) Config()->getColor(x)
|
2017-10-14 09:35:49 +00:00
|
|
|
|
2018-11-11 12:11:50 +00:00
|
|
|
enum ColorFlags {
|
|
|
|
LightFlag = 1,
|
|
|
|
DarkFlag = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CutterQtTheme {
|
|
|
|
QString name;
|
|
|
|
ColorFlags flag;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern const QList<CutterQtTheme> kCutterQtThemesList;
|
|
|
|
|
2017-10-14 09:35:49 +00:00
|
|
|
class Configuration : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
private:
|
|
|
|
QSettings s;
|
2018-02-26 22:25:23 +00:00
|
|
|
static Configuration *mPtr;
|
2017-10-14 09:35:49 +00:00
|
|
|
|
2017-12-03 12:10:09 +00:00
|
|
|
void loadInitial();
|
|
|
|
|
2017-11-20 11:23:37 +00:00
|
|
|
// Colors
|
2018-12-21 18:59:08 +00:00
|
|
|
bool windowColorIsDark();
|
2018-12-21 16:30:46 +00:00
|
|
|
void loadBaseThemeNative();
|
|
|
|
void loadBaseThemeDark();
|
2018-12-21 18:59:08 +00:00
|
|
|
void loadNativeTheme();
|
2017-11-20 11:23:37 +00:00
|
|
|
void loadDarkTheme();
|
|
|
|
void setColor(const QString &name, const QColor &color);
|
2017-10-15 07:14:05 +00:00
|
|
|
|
2018-03-22 08:42:54 +00:00
|
|
|
// Asm Options
|
|
|
|
void applySavedAsmOptions();
|
|
|
|
|
2017-10-14 09:35:49 +00:00
|
|
|
public:
|
|
|
|
// Functions
|
|
|
|
Configuration();
|
2018-03-21 20:32:32 +00:00
|
|
|
static Configuration *instance();
|
2017-10-14 09:35:49 +00:00
|
|
|
|
2017-12-03 12:10:09 +00:00
|
|
|
void resetAll();
|
|
|
|
|
2018-10-31 16:07:53 +00:00
|
|
|
// Languages
|
|
|
|
QLocale getCurrLocale() const;
|
|
|
|
void setLocale(const QLocale &l);
|
2019-01-20 17:00:23 +00:00
|
|
|
bool setLocaleByName(const QString &language);
|
2019-01-19 20:54:02 +00:00
|
|
|
QStringList getAvailableTranslations();
|
2018-10-31 16:07:53 +00:00
|
|
|
|
2017-10-14 09:35:49 +00:00
|
|
|
// Fonts
|
|
|
|
const QFont getFont() const;
|
|
|
|
void setFont(const QFont &font);
|
|
|
|
|
2017-10-15 07:14:05 +00:00
|
|
|
// Colors
|
2018-11-11 12:11:50 +00:00
|
|
|
void setLastThemeOf(const CutterQtTheme &currQtTheme, const QString& theme);
|
|
|
|
QString getLastThemeOf(const CutterQtTheme &currQtTheme) const;
|
2017-10-15 07:14:05 +00:00
|
|
|
const QColor getColor(const QString &name) const;
|
2018-06-22 15:57:26 +00:00
|
|
|
void setTheme(int theme);
|
|
|
|
int getTheme()
|
2018-03-21 20:32:32 +00:00
|
|
|
{
|
2018-11-11 12:11:50 +00:00
|
|
|
return s.value("ColorPalette", 0).toInt();
|
2018-03-21 20:32:32 +00:00
|
|
|
}
|
2017-10-15 07:14:05 +00:00
|
|
|
|
2018-12-24 15:12:08 +00:00
|
|
|
const CutterQtTheme *getCurrentTheme();
|
|
|
|
|
2018-03-25 16:58:34 +00:00
|
|
|
QString getDirProjects();
|
2018-10-10 09:37:24 +00:00
|
|
|
void setDirProjects(const QString &dir);
|
2018-03-25 16:58:34 +00:00
|
|
|
|
2018-07-07 08:47:46 +00:00
|
|
|
void setNewFileLastClicked(int lastClicked);
|
|
|
|
int getNewFileLastClicked();
|
|
|
|
|
2018-02-12 12:22:53 +00:00
|
|
|
// Images
|
|
|
|
QString getLogoFile();
|
|
|
|
|
2018-03-22 08:42:54 +00:00
|
|
|
// Asm Options
|
|
|
|
void resetToDefaultAsmOptions();
|
|
|
|
|
2017-12-19 16:00:42 +00:00
|
|
|
// Graph
|
2018-03-21 20:32:32 +00:00
|
|
|
int getGraphBlockMaxChars() const
|
|
|
|
{
|
2018-07-01 08:59:10 +00:00
|
|
|
return s.value("graph.maxcols", 100).toInt();
|
2018-03-21 20:32:32 +00:00
|
|
|
}
|
|
|
|
void setGraphBlockMaxChars(int ch)
|
|
|
|
{
|
|
|
|
s.setValue("graph.maxcols", ch);
|
|
|
|
}
|
2017-12-19 16:00:42 +00:00
|
|
|
|
2018-11-29 07:39:58 +00:00
|
|
|
QString getColorTheme() const { return s.value("theme", "cutter").toString(); }
|
|
|
|
void setColorTheme(const QString &theme);
|
2018-02-26 22:25:23 +00:00
|
|
|
|
2018-03-22 08:42:54 +00:00
|
|
|
/*!
|
|
|
|
* \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);
|
2019-01-19 20:54:02 +00:00
|
|
|
bool isFirstExecution();
|
2019-01-20 17:00:23 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Get list of available translation directories (depends on configuration and OS)
|
|
|
|
* \return list of directories
|
|
|
|
*/
|
|
|
|
QStringList getTranslationsDirectories() const;
|
2018-03-22 08:42:54 +00:00
|
|
|
|
2017-10-14 09:35:49 +00:00
|
|
|
signals:
|
|
|
|
void fontsUpdated();
|
2017-11-20 11:23:37 +00:00
|
|
|
void colorsUpdated();
|
2017-10-14 09:35:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CONFIGURATION_H
|