Skip to content

Commit

Permalink
[systemsettings] Reload the AboutSettings storage models when items a…
Browse files Browse the repository at this point in the history
…re added/removed. Fixes JB#44031
  • Loading branch information
blammit committed Mar 8, 2019
1 parent a0754ba commit ed2d41c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/aboutsettings.cpp
Expand Up @@ -42,6 +42,7 @@
#include <QTextStream>
#include <QVariant>
#include <QSettings>
#include <QTimer>

namespace
{
Expand Down Expand Up @@ -126,6 +127,11 @@ AboutSettings::AboutSettings(QObject *parent)
m_vendorVersion = settings.value(QStringLiteral("Version")).toString();

refreshStorageModels();

connect(&m_partitionManager, &PartitionManager::partitionAdded,
this, &AboutSettings::partitionCountChanged);
connect(&m_partitionManager, &PartitionManager::partitionRemoved,
this, &AboutSettings::partitionCountChanged);
}

AboutSettings::~AboutSettings()
Expand Down Expand Up @@ -227,12 +233,24 @@ QString AboutSettings::vendorVersion() const
}

void AboutSettings::refreshStorageModels()
{
m_partitionManager.refresh();

partitionCountChanged();
}

void AboutSettings::partitionCountChanged()
{
// Queue the method invocation in case several list changes are made consecutively, so that
// the list is only reloaded once.
QTimer::singleShot(0, this, &AboutSettings::reloadStorageLists);
}

void AboutSettings::reloadStorageLists()
{
m_internalStorage.clear();
m_externalStorage.clear();

m_partitionManager.refresh();

for (auto partition : m_partitionManager.partitions()) {
QVariantMap row;
row[QStringLiteral("mounted")] = partition.status() == Partition::Mounted;
Expand Down
3 changes: 3 additions & 0 deletions src/aboutsettings.h
Expand Up @@ -92,6 +92,9 @@ class SYSTEMSETTINGS_EXPORT AboutSettings: public QObject
void storageChanged();

private:
void partitionCountChanged();
void reloadStorageLists();

QNetworkInfo *m_netinfo;
QDeviceInfo *m_devinfo;

Expand Down

0 comments on commit ed2d41c

Please sign in to comment.