From 672e6937afd1ff429c1aea2028b369e11a4df01d Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Wed, 2 Aug 2017 13:41:24 +0000 Subject: [PATCH] kemu: disable some functionality of QEMU is not installed at all Signed-off-by: Ivailo Monev --- kemu/kemumainwindow.cpp | 11 +++++++++-- kemu/kemumainwindow.h | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/kemu/kemumainwindow.cpp b/kemu/kemumainwindow.cpp index 549ee8cf..9312a6d9 100644 --- a/kemu/kemumainwindow.cpp +++ b/kemu/kemumainwindow.cpp @@ -33,7 +33,7 @@ #include "ui_kemu.h" KEmuMainWindow::KEmuMainWindow(QWidget *parent, Qt::WindowFlags flags) - : KXmlGuiWindow(parent, flags), m_kemuui(new Ui_KEmuWindow) + : KXmlGuiWindow(parent, flags), m_loading(false), m_installed(false), m_kemuui(new Ui_KEmuWindow) { m_kemuui->setupUi(this); @@ -94,6 +94,7 @@ KEmuMainWindow::KEmuMainWindow(QWidget *parent, Qt::WindowFlags flags) << "qemu-system-xtensaeb"; foreach (const QString bin, qemuBins) { if(!KStandardDirs::findExe(bin).isEmpty()) { + m_installed = true; m_kemuui->systemComboBox->addItem(bin); } } @@ -112,6 +113,12 @@ KEmuMainWindow::KEmuMainWindow(QWidget *parent, Qt::WindowFlags flags) m_kemuui->machinesList->listView()->keyboardSearch(lastSelected); } + if(!m_installed) { + m_kemuui->startStopButton->setEnabled(false); + QMessageBox::critical(this, i18n("QEMU not available"), i18n("QEMU not available")); + return; + } + QFile kvmdev("/dev/kvm"); if (!kvmdev.exists()) { const QString modprobeBin = KStandardDirs::findExe("modprobe"); @@ -273,7 +280,7 @@ void KEmuMainWindow::machineChanged(QItemSelection ignored, QItemSelection ignor QFile kvmdev("/dev/kvm"); m_kemuui->KVMCheckBox->setEnabled(kvmdev.exists()); - m_kemuui->startStopButton->setEnabled(true); + m_kemuui->startStopButton->setEnabled(m_installed); m_kemuui->groupBox->setEnabled(true); if (m_machines.contains(machine)) { kDebug() << "machine is running" << machine; diff --git a/kemu/kemumainwindow.h b/kemu/kemumainwindow.h index 6df46236..a0071da8 100644 --- a/kemu/kemumainwindow.h +++ b/kemu/kemumainwindow.h @@ -49,10 +49,11 @@ private slots: private: void updateStatus(); + bool m_loading; + bool m_installed; Ui_KEmuWindow *m_kemuui; QSettings *m_settings; QHash m_machines; - bool m_loading; }; #endif // KEMUMAINWINDOW_H \ No newline at end of file