mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-13 16:18:30 +00:00
Use DockWidget base class
- DockWidgets inherit from base class and implement the interface - Move setup/refresh code from MainWindow to widgets - Remove unused/uneeded members - Use helper functions - Fix compiler/cppcheck warnings - Cleanup headers
This commit is contained in:
parent
8e542d40fe
commit
6f2607fc3c
@ -2,6 +2,7 @@
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QGraphicsView>
|
||||
#include <QComboBox>
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsRectItem>
|
||||
@ -16,7 +17,7 @@ GraphicsBar::GraphicsBar(MainWindow *main, QWidget *parent) :
|
||||
QNOTUSED(parent);
|
||||
|
||||
setObjectName("codeGraphics");
|
||||
setWindowTitle("Code bar");
|
||||
setWindowTitle(tr("Code bar"));
|
||||
// setMovable(false);
|
||||
setContentsMargins(0, 0, 0, 0);
|
||||
// If line below is used, with the dark theme the paintEvent is not called
|
||||
@ -55,7 +56,7 @@ void GraphicsBar::fillData()
|
||||
// Prepare the graph scene
|
||||
int w = this->codeGraphic->width();
|
||||
int h = this->codeGraphic->height();
|
||||
QGraphicsScene *scene = new QGraphicsScene();
|
||||
QGraphicsScene *scene = new QGraphicsScene(this);
|
||||
|
||||
const QBrush bg = QBrush(QColor(74, 74, 74));
|
||||
|
||||
|
@ -1,11 +1,10 @@
|
||||
#ifndef GRAPHICSBAR_H
|
||||
#define GRAPHICSBAR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QToolBar>
|
||||
#include <QGraphicsView>
|
||||
|
||||
class MainWindow;
|
||||
class QGraphicsView;
|
||||
|
||||
class GraphicsBar : public QToolBar
|
||||
{
|
||||
@ -13,7 +12,6 @@ class GraphicsBar : public QToolBar
|
||||
|
||||
public:
|
||||
explicit GraphicsBar(MainWindow *main, QWidget *parent = 0);
|
||||
QGraphicsView *codeGraphic;
|
||||
|
||||
public slots:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
@ -21,9 +19,7 @@ public slots:
|
||||
|
||||
private:
|
||||
MainWindow *main;
|
||||
|
||||
public slots:
|
||||
|
||||
QGraphicsView *codeGraphic;
|
||||
};
|
||||
|
||||
#endif // GRAPHICSBAR_H
|
||||
|
@ -2,17 +2,21 @@
|
||||
#include "ui_commentswidget.h"
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "helpers.h"
|
||||
|
||||
#include <QTreeWidget>
|
||||
#include <QMenu>
|
||||
#include <QResizeEvent>
|
||||
|
||||
|
||||
CommentsWidget::CommentsWidget(MainWindow *main, QWidget *parent) :
|
||||
QDockWidget(parent),
|
||||
ui(new Ui::CommentsWidget)
|
||||
DockWidget(parent),
|
||||
ui(new Ui::CommentsWidget),
|
||||
main(main)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// Radare core found in:
|
||||
this->main = main;
|
||||
this->commentsTreeWidget = ui->commentsTreeWidget;
|
||||
this->nestedCommentsTreeWidget = ui->nestedCmtsTreeWidget;
|
||||
ui->commentsTreeWidget->hideColumn(0);
|
||||
|
||||
QTabBar *tabs = ui->tabWidget->tabBar();
|
||||
tabs->setVisible(false);
|
||||
@ -33,6 +37,16 @@ CommentsWidget::~CommentsWidget()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void CommentsWidget::setup()
|
||||
{
|
||||
refreshTree();
|
||||
}
|
||||
|
||||
void CommentsWidget::refresh()
|
||||
{
|
||||
refreshTree();
|
||||
}
|
||||
|
||||
void CommentsWidget::on_commentsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
|
||||
{
|
||||
QNOTUSED(column);
|
||||
@ -45,39 +59,6 @@ void CommentsWidget::on_commentsTreeWidget_itemDoubleClicked(QTreeWidgetItem *it
|
||||
this->main->seek(offset, name);
|
||||
}
|
||||
|
||||
void CommentsWidget::refreshTree()
|
||||
{
|
||||
this->commentsTreeWidget->clear();
|
||||
QList<QList<QString>> comments = this->main->core->getComments();
|
||||
for (QList<QString> comment : comments)
|
||||
{
|
||||
this->main->add_debug_output(comment[1]);
|
||||
QString fcn_name = this->main->core->cmdFunctionAt(comment[1]);
|
||||
this->main->appendRow(this->commentsTreeWidget, comment[1], fcn_name, comment[0].remove('"'));
|
||||
}
|
||||
this->main->adjustColumns(this->commentsTreeWidget);
|
||||
|
||||
// Add nested comments
|
||||
this->nestedCommentsTreeWidget->clear();
|
||||
QMap<QString, QList<QList<QString>>> cmts = this->main->core->getNestedComments();
|
||||
for (auto cmt : cmts.keys())
|
||||
{
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(this->nestedCommentsTreeWidget);
|
||||
item->setText(0, cmt);
|
||||
QList<QList<QString>> meow = cmts.value(cmt);
|
||||
for (int i = 0; i < meow.size(); ++i)
|
||||
{
|
||||
QList<QString> tmp = meow.at(i);
|
||||
QTreeWidgetItem *it = new QTreeWidgetItem();
|
||||
it->setText(0, tmp[1]);
|
||||
it->setText(1, tmp[0].remove('"'));
|
||||
item->addChild(it);
|
||||
}
|
||||
this->nestedCommentsTreeWidget->addTopLevelItem(item);
|
||||
}
|
||||
this->main->adjustColumns(this->nestedCommentsTreeWidget);
|
||||
}
|
||||
|
||||
void CommentsWidget::on_toolButton_clicked()
|
||||
{
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
@ -140,3 +121,36 @@ void CommentsWidget::resizeEvent(QResizeEvent *event)
|
||||
}
|
||||
QDockWidget::resizeEvent(event);
|
||||
}
|
||||
|
||||
void CommentsWidget::refreshTree()
|
||||
{
|
||||
ui->commentsTreeWidget->clear();
|
||||
const QList<QList<QString>> &comments = main->core->getComments();
|
||||
for (const QList<QString> &comment : comments)
|
||||
{
|
||||
//this->main->add_debug_output(comment[1]);
|
||||
QString fcn_name = this->main->core->cmdFunctionAt(comment[1]);
|
||||
qhelpers::appendRow(ui->commentsTreeWidget, comment[1], fcn_name, QString(comment[0]).remove('"'));
|
||||
}
|
||||
qhelpers::adjustColumns(ui->commentsTreeWidget);
|
||||
|
||||
// Add nested comments
|
||||
ui->nestedCmtsTreeWidget->clear();
|
||||
const QMap<QString, QList<QList<QString>>> &cmts = main->core->getNestedComments();
|
||||
for (auto cmt : cmts.keys())
|
||||
{
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(ui->nestedCmtsTreeWidget);
|
||||
item->setText(0, cmt);
|
||||
const QList<QList<QString>> &meow = cmts.value(cmt);
|
||||
for (int i = 0; i < meow.size(); ++i)
|
||||
{
|
||||
const QList<QString> &tmp = meow.at(i);
|
||||
QTreeWidgetItem *it = new QTreeWidgetItem();
|
||||
it->setText(0, tmp[1]);
|
||||
it->setText(1, QString(tmp[0]).remove('"'));
|
||||
item->addChild(it);
|
||||
}
|
||||
ui->nestedCmtsTreeWidget->addTopLevelItem(item);
|
||||
}
|
||||
qhelpers::adjustColumns(ui->nestedCmtsTreeWidget);
|
||||
}
|
||||
|
@ -1,18 +1,17 @@
|
||||
#ifndef COMMENTSWIDGET_H
|
||||
#define COMMENTSWIDGET_H
|
||||
|
||||
#include <QDockWidget>
|
||||
#include <QTreeWidget>
|
||||
#include <QMenu>
|
||||
#include "dockwidget.h"
|
||||
|
||||
class MainWindow;
|
||||
class QTreeWidgetItem;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class CommentsWidget;
|
||||
}
|
||||
|
||||
class CommentsWidget : public QDockWidget
|
||||
class CommentsWidget : public DockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -20,9 +19,9 @@ public:
|
||||
explicit CommentsWidget(MainWindow *main, QWidget *parent = 0);
|
||||
~CommentsWidget();
|
||||
|
||||
QTreeWidget *commentsTreeWidget;
|
||||
QTreeWidget *nestedCommentsTreeWidget;
|
||||
void refreshTree();
|
||||
void setup() override;
|
||||
|
||||
void refresh() override;
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
@ -42,10 +41,9 @@ private slots:
|
||||
|
||||
private:
|
||||
Ui::CommentsWidget *ui;
|
||||
|
||||
MainWindow *main;
|
||||
|
||||
QWidget *title_bar;
|
||||
void refreshTree();
|
||||
};
|
||||
|
||||
#endif // COMMENTSWIDGET_H
|
||||
|
@ -8,9 +8,11 @@
|
||||
#include <QStringList>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include <QFile>
|
||||
|
||||
|
||||
Dashboard::Dashboard(MainWindow *main, QWidget *parent) :
|
||||
QDockWidget(parent),
|
||||
DockWidget(parent),
|
||||
ui(new Ui::Dashboard)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@ -26,6 +28,16 @@ Dashboard::~Dashboard()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void Dashboard::setup()
|
||||
{
|
||||
updateContents();
|
||||
}
|
||||
|
||||
void Dashboard::refresh()
|
||||
{
|
||||
updateContents();
|
||||
}
|
||||
|
||||
void Dashboard::updateContents()
|
||||
{
|
||||
|
||||
@ -186,3 +198,4 @@ void Dashboard::updateContents()
|
||||
code2.replace("WOEM", data);
|
||||
ui->polarWebView->setHtml(code2);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef DASHBOARD_H
|
||||
#define DASHBOARD_H
|
||||
|
||||
#include <QDockWidget>
|
||||
#include "dockwidget.h"
|
||||
|
||||
class MainWindow;
|
||||
|
||||
@ -10,7 +10,7 @@ namespace Ui
|
||||
class Dashboard;
|
||||
}
|
||||
|
||||
class Dashboard : public QDockWidget
|
||||
class Dashboard : public DockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -18,11 +18,14 @@ public:
|
||||
explicit Dashboard(MainWindow *main, QWidget *parent = 0);
|
||||
~Dashboard();
|
||||
|
||||
void updateContents();
|
||||
void setup() override;
|
||||
|
||||
void refresh() override;
|
||||
|
||||
private:
|
||||
Ui::Dashboard *ui;
|
||||
void updateContents();
|
||||
|
||||
Ui::Dashboard *ui;
|
||||
MainWindow *main;
|
||||
};
|
||||
|
||||
|
@ -2,18 +2,21 @@
|
||||
#include "ui_flagswidget.h"
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "helpers.h"
|
||||
|
||||
#include <QDockWidget>
|
||||
#include <QTreeWidget>
|
||||
#include <QComboBox>
|
||||
|
||||
|
||||
FlagsWidget::FlagsWidget(MainWindow *main, QWidget *parent) :
|
||||
QDockWidget(parent),
|
||||
ui(new Ui::FlagsWidget)
|
||||
DockWidget(parent),
|
||||
ui(new Ui::FlagsWidget),
|
||||
main(main)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// Radare core found in:
|
||||
this->main = main;
|
||||
|
||||
this->flagsTreeWidget = ui->flagsTreeWidget;
|
||||
this->flagspaceCombo = ui->flagspaceCombo;
|
||||
ui->flagsTreeWidget->hideColumn(0);
|
||||
}
|
||||
|
||||
FlagsWidget::~FlagsWidget()
|
||||
@ -21,6 +24,23 @@ FlagsWidget::~FlagsWidget()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void FlagsWidget::setup()
|
||||
{
|
||||
setScrollMode();
|
||||
|
||||
refreshFlagspaces();
|
||||
}
|
||||
|
||||
void FlagsWidget::refresh()
|
||||
{
|
||||
setup();
|
||||
}
|
||||
|
||||
void FlagsWidget::clear()
|
||||
{
|
||||
ui->flagsTreeWidget->clear();
|
||||
}
|
||||
|
||||
void FlagsWidget::on_flagsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
|
||||
{
|
||||
QNOTUSED(column);
|
||||
@ -34,5 +54,57 @@ void FlagsWidget::on_flagspaceCombo_currentTextChanged(const QString &arg1)
|
||||
{
|
||||
QNOTUSED(arg1);
|
||||
|
||||
this->main->refreshFlags();
|
||||
refreshFlags();
|
||||
}
|
||||
|
||||
void FlagsWidget::refreshFlagspaces()
|
||||
{
|
||||
int cur_idx = ui->flagspaceCombo->currentIndex();
|
||||
if (cur_idx < 0)cur_idx = 0;
|
||||
ui->flagspaceCombo->clear();
|
||||
ui->flagspaceCombo->addItem("(all)");
|
||||
for (auto i : main->core->getList("flagspaces"))
|
||||
{
|
||||
ui->flagspaceCombo->addItem(i);
|
||||
}
|
||||
if (cur_idx > 0)
|
||||
ui->flagspaceCombo->setCurrentIndex(cur_idx);
|
||||
|
||||
refreshFlags();
|
||||
}
|
||||
|
||||
void FlagsWidget::refreshFlags()
|
||||
{
|
||||
QString flagspace = ui->flagspaceCombo->currentText();
|
||||
// TODO: Do this in Omnibar
|
||||
//this->omnibar->clearFlags();
|
||||
if (flagspace == "(all)")
|
||||
flagspace = "";
|
||||
|
||||
ui->flagsTreeWidget->clear();
|
||||
|
||||
for (auto i : main->core->getList("flags", flagspace))
|
||||
{
|
||||
QStringList a = i.split(",");
|
||||
if (a.length() > 3)
|
||||
{
|
||||
qhelpers::appendRow(ui->flagsTreeWidget, a[1], a[2], a[0], a[3]);
|
||||
//this->omnibar->fillFlags(a[0]);
|
||||
}
|
||||
else if (a.length() > 2)
|
||||
{
|
||||
qhelpers::appendRow(ui->flagsTreeWidget, a[1], a[2], a[0], "");
|
||||
//this->omnibar->fillFlags(a[0]);
|
||||
}
|
||||
}
|
||||
qhelpers::adjustColumns(ui->flagsTreeWidget);
|
||||
// Set omnibar completer for flags and commands
|
||||
//this->omnibar->setupCompleter();
|
||||
|
||||
emit flagsRefreshed();
|
||||
}
|
||||
|
||||
void FlagsWidget::setScrollMode()
|
||||
{
|
||||
qhelpers::setVerticalScrollMode(ui->flagsTreeWidget);
|
||||
}
|
||||
|
@ -1,18 +1,17 @@
|
||||
#ifndef FLAGSWIDGET_H
|
||||
#define FLAGSWIDGET_H
|
||||
|
||||
#include <QDockWidget>
|
||||
#include <QTreeWidget>
|
||||
#include <QComboBox>
|
||||
#include "dockwidget.h"
|
||||
|
||||
class MainWindow;
|
||||
class QTreeWidgetItem;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class FlagsWidget;
|
||||
}
|
||||
|
||||
class FlagsWidget : public QDockWidget
|
||||
class FlagsWidget : public DockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -20,8 +19,14 @@ public:
|
||||
explicit FlagsWidget(MainWindow *main, QWidget *parent = 0);
|
||||
~FlagsWidget();
|
||||
|
||||
QTreeWidget *flagsTreeWidget;
|
||||
QComboBox *flagspaceCombo;
|
||||
void setup() override;
|
||||
|
||||
void refresh() override;
|
||||
|
||||
void clear();
|
||||
|
||||
signals:
|
||||
void flagsRefreshed();
|
||||
|
||||
private slots:
|
||||
void on_flagsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
|
||||
@ -30,8 +35,11 @@ private slots:
|
||||
|
||||
private:
|
||||
Ui::FlagsWidget *ui;
|
||||
|
||||
MainWindow *main;
|
||||
|
||||
void refreshFlags();
|
||||
void refreshFlagspaces();
|
||||
void setScrollMode();
|
||||
};
|
||||
|
||||
#endif // FLAGSWIDGET_H
|
||||
|
@ -1,32 +1,35 @@
|
||||
#include "functionswidget.h"
|
||||
#include "ui_functionswidget.h"
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "helpers.h"
|
||||
#include "dialogs/commentsdialog.h"
|
||||
#include "dialogs/renamedialog.h"
|
||||
#include "dialogs/xrefsdialog.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QTreeWidget>
|
||||
#include <QMenu>
|
||||
#include <QDebug>
|
||||
#include <QString>
|
||||
|
||||
|
||||
FunctionsWidget::FunctionsWidget(MainWindow *main, QWidget *parent) :
|
||||
QDockWidget(parent),
|
||||
ui(new Ui::FunctionsWidget)
|
||||
DockWidget(parent),
|
||||
ui(new Ui::FunctionsWidget),
|
||||
main(main)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// Radare core found in:
|
||||
this->main = main;
|
||||
this->functionsTreeWidget = ui->functionsTreeWidget;
|
||||
this->functionsTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
//this->functionsTreeWidget->setFont(QFont("Monospace", 8));
|
||||
ui->functionsTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
//ui->functionsTreeWidget->setFont(QFont("Monospace", 8));
|
||||
// Set Functions context menu
|
||||
connect(ui->functionsTreeWidget, SIGNAL(customContextMenuRequested(const QPoint &)),
|
||||
this, SLOT(showFunctionsContextMenu(const QPoint &)));
|
||||
connect(ui->nestedFunctionsTree, SIGNAL(customContextMenuRequested(const QPoint &)),
|
||||
this, SLOT(showFunctionsContextMenu(const QPoint &)));
|
||||
|
||||
ui->functionsTreeWidget->hideColumn(0);
|
||||
|
||||
// Hide the tabs
|
||||
QTabBar *tabs = ui->tabWidget->tabBar();
|
||||
tabs->setVisible(false);
|
||||
@ -44,9 +47,21 @@ FunctionsWidget::~FunctionsWidget()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void FunctionsWidget::setup()
|
||||
{
|
||||
setScrollMode();
|
||||
|
||||
fillFunctions();
|
||||
}
|
||||
|
||||
void FunctionsWidget::refresh()
|
||||
{
|
||||
setup();
|
||||
}
|
||||
|
||||
void FunctionsWidget::fillFunctions()
|
||||
{
|
||||
this->functionsTreeWidget->clear();
|
||||
ui->functionsTreeWidget->clear();
|
||||
ui->nestedFunctionsTree->clear();
|
||||
for (auto i : this->main->core->getList("anal", "functions"))
|
||||
{
|
||||
@ -57,7 +72,7 @@ void FunctionsWidget::fillFunctions()
|
||||
if (a.length() == 5)
|
||||
{
|
||||
// Add list function
|
||||
this->main->appendRow(this->functionsTreeWidget, a[0], a[1], a[4]);
|
||||
qhelpers::appendRow(ui->functionsTreeWidget, a[0], a[1], a[4]);
|
||||
// Add nested function
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(ui->nestedFunctionsTree);
|
||||
item->setText(0, a[4]);
|
||||
@ -72,7 +87,7 @@ void FunctionsWidget::fillFunctions()
|
||||
else if (a.length() == 6)
|
||||
{
|
||||
// Add list function
|
||||
this->main->appendRow(this->functionsTreeWidget, a[0], a[1], a[5]);
|
||||
qhelpers::appendRow(ui->functionsTreeWidget, a[0], a[1], a[5]);
|
||||
// Add nested function
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(ui->nestedFunctionsTree);
|
||||
item->setText(0, a[5]);
|
||||
@ -89,9 +104,9 @@ void FunctionsWidget::fillFunctions()
|
||||
qDebug() << "fillFunctions()" << a;
|
||||
}
|
||||
}
|
||||
this->functionsTreeWidget->sortByColumn(3, Qt::AscendingOrder);
|
||||
ui->functionsTreeWidget->sortByColumn(3, Qt::AscendingOrder);
|
||||
ui->nestedFunctionsTree->sortByColumn(0, Qt::AscendingOrder);
|
||||
this->main->adjustColumns(this->functionsTreeWidget);
|
||||
qhelpers::adjustColumns(ui->functionsTreeWidget);
|
||||
|
||||
this->addTooltips();
|
||||
}
|
||||
@ -103,7 +118,7 @@ void FunctionsWidget::on_functionsTreeWidget_itemDoubleClicked(QTreeWidgetItem *
|
||||
QString offset = item->text(1);
|
||||
QString name = item->text(3);
|
||||
this->main->seek(offset, name);
|
||||
this->main->memoryDock->raise();
|
||||
this->main->raiseMemoryDock();
|
||||
}
|
||||
|
||||
void FunctionsWidget::showFunctionsContextMenu(const QPoint &pt)
|
||||
@ -119,7 +134,7 @@ void FunctionsWidget::showFunctionsContextMenu(const QPoint &pt)
|
||||
|
||||
if (ui->tabWidget->currentIndex() == 0)
|
||||
{
|
||||
this->functionsTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
ui->functionsTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
menu->exec(ui->functionsTreeWidget->mapToGlobal(pt));
|
||||
}
|
||||
else
|
||||
@ -132,7 +147,7 @@ void FunctionsWidget::showFunctionsContextMenu(const QPoint &pt)
|
||||
|
||||
void FunctionsWidget::refreshTree()
|
||||
{
|
||||
this->functionsTreeWidget->clear();
|
||||
ui->functionsTreeWidget->clear();
|
||||
ui->nestedFunctionsTree->clear();
|
||||
for (auto i : this->main->core->getList("anal", "functions"))
|
||||
{
|
||||
@ -143,7 +158,7 @@ void FunctionsWidget::refreshTree()
|
||||
if (a.length() == 5)
|
||||
{
|
||||
// Add list function
|
||||
this->main->appendRow(this->functionsTreeWidget, a[0], a[1], a[4]);
|
||||
qhelpers::appendRow(ui->functionsTreeWidget, a[0], a[1], a[4]);
|
||||
// Add nested function
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(ui->nestedFunctionsTree);
|
||||
item->setText(0, a[4]);
|
||||
@ -158,7 +173,7 @@ void FunctionsWidget::refreshTree()
|
||||
else if (a.length() == 6)
|
||||
{
|
||||
// Add list function
|
||||
this->main->appendRow(this->functionsTreeWidget, a[0], a[1], a[5]);
|
||||
qhelpers::appendRow(ui->functionsTreeWidget, a[0], a[1], a[5]);
|
||||
// Add nested function
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(ui->nestedFunctionsTree);
|
||||
item->setText(0, a[5]);
|
||||
@ -175,9 +190,9 @@ void FunctionsWidget::refreshTree()
|
||||
qDebug() << "fillFunctions()" << a;
|
||||
}
|
||||
}
|
||||
this->functionsTreeWidget->sortByColumn(3, Qt::AscendingOrder);
|
||||
ui->functionsTreeWidget->sortByColumn(3, Qt::AscendingOrder);
|
||||
ui->nestedFunctionsTree->sortByColumn(0, Qt::AscendingOrder);
|
||||
this->main->adjustColumns(this->functionsTreeWidget);
|
||||
qhelpers::adjustColumns(ui->functionsTreeWidget);
|
||||
|
||||
this->addTooltips();
|
||||
}
|
||||
@ -218,7 +233,7 @@ void FunctionsWidget::addTooltips()
|
||||
{
|
||||
|
||||
// Add comments to list functions
|
||||
QList<QTreeWidgetItem *> clist = this->functionsTreeWidget->findItems("*", Qt::MatchWildcard, 3);
|
||||
QList<QTreeWidgetItem *> clist = ui->functionsTreeWidget->findItems("*", Qt::MatchWildcard, 3);
|
||||
foreach (QTreeWidgetItem *item, clist)
|
||||
{
|
||||
QString name = item->text(3);
|
||||
@ -389,7 +404,7 @@ void FunctionsWidget::on_nestedFunctionsTree_itemDoubleClicked(QTreeWidgetItem *
|
||||
QString name = item->text(0);
|
||||
QString offset = item->child(0)->text(0).split(":")[1];
|
||||
this->main->seek(offset, name);
|
||||
this->main->memoryDock->raise();
|
||||
this->main->raiseMemoryDock();
|
||||
}
|
||||
|
||||
void FunctionsWidget::resizeEvent(QResizeEvent *event)
|
||||
@ -409,3 +424,8 @@ void FunctionsWidget::resizeEvent(QResizeEvent *event)
|
||||
}
|
||||
QDockWidget::resizeEvent(event);
|
||||
}
|
||||
|
||||
void FunctionsWidget::setScrollMode()
|
||||
{
|
||||
qhelpers::setVerticalScrollMode(ui->functionsTreeWidget);
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
#ifndef FUNCTIONSWIDGET_H
|
||||
#define FUNCTIONSWIDGET_H
|
||||
|
||||
#include <QDockWidget>
|
||||
#include <QTreeWidget>
|
||||
#include "dashboard.h"
|
||||
|
||||
class MainWindow;
|
||||
class QTreeWidgetItem;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class FunctionsWidget;
|
||||
}
|
||||
|
||||
class FunctionsWidget : public QDockWidget
|
||||
class FunctionsWidget : public DockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -19,9 +19,11 @@ public:
|
||||
explicit FunctionsWidget(MainWindow *main, QWidget *parent = 0);
|
||||
~FunctionsWidget();
|
||||
|
||||
QTreeWidget *functionsTreeWidget;
|
||||
void setup() override;
|
||||
|
||||
void refresh() override;
|
||||
|
||||
void fillFunctions();
|
||||
void refreshTree();
|
||||
void addTooltips();
|
||||
|
||||
private slots:
|
||||
@ -47,8 +49,10 @@ protected:
|
||||
|
||||
private:
|
||||
Ui::FunctionsWidget *ui;
|
||||
|
||||
MainWindow *main;
|
||||
|
||||
void refreshTree();
|
||||
void setScrollMode();
|
||||
};
|
||||
|
||||
#endif // FUNCTIONSWIDGET_H
|
||||
|
@ -1,8 +1,13 @@
|
||||
#include "importswidget.h"
|
||||
#include "ui_importswidget.h"
|
||||
|
||||
#include <QStyledItemDelegate>
|
||||
#include "mainwindow.h"
|
||||
#include "helpers.h"
|
||||
|
||||
#include <QTreeWidget>
|
||||
#include <QPen>
|
||||
#include <QPainter>
|
||||
|
||||
|
||||
void CMyDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
@ -28,32 +33,50 @@ void CMyDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, c
|
||||
*/
|
||||
|
||||
ImportsWidget::ImportsWidget(MainWindow *main, QWidget *parent) :
|
||||
QDockWidget(parent),
|
||||
DockWidget(parent),
|
||||
ui(new Ui::ImportsWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// Radare core found in:
|
||||
this->main = main;
|
||||
this->importsTreeWidget = ui->importsTreeWidget;
|
||||
|
||||
// Delegate
|
||||
//CMyDelegate* delegate = new CMyDelegate(ui->importsTreeWidget);
|
||||
//ui->importsTreeWidget->setItemDelegate(delegate);
|
||||
|
||||
ui->importsTreeWidget->hideColumn(0);
|
||||
}
|
||||
|
||||
ImportsWidget::~ImportsWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ImportsWidget::setup()
|
||||
{
|
||||
setScrollMode();
|
||||
|
||||
fillImports();
|
||||
}
|
||||
|
||||
void ImportsWidget::refresh()
|
||||
{
|
||||
setup();
|
||||
}
|
||||
|
||||
void ImportsWidget::fillImports()
|
||||
{
|
||||
this->importsTreeWidget->clear();
|
||||
ui->importsTreeWidget->clear();
|
||||
for (auto i : this->main->core->getList("bin", "imports"))
|
||||
{
|
||||
QStringList a = i.split(",");
|
||||
// ord,plt,name
|
||||
if (a.length() == 6)
|
||||
this->main->appendRow(this->importsTreeWidget, a[1], a[3], "", a[4]);
|
||||
qhelpers::appendRow(ui->importsTreeWidget, a[1], a[3], "", a[4]);
|
||||
}
|
||||
highlightUnsafe();
|
||||
this->main->adjustColumns(this->importsTreeWidget);
|
||||
qhelpers::adjustColumns(ui->importsTreeWidget);
|
||||
}
|
||||
|
||||
void ImportsWidget::highlightUnsafe()
|
||||
@ -72,7 +95,7 @@ void ImportsWidget::highlightUnsafe()
|
||||
"OemToChar|OemToCharA|OemToCharW|CharToOemBuffA|CharToOemBuffW|alloca|_alloca|strlen|wcslen|_mbslen|_mbstrlen|StrLen|lstrlen|" \
|
||||
"ChangeWindowMessageFilter)");
|
||||
|
||||
QList<QTreeWidgetItem *> clist = this->importsTreeWidget->findItems(banned, Qt::MatchRegExp, 4);
|
||||
QList<QTreeWidgetItem *> clist = ui->importsTreeWidget->findItems(banned, Qt::MatchRegExp, 4);
|
||||
foreach (QTreeWidgetItem *item, clist)
|
||||
{
|
||||
item->setText(3, "Unsafe");
|
||||
@ -83,8 +106,14 @@ void ImportsWidget::highlightUnsafe()
|
||||
//ui->importsTreeWidget->setStyleSheet("QTreeWidget::item { padding-left:10px; padding-top: 1px; padding-bottom: 1px; border-left: 10px; }");
|
||||
}
|
||||
|
||||
void ImportsWidget::setScrollMode()
|
||||
{
|
||||
qhelpers::setVerticalScrollMode(ui->importsTreeWidget);
|
||||
}
|
||||
|
||||
void ImportsWidget::adjustColumns(QTreeWidget *tw)
|
||||
{
|
||||
// WARNING: was this ever called.. compare to master
|
||||
int count = tw->columnCount();
|
||||
for (int i = 0; i != count; ++i)
|
||||
{
|
||||
@ -93,8 +122,3 @@ void ImportsWidget::adjustColumns(QTreeWidget *tw)
|
||||
ui->importsTreeWidget->setColumnWidth(i, width + 10);
|
||||
}
|
||||
}
|
||||
|
||||
ImportsWidget::~ImportsWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
@ -1,18 +1,18 @@
|
||||
#ifndef IMPORTSWIDGET_H
|
||||
#define IMPORTSWIDGET_H
|
||||
|
||||
#include "dockwidget.h"
|
||||
#include <QStyledItemDelegate>
|
||||
#include <QDockWidget>
|
||||
#include <QTreeWidget>
|
||||
|
||||
class MainWindow;
|
||||
class QTreeWidget;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ImportsWidget;
|
||||
}
|
||||
|
||||
class ImportsWidget : public QDockWidget
|
||||
class ImportsWidget : public DockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -20,14 +20,17 @@ public:
|
||||
explicit ImportsWidget(MainWindow *main, QWidget *parent = 0);
|
||||
~ImportsWidget();
|
||||
|
||||
QTreeWidget *importsTreeWidget;
|
||||
void fillImports();
|
||||
void highlightUnsafe();
|
||||
void setup() override;
|
||||
|
||||
void refresh() override;
|
||||
|
||||
private:
|
||||
Ui::ImportsWidget *ui;
|
||||
|
||||
MainWindow *main;
|
||||
|
||||
void fillImports();
|
||||
void highlightUnsafe();
|
||||
void setScrollMode();
|
||||
void adjustColumns(QTreeWidget *tw);
|
||||
};
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "ui_memorywidget.h"
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "helpers.h"
|
||||
#include "dialogs/xrefsdialog.h"
|
||||
#include "dialogs/renamedialog.h"
|
||||
#include "dialogs/commentsdialog.h"
|
||||
@ -17,9 +18,12 @@
|
||||
#include <QUrl>
|
||||
#include <QWebEngineSettings>
|
||||
#include <QWebEngineProfile>
|
||||
#include <QSettings>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
MemoryWidget::MemoryWidget(MainWindow *main) :
|
||||
QDockWidget(main),
|
||||
DockWidget(main),
|
||||
ui(new Ui::MemoryWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@ -380,6 +384,27 @@ MemoryWidget::~MemoryWidget()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MemoryWidget::setup()
|
||||
{
|
||||
setScrollMode();
|
||||
|
||||
const QString off = main->core->cmd("afo entry0").trimmed();
|
||||
|
||||
refreshDisasm(off);
|
||||
refreshHexdump(off);
|
||||
create_graph(off);
|
||||
get_refs_data(off);
|
||||
setFcnName(off);
|
||||
}
|
||||
|
||||
void MemoryWidget::refresh()
|
||||
{
|
||||
setScrollMode();
|
||||
|
||||
// TODO: honor the offset
|
||||
updateViews();
|
||||
}
|
||||
|
||||
/*
|
||||
* Content management functions
|
||||
*/
|
||||
@ -1051,7 +1076,13 @@ void MemoryWidget::on_actionSettings_menu_1_triggered()
|
||||
// QFont font = QFont("Monospace", 8);
|
||||
|
||||
QFont font = QFontDialog::getFont(&ok, ui->disasTextEdit_2->font(), this);
|
||||
setFonts(font);
|
||||
|
||||
if (ok)
|
||||
{
|
||||
setFonts(font);
|
||||
|
||||
emit fontChanged(font);
|
||||
}
|
||||
}
|
||||
void MemoryWidget::setFonts(QFont font)
|
||||
{
|
||||
@ -1063,7 +1094,6 @@ void MemoryWidget::setFonts(QFont font)
|
||||
ui->hexASCIIText_2->setFont(font);
|
||||
ui->previewTextEdit->setFont(font);
|
||||
ui->decoTextEdit->setFont(font);
|
||||
this->main->notepadDock->setFonts(font);
|
||||
}
|
||||
|
||||
void MemoryWidget::on_actionHideDisasm_side_panel_triggered()
|
||||
@ -1544,13 +1574,11 @@ QString MemoryWidget::normalize_addr(QString addr)
|
||||
|
||||
void MemoryWidget::setFcnName(QString addr)
|
||||
{
|
||||
RAnalFunction *fcn;
|
||||
bool ok;
|
||||
|
||||
// TDOD: FIX ME, ugly
|
||||
if (addr.contains("0x"))
|
||||
{
|
||||
fcn = this->main->core->functionAt(addr.toULongLong(&ok, 16));
|
||||
bool ok = false;
|
||||
RAnalFunction *fcn = this->main->core->functionAt(addr.toULongLong(&ok, 16));
|
||||
if (ok && fcn)
|
||||
{
|
||||
QString segment = this->main->core->cmd("S. @ " + addr).split(" ").last();
|
||||
@ -1789,6 +1817,12 @@ bool MemoryWidget::eventFilter(QObject *obj, QEvent *event)
|
||||
return QDockWidget::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
void MemoryWidget::setScrollMode()
|
||||
{
|
||||
qhelpers::setVerticalScrollMode(ui->xreFromTreeWidget_2);
|
||||
qhelpers::setVerticalScrollMode(ui->xrefToTreeWidget_2);
|
||||
}
|
||||
|
||||
void MemoryWidget::on_actionXRefs_triggered()
|
||||
{
|
||||
// Get current offset
|
||||
|
@ -16,6 +16,8 @@
|
||||
#include <QPlainTextEdit>
|
||||
#include <QMouseEvent>
|
||||
|
||||
#include "dashboard.h"
|
||||
|
||||
class MainWindow;
|
||||
|
||||
namespace Ui
|
||||
@ -23,7 +25,7 @@ namespace Ui
|
||||
class MemoryWidget;
|
||||
}
|
||||
|
||||
class MemoryWidget : public QDockWidget
|
||||
class MemoryWidget : public DockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -31,6 +33,10 @@ public:
|
||||
explicit MemoryWidget(MainWindow *main);
|
||||
~MemoryWidget();
|
||||
|
||||
void setup() override;
|
||||
|
||||
void refresh() override;
|
||||
|
||||
MainWindow *main;
|
||||
QPlainTextEdit *disasTextEdit;
|
||||
QTextEdit *hexOffsetText;
|
||||
@ -50,6 +56,9 @@ public:
|
||||
Highlighter *preview_highlighter;
|
||||
Highlighter *deco_highlighter;
|
||||
|
||||
signals:
|
||||
void fontChanged(QFont font);
|
||||
|
||||
public slots:
|
||||
void fillPlugins(QStringList plugins);
|
||||
|
||||
@ -103,6 +112,8 @@ private:
|
||||
QString last_graph_fcn;
|
||||
QString last_hexdump_fcn;
|
||||
|
||||
void setScrollMode();
|
||||
|
||||
private slots:
|
||||
void highlightCurrentLine();
|
||||
|
||||
|
@ -3,13 +3,19 @@
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include "mdhighlighter.h"
|
||||
#include "highlighter.h"
|
||||
|
||||
#include <QPlainTextEdit>
|
||||
#include <QFont>
|
||||
#include <QDebug>
|
||||
#include <QFontDialog>
|
||||
#include <QTextCursor>
|
||||
#include <QMenu>
|
||||
|
||||
|
||||
Notepad::Notepad(MainWindow *main, QWidget *parent) :
|
||||
QDockWidget(parent),
|
||||
DockWidget(parent),
|
||||
ui(new Ui::Notepad)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@ -36,14 +42,38 @@ Notepad::Notepad(MainWindow *main, QWidget *parent) :
|
||||
this, SLOT(showNotepadContextMenu(const QPoint &)));
|
||||
}
|
||||
|
||||
void Notepad::setText(QString str)
|
||||
Notepad::~Notepad()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void Notepad::setup()
|
||||
{
|
||||
main->add_output(" > Adding binary information to notepad");
|
||||
|
||||
setText("# Binary information\n\n" + main->core->cmd("i") +
|
||||
"\n" + main->core->cmd("ie") + "\n" + main->core->cmd("iM") + "\n");
|
||||
}
|
||||
|
||||
void Notepad::refresh()
|
||||
{
|
||||
// TODO: implement
|
||||
eprintf("%s - not implemented\n", __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
void Notepad::setText(const QString &str)
|
||||
{
|
||||
ui->notepadTextEdit->setPlainText(str);
|
||||
}
|
||||
|
||||
Notepad::~Notepad()
|
||||
QString Notepad::textToBase64() const
|
||||
{
|
||||
delete ui;
|
||||
return notesTextEdit->toPlainText().toUtf8().toBase64();
|
||||
}
|
||||
|
||||
void Notepad::appendPlainText(const QString &text)
|
||||
{
|
||||
notesTextEdit->appendPlainText(text);
|
||||
}
|
||||
|
||||
void Notepad::on_fontButton_clicked()
|
||||
|
@ -1,29 +1,39 @@
|
||||
#ifndef NOTEPAD_H
|
||||
#define NOTEPAD_H
|
||||
|
||||
#include <QDockWidget>
|
||||
#include <QPlainTextEdit>
|
||||
#include "mdhighlighter.h"
|
||||
#include "highlighter.h"
|
||||
#include "dockwidget.h"
|
||||
|
||||
class MainWindow;
|
||||
class MdHighlighter;
|
||||
class Highlighter;
|
||||
class QPlainTextEdit;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class Notepad;
|
||||
}
|
||||
|
||||
class Notepad : public QDockWidget
|
||||
class Notepad : public DockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Notepad(MainWindow *main, QWidget *parent = 0);
|
||||
void setText(QString str);
|
||||
void highlightPreview();
|
||||
void setFonts(QFont font);
|
||||
~Notepad();
|
||||
QPlainTextEdit *notesTextEdit;
|
||||
|
||||
void setup() override;
|
||||
|
||||
void refresh() override;
|
||||
|
||||
void setText(const QString &str);
|
||||
QString textToBase64() const;
|
||||
|
||||
void appendPlainText(const QString &text);
|
||||
|
||||
void highlightPreview();
|
||||
|
||||
public slots:
|
||||
void setFonts(QFont font);
|
||||
|
||||
private slots:
|
||||
void on_fontButton_clicked();
|
||||
@ -61,12 +71,13 @@ private slots:
|
||||
void on_actionHexdump_function_triggered();
|
||||
|
||||
private:
|
||||
Ui::Notepad *ui;
|
||||
MdHighlighter *highlighter;
|
||||
Highlighter *disasm_highlighter;
|
||||
bool isFirstTime;
|
||||
MainWindow *main;
|
||||
QString addr;
|
||||
Ui::Notepad *ui;
|
||||
MdHighlighter *highlighter;
|
||||
Highlighter *disasm_highlighter;
|
||||
bool isFirstTime;
|
||||
MainWindow *main;
|
||||
QString addr;
|
||||
QPlainTextEdit *notesTextEdit;
|
||||
};
|
||||
|
||||
#endif // NOTEPAD_H
|
||||
|
@ -145,7 +145,7 @@ void Omnibar::on_gotoEntry_returnPressed()
|
||||
}
|
||||
else if (str.contains("Theme"))
|
||||
{
|
||||
this->main->sideBar->themesButtonToggle();
|
||||
this->main->toggleSideBarTheme();
|
||||
}
|
||||
else if (str.contains("Script"))
|
||||
{
|
||||
|
@ -11,27 +11,24 @@ class Omnibar : public QLineEdit
|
||||
public:
|
||||
explicit Omnibar(MainWindow *main, QWidget *parent = 0);
|
||||
|
||||
QStringList commands;
|
||||
QStringList flags;
|
||||
|
||||
void fillFlags(QString flag);
|
||||
void clearFlags();
|
||||
QStringList getFlags();
|
||||
void setupCompleter();
|
||||
|
||||
private:
|
||||
MainWindow *main;
|
||||
|
||||
private slots:
|
||||
void on_gotoEntry_returnPressed();
|
||||
|
||||
void restoreCompleter();
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void showCommands();
|
||||
void clearContents();
|
||||
|
||||
private:
|
||||
MainWindow *main;
|
||||
QStringList commands;
|
||||
QStringList flags;
|
||||
};
|
||||
|
||||
#endif // OMNIBAR_H
|
||||
|
@ -2,16 +2,19 @@
|
||||
#include "ui_relocswidget.h"
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "helpers.h"
|
||||
|
||||
#include <QTreeWidget>
|
||||
|
||||
|
||||
RelocsWidget::RelocsWidget(MainWindow *main, QWidget *parent) :
|
||||
QDockWidget(parent),
|
||||
ui(new Ui::RelocsWidget)
|
||||
DockWidget(parent),
|
||||
ui(new Ui::RelocsWidget),
|
||||
main(main)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// Radare core found in:
|
||||
this->main = main;
|
||||
this->relocsTreeWidget = ui->relocsTreeWidget;
|
||||
ui->relocsTreeWidget->hideColumn(0);
|
||||
}
|
||||
|
||||
RelocsWidget::~RelocsWidget()
|
||||
@ -19,6 +22,18 @@ RelocsWidget::~RelocsWidget()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void RelocsWidget::setup()
|
||||
{
|
||||
setScrollMode();
|
||||
|
||||
fillTreeWidget();
|
||||
}
|
||||
|
||||
void RelocsWidget::refresh()
|
||||
{
|
||||
setup();
|
||||
}
|
||||
|
||||
void RelocsWidget::on_relocsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
|
||||
{
|
||||
QNOTUSED(column);
|
||||
@ -28,5 +43,23 @@ void RelocsWidget::on_relocsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item,
|
||||
QString offset = item->text(1);
|
||||
QString name = item->text(2);
|
||||
main->seek(offset, name);
|
||||
this->main->memoryDock->raise();
|
||||
|
||||
main->raiseMemoryDock();
|
||||
}
|
||||
|
||||
void RelocsWidget::fillTreeWidget()
|
||||
{
|
||||
ui->relocsTreeWidget->clear();
|
||||
for (auto i : main->core->getList("bin", "relocs"))
|
||||
{
|
||||
QStringList pieces = i.split(",");
|
||||
if (pieces.length() == 3)
|
||||
qhelpers::appendRow(ui->relocsTreeWidget, pieces[0], pieces[1], pieces[2]);
|
||||
}
|
||||
qhelpers::adjustColumns(ui->relocsTreeWidget);
|
||||
}
|
||||
|
||||
void RelocsWidget::setScrollMode()
|
||||
{
|
||||
qhelpers::setVerticalScrollMode(ui->relocsTreeWidget);
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
#ifndef RELOCSWIDGET_H
|
||||
#define RELOCSWIDGET_H
|
||||
|
||||
#include <QDockWidget>
|
||||
#include <QTreeWidget>
|
||||
#include "dashboard.h"
|
||||
|
||||
class MainWindow;
|
||||
class QTreeWidgetItem;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class RelocsWidget;
|
||||
}
|
||||
|
||||
class RelocsWidget : public QDockWidget
|
||||
class RelocsWidget : public DockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -19,15 +19,19 @@ public:
|
||||
explicit RelocsWidget(MainWindow *main, QWidget *parent = 0);
|
||||
~RelocsWidget();
|
||||
|
||||
QTreeWidget *relocsTreeWidget;
|
||||
void setup() override;
|
||||
|
||||
void refresh() override;
|
||||
|
||||
private slots:
|
||||
void on_relocsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
|
||||
|
||||
private:
|
||||
Ui::RelocsWidget *ui;
|
||||
|
||||
MainWindow *main;
|
||||
|
||||
void fillTreeWidget();
|
||||
void setScrollMode();
|
||||
};
|
||||
|
||||
#endif // RELOCSWIDGET_H
|
||||
|
@ -2,10 +2,13 @@
|
||||
#include "ui_sdbdock.h"
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QTreeWidget>
|
||||
|
||||
|
||||
SdbDock::SdbDock(MainWindow *main, QWidget *parent) :
|
||||
QDockWidget(parent),
|
||||
DockWidget(parent),
|
||||
ui(new Ui::SdbDock)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@ -95,6 +98,18 @@ SdbDock::~SdbDock()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void SdbDock::setup()
|
||||
{
|
||||
// TODO: implement
|
||||
eprintf("%s - not implemented\n", __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
void SdbDock::refresh()
|
||||
{
|
||||
// TODO: implement
|
||||
eprintf("%s - not implemented\n", __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
void SdbDock::on_lockButton_clicked()
|
||||
{
|
||||
if (ui->lockButton->isChecked())
|
||||
|
@ -1,17 +1,17 @@
|
||||
#ifndef SDBDOCK_H
|
||||
#define SDBDOCK_H
|
||||
|
||||
#include <QDockWidget>
|
||||
#include <QTreeWidget>
|
||||
#include "dockwidget.h"
|
||||
|
||||
class MainWindow;
|
||||
class QTreeWidgetItem;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class SdbDock;
|
||||
}
|
||||
|
||||
class SdbDock : public QDockWidget
|
||||
class SdbDock : public DockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -19,6 +19,10 @@ public:
|
||||
explicit SdbDock(MainWindow *main, QWidget *parent = 0);
|
||||
~SdbDock();
|
||||
|
||||
void setup() override;
|
||||
|
||||
void refresh() override;
|
||||
|
||||
private slots:
|
||||
void on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
|
||||
|
||||
@ -28,10 +32,10 @@ private slots:
|
||||
|
||||
private:
|
||||
Ui::SdbDock *ui;
|
||||
void reload(QString path);
|
||||
QString path;
|
||||
|
||||
MainWindow *main;
|
||||
|
||||
void reload(QString path);
|
||||
};
|
||||
|
||||
#endif // SDBDOCK_H
|
||||
|
@ -4,8 +4,12 @@
|
||||
#include "mainwindow.h"
|
||||
#include "widgets/sectionswidget.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QResizeEvent>
|
||||
|
||||
|
||||
SectionsDock::SectionsDock(MainWindow *main, QWidget *parent) :
|
||||
QDockWidget(parent),
|
||||
DockWidget(parent),
|
||||
ui(new Ui::SectionsDock)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@ -26,6 +30,16 @@ SectionsDock::~SectionsDock()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void SectionsDock::setup()
|
||||
{
|
||||
sectionsWidget->setup();
|
||||
}
|
||||
|
||||
void SectionsDock::refresh()
|
||||
{
|
||||
sectionsWidget->setup();
|
||||
}
|
||||
|
||||
void SectionsDock::showSectionsContextMenu(const QPoint &pt)
|
||||
{
|
||||
// Set functions popup menu
|
||||
|
@ -1,17 +1,17 @@
|
||||
#ifndef SECTIONSDOCK_H
|
||||
#define SECTIONSDOCK_H
|
||||
|
||||
#include <QDockWidget>
|
||||
#include "widgets/sectionswidget.h"
|
||||
#include "dockwidget.h"
|
||||
|
||||
class MainWindow;
|
||||
class SectionsWidget;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class SectionsDock;
|
||||
}
|
||||
|
||||
class SectionsDock : public QDockWidget
|
||||
class SectionsDock : public DockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -19,7 +19,9 @@ public:
|
||||
explicit SectionsDock(MainWindow *main, QWidget *parent = 0);
|
||||
~SectionsDock();
|
||||
|
||||
SectionsWidget *sectionsWidget;
|
||||
void setup() override;
|
||||
|
||||
void refresh() override;
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
@ -34,8 +36,8 @@ private slots:
|
||||
|
||||
private:
|
||||
Ui::SectionsDock *ui;
|
||||
|
||||
MainWindow *main;
|
||||
SectionsWidget *sectionsWidget;
|
||||
};
|
||||
|
||||
#endif // SECTIONSDOCK_H
|
||||
|
@ -1,34 +1,52 @@
|
||||
#include <QtWidgets>
|
||||
#include <QSplitter>
|
||||
|
||||
#include "widgets/pieview.h"
|
||||
#include "widgets/sectionswidget.h"
|
||||
#include "widgets/pieview.h"
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "helpers.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QTreeWidget>
|
||||
|
||||
SectionsWidget::SectionsWidget(MainWindow *main, QWidget *parent) :
|
||||
QSplitter(main)
|
||||
QSplitter(main),
|
||||
main(main)
|
||||
{
|
||||
QNOTUSED(parent);
|
||||
|
||||
this->main = main;
|
||||
//setupModel();
|
||||
setupViews();
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
//setStyleSheet("QSplitter::handle:horizontal { width: 3px; } QSplitter::handle:vertical { height: 3px; }");
|
||||
setStyleSheet("QSplitter::handle { height: 2px; background-color: rgb(255, 255, 255); image: url(:/new/prefix1/img/icons/tabs.png); }");
|
||||
}
|
||||
|
||||
/*
|
||||
void SectionsWidget::setupModel()
|
||||
void SectionsWidget::setup()
|
||||
{
|
||||
model = new QStandardItemModel(0, 4, this);
|
||||
model->setHeaderData(0, Qt::Horizontal, "Name");
|
||||
model->setHeaderData(1, Qt::Horizontal, "Size");
|
||||
model->setHeaderData(2, Qt::Horizontal, "Address");
|
||||
model->setHeaderData(3, Qt::Horizontal, "End Address");
|
||||
tree->clear();
|
||||
|
||||
int row = 0;
|
||||
for (auto i : main->core->getList("bin", "sections"))
|
||||
{
|
||||
QStringList a = i.split(",");
|
||||
if (a.length() > 4)
|
||||
{
|
||||
// Fix to work with ARM bins
|
||||
//if (a[4].startsWith(".")) {
|
||||
if (a[4].contains("."))
|
||||
{
|
||||
QString addr = a[1];
|
||||
QString addr_end = "0x0" + main->core->itoa(main->core->math(addr + "+" + a[2]));
|
||||
QString size = QString::number(main->core->math(a[2]));
|
||||
QString name = a[4];
|
||||
|
||||
fillSections(row++, name, size, addr, addr_end);
|
||||
}
|
||||
}
|
||||
}
|
||||
//adjustColumns(sectionsWidget->tree);
|
||||
//this->sectionsDock->sectionsWidget->adjustColumns();
|
||||
qhelpers::adjustColumns(tree);
|
||||
}
|
||||
*/
|
||||
|
||||
void SectionsWidget::setupViews()
|
||||
{
|
||||
// Table view
|
||||
@ -63,29 +81,28 @@ void SectionsWidget::setupViews()
|
||||
pieChart->setSelectionModel(selectionModel);
|
||||
}
|
||||
|
||||
void SectionsWidget::fillSections(int row, const QString &str, const QString &str2 = NULL,
|
||||
const QString &str3 = NULL, const QString &str4 = NULL)
|
||||
void SectionsWidget::fillSections(int row, const QString &str, const QString &str2,
|
||||
const QString &str3, const QString &str4)
|
||||
{
|
||||
QList<QString> colors;
|
||||
//colors << "#F7464A" << "#46BFBD" << "#FDB45C" << "#949FB1" << "#4D5360" << "#D97041" <<"#C7604C" << "#21323D" << "#9D9B7F" << "#7D4F6D" << "#584A5E";
|
||||
colors << "#1ABC9C"; //TURQUOISE
|
||||
colors << "#2ECC71"; //EMERALD
|
||||
colors << "#3498DB"; //PETER RIVER
|
||||
colors << "#9B59B6"; //AMETHYST
|
||||
colors << "#34495E"; //WET ASPHALT
|
||||
colors << "#F1C40F"; //SUN FLOWER
|
||||
colors << "#E67E22"; //CARROT
|
||||
colors << "#E74C3C"; //ALIZARIN
|
||||
colors << "#ECF0F1"; //CLOUDS
|
||||
colors << "#BDC3C7"; //SILVER
|
||||
colors << "#95A5A6"; //COBCRETE
|
||||
// TODO: create unique colors, e. g. use HSV color space and rotate in H for 360/size
|
||||
static const QList<QColor> colors = { QColor("#1ABC9C"), //TURQUOISE
|
||||
QColor("#2ECC71"), //EMERALD
|
||||
QColor("#3498DB"), //PETER RIVER
|
||||
QColor("#9B59B6"), //AMETHYST
|
||||
QColor("#34495E"), //WET ASPHALT
|
||||
QColor("#F1C40F"), //SUN FLOWER
|
||||
QColor("#E67E22"), //CARROT
|
||||
QColor("#E74C3C"), //ALIZARIN
|
||||
QColor("#ECF0F1"), //CLOUDS
|
||||
QColor("#BDC3C7"), //SILVER
|
||||
QColor("#95A5A6")}; //COBCRETE
|
||||
|
||||
QTreeWidgetItem *tempItem = new QTreeWidgetItem();
|
||||
tempItem->setText(0, str);
|
||||
tempItem->setText(1, str2);
|
||||
tempItem->setText(2, str3);
|
||||
tempItem->setText(3, str4);
|
||||
tempItem->setData(0, Qt::DecorationRole, QColor(colors[row]));
|
||||
tempItem->setData(0, Qt::DecorationRole, colors[row % colors.size()]);
|
||||
this->tree->insertTopLevelItem(0, tempItem);
|
||||
}
|
||||
|
||||
|
@ -1,18 +1,13 @@
|
||||
#ifndef SECTIONSWIDGET_H
|
||||
#define SECTIONSWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QSplitter>
|
||||
#include <QTreeWidget>
|
||||
|
||||
class MainWindow;
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QTreeWidget;
|
||||
class QAbstractItemModel;
|
||||
class QAbstractItemView;
|
||||
class QItemSelectionModel;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
@ -25,19 +20,20 @@ class SectionsWidget : public QSplitter
|
||||
|
||||
public:
|
||||
explicit SectionsWidget(MainWindow *main, QWidget *parent = 0);
|
||||
void fillSections(int row, const QString &str, const QString &str2,
|
||||
const QString &str3, const QString &str4);
|
||||
void adjustColumns();
|
||||
QTreeWidget *tree;
|
||||
|
||||
void setup();
|
||||
|
||||
private:
|
||||
//void setupModel();
|
||||
QAbstractItemView *pieChart;
|
||||
QItemSelectionModel *selectionModel;
|
||||
MainWindow *main;
|
||||
QTreeWidget *tree;
|
||||
|
||||
void setupViews();
|
||||
|
||||
//QAbstractItemModel *model;
|
||||
QAbstractItemView *pieChart;
|
||||
QItemSelectionModel *selectionModel;
|
||||
MainWindow *main;
|
||||
void fillSections(int row, const QString &str, const QString &str2 = QString(),
|
||||
const QString &str3 = QString(), const QString &str4 = QString());
|
||||
void adjustColumns();
|
||||
};
|
||||
|
||||
#endif // SECTIONSWIDGET_H
|
||||
|
@ -1,9 +1,10 @@
|
||||
#include "sidebar.h"
|
||||
#include "ui_sidebar.h"
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
SideBar::SideBar(MainWindow *main) :
|
||||
QWidget(main),
|
||||
|
@ -19,7 +19,6 @@ public:
|
||||
~SideBar();
|
||||
|
||||
public slots:
|
||||
|
||||
void themesButtonToggle();
|
||||
|
||||
private slots:
|
||||
|
@ -1,18 +1,21 @@
|
||||
#include "stringswidget.h"
|
||||
#include "ui_stringswidget.h"
|
||||
|
||||
#include "dialogs/xrefsdialog.h"
|
||||
//#include "dialogs/xrefsdialog.h"
|
||||
#include "mainwindow.h"
|
||||
#include "helpers.h"
|
||||
|
||||
#include <QTreeWidget>
|
||||
|
||||
|
||||
StringsWidget::StringsWidget(MainWindow *main, QWidget *parent) :
|
||||
QDockWidget(parent),
|
||||
ui(new Ui::StringsWidget)
|
||||
DockWidget(parent),
|
||||
ui(new Ui::StringsWidget),
|
||||
main(main)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// Radare core found in:
|
||||
this->main = main;
|
||||
this->stringsTreeWidget = ui->stringsTreeWidget;
|
||||
ui->stringsTreeWidget->hideColumn(0);
|
||||
}
|
||||
|
||||
StringsWidget::~StringsWidget()
|
||||
@ -20,6 +23,18 @@ StringsWidget::~StringsWidget()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void StringsWidget::setup()
|
||||
{
|
||||
setScrollMode();
|
||||
|
||||
fillTreeWidget();
|
||||
}
|
||||
|
||||
void StringsWidget::refresh()
|
||||
{
|
||||
setup();
|
||||
}
|
||||
|
||||
void StringsWidget::on_stringsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
|
||||
{
|
||||
QNOTUSED(column);
|
||||
@ -30,5 +45,22 @@ void StringsWidget::on_stringsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item
|
||||
QString name = item->text(2);
|
||||
this->main->seek(offset);
|
||||
// Rise and shine baby!
|
||||
this->main->memoryDock->raise();
|
||||
this->main->raiseMemoryDock();
|
||||
}
|
||||
|
||||
void StringsWidget::fillTreeWidget()
|
||||
{
|
||||
ui->stringsTreeWidget->clear();
|
||||
for (auto i : main->core->getList("bin", "strings"))
|
||||
{
|
||||
QStringList pieces = i.split(",");
|
||||
if (pieces.length() == 2)
|
||||
qhelpers::appendRow(ui->stringsTreeWidget, pieces[0], pieces[1]);
|
||||
}
|
||||
qhelpers::adjustColumns(ui->stringsTreeWidget);
|
||||
}
|
||||
|
||||
void StringsWidget::setScrollMode()
|
||||
{
|
||||
qhelpers::setVerticalScrollMode(ui->stringsTreeWidget);
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
#ifndef STRINGSWIDGET_H
|
||||
#define STRINGSWIDGET_H
|
||||
|
||||
#include <QDockWidget>
|
||||
#include <QTreeWidget>
|
||||
#include "dockwidget.h"
|
||||
|
||||
class MainWindow;
|
||||
class QTreeWidgetItem;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class StringsWidget;
|
||||
}
|
||||
|
||||
class StringsWidget : public QDockWidget
|
||||
class StringsWidget : public DockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -19,15 +19,19 @@ public:
|
||||
explicit StringsWidget(MainWindow *main, QWidget *parent = 0);
|
||||
~StringsWidget();
|
||||
|
||||
QTreeWidget *stringsTreeWidget;
|
||||
void setup() override;
|
||||
|
||||
void refresh() override;
|
||||
|
||||
private slots:
|
||||
void on_stringsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
|
||||
|
||||
private:
|
||||
Ui::StringsWidget *ui;
|
||||
|
||||
MainWindow *main;
|
||||
|
||||
void fillTreeWidget();
|
||||
void setScrollMode();
|
||||
};
|
||||
|
||||
#endif // STRINGSWIDGET_H
|
||||
|
@ -2,14 +2,19 @@
|
||||
#include "ui_symbolswidget.h"
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "helpers.h"
|
||||
|
||||
#include <QTreeWidget>
|
||||
|
||||
|
||||
SymbolsWidget::SymbolsWidget(MainWindow *main, QWidget *parent) :
|
||||
QDockWidget(parent),
|
||||
ui(new Ui::SymbolsWidget)
|
||||
DockWidget(parent),
|
||||
ui(new Ui::SymbolsWidget),
|
||||
main(main)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->main = main;
|
||||
this->symbolsTreeWidget = ui->symbolsTreeWidget;
|
||||
|
||||
ui->symbolsTreeWidget->hideColumn(0);
|
||||
}
|
||||
|
||||
SymbolsWidget::~SymbolsWidget()
|
||||
@ -17,16 +22,16 @@ SymbolsWidget::~SymbolsWidget()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void SymbolsWidget::fillSymbols()
|
||||
void SymbolsWidget::setup()
|
||||
{
|
||||
this->symbolsTreeWidget->clear();
|
||||
for (auto i : this->main->core->getList("bin", "symbols"))
|
||||
{
|
||||
QStringList pieces = i.split(",");
|
||||
if (pieces.length() == 3)
|
||||
this->main->appendRow(this->symbolsTreeWidget, pieces[0], pieces[1], pieces[2]);
|
||||
}
|
||||
this->main->adjustColumns(this->symbolsTreeWidget);
|
||||
setScrollMode();
|
||||
|
||||
fillSymbols();
|
||||
}
|
||||
|
||||
void SymbolsWidget::refresh()
|
||||
{
|
||||
setup();
|
||||
}
|
||||
|
||||
void SymbolsWidget::on_symbolsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
|
||||
@ -41,3 +46,20 @@ void SymbolsWidget::on_symbolsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item
|
||||
this->main->seek(offset, name);
|
||||
//ui->memDock->setWindowTitle(name);
|
||||
}
|
||||
|
||||
void SymbolsWidget::fillSymbols()
|
||||
{
|
||||
ui->symbolsTreeWidget->clear();
|
||||
for (auto i : this->main->core->getList("bin", "symbols"))
|
||||
{
|
||||
QStringList pieces = i.split(",");
|
||||
if (pieces.length() == 3)
|
||||
qhelpers::appendRow(ui->symbolsTreeWidget, pieces[0], pieces[1], pieces[2]);
|
||||
}
|
||||
qhelpers::adjustColumns(ui->symbolsTreeWidget);
|
||||
}
|
||||
|
||||
void SymbolsWidget::setScrollMode()
|
||||
{
|
||||
qhelpers::setVerticalScrollMode(ui->symbolsTreeWidget);
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
#ifndef SYMBOLSWIDGET_H
|
||||
#define SYMBOLSWIDGET_H
|
||||
|
||||
#include <QDockWidget>
|
||||
#include <QTreeWidget>
|
||||
#include "dockwidget.h"
|
||||
|
||||
class MainWindow;
|
||||
class QTreeWidgetItem;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class SymbolsWidget;
|
||||
}
|
||||
|
||||
class SymbolsWidget : public QDockWidget
|
||||
class SymbolsWidget : public DockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -19,16 +19,19 @@ public:
|
||||
explicit SymbolsWidget(MainWindow *main, QWidget *parent = 0);
|
||||
~SymbolsWidget();
|
||||
|
||||
QTreeWidget *symbolsTreeWidget;
|
||||
void fillSymbols();
|
||||
void setup() override;
|
||||
|
||||
void refresh() override;
|
||||
|
||||
private slots:
|
||||
void on_symbolsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
|
||||
|
||||
private:
|
||||
Ui::SymbolsWidget *ui;
|
||||
|
||||
MainWindow *main;
|
||||
|
||||
void fillSymbols();
|
||||
void setScrollMode();
|
||||
};
|
||||
|
||||
#endif // SYMBOLSWIDGET_H
|
||||
|
Loading…
Reference in New Issue
Block a user