Add GraphOptionsWidget with Block Max Cols

This commit is contained in:
Florian Märkl 2017-12-19 17:13:44 +01:00
parent 46e862a3b8
commit 41430d2826
9 changed files with 146 additions and 4 deletions

View File

@ -551,6 +551,11 @@ void CutterCore::triggerAsmOptionsChanged()
emit asmOptionsChanged();
}
void CutterCore::triggerGraphOptionsChanged()
{
emit graphOptionsChanged();
}
void CutterCore::resetDefaultAsmOptions()
{
// TODO Merge with Configuration.cpp

View File

@ -329,6 +329,7 @@ public:
void triggerRefreshAll();
void triggerAsmOptionsChanged();
void triggerGraphOptionsChanged();
void resetDefaultAsmOptions();
void saveDefaultAsmOptions();
@ -360,6 +361,11 @@ signals:
*/
void asmOptionsChanged();
/*!
* emitted when config regarding graph display changes
*/
void graphOptionsChanged();
/*!
* \brief seekChanged is emitted each time radare2 seek value is modified
* \param offset

View File

@ -83,7 +83,8 @@ SOURCES += \
widgets/VisualNavbar.cpp \
widgets/GraphView.cpp \
dialogs/preferences/PreferencesDialog.cpp \
dialogs/preferences/GeneralOptionsWidget.cpp
dialogs/preferences/GeneralOptionsWidget.cpp \
dialogs/preferences/GraphOptionsWidget.cpp
HEADERS += \
cutter.h \
@ -137,7 +138,8 @@ HEADERS += \
widgets/VisualNavbar.h \
widgets/GraphView.h \
dialogs/preferences/PreferencesDialog.h \
dialogs/preferences/GeneralOptionsWidget.h
dialogs/preferences/GeneralOptionsWidget.h \
dialogs/preferences/GraphOptionsWidget.h
FORMS += \
dialogs/AboutDialog.ui \
@ -168,7 +170,8 @@ FORMS += \
widgets/HexdumpWidget.ui \
dialogs/SaveProjectDialog.ui \
dialogs/preferences/PreferencesDialog.ui \
dialogs/preferences/GeneralOptionsWidget.ui
dialogs/preferences/GeneralOptionsWidget.ui \
dialogs/preferences/GraphOptionsWidget.ui
RESOURCES += \
resources.qrc

View File

@ -52,4 +52,4 @@ private slots:
};
#endif //ASMOPTIONSDIALOG_H
#endif //ASMOPTIONSWIDGET_H

View File

@ -0,0 +1,46 @@
#include <QLabel>
#include <QFontDialog>
#include "GraphOptionsWidget.h"
#include "ui_GraphOptionsWidget.h"
#include "PreferencesDialog.h"
#include "utils/Helpers.h"
#include "utils/Configuration.h"
GraphOptionsWidget::GraphOptionsWidget(PreferencesDialog */*dialog*/, QWidget *parent)
: QDialog(parent),
ui(new Ui::GraphOptionsWidget)
{
ui->setupUi(this);
updateOptionsFromVars();
connect(Core(), SIGNAL(graphOptionsChanged()), this, SLOT(updateOptionsFromVars()));
}
GraphOptionsWidget::~GraphOptionsWidget() {}
void GraphOptionsWidget::updateOptionsFromVars()
{
ui->maxColsSpinBox->blockSignals(true);
ui->maxColsSpinBox->setValue(Config()->getGraphBlockMaxChars());
ui->maxColsSpinBox->blockSignals(false);
}
void GraphOptionsWidget::triggerOptionsChanged()
{
disconnect(Core(), SIGNAL(graphOptionsChanged()), this, SLOT(updateOptionsFromVars()));
Core()->triggerGraphOptionsChanged();
connect(Core(), SIGNAL(graphOptionsChanged()), this, SLOT(updateOptionsFromVars()));
}
void GraphOptionsWidget::on_maxColsSpinBox_valueChanged(int value)
{
Config()->setGraphBlockMaxChars(value);
triggerOptionsChanged();
}

View File

@ -0,0 +1,38 @@
#ifndef GRAPHOPTIONSWIDGET_H
#define GRAPHOPTIONSWIDGET_H
#include <QDialog>
#include <QPushButton>
#include <memory>
#include "cutter.h"
class PreferencesDialog;
namespace Ui
{
class GraphOptionsWidget;
}
class GraphOptionsWidget : public QDialog
{
Q_OBJECT
public:
explicit GraphOptionsWidget(PreferencesDialog *dialog, QWidget *parent = nullptr);
~GraphOptionsWidget();
private:
std::unique_ptr<Ui::GraphOptionsWidget> ui;
void triggerOptionsChanged();
private slots:
void updateOptionsFromVars();
void on_maxColsSpinBox_valueChanged(int value);
};
#endif //GRAPHOPTIONSWIDGET_H

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GraphOptionsWidget</class>
<widget class="QWidget" name="GraphOptionsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Graph</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="maxColsLabel">
<property name="text">
<string>Maximum Line Length:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="maxColsSpinBox">
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>999999999</number>
</property>
<property name="singleStep">
<number>5</number>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -6,6 +6,7 @@
#include "GeneralOptionsWidget.h"
#include "AsmOptionsWidget.h"
#include "GraphOptionsWidget.h"
#include "utils/Helpers.h"
#include "utils/Configuration.h"
@ -20,6 +21,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent)
#define ADD_TAB(c) { auto w = new c(this); ui->tabWidget->addTab(w, w->windowTitle()); }
ADD_TAB(GeneralOptionsWidget)
ADD_TAB(AsmOptionsWidget)
ADD_TAB(GraphOptionsWidget)
#undef ADD_TAB
}

View File

@ -26,6 +26,7 @@ DisassemblerGraphView::DisassemblerGraphView(QWidget *parent)
connect(Core(), SIGNAL(varsChanged()), this, SLOT(refreshView()));
connect(Core(), SIGNAL(instructionChanged(RVA)), this, SLOT(refreshView()));
connect(Core(), SIGNAL(functionsChanged()), this, SLOT(refreshView()));
connect(Core(), SIGNAL(graphOptionsChanged()), this, SLOT(refreshView()));
connect(Config(), SIGNAL(colorsUpdated()), this, SLOT(colorsUpdatedSlot()));
connect(Config(), SIGNAL(fontsUpdated()), this, SLOT(fontsUpdatedSlot()));