From 71c3f58c9922e957768199fedf027651a032a575 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 27 Jul 2020 20:40:38 -0400 Subject: [PATCH] Provides user feedback upon improper command-line usage. --- OSBindings/Qt/mainwindow.cpp | 12 ++++++++++-- OSBindings/Qt/mainwindow.h | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/OSBindings/Qt/mainwindow.cpp b/OSBindings/Qt/mainwindow.cpp index 8286fe45f..8a85b99dc 100644 --- a/OSBindings/Qt/mainwindow.cpp +++ b/OSBindings/Qt/mainwindow.cpp @@ -45,7 +45,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { MainWindow::MainWindow(const QString &fileName) { init(); - launchFile(fileName); + if(!launchFile(fileName)) { + setUIPhase(UIPhase::SelectingMachine); + } } void MainWindow::deleteMachine() { @@ -210,11 +212,17 @@ void MainWindow::insertFile(const QString &fileName) { mediaTarget->insert_media(media); } -void MainWindow::launchFile(const QString &fileName) { +bool MainWindow::launchFile(const QString &fileName) { targets = Analyser::Static::GetTargets(fileName.toStdString()); if(!targets.empty()) { openFileName = QFileInfo(fileName).fileName(); launchMachine(); + return true; + } else { + QMessageBox msgBox; + msgBox.setText("Unable to open file: " + fileName); + msgBox.exec(); + return false; } } diff --git a/OSBindings/Qt/mainwindow.h b/OSBindings/Qt/mainwindow.h index 91f3cab2d..22be7e739 100644 --- a/OSBindings/Qt/mainwindow.h +++ b/OSBindings/Qt/mainwindow.h @@ -102,7 +102,7 @@ class MainWindow : public QMainWindow, public Outputs::Speaker::Speaker::Delegat QAction *insertAction = nullptr; void insertFile(const QString &fileName); - void launchFile(const QString &fileName); + bool launchFile(const QString &fileName); void launchTarget(std::unique_ptr &&); void restoreSelections();