2017-10-14 09:35:49 +00:00
|
|
|
#ifndef CONFIGURATION_H
|
|
|
|
#define CONFIGURATION_H
|
|
|
|
|
|
|
|
#include <QSettings>
|
|
|
|
#include <QFont>
|
2019-02-22 16:50:45 +00:00
|
|
|
#include <core/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
|
|
|
|
2019-07-11 13:21:54 +00:00
|
|
|
#ifdef CUTTER_ENABLE_KSYNTAXHIGHLIGHTING
|
|
|
|
namespace KSyntaxHighlighting {
|
|
|
|
class Repository;
|
|
|
|
class Theme;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
class QSyntaxHighlighter;
|
|
|
|
class QTextDocument;
|
|
|
|
|
2020-03-09 20:59:03 +00:00
|
|
|
|
2018-11-11 12:11:50 +00:00
|
|
|
enum ColorFlags {
|
|
|
|
LightFlag = 1,
|
2019-12-08 09:57:42 +00:00
|
|
|
DarkFlag = 2,
|
2018-11-11 12:11:50 +00:00
|
|
|
};
|
|
|
|
|
2019-05-01 16:15:33 +00:00
|
|
|
struct CutterInterfaceTheme {
|
2018-11-11 12:11:50 +00:00
|
|
|
QString name;
|
|
|
|
ColorFlags flag;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-08-01 14:14:30 +00:00
|
|
|
class CUTTER_EXPORT Configuration : public QObject
|
2017-10-14 09:35:49 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
private:
|
2019-05-01 16:15:33 +00:00
|
|
|
QPalette nativePalette;
|
2017-10-14 09:35:49 +00:00
|
|
|
QSettings s;
|
2018-02-26 22:25:23 +00:00
|
|
|
static Configuration *mPtr;
|
2017-10-14 09:35:49 +00:00
|
|
|
|
2019-07-11 13:21:54 +00:00
|
|
|
#ifdef CUTTER_ENABLE_KSYNTAXHIGHLIGHTING
|
|
|
|
KSyntaxHighlighting::Repository *kSyntaxHighlightingRepository;
|
|
|
|
#endif
|
2020-04-17 12:02:44 +00:00
|
|
|
bool outputRedirectEnabled = true;
|
2019-07-11 13:21:54 +00:00
|
|
|
|
2020-06-16 10:43:45 +00:00
|
|
|
Configuration();
|
2017-11-20 11:23:37 +00:00
|
|
|
// Colors
|
2018-12-21 16:30:46 +00:00
|
|
|
void loadBaseThemeNative();
|
|
|
|
void loadBaseThemeDark();
|
2019-06-12 17:46:07 +00:00
|
|
|
void loadNativeStylesheet();
|
|
|
|
void loadLightStylesheet();
|
|
|
|
void loadDarkStylesheet();
|
2019-12-08 09:57:42 +00:00
|
|
|
void loadMidnightStylesheet();
|
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:
|
2019-06-12 17:46:07 +00:00
|
|
|
static const QList<CutterInterfaceTheme>& cutterInterfaceThemesList();
|
|
|
|
static const QHash<QString, ColorFlags> relevantThemes;
|
|
|
|
static const QHash<QString, QHash<ColorFlags, QColor>> cutterOptionColors;
|
|
|
|
|
2017-10-14 09:35:49 +00:00
|
|
|
// Functions
|
2018-03-21 20:32:32 +00:00
|
|
|
static Configuration *instance();
|
2017-10-14 09:35:49 +00:00
|
|
|
|
2019-02-20 17:52:11 +00:00
|
|
|
void loadInitial();
|
|
|
|
|
2017-12-03 12:10:09 +00:00
|
|
|
void resetAll();
|
|
|
|
|
2019-03-09 13:11:39 +00:00
|
|
|
// Auto update
|
|
|
|
bool getAutoUpdateEnabled() const;
|
|
|
|
void setAutoUpdateEnabled(bool au);
|
|
|
|
|
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
|
2019-10-12 05:50:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Gets the configured font set by the font selection box
|
|
|
|
* @return the configured font
|
|
|
|
*/
|
|
|
|
const QFont getBaseFont() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Gets the configured font with the point size adjusted by the configured zoom
|
|
|
|
* level (minimum of 10%)
|
|
|
|
* @return the configured font size adjusted by zoom level
|
|
|
|
*/
|
2017-10-14 09:35:49 +00:00
|
|
|
const QFont getFont() const;
|
|
|
|
void setFont(const QFont &font);
|
2019-10-12 05:50:10 +00:00
|
|
|
qreal getZoomFactor() const;
|
|
|
|
void setZoomFactor(qreal zoom);
|
2017-10-14 09:35:49 +00:00
|
|
|
|
2017-10-15 07:14:05 +00:00
|
|
|
// Colors
|
2019-02-07 20:39:14 +00:00
|
|
|
bool windowColorIsDark();
|
2019-06-12 17:46:07 +00:00
|
|
|
static bool nativeWindowIsDark();
|
2019-05-01 16:15:33 +00:00
|
|
|
void setLastThemeOf(const CutterInterfaceTheme &currInterfaceTheme, const QString &theme);
|
|
|
|
QString getLastThemeOf(const CutterInterfaceTheme &currInterfaceTheme) const;
|
|
|
|
void setInterfaceTheme(int theme);
|
|
|
|
int getInterfaceTheme()
|
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
|
|
|
|
2019-05-01 16:15:33 +00:00
|
|
|
const CutterInterfaceTheme *getCurrentTheme();
|
2018-12-24 15:12:08 +00:00
|
|
|
|
2019-07-11 13:21:54 +00:00
|
|
|
#ifdef CUTTER_ENABLE_KSYNTAXHIGHLIGHTING
|
|
|
|
KSyntaxHighlighting::Repository *getKSyntaxHighlightingRepository();
|
|
|
|
KSyntaxHighlighting::Theme getKSyntaxHighlightingTheme();
|
|
|
|
#endif
|
|
|
|
QSyntaxHighlighter *createSyntaxHighlighter(QTextDocument *document);
|
|
|
|
|
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
|
|
|
|
2019-01-29 17:37:09 +00:00
|
|
|
QString getRecentFolder();
|
|
|
|
void setRecentFolder(const QString &dir);
|
|
|
|
|
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();
|
|
|
|
|
2018-11-29 07:39:58 +00:00
|
|
|
QString getColorTheme() const { return s.value("theme", "cutter").toString(); }
|
|
|
|
void setColorTheme(const QString &theme);
|
2020-05-04 09:49:40 +00:00
|
|
|
/**
|
2020-11-29 14:41:13 +00:00
|
|
|
* @brief Change current color theme if it doesn't much native theme's darkness.
|
2020-05-04 09:49:40 +00:00
|
|
|
*/
|
|
|
|
void adjustColorThemeDarkness();
|
|
|
|
int colorThemeDarkness(const QString &colorTheme) const;
|
2018-02-26 22:25:23 +00:00
|
|
|
|
2019-05-01 16:15:33 +00:00
|
|
|
void setColor(const QString &name, const QColor &color);
|
|
|
|
const QColor getColor(const QString &name) const;
|
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @brief Get the value of a config var either from r2 or settings, depending on the key.
|
2018-03-22 08:42:54 +00:00
|
|
|
*/
|
|
|
|
QVariant getConfigVar(const QString &key);
|
|
|
|
bool getConfigBool(const QString &key);
|
|
|
|
int getConfigInt(const QString &key);
|
|
|
|
QString getConfigString(const QString &key);
|
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @brief Set the value of a config var either to r2 or settings, depending on the key.
|
2018-03-22 08:42:54 +00:00
|
|
|
*/
|
|
|
|
void setConfig(const QString &key, const QVariant &value);
|
2019-01-19 20:54:02 +00:00
|
|
|
bool isFirstExecution();
|
2020-11-29 14:41:13 +00:00
|
|
|
|
2019-07-16 18:33:05 +00:00
|
|
|
/**
|
|
|
|
* @return id of the last selected decompiler (see CutterCore::getDecompilerById)
|
|
|
|
*/
|
|
|
|
QString getSelectedDecompiler();
|
|
|
|
void setSelectedDecompiler(const QString &id);
|
|
|
|
|
2019-09-01 09:06:54 +00:00
|
|
|
bool getDecompilerAutoRefreshEnabled();
|
|
|
|
void setDecompilerAutoRefreshEnabled(bool enabled);
|
2020-03-09 20:59:03 +00:00
|
|
|
|
2020-08-31 06:00:55 +00:00
|
|
|
void enableDecompilerAnnotationHighlighter(bool useDecompilerHighlighter);
|
|
|
|
bool isDecompilerAnnotationHighlighterEnabled();
|
|
|
|
|
2020-06-16 10:43:45 +00:00
|
|
|
// Graph
|
|
|
|
int getGraphBlockMaxChars() const
|
|
|
|
{
|
|
|
|
return s.value("graph.maxcols", 100).toInt();
|
|
|
|
}
|
|
|
|
void setGraphBlockMaxChars(int ch)
|
|
|
|
{
|
|
|
|
s.setValue("graph.maxcols", ch);
|
|
|
|
}
|
|
|
|
|
2020-03-09 20:59:03 +00:00
|
|
|
/**
|
|
|
|
* @brief Getters and setters for the transaparent option state and scale factor for bitmap graph exports.
|
|
|
|
*/
|
|
|
|
bool getBitmapTransparentState();
|
|
|
|
double getBitmapExportScaleFactor();
|
|
|
|
void setBitmapTransparentState(bool inputValueGraph);
|
|
|
|
void setBitmapExportScaleFactor(double inputValueGraph);
|
2020-06-16 10:43:45 +00:00
|
|
|
void setGraphSpacing(QPoint blockSpacing, QPoint edgeSpacing);
|
|
|
|
QPoint getGraphBlockSpacing();
|
|
|
|
QPoint getGraphEdgeSpacing();
|
2020-03-09 20:59:03 +00:00
|
|
|
|
2020-11-29 14:41:13 +00:00
|
|
|
/**
|
|
|
|
* @brief Gets whether the entry offset of each block has to be displayed or not
|
|
|
|
* @return true if the entry offset has to be displayed, false otherwise
|
|
|
|
*/
|
|
|
|
bool getGraphBlockEntryOffset();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Enable or disable the displaying of the entry offset in each graph block
|
|
|
|
* @param enabled set this to true for displaying the entry offset in each graph block, false otherwise
|
|
|
|
*/
|
|
|
|
void setGraphBlockEntryOffset(bool enabled);
|
|
|
|
|
2020-04-17 12:02:44 +00:00
|
|
|
/**
|
|
|
|
* @brief Enable or disable Cutter output redirection.
|
2020-11-29 14:41:13 +00:00
|
|
|
* Output redirection state can only be changed early during Cutter initialization.
|
2020-04-17 12:02:44 +00:00
|
|
|
* Changing it later will have no effect
|
|
|
|
* @param enabled set this to false for disabling output redirection
|
|
|
|
*/
|
|
|
|
void setOutputRedirectionEnabled(bool enabled);
|
|
|
|
bool getOutputRedirectionEnabled() const;
|
|
|
|
|
2020-01-07 22:03:25 +00:00
|
|
|
public slots:
|
|
|
|
void refreshFont();
|
2017-10-14 09:35:49 +00:00
|
|
|
signals:
|
|
|
|
void fontsUpdated();
|
2017-11-20 11:23:37 +00:00
|
|
|
void colorsUpdated();
|
2019-05-01 16:15:33 +00:00
|
|
|
void interfaceThemeChanged();
|
2019-07-12 13:37:19 +00:00
|
|
|
#ifdef CUTTER_ENABLE_KSYNTAXHIGHLIGHTING
|
|
|
|
void kSyntaxHighlightingThemeChanged();
|
|
|
|
#endif
|
2017-10-14 09:35:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CONFIGURATION_H
|