Skip to content

Commit fa5fb90

Browse files
committed
Added MINIMAL compiler option
1 parent fd2c90c commit fa5fb90

File tree

5 files changed

+20
-13
lines changed

5 files changed

+20
-13
lines changed

fhex.pro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ SOURCES += \
3131
src/chunks.cpp \
3232
src/commands.cpp \
3333
src/core/patternmatching.cpp \
34-
src/main.cpp \
35-
src/fhex.cpp \
34+
src/main.cpp \
35+
src/fhex.cpp \
3636
src/core/hexeditor.cpp \
3737
src/qhexedit.cpp
3838

@@ -42,7 +42,7 @@ HEADERS += \
4242
src/commands.h \
4343
src/core/json.h \
4444
src/core/patternmatching.h \
45-
src/fhex.h \
45+
src/fhex.h \
4646
src/core/hexeditor.h \
4747
src/qhexedit.h
4848

src/core/hexeditor.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
#include "hexeditor.h"
22

3-
/*
4-
* REMOVED HARDCODED PATTERNS FILE PATH
5-
*/
6-
73
HexEditor::HexEditor()
84
{
95
this->fileSize = 0;

src/core/patternmatching.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ PatternMatching::PatternMatching(string path)
55
std::ifstream configFile(path);
66

77
if (!configFile.good()) {
8-
cerr << "The file '" << path << "' is not accessible." << endl;
8+
cerr << "The pattern config file '" << path << "' is not accessible." << endl;
99
return;
1010
}
1111

src/fhex.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,15 @@ Fhex::Fhex(QWidget *parent, QApplication *app, QString filepath)
196196
QAction *escapeHex = new QAction("Hex Strin&g Manipulation", this);
197197
escapeHex->setShortcut(QKeySequence(Qt::Key_F3));
198198
tools->addAction(escapeHex);
199+
#ifndef MINIMAL
199200
QAction *fasm = new QAction(QIcon::fromTheme("map-flat"), "&Assembler/Disassembler", this);
200201
fasm->setShortcut(QKeySequence(Qt::Key_F4));
201202
tools->addAction(fasm);
202-
203+
connect(fasm, &QAction::triggered, this, &Fhex::on_menu_fasm_click);
204+
#endif
203205
connect(hexDec, &QAction::triggered, this, &Fhex::on_menu_hex_dec_converter_click);
204206
connect(escapeHex, &QAction::triggered, this, &Fhex::on_menu_escape_hex_click);
205-
connect(fasm, &QAction::triggered, this, &Fhex::on_menu_fasm_click);
207+
206208

207209
QMenu *help;
208210
help = menuBar()->addMenu("&Help");
@@ -351,8 +353,9 @@ Fhex::Fhex(QWidget *parent, QApplication *app, QString filepath)
351353

352354
this->statusBar.setText("Fhex loaded");
353355
this->setCentralWidget(mainWidget);
356+
#ifndef MINIMAL
354357
this->fasm = nullptr;
355-
358+
#endif
356359
//If a filepath was passed as argument, open it
357360
if (filepath != "") {
358361
this->loadFile(filepath);
@@ -368,9 +371,11 @@ Fhex::Fhex(QWidget *parent, QApplication *app, QString filepath)
368371
Fhex::~Fhex()
369372
{
370373
delete this->hexEditor;
374+
#ifndef MINIMAL
371375
if (this->fasm != nullptr) {
372376
delete this->fasm;
373377
}
378+
#endif
374379
}
375380

376381
void Fhex::on_menu_find_patterns_click() {
@@ -499,6 +504,7 @@ void Fhex::on_menu_about_click() {
499504
newWindow->show();
500505
}
501506

507+
#ifndef MINIMAL
502508
void Fhex::on_menu_fasm_click() {
503509
if (fasm != nullptr) {
504510
delete fasm;
@@ -507,6 +513,7 @@ void Fhex::on_menu_fasm_click() {
507513
fasm = new Fasm(this->qhex->selectedData());
508514
fasm->show();
509515
}
516+
#endif
510517

511518
void Fhex::on_menu_offset_list_click() {
512519
this->listOffsets->setVisible(!this->listOffsets->isVisible());

src/fhex.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@
5353

5454
#include "qhexedit.h"
5555
#include "core/hexeditor.h"
56+
#ifndef MINIMAL
5657
#include "fasm.h"
57-
58+
#endif
5859
#define MAX_DIFF_BYTES 3000
5960
#define DEFAULT_UNPRINTABLE_CHAR "."
6061
#define CHUNK_SIZE 1024
@@ -93,8 +94,9 @@ class Fhex : public QMainWindow
9394

9495
// PATTERNS
9596
bool patternsEnabled;
96-
97+
#ifndef MINIMAL
9798
Fasm *fasm;
99+
#endif
98100
unsigned long file_size_limit = 1073741824; //1GB is the maximum amount of bytes that the hex editor can load into memory (configurable)
99101
qint64 lastCursorPos = 0;
100102
qint64 currentCursorPos = 0;
@@ -181,7 +183,9 @@ public slots:
181183
void on_menu_escape_hex_click();
182184
void on_binchart_click(const QPointF &p);
183185
void on_menu_binchart_click();
186+
#ifndef MINIMAL
184187
void on_menu_fasm_click();
188+
#endif
185189
void on_menu_about_click();
186190
void on_regex_checkbox_changed(int);
187191

0 commit comments

Comments
 (0)