Skip to content

Commit ce04d65

Browse files
committed
Use theme colors for the navigation bar
1 parent 8e84add commit ce04d65

11 files changed

Lines changed: 196 additions & 55 deletions

AGENTS.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ iaito is the official Qt-based GUI for radare2. It uses qmake for building and r
1515

1616
## Formatting Style
1717

18-
- Follow Qt Creator coding style (see `.clang-format`)
19-
- Indent with **4 spaces** (no tabs)
20-
- Column limit: 100 characters
21-
- Braces on same line for control statements, new line for functions/classes
22-
- Use `clang-format -i file.cpp` or `make indent`
18+
- Follow C++ / Qt Creator coding style (see `.clang-format`)
19+
- Indent with **4 spaces** (no tabs)
20+
- Column limit: 100 characters
21+
- Use `make fmt` to format the whole project source
2322

2423
## Coding Rules
2524

2625
- C++20 standard
26+
- Code must be portable across windows, macos and linux
2727
- Use Qt signals/slots for communication between components
2828
- Widgets inherit from `IaitoDockWidget` or `AddressableDockWidget`
2929
- Access radare2 via the `Core()` singleton (defined in `core/Iaito.h`)

src/common/ColorThemeWorker.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const QStringList ColorThemeWorker::iaitoSpecificOptions
1414
"gui.imports", "highlightPC", "gui.navbar.err",
1515
"gui.navbar.seek", "gui.navbar.pc", "gui.navbar.sym",
1616
"gui.dataoffset", "gui.navbar.code", "gui.navbar.empty",
17-
"angui.navbar.str", "gui.disass_selected", "gui.breakpoint_background",
17+
"gui.navbar.str", "gui.disass_selected", "gui.breakpoint_background",
1818
"gui.overview.node", "gui.overview.fill", "gui.overview.border",
1919
"gui.border", "gui.background", "gui.alt_background",
2020
"gui.disass_selected"};
@@ -180,8 +180,10 @@ QJsonDocument ColorThemeWorker::getTheme(const QString &themeName) const
180180
if (sl.size() != 3 || sl[0][0] == '#') {
181181
continue;
182182
}
183+
QString optionName = sl[1] == "angui.navbar.str" ? QStringLiteral("gui.navbar.str")
184+
: sl[1];
183185
QColor(sl[2]).getRgb(&r, &g, &b, &a);
184-
theme.insert(sl[1], QJsonArray({r, g, b, a}));
186+
theme.insert(optionName, QJsonArray({r, g, b, a}));
185187
}
186188
}
187189

@@ -290,7 +292,8 @@ bool ColorThemeWorker::isFileTheme(const QString &filePath, bool *ok) const
290292
}
291293

292294
const QString colors = "black|red|white|green|magenta|yellow|cyan|blue|gray|none";
293-
QString options = (Core()->cmdj("ecj").object().keys() << iaitoSpecificOptions)
295+
QString options = (Core()->cmdj("ecj").object().keys()
296+
<< iaitoSpecificOptions << QStringLiteral("angui.navbar.str"))
294297
.join('|')
295298
.replace(".", "\\.");
296299

src/common/Configuration.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ static inline int variantTypeId(const QVariant &v)
3232
constexpr int VisualNavbarThicknessDefault = 15;
3333
constexpr int VisualNavbarThicknessMin = 8;
3434
constexpr int VisualNavbarThicknessMax = 64;
35+
constexpr bool VisualNavbarUseThemeColorsDefault = false;
3536
} // namespace
3637

