@@ -41,23 +41,26 @@ NavigationPaneHelper::NavigationPaneHelper(FolderMan *folderMan)
41
41
42
42
void NavigationPaneHelper::setShowInExplorerNavigationPane (bool show)
43
43
{
44
- if (_showInExplorerNavigationPane == show)
44
+ if (_showInExplorerNavigationPane == show) {
45
45
return ;
46
+ }
46
47
47
48
_showInExplorerNavigationPane = show;
48
49
// Re-generate a new CLSID when enabling, possibly throwing away the old one.
49
50
// updateCloudStorageRegistry will take care of removing any unknown CLSID our application owns from the registry.
50
- foreach (Folder * folder, _folderMan->map ())
51
+ for ( const auto & folder : qAsConst ( _folderMan->map ())) {
51
52
folder->setNavigationPaneClsid (show ? QUuid::createUuid () : QUuid ());
53
+ }
52
54
53
55
scheduleUpdateCloudStorageRegistry ();
54
56
}
55
57
56
58
void NavigationPaneHelper::scheduleUpdateCloudStorageRegistry ()
57
59
{
58
60
// Schedule the update to happen a bit later to avoid doing the update multiple times in a row.
59
- if (!_updateCloudStorageRegistryTimer.isActive ())
61
+ if (!_updateCloudStorageRegistryTimer.isActive ()) {
60
62
_updateCloudStorageRegistryTimer.start (500 );
63
+ }
61
64
}
62
65
63
66
void NavigationPaneHelper::updateCloudStorageRegistry ()
@@ -66,11 +69,12 @@ void NavigationPaneHelper::updateCloudStorageRegistry()
66
69
// that matches ours when we saved.
67
70
QVector<QUuid> entriesToRemove;
68
71
#ifdef Q_OS_WIN
69
- QString nameSpaceKey = QStringLiteral (R"( Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace)" );
72
+ const auto nameSpaceKey = QStringLiteral (R"( Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace)" );
70
73
if (Utility::registryKeyExists (HKEY_CURRENT_USER, nameSpaceKey)) {
71
74
Utility::registryWalkSubKeys (HKEY_CURRENT_USER, nameSpaceKey,
72
75
[&entriesToRemove](HKEY key, const QString &subKey) {
73
- QVariant appName = Utility::registryGetKeyValue (key, subKey, QStringLiteral (" ApplicationName" ));
76
+ const auto appName = Utility::registryGetKeyValue (key, subKey, QStringLiteral (" ApplicationName" ));
77
+ qCDebug (lcNavPane) << " Searching for user with subKey:" << subKey;
74
78
if (appName.toString () == QLatin1String (APPLICATION_NAME)) {
75
79
QUuid clsid{ subKey };
76
80
Q_ASSERT (!clsid.isNull ());
@@ -85,23 +89,23 @@ void NavigationPaneHelper::updateCloudStorageRegistry()
85
89
// Then re-save every folder that has a valid navigationPaneClsid to the registry.
86
90
// We currently don't distinguish between new and existing CLSIDs, if it's there we just
87
91
// save over it. We at least need to update the tile in case we are suddently using multiple accounts.
88
- foreach (Folder * folder, _folderMan->map ()) {
92
+ for ( const auto & folder : qAsConst ( _folderMan->map () )) {
89
93
if (!folder->navigationPaneClsid ().isNull ()) {
90
94
// If it already exists, unmark it for removal, this is a valid sync root.
91
95
entriesToRemove.removeOne (folder->navigationPaneClsid ());
92
96
93
- QString clsidStr = folder->navigationPaneClsid ().toString ();
94
- QString clsidPath = QString () % R"( Software\Classes\CLSID\)" % clsidStr;
95
- QString clsidPathWow64 = QString () % R"( Software\Classes\Wow6432Node\CLSID\)" % clsidStr;
96
- QString namespacePath = QString () % R"( Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\)" % clsidStr;
97
+ const auto clsidStr = folder->navigationPaneClsid ().toString ();
98
+ const QString clsidPath = QString () % R"( Software\Classes\CLSID\)" % clsidStr;
99
+ const QString clsidPathWow64 = QString () % R"( Software\Classes\Wow6432Node\CLSID\)" % clsidStr;
100
+ const QString namespacePath = QString () % R"( Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\)" % clsidStr;
97
101
98
- QString title = folder->shortGuiRemotePathOrAppName ();
102
+ auto title = folder->shortGuiRemotePathOrAppName ();
99
103
// Write the account name in the sidebar only when using more than one account.
100
104
if (AccountManager::instance ()->accounts ().size () > 1 ) {
101
105
title = title % " - " % folder->accountState ()->account ()->prettyName ();
102
106
}
103
- QString iconPath = QDir::toNativeSeparators (qApp->applicationFilePath ());
104
- QString targetFolderPath = QDir::toNativeSeparators (folder->cleanPath ());
107
+ const auto iconPath = QDir::toNativeSeparators (qApp->applicationFilePath ());
108
+ const auto targetFolderPath = QDir::toNativeSeparators (folder->cleanPath ());
105
109
106
110
qCInfo (lcNavPane) << " Explorer Cloud storage provider: saving path" << targetFolderPath << " to CLSID" << clsidStr;
107
111
#ifdef Q_OS_WIN
@@ -157,11 +161,11 @@ void NavigationPaneHelper::updateCloudStorageRegistry()
157
161
}
158
162
159
163
// Then remove anything that isn't in our folder list anymore.
160
- foreach ( auto &clsid, entriesToRemove) {
161
- QString clsidStr = clsid.toString ();
162
- QString clsidPath = QString () % R"( Software\Classes\CLSID\)" % clsidStr;
163
- QString clsidPathWow64 = QString () % R"( Software\Classes\Wow6432Node\CLSID\)" % clsidStr;
164
- QString namespacePath = QString () % R"( Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\)" % clsidStr;
164
+ for ( const auto &clsid : qAsConst ( entriesToRemove) ) {
165
+ const auto clsidStr = clsid.toString ();
166
+ const QString clsidPath = QString () % R"( Software\Classes\CLSID\)" % clsidStr;
167
+ const QString clsidPathWow64 = QString () % R"( Software\Classes\Wow6432Node\CLSID\)" % clsidStr;
168
+ const QString namespacePath = QString () % R"( Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\)" % clsidStr;
165
169
166
170
qCInfo (lcNavPane) << " Explorer Cloud storage provider: now unused, removing own CLSID" << clsidStr;
167
171
#ifdef Q_OS_WIN
0 commit comments