1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-10-04 01:57:54 +00:00

Provides user feedback upon improper command-line usage.

This commit is contained in:
Thomas Harte 2020-07-27 20:40:38 -04:00
parent 7c05b1788e
commit 71c3f58c99
2 changed files with 11 additions and 3 deletions

View File

@ -45,7 +45,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
MainWindow::MainWindow(const QString &fileName) { MainWindow::MainWindow(const QString &fileName) {
init(); init();
launchFile(fileName); if(!launchFile(fileName)) {
setUIPhase(UIPhase::SelectingMachine);
}
} }
void MainWindow::deleteMachine() { void MainWindow::deleteMachine() {
@ -210,11 +212,17 @@ void MainWindow::insertFile(const QString &fileName) {
mediaTarget->insert_media(media); mediaTarget->insert_media(media);
} }
void MainWindow::launchFile(const QString &fileName) { bool MainWindow::launchFile(const QString &fileName) {
targets = Analyser::Static::GetTargets(fileName.toStdString()); targets = Analyser::Static::GetTargets(fileName.toStdString());
if(!targets.empty()) { if(!targets.empty()) {
openFileName = QFileInfo(fileName).fileName(); openFileName = QFileInfo(fileName).fileName();
launchMachine(); launchMachine();
return true;
} else {
QMessageBox msgBox;
msgBox.setText("Unable to open file: " + fileName);
msgBox.exec();
return false;
} }
} }

View File

@ -102,7 +102,7 @@ class MainWindow : public QMainWindow, public Outputs::Speaker::Speaker::Delegat
QAction *insertAction = nullptr; QAction *insertAction = nullptr;
void insertFile(const QString &fileName); void insertFile(const QString &fileName);
void launchFile(const QString &fileName); bool launchFile(const QString &fileName);
void launchTarget(std::unique_ptr<Analyser::Static::Target> &&); void launchTarget(std::unique_ptr<Analyser::Static::Target> &&);
void restoreSelections(); void restoreSelections();