Resize columns of "other swift versions" to percentage

This commit is contained in:
Klaus Basan
2018-12-26 01:06:07 +01:00
committed by Mat Sutcliffe
parent 7baf5f238e
commit 48b18c7acd
10 changed files with 47 additions and 19 deletions

View File

@@ -30,6 +30,7 @@ namespace BlackGui
this->setWindowFlags(windowFlags() | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint); this->setWindowFlags(windowFlags() | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint);
ui->wp_CopyModels->setConfigComponent(ui->comp_CopyModels); ui->wp_CopyModels->setConfigComponent(ui->comp_CopyModels);
ui->wp_CopySettingsAndCaches->setConfigComponent(ui->comp_CopySettingsAndCachesComponent);
ui->wp_Simulator->setConfigComponent(ui->comp_Simulator); ui->wp_Simulator->setConfigComponent(ui->comp_Simulator);
ui->wp_SimulatorSpecific->setConfigComponent(ui->comp_InstallXSwiftBus, ui->comp_InstallFsxTerrainProbe); ui->wp_SimulatorSpecific->setConfigComponent(ui->comp_InstallXSwiftBus, ui->comp_InstallFsxTerrainProbe);
ui->wp_DataLoad->setConfigComponent(ui->comp_DataLoad); ui->wp_DataLoad->setConfigComponent(ui->comp_DataLoad);

View File

@@ -16,6 +16,7 @@
#include "blackmisc/directoryutils.h" #include "blackmisc/directoryutils.h"
#include <QSet> #include <QSet>
#include <QPointer>
#include <QFileInfo> #include <QFileInfo>
#include <QMessageBox> #include <QMessageBox>
@@ -182,15 +183,15 @@ namespace BlackGui
ui->comp_SimulatorSelector->setValue(setSims); 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() void CCopyModelsFromOtherSwiftVersionsWizardPage::initializePage()
{ {
// force reload as the other version could be changed // 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() bool CCopyModelsFromOtherSwiftVersionsWizardPage::validatePage()

View File

@@ -39,7 +39,7 @@ namespace BlackGui
virtual ~CCopyModelsFromOtherSwiftVersionsComponent(); virtual ~CCopyModelsFromOtherSwiftVersionsComponent();
//! Reload other versions //! Reload other versions
void reloadOtherVersions(); void reloadOtherVersions(int deferMs = -1);
private: private:
//! Copy as per UI settings //! Copy as per UI settings

View File

@@ -53,9 +53,9 @@ namespace BlackGui
CCopySettingsAndCachesComponent::~CCopySettingsAndCachesComponent() 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) void CCopySettingsAndCachesComponent::onOtherVersionChanged(const CApplicationInfo &info)
@@ -475,7 +475,7 @@ namespace BlackGui
void CCopySettingsAndCachesWizardPage::initializePage() void CCopySettingsAndCachesWizardPage::initializePage()
{ {
// re-init other versions // re-init other versions
if (m_copyCachesAndSettings) { m_copyCachesAndSettings->reloadOtherVersions(); } if (m_copyCachesAndSettings) { m_copyCachesAndSettings->reloadOtherVersions(1000); }
} }
bool CCopySettingsAndCachesWizardPage::validatePage() bool CCopySettingsAndCachesWizardPage::validatePage()

View File

@@ -58,7 +58,7 @@ namespace BlackGui
virtual ~CCopySettingsAndCachesComponent(); virtual ~CCopySettingsAndCachesComponent();
//! Reload other versions //! Reload other versions
void reloadOtherVersions(); void reloadOtherVersions(int deferMs = -1);
private: private:
//! Other version has been changed //! Other version has been changed

View File

@@ -29,8 +29,8 @@ namespace BlackGui
ui->tvp_ApplicationInfo->menuRemoveItems(CApplicationInfoView::MenuClear); ui->tvp_ApplicationInfo->menuRemoveItems(CApplicationInfoView::MenuClear);
ui->tvp_ApplicationInfo->menuAddItems(CApplicationInfoView::MenuRefresh); ui->tvp_ApplicationInfo->menuAddItems(CApplicationInfoView::MenuRefresh);
ui->tvp_ApplicationInfo->otherSwiftVersionsFromDataDirectories(); ui->tvp_ApplicationInfo->otherSwiftVersionsFromDataDirectories();
ui->le_ThisVersion->setText(sGui->getApplicationInfo().asOtherSwiftVersionString()); ui->le_ThisVersion->setText(sGui->getApplicationInfo().asOtherSwiftVersionString());
ui->le_ThisVersion->home(false); ui->le_ThisVersion->home(false);
@@ -47,15 +47,26 @@ namespace BlackGui
return (ui->tvp_ApplicationInfo->hasSelection()); return (ui->tvp_ApplicationInfo->hasSelection());
} }
BlackMisc::CApplicationInfo COtherSwiftVersionsComponent::selectedOtherVersion() const CApplicationInfo COtherSwiftVersionsComponent::selectedOtherVersion() const
{ {
if (!this->hasSelection()) { return CApplicationInfo::null(); } if (!this->hasSelection()) { return CApplicationInfo::null(); }
return ui->tvp_ApplicationInfo->selectedObject(); 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<COtherSwiftVersionsComponent> myself(this);
QTimer::singleShot(deferMs, this, [ = ]
{
if (myself) { myself->reloadOtherVersionsDeferred(-1); }
});
}
} }
void COtherSwiftVersionsComponent::openDataDirectory() void COtherSwiftVersionsComponent::openDataDirectory()

