diff --git a/src/blackgui/components/configurationwizard.cpp b/src/blackgui/components/configurationwizard.cpp index e2f22e9be..dfb58b914 100644 --- a/src/blackgui/components/configurationwizard.cpp +++ b/src/blackgui/components/configurationwizard.cpp @@ -30,6 +30,7 @@ namespace BlackGui this->setWindowFlags(windowFlags() | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint); ui->wp_CopyModels->setConfigComponent(ui->comp_CopyModels); + ui->wp_CopySettingsAndCaches->setConfigComponent(ui->comp_CopySettingsAndCachesComponent); ui->wp_Simulator->setConfigComponent(ui->comp_Simulator); ui->wp_SimulatorSpecific->setConfigComponent(ui->comp_InstallXSwiftBus, ui->comp_InstallFsxTerrainProbe); ui->wp_DataLoad->setConfigComponent(ui->comp_DataLoad); diff --git a/src/blackgui/components/copymodelsfromotherswiftversionscomponent.cpp b/src/blackgui/components/copymodelsfromotherswiftversionscomponent.cpp index 275e7882e..ef2e73869 100644 --- a/src/blackgui/components/copymodelsfromotherswiftversionscomponent.cpp +++ b/src/blackgui/components/copymodelsfromotherswiftversionscomponent.cpp @@ -16,6 +16,7 @@ #include "blackmisc/directoryutils.h" #include +#include #include #include @@ -182,15 +183,15 @@ namespace BlackGui ui->comp_SimulatorSelector->setValue(setSims); } - void CCopyModelsFromOtherSwiftVersionsComponent::reloadOtherVersions() + void CCopyModelsFromOtherSwiftVersionsComponent::reloadOtherVersions(int deferMs) { - ui->comp_OtherSwiftVersions->reloadOtherVersions(); + ui->comp_OtherSwiftVersions->reloadOtherVersionsDeferred(deferMs); } void CCopyModelsFromOtherSwiftVersionsWizardPage::initializePage() { // force reload as the other version could be changed - if (m_copyModels) { m_copyModels->reloadOtherVersions(); } + if (m_copyModels) { m_copyModels->reloadOtherVersions(1000); } } bool CCopyModelsFromOtherSwiftVersionsWizardPage::validatePage() diff --git a/src/blackgui/components/copymodelsfromotherswiftversionscomponent.h b/src/blackgui/components/copymodelsfromotherswiftversionscomponent.h index 3d137978d..cc53f76ae 100644 --- a/src/blackgui/components/copymodelsfromotherswiftversionscomponent.h +++ b/src/blackgui/components/copymodelsfromotherswiftversionscomponent.h @@ -39,7 +39,7 @@ namespace BlackGui virtual ~CCopyModelsFromOtherSwiftVersionsComponent(); //! Reload other versions - void reloadOtherVersions(); + void reloadOtherVersions(int deferMs = -1); private: //! Copy as per UI settings diff --git a/src/blackgui/components/copysettingsandcachescomponent.cpp b/src/blackgui/components/copysettingsandcachescomponent.cpp index a41d5ec39..f826efae9 100644 --- a/src/blackgui/components/copysettingsandcachescomponent.cpp +++ b/src/blackgui/components/copysettingsandcachescomponent.cpp @@ -53,9 +53,9 @@ namespace BlackGui CCopySettingsAndCachesComponent::~CCopySettingsAndCachesComponent() { } - void CCopySettingsAndCachesComponent::reloadOtherVersions() + void CCopySettingsAndCachesComponent::reloadOtherVersions(int deferMs) { - ui->comp_OtherSwiftVersions->reloadOtherVersions(); + ui->comp_OtherSwiftVersions->reloadOtherVersionsDeferred(deferMs); } void CCopySettingsAndCachesComponent::onOtherVersionChanged(const CApplicationInfo &info) @@ -475,7 +475,7 @@ namespace BlackGui void CCopySettingsAndCachesWizardPage::initializePage() { // re-init other versions - if (m_copyCachesAndSettings) { m_copyCachesAndSettings->reloadOtherVersions(); } + if (m_copyCachesAndSettings) { m_copyCachesAndSettings->reloadOtherVersions(1000); } } bool CCopySettingsAndCachesWizardPage::validatePage() diff --git a/src/blackgui/components/copysettingsandcachescomponent.h b/src/blackgui/components/copysettingsandcachescomponent.h index 977f6b951..6032606f3 100644 --- a/src/blackgui/components/copysettingsandcachescomponent.h +++ b/src/blackgui/components/copysettingsandcachescomponent.h @@ -58,7 +58,7 @@ namespace BlackGui virtual ~CCopySettingsAndCachesComponent(); //! Reload other versions - void reloadOtherVersions(); + void reloadOtherVersions(int deferMs = -1); private: //! Other version has been changed diff --git a/src/blackgui/components/otherswiftversionscomponent.cpp b/src/blackgui/components/otherswiftversionscomponent.cpp index bdb29fdde..5f2217055 100644 --- a/src/blackgui/components/otherswiftversionscomponent.cpp +++ b/src/blackgui/components/otherswiftversionscomponent.cpp @@ -29,8 +29,8 @@ namespace BlackGui ui->tvp_ApplicationInfo->menuRemoveItems(CApplicationInfoView::MenuClear); ui->tvp_ApplicationInfo->menuAddItems(CApplicationInfoView::MenuRefresh); - ui->tvp_ApplicationInfo->otherSwiftVersionsFromDataDirectories(); + ui->le_ThisVersion->setText(sGui->getApplicationInfo().asOtherSwiftVersionString()); ui->le_ThisVersion->home(false); @@ -47,15 +47,26 @@ namespace BlackGui return (ui->tvp_ApplicationInfo->hasSelection()); } - BlackMisc::CApplicationInfo COtherSwiftVersionsComponent::selectedOtherVersion() const + CApplicationInfo COtherSwiftVersionsComponent::selectedOtherVersion() const { if (!this->hasSelection()) { return CApplicationInfo::null(); } return ui->tvp_ApplicationInfo->selectedObject(); } - void COtherSwiftVersionsComponent::reloadOtherVersions() + void COtherSwiftVersionsComponent::reloadOtherVersionsDeferred(int deferMs) { - ui->tvp_ApplicationInfo->otherSwiftVersionsFromDataDirectories(true); + if (deferMs <= 0) + { + ui->tvp_ApplicationInfo->otherSwiftVersionsFromDataDiretoriesAndResize(true); + } + else + { + QPointer myself(this); + QTimer::singleShot(deferMs, this, [ = ] + { + if (myself) { myself->reloadOtherVersionsDeferred(-1); } + }); + } } void COtherSwiftVersionsComponent::openDataDirectory() diff --git a/src/blackgui/components/otherswiftversionscomponent.h b/src/blackgui/components/otherswiftversionscomponent.h index 8f8c02940..e64fd7d51 100644 --- a/src/blackgui/components/otherswiftversionscomponent.h +++ b/src/blackgui/components/otherswiftversionscomponent.h @@ -41,8 +41,11 @@ namespace BlackGui //! Get the selected other version BlackMisc::CApplicationInfo selectedOtherVersion() const; + //! Reload other versions + void reloadOtherVersions() { this->reloadOtherVersionsDeferred(0); } + //! Reload versions - void reloadOtherVersions(); + void reloadOtherVersionsDeferred(int deferMs); signals: //! Selection changed diff --git a/src/blackgui/models/applicationinfolistmodel.cpp b/src/blackgui/models/applicationinfolistmodel.cpp index eef5e89e9..e86407007 100644 --- a/src/blackgui/models/applicationinfolistmodel.cpp +++ b/src/blackgui/models/applicationinfolistmodel.cpp @@ -31,9 +31,9 @@ namespace BlackGui m_columns.addColumn(CColumn::standardString("version", CApplicationInfo::IndexVersionString)); m_columns.addColumn(CColumn::standardString("OS", CApplicationInfo::IndexPlatformInfo)); m_columns.addColumn(CColumn::standardString("exe.path", CApplicationInfo::IndexExecutablePath)); - m_columns.addColumn(CColumn("e.?", "existing?", CApplicationInfo::IndexExecutablePathExisting, - new CBoolIconFormatter("directory existing", "directory not existing"))); + m_columns.addColumn(CColumn("e.?", "existing?", CApplicationInfo::IndexExecutablePathExisting, new CBoolIconFormatter("directory existing", "directory not existing"))); m_columns.addColumn(CColumn::standardString("data.path", CApplicationInfo::IndexApplicationDataPath)); + m_columns.setWidthPercentages({10, 10, 30, 5, 30}); // default sort order this->setSortColumnByPropertyIndex(CApplicationInfo::IndexVersionString); diff --git a/src/blackgui/views/applicationinfoview.cpp b/src/blackgui/views/applicationinfoview.cpp index 2f1defe98..5ddfdea7f 100644 --- a/src/blackgui/views/applicationinfoview.cpp +++ b/src/blackgui/views/applicationinfoview.cpp @@ -27,14 +27,23 @@ namespace BlackGui this->setCustomMenu(new CApplicationInfoMenu(this)); } - int CApplicationInfoView::otherSwiftVersionsFromDataDirectories(bool reInit) + int CApplicationInfoView::otherSwiftVersionsFromDataDirectories(bool reinitOtherVersions) { - const CApplicationInfoList others = CApplicationInfoList::fromOtherSwiftVersionsFromDataDirectories(reInit); - this->updateContainer(others); + const CApplicationInfoList others = CApplicationInfoList::fromOtherSwiftVersionsFromDataDirectories(reinitOtherVersions); m_acceptRowSelection = (others.size() > 0); + + this->updateContainer(others); return others.size(); } + int CApplicationInfoView::otherSwiftVersionsFromDataDiretoriesAndResize(bool reinitOtherVersion) + { + const int r = this->otherSwiftVersionsFromDataDirectories(reinitOtherVersion); + this->setPercentageColumnWidths(); + this->resizeRowsToContents(); + return r; + } + void CApplicationInfoView::deleteSelectedDataDirectories() { if (!this->hasSelection()) { return; } diff --git a/src/blackgui/views/applicationinfoview.h b/src/blackgui/views/applicationinfoview.h index 9e05ed6e6..13020dee1 100644 --- a/src/blackgui/views/applicationinfoview.h +++ b/src/blackgui/views/applicationinfoview.h @@ -33,7 +33,10 @@ namespace BlackGui explicit CApplicationInfoView(QWidget *parent = nullptr); //! BlackMisc::CApplicationInfoList::otherSwiftVersionsFromDataDirectories - int otherSwiftVersionsFromDataDirectories(bool reInit = false); + int otherSwiftVersionsFromDataDirectories(bool reinitOtherVersions = false); + + //! Display versions and resize + int otherSwiftVersionsFromDataDiretoriesAndResize(bool reinitOtherVersion = false); //! Delete the selected directories void deleteSelectedDataDirectories();