From b45720b566411a77fa18717f8ce82b77945184c2 Mon Sep 17 00:00:00 2001 From: Srivats P Date: Thu, 13 Oct 2016 22:06:11 +0530 Subject: [PATCH] Ostinato starts with session file if provided on command line --- client/mainwindow.cpp | 19 ++++++++++++++++--- client/mainwindow.h | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/client/mainwindow.cpp b/client/mainwindow.cpp index 8c881d7..240b410 100644 --- a/client/mainwindow.cpp +++ b/client/mainwindow.cpp @@ -120,6 +120,16 @@ MainWindow::MainWindow(QWidget *parent) connect(updater, SIGNAL(newVersionAvailable(QString)), this, SLOT(onNewVersion(QString))); updater->checkForNewVersion(); + + if (appParams.argumentCount()) { + QString fileName = appParams.argument(0); + if (QFile::exists(fileName)) + on_actionOpenSession_triggered(fileName); + else + QMessageBox::information(NULL, qApp->applicationName(), + QString("File not found: " + fileName)); + } + #if 0 { DbgThread *dbg = new DbgThread(pgl); @@ -151,18 +161,20 @@ MainWindow::~MainWindow() } } -void MainWindow::on_actionOpenSession_triggered() +void MainWindow::on_actionOpenSession_triggered(QString fileName) { - qDebug("Open Session Action"); + qDebug("Open Session Action (%s)", qPrintable(fileName)); static QString dirName; - QString fileName; QStringList fileTypes = SessionFileFormat::supportedFileTypes( SessionFileFormat::kOpenFile); QString fileType; QString errorStr; bool ret; + if (!fileName.isEmpty()) + goto _skip_prompt; + if (portsWindow->portGroupCount()) { if (QMessageBox::question(this, tr("Open Session"), @@ -180,6 +192,7 @@ void MainWindow::on_actionOpenSession_triggered() if (fileName.isEmpty()) goto _exit; +_skip_prompt: ret = openSession(fileName, errorStr); if (!ret || !errorStr.isEmpty()) { QMessageBox msgBox(this); diff --git a/client/mainwindow.h b/client/mainwindow.h index ba16ed6..1b37798 100644 --- a/client/mainwindow.h +++ b/client/mainwindow.h @@ -51,7 +51,7 @@ public: ~MainWindow(); public slots: - void on_actionOpenSession_triggered(); + void on_actionOpenSession_triggered(QString fileName = QString()); void on_actionSaveSession_triggered(); void on_actionPreferences_triggered(); void on_actionViewRestoreDefaults_triggered();