Skip to content

Commit 83e920d

Browse files
committed
Added support to filepath as command-line argument
1 parent 9f96e84 commit 83e920d

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/fhex.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "fhex.h"
22
#include <QDebug>
33

4-
Fhex::Fhex(QWidget *parent, QApplication *app)
4+
Fhex::Fhex(QWidget *parent, QApplication *app, QString filepath)
55
: QMainWindow(parent)
66
{
77
this->app = app;
@@ -212,6 +212,12 @@ Fhex::Fhex(QWidget *parent, QApplication *app)
212212
this->statusBar.setText("Fhex loaded");
213213
this->setCentralWidget(mainWidget);
214214

215+
//If a filepath was passed as argument, open it
216+
if (filepath != "") {
217+
this->loadFile(filepath);
218+
this->loadTables();
219+
}
220+
215221
}
216222

217223
Fhex::~Fhex()

src/fhex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class Fhex : public QMainWindow
6565
Q_OBJECT
6666

6767
public:
68-
Fhex(QWidget *parent = nullptr, QApplication *app = nullptr);
68+
Fhex(QWidget *parent = nullptr, QApplication *app = nullptr, QString filepath = "");
6969
~Fhex();
7070

7171
private:

src/main.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
#include "fhex.h"
2+
#include <QFile>
23
#include <QApplication>
34

45
int main(int argc, char *argv[])
56
{
67
QApplication a(argc, argv);
7-
Fhex w(nullptr, &a);
8+
9+
QString filepath = "";
10+
if ((argc > 1) && (QFile::exists(argv[1]))) {
11+
filepath = argv[1];
12+
}
13+
Fhex w(nullptr, &a, filepath);
814

915
w.show();
1016

0 commit comments

Comments
 (0)