From fc1af8aad04597d710b9edc146aa711f184d3c32 Mon Sep 17 00:00:00 2001 From: "andrei.danila" Date: Tue, 23 Apr 2024 16:19:06 +0300 Subject: [PATCH] core/emuwidget: Check iio-emu in system. Signed-off-by: andrei.danila --- core/include/core/emuwidget.h | 2 +- core/src/emuwidget.cpp | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/core/include/core/emuwidget.h b/core/include/core/emuwidget.h index b1611df51..8ecd27027 100644 --- a/core/include/core/emuwidget.h +++ b/core/include/core/emuwidget.h @@ -35,7 +35,7 @@ private Q_SLOTS: void setStatusMessage(QString msg); QString findEmuPath(); void stopEnableBtn(QString btnText); - bool startIioEmuProcess(); + bool startIioEmuProcess(QString processPath); void killEmuProcess(); Ui::EmuWidget *m_ui; diff --git a/core/src/emuwidget.cpp b/core/src/emuwidget.cpp index 17351da46..7974cc68e 100644 --- a/core/src/emuwidget.cpp +++ b/core/src/emuwidget.cpp @@ -44,8 +44,17 @@ void EmuWidget::init() Preferences *p = Preferences::GetInstance(); p->init("iio_emu_path", QCoreApplication::applicationDirPath()); - m_emuPath = findEmuPath(); - m_emuPath.isEmpty() ? setStatusMessage("Can't find iio-emu in the system!") : setStatusMessage(""); + QString systemEmuCall = "iio-emu"; + if(startIioEmuProcess(systemEmuCall)) { + m_emuPath = systemEmuCall; + } else { + m_emuPath = findEmuPath(); + } + if(m_emuPath.isEmpty()) { + setStatusMessage("Can't find iio-emu in the system!"); + } else { + setStatusMessage(""); + } this->setEnabled(!m_emuPath.isEmpty()); QMovie *loadingIcon(new QMovie(this)); @@ -72,7 +81,7 @@ void EmuWidget::onEnableDemoClicked() { m_ui->btnEnableDemo->startAnimation(); if(!m_enableDemo) { - bool started = startIioEmuProcess(); + bool started = startIioEmuProcess(m_emuPath); if(!started) { stopEnableBtn("Enable Demo"); return; @@ -122,10 +131,10 @@ void EmuWidget::stopEnableBtn(QString btnText) m_ui->btnEnableDemo->setText(btnText); } -bool EmuWidget::startIioEmuProcess() +bool EmuWidget::startIioEmuProcess(QString processPath) { QStringList arg = createArgList(); - m_emuProcess->setProgram(m_emuPath); + m_emuProcess->setProgram(processPath); m_emuProcess->setArguments(arg); m_emuProcess->start();