mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-31 08:37:26 +00:00
Splitted Qt theme and color theme (now using eco/ecoj)
This commit is contained in:
parent
2795d3449c
commit
a9f669e27e
2
radare2
2
radare2
@ -1 +1 @@
|
||||
Subproject commit 06c519ead78a37aea46fab7443cdde41c6d3dd7b
|
||||
Subproject commit 70bd99da259438fbe552b7debfe68c571cdcd2da
|
@ -87,12 +87,12 @@ static void registerCustomFonts()
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
core(CutterCore::getInstance()),
|
||||
core(Core()),
|
||||
ui(new Ui::MainWindow)
|
||||
{
|
||||
panelLock = false;
|
||||
tabsOnTop = false;
|
||||
configuration = new Configuration();
|
||||
configuration = Config();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
@ -824,8 +824,7 @@ void CutterCore::setSettings()
|
||||
setConfig("http.sandbox", false);
|
||||
|
||||
// Colors
|
||||
setConfig("scr.color", false);
|
||||
setConfig("scr.truecolor", false);
|
||||
setConfig("scr.color", COLOR_MODE_DISABLED);
|
||||
}
|
||||
|
||||
QList<RVA> CutterCore::getSeekHistory()
|
||||
@ -1417,3 +1416,12 @@ QJsonArray CutterCore::getOpenedFiles()
|
||||
QJsonDocument files = cmdj("oj");
|
||||
return files.array();
|
||||
}
|
||||
|
||||
QList<QString> CutterCore::getColorThemes()
|
||||
{
|
||||
QList<QString> r;
|
||||
QJsonDocument themes = cmdj("ecoj");
|
||||
for (auto s : themes.array())
|
||||
r << s.toString();
|
||||
return r;
|
||||
}
|
||||
|
@ -381,6 +381,8 @@ public:
|
||||
QString getVersionInformation();
|
||||
QJsonArray getOpenedFiles();
|
||||
|
||||
QList<QString> getColorThemes();
|
||||
|
||||
RCoreLocked core() const;
|
||||
|
||||
/* fields */
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include "GeneralOptionsWidget.h"
|
||||
#include "ui_GeneralOptionsWidget.h"
|
||||
|
||||
#include <QComboBox>
|
||||
#include "PreferencesDialog.h"
|
||||
|
||||
#include "utils/Helpers.h"
|
||||
@ -18,8 +18,8 @@ GeneralOptionsWidget::GeneralOptionsWidget(PreferencesDialog */*dialog*/, QWidge
|
||||
updateFontFromConfig();
|
||||
updateThemeFromConfig();
|
||||
|
||||
connect(Config(), SIGNAL(fontsUpdated()), this, SLOT(updateFontFromConfig()));
|
||||
connect(Config(), SIGNAL(colorsUpdated()), this, SLOT(updateThemeFromConfig()));
|
||||
//connect(Config(), SIGNAL(fontsUpdated()), this, SLOT(updateFontFromConfig()));
|
||||
//connect(Config(), SIGNAL(colorsUpdated()), this, SLOT(updateThemeFromConfig()));
|
||||
}
|
||||
|
||||
GeneralOptionsWidget::~GeneralOptionsWidget() {}
|
||||
@ -33,6 +33,15 @@ void GeneralOptionsWidget::updateFontFromConfig()
|
||||
void GeneralOptionsWidget::updateThemeFromConfig()
|
||||
{
|
||||
ui->themeComboBox->setCurrentIndex(Config()->getDarkTheme() ? 1 : 0);
|
||||
|
||||
QList<QString> themes = Core()->getColorThemes();
|
||||
ui->colorComboBox->clear();
|
||||
ui->colorComboBox->addItem("default");
|
||||
for (QString str : themes)
|
||||
ui->colorComboBox->addItem(str);
|
||||
QString curTheme = Config()->getCurrentTheme();
|
||||
int index = themes.indexOf(curTheme) + 1;
|
||||
ui->colorComboBox->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
void GeneralOptionsWidget::on_fontSelectionButton_clicked()
|
||||
@ -47,7 +56,13 @@ void GeneralOptionsWidget::on_fontSelectionButton_clicked()
|
||||
|
||||
void GeneralOptionsWidget::on_themeComboBox_currentIndexChanged(int index)
|
||||
{
|
||||
disconnect(Config(), SIGNAL(colorsUpdated()), this, SLOT(updateThemeFromConfig()));
|
||||
//disconnect(Config(), SIGNAL(colorsUpdated()), this, SLOT(updateThemeFromConfig()));
|
||||
Config()->setDarkTheme(index == 1);
|
||||
connect(Config(), SIGNAL(colorsUpdated()), this, SLOT(updateThemeFromConfig()));
|
||||
//connect(Config(), SIGNAL(colorsUpdated()), this, SLOT(updateThemeFromConfig()));
|
||||
}
|
||||
|
||||
void GeneralOptionsWidget::on_colorComboBox_currentIndexChanged(int index)
|
||||
{
|
||||
QString theme = ui->colorComboBox->itemText(index);
|
||||
Config()->setColorTheme(theme);
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ private slots:
|
||||
|
||||
void on_fontSelectionButton_clicked();
|
||||
void on_themeComboBox_currentIndexChanged(int index);
|
||||
void on_colorComboBox_currentIndexChanged(int index);
|
||||
};
|
||||
|
||||
|
||||
|
@ -59,7 +59,7 @@
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="themeLabel">
|
||||
<property name="text">
|
||||
<string>Theme:</string>
|
||||
<string>Qt Theme:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -83,6 +83,23 @@
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="colorLabel">
|
||||
<property name="text">
|
||||
<string>Color theme</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="colorComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -15,6 +15,8 @@ Configuration::Configuration() : QObject()
|
||||
|
||||
Configuration* Configuration::instance()
|
||||
{
|
||||
if (!mPtr)
|
||||
mPtr = new Configuration();
|
||||
return mPtr;
|
||||
}
|
||||
|
||||
@ -37,193 +39,34 @@ void Configuration::resetAll()
|
||||
|
||||
void Configuration::loadDefaultTheme()
|
||||
{
|
||||
QColor color0 = QColor(0, 0, 0);
|
||||
QColor color1 = QColor(0, 0, 255);
|
||||
QColor color2 = QColor(0, 128, 0);
|
||||
QColor color3 = QColor(255, 0, 0);
|
||||
QColor color4 = QColor(127, 0, 127);
|
||||
QColor color5 = QColor(95, 95, 175);
|
||||
QColor color6 = QColor(255, 235, 95);
|
||||
QColor color7 = QColor(215, 135, 0);
|
||||
QColor color8 = QColor(108, 108, 108);
|
||||
QColor color9 = QColor(96, 48, 0);
|
||||
QColor colorA = QColor(50, 140, 255);
|
||||
|
||||
QColor highlightColor = QColor(210, 210, 255);
|
||||
|
||||
// Instructions
|
||||
setColor("comment", color4);
|
||||
setColor("usrcmt", color2);
|
||||
setColor("args", color5);
|
||||
setColor("fname", color1);
|
||||
setColor("floc", color6);
|
||||
setColor("fline", color2);
|
||||
setColor("flag", color1);
|
||||
setColor("label", color7);
|
||||
setColor("help", color1);
|
||||
setColor("flow", color2);
|
||||
setColor("flow2", color2);
|
||||
setColor("prompt", color0);
|
||||
setColor("offset", color0);
|
||||
setColor("input", color0);
|
||||
setColor("invalid", color3);
|
||||
setColor("other", color1);
|
||||
setColor("b0x00", color8);
|
||||
setColor("b0x7f", color0);
|
||||
setColor("b0xff", color3);
|
||||
setColor("math", color1);
|
||||
setColor("bin", color1);
|
||||
setColor("btext", color0);
|
||||
setColor("push", color0);
|
||||
setColor("pop", color0);
|
||||
setColor("crypto", color4);
|
||||
setColor("jmp", color2);
|
||||
setColor("cjmp", color2);
|
||||
setColor("call", color9);
|
||||
setColor("nop", color1);
|
||||
setColor("ret", color9);
|
||||
setColor("trap", color3);
|
||||
setColor("swi", color2);
|
||||
setColor("cmp", color0);
|
||||
setColor("reg", color1);
|
||||
setColor("creg", color1);
|
||||
setColor("num", color1);
|
||||
setColor("mov", color0);
|
||||
|
||||
// AI
|
||||
setColor("ai.read", color0);
|
||||
setColor("ai.write", color0);
|
||||
setColor("ai.exec", color0);
|
||||
setColor("ai.seq", color0);
|
||||
setColor("ai.ascii", color0);
|
||||
|
||||
// Graphs
|
||||
setColor("graph.box", color0);
|
||||
setColor("graph.box2", color2);
|
||||
setColor("graph.box3", color3);
|
||||
setColor("graph.box4", color0);
|
||||
setColor("graph.true", color2);
|
||||
setColor("graph.false", color3);
|
||||
setColor("graph.trufae", color0);
|
||||
setColor("graph.current", color0);
|
||||
setColor("graph.traced", color3);
|
||||
|
||||
// GUI
|
||||
setColor("gui.cflow", color0);
|
||||
setColor("gui.dataoffset", color0);
|
||||
setColor("gui.border", color0);
|
||||
setColor("highlight", highlightColor);
|
||||
// Windows background
|
||||
setColor("gui.background", QColor(255, 255, 255));
|
||||
// Disassembly nodes background
|
||||
setColor("gui.alt_background", QColor(245, 250, 255));
|
||||
// Custom
|
||||
setColor("gui.imports", colorA);
|
||||
setColor("gui.main", color2);
|
||||
setColor("gui.navbar.err", QColor(255, 0, 0));
|
||||
setColor("gui.navbar.code", QColor(104, 229, 69));
|
||||
setColor("gui.navbar.str", QColor(69, 104, 229));
|
||||
setColor("gui.navbar.sym", QColor(229, 150, 69));
|
||||
setColor("gui.navbar.empty", QColor(100, 100, 100));
|
||||
|
||||
/* Load Qt Theme */
|
||||
qApp->setStyleSheet("");
|
||||
|
||||
/* Images */
|
||||
logoFile = QString(":/img/cutter_plain.svg");
|
||||
}
|
||||
|
||||
void Configuration::loadDarkTheme()
|
||||
{
|
||||
QColor color0 = QColor(255, 255, 255);
|
||||
QColor color1 = QColor(100, 180, 255);
|
||||
QColor color2 = QColor(0, 255, 0);
|
||||
QColor color3 = QColor(255, 0, 0);
|
||||
QColor color4 = QColor(128, 235, 200);
|
||||
QColor color5 = QColor(95, 95, 175);
|
||||
QColor color6 = QColor(255, 235, 95);
|
||||
QColor color7 = QColor(255, 130, 0);
|
||||
QColor color8 = QColor(108, 108, 108);
|
||||
QColor color9 = QColor(255, 130, 0);
|
||||
QColor colorA = QColor(50, 140, 255);
|
||||
|
||||
QColor highlightColor = QColor(64, 115, 115);
|
||||
|
||||
// Instructions
|
||||
setColor("comment", color4);
|
||||
setColor("usrcmt", color2);
|
||||
setColor("args", color5);
|
||||
setColor("fname", color1);
|
||||
setColor("floc", color6);
|
||||
setColor("fline", color2);
|
||||
setColor("flag", color1);
|
||||
setColor("label", color7);
|
||||
setColor("help", color1);
|
||||
setColor("flow", color2);
|
||||
setColor("flow2", color2);
|
||||
setColor("prompt", color0);
|
||||
setColor("offset", color0);
|
||||
setColor("input", color0);
|
||||
setColor("invalid", color3);
|
||||
setColor("other", color1);
|
||||
setColor("b0x00", color8);
|
||||
setColor("b0x7f", color0);
|
||||
setColor("b0xff", color3);
|
||||
setColor("math", color1);
|
||||
setColor("bin", color1);
|
||||
setColor("btext", color0);
|
||||
setColor("push", color0);
|
||||
setColor("pop", color0);
|
||||
setColor("crypto", color4);
|
||||
setColor("jmp", color2);
|
||||
setColor("cjmp", color2);
|
||||
setColor("call", color9);
|
||||
setColor("nop", color1);
|
||||
setColor("ret", color9);
|
||||
setColor("trap", color3);
|
||||
setColor("swi", color2);
|
||||
setColor("cmp", color0);
|
||||
setColor("reg", color1);
|
||||
setColor("creg", color1);
|
||||
setColor("num", color1);
|
||||
setColor("mov", color0);
|
||||
|
||||
// AI
|
||||
setColor("ai.read", color0);
|
||||
setColor("ai.write", color0);
|
||||
setColor("ai.exec", color0);
|
||||
setColor("ai.seq", color0);
|
||||
setColor("ai.ascii", color0);
|
||||
|
||||
// Graphs
|
||||
setColor("graph.box", color0);
|
||||
setColor("graph.box2", color2);
|
||||
setColor("graph.box3", color3);
|
||||
setColor("graph.box4", color0);
|
||||
setColor("graph.true", color2);
|
||||
setColor("graph.false", color3);
|
||||
setColor("graph.trufae", color0);
|
||||
setColor("graph.current", color0);
|
||||
setColor("graph.traced", color3);
|
||||
|
||||
/* Colors */
|
||||
// GUI
|
||||
setColor("gui.cflow", color0);
|
||||
setColor("gui.dataoffset", color0);
|
||||
setColor("gui.border", color0);
|
||||
setColor("highlight", highlightColor);
|
||||
setColor("gui.cflow", QColor(0, 0, 0));
|
||||
setColor("gui.dataoffset", QColor(0, 0, 0));
|
||||
setColor("gui.border", QColor(0, 0, 0));
|
||||
setColor("highlight", QColor(210, 210, 255));
|
||||
// Windows background
|
||||
setColor("gui.background", QColor(36, 66, 79));
|
||||
setColor("gui.background", QColor(255, 255, 255));
|
||||
// Disassembly nodes background
|
||||
setColor("gui.alt_background", QColor(58, 100, 128));
|
||||
setColor("gui.alt_background", QColor(245, 250, 255));
|
||||
// Custom
|
||||
setColor("gui.imports", colorA);
|
||||
setColor("gui.main", color2);
|
||||
setColor("gui.imports", QColor(50, 140, 255));
|
||||
setColor("gui.main", QColor(0, 128, 0));
|
||||
setColor("gui.navbar.err", QColor(255, 0, 0));
|
||||
setColor("gui.navbar.code", QColor(104, 229, 69));
|
||||
setColor("gui.navbar.str", QColor(69, 104, 229));
|
||||
setColor("gui.navbar.sym", QColor(229, 150, 69));
|
||||
setColor("gui.navbar.empty", QColor(100, 100, 100));
|
||||
}
|
||||
|
||||
void Configuration::loadDarkTheme()
|
||||
{
|
||||
/* Load Qt Theme */
|
||||
QFile f(":qdarkstyle/style.qss");
|
||||
if (!f.exists())
|
||||
@ -249,6 +92,25 @@ void Configuration::loadDarkTheme()
|
||||
|
||||
/* Images */
|
||||
logoFile = QString(":/img/cutter_white_plain.svg");
|
||||
|
||||
/* Colors */
|
||||
// GUI
|
||||
setColor("gui.cflow", QColor(255, 255, 255));
|
||||
setColor("gui.dataoffset", QColor(255, 255, 255));
|
||||
setColor("gui.border", QColor(255, 255, 255));
|
||||
setColor("highlight", QColor(64, 115, 115));
|
||||
// Windows background
|
||||
setColor("gui.background", QColor(36, 66, 79));
|
||||
// Disassembly nodes background
|
||||
setColor("gui.alt_background", QColor(58, 100, 128));
|
||||
// Custom
|
||||
setColor("gui.imports", QColor(50, 140, 255));
|
||||
setColor("gui.main", QColor(0, 128, 0));
|
||||
setColor("gui.navbar.err", QColor(255, 0, 0));
|
||||
setColor("gui.navbar.code", QColor(104, 229, 69));
|
||||
setColor("gui.navbar.str", QColor(69, 104, 229));
|
||||
setColor("gui.navbar.sym", QColor(229, 150, 69));
|
||||
setColor("gui.navbar.empty", QColor(100, 100, 100));
|
||||
}
|
||||
|
||||
const QFont Configuration::getFont() const
|
||||
@ -290,15 +152,25 @@ QString Configuration::getLogoFile()
|
||||
|
||||
/**
|
||||
* @brief Configuration::setColor sets the local Cutter configuration color
|
||||
* and the radare2 color.
|
||||
* @param name Color Name
|
||||
* @param color The color you want to set
|
||||
*/
|
||||
void Configuration::setColor(const QString &name, const QColor &color)
|
||||
{
|
||||
s.setValue("colors." + name, color);
|
||||
// R2 does not support truecolor properly
|
||||
QString col = QString("rgb:%1%2%3").arg(color.red() >> 4, 1, 16).arg(color.green() >> 4, 1, 16).arg(color.blue() >> 4, 1, 16);
|
||||
// Not clean but this is a private function so name should NEVER be a bad input
|
||||
Core()->cmd("ec " + name + " " + col);
|
||||
}
|
||||
|
||||
void Configuration::setColorTheme(QString theme)
|
||||
{
|
||||
if (theme == "default")
|
||||
{
|
||||
Core()->cmd("ecd");
|
||||
s.setValue("theme", "default");
|
||||
}
|
||||
else
|
||||
{
|
||||
Core()->cmd(QString("eco %1").arg(theme));
|
||||
s.setValue("theme", theme);
|
||||
}
|
||||
emit colorsUpdated();
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ class Configuration : public QObject
|
||||
Q_OBJECT
|
||||
private:
|
||||
QSettings s;
|
||||
static Configuration* mPtr;
|
||||
static Configuration *mPtr;
|
||||
|
||||
void loadInitial();
|
||||
|
||||
@ -115,6 +115,9 @@ public:
|
||||
int getAsmTabs() const { return s.value("asm.tabs", 5).toInt(); }
|
||||
void setAsmTabs(int v) { s.setValue("asm.tabs", v); }
|
||||
|
||||
QString getCurrentTheme() const { return s.value("theme", "default").toString(); }
|
||||
void setColorTheme(QString theme);
|
||||
|
||||
signals:
|
||||
void fontsUpdated();
|
||||
void colorsUpdated();
|
||||
|
@ -121,7 +121,7 @@ void DisassemblerGraphView::loadCurrentGraph()
|
||||
{
|
||||
TempConfig tempConfig;
|
||||
tempConfig.set("scr.html", true)
|
||||
.set("scr.color", true)
|
||||
.set("scr.color", COLOR_MODE_16M)
|
||||
.set("asm.bbline", false)
|
||||
.set("asm.lines", false)
|
||||
.set("asm.fcnlines", false);
|
||||
|
@ -189,7 +189,7 @@ void DisassemblyWidget::refreshDisasm(RVA offset)
|
||||
{
|
||||
TempConfig tempConfig;
|
||||
tempConfig.set("scr.html", true)
|
||||
.set("scr.color", true);
|
||||
.set("scr.color", COLOR_MODE_16M);
|
||||
disassemblyLines = Core()->disassembleLines(topOffset, maxLines);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user