summaryrefslogtreecommitdiff
path: root/src/gui_qt.cc
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@yahoo.com>2017-07-29 18:31:48 +0200
committerJoel Klinghed <the_jk@yahoo.com>2017-07-29 18:31:48 +0200
commit1d6b4708c0093256ee67cc4c8ba1982719243b6d (patch)
tree1544c5c70d07ab8dfad209b501f84c581fc42e37 /src/gui_qt.cc
parent8d58ffb022649fd8a28d2f74845fc8ca5c934029 (diff)
Handle FILE argument in monitor-gui
Diffstat (limited to 'src/gui_qt.cc')
-rw-r--r--src/gui_qt.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/gui_qt.cc b/src/gui_qt.cc
index 5cd16f9..4d6eba1 100644
--- a/src/gui_qt.cc
+++ b/src/gui_qt.cc
@@ -7,6 +7,7 @@
#include <QCheckBox>
#include <QClipboard>
#include <QCloseEvent>
+#include <QCommandLineParser>
#include <QDialogButtonBox>
#include <QFileDialog>
#include <QGridLayout>
@@ -560,6 +561,13 @@ private:
}
}
+ void notify_open(std::string const& file) {
+ auto it = observers_.notify();
+ while (it.has_next()) {
+ it.next()->open(this, file);
+ }
+ }
+
std::string title_;
uint32_t width_;
uint32_t height_;
@@ -1571,6 +1579,15 @@ private:
bool QtGuiMain::run(int argc, char** argv) {
QApplication app(argc, argv);
+ app.setApplicationName(QString::fromStdString(title_));
+ app.setApplicationVersion(VERSION);
+
+ QCommandLineParser parser;
+ parser.addHelpOption();
+ parser.addVersionOption();
+ parser.addPositionalArgument("FILE", "Package capture to load");
+ parser.process(app);
+
app.setStyleSheet("QStatusBar::item { border: 0px }");
main_.reset(new QMainWindow());
main_->setWindowTitle(QString::fromStdString(title_));
@@ -1614,6 +1631,12 @@ bool QtGuiMain::run(int argc, char** argv) {
}
main_->show();
set_split(split_);
+
+ auto args = parser.positionalArguments();
+ if (args.size() > 0) {
+ notify_open(args[0].toStdString());
+ }
+
auto ret = app.exec() == 0;
layout_.reset();
top_ = nullptr;