View File

@@ -41,8 +41,11 @@ namespace BlackGui
//! Get the selected other version //! Get the selected other version
BlackMisc::CApplicationInfo selectedOtherVersion() const; BlackMisc::CApplicationInfo selectedOtherVersion() const;
//! Reload other versions
void reloadOtherVersions() { this->reloadOtherVersionsDeferred(0); }
//! Reload versions //! Reload versions
void reloadOtherVersions(); void reloadOtherVersionsDeferred(int deferMs);
signals: signals:
//! Selection changed //! Selection changed

View File

@@ -31,9 +31,9 @@ namespace BlackGui
m_columns.addColumn(CColumn::standardString("version", CApplicationInfo::IndexVersionString)); m_columns.addColumn(CColumn::standardString("version", CApplicationInfo::IndexVersionString));
m_columns.addColumn(CColumn::standardString("OS", CApplicationInfo::IndexPlatformInfo)); m_columns.addColumn(CColumn::standardString("OS", CApplicationInfo::IndexPlatformInfo));
m_columns.addColumn(CColumn::standardString("exe.path", CApplicationInfo::IndexExecutablePath)); m_columns.addColumn(CColumn::standardString("exe.path", CApplicationInfo::IndexExecutablePath));
m_columns.addColumn(CColumn("e.?", "existing?", CApplicationInfo::IndexExecutablePathExisting, m_columns.addColumn(CColumn("e.?", "existing?", CApplicationInfo::IndexExecutablePathExisting, new CBoolIconFormatter("directory existing", "directory not existing")));
new CBoolIconFormatter("directory existing", "directory not existing")));
m_columns.addColumn(CColumn::standardString("data.path", CApplicationInfo::IndexApplicationDataPath)); m_columns.addColumn(CColumn::standardString("data.path", CApplicationInfo::IndexApplicationDataPath));
m_columns.setWidthPercentages({10, 10, 30, 5, 30});
// default sort order // default sort order
this->setSortColumnByPropertyIndex(CApplicationInfo::IndexVersionString); this->setSortColumnByPropertyIndex(CApplicationInfo::IndexVersionString);

View File

@@ -27,14 +27,23 @@ namespace BlackGui
this->setCustomMenu(new CApplicationInfoMenu(this)); this->setCustomMenu(new CApplicationInfoMenu(this));
} }
int CApplicationInfoView::otherSwiftVersionsFromDataDirectories(bool reInit) int CApplicationInfoView::otherSwiftVersionsFromDataDirectories(bool reinitOtherVersions)
{ {
const CApplicationInfoList others = CApplicationInfoList::fromOtherSwiftVersionsFromDataDirectories(reInit); const CApplicationInfoList others = CApplicationInfoList::fromOtherSwiftVersionsFromDataDirectories(reinitOtherVersions);
this->updateContainer(others);
m_acceptRowSelection = (others.size() > 0); m_acceptRowSelection = (others.size() > 0);
this->updateContainer(others);
return others.size(); return others.size();
} }
int CApplicationInfoView::otherSwiftVersionsFromDataDiretoriesAndResize(bool reinitOtherVersion)
{
const int r = this->otherSwiftVersionsFromDataDirectories(reinitOtherVersion);
this->setPercentageColumnWidths();
this->resizeRowsToContents();
return r;
}
void CApplicationInfoView::deleteSelectedDataDirectories() void CApplicationInfoView::deleteSelectedDataDirectories()
{ {
if (!this->hasSelection()) { return; } if (!this->hasSelection()) { return; }

View File

@@ -33,7 +33,10 @@ namespace BlackGui
explicit CApplicationInfoView(QWidget *parent = nullptr); explicit CApplicationInfoView(QWidget *parent = nullptr);
//! BlackMisc::CApplicationInfoList::otherSwiftVersionsFromDataDirectories //! 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 //! Delete the selected directories
void deleteSelectedDataDirectories(); void deleteSelectedDataDirectories();