Windows: Add a setting to enable/disable the explorer navigation pane integration

Issue #5295
This commit is contained in:
Jocelyn Turcotte 2017-10-19 16:37:51 +02:00 committed by Jocelyn Turcotte
parent 56e38e6f80
commit 10c6951438
9 changed files with 79 additions and 4 deletions

View file

@ -401,8 +401,8 @@ void AccountSettings::slotFolderWizardAccepted()
*/
definition.ignoreHiddenFiles = folderMan->ignoreHiddenFiles();
// FIXME: Make this depend on a checkbox in settings.
definition.navigationPaneClsid = QUuid::createUuid();
if (folderMan->navigationPaneHelper().showInExplorerNavigationPane())
definition.navigationPaneClsid = QUuid::createUuid();
auto selectiveSyncBlackList = folderWizard->property("selectiveSyncBlackList").toStringList();

View file

@ -44,6 +44,7 @@ GeneralSettings::GeneralSettings(QWidget *parent)
connect(_ui->desktopNotificationsCheckBox, &QAbstractButton::toggled,
this, &GeneralSettings::slotToggleOptionalDesktopNotifications);
connect(_ui->showInExplorerNavigationPaneCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::slotShowInExplorerNavigationPane);
_ui->autostartCheckBox->setChecked(Utility::hasLaunchOnStartup(Theme::instance()->appName()));
connect(_ui->autostartCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::slotToggleLaunchOnStartup);
@ -73,6 +74,13 @@ GeneralSettings::GeneralSettings(QWidget *parent)
_ui->crashreporterCheckBox->setVisible(false);
#endif
// Hide on non-Windows, or WindowsVersion < 10.
// The condition should match the default value of ConfigFile::showInExplorerNavigationPane.
#ifdef Q_OS_WIN
if (QSysInfo::windowsVersion() < QSysInfo::WV_WINDOWS10)
#endif
_ui->showInExplorerNavigationPaneCheckBox->setVisible(false);
/* Set the left contents margin of the layout to zero to make the checkboxes
* align properly vertically , fixes bug #3758
*/
@ -107,6 +115,7 @@ void GeneralSettings::loadMiscSettings()
ConfigFile cfgFile;
_ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons());
_ui->desktopNotificationsCheckBox->setChecked(cfgFile.optionalDesktopNotifications());
_ui->showInExplorerNavigationPaneCheckBox->setChecked(cfgFile.showInExplorerNavigationPane());
_ui->crashreporterCheckBox->setChecked(cfgFile.crashReporter());
auto newFolderLimit = cfgFile.newBigFolderSizeLimit();
_ui->newFolderLimitCheckBox->setChecked(newFolderLimit.first);
@ -162,6 +171,14 @@ void GeneralSettings::slotToggleOptionalDesktopNotifications(bool enable)
cfgFile.setOptionalDesktopNotifications(enable);
}
void GeneralSettings::slotShowInExplorerNavigationPane(bool checked)
{
ConfigFile cfgFile;
cfgFile.setShowInExplorerNavigationPane(checked);
// Now update the registry with the change.
FolderMan::instance()->navigationPaneHelper().setShowInExplorerNavigationPane(checked);
}
void GeneralSettings::slotIgnoreFilesEditor()
{
if (_ignoreEditor.isNull()) {

View file

@ -43,6 +43,7 @@ private slots:
void saveMiscSettings();
void slotToggleLaunchOnStartup(bool);
void slotToggleOptionalDesktopNotifications(bool);
void slotShowInExplorerNavigationPane(bool);
void slotUpdateInfo();
void slotIgnoreFilesEditor();
void loadMiscSettings();

View file

@ -218,6 +218,17 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QCheckBox" name="showInExplorerNavigationPaneCheckBox">
<property name="text">
<string>Show sync folders in &amp;Explorer's Navigation Pane</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>

View file

@ -14,6 +14,7 @@
#include "navigationpanehelper.h"
#include "accountmanager.h"
#include "configfile.h"
#include "folderman.h"
#include <QDir>
@ -26,10 +27,27 @@ Q_LOGGING_CATEGORY(lcNavPane, "gui.folder.navigationpane", QtInfoMsg)
NavigationPaneHelper::NavigationPaneHelper(FolderMan *folderMan)
: _folderMan(folderMan)
{
ConfigFile cfg;
_showInExplorerNavigationPane = cfg.showInExplorerNavigationPane();
_updateCloudStorageRegistryTimer.setSingleShot(true);
connect(&_updateCloudStorageRegistryTimer, &QTimer::timeout, this, &NavigationPaneHelper::updateCloudStorageRegistry);
}
void NavigationPaneHelper::setShowInExplorerNavigationPane(bool show)
{
if (_showInExplorerNavigationPane == show)
return;
_showInExplorerNavigationPane = show;
// Re-generate a new CLSID when enabling, possibly throwing away the old one.
// updateCloudStorageRegistry will take care of removing any unknown CLSID our application owns from the registry.
foreach (Folder *folder, _folderMan->map())
folder->setNavigationPaneClsid(show ? QUuid::createUuid() : QUuid());
scheduleUpdateCloudStorageRegistry();
}
void NavigationPaneHelper::scheduleUpdateCloudStorageRegistry()
{
// Schedule the update to happen a bit later to avoid doing the update multiple times in a row.

View file

@ -29,12 +29,16 @@ class NavigationPaneHelper : public QObject
public:
NavigationPaneHelper(FolderMan *folderMan);
bool showInExplorerNavigationPane() const { return _showInExplorerNavigationPane; }
void setShowInExplorerNavigationPane(bool show);
void scheduleUpdateCloudStorageRegistry();
private:
void updateCloudStorageRegistry();
FolderMan *_folderMan;
bool _showInExplorerNavigationPane;
QTimer _updateCloudStorageRegistryTimer;
};

View file

@ -579,8 +579,8 @@ void OwncloudSetupWizard::slotAssistantFinished(int result)
folderDefinition.localPath = localFolder;
folderDefinition.targetPath = FolderDefinition::prepareTargetPath(_remoteFolder);
folderDefinition.ignoreHiddenFiles = folderMan->ignoreHiddenFiles();
// FIXME: Make this depend on a checkbox in settings.
folderDefinition.navigationPaneClsid = QUuid::createUuid();
if (folderMan->navigationPaneHelper().showInExplorerNavigationPane())
folderDefinition.navigationPaneClsid = QUuid::createUuid();
auto f = folderMan->addFolder(account, folderDefinition);
if (f) {

View file

@ -52,6 +52,7 @@ static const char monoIconsC[] = "monoIcons";
static const char promptDeleteC[] = "promptDeleteAllFiles";
static const char crashReporterC[] = "crashReporter";
static const char optionalDesktopNoficationsC[] = "optionalDesktopNotifications";
static const char showInExplorerNavigationPaneC[] = "showInExplorerNavigationPane";
static const char skipUpdateCheckC[] = "skipUpdateCheck";
static const char updateCheckIntervalC[] = "updateCheckInterval";
static const char geometryC[] = "geometry";
@ -124,6 +125,26 @@ bool ConfigFile::optionalDesktopNotifications() const
return settings.value(QLatin1String(optionalDesktopNoficationsC), true).toBool();
}
bool ConfigFile::showInExplorerNavigationPane() const
{
const bool defaultValue =
#ifdef Q_OS_WIN
QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS10
#else
false
#endif
;
QSettings settings(configFile(), QSettings::IniFormat);
return settings.value(QLatin1String(showInExplorerNavigationPaneC), defaultValue).toBool();
}
void ConfigFile::setShowInExplorerNavigationPane(bool show)
{
QSettings settings(configFile(), QSettings::IniFormat);
settings.setValue(QLatin1String(showInExplorerNavigationPaneC), show);
settings.sync();
}
int ConfigFile::timeout() const
{
QSettings settings(configFile(), QSettings::IniFormat);

View file

@ -123,6 +123,9 @@ public:
bool optionalDesktopNotifications() const;
void setOptionalDesktopNotifications(bool show);
bool showInExplorerNavigationPane() const;
void setShowInExplorerNavigationPane(bool show);
int timeout() const;
quint64 chunkSize() const;
quint64 maxChunkSize() const;