Native Windows file dialog: Observe Windows Explorer "Show hidden files" setting
Extract a helper function to read the setting and use that in file dialogs and tray icon. Task-number: QTBUG-60593 Change-Id: I03cf1e45611690a128bf2cc17eba5dff23b86969 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>bb10
parent
b05d1c2ebf
commit
4b63565bbc
|
|
@ -1261,6 +1261,29 @@ QTouchDevice *QWindowsContext::touchDevice() const
|
|||
return d->m_mouseHandler.touchDevice();
|
||||
}
|
||||
|
||||
static DWORD readDwordRegistrySetting(const wchar_t *regKey, const wchar_t *subKey, DWORD defaultValue)
|
||||
{
|
||||
DWORD result = defaultValue;
|
||||
HKEY handle;
|
||||
if (RegOpenKeyEx(HKEY_CURRENT_USER, regKey, 0, KEY_READ, &handle) == ERROR_SUCCESS) {
|
||||
DWORD type;
|
||||
if (RegQueryValueEx(handle, subKey, 0, &type, 0, 0) == ERROR_SUCCESS && type == REG_DWORD) {
|
||||
DWORD value;
|
||||
DWORD size = sizeof(result);
|
||||
if (RegQueryValueEx(handle, subKey, 0, 0, reinterpret_cast<unsigned char *>(&value), &size) == ERROR_SUCCESS)
|
||||
result = value;
|
||||
}
|
||||
RegCloseKey(handle);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
DWORD QWindowsContext::readAdvancedExplorerSettings(const wchar_t *subKey, DWORD defaultValue)
|
||||
{
|
||||
return readDwordRegistrySetting(L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
|
||||
subKey, defaultValue);
|
||||
}
|
||||
|
||||
static inline bool isEmptyRect(const RECT &rect)
|
||||
{
|
||||
return rect.right - rect.left == 0 && rect.bottom - rect.top == 0;
|
||||
|
|
|
|||
|
|
@ -220,6 +220,8 @@ public:
|
|||
bool asyncExpose() const;
|
||||
void setAsyncExpose(bool value);
|
||||
|
||||
static DWORD readAdvancedExplorerSettings(const wchar_t *subKey, DWORD defaultValue);
|
||||
|
||||
QTouchDevice *touchDevice() const;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -973,7 +973,9 @@ void QWindowsNativeFileDialogBase::setMode(QFileDialogOptions::FileMode mode,
|
|||
QFileDialogOptions::AcceptMode acceptMode,
|
||||
QFileDialogOptions::FileDialogOptions options)
|
||||
{
|
||||
DWORD flags = FOS_PATHMUSTEXIST | FOS_FORCESHOWHIDDEN;
|
||||
DWORD flags = FOS_PATHMUSTEXIST;
|
||||
if (QWindowsContext::readAdvancedExplorerSettings(L"Hidden", 1) == 1) // 1:show, 2:hidden
|
||||
flags |= FOS_FORCESHOWHIDDEN;
|
||||
if (options & QFileDialogOptions::DontResolveSymlinks)
|
||||
flags |= FOS_NODEREFERENCELINKS;
|
||||
switch (mode) {
|
||||
|
|
|
|||
|
|
@ -288,21 +288,8 @@ void QWindowsSystemTrayIcon::showMessage(const QString &title, const QString &me
|
|||
|
||||
bool QWindowsSystemTrayIcon::supportsMessages() const
|
||||
{
|
||||
bool result = true; // The key does typically not exist on Windows 10, default to true.
|
||||
static const wchar_t regKey[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced";
|
||||
HKEY handle;
|
||||
if (RegOpenKeyEx(HKEY_CURRENT_USER, regKey, 0, KEY_READ, &handle) == ERROR_SUCCESS) {
|
||||
DWORD type;
|
||||
static const wchar_t subKey[] = L"EnableBalloonTips";
|
||||
if (RegQueryValueEx(handle, subKey, 0, &type, 0, 0) == ERROR_SUCCESS && type == REG_DWORD) {
|
||||
DWORD value;
|
||||
DWORD size = sizeof(value);
|
||||
if (RegQueryValueEx(handle, subKey, 0, 0, reinterpret_cast<unsigned char *>(&value), &size) == ERROR_SUCCESS)
|
||||
result = value != 0;
|
||||
}
|
||||
RegCloseKey(handle);
|
||||
}
|
||||
return result;
|
||||
// The key does typically not exist on Windows 10, default to true.
|
||||
return QWindowsContext::readAdvancedExplorerSettings(L"EnableBalloonTips", 1) != 0;
|
||||
}
|
||||
|
||||
QPlatformMenu *QWindowsSystemTrayIcon::createMenu() const
|
||||
|
|
|
|||
Loading…
Reference in New Issue