mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-20 03:46:11 +00:00
Automatically switch colors if Native Theme is Dark
This commit is contained in:
parent
e57c2fb941
commit
350825849b
@ -9,7 +9,7 @@
|
|||||||
#include "common/ColorSchemeFileSaver.h"
|
#include "common/ColorSchemeFileSaver.h"
|
||||||
|
|
||||||
const QList<CutterQtTheme> kCutterQtThemesList = {
|
const QList<CutterQtTheme> kCutterQtThemesList = {
|
||||||
{ "Default", static_cast<ColorFlags>(LightFlag | DarkFlag) },
|
{ "Native", static_cast<ColorFlags>(LightFlag | DarkFlag) },
|
||||||
{ "Dark", DarkFlag }
|
{ "Dark", DarkFlag }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -125,14 +125,17 @@ void Configuration::setLocale(const QLocale &l)
|
|||||||
s.setValue("locale", l);
|
s.setValue("locale", l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Configuration::windowColorIsDark()
|
||||||
|
{
|
||||||
|
auto windowColor = QPalette().color(QPalette::Window).toRgb();
|
||||||
|
return (windowColor.red() + windowColor.green() + windowColor.blue()) < 382;
|
||||||
|
}
|
||||||
|
|
||||||
void Configuration::loadBaseThemeNative()
|
void Configuration::loadBaseThemeNative()
|
||||||
{
|
{
|
||||||
/* Load Qt Theme */
|
/* Load Qt Theme */
|
||||||
qApp->setStyleSheet("");
|
qApp->setStyleSheet("");
|
||||||
|
|
||||||
/* Images */
|
|
||||||
logoFile = QString(":/img/cutter_plain.svg");
|
|
||||||
|
|
||||||
/* Colors */
|
/* Colors */
|
||||||
// GUI
|
// GUI
|
||||||
setColor("gui.cflow", QColor(0, 0, 0));
|
setColor("gui.cflow", QColor(0, 0, 0));
|
||||||
@ -151,11 +154,12 @@ void Configuration::loadBaseThemeNative()
|
|||||||
setColor("gui.item_invalid", QColor(155, 155, 155));
|
setColor("gui.item_invalid", QColor(155, 155, 155));
|
||||||
setColor("gui.item_unsafe", QColor(255, 129, 123));
|
setColor("gui.item_unsafe", QColor(255, 129, 123));
|
||||||
}
|
}
|
||||||
void Configuration::loadNativeTheme(bool dark)
|
|
||||||
|
void Configuration::loadNativeTheme()
|
||||||
{
|
{
|
||||||
loadBaseThemeNative();
|
loadBaseThemeNative();
|
||||||
|
|
||||||
if(dark)
|
if(windowColorIsDark())
|
||||||
{
|
{
|
||||||
setColor("gui.border", QColor(0, 0, 0));
|
setColor("gui.border", QColor(0, 0, 0));
|
||||||
setColor("gui.background", QColor(30, 30, 30));
|
setColor("gui.background", QColor(30, 30, 30));
|
||||||
@ -197,9 +201,6 @@ void Configuration::loadBaseThemeDark()
|
|||||||
qApp->setStyleSheet(stylesheet);
|
qApp->setStyleSheet(stylesheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Images */
|
|
||||||
logoFile = QString(":/img/cutter_white_plain.svg");
|
|
||||||
|
|
||||||
/* Colors */
|
/* Colors */
|
||||||
// GUI
|
// GUI
|
||||||
setColor("gui.cflow", QColor(255, 255, 255));
|
setColor("gui.cflow", QColor(255, 255, 255));
|
||||||
@ -235,7 +236,6 @@ void Configuration::loadDarkTheme()
|
|||||||
// Disassembly line selected
|
// Disassembly line selected
|
||||||
setColor("highlight", QColor(21, 29, 29, 150));
|
setColor("highlight", QColor(21, 29, 29, 150));
|
||||||
setColor("highlightWord", QColor(52, 58, 71, 255));
|
setColor("highlightWord", QColor(52, 58, 71, 255));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const QFont Configuration::getFont() const
|
const QFont Configuration::getFont() const
|
||||||
@ -265,7 +265,7 @@ void Configuration::setTheme(int theme)
|
|||||||
s.setValue("ColorPalette", theme);
|
s.setValue("ColorPalette", theme);
|
||||||
QString themeName = kCutterQtThemesList[theme].name;
|
QString themeName = kCutterQtThemesList[theme].name;
|
||||||
|
|
||||||
if (themeName == "Default") {
|
if (themeName == "Native") {
|
||||||
loadNativeTheme();
|
loadNativeTheme();
|
||||||
} else if (themeName == "Dark") {
|
} else if (themeName == "Dark") {
|
||||||
loadDarkTheme();
|
loadDarkTheme();
|
||||||
@ -279,7 +279,9 @@ void Configuration::setTheme(int theme)
|
|||||||
|
|
||||||
QString Configuration::getLogoFile()
|
QString Configuration::getLogoFile()
|
||||||
{
|
{
|
||||||
return logoFile;
|
return windowColorIsDark()
|
||||||
|
? QString(":/img/cutter_white_plain.svg")
|
||||||
|
: QString(":/img/cutter_plain.svg");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -30,15 +30,13 @@ private:
|
|||||||
void loadInitial();
|
void loadInitial();
|
||||||
|
|
||||||
// Colors
|
// Colors
|
||||||
|
bool windowColorIsDark();
|
||||||
void loadBaseThemeNative();
|
void loadBaseThemeNative();
|
||||||
void loadBaseThemeDark();
|
void loadBaseThemeDark();
|
||||||
void loadNativeTheme(bool dark = false);
|
void loadNativeTheme();
|
||||||
void loadDarkTheme();
|
void loadDarkTheme();
|
||||||
void setColor(const QString &name, const QColor &color);
|
void setColor(const QString &name, const QColor &color);
|
||||||
|
|
||||||
// Images
|
|
||||||
QString logoFile;
|
|
||||||
|
|
||||||
// Asm Options
|
// Asm Options
|
||||||
void applySavedAsmOptions();
|
void applySavedAsmOptions();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user