3738
/* Map with names of themes associated with its color palette
@@ -503,6 +504,21 @@ void Configuration::setVisualNavbarThickness(int thickness)
503504
emit visualNavbarThicknessChanged(thickness);
504505
}
505506

507+
bool Configuration::getVisualNavbarUseThemeColors() const
508+
{
509+
return s.value("visualNavbarUseThemeColors", VisualNavbarUseThemeColorsDefault).toBool();
510+
}
511+
512+
void Configuration::setVisualNavbarUseThemeColors(bool enabled)
513+
{
514+
if (getVisualNavbarUseThemeColors() == enabled) {
515+
return;
516+
}
517+
518+
s.setValue("visualNavbarUseThemeColors", enabled);
519+
emit colorsUpdated();
520+
}
521+
506522
QString Configuration::getLastThemeOf(const IaitoInterfaceTheme &currInterfaceTheme) const
507523
{
508524
return s.value("lastThemeOf." + currInterfaceTheme.name, Config()->getColorTheme()).toString();

src/common/Configuration.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ class IAITO_EXPORT Configuration : public QObject
101101
void setVisualNavbarLocation(VisualNavbarLocation location);
102102
int getVisualNavbarThickness() const;
103103
void setVisualNavbarThickness(int thickness);
104+
bool getVisualNavbarUseThemeColors() const;
105+
void setVisualNavbarUseThemeColors(bool enabled);
104106

105107
// Colors
106108
bool windowColorIsDark();

src/core/Iaito.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4081,6 +4081,9 @@ BlockStatistics IaitoCore::getBlockStatistics(unsigned int blocksCount)
40814081

40824082
block.rwx = 0;
40834083
QString rwxStr = blockObj[RJsonKey::rwx].toString();
4084+
if (rwxStr.isEmpty()) {
4085+
rwxStr = blockObj[RJsonKey::perm].toString();
4086+
}
40844087
if (rwxStr.length() == 3) {
40854088
if (rwxStr[0] == 'r') {
40864089
block.rwx |= (1 << 0);

src/dialogs/preferences/AppearanceOptionsWidget.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ AppearanceOptionsWidget::AppearanceOptionsWidget(PreferencesDialog *dialog)
8080
connect(Config(), &Configuration::visualNavbarThicknessChanged, this, [this](int) {
8181
updateVisualNavbarFromConfig();
8282
});
83+
connect(Config(), &Configuration::colorsUpdated, this, [this]() {
84+
updateVisualNavbarFromConfig();
85+
});
8386

8487
connect(
8588
ui->colorComboBox,
@@ -137,6 +140,7 @@ void AppearanceOptionsWidget::updateVisualNavbarFromConfig()
137140
{
138141
QSignalBlocker locationBlocker(ui->visualNavbarLocationComboBox);
139142
QSignalBlocker thicknessBlocker(ui->visualNavbarThicknessSpinBox);
143+
QSignalBlocker themeColorBlocker(ui->visualNavbarUseThemeColorsCheckBox);
140144

141145
auto location = static_cast<int>(Config()->getVisualNavbarLocation());
142146
int index = ui->visualNavbarLocationComboBox->findData(location);
@@ -145,6 +149,7 @@ void AppearanceOptionsWidget::updateVisualNavbarFromConfig()
145149
}
146150

147151
ui->visualNavbarThicknessSpinBox->setValue(Config()->getVisualNavbarThickness());
152+
ui->visualNavbarUseThemeColorsCheckBox->setChecked(Config()->getVisualNavbarUseThemeColors());
148153
}
149154

150155
void AppearanceOptionsWidget::onFontZoomBoxValueChanged(int zoom)
@@ -182,6 +187,11 @@ void AppearanceOptionsWidget::on_visualNavbarThicknessSpinBox_valueChanged(int v
182187
Config()->setVisualNavbarThickness(value);
183188
}
184189

190+
void AppearanceOptionsWidget::on_visualNavbarUseThemeColorsCheckBox_toggled(bool checked)
191+
{
192+
Config()->setVisualNavbarUseThemeColors(checked);
193+
}
194+
185195
void AppearanceOptionsWidget::on_editButton_clicked()
186196
{
187197
ColorThemeEditDialog dial;

src/dialogs/preferences/AppearanceOptionsWidget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ private slots:
3535
void on_themeComboBox_currentIndexChanged(int index);
3636
void on_visualNavbarLocationComboBox_currentIndexChanged(int index);
3737
void on_visualNavbarThicknessSpinBox_valueChanged(int value);
38+
void on_visualNavbarUseThemeColorsCheckBox_toggled(bool checked);
3839
void on_copyButton_clicked();
3940
void on_deleteButton_clicked();
4041

src/dialogs/preferences/AppearanceOptionsWidget.ui

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>619</width>
10-
<height>225</height>
10+
<height>255</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -159,37 +159,48 @@
159159
<property name="text">
160160
<string>Navigation Bar:</string>
161161
</property>
162-
</widget>
162+
</widget>
163163
</item>
164164
<item row="3" column="1">
165-
<layout class="QHBoxLayout" name="visualNavbarLayout">
165+
<layout class="QVBoxLayout" name="visualNavbarSettingsLayout">
166166
<item>
167-
<widget class="QComboBox" name="visualNavbarLocationComboBox">
168-
<property name="sizePolicy">
169-
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
170-
<horstretch>0</horstretch>
171-
<verstretch>0</verstretch>
172-
</sizepolicy>
173-
</property>
174-
</widget>
167+
<layout class="QHBoxLayout" name="visualNavbarLayout">
168+
<item>
169+
<widget class="QComboBox" name="visualNavbarLocationComboBox">
170+
<property name="sizePolicy">
171+
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
172+
<horstretch>0</horstretch>
173+
<verstretch>0</verstretch>
174+
</sizepolicy>
175+
</property>
176+
</widget>
177+
</item>
178+
<item>
179+
<widget class="QLabel" name="visualNavbarThicknessLabel">
180+
<property name="text">
181+
<string>Thickness</string>
182+
</property>
183+
</widget>
184+
</item>
185+
<item>
186+
<widget class="QSpinBox" name="visualNavbarThicknessSpinBox">
187+
<property name="suffix">
188+
<string> px</string>
189+
</property>
190+
<property name="minimum">
191+
<number>8</number>
192+
</property>
193+
<property name="maximum">
194+
<number>64</number>
195+
</property>
196+
</widget>
197+
</item>
198+
</layout>
175199
</item>
176200
<item>
177-
<widget class="QLabel" name="visualNavbarThicknessLabel">
201+
<widget class="QCheckBox" name="visualNavbarUseThemeColorsCheckBox">
178202
<property name="text">
179-
<string>Thickness</string>
180-
</property>
181-
</widget>
182-
</item>
183-
<item>
184-
<widget class="QSpinBox" name="visualNavbarThicknessSpinBox">
185-
<property name="suffix">
186-
<string> px</string>
187-
</property>
188-
<property name="minimum">
189-
<number>8</number>
190-
</property>
191-
<property name="maximum">
192-
<number>64</number>
203+
<string>Use colors from the current radare2 theme</string>
193204
</property>
194205
</widget>
195206
</item>

src/widgets/ColorThemeListView.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,8 @@ const QMap<QString, OptionInfo> optionInfoMap__ = {
522522
{"highlightPC", {"", "highlightPC"}},
523523
{"gui.navbar.err", {"", "gui.navbar.err"}},
524524
{"gui.navbar.seek", {"", "gui.navbar.seek"}},
525-
{"angui.navbar.str", {"", "angui.navbar.str"}},
525+
{"gui.navbar.str",
526+
{QObject::tr("String region color in navigation bar"), QObject::tr("Navbar strings")}},
526527
{"gui.navbar.pc", {"", "gui.navbar.pc"}},
527528
{"gui.navbar.sym", {"", "gui.navbar.sym"}},
528529
{"gui.navbar.code",

0 commit comments

Comments
 (0)