auto load file data from application startup param

This commit is contained in:
dreamsourcelabTAI 2021-12-06 16:38:13 +08:00
parent 65f5946fe3
commit 26f4e65b7b
4 changed files with 19 additions and 11 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -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:"<<f;
on_load_file(f);
}
}
}

View File

@ -224,6 +224,7 @@ private:
QTranslator _qtTrans;
QTranslator _myTrans;
EventObject _event;
bool _bFirstLoad;
};
} // namespace pv