diff --git a/src/utils/Configuration.cpp b/src/utils/Configuration.cpp index d5a8d070..3f9df1de 100644 --- a/src/utils/Configuration.cpp +++ b/src/utils/Configuration.cpp @@ -119,6 +119,7 @@ void Configuration::loadDefaultTheme() 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)); @@ -213,6 +214,7 @@ void Configuration::loadDarkTheme() setColor("gui.alt_background", QColor(58, 100, 128)); // 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)); diff --git a/src/widgets/FunctionsWidget.cpp b/src/widgets/FunctionsWidget.cpp index 12a31d94..5bbaeb1a 100644 --- a/src/widgets/FunctionsWidget.cpp +++ b/src/widgets/FunctionsWidget.cpp @@ -13,11 +13,13 @@ #include #include #include +#include -FunctionModel::FunctionModel(QList *functions, QSet *importAddresses, bool nested, QFont default_font, QFont highlight_font, QObject *parent) +FunctionModel::FunctionModel(QList *functions, QSet *importAddresses, ut64 *mainAdress, bool nested, QFont default_font, QFont highlight_font, QObject *parent) : QAbstractItemModel(parent), functions(functions), importAddresses(importAddresses), + mainAdress(mainAdress), highlightFont(highlight_font), defaultFont(default_font), nested(nested), @@ -75,6 +77,10 @@ bool FunctionModel::functionIsImport(ut64 addr) const return importAddresses->contains(addr); } +bool FunctionModel::functionIsMain(ut64 addr) const +{ + return *mainAdress == addr; +} QVariant FunctionModel::data(const QModelIndex &index, int role) const { @@ -167,6 +173,8 @@ QVariant FunctionModel::data(const QModelIndex &index, int role) const case Qt::ForegroundRole: if (functionIsImport(function.offset)) return QVariant(ConfigColor("gui.imports")); + if (functionIsMain(function.offset)) + return QVariant(ConfigColor("gui.main")); return QVariant(this->property("color")); case FunctionDescriptionRole: @@ -361,7 +369,7 @@ FunctionsWidget::FunctionsWidget(MainWindow *main, QWidget *parent) : QFont default_font = QFont(font_info.family(), font_info.pointSize()); QFont highlight_font = QFont(font_info.family(), font_info.pointSize(), QFont::Bold); - functionModel = new FunctionModel(&functions, &importAddresses, false, default_font, highlight_font, this); + functionModel = new FunctionModel(&functions, &importAddresses, &mainAdress, false, default_font, highlight_font, this); functionProxyModel = new FunctionSortFilterProxyModel(functionModel, this); ui->functionsTreeView->setModel(functionProxyModel); ui->functionsTreeView->sortByColumn(FunctionModel::NameColumn, Qt::AscendingOrder); @@ -400,6 +408,8 @@ void FunctionsWidget::refreshTree() foreach (ImportDescription import, CutterCore::getInstance()->getAllImports()) importAddresses.insert(import.plt); + mainAdress = (ut64)CutterCore::getInstance()->cmdj("iMj").object()["vaddr"].toInt(); + functionModel->endReloadFunctions(); // resize offset and size columns diff --git a/src/widgets/FunctionsWidget.h b/src/widgets/FunctionsWidget.h index ee89b7a8..257414ad 100644 --- a/src/widgets/FunctionsWidget.h +++ b/src/widgets/FunctionsWidget.h @@ -25,6 +25,7 @@ class FunctionModel : public QAbstractItemModel private: QList *functions; QSet *importAddresses; + ut64 *mainAdress; QFont highlightFont; @@ -35,13 +36,15 @@ private: bool functionIsImport(ut64 addr) const; + bool functionIsMain(ut64 addr) const; + public: static const int FunctionDescriptionRole = Qt::UserRole; static const int IsImportRole = Qt::UserRole + 1; enum Column { NameColumn = 0, SizeColumn, ImportColumn, OffsetColumn, ColumnCount }; - FunctionModel(QList *functions, QSet *importAddresses, bool nested, QFont defaultFont, QFont highlightFont, QObject *parent = 0); + FunctionModel(QList *functions, QSet *importAddresses, ut64 *mainAdress, bool nested, QFont defaultFont, QFont highlightFont, QObject *parent = 0); QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; QModelIndex parent(const QModelIndex &index) const; @@ -116,6 +119,7 @@ private: QList functions; QSet importAddresses; + ut64 mainAdress; FunctionModel *functionModel; FunctionSortFilterProxyModel *functionProxyModel;