diff --git a/src/swiftlauncher/swiftlauncher.cpp b/src/swiftlauncher/swiftlauncher.cpp index e9f59af30..4bd51cb74 100644 --- a/src/swiftlauncher/swiftlauncher.cpp +++ b/src/swiftlauncher/swiftlauncher.cpp @@ -8,16 +8,17 @@ #include "swiftlauncher.h" #include "ui_swiftlauncher.h" +#include "blackgui/overlaymessagesframe.h" #include "blackgui/components/configurationwizard.h" #include "blackgui/components/texteditdialog.h" #include "blackgui/guiapplication.h" #include "blackgui/stylesheetutility.h" #include "blackcore/context/contextapplicationproxy.h" #include "blackcore/setupreader.h" +#include "blacksound/audioutilities.h" #include "blackmisc/simulation/fscommon/fscommonutil.h" #include "blackcore/context/contextnetwork.h" #include "blackmisc/network/networkutils.h" -#include "blacksound/audioutilities.h" #include "blackmisc/dbusserver.h" #include "blackmisc/directoryutils.h" #include "blackmisc/icons.h" @@ -48,11 +49,14 @@ using namespace BlackSound; using namespace BlackMisc; using namespace BlackMisc::Db; using namespace BlackMisc::Network; +using namespace BlackMisc::Simulation; +using namespace BlackMisc::Simulation::Data; using namespace BlackMisc::Simulation::FsCommon; CSwiftLauncher::CSwiftLauncher(QWidget *parent) : QDialog(parent, CEnableForFramelessWindow::modeToWindowFlags(CEnableForFramelessWindow::WindowNormal)), CEnableForFramelessWindow(CEnableForFramelessWindow::WindowFrameless, true, "framelessMainWindow", this), + CCentralMultiSimulatorModelSetCachesAware(), CIdentifiable(this), ui(new Ui::CSwiftLauncher) { @@ -77,10 +81,10 @@ CSwiftLauncher::CSwiftLauncher(QWidget *parent) : connect(ui->comp_DBusSelector, &CDBusServerAddressSelector::editingFinished, this, &CSwiftLauncher::onDBusEditingFinished, Qt::QueuedConnection); connect(sGui, &CGuiApplication::styleSheetsChanged, this, &CSwiftLauncher::onStyleSheetsChanged, Qt::QueuedConnection); - connect(ui->pb_Log, &QPushButton::released, this, &CSwiftLauncher::showLogPage, Qt::QueuedConnection); - connect(ui->pb_Log, &QPushButton::released, this, &CSwiftLauncher::showLogPage, Qt::QueuedConnection); - connect(ui->pb_LogDir, &QPushButton::released, sGui, &CGuiApplication::openStandardLogDirectory, Qt::QueuedConnection); - connect(ui->pb_DumpDir, &QPushButton::released, sGui, &CGuiApplication::openStandardCrashDumpDirectory, Qt::QueuedConnection); + connect(ui->pb_LogDir, &QPushButton::released, sGui, &CGuiApplication::openStandardLogDirectory, Qt::QueuedConnection); + connect(ui->pb_DumpDir, &QPushButton::released, sGui, &CGuiApplication::openStandardCrashDumpDirectory, Qt::QueuedConnection); + connect(ui->pb_Log, &QPushButton::released, this, &CSwiftLauncher::showLogPage, Qt::QueuedConnection); + connect(ui->pb_Log, &QPushButton::released, this, &CSwiftLauncher::showLogPage, Qt::QueuedConnection); connect(ui->pb_FSXConfigDirs, &QPushButton::released, this, &CSwiftLauncher::showSimulatorConfigDirs, Qt::QueuedConnection); connect(ui->pb_P3DConfigDirs, &QPushButton::released, this, &CSwiftLauncher::showSimulatorConfigDirs, Qt::QueuedConnection); @@ -92,17 +96,73 @@ CSwiftLauncher::CSwiftLauncher(QWidget *parent) : m_checkTimer.setInterval(2500); m_checkTimer.start(); - // auto launch wizard nd other init parts const QPointer myself(this); + if (sGui->isInstallerOptionSet()) + { + QTimer::singleShot(1000, this, [ = ] + { + if (!sGui || sGui->isShuttingDown() || !myself) { return; } + ui->fr_SwiftLauncherMain->showOverlayHTMLMessage("Checking installation!
One moment please ...."); + this->raise(); + }); + } + + // auto launch wizard and other init parts QTimer::singleShot(2500, this, [ = ] { if (!sGui || sGui->isShuttingDown() || !myself) { return; } this->onCoreModeReleased(); this->requestMacMicrophoneAccess(); - if (sGui->isInstallerOptionSet()) { myself->startWizard(); } + this->installerMode(); }); } +void CSwiftLauncher::installerMode() +{ + if (!sGui || sGui->isShuttingDown()) { return; } + if (!sGui->isInstallerOptionSet()) { return; } + + bool runDialog = false; + do + { + const QDir dir = CDirectoryUtils::logDirectory(); + if (!dir.exists()) { break; } + + if (sGui && sGui->getSetupReader()) + { + sGui->getSetupReader()->prefillCacheWithLocalResourceBootstrapFile(); + } + + for (const CSimulatorInfo &sim : CSimulatorInfo::allSimulatorsSet()) + { + this->synchronizeCache(sim); + const int c = this->getCachedModelsCount(sim); + if (c > 0) + { + // we already have data + runDialog = true; + break; + } + } + } + while (false); + + bool startWizard = true; + ui->fr_SwiftLauncherMain->closeOverlay(); + + if (runDialog) + { + const QMessageBox::StandardButton ret = + QMessageBox::question(this, + tr("swift configuration"), + tr("This installation directory already contains a swift configuration.\n" + "Do you want to use that one?")); + if (ret != QMessageBox::No) { startWizard = false; } + } + + if (startWizard) { this->startWizard(); } +} + CSwiftLauncher::~CSwiftLauncher() { } diff --git a/src/swiftlauncher/swiftlauncher.h b/src/swiftlauncher/swiftlauncher.h index d579a8a34..fdca66e23 100644 --- a/src/swiftlauncher/swiftlauncher.h +++ b/src/swiftlauncher/swiftlauncher.h @@ -11,12 +11,13 @@ #ifndef SWIFTLAUNCHER_H #define SWIFTLAUNCHER_H -#include "blackgui/overlaymessagesframe.h" #include "blackgui/enableforframelesswindow.h" +#include "blackgui/overlaymessagesframe.h" #include "blackgui/mainwindowaccess.h" #include "blackcore/data/globalsetup.h" #include "blackcore/data/launchersetup.h" #include "blackcore/coremodeenums.h" +#include "blackmisc/simulation/data/modelcaches.h" #include "blackmisc/db/artifact.h" #include "blackmisc/identifiable.h" @@ -50,6 +51,7 @@ class CSwiftLauncher : public QDialog, public BlackGui::CEnableForFramelessWindow, public BlackGui::IMainWindowAccess, + public BlackMisc::Simulation::Data::CCentralMultiSimulatorModelSetCachesAware, public BlackMisc::CIdentifiable { Q_OBJECT @@ -211,6 +213,9 @@ private: //! Request MacOS microphone request void requestMacMicrophoneAccess(); + //! Run in installer mode + void installerMode(); + //! Command line static QString toCmdLine(const QString &exe, const QStringList &exeArgs); };