From 26f4e65b7b6592173aa1b23fcd23861b4d3d1c3d Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Mon, 6 Dec 2021 16:38:13 +0800 Subject: [PATCH] auto load file data from application startup param --- DSView/main.cpp | 1 + DSView/pv/appcontrol.h | 3 +++ DSView/pv/mainwindow.cpp | 25 ++++++++++++++----------- DSView/pv/mainwindow.h | 1 + 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/DSView/main.cpp b/DSView/main.cpp index dac39c93..0fce15d8 100755 --- a/DSView/main.cpp +++ b/DSView/main.cpp @@ -147,6 +147,7 @@ int main(int argc, char *argv[]) return 1; } else if (argcFinal - optind == 1){ open_file = argvFinal[argcFinal - 1]; + control->_open_file_name = open_file; } diff --git a/DSView/pv/appcontrol.h b/DSView/pv/appcontrol.h index 8e0e1ac0..2766cbae 100644 --- a/DSView/pv/appcontrol.h +++ b/DSView/pv/appcontrol.h @@ -62,6 +62,9 @@ public: inline pv::DeviceManager& GetDeviceManager() { return *_device_manager;} +public: + std::string _open_file_name; + private: std::string m_error; struct sr_context *sr_ctx; diff --git a/DSView/pv/mainwindow.cpp b/DSView/pv/mainwindow.cpp index 8437868f..9efe422f 100644 --- a/DSView/pv/mainwindow.cpp +++ b/DSView/pv/mainwindow.cpp @@ -91,6 +91,7 @@ #include "config/appconfig.h" #include "appcontrol.h" #include "dsvdef.h" +#include "appcontrol.h" namespace pv { @@ -102,20 +103,11 @@ MainWindow::MainWindow(QWidget *parent) : { _control = AppControl::Instance(); _control->GetSession()->set_callback(this); + _bFirstLoad = true; setup_ui(); - setContextMenuPolicy(Qt::NoContextMenu); - - /* - if (open_file_name) { - qDebug("Open file: %s", open_file_name); - const QString s(QString::fromUtf8(open_file_name)); - QMetaObject::invokeMethod(this, "on_load_file", - Qt::QueuedConnection, - Q_ARG(QString, s)); - } - */ + setContextMenuPolicy(Qt::NoContextMenu); } void MainWindow::setup_ui() @@ -439,6 +431,17 @@ void MainWindow::update_device_list() } _trig_bar->restore_status(); + + //load specified file name from application startup param + if (_bFirstLoad){ + _bFirstLoad = false; + + if (AppControl::Instance()->_open_file_name != ""){ + QString f(QString::fromUtf8(AppControl::Instance()->_open_file_name.c_str())); + qDebug()<<"auto load file:"<