summaryrefslogtreecommitdiffstats
path: root/src/plugins/platformthemes
diff options
context:
space:
mode:
authorMichael BrĂ¼ning <michael.bruning@qt.io>2017-03-28 17:12:44 +0200
committerMichael BrĂ¼ning <michael.bruning@qt.io>2017-03-29 12:25:00 +0000
commit78f761318a20f320e04a8439101d429136fe3d0a (patch)
tree9655e575183e12c9dbb4cae1c5aef0416f3161ac /src/plugins/platformthemes
parentff259bffe6b1d09dfec2f56f6c9a4a326ff8e98a (diff)
Set the mode for the GTK3 file chooser also in selectFile
If the mode is not GTK_FILE_CHOOSER_ACTION_SAVE or GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER , a GTK warning will be generated which makes Qt WebEngine's Glib error handler assert. Doing so only when showing the dialog is too late. This patch moves the actual file selection to a private method that can be called from both selectFile and applyOptions in order to prevent overwriting the file chooser action potentially multiple times. Task-number: QTBUG-59692 Change-Id: Ied939248cdc3a0b4c9e8239ab61ba617a46b8496 Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src/plugins/platformthemes')
-rw-r--r--src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp19
-rw-r--r--src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.h2
2 files changed, 18 insertions, 3 deletions
diff --git a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp
index 8b6ec31400..b1821ebbd2 100644
--- a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp
+++ b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp
@@ -316,6 +316,12 @@ QUrl QGtk3FileDialogHelper::directory() const
void QGtk3FileDialogHelper::selectFile(const QUrl &filename)
{
+ setFileChooserAction();
+ selectFileInternal(filename);
+}
+
+void QGtk3FileDialogHelper::selectFileInternal(const QUrl &filename)
+{
GtkDialog *gtkDialog = d->gtkDialog();
if (options()->acceptMode() == QFileDialogOptions::AcceptSave) {
QFileInfo fi(filename.toLocalFile());
@@ -409,6 +415,14 @@ static GtkFileChooserAction gtkFileChooserAction(const QSharedPointer<QFileDialo
}
}
+void QGtk3FileDialogHelper::setFileChooserAction()
+{
+ GtkDialog *gtkDialog = d->gtkDialog();
+
+ const GtkFileChooserAction action = gtkFileChooserAction(options());
+ gtk_file_chooser_set_action(GTK_FILE_CHOOSER(gtkDialog), action);
+}
+
void QGtk3FileDialogHelper::applyOptions()
{
GtkDialog *gtkDialog = d->gtkDialog();
@@ -417,8 +431,7 @@ void QGtk3FileDialogHelper::applyOptions()
gtk_window_set_title(GTK_WINDOW(gtkDialog), opts->windowTitle().toUtf8());
gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(gtkDialog), true);
- const GtkFileChooserAction action = gtkFileChooserAction(opts);
- gtk_file_chooser_set_action(GTK_FILE_CHOOSER(gtkDialog), action);
+ setFileChooserAction();
const bool selectMultiple = opts->fileMode() == QFileDialogOptions::ExistingFiles;
gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(gtkDialog), selectMultiple);
@@ -437,7 +450,7 @@ void QGtk3FileDialogHelper::applyOptions()
setDirectory(opts->initialDirectory());
foreach (const QUrl &filename, opts->initiallySelectedFiles())
- selectFile(filename);
+ selectFileInternal(filename);
const QString initialNameFilter = opts->initiallySelectedNameFilter();
if (!initialNameFilter.isEmpty())
diff --git a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.h b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.h
index 99add3bda3..ba43046e04 100644
--- a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.h
+++ b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.h
@@ -110,6 +110,8 @@ private:
static void onFilterChanged(QGtk3FileDialogHelper *helper);
void applyOptions();
void setNameFilters(const QStringList &filters);
+ void selectFileInternal(const QUrl &filename);
+ void setFileChooserAction();
QUrl _dir;
QList<QUrl> _selection;