summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@digia.com>2013-01-23 12:48:21 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-24 06:57:32 +0100
commitbfd73eaba3000861037d03787f87d1f4dafefea8 (patch)
treeb5db787629f749ab68052a0e4aa47691a15a76ee /src/plugins/platforms
parent6476d6728eb3cde8e4a5fd0eb607b92977932296 (diff)
Respect the filename specified when showing the native filedialog
When a filename was specified as part of the start up directory then it should ensure this is put in the filename lineedit in the native filedialog. Change-Id: I2b190933d46553908b5bcf17506cb2a95fb1f982 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/windows/qwindowsdialoghelpers.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
index 15520c98b0..74193c47a3 100644
--- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
+++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
@@ -668,6 +668,7 @@ public:
inline void setNameFilters(const QStringList &f);
inline void selectNameFilter(const QString &filter);
inline QString selectedNameFilter() const;
+ void selectFile(const QString &fileName) const;
bool hideFiltersDetails() const { return m_hideFiltersDetails; }
void setHideFiltersDetails(bool h) { m_hideFiltersDetails = h; }
void setDefaultSuffix(const QString &s);
@@ -961,6 +962,11 @@ void QWindowsNativeFileDialogBase::setLabelText(QFileDialogOptions::DialogLabel
}
}
+void QWindowsNativeFileDialogBase::selectFile(const QString &fileName) const
+{
+ m_fileDialog->SetFileName((wchar_t*)fileName.utf16());
+}
+
// Return the index of the selected filter, accounting for QFileDialog
// sometimes stripping the filter specification depending on the
// hideFilterDetails setting.
@@ -1230,6 +1236,12 @@ QWindowsNativeDialogBase *QWindowsFileDialogHelper::createNativeDialog()
const QString initialDirectory = opts->initialDirectory();
if (!initialDirectory.isEmpty())
result->setDirectory(initialDirectory);
+ const QStringList initialSelection = opts->initiallySelectedFiles();
+ if (initialSelection.size() > 0) {
+ QFileInfo info(initialSelection.front());
+ if (!info.isDir())
+ result->selectFile(info.fileName());
+ }
const QString initialNameFilter = opts->initiallySelectedNameFilter();
if (!initialNameFilter.isEmpty())
result->selectNameFilter(initialNameFilter);
@@ -1255,9 +1267,13 @@ QString QWindowsFileDialogHelper::directory() const
return QString();
}
-void QWindowsFileDialogHelper::selectFile(const QString & /* filename */)
+void QWindowsFileDialogHelper::selectFile(const QString &fileName)
{
- // Not implemented.
+ if (QWindowsContext::verboseDialogs)
+ qDebug("%s %s" , __FUNCTION__, qPrintable(fileName));
+
+ if (QWindowsNativeFileDialogBase *nfd = nativeFileDialog())
+ nfd->selectFile(fileName);
}
QStringList QWindowsFileDialogHelper::selectedFiles() const