mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-19 02:48:49 +00:00
Fixed #129. Refactorized the sections dock
This commit is contained in:
parent
a1a663ca4b
commit
3d85370ff9
@ -61,7 +61,8 @@ SOURCES += \
|
|||||||
widgets/omnibar.cpp \
|
widgets/omnibar.cpp \
|
||||||
widgets/dashboard.cpp \
|
widgets/dashboard.cpp \
|
||||||
dialogs/xrefsdialog.cpp \
|
dialogs/xrefsdialog.cpp \
|
||||||
hexhighlighter.cpp
|
hexhighlighter.cpp \
|
||||||
|
widgets/sectionsdock.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
mainwindow.h \
|
mainwindow.h \
|
||||||
@ -97,7 +98,8 @@ HEADERS += \
|
|||||||
widgets/dashboard.h \
|
widgets/dashboard.h \
|
||||||
dialogs/xrefsdialog.h \
|
dialogs/xrefsdialog.h \
|
||||||
widgets/banned.h \
|
widgets/banned.h \
|
||||||
hexhighlighter.h
|
hexhighlighter.h \
|
||||||
|
widgets/sectionsdock.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
mainwindow.ui \
|
mainwindow.ui \
|
||||||
@ -119,7 +121,8 @@ FORMS += \
|
|||||||
dialogs/commentsdialog.ui \
|
dialogs/commentsdialog.ui \
|
||||||
widgets/sidebar.ui \
|
widgets/sidebar.ui \
|
||||||
widgets/dashboard.ui \
|
widgets/dashboard.ui \
|
||||||
dialogs/xrefsdialog.ui
|
dialogs/xrefsdialog.ui \
|
||||||
|
widgets/sectionsdock.ui
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
resources.qrc
|
resources.qrc
|
||||||
|
@ -139,16 +139,7 @@ MainWindow::MainWindow(QWidget *parent, QRCore *kore) :
|
|||||||
// this->add_debug_output( QString::number(this->dockList.length()) );
|
// this->add_debug_output( QString::number(this->dockList.length()) );
|
||||||
|
|
||||||
// Add Sections dock panel
|
// Add Sections dock panel
|
||||||
this->sectionsWidget = new SectionsWidget(this);
|
this->sectionsDock = new SectionsDock(this);
|
||||||
this->sectionsDock = new QDockWidget("Sections");
|
|
||||||
this->sectionsDock->setObjectName("sectionsDock");
|
|
||||||
this->sectionsDock->setAllowedAreas(Qt::AllDockWidgetAreas);
|
|
||||||
this->sectionsDock->setWidget(this->sectionsWidget);
|
|
||||||
this->sectionsWidget->setContentsMargins(0, 0, 0, 5);
|
|
||||||
this->sectionsDock->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
|
||||||
this->sectionsDock->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
||||||
connect(this->sectionsDock, SIGNAL(customContextMenuRequested(const QPoint &)),
|
|
||||||
this, SLOT(showSectionsContextMenu(const QPoint &)));
|
|
||||||
|
|
||||||
// Add functions DockWidget
|
// Add functions DockWidget
|
||||||
this->functionsDock = new FunctionsWidget(this);
|
this->functionsDock = new FunctionsWidget(this);
|
||||||
@ -579,7 +570,7 @@ void MainWindow::updateFrames()
|
|||||||
// TODO: FIXME: Remove the check for first_time;
|
// TODO: FIXME: Remove the check for first_time;
|
||||||
if (first_time)
|
if (first_time)
|
||||||
{
|
{
|
||||||
sectionsWidget->tree->clear();
|
this->sectionsDock->sectionsWidget->tree->clear();
|
||||||
int row = 0;
|
int row = 0;
|
||||||
for (auto i : core->getList("bin", "sections"))
|
for (auto i : core->getList("bin", "sections"))
|
||||||
{
|
{
|
||||||
@ -594,7 +585,7 @@ void MainWindow::updateFrames()
|
|||||||
QString addr_end = "0x0" + core->itoa(core->math(a[1] + "+" + a[2]));
|
QString addr_end = "0x0" + core->itoa(core->math(a[1] + "+" + a[2]));
|
||||||
QString size = QString::number(core->math(a[2]));
|
QString size = QString::number(core->math(a[2]));
|
||||||
QString name = a[4];
|
QString name = a[4];
|
||||||
this->sectionsWidget->fillSections(row, name, size, addr, addr_end);
|
this->sectionsDock->sectionsWidget->fillSections(row, name, size, addr, addr_end);
|
||||||
|
|
||||||
// Used to select a color for the sections graph
|
// Used to select a color for the sections graph
|
||||||
if (row == 10)
|
if (row == 10)
|
||||||
@ -609,7 +600,7 @@ void MainWindow::updateFrames()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//adjustColumns(sectionsWidget->tree);
|
//adjustColumns(sectionsWidget->tree);
|
||||||
sectionsWidget->adjustColumns();
|
this->sectionsDock->sectionsWidget->adjustColumns();
|
||||||
|
|
||||||
first_time = false;
|
first_time = false;
|
||||||
|
|
||||||
@ -1159,40 +1150,6 @@ void MainWindow::on_actionDashboard_triggered()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::showSectionsContextMenu(const QPoint &pt)
|
|
||||||
{
|
|
||||||
// Set functions popup menu
|
|
||||||
QMenu *menu = new QMenu(this->sectionsDock);
|
|
||||||
menu->clear();
|
|
||||||
menu->addAction(ui->actionSectionsHorizontal);
|
|
||||||
menu->addAction(ui->actionSectionsVertical);
|
|
||||||
|
|
||||||
if (this->sectionsWidget->orientation() == 1)
|
|
||||||
{
|
|
||||||
ui->actionSectionsHorizontal->setChecked(true);
|
|
||||||
ui->actionSectionsVertical->setChecked(false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ui->actionSectionsVertical->setChecked(true);
|
|
||||||
ui->actionSectionsHorizontal->setChecked(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
this->sectionsDock->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
||||||
menu->exec(this->sectionsDock->mapToGlobal(pt));
|
|
||||||
delete menu;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::on_actionSectionsHorizontal_triggered()
|
|
||||||
{
|
|
||||||
this->sectionsWidget->setOrientation(Qt::Horizontal);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::on_actionSectionsVertical_triggered()
|
|
||||||
{
|
|
||||||
this->sectionsWidget->setOrientation(Qt::Vertical);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::on_actionForward_triggered()
|
void MainWindow::on_actionForward_triggered()
|
||||||
{
|
{
|
||||||
this->core->cmd("s+");
|
this->core->cmd("s+");
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "widgets/importswidget.h"
|
#include "widgets/importswidget.h"
|
||||||
#include "widgets/symbolswidget.h"
|
#include "widgets/symbolswidget.h"
|
||||||
#include "widgets/stringswidget.h"
|
#include "widgets/stringswidget.h"
|
||||||
|
#include "widgets/sectionsdock.h"
|
||||||
#include "widgets/relocswidget.h"
|
#include "widgets/relocswidget.h"
|
||||||
#include "widgets/flagswidget.h"
|
#include "widgets/flagswidget.h"
|
||||||
#include "widgets/codegraphic.h"
|
#include "widgets/codegraphic.h"
|
||||||
@ -51,7 +52,6 @@ public:
|
|||||||
QDockWidget *calcDock;
|
QDockWidget *calcDock;
|
||||||
Omnibar *omnibar;
|
Omnibar *omnibar;
|
||||||
MemoryWidget *memoryDock;
|
MemoryWidget *memoryDock;
|
||||||
QDockWidget *sectionsDock;
|
|
||||||
Notepad *notepadDock;
|
Notepad *notepadDock;
|
||||||
SideBar *sideBar;
|
SideBar *sideBar;
|
||||||
|
|
||||||
@ -121,10 +121,6 @@ public slots:
|
|||||||
|
|
||||||
void on_actionRun_Script_triggered();
|
void on_actionRun_Script_triggered();
|
||||||
|
|
||||||
void on_actionSectionsHorizontal_triggered();
|
|
||||||
|
|
||||||
void on_actionSectionsVertical_triggered();
|
|
||||||
|
|
||||||
void toggleResponsive(bool maybe);
|
void toggleResponsive(bool maybe);
|
||||||
|
|
||||||
void on_backButton_clicked();
|
void on_backButton_clicked();
|
||||||
@ -183,8 +179,6 @@ private slots:
|
|||||||
|
|
||||||
void on_actionShow_Hide_mainsidebar_triggered();
|
void on_actionShow_Hide_mainsidebar_triggered();
|
||||||
|
|
||||||
void showSectionsContextMenu(const QPoint &pt);
|
|
||||||
|
|
||||||
void on_actionForward_triggered();
|
void on_actionForward_triggered();
|
||||||
|
|
||||||
void on_actionTabs_on_Top_triggered();
|
void on_actionTabs_on_Top_triggered();
|
||||||
@ -210,7 +204,6 @@ private:
|
|||||||
Highlighter *highlighter_5;
|
Highlighter *highlighter_5;
|
||||||
AsciiHighlighter *hex_highlighter;
|
AsciiHighlighter *hex_highlighter;
|
||||||
GraphicsBar *graphicsBar;
|
GraphicsBar *graphicsBar;
|
||||||
SectionsWidget *sectionsWidget;
|
|
||||||
FunctionsWidget *functionsDock;
|
FunctionsWidget *functionsDock;
|
||||||
ImportsWidget *importsDock;
|
ImportsWidget *importsDock;
|
||||||
SymbolsWidget *symbolsDock;
|
SymbolsWidget *symbolsDock;
|
||||||
@ -222,6 +215,7 @@ private:
|
|||||||
QLineEdit *gotoEntry;
|
QLineEdit *gotoEntry;
|
||||||
SdbDock *sdbDock;
|
SdbDock *sdbDock;
|
||||||
QAction *sidebar_action;
|
QAction *sidebar_action;
|
||||||
|
SectionsDock *sectionsDock;
|
||||||
WebServerThread webserverThread;
|
WebServerThread webserverThread;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -676,7 +676,7 @@ background: rgb(64, 64, 64);</string>
|
|||||||
<string>Sections</string>
|
<string>Sections</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Show/HIde Sections panel</string>
|
<string>Show/Hide Sections panel</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionFunctions">
|
<action name="actionFunctions">
|
||||||
@ -1057,28 +1057,6 @@ background: rgb(64, 64, 64);</string>
|
|||||||
<string>Show/HIde Dashboard panel</string>
|
<string>Show/HIde Dashboard panel</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionSectionsVertical">
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Vertical</string>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Vertical view</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionSectionsHorizontal">
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Horizontal</string>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Horizontal</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionReset_settings">
|
<action name="actionReset_settings">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Reset settings</string>
|
<string>Reset settings</string>
|
||||||
|
79
src/widgets/sectionsdock.cpp
Normal file
79
src/widgets/sectionsdock.cpp
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
#include "sectionsdock.h"
|
||||||
|
#include "ui_sectionsdock.h"
|
||||||
|
|
||||||
|
#include "mainwindow.h"
|
||||||
|
#include "widgets/sectionswidget.h"
|
||||||
|
|
||||||
|
SectionsDock::SectionsDock(MainWindow *main, QWidget *parent) :
|
||||||
|
QDockWidget(parent),
|
||||||
|
ui(new Ui::SectionsDock)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
// Radare core found in:
|
||||||
|
this->main = main;
|
||||||
|
|
||||||
|
this->sectionsWidget = new SectionsWidget(this->main);
|
||||||
|
this->setWidget(this->sectionsWidget);
|
||||||
|
this->sectionsWidget->setContentsMargins(0, 0, 0, 5);
|
||||||
|
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)),
|
||||||
|
this, SLOT(showSectionsContextMenu(const QPoint &)));
|
||||||
|
}
|
||||||
|
|
||||||
|
SectionsDock::~SectionsDock()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SectionsDock::showSectionsContextMenu(const QPoint &pt)
|
||||||
|
{
|
||||||
|
// Set functions popup menu
|
||||||
|
QMenu *menu = new QMenu(this);
|
||||||
|
menu->clear();
|
||||||
|
menu->addAction(ui->actionHorizontal);
|
||||||
|
menu->addAction(ui->actionVertical);
|
||||||
|
|
||||||
|
if (this->sectionsWidget->orientation() == 1)
|
||||||
|
{
|
||||||
|
ui->actionHorizontal->setChecked(true);
|
||||||
|
ui->actionVertical->setChecked(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->actionVertical->setChecked(true);
|
||||||
|
ui->actionHorizontal->setChecked(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
menu->exec(this->mapToGlobal(pt));
|
||||||
|
delete menu;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SectionsDock::resizeEvent(QResizeEvent *event)
|
||||||
|
{
|
||||||
|
if(main->responsive && isVisible())
|
||||||
|
{
|
||||||
|
if (event->size().width() >= event->size().height())
|
||||||
|
{
|
||||||
|
// Set horizontal view (list)
|
||||||
|
this->on_actionHorizontal_triggered();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Set vertical view (Tree)
|
||||||
|
this->on_actionVertical_triggered();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QWidget::resizeEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SectionsDock::on_actionVertical_triggered()
|
||||||
|
{
|
||||||
|
this->sectionsWidget->setOrientation(Qt::Vertical);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SectionsDock::on_actionHorizontal_triggered()
|
||||||
|
{
|
||||||
|
this->sectionsWidget->setOrientation(Qt::Horizontal);
|
||||||
|
}
|
41
src/widgets/sectionsdock.h
Normal file
41
src/widgets/sectionsdock.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#ifndef SECTIONSDOCK_H
|
||||||
|
#define SECTIONSDOCK_H
|
||||||
|
|
||||||
|
#include <QDockWidget>
|
||||||
|
#include "widgets/sectionswidget.h"
|
||||||
|
|
||||||
|
class MainWindow;
|
||||||
|
|
||||||
|
namespace Ui
|
||||||
|
{
|
||||||
|
class SectionsDock;
|
||||||
|
}
|
||||||
|
|
||||||
|
class SectionsDock : public QDockWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit SectionsDock(MainWindow *main, QWidget *parent = 0);
|
||||||
|
~SectionsDock();
|
||||||
|
|
||||||
|
SectionsWidget *sectionsWidget;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
void showSectionsContextMenu(const QPoint &pt);
|
||||||
|
|
||||||
|
void on_actionVertical_triggered();
|
||||||
|
|
||||||
|
void on_actionHorizontal_triggered();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::SectionsDock *ui;
|
||||||
|
|
||||||
|
MainWindow *main;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SECTIONSDOCK_H
|
36
src/widgets/sectionsdock.ui
Normal file
36
src/widgets/sectionsdock.ui
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>SectionsDock</class>
|
||||||
|
<widget class="QDockWidget" name="SectionsDock">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Sections</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="dockWidgetContents"/>
|
||||||
|
<action name="actionVertical">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Vertical</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionHorizontal">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Horizontal</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
@ -33,7 +33,7 @@ void SectionsWidget::setupViews()
|
|||||||
{
|
{
|
||||||
// Table view
|
// Table view
|
||||||
this->tree = new QTreeWidget;
|
this->tree = new QTreeWidget;
|
||||||
this->tree->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
this->tree->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
//this->tree->setFont(QFont("Lucida Grande UI", 12));
|
//this->tree->setFont(QFont("Lucida Grande UI", 12));
|
||||||
//this->tree->setFont(QFont("Courier New", 11));
|
//this->tree->setFont(QFont("Courier New", 11));
|
||||||
this->tree->setIndentation(10);
|
this->tree->setIndentation(10);
|
||||||
@ -50,7 +50,7 @@ void SectionsWidget::setupViews()
|
|||||||
|
|
||||||
pieChart = new PieView;
|
pieChart = new PieView;
|
||||||
pieChart->setFrameShape(QFrame::NoFrame);
|
pieChart->setFrameShape(QFrame::NoFrame);
|
||||||
pieChart->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
pieChart->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
this->addWidget(this->tree);
|
this->addWidget(this->tree);
|
||||||
this->addWidget(pieChart);
|
this->addWidget(pieChart);
|
||||||
this->setStretchFactor(0, 4);
|
this->setStretchFactor(0, 4);
|
||||||
@ -97,21 +97,3 @@ void SectionsWidget::adjustColumns()
|
|||||||
this->tree->resizeColumnToContents(i);
|
this->tree->resizeColumnToContents(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SectionsWidget::resizeEvent(QResizeEvent *event)
|
|
||||||
{
|
|
||||||
if(main->responsive && isVisible())
|
|
||||||
{
|
|
||||||
if (event->size().width() >= event->size().height())
|
|
||||||
{
|
|
||||||
// Set horizontal view (list)
|
|
||||||
main->on_actionSectionsHorizontal_triggered();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Set vertical view (Tree)
|
|
||||||
main->on_actionSectionsVertical_triggered();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QWidget::resizeEvent(event);
|
|
||||||
}
|
|
||||||
|
@ -30,9 +30,6 @@ public:
|
|||||||
void adjustColumns();
|
void adjustColumns();
|
||||||
QTreeWidget *tree;
|
QTreeWidget *tree;
|
||||||
|
|
||||||
protected:
|
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//void setupModel();
|
//void setupModel();
|
||||||
void setupViews();
|
void setupViews();
|
||||||
|
Loading…
Reference in New Issue
Block a user