Skip to content
This repository was archived by the owner on Apr 28, 2022. It is now read-only.

Commit d374ea0

Browse files
author
blam
committed
Merge branch 'jb44031-update-storage-models' into 'master'
[systemsettings] Reload the AboutSettings storage models when items are... See merge request mer-core/nemo-qml-plugin-systemsettings!101
2 parents a0754ba + ed2d41c commit d374ea0

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/aboutsettings.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include <QTextStream>
4343
#include <QVariant>
4444
#include <QSettings>
45+
#include <QTimer>
4546

4647
namespace
4748
{
@@ -126,6 +127,11 @@ AboutSettings::AboutSettings(QObject *parent)
126127
m_vendorVersion = settings.value(QStringLiteral("Version")).toString();
127128

128129
refreshStorageModels();
130+
131+
connect(&m_partitionManager, &PartitionManager::partitionAdded,
132+
this, &AboutSettings::partitionCountChanged);
133+
connect(&m_partitionManager, &PartitionManager::partitionRemoved,
134+
this, &AboutSettings::partitionCountChanged);
129135
}
130136

131137
AboutSettings::~AboutSettings()
@@ -227,12 +233,24 @@ QString AboutSettings::vendorVersion() const
227233
}
228234

229235
void AboutSettings::refreshStorageModels()
236+
{
237+
m_partitionManager.refresh();
238+
239+
partitionCountChanged();
240+
}
241+
242+
void AboutSettings::partitionCountChanged()
243+
{
244+
// Queue the method invocation in case several list changes are made consecutively, so that
245+
// the list is only reloaded once.
246+
QTimer::singleShot(0, this, &AboutSettings::reloadStorageLists);
247+
}
248+
249+
void AboutSettings::reloadStorageLists()
230250
{
231251
m_internalStorage.clear();
232252
m_externalStorage.clear();
233253

234-
m_partitionManager.refresh();
235-
236254
for (auto partition : m_partitionManager.partitions()) {
237255
QVariantMap row;
238256
row[QStringLiteral("mounted")] = partition.status() == Partition::Mounted;

src/aboutsettings.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ class SYSTEMSETTINGS_EXPORT AboutSettings: public QObject
9292
void storageChanged();
9393

9494
private:
95+
void partitionCountChanged();
96+
void reloadStorageLists();
97+
9598
QNetworkInfo *m_netinfo;
9699
QDeviceInfo *m_devinfo;
97100

0 commit comments

Comments
 (0)