4#define QT_NO_URL_CAST_FROM_STRING 1
6#include <QtCore/qt_windows.h>
15#include <QtGui/qguiapplication.h>
16#include <QtGui/qcolor.h>
18#include <QtCore/qdebug.h>
19#if QT_CONFIG(regularexpression)
20# include <QtCore/qregularexpression.h>
22#include <QtCore/qtimer.h>
23#include <QtCore/qdir.h>
24#include <QtCore/qscopedpointer.h>
25#include <QtCore/qsharedpointer.h>
26#include <QtCore/qobject.h>
27#include <QtCore/qthread.h>
28#include <QtCore/qsysinfo.h>
29#include <QtCore/qshareddata.h>
30#include <QtCore/qshareddata.h>
31#include <QtCore/qmutex.h>
32#include <QtCore/quuid.h>
33#include <QtCore/qtemporaryfile.h>
34#include <QtCore/private/qfunctions_win_p.h>
35#include <QtCore/private/qsystemerror_p.h>
49 const size_t stringSize =
s.size();
50 wchar_t *
result =
new wchar_t[
qMax(stringSize + 1, reserveSize)];
71 MSG msg = {
nullptr, 0, 0, 0, 0, {0, 0} };
72 while (PeekMessage(&msg,
nullptr, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE))
74 if (msg.message == WM_MOUSEMOVE)
75 PostMessage(msg.hwnd, msg.message, 0, msg.lParam);
76 qCDebug(lcQpaDialogs) << __FUNCTION__ <<
"triggered=" << (msg.message == WM_MOUSEMOVE);
81 IOleWindow *oleWindow =
nullptr;
82 if (FAILED(fileDialog->QueryInterface(IID_IOleWindow,
reinterpret_cast<void **
>(&oleWindow)))) {
83 qCWarning(lcQpaDialogs,
"Native file dialog: unable to query IID_IOleWindow interface.");
88 if (FAILED(oleWindow->GetWindow(&
result)))
89 qCWarning(lcQpaDialogs,
"Native file dialog: unable to get dialog's window.");
133 void exec(HWND owner =
nullptr) {
doExec(owner); m_executed =
true; }
146 virtual void doExec(HWND owner =
nullptr) = 0;
166template <
class BaseClass>
173template <
class BaseClass>
182 if (m_thread->wait(500))
185 qCCritical(lcQpaDialogs) <<__FUNCTION__ <<
"Thread failed to finish.";
190template <
class BaseClass>
193 if (m_nativeDialog.isNull()) {
194 qWarning(
"%s invoked with no native dialog present.", __FUNCTION__);
197 return m_nativeDialog.data();
200template <
class BaseClass>
206template <
class BaseClass>
211 if (m_nativeDialog.isNull() || m_nativeDialog->executed())
213 return m_nativeDialog.data();
230 : m_dialog(
d), m_owner(owner) {}
240 qCDebug(lcQpaDialogs) <<
'>' << __FUNCTION__;
241 QComHelper comInit(COINIT_APARTMENTTHREADED);
242 m_dialog->
exec(m_owner);
243 qCDebug(lcQpaDialogs) <<
'<' << __FUNCTION__;
246template <
class BaseClass>
257 m_ownerWindow =
nullptr;
259 qCDebug(lcQpaDialogs) << __FUNCTION__ <<
"modal=" << modal
260 <<
" modal supported? " << supportsNonModalDialog(
parent)
261 <<
"native=" << m_nativeDialog.data() <<
"owner" << m_ownerWindow;
262 if (!modal && !supportsNonModalDialog(
parent))
264 if (!ensureNativeDialog())
272 m_timerId = this->startTimer(0);
279template <
class BaseClass>
289template <
class BaseClass>
293 this->killTimer(m_timerId);
298template <
class BaseClass>
301 if (m_nativeDialog) {
302 m_nativeDialog->close();
303 m_nativeDialog.clear();
305 m_ownerWindow =
nullptr;
308template <
class BaseClass>
311 qCDebug(lcQpaDialogs) << __FUNCTION__;
314 nd->exec(m_ownerWindow);
315 m_nativeDialog.clear();
359 m_data->mutex.lock();
361 m_data->mutex.unlock();
368 m_data->directory =
d;
373 m_data->mutex.lock();
375 m_data->mutex.unlock();
382 m_data->selectedNameFilter =
f;
387 m_data->mutex.lock();
388 const auto result = m_data->selectedFiles;
389 m_data->mutex.unlock();
402 m_data->selectedFiles = urls;
408 m_data->directory =
o->initialDirectory();
409 m_data->selectedFiles =
o->initiallySelectedFiles();
410 m_data->selectedNameFilter =
o->initiallySelectedNameFilter();
433 IFACEMETHODIMP
OnFileOk(IFileDialog *)
override;
438 FDE_SHAREVIOLATION_RESPONSE *)
override
443 IFACEMETHODIMP
OnOverwrite(IFileDialog *, IShellItem *, FDE_OVERWRITE_RESPONSE *)
override
449 m_nativeFileDialog(nativeFileDialog) {}
457 IFileDialogEvents *
result;
459 if (FAILED(eventHandler->QueryInterface(IID_IFileDialogEvents,
reinterpret_cast<void **
>(&
result)))) {
463 eventHandler->Release();
483 {
return displayName(m_item, SIGDN_NORMALDISPLAY); }
485 {
return displayName(m_item, SIGDN_URL); }
487 {
return displayName(m_item, SIGDN_FILESYSPATH); }
489 {
return displayName(m_item, SIGDN_DESKTOPABSOLUTEPARSING); }
493 bool isFileSystem()
const {
return (m_attributes & SFGAO_FILESYSTEM) != 0; }
494 bool isDir()
const {
return (m_attributes & SFGAO_FOLDER) != 0; }
496 bool canStream()
const {
return (m_attributes & SFGAO_STREAM) != 0; }
502#ifndef QT_NO_DEBUG_STREAM
508 static QString libraryItemDefaultSaveFolder(IShellItem *
item);
509 QUrl urlValue()
const;
519 SFGAOF
mask = (SFGAO_CAPABILITYMASK | SFGAO_CONTENTSMASK | SFGAO_STORAGECAPMASK);
522 if (FAILED(
item->GetAttributes((SFGAO_STREAM | SFGAO_COMPRESSED), &m_attributes))) {
526 if (m_attributes & (SFGAO_STREAM | SFGAO_COMPRESSED))
527 mask &= ~SFGAO_HASSUBFOLDER;
528 if (FAILED(
item->GetAttributes(
mask, &m_attributes)))
536 return QDir::cleanPath(QWindowsShellItem::displayName(m_item, SIGDN_FILESYSPATH));
539 return QWindowsShellItem::libraryItemDefaultSaveFolder(m_item);
543QUrl QWindowsShellItem::urlValue() const
552 qWarning(
"%s: Unable to decode URL \"%s\": %s", __FUNCTION__,
565 const QUrl urlV = urlValue();
576 LPWSTR
name =
nullptr;
589 if (FAILED(
items->GetCount(&itemCount)) || itemCount == 0)
591 result.reserve(itemCount);
592 for (DWORD
i = 0;
i < itemCount; ++
i) {
593 IShellItem *
item =
nullptr;
606 IStream *istream =
nullptr;
607 HRESULT hr = m_item->BindToHandler(
nullptr, BHID_Stream, IID_PPV_ARGS(&istream));
610 + QSystemError::windowsComString(hr);
613 enum : ULONG {
bufSize = 102400 };
619 if ((hr == S_OK || hr == S_FALSE) && bytesRead)
625 if (hr != S_OK && hr != S_FALSE) {
627 + QSystemError::windowsComString(hr);
641 static const CLSID classId_ShellLibrary = {0xd9b3211d, 0xe57f, 0x4426, {0xaa, 0xef, 0x30, 0xa8, 0x6, 0xad, 0xd3, 0x97}};
642 static const IID iId_IShellLibrary = {0x11a66efa, 0x382e, 0x451a, {0x92, 0x34, 0x1e, 0xe, 0x12, 0xef, 0x30, 0x85}};
644 IShellLibrary *helper =
nullptr;
645 IShellLibrary *
result =
nullptr;
646 if (SUCCEEDED(CoCreateInstance(classId_ShellLibrary,
nullptr, CLSCTX_INPROC_SERVER, iId_IShellLibrary,
reinterpret_cast<void **
>(&helper))))
647 if (SUCCEEDED(helper->LoadLibraryFromItem(libraryItem,
mode)))
648 helper->QueryInterface(iId_IShellLibrary,
reinterpret_cast<void **
>(&
result));
655QString QWindowsShellItem::libraryItemDefaultSaveFolder(IShellItem *
item)
659 IShellItem *
item =
nullptr;
660 if (SUCCEEDED(library->GetDefaultSaveFolder(DSFT_DETECT, IID_IShellItem,
reinterpret_cast<void **
>(&
item)))) {
669#ifndef QT_NO_DEBUG_STREAM
684 d <<
", path=\"" << pathS <<
'"';
685 const QUrl urlV = urlValue();
687 d <<
"\", url=" << urlV;
706 d <<
"IShellItem(" <<
static_cast<const void *
>(
i);
741 void doExec(HWND owner =
nullptr)
override;
770 void close()
override;
774 bool init(
const CLSID &clsId,
const IID &iid);
776 inline IFileDialog *
fileDialog()
const {
return m_fileDialog; }
783 IFileDialog *m_fileDialog =
nullptr;
784 IFileDialogEvents *m_dialogEvents =
nullptr;
787 bool m_hideFiltersDetails =
false;
788 bool m_hasDefaultSuffix =
false;
800 if (m_dialogEvents && m_fileDialog)
801 m_fileDialog->Unadvise(m_cookie);
803 m_dialogEvents->Release();
805 m_fileDialog->Release();
810 HRESULT hr = CoCreateInstance(clsId,
nullptr, CLSCTX_INPROC_SERVER,
811 iid,
reinterpret_cast<void **
>(&m_fileDialog));
820 hr = m_fileDialog->Advise(m_dialogEvents, &m_cookie);
825 qCDebug(lcQpaDialogs) << __FUNCTION__ << m_fileDialog << m_dialogEvents << m_cookie;
833 m_fileDialog->SetTitle(
reinterpret_cast<const wchar_t *
>(
title.
utf16()));
839 IShellItem *
result =
nullptr;
842 SHCreateItemFromParsingName(
reinterpret_cast<const wchar_t *
>(native.
utf16()),
843 nullptr, IID_IShellItem,
844 reinterpret_cast<void **
>(&
result));
854 IShellItem *
result =
nullptr;
860 PIDLIST_ABSOLUTE idList;
861 HRESULT hr = SHGetKnownFolderIDList(uuid, 0,
nullptr, &idList);
866 hr = SHCreateItemFromIDList(idList, IID_IShellItem,
reinterpret_cast<void **
>(&
result));
867 CoTaskMemFree(idList);
883 m_fileDialog->SetFolder(psi);
892 IShellItem *
item =
nullptr;
893 if (m_fileDialog && SUCCEEDED(m_fileDialog->GetFolder(&
item)) &&
item) {
902 qCDebug(lcQpaDialogs) <<
'>' << __FUNCTION__;
905 const HRESULT hr = m_fileDialog->Show(owner);
907 qCDebug(lcQpaDialogs) <<
'<' << __FUNCTION__ <<
" returns " <<
Qt::hex << hr;
919 QFileDialogOptions::FileDialogOptions options)
921 DWORD
flags = FOS_PATHMUSTEXIST;
923 flags |= FOS_FORCESHOWHIDDEN;
925 flags |= FOS_NODEREFERENCELINKS;
929 flags |= FOS_NOREADONLYRETURN;
931 flags |= FOS_OVERWRITEPROMPT;
934 flags |= FOS_FILEMUSTEXIST;
940 flags |= FOS_PICKFOLDERS | FOS_FILEMUSTEXIST | FOS_FORCEFILESYSTEM;
943 flags |= FOS_FILEMUSTEXIST | FOS_ALLOWMULTISELECT;
946 qCDebug(lcQpaDialogs) << __FUNCTION__ <<
"mode=" <<
mode
947 <<
"acceptMode=" << acceptMode <<
"options=" << options
950 if (FAILED(m_fileDialog->SetOptions(
flags)))
962 bool hideFilterDetails,
963 int *totalStringLength)
967 *totalStringLength = 0;
969#if QT_CONFIG(regularexpression)
978 const int openingParenPos = filterString.lastIndexOf(u
'(');
979 const int closingParenPos = openingParenPos != -1 ?
980 filterString.indexOf(u
')', openingParenPos + 1) : -1;
982 filterSpec.
filter = closingParenPos == -1 ?
984 filterString.
mid(openingParenPos + 1, closingParenPos - openingParenPos - 1).
trimmed();
986 filterSpec.
filter += u
'*';
987#if QT_CONFIG(regularexpression)
993 if (hideFilterDetails && openingParenPos != -1) {
999 result.push_back(filterSpec);
1009 int totalStringLength = 0;
1020 for (
int i = 0;
i <
size; ++
i) {
1024 QString description = specs[
i].description;
1026 if (!m_hideFiltersDetails && !
filter.startsWith(u
"*.")) {
1031 description.
chop(1);
1035 comFilterSpec[
i].pszName =
ptr;
1038 comFilterSpec[
i].pszSpec =
ptr;
1039 ptr += specs[
i].filter.toWCharArray(
ptr);
1043 m_fileDialog->SetFileTypes(
size, comFilterSpec.
data());
1049 m_hasDefaultSuffix = !
s.isEmpty();
1057 auto *wSuffix =
const_cast<wchar_t *
>(
reinterpret_cast<const wchar_t *
>(
s.utf16()));
1058 m_fileDialog->SetDefaultExtension(wSuffix);
1064 return SUCCEEDED(fileDialog->QueryInterface(IID_IFileDialog2,
reinterpret_cast<void **
>(&
result)))
1070 auto *wText =
const_cast<wchar_t *
>(
reinterpret_cast<const wchar_t *
>(
text.
utf16()));
1073 m_fileDialog->SetFileNameLabel(wText);
1076 m_fileDialog->SetOkButtonLabel(wText);
1080 dialog2->SetCancelButtonLabel(wText);
1096 || (
ch >= u
'a' &&
ch <= u
'f')
1097 || (
ch >= u
'A' &&
ch <= u
'F')))
1106 const QChar dash(u
'-');
1107 return s.size() == 36
1124 m_fileDialog->SetFileName((
wchar_t*)
fileName.utf16());
1136 if (
filters.at(
i).startsWith(needle))
1147 qWarning(
"%s: Invalid parameter '%s' not found in '%s'.",
1152 m_fileDialog->SetFileTypeIndex(
index + 1);
1158 if (SUCCEEDED(m_fileDialog->GetFileTypeIndex(&uIndex))) {
1159 const int index = uIndex - 1;
1160 if (
index < m_nameFilters.size())
1161 return m_nameFilters.at(
index);
1179 qCDebug(lcQpaDialogs) << __FUNCTION__ << current << current.
size();
1181 if (current.
size() == 1)
1201 m_fileDialog->Close(S_OK);
1205 qCDebug(lcQpaDialogs) << __FUNCTION__ <<
"closing" << hwnd;
1206 if (hwnd && IsWindowVisible(hwnd))
1207 PostMessageW(hwnd, WM_CLOSE, 0, 0);
1230 return m_nativeFileDialog->
onFileOk() ? S_OK : S_FALSE;
1261 int endPos =
filter.indexOf(u
' ', suffixPos + 1);
1263 endPos =
filter.indexOf(u
';', suffixPos + 1);
1265 endPos =
filter.indexOf(u
')', suffixPos + 1);
1268 return filter.mid(suffixPos, endPos - suffixPos);
1291 IShellItem *
item =
nullptr;
1300 IShellItem *
item =
nullptr;
1302 if (SUCCEEDED(hr) &&
item) {
1327 inline IFileOpenDialog *openFileDialog()
const
1328 {
return static_cast<IFileOpenDialog *
>(
fileDialog()); }
1340 for (
const QString &
file : std::as_const(*temporaryItemCopies()))
1349 return c.isLetterOrNumber() ||
c == u
'_' ||
c == u
'-';
1354 const int lastSlash =
qMax(
name.lastIndexOf(u
'/'),
1355 name.lastIndexOf(u
'\\'));
1356 if (lastSlash != -1)
1357 name.remove(0, lastSlash + 1);
1359 int lastDot =
name.lastIndexOf(u
'.');
1361 lastDot =
name.size();
1364 for (
int i = lastDot - 1;
i >= 0; --
i) {
1382 if (!targetFile.
open()) {
1390 if (temporaryItemCopies()->isEmpty())
1392 temporaryItemCopies()->append(
result);
1404 if (temporaryCopy.
isEmpty()) {
1419 IShellItemArray *
items =
nullptr;
1420 if (SUCCEEDED(openFileDialog()->GetResults(&
items)) &&
items) {
1439 IShellItemArray *
items =
nullptr;
1440 const HRESULT hr = openFileDialog()->GetSelectedItems(&
items);
1441 if (SUCCEEDED(hr) &&
items) {
1448 qWarning().nospace() << __FUNCTION__<<
": Unable to obtain URL of " << qItem;
1466 if (!
result->init(CLSID_FileOpenDialog, IID_IFileOpenDialog)) {
1472 if (!
result->init(CLSID_FileSaveDialog, IID_IFileSaveDialog)) {
1532 result->setWindowTitle(opts->windowTitle());
1533 result->setMode(
mode, opts->acceptMode(), opts->options());
1535 const QStringList nameFilters = opts->nameFilters();
1536 if (!nameFilters.isEmpty())
1537 result->setNameFilters(nameFilters);
1544 result->updateDirectory();
1545 result->updateSelectedNameFilter();
1546 const QList<QUrl> initialSelection = opts->initiallySelectedFiles();
1547 if (!initialSelection.
empty()) {
1559 const QString initialNameFilter = opts->initiallySelectedNameFilter();
1560 if (!initialNameFilter.
isEmpty())
1561 result->selectNameFilter(initialNameFilter);
1563 const QString defaultSuffix = opts->defaultSuffix();
1565 result->setDefaultSuffix(defaultSuffix);
1598 qCDebug(lcQpaDialogs) << __FUNCTION__;
1634 void doExec(HWND owner =
nullptr)
override;
1643 void populateOpenFileName(OPENFILENAME *ofn, HWND owner)
const;
1645 QList<QUrl> execFileNames(HWND owner,
int *selectedFilterIndex)
const;
1658QWindowsXpNativeFileDialog::QWindowsXpNativeFileDialog(
const OptionsPtr &options,
1667 int selectedFilterIndex = -1;
1670 execExistingDir(owner) : execFileNames(owner, &selectedFilterIndex);
1673 if (selectedFiles.
isEmpty()) {
1678 if (selectedFilterIndex >= 0 && selectedFilterIndex < nameFilters.size())
1693 return dialog->existingDirCallback(hwnd, uMsg, lParam);
1698#if defined(Q_CC_MINGW) && (!defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 3)
1707 case BFFM_INITIALIZED: {
1709 SetWindowText(hwnd,
reinterpret_cast<const wchar_t *
>(m_title.
utf16()));
1712 SendMessage(hwnd, BFFM_SETSELECTION, TRUE, LPARAM(initialFile.
utf16()));
1715 case BFFM_SELCHANGED: {
1719 SendMessage(hwnd, BFFM_ENABLEOK,
ok ? 1 : 0, 1);
1726QList<QUrl> QWindowsXpNativeFileDialog::execExistingDir(HWND owner)
1731 bi.hwndOwner = owner;
1732 bi.pidlRoot =
nullptr;
1733 bi.lpszTitle =
nullptr;
1734 bi.pszDisplayName = initPath;
1735 bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT | BIF_NEWDIALOGSTYLE;
1737 bi.lParam = LPARAM(
this);
1742 if (SHGetPathFromIDList(pItemIDList,
path) &&
path[0])
1745 if (SHGetMalloc(&pMalloc) == NOERROR) {
1746 pMalloc->Free(pItemIDList);
1750 return selectedFiles;
1754void QWindowsXpNativeFileDialog::populateOpenFileName(OPENFILENAME *ofn, HWND owner)
const
1756 ZeroMemory(ofn,
sizeof(OPENFILENAME));
1757 ofn->lStructSize =
sizeof(OPENFILENAME);
1758 ofn->hwndOwner = owner;
1761 int totalStringLength = 0;
1765 auto *
ptr =
new wchar_t[totalStringLength + 2 *
size + 1];
1766 ofn->lpstrFilter =
ptr;
1768 ptr += spec.description.toWCharArray(
ptr);
1770 ptr += spec.filter.toWCharArray(
ptr);
1775 if (nameFilterIndex >= 0)
1776 ofn->nFilterIndex = nameFilterIndex + 1;
1780 ofn->nMaxFile = 65535;
1782 initiallySelectedFile.
remove(u
'<');
1783 initiallySelectedFile.
remove(u
'>');
1784 initiallySelectedFile.
remove(u
'"');
1785 initiallySelectedFile.
remove(u
'|');
1788 ofn->lpstrTitle = (
wchar_t*)m_title.
utf16();
1797 defaultSuffix.
remove(0, 1);
1802 ofn->Flags = (OFN_NOCHANGEDIR | OFN_HIDEREADONLY | OFN_EXPLORER | OFN_PATHMUSTEXIST);
1805 ofn->Flags |= (OFN_FILEMUSTEXIST);
1807 ofn->Flags |= (OFN_ALLOWMULTISELECT);
1809 ofn->Flags |= OFN_OVERWRITEPROMPT;
1812QList<QUrl> QWindowsXpNativeFileDialog::execFileNames(HWND owner,
int *selectedFilterIndex)
const
1814 *selectedFilterIndex = -1;
1816 populateOpenFileName(&ofn, owner);
1819 if (isSave ? GetSaveFileNameW(&ofn) : GetOpenFileNameW(&ofn)) {
1820 *selectedFilterIndex = ofn.nFilterIndex - 1;
1825 if (ofn.Flags & (OFN_ALLOWMULTISELECT)) {
1826 wchar_t *
ptr = ofn.lpstrFile +
dir.
size() + 1;
1838 delete [] ofn.lpstrFile;
1839 delete [] ofn.lpstrInitialDir;
1840 delete [] ofn.lpstrFilter;
1841 delete [] ofn.lpstrDefExt;
1931#ifdef USE_NATIVE_COLOR_DIALOG
1936 enum { CustomColorCount = 16 };
1940 void setWindowTitle(
const QString &)
override {}
1943 void close()
override {}
1946 void doExec(HWND owner = 0)
override;
1948 COLORREF m_customColors[CustomColorCount];
1956 std::fill(m_customColors, m_customColors + 16, COLORREF(0));
1959void QWindowsNativeColorDialog::doExec(HWND owner)
1961 CHOOSECOLOR chooseColor;
1962 ZeroMemory(&chooseColor,
sizeof(chooseColor));
1963 chooseColor.lStructSize =
sizeof(chooseColor);
1964 chooseColor.hwndOwner = owner;
1965 chooseColor.lpCustColors = m_customColors;
1966 QRgb *qCustomColors = QColorDialogOptions::customColors();
1967 const int customColorCount =
qMin(QColorDialogOptions::customColorCount(),
1968 int(CustomColorCount));
1969 for (
int c= 0;
c < customColorCount; ++
c)
1970 m_customColors[
c] = qColorToCOLORREF(
QColor(qCustomColors[
c]));
1971 chooseColor.rgbResult = qColorToCOLORREF(*m_color);
1972 chooseColor.Flags = CC_FULLOPEN | CC_RGBINIT;
1973 m_code = ChooseColorW(&chooseColor) ?
1977 *m_color = COLORREFToQColor(chooseColor.rgbResult);
1978 for (
int c= 0;
c < customColorCount; ++
c)
1979 qCustomColors[
c] = COLORREFToQColor(m_customColors[
c]).rgb();
2000 QWindowsColorDialogHelper() : m_currentColor(new
QColor) {}
2005 virtual QColor currentColor()
const {
return *m_currentColor; }
2006 virtual void setCurrentColor(
const QColor &
c) { *m_currentColor =
c; }
2019 nativeDialog->setWindowTitle(options()->
windowTitle());
2022 return nativeDialog;
2037#ifdef USE_NATIVE_COLOR_DIALOG
2061#ifdef USE_NATIVE_COLOR_DIALOG
2062 return new QWindowsColorDialogHelper();
2078#include "qwindowsdialoghelpers.moc"
constexpr bool isSpace() const noexcept
Returns true if the character is a separator character (Separator_* categories or certain code points...
The QColor class provides colors based on RGB, HSV or CMYK values.
static QString tempPath()
Returns the absolute canonical path of the system's temporary directory.
static QString cleanPath(const QString &path)
Returns path with directory separators normalized (that is, platform-native separators converted to "...
static QString toNativeSeparators(const QString &pathName)
AcceptMode acceptMode() const
QString defaultSuffix() const
QStringList nameFilters() const
FileDialogOptions options() const
FileMode fileMode() const
QString windowTitle() const
\inmodule QtCore \reentrant
QString fileName() const
Returns the name of the file, excluding the path.
bool isDir() const
Returns true if this object points to a directory or to a symbolic link to a directory.
bool remove()
Removes the file specified by fileName().
static QWindow * focusWindow()
Returns the QWindow that receives events tied to focus, such as key events.
\inmodule QtCore \reentrant
QString errorString() const
Returns a human-readable description of the last device error that occurred.
qsizetype size() const noexcept
bool isEmpty() const noexcept
bool empty() const noexcept
void push_back(parameter_type t)
const T & constFirst() const noexcept
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
void deleteLater()
\threadsafe
\inmodule QtCore \reentrant
bool isValid() const
Returns true if the regular expression is a valid regular expression (that is, it contains no syntax ...
T * data() const noexcept
Returns the value of the pointer referenced by this object.
\macro QT_RESTRICTED_CAST_FROM_ASCII
qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
qsizetype toWCharArray(wchar_t *array) const
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
QString & replace(qsizetype i, qsizetype len, QChar after)
void chop(qsizetype n)
Removes n characters from the end of the string.
const ushort * utf16() const
Returns the QString as a '\0\'-terminated array of unsigned shorts.
void truncate(qsizetype pos)
Truncates the string at the given position index.
qsizetype size() const
Returns the number of characters in this string.
QString mid(qsizetype position, qsizetype n=-1) const
Returns a string that contains n characters of this string, starting at the specified position index.
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
static QString fromWCharArray(const wchar_t *string, qsizetype size=-1)
static QString static QString qsizetype indexOf(QChar c, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QString trimmed() const &
QString & remove(qsizetype i, qsizetype len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
\inmodule QtCore \reentrant
QString fileName() const override
Returns the complete unique filename backing the QTemporaryFile object.
bool open()
A QTemporaryFile will always be opened in QIODevice::ReadWrite mode, this allows easy access to the d...
void setAutoRemove(bool b)
Sets the QTemporaryFile into auto-remove mode if b is true.
static QUrl fromLocalFile(const QString &localfile)
Returns a QUrl representation of localFile, interpreted as a local file.
bool isValid() const
Returns true if the URL is non-empty and valid; otherwise returns false.
QUrl adjusted(FormattingOptions options) const
QString scheme() const
Returns the scheme of the URL.
QString errorString() const
QString toString(FormattingOptions options=FormattingOptions(PrettyDecoded)) const
Returns a string representation of the URL.
QString toLocalFile() const
Returns the path of this URL formatted as a local file path.
QString path(ComponentFormattingOptions options=FullyDecoded) const
Returns the path of the URL.
static QUuid fromString(QAnyStringView string) noexcept
static HWND handleOf(const QWindow *w)
static DWORD readAdvancedExplorerSettings(const wchar_t *subKey, DWORD defaultValue)
Helper for native Windows dialogs.
bool show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent) override
virtual bool supportsNonModalDialog(const QWindow *=nullptr) const
void timerEvent(QTimerEvent *) override
virtual QWindowsNativeDialogBase * createNativeDialog()=0
bool hasNativeDialog() const
~QWindowsDialogHelperBase()
QWindowsNativeDialogBase * nativeDialog() const
Run a non-modal native dialog in a separate thread.
QWindowsDialogThread(const QWindowsNativeDialogBasePtr &d, HWND owner)
QSharedPointer< QWindowsNativeDialogBase > QWindowsNativeDialogBasePtr
Helper for native Windows file dialogs.
QWindowsFileDialogHelper()
void setFilter() override
QWindowsNativeDialogBase * createNativeDialog() override
QString selectedNameFilter() const override
bool supportsNonModalDialog(const QWindow *=nullptr) const override
bool defaultNameFilterDisables() const override
QUrl directory() const override
void setDirectory(const QUrl &directory) override
void selectFile(const QUrl &filename) override
QList< QUrl > selectedFiles() const override
void selectNameFilter(const QString &filter) override
Explicitly shared file dialog parameters that are not in QFileDialogOptions.
QString selectedNameFilter() const
void fromOptions(const QSharedPointer< QFileDialogOptions > &o)
void setSelectedNameFilter(const QString &)
QString selectedFile() const
void setDirectory(const QUrl &)
QWindowsFileDialogSharedData()
QList< QUrl > selectedFiles() const
void setSelectedFiles(const QList< QUrl > &)
static QWindowsIntegration * instance()
Native Windows color dialog.
Base class for Windows native dialogs.
virtual void setWindowTitle(const QString &title)=0
void exec(HWND owner=nullptr)
virtual void doExec(HWND owner=nullptr)=0
QWindowsNativeDialogBase()
Windows native file dialog wrapper around IFileOpenDialog, IFileSaveDialog.
void setDefaultSuffix(const QString &s)
bool hasDefaultSuffix() const
QWindowsFileDialogSharedData & data()
void setDirectory(const QUrl &directory)
void setLabelText(QFileDialogOptions::DialogLabel l, const QString &text)
void selectFile(const QString &fileName) const
void currentChanged(const QUrl &file)
bool hideFiltersDetails() const
QString selectedNameFilter() const
QWindowsNativeFileDialogBase(const QWindowsFileDialogSharedData &data)
void setHideFiltersDetails(bool h)
virtual void setNameFilters(const QStringList &f)
static IShellItem * shellItem(const QUrl &url)
IFileDialog * fileDialog() const
virtual QList< QUrl > selectedFiles() const =0
void setMode(QFileDialogOptions::FileMode mode, QFileDialogOptions::AcceptMode acceptMode, QFileDialogOptions::FileDialogOptions options)
void selectNameFilter(const QString &filter)
~QWindowsNativeFileDialogBase() override
static QWindowsNativeFileDialogBase * create(QFileDialogOptions::AcceptMode am, const QWindowsFileDialogSharedData &data)
Factory method for QWindowsNativeFileDialogBase returning QWindowsNativeOpenFileDialog or QWindowsNat...
const QWindowsFileDialogSharedData & data() const
void directoryEntered(const QUrl &directory)
void setWindowTitle(const QString &title) override
void updateSelectedNameFilter()
bool init(const CLSID &clsId, const IID &iid)
QString directory() const
void setDefaultSuffixSys(const QString &s)
void filterSelected(const QString &filter)
void doExec(HWND owner=nullptr) override
virtual QList< QUrl > dialogResult() const =0
void onFolderChange(IShellItem *)
Listens to IFileDialog events and forwards them to QWindowsNativeFileDialogBase.
IFACEMETHODIMP OnFileOk(IFileDialog *) override
IFACEMETHODIMP OnFolderChange(IFileDialog *) override
QWindowsNativeFileDialogEventHandler(QWindowsNativeFileDialogBase *nativeFileDialog)
IFACEMETHODIMP OnShareViolation(IFileDialog *, IShellItem *, FDE_SHAREVIOLATION_RESPONSE *) override
IFACEMETHODIMP OnOverwrite(IFileDialog *, IShellItem *, FDE_OVERWRITE_RESPONSE *) override
static IFileDialogEvents * create(QWindowsNativeFileDialogBase *nativeFileDialog)
IFACEMETHODIMP OnFolderChanging(IFileDialog *, IShellItem *) override
IFACEMETHODIMP OnSelectionChange(IFileDialog *) override
IFACEMETHODIMP OnTypeChange(IFileDialog *) override
Windows native file save dialog wrapper around IFileOpenDialog.
QWindowsNativeOpenFileDialog(const QWindowsFileDialogSharedData &data)
QList< QUrl > dialogResult() const override
QList< QUrl > selectedFiles() const override
Windows native file save dialog wrapper around IFileSaveDialog.
void setNameFilters(const QStringList &f) override
QWindowsNativeSaveFileDialog(const QWindowsFileDialogSharedData &data)
QList< QUrl > dialogResult() const override
QList< QUrl > selectedFiles() const override
bool isFileSystem() const
SFGAOF attributes() const
QWindowsShellItem(IShellItem *item)
QString normalDisplay() const
static IShellItems itemsFromItemArray(IShellItemArray *items)
QString urlString() const
QString fileSysPath() const
void format(QDebug &d) const
bool copyData(QIODevice *out, QString *errorMessage)
QString desktopAbsoluteParsing() const
std::vector< IShellItem * > IShellItems
Dialog helper using QWindowsXpNativeFileDialog.
void selectNameFilter(const QString &) override
void selectFile(const QUrl &url) override
bool defaultNameFilterDisables() const override
QList< QUrl > selectedFiles() const override
QWindowsXpFileDialogHelper()=default
void setFilter() override
bool supportsNonModalDialog(const QWindow *=nullptr) const override
QWindowsNativeDialogBase * createNativeDialog() override
QUrl directory() const override
QString selectedNameFilter() const override
void setDirectory(const QUrl &directory) override
Native Windows directory dialog for Windows XP using SHlib-functions.
QSharedPointer< QFileDialogOptions > OptionsPtr
static QWindowsXpNativeFileDialog * create(const OptionsPtr &options, const QWindowsFileDialogSharedData &data)
void setWindowTitle(const QString &t) override
int existingDirCallback(HWND hwnd, UINT uMsg, LPARAM lParam)
void doExec(HWND owner=nullptr) override
void qErrnoWarning(const char *msg,...)
Combined button and popup list for selecting options.
bool useHelper(QPlatformTheme::DialogType type)
QPlatformDialogHelper * createHelper(QPlatformTheme::DialogType type)
HWND getHWND(IFileDialog *fileDialog)
void eatMouseMove()
After closing a windows dialog with a double click (i.e.
QTextStream & hex(QTextStream &stream)
Calls QTextStream::setIntegerBase(16) on stream and returns stream.
QTextStream & showbase(QTextStream &stream)
Calls QTextStream::setNumberFlags(QTextStream::numberFlags() | QTextStream::ShowBase) on stream and r...
QTextStream & dec(QTextStream &stream)
Calls QTextStream::setIntegerBase(10) on stream and returns stream.
SharedPointerFileDialogOptions m_options
void qAddPostRoutine(QtCleanUpFunction p)
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
#define qCCritical(category,...)
#define qCWarning(category,...)
#define qCDebug(category,...)
static ControlElement< T > * ptr(QWidget *widget)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLint GLsizei GLsizei GLenum format
GLfloat GLfloat GLfloat GLfloat h
GLsizei const GLchar *const * path
QT_BEGIN_NAMESPACE typedef unsigned int QRgb
#define qPrintable(string)
#define QStringLiteral(str)
static QString errorMessage(QUrlPrivate::ErrorCode errorCode, const QString &errorSource, qsizetype errorPosition)
static QT_BEGIN_NAMESPACE QString windowTitle(HWND hwnd)
static bool validFileNameCharacter(QChar c)
static IFileDialog2 * getFileDialog2(IFileDialog *fileDialog)
QDebug operator<<(QDebug d, const QWindowsShellItem &i)
static int indexOfNameFilter(const QStringList &filters, const QString &needle)
static void cleanupTemporaryItemCopies()
static bool isClsid(const QString &s)
static QList< FilterSpec > filterSpecs(const QStringList &filters, bool hideFilterDetails, int *totalStringLength)
static QString createTemporaryItemCopy(QWindowsShellItem &qItem, QString *errorMessage)
static IShellLibrary * sHLoadLibraryFromItem(IShellItem *libraryItem, DWORD mode)
static wchar_t * qStringToWCharArray(const QString &s, size_t reserveSize=0)
static bool isHexRange(const QString &s, int start, int end)
static QUrl itemToDialogUrl(QWindowsShellItem &qItem, QString *errorMessage)
PIDLIST_ABSOLUTE qt_LpItemIdList
static QString suffixFromFilter(const QString &filter)
static int QT_WIN_CALLBACK xpFileDialogGetExistingDirCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
QFileInfo info(fileName)
[8]
QTextStream out(stdout)
[7]
QUrl url("example.com")
[constructor-url-reference]
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
QFileDialog dialog(this)
[1]
const QStringList filters({"Image files (*.png *.xpm *.jpg)", "Text files (*.txt)", "Any files (*)" })
[6]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent
static char * tempFilePattern()