Skip to content

Commit

Permalink
core/emuwidget: Check iio-emu in system.
Browse files Browse the repository at this point in the history
Signed-off-by: andrei.danila <[email protected]>
  • Loading branch information
andreidanila1 committed Apr 24, 2024
1 parent b6659ff commit fc1af8a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion core/include/core/emuwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
19 changes: 14 additions & 5 deletions core/src/emuwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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;
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit fc1af8a

Please sign in to comment.