mirror of
https://bitbucket.org/smil3y/kde-playground.git
synced 2025-02-23 10:22:50 +00:00
kemu: disable some functionality of QEMU is not installed at all
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
parent
3898fad667
commit
672e6937af
2 changed files with 11 additions and 3 deletions
|
@ -33,7 +33,7 @@
|
||||||
#include "ui_kemu.h"
|
#include "ui_kemu.h"
|
||||||
|
|
||||||
KEmuMainWindow::KEmuMainWindow(QWidget *parent, Qt::WindowFlags flags)
|
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);
|
m_kemuui->setupUi(this);
|
||||||
|
|
||||||
|
@ -94,6 +94,7 @@ KEmuMainWindow::KEmuMainWindow(QWidget *parent, Qt::WindowFlags flags)
|
||||||
<< "qemu-system-xtensaeb";
|
<< "qemu-system-xtensaeb";
|
||||||
foreach (const QString bin, qemuBins) {
|
foreach (const QString bin, qemuBins) {
|
||||||
if(!KStandardDirs::findExe(bin).isEmpty()) {
|
if(!KStandardDirs::findExe(bin).isEmpty()) {
|
||||||
|
m_installed = true;
|
||||||
m_kemuui->systemComboBox->addItem(bin);
|
m_kemuui->systemComboBox->addItem(bin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,6 +113,12 @@ KEmuMainWindow::KEmuMainWindow(QWidget *parent, Qt::WindowFlags flags)
|
||||||
m_kemuui->machinesList->listView()->keyboardSearch(lastSelected);
|
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");
|
QFile kvmdev("/dev/kvm");
|
||||||
if (!kvmdev.exists()) {
|
if (!kvmdev.exists()) {
|
||||||
const QString modprobeBin = KStandardDirs::findExe("modprobe");
|
const QString modprobeBin = KStandardDirs::findExe("modprobe");
|
||||||
|
@ -273,7 +280,7 @@ void KEmuMainWindow::machineChanged(QItemSelection ignored, QItemSelection ignor
|
||||||
QFile kvmdev("/dev/kvm");
|
QFile kvmdev("/dev/kvm");
|
||||||
m_kemuui->KVMCheckBox->setEnabled(kvmdev.exists());
|
m_kemuui->KVMCheckBox->setEnabled(kvmdev.exists());
|
||||||
|
|
||||||
m_kemuui->startStopButton->setEnabled(true);
|
m_kemuui->startStopButton->setEnabled(m_installed);
|
||||||
m_kemuui->groupBox->setEnabled(true);
|
m_kemuui->groupBox->setEnabled(true);
|
||||||
if (m_machines.contains(machine)) {
|
if (m_machines.contains(machine)) {
|
||||||
kDebug() << "machine is running" << machine;
|
kDebug() << "machine is running" << machine;
|
||||||
|
|
|
@ -49,10 +49,11 @@ private slots:
|
||||||
private:
|
private:
|
||||||
void updateStatus();
|
void updateStatus();
|
||||||
|
|
||||||
|
bool m_loading;
|
||||||
|
bool m_installed;
|
||||||
Ui_KEmuWindow *m_kemuui;
|
Ui_KEmuWindow *m_kemuui;
|
||||||
QSettings *m_settings;
|
QSettings *m_settings;
|
||||||
QHash<QString,QProcess*> m_machines;
|
QHash<QString,QProcess*> m_machines;
|
||||||
bool m_loading;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KEMUMAINWINDOW_H
|
#endif // KEMUMAINWINDOW_H
|
Loading…
Add table
Reference in a new issue