mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-15 01:05:35 +08:00
Improved version of "Allow to delete data directory from application view"
- split functions into dynamic loading and const versions (loading at startup) - reload other versions from wizard in case they changed - some renaming/formatting
This commit is contained in:
@@ -419,7 +419,7 @@ namespace BlackGui
|
|||||||
void CCopyConfigurationComponent::initOtherSwiftVersions()
|
void CCopyConfigurationComponent::initOtherSwiftVersions()
|
||||||
{
|
{
|
||||||
ui->cb_OtherVersions->clear();
|
ui->cb_OtherVersions->clear();
|
||||||
const QMap<QString, CApplicationInfo> otherVersions = CDirectoryUtils::applicationDataDirectoryMapWithoutCurrentVersion(true);
|
const QMap<QString, CApplicationInfo> otherVersions = CDirectoryUtils::currentApplicationDataDirectoryMapWithoutCurrentVersion();
|
||||||
for (const QString &directory : otherVersions.keys())
|
for (const QString &directory : otherVersions.keys())
|
||||||
{
|
{
|
||||||
const CApplicationInfo info(otherVersions.value(directory));
|
const CApplicationInfo info(otherVersions.value(directory));
|
||||||
@@ -445,8 +445,8 @@ namespace BlackGui
|
|||||||
void CCopyConfigurationComponent::setWidths()
|
void CCopyConfigurationComponent::setWidths()
|
||||||
{
|
{
|
||||||
const int w = this->width();
|
const int w = this->width();
|
||||||
const int wCb = 0.45 * w;
|
const int wCb = qRound(0.45 * w);
|
||||||
const int wView = 0.4 * w;
|
const int wView = qRound(0.4 * w);
|
||||||
ui->cb_OtherVersions->setMaximumWidth(wCb);
|
ui->cb_OtherVersions->setMaximumWidth(wCb);
|
||||||
ui->tv_Destination->setMinimumWidth(wView);
|
ui->tv_Destination->setMinimumWidth(wView);
|
||||||
ui->tv_Source->setMinimumWidth(wView);
|
ui->tv_Source->setMinimumWidth(wView);
|
||||||
|
|||||||
@@ -122,9 +122,9 @@ namespace BlackGui
|
|||||||
QStringList m_otherVersionDirs;
|
QStringList m_otherVersionDirs;
|
||||||
QString m_initializedSourceDir;
|
QString m_initializedSourceDir;
|
||||||
QString m_initializedDestinationDir;
|
QString m_initializedDestinationDir;
|
||||||
bool m_logCopiedFiles = true;
|
bool m_logCopiedFiles = true;
|
||||||
bool m_nameFilterDisables = false; //!< name filter disables or hides
|
bool m_nameFilterDisables = false; //!< name filter disables or hides
|
||||||
bool m_withBootstrapFile = false;
|
bool m_withBootstrapFile = false;
|
||||||
bool m_hasOtherSwiftVersions = false;
|
bool m_hasOtherSwiftVersions = false;
|
||||||
|
|
||||||
// caches will be explicitly initialized in initCaches
|
// caches will be explicitly initialized in initCaches
|
||||||
@@ -135,11 +135,11 @@ namespace BlackGui
|
|||||||
// those caches do not harm if they exists default initialized
|
// those caches do not harm if they exists default initialized
|
||||||
//! \fixme this is a workaround, as it creates files on disk even if those are not copied. It was much nicer if the cache would init themself if the file appears
|
//! \fixme this is a workaround, as it creates files on disk even if those are not copied. It was much nicer if the cache would init themself if the file appears
|
||||||
BlackMisc::CData<BlackMisc::Network::Data::TLastServer> m_lastServer { this }; //!< recently used server (VATSIM, other)
|
BlackMisc::CData<BlackMisc::Network::Data::TLastServer> m_lastServer { this }; //!< recently used server (VATSIM, other)
|
||||||
BlackMisc::CData<BlackMisc::Simulation::Data::TSimulatorLastSelection> m_modelSetCurrentSimulator { this };
|
BlackMisc::CData<BlackMisc::Simulation::Data::TSimulatorLastSelection> m_modelSetCurrentSimulator { this };
|
||||||
BlackMisc::CData<BlackMisc::Simulation::Data::TModelCacheLastSelection> m_modelsCurrentSimulator { this };
|
BlackMisc::CData<BlackMisc::Simulation::Data::TModelCacheLastSelection> m_modelsCurrentSimulator { this };
|
||||||
BlackMisc::CData<BlackMisc::Simulation::Data::TLastModel> m_lastAircraftModel { this }; //!< recently used aircraft model
|
BlackMisc::CData<BlackMisc::Simulation::Data::TLastModel> m_lastAircraftModel { this }; //!< recently used aircraft model
|
||||||
BlackMisc::CData<BlackCore::Data::TLauncherSetup> m_launcherSetup { this };
|
BlackMisc::CData<BlackCore::Data::TLauncherSetup> m_launcherSetup { this };
|
||||||
BlackMisc::CData<BlackCore::Data::TVatsimSetup> m_vatsimSetup { this };
|
BlackMisc::CData<BlackCore::Data::TVatsimSetup> m_vatsimSetup { this };
|
||||||
BlackMisc::CData<BlackCore::Data::TVatsimLastServer> m_lastVatsimServer { this }; //!< recently used VATSIM server
|
BlackMisc::CData<BlackCore::Data::TVatsimLastServer> m_lastVatsimServer { this }; //!< recently used VATSIM server
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -46,8 +46,8 @@ namespace BlackGui
|
|||||||
void CCopyModelsFromOtherSwiftVersionsComponent::copy()
|
void CCopyModelsFromOtherSwiftVersionsComponent::copy()
|
||||||
{
|
{
|
||||||
const CSimulatorInfo selectedSimulators = ui->comp_SimulatorSelector->getValue();
|
const CSimulatorInfo selectedSimulators = ui->comp_SimulatorSelector->getValue();
|
||||||
const QSet<CSimulatorInfo> sims = selectedSimulators.asSingleSimulatorSet();
|
const QSet<CSimulatorInfo> simulators = selectedSimulators.asSingleSimulatorSet();
|
||||||
if (sims.isEmpty())
|
if (simulators.isEmpty())
|
||||||
{
|
{
|
||||||
static const CStatusMessage m = CStatusMessage(this).validationError("No simulators selected");
|
static const CStatusMessage m = CStatusMessage(this).validationError("No simulators selected");
|
||||||
this->showOverlayMessage(m);
|
this->showOverlayMessage(m);
|
||||||
@@ -73,22 +73,22 @@ namespace BlackGui
|
|||||||
int sets = 0;
|
int sets = 0;
|
||||||
int caches = 0;
|
int caches = 0;
|
||||||
const CApplicationInfo otherVersion = ui->comp_OtherSwiftVersions->selectedOtherVersion();
|
const CApplicationInfo otherVersion = ui->comp_OtherSwiftVersions->selectedOtherVersion();
|
||||||
for (const CSimulatorInfo &sim : sims)
|
for (const CSimulatorInfo &simulator : simulators)
|
||||||
{
|
{
|
||||||
if (set)
|
if (set)
|
||||||
{
|
{
|
||||||
// inits current version cache
|
// inits current version cache
|
||||||
m_modelSetCaches.synchronizeCache(sim);
|
m_modelSetCaches.synchronizeCache(simulator);
|
||||||
|
|
||||||
// get file name
|
// get file name
|
||||||
CAircraftModelList otherSet;
|
CAircraftModelList otherSet;
|
||||||
const QString thisVersionModelSetFile = m_modelSetCaches.getFilename(sim);
|
const QString thisVersionModelSetFile = m_modelSetCaches.getFilename(simulator);
|
||||||
if (this->readDataFile(thisVersionModelSetFile, otherSet, otherVersion, sim) && !otherSet.isEmpty())
|
if (this->readDataFile(thisVersionModelSetFile, otherSet, otherVersion, simulator) && !otherSet.isEmpty())
|
||||||
{
|
{
|
||||||
CApplication::processEventsFor(250);
|
CApplication::processEventsFor(250);
|
||||||
if (this->confirmOverride(QString("Override model set for '%1'").arg(sim.toQString())))
|
if (this->confirmOverride(QString("Override model set for '%1'").arg(simulator.toQString())))
|
||||||
{
|
{
|
||||||
m_modelSetCaches.setModelsForSimulator(otherSet, sim);
|
m_modelSetCaches.setModelsForSimulator(otherSet, simulator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sets++;
|
sets++;
|
||||||
@@ -97,17 +97,17 @@ namespace BlackGui
|
|||||||
if (cache)
|
if (cache)
|
||||||
{
|
{
|
||||||
// inits current version cache
|
// inits current version cache
|
||||||
m_modelCaches.synchronizeCache(sim);
|
m_modelCaches.synchronizeCache(simulator);
|
||||||
|
|
||||||
// get file name
|
// get file name
|
||||||
CAircraftModelList otherCache;
|
CAircraftModelList otherCache;
|
||||||
const QString thisVersionModelCacheFile = m_modelCaches.getFilename(sim);
|
const QString thisVersionModelCacheFile = m_modelCaches.getFilename(simulator);
|
||||||
if (this->readDataFile(thisVersionModelCacheFile, otherCache, otherVersion, sim) && !otherCache.isEmpty())
|
if (this->readDataFile(thisVersionModelCacheFile, otherCache, otherVersion, simulator) && !otherCache.isEmpty())
|
||||||
{
|
{
|
||||||
CApplication::processEventsFor(250);
|
CApplication::processEventsFor(250);
|
||||||
if (this->confirmOverride(QString("Override model cache for '%1'").arg(sim.toQString())))
|
if (this->confirmOverride(QString("Override model cache for '%1'").arg(simulator.toQString())))
|
||||||
{
|
{
|
||||||
m_modelCaches.setModelsForSimulator(otherCache, sim);
|
m_modelCaches.setModelsForSimulator(otherCache, simulator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
caches++;
|
caches++;
|
||||||
@@ -186,6 +186,17 @@ namespace BlackGui
|
|||||||
ui->comp_SimulatorSelector->setValue(setSims);
|
ui->comp_SimulatorSelector->setValue(setSims);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CCopyModelsFromOtherSwiftVersionsComponent::reloadOtherVersions()
|
||||||
|
{
|
||||||
|
ui->comp_OtherSwiftVersions->reloadOtherVersions();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCopyModelsFromOtherSwiftVersionsWizardPage::initializePage()
|
||||||
|
{
|
||||||
|
// force reload as the other version could be changed
|
||||||
|
if (m_copyModels) { m_copyModels->reloadOtherVersions(); }
|
||||||
|
}
|
||||||
|
|
||||||
bool CCopyModelsFromOtherSwiftVersionsWizardPage::validatePage()
|
bool CCopyModelsFromOtherSwiftVersionsWizardPage::validatePage()
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(m_copyModels, Q_FUNC_INFO, "Missing widget");
|
Q_ASSERT_X(m_copyModels, Q_FUNC_INFO, "Missing widget");
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ namespace BlackGui
|
|||||||
//! Dtor
|
//! Dtor
|
||||||
virtual ~CCopyModelsFromOtherSwiftVersionsComponent();
|
virtual ~CCopyModelsFromOtherSwiftVersionsComponent();
|
||||||
|
|
||||||
|
//! Reload other versions
|
||||||
|
void reloadOtherVersions();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! Copy as per UI settings
|
//! Copy as per UI settings
|
||||||
void copy();
|
void copy();
|
||||||
@@ -54,7 +57,7 @@ namespace BlackGui
|
|||||||
QScopedPointer<Ui::CCopyModelsFromOtherSwiftVersionsComponent> ui;
|
QScopedPointer<Ui::CCopyModelsFromOtherSwiftVersionsComponent> ui;
|
||||||
|
|
||||||
// caches will be explicitly initialized in copy
|
// caches will be explicitly initialized in copy
|
||||||
BlackMisc::Simulation::Data::CModelCaches m_modelCaches { false, this };
|
BlackMisc::Simulation::Data::CModelCaches m_modelCaches { false, this };
|
||||||
BlackMisc::Simulation::Data::CModelSetCaches m_modelSetCaches { false, this };
|
BlackMisc::Simulation::Data::CModelSetCaches m_modelSetCaches { false, this };
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -70,6 +73,9 @@ namespace BlackGui
|
|||||||
//! Set config
|
//! Set config
|
||||||
void setConfigComponent(CCopyModelsFromOtherSwiftVersionsComponent *config) { m_copyModels = config; }
|
void setConfigComponent(CCopyModelsFromOtherSwiftVersionsComponent *config) { m_copyModels = config; }
|
||||||
|
|
||||||
|
//! \copydoc QWizardPage::initializePage
|
||||||
|
virtual void initializePage() override;
|
||||||
|
|
||||||
//! \copydoc QWizardPage::validatePage
|
//! \copydoc QWizardPage::validatePage
|
||||||
virtual bool validatePage() override;
|
virtual bool validatePage() override;
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,11 @@ namespace BlackGui
|
|||||||
CCopySettingsAndCachesComponent::~CCopySettingsAndCachesComponent()
|
CCopySettingsAndCachesComponent::~CCopySettingsAndCachesComponent()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
void CCopySettingsAndCachesComponent::reloadOtherVersions()
|
||||||
|
{
|
||||||
|
ui->comp_OtherSwiftVersions->reloadOtherVersions();
|
||||||
|
}
|
||||||
|
|
||||||
void CCopySettingsAndCachesComponent::onOtherVersionChanged(const CApplicationInfo &info)
|
void CCopySettingsAndCachesComponent::onOtherVersionChanged(const CApplicationInfo &info)
|
||||||
{
|
{
|
||||||
readOnlyCheckbox(ui->cb_SettingsAudio, !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsAudio.getFilename()));
|
readOnlyCheckbox(ui->cb_SettingsAudio, !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsAudio.getFilename()));
|
||||||
@@ -396,7 +401,7 @@ namespace BlackGui
|
|||||||
if (copied > 0)
|
if (copied > 0)
|
||||||
{
|
{
|
||||||
const CStatusMessage m = CStatusMessage(this).validationInfo("Copied %1 settings") << copied;
|
const CStatusMessage m = CStatusMessage(this).validationInfo("Copied %1 settings") << copied;
|
||||||
this->showOverlayMessage(m);
|
this->showOverlayHTMLMessage(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
return copied;
|
return copied;
|
||||||
@@ -469,6 +474,12 @@ namespace BlackGui
|
|||||||
return setting ? s.arg(text) : c.arg(text);
|
return setting ? s.arg(text) : c.arg(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CCopySettingsAndCachesWizardPage::initializePage()
|
||||||
|
{
|
||||||
|
// re-init other versions
|
||||||
|
if (m_copyCachesAndSettings) { m_copyCachesAndSettings->reloadOtherVersions(); }
|
||||||
|
}
|
||||||
|
|
||||||
bool CCopySettingsAndCachesWizardPage::validatePage()
|
bool CCopySettingsAndCachesWizardPage::validatePage()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -57,6 +57,9 @@ namespace BlackGui
|
|||||||
//! Dtor
|
//! Dtor
|
||||||
virtual ~CCopySettingsAndCachesComponent();
|
virtual ~CCopySettingsAndCachesComponent();
|
||||||
|
|
||||||
|
//! Reload other versions
|
||||||
|
void reloadOtherVersions();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! Other version has been changed
|
//! Other version has been changed
|
||||||
void onOtherVersionChanged(const BlackMisc::CApplicationInfo &info);
|
void onOtherVersionChanged(const BlackMisc::CApplicationInfo &info);
|
||||||
@@ -111,14 +114,14 @@ namespace BlackGui
|
|||||||
|
|
||||||
QScopedPointer<Ui::CCopySettingsAndCachesComponent> ui;
|
QScopedPointer<Ui::CCopySettingsAndCachesComponent> ui;
|
||||||
|
|
||||||
BlackMisc::CSetting<BlackCore::Audio::TInputDevice> m_settingsAudioInputDevice { this };
|
BlackMisc::CSetting<BlackCore::Audio::TInputDevice> m_settingsAudioInputDevice { this };
|
||||||
BlackMisc::CSetting<BlackCore::Audio::TOutputDevice> m_settingsAudioOutputDevice { this };
|
BlackMisc::CSetting<BlackCore::Audio::TOutputDevice> m_settingsAudioOutputDevice { this };
|
||||||
BlackMisc::CSetting<Settings::TGeneralGui> m_settingsGuiGeneral { this };
|
BlackMisc::CSetting<Settings::TGeneralGui> m_settingsGuiGeneral { this };
|
||||||
BlackMisc::CSetting<Settings::TDockWidget> m_settingsDockWidget { this };
|
BlackMisc::CSetting<Settings::TDockWidget> m_settingsDockWidget { this };
|
||||||
BlackMisc::CSetting<Settings::TViewUpdateSettings> m_settingsViewUpdate { this };
|
BlackMisc::CSetting<Settings::TViewUpdateSettings> m_settingsViewUpdate { this };
|
||||||
BlackMisc::CSetting<Settings::TBackgroundConsolidation> m_settingsConsolidation { this }; //!< consolidation time
|
BlackMisc::CSetting<Settings::TBackgroundConsolidation> m_settingsConsolidation { this }; //!< consolidation time
|
||||||
BlackMisc::CSetting<Settings::TAtcStationsSettings> m_settingsAtcStations { this };
|
BlackMisc::CSetting<Settings::TAtcStationsSettings> m_settingsAtcStations { this };
|
||||||
BlackMisc::CSetting<Settings::TextMessageSettings> m_settingsTextMessage { this };
|
BlackMisc::CSetting<Settings::TextMessageSettings> m_settingsTextMessage { this };
|
||||||
BlackMisc::CSetting<BlackCore::Application::TEnabledSimulators> m_settingsEnabledSimulators { this };
|
BlackMisc::CSetting<BlackCore::Application::TEnabledSimulators> m_settingsEnabledSimulators { this };
|
||||||
BlackMisc::CSetting<BlackCore::Application::TActionHotkeys> m_settingsActionHotkeys { this };
|
BlackMisc::CSetting<BlackCore::Application::TActionHotkeys> m_settingsActionHotkeys { this };
|
||||||
BlackMisc::CSetting<BlackCore::Audio::TSettings> m_settingsAudio { this };
|
BlackMisc::CSetting<BlackCore::Audio::TSettings> m_settingsAudio { this };
|
||||||
@@ -127,7 +130,7 @@ namespace BlackGui
|
|||||||
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TSimulatorFsx> m_settingsSimulatorFsx { this }; //!< FSX settings
|
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TSimulatorFsx> m_settingsSimulatorFsx { this }; //!< FSX settings
|
||||||
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TSimulatorFs9> m_settingsSimulatorFs9 { this }; //!< FS9 settings
|
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TSimulatorFs9> m_settingsSimulatorFs9 { this }; //!< FS9 settings
|
||||||
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TSimulatorP3D> m_settingsSimulatorP3D { this }; //!< P3D settings
|
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TSimulatorP3D> m_settingsSimulatorP3D { this }; //!< P3D settings
|
||||||
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TSimulatorXP> m_settingsSimulatorXPlane { this }; //!< XP settings
|
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TSimulatorXP> m_settingsSimulatorXPlane { this }; //!< XP settings
|
||||||
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TModel> m_settingsModel { this }; //!< model setting
|
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TModel> m_settingsModel { this }; //!< model setting
|
||||||
|
|
||||||
BlackMisc::CData<BlackCore::Data::TVatsimLastServer> m_cacheLastVatsimServer { this }; //!< recently used VATSIM server
|
BlackMisc::CData<BlackCore::Data::TVatsimLastServer> m_cacheLastVatsimServer { this }; //!< recently used VATSIM server
|
||||||
@@ -151,6 +154,9 @@ namespace BlackGui
|
|||||||
//! Set config
|
//! Set config
|
||||||
void setConfigComponent(CCopySettingsAndCachesComponent *config) { m_copyCachesAndSettings = config; }
|
void setConfigComponent(CCopySettingsAndCachesComponent *config) { m_copyCachesAndSettings = config; }
|
||||||
|
|
||||||
|
//! \copydoc QWizardPage::initializePage
|
||||||
|
virtual void initializePage() override;
|
||||||
|
|
||||||
//! \copydoc QWizardPage::validatePage
|
//! \copydoc QWizardPage::validatePage
|
||||||
virtual bool validatePage() override;
|
virtual bool validatePage() override;
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
connect(ui->tb_DataDir, &QToolButton::clicked, this, &COtherSwiftVersionsComponent::openDataDirectory);
|
connect(ui->tb_DataDir, &QToolButton::clicked, this, &COtherSwiftVersionsComponent::openDataDirectory);
|
||||||
connect(ui->tvp_ApplicationInfo, &CApplicationInfoView::objectSelected, this, &COtherSwiftVersionsComponent::onObjectSelected);
|
connect(ui->tvp_ApplicationInfo, &CApplicationInfoView::objectSelected, this, &COtherSwiftVersionsComponent::onObjectSelected);
|
||||||
connect(ui->tvp_ApplicationInfo, &CApplicationInfoView::requestUpdate, this, &COtherSwiftVersionsComponent::reloadVersions);
|
connect(ui->tvp_ApplicationInfo, &CApplicationInfoView::requestUpdate, this, &COtherSwiftVersionsComponent::reloadOtherVersions);
|
||||||
}
|
}
|
||||||
|
|
||||||
COtherSwiftVersionsComponent::~COtherSwiftVersionsComponent()
|
COtherSwiftVersionsComponent::~COtherSwiftVersionsComponent()
|
||||||
@@ -53,9 +53,9 @@ namespace BlackGui
|
|||||||
return ui->tvp_ApplicationInfo->selectedObject();
|
return ui->tvp_ApplicationInfo->selectedObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
void COtherSwiftVersionsComponent::reloadVersions()
|
void COtherSwiftVersionsComponent::reloadOtherVersions()
|
||||||
{
|
{
|
||||||
ui->tvp_ApplicationInfo->otherSwiftVersionsFromDataDirectories();
|
ui->tvp_ApplicationInfo->otherSwiftVersionsFromDataDirectories(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void COtherSwiftVersionsComponent::openDataDirectory()
|
void COtherSwiftVersionsComponent::openDataDirectory()
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ namespace BlackGui
|
|||||||
//! Get the selected other version
|
//! Get the selected other version
|
||||||
BlackMisc::CApplicationInfo selectedOtherVersion() const;
|
BlackMisc::CApplicationInfo selectedOtherVersion() const;
|
||||||
|
|
||||||
|
//! Reload versions
|
||||||
|
void reloadOtherVersions();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! Selection changed
|
//! Selection changed
|
||||||
void versionChanged(const BlackMisc::CApplicationInfo &info);
|
void versionChanged(const BlackMisc::CApplicationInfo &info);
|
||||||
@@ -48,9 +51,6 @@ namespace BlackGui
|
|||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::COtherSwiftVersionsComponent> ui;
|
QScopedPointer<Ui::COtherSwiftVersionsComponent> ui;
|
||||||
|
|
||||||
//! Reload versions
|
|
||||||
void reloadVersions();
|
|
||||||
|
|
||||||
//! Data directory
|
//! Data directory
|
||||||
void openDataDirectory();
|
void openDataDirectory();
|
||||||
|
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ namespace BlackGui
|
|||||||
this->setCustomMenu(new CApplicationInfoMenu(this));
|
this->setCustomMenu(new CApplicationInfoMenu(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
int CApplicationInfoView::otherSwiftVersionsFromDataDirectories()
|
int CApplicationInfoView::otherSwiftVersionsFromDataDirectories(bool reInit)
|
||||||
{
|
{
|
||||||
const CApplicationInfoList others = CApplicationInfoList::fromOtherSwiftVersionsFromDataDirectories();
|
const CApplicationInfoList others = CApplicationInfoList::fromOtherSwiftVersionsFromDataDirectories(reInit);
|
||||||
this->updateContainer(others);
|
this->updateContainer(others);
|
||||||
m_acceptRowSelection = (others.size() > 0);
|
m_acceptRowSelection = (others.size() > 0);
|
||||||
return others.size();
|
return others.size();
|
||||||
@@ -53,7 +53,7 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (deletedDirectories.isEmpty()) { return; }
|
if (deletedDirectories.isEmpty()) { return; }
|
||||||
this->otherSwiftVersionsFromDataDirectories();
|
this->otherSwiftVersionsFromDataDirectories(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CApplicationInfoMenu::customMenu(CMenuActions &menuActions)
|
void CApplicationInfoMenu::customMenu(CMenuActions &menuActions)
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace BlackGui
|
|||||||
explicit CApplicationInfoView(QWidget *parent = nullptr);
|
explicit CApplicationInfoView(QWidget *parent = nullptr);
|
||||||
|
|
||||||
//! BlackMisc::CApplicationInfoList::otherSwiftVersionsFromDataDirectories
|
//! BlackMisc::CApplicationInfoList::otherSwiftVersionsFromDataDirectories
|
||||||
int otherSwiftVersionsFromDataDirectories();
|
int otherSwiftVersionsFromDataDirectories(bool reInit = false);
|
||||||
|
|
||||||
//! Delete the selected directories
|
//! Delete the selected directories
|
||||||
void deleteSelectedDataDirectories();
|
void deleteSelectedDataDirectories();
|
||||||
|
|||||||
@@ -45,7 +45,10 @@ namespace BlackMisc
|
|||||||
int CApplicationInfoList::otherSwiftVersionsFromDataDirectories(bool reinit)
|
int CApplicationInfoList::otherSwiftVersionsFromDataDirectories(bool reinit)
|
||||||
{
|
{
|
||||||
this->clear();
|
this->clear();
|
||||||
const QMap<QString, CApplicationInfo> otherVersions = CDirectoryUtils::applicationDataDirectoryMapWithoutCurrentVersion(reinit);
|
const QMap<QString, CApplicationInfo> otherVersions = reinit ?
|
||||||
|
CDirectoryUtils::currentApplicationDataDirectoryMapWithoutCurrentVersion() :
|
||||||
|
CDirectoryUtils::applicationDataDirectoryMapWithoutCurrentVersion();
|
||||||
|
|
||||||
for (const QString &directory : otherVersions.keys())
|
for (const QString &directory : otherVersions.keys())
|
||||||
{
|
{
|
||||||
CApplicationInfo info(otherVersions.value(directory));
|
CApplicationInfo info(otherVersions.value(directory));
|
||||||
|
|||||||
@@ -117,15 +117,17 @@ namespace BlackMisc
|
|||||||
|
|
||||||
const QFileInfoList &CDirectoryUtils::applicationDataDirectories()
|
const QFileInfoList &CDirectoryUtils::applicationDataDirectories()
|
||||||
{
|
{
|
||||||
static const QFileInfoList fileInfoList([]
|
static QFileInfoList fileInfoList = currentApplicationDataDirectories();
|
||||||
{
|
|
||||||
const QDir swiftAppData(CDirectoryUtils::applicationDataDirectory()); // contains 1..n subdirs
|
|
||||||
if (!swiftAppData.isReadable()) { return QFileInfoList(); }
|
|
||||||
return swiftAppData.entryInfoList({}, QDir::Dirs | QDir::NoDotAndDotDot, QDir::Time);
|
|
||||||
}());
|
|
||||||
return fileInfoList;
|
return fileInfoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QFileInfoList CDirectoryUtils::currentApplicationDataDirectories()
|
||||||
|
{
|
||||||
|
const QDir swiftAppData(CDirectoryUtils::applicationDataDirectory()); // contains 1..n subdirs
|
||||||
|
if (!swiftAppData.isReadable()) { return QFileInfoList(); }
|
||||||
|
return swiftAppData.entryInfoList({}, QDir::Dirs | QDir::NoDotAndDotDot, QDir::Time);
|
||||||
|
}
|
||||||
|
|
||||||
int CDirectoryUtils::applicationDataDirectoriesCount()
|
int CDirectoryUtils::applicationDataDirectoriesCount()
|
||||||
{
|
{
|
||||||
return CDirectoryUtils::applicationDataDirectories().size();
|
return CDirectoryUtils::applicationDataDirectories().size();
|
||||||
@@ -144,14 +146,18 @@ namespace BlackMisc
|
|||||||
return dirs;
|
return dirs;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CDirectoryUtils::FilePerApplication &CDirectoryUtils::applicationDataDirectoryMapWithoutCurrentVersion(bool reinit)
|
const CDirectoryUtils::FilePerApplication &CDirectoryUtils::applicationDataDirectoryMapWithoutCurrentVersion()
|
||||||
{
|
{
|
||||||
static FilePerApplication dirs;
|
static const FilePerApplication directories = currentApplicationDataDirectoryMapWithoutCurrentVersion();
|
||||||
if (!reinit && !dirs.isEmpty()) { return dirs; }
|
return directories;
|
||||||
|
}
|
||||||
|
|
||||||
|
CDirectoryUtils::FilePerApplication CDirectoryUtils::currentApplicationDataDirectoryMapWithoutCurrentVersion()
|
||||||
|
{
|
||||||
FilePerApplication directories;
|
FilePerApplication directories;
|
||||||
for (const QFileInfo &info : CDirectoryUtils::applicationDataDirectories())
|
for (const QFileInfo &info : CDirectoryUtils::currentApplicationDataDirectories())
|
||||||
{
|
{
|
||||||
|
// check for myself (the running swift)
|
||||||
if (caseInsensitiveStringCompare(info.filePath(), CDirectoryUtils::normalizedApplicationDataDirectory())) { continue; }
|
if (caseInsensitiveStringCompare(info.filePath(), CDirectoryUtils::normalizedApplicationDataDirectory())) { continue; }
|
||||||
|
|
||||||
// the application info will be written by each swift application started
|
// the application info will be written by each swift application started
|
||||||
@@ -161,6 +167,7 @@ namespace BlackMisc
|
|||||||
CApplicationInfo appInfo;
|
CApplicationInfo appInfo;
|
||||||
if (appInfoJson.isEmpty())
|
if (appInfoJson.isEmpty())
|
||||||
{
|
{
|
||||||
|
// no JSON means the app no longer exists
|
||||||
const QString exeDir = CDirectoryUtils::decodeNormalizedDirectory(info.filePath());
|
const QString exeDir = CDirectoryUtils::decodeNormalizedDirectory(info.filePath());
|
||||||
appInfo.setExecutablePath(exeDir);
|
appInfo.setExecutablePath(exeDir);
|
||||||
}
|
}
|
||||||
@@ -172,13 +179,12 @@ namespace BlackMisc
|
|||||||
directories.insert(info.filePath(), appInfo);
|
directories.insert(info.filePath(), appInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
dirs = directories;
|
return directories;
|
||||||
return dirs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CDirectoryUtils::hasOtherSwiftDataDirectories(bool reinit)
|
bool CDirectoryUtils::hasOtherSwiftDataDirectories()
|
||||||
{
|
{
|
||||||
return CDirectoryUtils::applicationDataDirectoryMapWithoutCurrentVersion(reinit).size() > 0;
|
return CDirectoryUtils::applicationDataDirectoryMapWithoutCurrentVersion().size() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &CDirectoryUtils::normalizedApplicationDataDirectory()
|
const QString &CDirectoryUtils::normalizedApplicationDataDirectory()
|
||||||
|
|||||||
@@ -58,14 +58,20 @@ namespace BlackMisc
|
|||||||
//! number of data directories (including this version)
|
//! number of data directories (including this version)
|
||||||
static int applicationDataDirectoriesCount();
|
static int applicationDataDirectoriesCount();
|
||||||
|
|
||||||
|
//! swift application data sub directories
|
||||||
|
static QFileInfoList currentApplicationDataDirectories();
|
||||||
|
|
||||||
//! swift application data sub directories
|
//! swift application data sub directories
|
||||||
static QStringList applicationDataDirectoryList(bool withoutCurrent = false, bool decodedDirName = false);
|
static QStringList applicationDataDirectoryList(bool withoutCurrent = false, bool decodedDirName = false);
|
||||||
|
|
||||||
//! swift application data sub directories with info if available
|
//! swift application data sub directories with info if available
|
||||||
static const FilePerApplication &applicationDataDirectoryMapWithoutCurrentVersion(bool reinit = false);
|
static const FilePerApplication &applicationDataDirectoryMapWithoutCurrentVersion();
|
||||||
|
|
||||||
|
//! swift application data sub directories with info if available
|
||||||
|
static FilePerApplication currentApplicationDataDirectoryMapWithoutCurrentVersion();
|
||||||
|
|
||||||
//! Other swift data directories
|
//! Other swift data directories
|
||||||
static bool hasOtherSwiftDataDirectories(bool reinit = false);
|
static bool hasOtherSwiftDataDirectories();
|
||||||
|
|
||||||
//! Is MacOS application bundle?
|
//! Is MacOS application bundle?
|
||||||
//! \remark: Means the currently running executable is a MacOS bundle, but not all our executables are bundles on MacOS
|
//! \remark: Means the currently running executable is a MacOS bundle, but not all our executables are bundles on MacOS
|
||||||
|
|||||||
Reference in New Issue
Block a user