@@ -59,8 +59,8 @@ int MainWindow::_currentMode = 0;
5959MainWindow::MainWindow (const QString &defaultDisplay, QSplashScreen *splash, QWidget *parent) :
6060 QMainWindow(parent),
6161 ui(new Ui::MainWindow),
62- _qpd(NULL ), _kcpos(0 ), _defaultDisplay(defaultDisplay), _splash(splash),
63- _silent(false ), _allowSilent(false ), _settings(NULL ),
62+ _qpd(NULL ), _kcpos(0 ), _defaultDisplay(defaultDisplay),
63+ _silent(false ), _allowSilent(false ), _splash(splash), _settings(NULL ),
6464 _activatedEth(false ), _numInstalledOS(0 ), _netaccess(NULL ), _displayModeBox(NULL )
6565{
6666 ui->setupUi (this );
@@ -317,7 +317,13 @@ void MainWindow::repopulate()
317317/* Whether this OS should be displayed in the list of installable OSes */
318318bool canInstallOs (const QString& name, const QVariantMap& values)
319319{
320- /* Can't simply pull "name" from "values" because in some JSON files it's "os_name" and in others it's "name"
320+ /* Can't simply pull "name" from "values" because in some JSON files it's "os_name" and in others it's "name" */
321+
322+ /* If it's not bootable, is isn't really an OS, so is always installable */
323+ if (!canBootOs (name, values))
324+ {
325+ return true ;
326+ }
321327
322328 /* RISC_OS needs a matching riscos_offset */
323329 if (nameMatchesRiscOS (name))
@@ -331,6 +337,27 @@ bool canInstallOs(const QString& name, const QVariantMap& values)
331337 return true ;
332338}
333339
340+ /* Whether this OS is supported */
341+ bool isSupportedOs (const QString& name, const QVariantMap& values)
342+ {
343+ /* Can't simply pull "name" from "values" because in some JSON files it's "os_name" and in others it's "name" */
344+
345+ /* If it's not bootable, is isn't really an OS, so is always supported */
346+ if (!canBootOs (name, values))
347+ {
348+ return true ;
349+ }
350+
351+ /* Check the feature_level flag */
352+ quint64 featurelevel = values.value (" feature_level" , 58364 ).toULongLong ();
353+ quint64 mask = (quint64)1 << readBoardRevision ();
354+ if ((featurelevel & mask) != mask) {
355+ return false ;
356+ }
357+
358+ return true ;
359+ }
360+
334361QMap<QString, QVariantMap> MainWindow::listImages ()
335362{
336363 QMap<QString,QVariantMap> images;
@@ -364,7 +391,8 @@ QMap<QString, QVariantMap> MainWindow::listImages()
364391 fm[" recommended" ] = true ;
365392 fm[" folder" ] = imagefolder;
366393 fm[" release_date" ] = osv.value (" release_date" );
367- images[imagefolder+" #" +name] = fm;
394+ QString imagekey = imagefolder+" #" +name;
395+ images[imagekey] = fm;
368396 }
369397 }
370398 }
@@ -374,7 +402,8 @@ QMap<QString, QVariantMap> MainWindow::listImages()
374402 if (name.contains (RECOMMENDED_IMAGE))
375403 osv[" recommended" ] = true ;
376404 osv[" folder" ] = imagefolder;
377- images[imagefolder+" #" +name] = osv;
405+ QString imagekey = imagefolder+" #" +name;
406+ images[imagekey] = osv;
378407 }
379408 }
380409 }
@@ -386,10 +415,18 @@ QMap<QString, QVariantMap> MainWindow::listImages()
386415 foreach (QVariant v, i)
387416 {
388417 QVariantMap m = v.toMap ();
389- m[" installed" ] = true ;
390418 QString flavour = m.value (" name" ).toString ();
391419 QString imagefolder = m.value (" folder" ).toString ();
392- images[imagefolder+" #" +flavour] = m;
420+ QString imageKey = imagefolder+" #" +flavour;
421+ if (images.contains (imageKey))
422+ {
423+ images[imageKey][" installed" ] = true ;
424+ }
425+ else
426+ {
427+ m[" installed" ] = true ;
428+ images[imageKey] = m;
429+ }
393430 }
394431 }
395432
@@ -425,46 +462,65 @@ void MainWindow::on_actionWrite_image_to_disk_triggered()
425462 tr (" Warning: this will install the selected Operating System(s). All existing data on the SD card will be overwritten, including any OSes that are already installed." ),
426463 QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
427464 {
428- setEnabled ( false );
429- _numMetaFilesToDownload = 0 ;
430-
465+ /* See if any of the OSes are unsupported */
466+ bool allSupported = true ;
467+ QString unsupportedOses;
431468 QList<QListWidgetItem *> selected = selectedItems ();
432469 foreach (QListWidgetItem *item, selected)
433470 {
434471 QVariantMap entry = item->data (Qt::UserRole).toMap ();
472+ QString name = entry.value (" name" ).toString ();
473+ if (!isSupportedOs (name, entry)) {
474+ allSupported = false ;
475+ unsupportedOses += " \n " + name;
476+ }
477+ }
478+ if (_silent || allSupported || QMessageBox::warning (this ,
479+ tr (" Confirm" ),
480+ tr (" Warning: incompatible Operating System(s) detected. The following OSes aren't supported on this revision of Raspberry Pi and may fail to boot or function correctly:" ) + unsupportedOses,
481+ QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
482+ {
483+ setEnabled (false );
484+ _numMetaFilesToDownload = 0 ;
435485
436- if (!entry.contains (" folder" ))
486+ QList<QListWidgetItem *> selected = selectedItems ();
487+ foreach (QListWidgetItem *item, selected)
437488 {
438- QDir d;
439- QString folder = " /settings/os/" +entry.value (" name" ).toString ();
440- folder.replace (' ' , ' _' );
441- if (!d.exists (folder))
442- d.mkpath (folder);
489+ QVariantMap entry = item->data (Qt::UserRole).toMap ();
490+
491+ if (!entry.contains (" folder" ))
492+ {
493+ QDir d;
494+ QString folder = " /settings/os/" +entry.value (" name" ).toString ();
495+ folder.replace (' ' , ' _' );
496+ if (!d.exists (folder))
497+ d.mkpath (folder);
443498
444- downloadMetaFile (entry.value (" os_info" ).toString (), folder+" /os.json" );
445- downloadMetaFile (entry.value (" partitions_info" ).toString (), folder+" /partitions.json" );
499+ downloadMetaFile (entry.value (" os_info" ).toString (), folder+" /os.json" );
500+ downloadMetaFile (entry.value (" partitions_info" ).toString (), folder+" /partitions.json" );
446501
447- if (entry.contains (" marketing_info" ))
448- downloadMetaFile (entry.value (" marketing_info" ).toString (), folder+" /marketing.tar" );
502+ if (entry.contains (" marketing_info" ))
503+ downloadMetaFile (entry.value (" marketing_info" ).toString (), folder+" /marketing.tar" );
449504
450- if (entry.contains (" partition_setup" ))
451- downloadMetaFile (entry.value (" partition_setup" ).toString (), folder+" /partition_setup.sh" );
505+ if (entry.contains (" partition_setup" ))
506+ downloadMetaFile (entry.value (" partition_setup" ).toString (), folder+" /partition_setup.sh" );
452507
453- if (entry.contains (" icon" ))
454- downloadMetaFile (entry.value (" icon" ).toString (), folder+" /icon.png" );
508+ if (entry.contains (" icon" ))
509+ downloadMetaFile (entry.value (" icon" ).toString (), folder+" /icon.png" );
510+ }
455511 }
456- }
457512
458- if (_numMetaFilesToDownload == 0 )
459- {
460- /* All OSes selected are local */
461- startImageWrite ();
462- }
463- else if (!_silent)
464- {
465- _qpd = new QProgressDialog (tr (" The install process will begin shortly." ), QString (), 0 , 0 , this );
466- _qpd->setWindowFlags (Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint);
467- _qpd->show ();
513+ if (_numMetaFilesToDownload == 0 )
514+ {
515+ /* All OSes selected are local */
516+ startImageWrite ();
517+ }
518+ else if (!_silent)
519+ {
520+ _qpd = new QProgressDialog (tr (" The install process will begin shortly." ), QString (), 0 , 0 , this );
521+ _qpd->setWindowFlags (Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint);
522+ _qpd->show ();
523+ }
468524 }
469525 }
470526}
0 commit comments