- bool ok;
- QList<EmuFrontObject*> selectedImages;
- if (list.count() > mediaImages.count()) {
- throw EmuFrontException(tr("Select %1 media images for this emulator configuration").arg(list.count()));
- }
- if (list.count() > 1) {
- int lim = list.count() == mediaImages.count() ? list.count() - 1 : list.count();
- for(int i = 0; i < lim; i++) {
+ // check if command options have slots for nr media images > 1 e.g. "-diska $1 -diskb $2 ..."
+ QString opts = exe->getOptions();
+ QRegExp rx("(\\$\\d+)");
+ QStringList list;
+ int pos = 0;
+ while ((pos = rx.indexIn(opts, pos)) != -1) {
+ list << rx.cap(1);
+ pos += rx.matchedLength();
+ }
+ bool ok;
+
+ if (list.count() > mediaImages.count()) {
+ throw EmuFrontException(tr("Select %1 media images for this emulator configuration").arg(list.count()));
+ }
+ if (list.count() > 1) {
+ // more than one placeholder for media image in the command line ($1, $2, ...)
+ int lim = list.count() == mediaImages.count() ? list.count() - 1 : list.count();
+ // user sets the order of media images
+ for(int i = 0; i < lim; i++) {
+ EmuFrontObject *efo = EmuFrontInputDialog::getItem(
+ this, tr("Select image no. %1").arg(i+1), tr("Select"), mediaImages.values(), 0, false, &ok);
+ if (!ok) {
+ throw EmuFrontException(tr("Boot image selection was canceled, aborting."));
+ }
+ selectedImages << efo;
+ MediaImage *mi = dynamic_cast<MediaImage*>(efo);
+ QString key = mi->getCheckSum();
+ mediaImages.remove(key);
+ }
+ // there should be at least one media image left in mediaImages map...
+ /*if (mediaImages.count() == 1) {
+ selectedImages << mediaImages.values().first();
+ } ... this is added later-> */
+ }
+ else if (mediaImages.count() > 1) {
+ // show select boot image dialog