OCSYNC_EXPORT QByteArray conflictFileBaseNameFromPattern(const QByteArray &conflictName);
#ifdef Q_OS_WIN
+ OCSYNC_EXPORT bool registryKeyExists(HKEY hRootKey, const QString &subKey);
OCSYNC_EXPORT QVariant registryGetKeyValue(HKEY hRootKey, const QString &subKey, const QString &valueName);
OCSYNC_EXPORT bool registrySetKeyValue(HKEY hRootKey, const QString &subKey, const QString &valueName, DWORD type, const QVariant &value);
OCSYNC_EXPORT bool registryDeleteKeyTree(HKEY hRootKey, const QString &subKey);
return QRect(barRect.left, barRect.top, (barRect.right - barRect.left), (barRect.bottom - barRect.top));
}
+bool Utility::registryKeyExists(HKEY hRootKey, const QString &subKey)
+{
+ HKEY hKey;
+
+ REGSAM sam = KEY_READ | KEY_WOW64_64KEY;
+ LONG result = RegOpenKeyEx(hRootKey, reinterpret_cast<LPCWSTR>(subKey.utf16()), 0, sam, &hKey);
+
+ RegCloseKey(hKey);
+ return result != ERROR_FILE_NOT_FOUND;
+}
+
QVariant Utility::registryGetKeyValue(HKEY hRootKey, const QString &subKey, const QString &valueName)
{
QVariant value;
// that matches ours when we saved.
QVector<QUuid> entriesToRemove;
#ifdef Q_OS_WIN
- Utility::registryWalkSubKeys(
- HKEY_CURRENT_USER,
- QStringLiteral(R"(Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace)"),
- [&entriesToRemove](HKEY key, const QString &subKey) {
- QVariant appName = Utility::registryGetKeyValue(key, subKey, QStringLiteral("ApplicationName"));
- if (appName.toString() == QLatin1String(APPLICATION_NAME)) {
- QUuid clsid{ subKey };
- Q_ASSERT(!clsid.isNull());
- entriesToRemove.append(clsid);
- }
- });
+ QString nameSpaceKey = QStringLiteral(R"(Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace)");
+ if (Utility::registryKeyExists(HKEY_CURRENT_USER, nameSpaceKey)) {
+ Utility::registryWalkSubKeys(HKEY_CURRENT_USER, nameSpaceKey,
+ [&entriesToRemove](HKEY key, const QString &subKey) {
+ QVariant appName = Utility::registryGetKeyValue(key, subKey, QStringLiteral("ApplicationName"));
+ if (appName.toString() == QLatin1String(APPLICATION_NAME)) {
+ QUuid clsid{ subKey };
+ Q_ASSERT(!clsid.isNull());
+ entriesToRemove.append(clsid);
+ }
+ });
+ }
#endif
// Only save folder entries if the option is enabled.
return TaskBarPosition::Top;
// Windows: Check registry for actual taskbar orientation
#elif defined(Q_OS_WIN)
- auto taskbarPosition = Utility::registryGetKeyValue(HKEY_CURRENT_USER,
- "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StuckRects3",
- "Settings");
+ auto taskbarPositionSubkey = QStringLiteral("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StuckRects3");
+ if (!Utility::registryKeyExists(HKEY_CURRENT_USER, taskbarPositionSubkey)) {
+ // Windows 7
+ taskbarPositionSubkey = QStringLiteral("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StuckRects2");
+ }
+ if (!Utility::registryKeyExists(HKEY_CURRENT_USER, taskbarPositionSubkey)) {
+ return TaskBarPosition::Bottom;
+ }
+ auto taskbarPosition = Utility::registryGetKeyValue(HKEY_CURRENT_USER, taskbarPositionSubkey, "Settings");
switch (taskbarPosition.toInt()) {
// Mapping windows binary value (0 = left, 1 = top, 2 = right, 3 = bottom) to qml logic (0 = bottom, 1 = left...)
case 0:
qCDebug(lcSystray) << "taskbarScreenEdge:" << taskbarScreenEdge;
qCDebug(lcSystray) << "screenRect:" << screenRect;
qCDebug(lcSystray) << "windowRect (reference)" << QRect(topLeft, bottomRight);
- qCDebug(lcSystray) << "windowRect (adjusted )" << windowRect;
+ qCDebug(lcSystray) << "windowRect (adjusted)" << windowRect;
return windowRect.topLeft();
}