//
//
// EmuFront is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
+// it under the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation and appearing in the file gpl.txt included in the
+// packaging of this file.
//
// EmuFront is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include <QtGui>
#include <QProcess>
#include <QSqlTableModel>
+#include <QItemSelectionModel>
#include "utils/OSDaB-Zip/unzip.h"
#include "emulauncher.h"
#include "db/dbmediatype.h"
void EmuLauncher::initWidgets()
{
micTable = new QTableView(this);
- micTable->setSelectionMode(QAbstractItemView::SingleSelection);
+ micTable->setSelectionMode(QAbstractItemView::MultiSelection);
mediaTypeSelectBox = new EFFileObjectComboBox(dbMediaType, this);
platformSelectBox = new EFFileObjectComboBox(dbPlatform, this);
execSelectBox = new ExecutableComboBox(dbExec, this);
if (!execSelectBox || execSelectBox->currentIndex() == -1) {
throw EmuFrontException(tr("Emulator not selected!"));
}
- // TODO: multiple media image container selection
- QModelIndex mindex = micTable->currentIndex();
- if (!mindex.isValid()) {
+ //QModelIndex mindex = micTable->currentIndex();
+ QItemSelectionModel *selModel = micTable->selectionModel();
+ QModelIndexList listMIndex = selModel->selectedIndexes();
+ /*if (!mindex.isValid()) {
+ throw EmuFrontException(tr("Media image container not selected!"));
+ }*/
+ if (listMIndex.count() < 1) {
throw EmuFrontException(tr("Media image container not selected!"));
}
+ qDebug() << listMIndex.count() << " items selected.";
+ // TODO: multiple media image container selection
+ QModelIndex mindex = listMIndex.first();
EmuFrontObject *obImg = dbMic->getDataObjectFromModel(&mindex);
if (!obImg) {
throw EmuFrontException(tr("Failed fetching selected media image container."));
<< mic->getName() << " and emulator "
<< obExe->getName() << ".";
if (mic->getMediaImages().count() > 0) {
- // TODO
// 1. Launch media image
+ // TODO
// 2. If 2 or more media images in container
// show a diaglog for choosing the boot image
// 3. If 2 or more media image containers selected
// Executable and MediaImageContainer objects are no more needed:
delete ex;
delete mic;
- if (!proc) proc = new QProcess(this); // This has to be done in the heap
+ if (!proc) {
+ proc = new QProcess(this); // This has to be done in the heap
+ connect(proc, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));
+ connect(proc, SIGNAL(finished(int)), this, SLOT(processFinished(int)));
+ }
proc->start(cmdWithParams, QIODevice::ReadOnly);
}
+
+void EmuLauncher::processError(QProcess::ProcessError e)
+{
+ QString stdErr = proc->readAllStandardError();
+ QMessageBox::warning(this, tr("Emulator"),
+ tr("Launching emulator failed with: %1.\n").arg(e)
+ .append(";\n").append(proc->errorString().append(";\n")
+ .append(stdErr)), QMessageBox::Ok );
+}
+
+void EmuLauncher::processFinished(int a)
+{
+ QString stdErr = proc->readAllStandardError();
+ QString stdMsg = proc->readAllStandardOutput();
+ QString msg = tr("Emulator has finished with: %1.\n").arg(a).append(stdMsg);
+ if (a) msg.append("; ").append(proc->errorString()).append(";\n").append(stdErr);
+ QMessageBox::information(this, tr("Emulator finished"), msg, QMessageBox::Ok);
+}