diff options
author | Hannah von Reth <hannah.vonreth@owncloud.com> | 2020-06-29 17:06:00 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-29 17:06:00 +0300 |
commit | 9a8fc4277d4d05927f5423c34e16a13ca29d1343 (patch) | |
tree | d6d96e40fa7c41484f7b60c3ff699c745c0b315a /src/gui | |
parent | 8b95caae9e3979987c3dac75bb5ae4a5af806330 (diff) |
Merge pull request #7910 from TheOneRing/non_win
Don't build Windows only code on other platforms
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/CMakeLists.txt | 9 | ||||
-rw-r--r-- | src/gui/accountsettings.cpp | 8 | ||||
-rw-r--r-- | src/gui/folderman.cpp | 6 | ||||
-rw-r--r-- | src/gui/folderman.h | 4 | ||||
-rw-r--r-- | src/gui/generalsettings.cpp | 2 | ||||
-rw-r--r-- | src/gui/navigationpanehelper.cpp | 10 | ||||
-rw-r--r-- | src/gui/owncloudsetupwizard.cpp | 2 |
7 files changed, 26 insertions, 15 deletions
diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 37845024c..28f6f94ae 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -48,7 +48,6 @@ set(client_SRCS ignorelisteditor.cpp lockwatcher.cpp logbrowser.cpp - navigationpanehelper.cpp networksettings.cpp ocsjob.cpp ocssharejob.cpp @@ -122,13 +121,15 @@ IF( APPLE ) ENDIF() IF( NOT WIN32 AND NOT APPLE ) -set(client_SRCS ${client_SRCS} folderwatcher_linux.cpp) + list(APPEND client_SRCS folderwatcher_linux.cpp) ENDIF() IF( WIN32 ) -set(client_SRCS ${client_SRCS} folderwatcher_win.cpp) + list(APPEND client_SRCS + folderwatcher_win.cpp + navigationpanehelper.cpp) ENDIF() IF( APPLE ) -list(APPEND client_SRCS folderwatcher_mac.cpp) + list(APPEND client_SRCS folderwatcher_mac.cpp) ENDIF() set(3rdparty_SRC diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp index d1716c430..e873333df 100644 --- a/src/gui/accountsettings.cpp +++ b/src/gui/accountsettings.cpp @@ -456,8 +456,10 @@ void AccountSettings::slotFolderWizardAccepted() */ definition.ignoreHiddenFiles = folderMan->ignoreHiddenFiles(); +#ifdef Q_OS_WIN if (folderMan->navigationPaneHelper().showInExplorerNavigationPane()) definition.navigationPaneClsid = QUuid::createUuid(); +#endif auto selectiveSyncBlackList = folderWizard->property("selectiveSyncBlackList").toStringList(); @@ -551,8 +553,10 @@ void AccountSettings::slotEnableVfsCurrentFolder() if (!enable || !folder) return; +#ifdef Q_OS_WIN // we might need to add or remove the panel entry as cfapi brings this feature out of the box FolderMan::instance()->navigationPaneHelper().scheduleUpdateCloudStorageRegistry(); +#endif // It is unsafe to switch on vfs while a sync is running - wait if necessary. auto connection = std::make_shared<QMetaObject::Connection>(); @@ -621,8 +625,10 @@ void AccountSettings::slotDisableVfsCurrentFolder() if (msgBox->clickedButton() != acceptButton|| !folder) return; - // we might need to add or remove the panel entry as cfapi brings this feature out of the box +#ifdef Q_OS_WIN + // we might need to add or remove the panel entry as cfapi brings this feature out of the box FolderMan::instance()->navigationPaneHelper().scheduleUpdateCloudStorageRegistry(); +#endif // It is unsafe to switch off vfs while a sync is running - wait if necessary. auto connection = std::make_shared<QMetaObject::Connection>(); diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp index 5ac739dfd..3ce46ae87 100644 --- a/src/gui/folderman.cpp +++ b/src/gui/folderman.cpp @@ -50,7 +50,9 @@ FolderMan::FolderMan(QObject *parent) , _currentSyncFolder(nullptr) , _syncEnabled(true) , _lockWatcher(new LockWatcher) +#ifdef Q_OS_WIN , _navigationPaneHelper(this) +#endif , _appRestartRequired(false) { ASSERT(!_instance); @@ -998,7 +1000,9 @@ Folder *FolderMan::addFolder(AccountState *accountState, const FolderDefinition emit folderListChanged(_folderMap); } +#ifdef Q_OS_WIN _navigationPaneHelper.scheduleUpdateCloudStorageRegistry(); +#endif return folder; } @@ -1122,7 +1126,9 @@ void FolderMan::removeFolder(Folder *f) delete f; } +#ifdef Q_OS_WIN _navigationPaneHelper.scheduleUpdateCloudStorageRegistry(); +#endif emit folderListChanged(_folderMap); } diff --git a/src/gui/folderman.h b/src/gui/folderman.h index 057dff446..a685674d8 100644 --- a/src/gui/folderman.h +++ b/src/gui/folderman.h @@ -144,7 +144,9 @@ public: static QString unescapeAlias(const QString &); SocketApi *socketApi(); +#ifdef Q_OS_WIN NavigationPaneHelper &navigationPaneHelper() { return _navigationPaneHelper; } +#endif /** * Check if @a path is a valid path for a new folder considering the already sync'ed items. @@ -352,7 +354,9 @@ private: QTimer _startScheduledSyncTimer; QScopedPointer<SocketApi> _socketApi; +#ifdef Q_OS_WIN NavigationPaneHelper _navigationPaneHelper; +#endif bool _appRestartRequired; diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index 3698221f3..fff0e6436 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -252,10 +252,12 @@ void GeneralSettings::slotToggleOptionalDesktopNotifications(bool enable) void GeneralSettings::slotShowInExplorerNavigationPane(bool checked) { +#ifdef Q_OS_WIN ConfigFile cfgFile; cfgFile.setShowInExplorerNavigationPane(checked); // Now update the registry with the change. FolderMan::instance()->navigationPaneHelper().setShowInExplorerNavigationPane(checked); +#endif } void GeneralSettings::slotIgnoreFilesEditor() diff --git a/src/gui/navigationpanehelper.cpp b/src/gui/navigationpanehelper.cpp index 38a0b75dc..4cf4eb609 100644 --- a/src/gui/navigationpanehelper.cpp +++ b/src/gui/navigationpanehelper.cpp @@ -60,7 +60,6 @@ void NavigationPaneHelper::updateCloudStorageRegistry() // Start by looking at every registered namespace extension for the sidebar, and look for an "ApplicationName" value // that matches ours when we saved. QVector<QUuid> entriesToRemove; -#ifdef Q_OS_WIN Utility::registryWalkSubKeys( HKEY_CURRENT_USER, QStringLiteral("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Desktop\\NameSpace"), @@ -72,7 +71,6 @@ void NavigationPaneHelper::updateCloudStorageRegistry() entriesToRemove.append(clsid); } }); -#endif // Then re-save every folder that has a valid navigationPaneClsid to the registry. // We currently don't distinguish between new and existing CLSIDs, if it's there we just @@ -99,7 +97,6 @@ void NavigationPaneHelper::updateCloudStorageRegistry() QString targetFolderPath = QDir::toNativeSeparators(folder->cleanPath()); qCInfo(lcNavPane) << "Explorer Cloud storage provider: saving path" << targetFolderPath << "to CLSID" << clsidStr; -#ifdef Q_OS_WIN // Steps taken from: https://msdn.microsoft.com/en-us/library/windows/desktop/dn889934%28v=vs.85%29.aspx // Step 1: Add your CLSID and name your extension Utility::registrySetKeyValue(HKEY_CURRENT_USER, clsidPath, QString(), REG_SZ, title); @@ -140,11 +137,6 @@ void NavigationPaneHelper::updateCloudStorageRegistry() // For us, to later be able to iterate and find our own namespace entries and associated CLSID. // Use the macro instead of the theme to make sure it matches with the uninstaller. Utility::registrySetKeyValue(HKEY_CURRENT_USER, namespacePath, QStringLiteral("ApplicationName"), REG_SZ, QLatin1String(APPLICATION_NAME)); -#else - // This code path should only occur on Windows (the config will be false, and the checkbox invisible on other platforms). - // Add runtime checks rather than #ifdefing out the whole code to help catch breakages when developing on other platforms. - Q_ASSERT(false); -#endif } } @@ -156,12 +148,10 @@ void NavigationPaneHelper::updateCloudStorageRegistry() QString namespacePath = QString() % "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Desktop\\NameSpace\\" % clsidStr; qCInfo(lcNavPane) << "Explorer Cloud storage provider: now unused, removing own CLSID" << clsidStr; -#ifdef Q_OS_WIN Utility::registryDeleteKeyTree(HKEY_CURRENT_USER, clsidPath); Utility::registryDeleteKeyTree(HKEY_CURRENT_USER, clsidPathWow64); Utility::registryDeleteKeyTree(HKEY_CURRENT_USER, namespacePath); Utility::registryDeleteKeyValue(HKEY_CURRENT_USER, QStringLiteral("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\HideDesktopIcons\\NewStartPanel"), clsidStr); -#endif } } diff --git a/src/gui/owncloudsetupwizard.cpp b/src/gui/owncloudsetupwizard.cpp index 8e77c28c4..908d9813c 100644 --- a/src/gui/owncloudsetupwizard.cpp +++ b/src/gui/owncloudsetupwizard.cpp @@ -599,8 +599,10 @@ void OwncloudSetupWizard::slotAssistantFinished(int result) if (_ocWizard->useVirtualFileSync()) { folderDefinition.virtualFilesMode = bestAvailableVfsMode(); } +#ifdef Q_OS_WIN if (folderMan->navigationPaneHelper().showInExplorerNavigationPane()) folderDefinition.navigationPaneClsid = QUuid::createUuid(); +#endif auto f = folderMan->addFolder(account, folderDefinition); if (f) { |