mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-21 04:16:12 +00:00
Updated Configuration model + Added Font selection
This commit is contained in:
parent
9860e1d6bf
commit
e54b0ee106
@ -2,7 +2,6 @@
|
|||||||
#include "cutter.h"
|
#include "cutter.h"
|
||||||
#include "AnalThread.h"
|
#include "AnalThread.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "Settings.h"
|
|
||||||
#include "dialogs/OptionsDialog.h"
|
#include "dialogs/OptionsDialog.h"
|
||||||
|
|
||||||
AnalThread::AnalThread(OptionsDialog *parent) :
|
AnalThread::AnalThread(OptionsDialog *parent) :
|
||||||
|
@ -58,7 +58,6 @@
|
|||||||
#include "widgets/SdbDock.h"
|
#include "widgets/SdbDock.h"
|
||||||
#include "widgets/Omnibar.h"
|
#include "widgets/Omnibar.h"
|
||||||
#include "widgets/ConsoleWidget.h"
|
#include "widgets/ConsoleWidget.h"
|
||||||
#include "Settings.h"
|
|
||||||
#include "dialogs/OptionsDialog.h"
|
#include "dialogs/OptionsDialog.h"
|
||||||
#include "widgets/EntrypointWidget.h"
|
#include "widgets/EntrypointWidget.h"
|
||||||
#include "widgets/DisassemblerGraphView.h"
|
#include "widgets/DisassemblerGraphView.h"
|
||||||
@ -113,6 +112,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
webserver(core)
|
webserver(core)
|
||||||
{
|
{
|
||||||
doLock = false;
|
doLock = false;
|
||||||
|
configuration = new Configuration();
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "widgets/SidebarWidget.h"
|
#include "widgets/SidebarWidget.h"
|
||||||
#include "widgets/HexdumpWidget.h"
|
#include "widgets/HexdumpWidget.h"
|
||||||
#include "cutter.h" // only needed for ut64
|
#include "cutter.h" // only needed for ut64
|
||||||
|
#include "utils/Configuration.h"
|
||||||
|
|
||||||
class CutterCore;
|
class CutterCore;
|
||||||
class DockWidget;
|
class DockWidget;
|
||||||
@ -180,6 +181,7 @@ private:
|
|||||||
SideBar *sideBar;
|
SideBar *sideBar;
|
||||||
PreviewWidget *previewDock;
|
PreviewWidget *previewDock;
|
||||||
Notepad *notepadDock;
|
Notepad *notepadDock;
|
||||||
|
Configuration *configuration;
|
||||||
|
|
||||||
bool doLock;
|
bool doLock;
|
||||||
void refreshMem();
|
void refreshMem();
|
||||||
|
@ -1,56 +0,0 @@
|
|||||||
|
|
||||||
#ifndef SETTINGS_H
|
|
||||||
#define SETTINGS_H
|
|
||||||
|
|
||||||
#include <QSettings>
|
|
||||||
|
|
||||||
class Settings
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
QSettings settings;
|
|
||||||
|
|
||||||
public:
|
|
||||||
bool getAsmESIL() const { return settings.value("asm.esil", false).toBool(); }
|
|
||||||
void setAsmESIL(bool v) { settings.setValue("asm.esil", v); }
|
|
||||||
|
|
||||||
bool getAsmPseudo() const { return settings.value("asm.pseudo", false).toBool(); }
|
|
||||||
void setAsmPseudo(bool v) { settings.setValue("asm.pseudo", v); }
|
|
||||||
|
|
||||||
bool getAsmOffset() const { return settings.value("asm.offset", true).toBool(); }
|
|
||||||
void setAsmOffset(bool v) { settings.setValue("asm.offset", v); }
|
|
||||||
|
|
||||||
bool getAsmDescribe() const { return settings.value("asm.describe", false).toBool(); }
|
|
||||||
void setAsmDescribe(bool v) { settings.setValue("asm.describe", v); }
|
|
||||||
|
|
||||||
bool getAsmStackPointer() const { return settings.value("asm.stackptr", false).toBool(); }
|
|
||||||
void setAsmStackPointer(bool v) { settings.setValue("asm.stackptr", v); }
|
|
||||||
|
|
||||||
bool getAsmBytes() const { return settings.value("asm.bytes", false).toBool(); }
|
|
||||||
void setAsmBytes(bool v) { settings.setValue("asm.bytes", v); }
|
|
||||||
|
|
||||||
bool getAsmBytespace() const { return settings.value("asm.bytespace", false).toBool(); }
|
|
||||||
void setAsmBytespace(bool v) { settings.setValue("asm.bytespace", v); }
|
|
||||||
|
|
||||||
bool getAsmLBytes() const { return settings.value("asm.lbytes", true).toBool(); }
|
|
||||||
void setAsmLBytes(bool v) { settings.setValue("asm.lbytes", v); }
|
|
||||||
|
|
||||||
QString getAsmSyntax() const { return settings.value("asm.syntax", "intel").toString(); }
|
|
||||||
void setAsmSyntax(const QString &v) { settings.setValue("asm.syntax", v); }
|
|
||||||
|
|
||||||
bool getAsmUppercase() const { return settings.value("asm.ucase", false).toBool(); }
|
|
||||||
void setAsmUppercase(bool v) { settings.setValue("asm.ucase", v); }
|
|
||||||
|
|
||||||
bool getAsmBBLine() const { return settings.value("asm.bbline", false).toBool(); }
|
|
||||||
void setAsmBBLine(bool v) { settings.setValue("asm.bbline", v); }
|
|
||||||
|
|
||||||
bool getAsmCapitalize() const { return settings.value("asm.capitalize", false).toBool(); }
|
|
||||||
void setAsmCapitalize(bool v) { settings.setValue("asm.capitalize", v); }
|
|
||||||
|
|
||||||
bool getAsmVarsub() const { return settings.value("asm.varsub", true).toBool(); }
|
|
||||||
void setAsmVarsub(bool v) { settings.setValue("asm.varsub", v); }
|
|
||||||
|
|
||||||
bool getAsmVarsubOnly() const { return settings.value("asm.varsub_only", true).toBool(); }
|
|
||||||
void setAsmVarsubOnly(bool v) { settings.setValue("asm.varsub_only", v); }
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SETTINGS_H
|
|
@ -1,8 +1,8 @@
|
|||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
#include "utils/Configuration.h"
|
||||||
#include "cutter.h"
|
#include "cutter.h"
|
||||||
#include "sdb.h"
|
#include "sdb.h"
|
||||||
#include "Settings.h"
|
|
||||||
|
|
||||||
Q_GLOBAL_STATIC(ccClass, uniqueInstance)
|
Q_GLOBAL_STATIC(ccClass, uniqueInstance)
|
||||||
|
|
||||||
@ -513,40 +513,38 @@ void CutterCore::triggerAsmOptionsChanged()
|
|||||||
|
|
||||||
void CutterCore::resetDefaultAsmOptions()
|
void CutterCore::resetDefaultAsmOptions()
|
||||||
{
|
{
|
||||||
Settings settings;
|
setConfig("asm.esil", Config()->getAsmESIL());
|
||||||
setConfig("asm.esil", settings.getAsmESIL());
|
setConfig("asm.pseudo", Config()->getAsmPseudo());
|
||||||
setConfig("asm.pseudo", settings.getAsmPseudo());
|
setConfig("asm.offset", Config()->getAsmOffset());
|
||||||
setConfig("asm.offset", settings.getAsmOffset());
|
setConfig("asm.describe", Config()->getAsmDescribe());
|
||||||
setConfig("asm.describe", settings.getAsmDescribe());
|
setConfig("asm.stackptr", Config()->getAsmStackPointer());
|
||||||
setConfig("asm.stackptr", settings.getAsmStackPointer());
|
setConfig("asm.bytes", Config()->getAsmBytes());
|
||||||
setConfig("asm.bytes", settings.getAsmBytes());
|
setConfig("asm.bytespace", Config()->getAsmBytespace());
|
||||||
setConfig("asm.bytespace", settings.getAsmBytespace());
|
setConfig("asm.lbytes", Config()->getAsmLBytes());
|
||||||
setConfig("asm.lbytes", settings.getAsmLBytes());
|
setConfig("asm.syntax", Config()->getAsmSyntax());
|
||||||
setConfig("asm.syntax", settings.getAsmSyntax());
|
setConfig("asm.ucase", Config()->getAsmUppercase());
|
||||||
setConfig("asm.ucase", settings.getAsmUppercase());
|
setConfig("asm.bbline", Config()->getAsmBBLine());
|
||||||
setConfig("asm.bbline", settings.getAsmBBLine());
|
setConfig("asm.capitalize", Config()->getAsmCapitalize());
|
||||||
setConfig("asm.capitalize", settings.getAsmCapitalize());
|
setConfig("asm.varsub", Config()->getAsmVarsub());
|
||||||
setConfig("asm.varsub", settings.getAsmVarsub());
|
setConfig("asm.varsub_only", Config()->getAsmVarsubOnly());
|
||||||
setConfig("asm.varsub_only", settings.getAsmVarsubOnly());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CutterCore::saveDefaultAsmOptions()
|
void CutterCore::saveDefaultAsmOptions()
|
||||||
{
|
{
|
||||||
Settings settings;
|
Config()->setAsmESIL(getConfigb("asm.esil"));
|
||||||
settings.setAsmESIL(getConfigb("asm.esil"));
|
Config()->setAsmPseudo(getConfigb("asm.pseudo"));
|
||||||
settings.setAsmPseudo(getConfigb("asm.pseudo"));
|
Config()->setAsmOffset(getConfigb("asm.offset"));
|
||||||
settings.setAsmOffset(getConfigb("asm.offset"));
|
Config()->setAsmDescribe(getConfigb("asm.describe"));
|
||||||
settings.setAsmDescribe(getConfigb("asm.describe"));
|
Config()->setAsmStackPointer(getConfigb("asm.stackptr"));
|
||||||
settings.setAsmStackPointer(getConfigb("asm.stackptr"));
|
Config()->setAsmBytes(getConfigb("asm.bytes"));
|
||||||
settings.setAsmBytes(getConfigb("asm.bytes"));
|
Config()->setAsmBytespace(getConfigb("asm.bytespace"));
|
||||||
settings.setAsmBytespace(getConfigb("asm.bytespace"));
|
Config()->setAsmLBytes(getConfigb("asm.lbytes"));
|
||||||
settings.setAsmLBytes(getConfigb("asm.lbytes"));
|
Config()->setAsmSyntax(getConfig("asm.syntax"));
|
||||||
settings.setAsmSyntax(getConfig("asm.syntax"));
|
Config()->setAsmUppercase(getConfigb("asm.ucase"));
|
||||||
settings.setAsmUppercase(getConfigb("asm.ucase"));
|
Config()->setAsmBBLine(getConfigb("asm.bbline"));
|
||||||
settings.setAsmBBLine(getConfigb("asm.bbline"));
|
Config()->setAsmCapitalize(getConfigb("asm.capitalize"));
|
||||||
settings.setAsmCapitalize(getConfigb("asm.capitalize"));
|
Config()->setAsmVarsub(getConfigb("asm.varsub"));
|
||||||
settings.setAsmVarsub(getConfigb("asm.varsub"));
|
Config()->setAsmVarsubOnly(getConfigb("asm.varsub_only"));
|
||||||
settings.setAsmVarsubOnly(getConfigb("asm.varsub_only"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CutterCore::getConfig(const QString &k)
|
QString CutterCore::getConfig(const QString &k)
|
||||||
|
@ -32,6 +32,8 @@
|
|||||||
|
|
||||||
#define APPNAME "Cutter"
|
#define APPNAME "Cutter"
|
||||||
|
|
||||||
|
#define Core() (CutterCore::getInstance())
|
||||||
|
|
||||||
typedef ut64 RVA;
|
typedef ut64 RVA;
|
||||||
#define RVA_INVALID UT64_MAX
|
#define RVA_INVALID UT64_MAX
|
||||||
|
|
||||||
|
@ -76,7 +76,8 @@ SOURCES += \
|
|||||||
menus/DisassemblyContextMenu.cpp \
|
menus/DisassemblyContextMenu.cpp \
|
||||||
widgets/DisassemblyWidget.cpp \
|
widgets/DisassemblyWidget.cpp \
|
||||||
widgets/SidebarWidget.cpp \
|
widgets/SidebarWidget.cpp \
|
||||||
widgets/HexdumpWidget.cpp
|
widgets/HexdumpWidget.cpp \
|
||||||
|
utils/Configuration.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
cutter.h \
|
cutter.h \
|
||||||
@ -96,7 +97,6 @@ HEADERS += \
|
|||||||
MainWindow.h \
|
MainWindow.h \
|
||||||
utils/Highlighter.h \
|
utils/Highlighter.h \
|
||||||
utils/MdHighlighter.h \
|
utils/MdHighlighter.h \
|
||||||
Settings.h \
|
|
||||||
dialogs/OptionsDialog.h \
|
dialogs/OptionsDialog.h \
|
||||||
dialogs/CreateNewDialog.h \
|
dialogs/CreateNewDialog.h \
|
||||||
dialogs/NewFileDialog.h \
|
dialogs/NewFileDialog.h \
|
||||||
@ -125,7 +125,8 @@ HEADERS += \
|
|||||||
menus/DisassemblyContextMenu.h \
|
menus/DisassemblyContextMenu.h \
|
||||||
widgets/DisassemblyWidget.h \
|
widgets/DisassemblyWidget.h \
|
||||||
widgets/SidebarWidget.h \
|
widgets/SidebarWidget.h \
|
||||||
widgets/HexdumpWidget.h
|
widgets/HexdumpWidget.h \
|
||||||
|
utils/Configuration.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
widgets/PreviewWidget.ui \
|
widgets/PreviewWidget.ui \
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
|
#include <QLabel>
|
||||||
|
#include <QFontDialog>
|
||||||
|
|
||||||
#include "Settings.h"
|
|
||||||
#include "AsmOptionsDialog.h"
|
#include "AsmOptionsDialog.h"
|
||||||
#include "ui_AsmOptionsDialog.h"
|
#include "ui_AsmOptionsDialog.h"
|
||||||
|
|
||||||
#include "utils/Helpers.h"
|
#include "utils/Helpers.h"
|
||||||
|
#include "utils/Configuration.h"
|
||||||
|
|
||||||
AsmOptionsDialog::AsmOptionsDialog(QWidget *parent)
|
AsmOptionsDialog::AsmOptionsDialog(QWidget *parent)
|
||||||
: QDialog(parent),
|
: QDialog(parent),
|
||||||
@ -19,6 +21,9 @@ AsmOptionsDialog::AsmOptionsDialog(QWidget *parent)
|
|||||||
ui->syntaxComboBox->addItem(syntax, syntax);
|
ui->syntaxComboBox->addItem(syntax, syntax);
|
||||||
ui->syntaxComboBox->blockSignals(false);
|
ui->syntaxComboBox->blockSignals(false);
|
||||||
|
|
||||||
|
QFont currentFont = Config()->getFont();
|
||||||
|
ui->fontSelectionLabel->setText(currentFont.toString());
|
||||||
|
|
||||||
updateFromVars();
|
updateFromVars();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,3 +214,14 @@ void AsmOptionsDialog::on_buttonBox_clicked(QAbstractButton *button)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AsmOptionsDialog::on_fontSelectionButton_clicked()
|
||||||
|
{
|
||||||
|
QFont currentFont = Config()->getFont();
|
||||||
|
bool ok;
|
||||||
|
QFont newFont = QFontDialog::getFont(&ok, currentFont, this);
|
||||||
|
if (ok) {
|
||||||
|
Config()->setFont(newFont);
|
||||||
|
ui->fontSelectionLabel->setText(newFont.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -44,6 +44,7 @@ private slots:
|
|||||||
void on_varsubCheckBox_toggled(bool checked);
|
void on_varsubCheckBox_toggled(bool checked);
|
||||||
void on_varsubOnlyCheckBox_toggled(bool checked);
|
void on_varsubOnlyCheckBox_toggled(bool checked);
|
||||||
void on_buttonBox_clicked(QAbstractButton *button);
|
void on_buttonBox_clicked(QAbstractButton *button);
|
||||||
|
void on_fontSelectionButton_clicked();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>445</width>
|
<width>476</width>
|
||||||
<height>631</height>
|
<height>631</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -17,6 +17,24 @@
|
|||||||
<property name="sizeConstraint">
|
<property name="sizeConstraint">
|
||||||
<enum>QLayout::SetMinAndMaxSize</enum>
|
<enum>QLayout::SetMinAndMaxSize</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="fontSelectionLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="fontSelectionLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true"/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="fontSelectionButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Select font</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="esilCheckBox">
|
<widget class="QCheckBox" name="esilCheckBox">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
// TODO: remove us
|
// TODO: remove us
|
||||||
#include "widgets/PreviewWidget.h"
|
#include "widgets/PreviewWidget.h"
|
||||||
#include "widgets/Notepad.h"
|
#include "widgets/Notepad.h"
|
||||||
#include "Settings.h"
|
|
||||||
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
25
src/utils/Configuration.cpp
Normal file
25
src/utils/Configuration.cpp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#include "Configuration.h"
|
||||||
|
|
||||||
|
Configuration* Configuration::mPtr = nullptr;
|
||||||
|
|
||||||
|
Configuration::Configuration() : QObject()
|
||||||
|
{
|
||||||
|
mPtr = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Configuration* Configuration::instance()
|
||||||
|
{
|
||||||
|
return mPtr;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QFont Configuration::getFont() const
|
||||||
|
{
|
||||||
|
QFont font = s.value("font", QFont("Monospace", 12)).value<QFont>();
|
||||||
|
return font;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Configuration::setFont(const QFont &font)
|
||||||
|
{
|
||||||
|
s.setValue("font", font);
|
||||||
|
emit fontsUpdated();
|
||||||
|
}
|
72
src/utils/Configuration.h
Normal file
72
src/utils/Configuration.h
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
#ifndef CONFIGURATION_H
|
||||||
|
#define CONFIGURATION_H
|
||||||
|
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QFont>
|
||||||
|
|
||||||
|
#define Config() (Configuration::instance())
|
||||||
|
|
||||||
|
class Configuration : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
private:
|
||||||
|
QSettings s;
|
||||||
|
static Configuration* mPtr;
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Functions
|
||||||
|
Configuration();
|
||||||
|
static Configuration* instance();
|
||||||
|
|
||||||
|
// Fonts
|
||||||
|
const QFont getFont() const;
|
||||||
|
void setFont(const QFont &font);
|
||||||
|
|
||||||
|
// TODO Imho it's wrong doing it this way. Should find something else.
|
||||||
|
bool getAsmESIL() const { return s.value("asm.esil", false).toBool(); }
|
||||||
|
void setAsmESIL(bool v) { s.setValue("asm.esil", v); }
|
||||||
|
|
||||||
|
bool getAsmPseudo() const { return s.value("asm.pseudo", false).toBool(); }
|
||||||
|
void setAsmPseudo(bool v) { s.setValue("asm.pseudo", v); }
|
||||||
|
|
||||||
|
bool getAsmOffset() const { return s.value("asm.offset", true).toBool(); }
|
||||||
|
void setAsmOffset(bool v) { s.setValue("asm.offset", v); }
|
||||||
|
|
||||||
|
bool getAsmDescribe() const { return s.value("asm.describe", false).toBool(); }
|
||||||
|
void setAsmDescribe(bool v) { s.setValue("asm.describe", v); }
|
||||||
|
|
||||||
|
bool getAsmStackPointer() const { return s.value("asm.stackptr", false).toBool(); }
|
||||||
|
void setAsmStackPointer(bool v) { s.setValue("asm.stackptr", v); }
|
||||||
|
|
||||||
|
bool getAsmBytes() const { return s.value("asm.bytes", false).toBool(); }
|
||||||
|
void setAsmBytes(bool v) { s.setValue("asm.bytes", v); }
|
||||||
|
|
||||||
|
bool getAsmBytespace() const { return s.value("asm.bytespace", false).toBool(); }
|
||||||
|
void setAsmBytespace(bool v) { s.setValue("asm.bytespace", v); }
|
||||||
|
|
||||||
|
bool getAsmLBytes() const { return s.value("asm.lbytes", true).toBool(); }
|
||||||
|
void setAsmLBytes(bool v) { s.setValue("asm.lbytes", v); }
|
||||||
|
|
||||||
|
QString getAsmSyntax() const { return s.value("asm.syntax", "intel").toString(); }
|
||||||
|
void setAsmSyntax(const QString &v) { s.setValue("asm.syntax", v); }
|
||||||
|
|
||||||
|
bool getAsmUppercase() const { return s.value("asm.ucase", false).toBool(); }
|
||||||
|
void setAsmUppercase(bool v) { s.setValue("asm.ucase", v); }
|
||||||
|
|
||||||
|
bool getAsmBBLine() const { return s.value("asm.bbline", false).toBool(); }
|
||||||
|
void setAsmBBLine(bool v) { s.setValue("asm.bbline", v); }
|
||||||
|
|
||||||
|
bool getAsmCapitalize() const { return s.value("asm.capitalize", false).toBool(); }
|
||||||
|
void setAsmCapitalize(bool v) { s.setValue("asm.capitalize", v); }
|
||||||
|
|
||||||
|
bool getAsmVarsub() const { return s.value("asm.varsub", true).toBool(); }
|
||||||
|
void setAsmVarsub(bool v) { s.setValue("asm.varsub", v); }
|
||||||
|
|
||||||
|
bool getAsmVarsubOnly() const { return s.value("asm.varsub_only", true).toBool(); }
|
||||||
|
void setAsmVarsubOnly(bool v) { s.setValue("asm.varsub_only", v); }
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void fontsUpdated();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CONFIGURATION_H
|
@ -9,6 +9,7 @@
|
|||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include "utils/Configuration.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#undef min
|
#undef min
|
||||||
@ -74,7 +75,7 @@ DisassemblerGraphView::DisassemblerGraphView(QWidget *parent)
|
|||||||
setupContextMenu();
|
setupContextMenu();
|
||||||
|
|
||||||
//Connect to bridge
|
//Connect to bridge
|
||||||
connect(CutterCore::getInstance(), SIGNAL(seekChanged(RVA)), this, SLOT(on_seekChanged(RVA)));
|
connect(Core(), SIGNAL(seekChanged(RVA)), this, SLOT(on_seekChanged(RVA)));
|
||||||
//connect(Bridge::getBridge(), SIGNAL(loadGraph(BridgeCFGraphList*, duint)), this, SLOT(loadGraphSlot(BridgeCFGraphList*, duint)));
|
//connect(Bridge::getBridge(), SIGNAL(loadGraph(BridgeCFGraphList*, duint)), this, SLOT(loadGraphSlot(BridgeCFGraphList*, duint)));
|
||||||
//connect(Bridge::getBridge(), SIGNAL(graphAt(duint)), this, SLOT(graphAtSlot(duint)));
|
//connect(Bridge::getBridge(), SIGNAL(graphAt(duint)), this, SLOT(graphAtSlot(duint)));
|
||||||
//connect(Bridge::getBridge(), SIGNAL(updateGraph()), this, SLOT(updateGraphSlot()));
|
//connect(Bridge::getBridge(), SIGNAL(updateGraph()), this, SLOT(updateGraphSlot()));
|
||||||
@ -84,7 +85,7 @@ DisassemblerGraphView::DisassemblerGraphView(QWidget *parent)
|
|||||||
|
|
||||||
//Connect to config
|
//Connect to config
|
||||||
//connect(Config(), SIGNAL(colorsUpdated()), this, SLOT(colorsUpdatedSlot()));
|
//connect(Config(), SIGNAL(colorsUpdated()), this, SLOT(colorsUpdatedSlot()));
|
||||||
//connect(Config(), SIGNAL(fontsUpdated()), this, SLOT(fontsUpdatedSlot()));
|
connect(Config(), SIGNAL(fontsUpdated()), this, SLOT(fontsUpdatedSlot()));
|
||||||
//connect(Config(), SIGNAL(shortcutsUpdated()), this, SLOT(shortcutsUpdatedSlot()));
|
//connect(Config(), SIGNAL(shortcutsUpdated()), this, SLOT(shortcutsUpdatedSlot()));
|
||||||
//connect(Config(), SIGNAL(tokenizerConfigUpdated()), this, SLOT(tokenizerConfigUpdatedSlot()));
|
//connect(Config(), SIGNAL(tokenizerConfigUpdated()), this, SLOT(tokenizerConfigUpdatedSlot()));
|
||||||
|
|
||||||
@ -98,7 +99,7 @@ DisassemblerGraphView::~DisassemblerGraphView()
|
|||||||
|
|
||||||
void DisassemblerGraphView::initFont()
|
void DisassemblerGraphView::initFont()
|
||||||
{
|
{
|
||||||
setFont(QFont("Monospace", 10));
|
setFont(Config()->getFont());
|
||||||
QFontMetricsF metrics(this->font());
|
QFontMetricsF metrics(this->font());
|
||||||
this->baseline = int(metrics.ascent());
|
this->baseline = int(metrics.ascent());
|
||||||
this->charWidth = metrics.width('X');
|
this->charWidth = metrics.width('X');
|
||||||
@ -734,9 +735,9 @@ void DisassemblerGraphView::mouseDoubleClickEvent(QMouseEvent* event)
|
|||||||
{
|
{
|
||||||
duint instr = this->getInstrForMouseEvent(event);
|
duint instr = this->getInstrForMouseEvent(event);
|
||||||
//DbgCmdExec(QString("graph dis.branchdest(%1), silent").arg(ToPtrString(instr)).toUtf8().constData());
|
//DbgCmdExec(QString("graph dis.branchdest(%1), silent").arg(ToPtrString(instr)).toUtf8().constData());
|
||||||
QList<XrefDescription> refs = CutterCore::getInstance()->getXRefs(instr, false, false);
|
QList<XrefDescription> refs = Core()->getXRefs(instr, false, false);
|
||||||
if (refs.length()) {
|
if (refs.length()) {
|
||||||
CutterCore::getInstance()->seek(refs.at(0).to);
|
Core()->seek(refs.at(0).to);
|
||||||
}
|
}
|
||||||
if (refs.length() > 1) {
|
if (refs.length() > 1) {
|
||||||
qWarning() << "Too many references here. Weird behaviour expected.";
|
qWarning() << "Too many references here. Weird behaviour expected.";
|
||||||
@ -1547,7 +1548,7 @@ void DisassemblerGraphView::tokenizerConfigUpdatedSlot()
|
|||||||
void DisassemblerGraphView::loadCurrentGraph()
|
void DisassemblerGraphView::loadCurrentGraph()
|
||||||
{
|
{
|
||||||
// Read functions
|
// Read functions
|
||||||
QJsonDocument functionsDoc = CutterCore::getInstance()->cmdj("agj");
|
QJsonDocument functionsDoc = Core()->cmdj("agj");
|
||||||
QJsonArray functions = functionsDoc.array();
|
QJsonArray functions = functionsDoc.array();
|
||||||
|
|
||||||
Analysis anal;
|
Analysis anal;
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "utils/HexHighlighter.h"
|
#include "utils/HexHighlighter.h"
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
|
#include "utils/Configuration.h"
|
||||||
|
|
||||||
DisassemblyWidget::DisassemblyWidget(QWidget *parent) :
|
DisassemblyWidget::DisassemblyWidget(QWidget *parent) :
|
||||||
QDockWidget(parent),
|
QDockWidget(parent),
|
||||||
@ -15,8 +16,7 @@ DisassemblyWidget::DisassemblyWidget(QWidget *parent) :
|
|||||||
setAllowedAreas(Qt::AllDockWidgetAreas);
|
setAllowedAreas(Qt::AllDockWidgetAreas);
|
||||||
setObjectName("DisassemblyWidget");
|
setObjectName("DisassemblyWidget");
|
||||||
|
|
||||||
// TODO Use Settings
|
mDisasTextEdit->setFont(Config()->getFont());
|
||||||
mDisasTextEdit->setFont(QFont("Monospace", 10));
|
|
||||||
|
|
||||||
// Increase asm text edit margin
|
// Increase asm text edit margin
|
||||||
QTextDocument *asm_docu = mDisasTextEdit->document();
|
QTextDocument *asm_docu = mDisasTextEdit->document();
|
||||||
@ -66,6 +66,7 @@ DisassemblyWidget::DisassemblyWidget(QWidget *parent) :
|
|||||||
|
|
||||||
// Seek signal
|
// Seek signal
|
||||||
connect(CutterCore::getInstance(), SIGNAL(seekChanged(RVA)), this, SLOT(on_seekChanged(RVA)));
|
connect(CutterCore::getInstance(), SIGNAL(seekChanged(RVA)), this, SLOT(on_seekChanged(RVA)));
|
||||||
|
connect(Config(), SIGNAL(fontsUpdated()), this, SLOT(fontsUpdatedSlot()));
|
||||||
}
|
}
|
||||||
|
|
||||||
DisassemblyWidget::DisassemblyWidget(const QString &title, QWidget *parent) :
|
DisassemblyWidget::DisassemblyWidget(const QString &title, QWidget *parent) :
|
||||||
@ -407,3 +408,9 @@ void DisassemblyWidget::highlightDisasms()
|
|||||||
//Highlighter *preview_highlighter = new Highlighter(mDisasTextEdit->document());
|
//Highlighter *preview_highlighter = new Highlighter(mDisasTextEdit->document());
|
||||||
//Highlighter *deco_highlighter = new Highlighter(mDisasTextEdit->document());
|
//Highlighter *deco_highlighter = new Highlighter(mDisasTextEdit->document());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DisassemblyWidget::fontsUpdatedSlot()
|
||||||
|
{
|
||||||
|
mDisasTextEdit->setFont(Config()->getFont());
|
||||||
|
refreshDisasm();
|
||||||
|
}
|
||||||
|
@ -22,6 +22,7 @@ public slots:
|
|||||||
void on_mDisasTextEdit_cursorPositionChanged();
|
void on_mDisasTextEdit_cursorPositionChanged();
|
||||||
void on_seekChanged(RVA offset);
|
void on_seekChanged(RVA offset);
|
||||||
void refreshDisasm();
|
void refreshDisasm();
|
||||||
|
void fontsUpdatedSlot();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTextEdit *mDisasTextEdit;
|
QTextEdit *mDisasTextEdit;
|
||||||
|
Loading…
Reference in New Issue
Block a user