Windows QPA: Implement setting the "Cancel" button text of file dialogs
The functionality was missing in IFileDialog. As of Windows 7; IFileDialog can be queried for IFileDialog2, which provides it. Task-number: QTBUG-44112 Change-Id: I0c0345d516bbc36f9bb519545f5eda1289c9ef23 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
parent
3d08f308f1
commit
d135acfa43
@ -1001,6 +1001,13 @@ void QWindowsNativeFileDialogBase::setDefaultSuffixSys(const QString &s)
|
|||||||
m_fileDialog->SetDefaultExtension(wSuffix);
|
m_fileDialog->SetDefaultExtension(wSuffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline IFileDialog2 *getFileDialog2(IFileDialog *fileDialog)
|
||||||
|
{
|
||||||
|
IFileDialog2 *result;
|
||||||
|
return SUCCEEDED(fileDialog->QueryInterface(IID_IFileDialog2, reinterpret_cast<void **>(&result)))
|
||||||
|
? result : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void QWindowsNativeFileDialogBase::setLabelText(QFileDialogOptions::DialogLabel l, const QString &text)
|
void QWindowsNativeFileDialogBase::setLabelText(QFileDialogOptions::DialogLabel l, const QString &text)
|
||||||
{
|
{
|
||||||
wchar_t *wText = const_cast<wchar_t *>(reinterpret_cast<const wchar_t *>(text.utf16()));
|
wchar_t *wText = const_cast<wchar_t *>(reinterpret_cast<const wchar_t *>(text.utf16()));
|
||||||
@ -1011,8 +1018,13 @@ void QWindowsNativeFileDialogBase::setLabelText(QFileDialogOptions::DialogLabel
|
|||||||
case QFileDialogOptions::Accept:
|
case QFileDialogOptions::Accept:
|
||||||
m_fileDialog->SetOkButtonLabel(wText);
|
m_fileDialog->SetOkButtonLabel(wText);
|
||||||
break;
|
break;
|
||||||
case QFileDialogOptions::LookIn:
|
|
||||||
case QFileDialogOptions::Reject:
|
case QFileDialogOptions::Reject:
|
||||||
|
if (IFileDialog2 *dialog2 = getFileDialog2(m_fileDialog)) {
|
||||||
|
dialog2->SetCancelButtonLabel(wText);
|
||||||
|
dialog2->Release();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case QFileDialogOptions::LookIn:
|
||||||
case QFileDialogOptions::FileType:
|
case QFileDialogOptions::FileType:
|
||||||
case QFileDialogOptions::DialogLabelCount:
|
case QFileDialogOptions::DialogLabelCount:
|
||||||
break;
|
break;
|
||||||
@ -1347,6 +1359,8 @@ QWindowsNativeDialogBase *QWindowsFileDialogHelper::createNativeDialog()
|
|||||||
result->setLabelText(QFileDialogOptions::FileName, opts->labelText(QFileDialogOptions::FileName));
|
result->setLabelText(QFileDialogOptions::FileName, opts->labelText(QFileDialogOptions::FileName));
|
||||||
if (opts->isLabelExplicitlySet(QFileDialogOptions::Accept))
|
if (opts->isLabelExplicitlySet(QFileDialogOptions::Accept))
|
||||||
result->setLabelText(QFileDialogOptions::Accept, opts->labelText(QFileDialogOptions::Accept));
|
result->setLabelText(QFileDialogOptions::Accept, opts->labelText(QFileDialogOptions::Accept));
|
||||||
|
if (opts->isLabelExplicitlySet(QFileDialogOptions::Reject))
|
||||||
|
result->setLabelText(QFileDialogOptions::Reject, opts->labelText(QFileDialogOptions::Reject));
|
||||||
result->updateDirectory();
|
result->updateDirectory();
|
||||||
result->updateSelectedNameFilter();
|
result->updateSelectedNameFilter();
|
||||||
const QList<QUrl> initialSelection = opts->initiallySelectedFiles();
|
const QList<QUrl> initialSelection = opts->initiallySelectedFiles();
|
||||||
|
Loading…
Reference in New Issue
Block a user