|
42 | 42 | #include <QTextStream>
|
43 | 43 | #include <QVariant>
|
44 | 44 | #include <QSettings>
|
| 45 | +#include <QTimer> |
45 | 46 |
|
46 | 47 | namespace
|
47 | 48 | {
|
@@ -126,6 +127,11 @@ AboutSettings::AboutSettings(QObject *parent)
|
126 | 127 | m_vendorVersion = settings.value(QStringLiteral("Version")).toString();
|
127 | 128 |
|
128 | 129 | refreshStorageModels();
|
| 130 | + |
| 131 | + connect(&m_partitionManager, &PartitionManager::partitionAdded, |
| 132 | + this, &AboutSettings::partitionCountChanged); |
| 133 | + connect(&m_partitionManager, &PartitionManager::partitionRemoved, |
| 134 | + this, &AboutSettings::partitionCountChanged); |
129 | 135 | }
|
130 | 136 |
|
131 | 137 | AboutSettings::~AboutSettings()
|
@@ -227,12 +233,24 @@ QString AboutSettings::vendorVersion() const
|
227 | 233 | }
|
228 | 234 |
|
229 | 235 | 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() |
230 | 250 | {
|
231 | 251 | m_internalStorage.clear();
|
232 | 252 | m_externalStorage.clear();
|
233 | 253 |
|
234 |
| - m_partitionManager.refresh(); |
235 |
| - |
236 | 254 | for (auto partition : m_partitionManager.partitions()) {
|
237 | 255 | QVariantMap row;
|
238 | 256 | row[QStringLiteral("mounted")] = partition.status() == Partition::Mounted;
|
|
0 commit comments