Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qgtk3dialoghelpers.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5#include "qgtk3theme.h"
6
7#include <qeventloop.h>
8#include <qwindow.h>
9#include <qcolor.h>
10#include <qdebug.h>
11#include <qfont.h>
12#include <qfileinfo.h>
13
14#include <private/qguiapplication_p.h>
15#include <private/qgenericunixservices_p.h>
16#include <qpa/qplatformintegration.h>
17#include <qpa/qplatformfontdatabase.h>
18
19#undef signals
20#include <gtk/gtk.h>
21#include <gdk/gdk.h>
22#include <pango/pango.h>
23
24#if QT_CONFIG(xlib) && defined(GDK_WINDOWING_X11)
25#include <gdk/gdkx.h>
26#endif
27
28#ifdef GDK_WINDOWING_WAYLAND
29#include <gdk/gdkwayland.h>
30#endif
31
32// The size of the preview we display for selected image files. We set height
33// larger than width because generally there is more free space vertically
34// than horizontally (setting the preview image will always expand the width of
35// the dialog, but usually not the height). The image's aspect ratio will always
36// be preserved.
37#define PREVIEW_WIDTH 256
38#define PREVIEW_HEIGHT 512
39
41
42using namespace Qt::StringLiterals;
43
45{
46public:
47 QGtk3Dialog(GtkWidget *gtkWidget, QPlatformDialogHelper *helper);
49
50 GtkDialog *gtkDialog() const;
51
52 void exec();
53 bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent);
54 void hide();
55
56protected:
57 static void onResponse(QPlatformDialogHelper *helper, int response);
58
59private:
60 GtkWidget *gtkWidget;
62 Qt::WindowModality modality;
63};
64
66 : gtkWidget(gtkWidget)
67 , helper(helper)
68{
69 g_signal_connect_swapped(G_OBJECT(gtkWidget), "response", G_CALLBACK(onResponse), helper);
70 g_signal_connect(G_OBJECT(gtkWidget), "delete-event", G_CALLBACK(gtk_widget_hide_on_delete), NULL);
71}
72
74{
75 gtk_clipboard_store(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD));
76 gtk_widget_destroy(gtkWidget);
77}
78
80{
81 return GTK_DIALOG(gtkWidget);
82}
83
85{
86 if (modality == Qt::ApplicationModal) {
87 // block input to the whole app, including other GTK dialogs
88 gtk_dialog_run(gtkDialog());
89 } else {
90 // block input to the window, allow input to other GTK dialogs
91 QEventLoop loop;
92 loop.connect(helper, SIGNAL(accept()), SLOT(quit()));
93 loop.connect(helper, SIGNAL(reject()), SLOT(quit()));
94 loop.exec();
95 }
96}
97
98bool QGtk3Dialog::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent)
99{
101 this->modality = modality;
102
103 gtk_widget_realize(gtkWidget); // creates X window
104
105 GdkWindow *gdkWindow = gtk_widget_get_window(gtkWidget);
106 if (parent) {
107 if (false) {
108#if defined(GDK_WINDOWING_WAYLAND) && GTK_CHECK_VERSION(3, 22, 0)
109 } else if (GDK_IS_WAYLAND_WINDOW(gdkWindow)) {
110 const auto unixServices = dynamic_cast<QGenericUnixServices *>(
112 if (unixServices) {
113 const auto handle = unixServices->portalWindowIdentifier(parent);
114 if (handle.startsWith("wayland:"_L1)) {
115 auto handleBa = handle.sliced(8).toUtf8();
116 gdk_wayland_window_set_transient_for_exported(gdkWindow, handleBa.data());
117 }
118 }
119#endif
120#if QT_CONFIG(xlib) && defined(GDK_WINDOWING_X11)
121 } else if (GDK_IS_X11_WINDOW(gdkWindow)) {
122 GdkDisplay *gdkDisplay = gdk_window_get_display(gdkWindow);
123 XSetTransientForHint(gdk_x11_display_get_xdisplay(gdkDisplay),
124 gdk_x11_window_get_xid(gdkWindow),
125 parent->winId());
126#endif
127 }
128 }
129
130 if (modality != Qt::NonModal) {
131 gdk_window_set_modal_hint(gdkWindow, true);
132 }
133
134 gtk_widget_show(gtkWidget);
135 gdk_window_focus(gdkWindow, GDK_CURRENT_TIME);
136 return true;
137}
138
140{
141 gtk_widget_hide(gtkWidget);
142}
143
145{
146 if (response == GTK_RESPONSE_OK)
147 emit helper->accept();
148 else
149 emit helper->reject();
150}
151
153{
154 d.reset(new QGtk3Dialog(gtk_color_chooser_dialog_new("", nullptr), this));
155 g_signal_connect_swapped(d->gtkDialog(), "notify::rgba", G_CALLBACK(onColorChanged), this);
156}
157
159{
160}
161
163{
164 applyOptions();
165 return d->show(flags, modality, parent);
166}
167
169{
170 d->exec();
171}
172
174{
175 d->hide();
176}
177
179{
180 GtkDialog *gtkDialog = d->gtkDialog();
181 if (color.alpha() < 255)
182 gtk_color_chooser_set_use_alpha(GTK_COLOR_CHOOSER(gtkDialog), true);
183 GdkRGBA gdkColor;
184 gdkColor.red = color.redF();
185 gdkColor.green = color.greenF();
186 gdkColor.blue = color.blueF();
187 gdkColor.alpha = color.alphaF();
188 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(gtkDialog), &gdkColor);
189}
190
192{
193 GtkDialog *gtkDialog = d->gtkDialog();
194 GdkRGBA gdkColor;
195 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(gtkDialog), &gdkColor);
196 return QColor::fromRgbF(gdkColor.red, gdkColor.green, gdkColor.blue, gdkColor.alpha);
197}
198
199void QGtk3ColorDialogHelper::onColorChanged(QGtk3ColorDialogHelper *dialog)
200{
201 emit dialog->currentColorChanged(dialog->currentColor());
202}
203
204void QGtk3ColorDialogHelper::applyOptions()
205{
206 GtkDialog *gtkDialog = d->gtkDialog();
207 gtk_window_set_title(GTK_WINDOW(gtkDialog), qUtf8Printable(options()->windowTitle()));
208
209 gtk_color_chooser_set_use_alpha(GTK_COLOR_CHOOSER(gtkDialog), options()->testOption(QColorDialogOptions::ShowAlphaChannel));
210}
211
213{
214 d.reset(new QGtk3Dialog(gtk_file_chooser_dialog_new("", nullptr,
215 GTK_FILE_CHOOSER_ACTION_OPEN,
218 NULL), this));
219
220 g_signal_connect(GTK_FILE_CHOOSER(d->gtkDialog()), "selection-changed", G_CALLBACK(onSelectionChanged), this);
221 g_signal_connect_swapped(GTK_FILE_CHOOSER(d->gtkDialog()), "current-folder-changed", G_CALLBACK(onCurrentFolderChanged), this);
222 g_signal_connect_swapped(GTK_FILE_CHOOSER(d->gtkDialog()), "notify::filter", G_CALLBACK(onFilterChanged), this);
223
224 previewWidget = gtk_image_new();
225 g_signal_connect(G_OBJECT(d->gtkDialog()), "update-preview", G_CALLBACK(onUpdatePreview), this);
226 gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(d->gtkDialog()), previewWidget);
227}
228
230{
231}
232
234{
235 _dir.clear();
236 _selection.clear();
237
238 applyOptions();
239 return d->show(flags, modality, parent);
240}
241
243{
244 d->exec();
245}
246
248{
249 // After GtkFileChooserDialog has been hidden, gtk_file_chooser_get_current_folder()
250 // & gtk_file_chooser_get_filenames() will return bogus values -> cache the actual
251 // values before hiding the dialog
252 _dir = directory();
253 _selection = selectedFiles();
254
255 d->hide();
256}
257
259{
260 return false;
261}
262
264{
265 GtkDialog *gtkDialog = d->gtkDialog();
266 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(gtkDialog), qUtf8Printable(directory.toLocalFile()));
267}
268
270{
271 // While GtkFileChooserDialog is hidden, gtk_file_chooser_get_current_folder()
272 // returns a bogus value -> return the cached value before hiding
273 if (!_dir.isEmpty())
274 return _dir;
275
276 QString ret;
277 GtkDialog *gtkDialog = d->gtkDialog();
278 gchar *folder = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(gtkDialog));
279 if (folder) {
280 ret = QString::fromUtf8(folder);
281 g_free(folder);
282 }
283 return QUrl::fromLocalFile(ret);
284}
285
287{
288 setFileChooserAction();
289 selectFileInternal(filename);
290}
291
292void QGtk3FileDialogHelper::selectFileInternal(const QUrl &filename)
293{
294 GtkDialog *gtkDialog = d->gtkDialog();
295 if (options()->acceptMode() == QFileDialogOptions::AcceptSave) {
296 QFileInfo fi(filename.toLocalFile());
297 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(gtkDialog), qUtf8Printable(fi.path()));
298 gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(gtkDialog), qUtf8Printable(fi.fileName()));
299 } else {
300 gtk_file_chooser_select_filename(GTK_FILE_CHOOSER(gtkDialog), qUtf8Printable(filename.toLocalFile()));
301 }
302}
303
305{
306 // While GtkFileChooserDialog is hidden, gtk_file_chooser_get_filenames()
307 // returns a bogus value -> return the cached value before hiding
308 if (!_selection.isEmpty())
309 return _selection;
310
312 GtkDialog *gtkDialog = d->gtkDialog();
313 GSList *filenames = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(gtkDialog));
314 for (GSList *it = filenames; it; it = it->next)
315 selection += QUrl::fromLocalFile(QString::fromUtf8((const char*)it->data));
316 g_slist_free(filenames);
317 return selection;
318}
319
321{
322 applyOptions();
323}
324
326{
327 GtkFileFilter *gtkFilter = _filters.value(filter);
328 if (gtkFilter) {
329 GtkDialog *gtkDialog = d->gtkDialog();
330 gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(gtkDialog), gtkFilter);
331 }
332}
333
335{
336 GtkDialog *gtkDialog = d->gtkDialog();
337 GtkFileFilter *gtkFilter = gtk_file_chooser_get_filter(GTK_FILE_CHOOSER(gtkDialog));
338 return _filterNames.value(gtkFilter);
339}
340
341void QGtk3FileDialogHelper::onSelectionChanged(GtkDialog *gtkDialog, QGtk3FileDialogHelper *helper)
342{
344 gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(gtkDialog));
345 if (filename) {
346 selection = QString::fromUtf8(filename);
347 g_free(filename);
348 }
350}
351
352void QGtk3FileDialogHelper::onCurrentFolderChanged(QGtk3FileDialogHelper *dialog)
353{
355}
356
357void QGtk3FileDialogHelper::onFilterChanged(QGtk3FileDialogHelper *dialog)
358{
360}
361
362void QGtk3FileDialogHelper::onUpdatePreview(GtkDialog *gtkDialog, QGtk3FileDialogHelper *helper)
363{
364 gchar *filename = gtk_file_chooser_get_preview_filename(GTK_FILE_CHOOSER(gtkDialog));
365 if (!filename) {
366 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(gtkDialog), false);
367 return;
368 }
369
370 // Don't attempt to open anything which isn't a regular file. If a named pipe,
371 // this may hang.
372 QFileInfo fileinfo(filename);
373 if (!fileinfo.exists() || !fileinfo.isFile()) {
374 g_free(filename);
375 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(gtkDialog), false);
376 return;
377 }
378
379 // This will preserve the image's aspect ratio.
380 GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file_at_size(filename, PREVIEW_WIDTH, PREVIEW_HEIGHT, 0);
381 g_free(filename);
382 if (pixbuf) {
383 gtk_image_set_from_pixbuf(GTK_IMAGE(helper->previewWidget), pixbuf);
384 g_object_unref(pixbuf);
385 }
386 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(gtkDialog), pixbuf ? true : false);
387}
388
389static GtkFileChooserAction gtkFileChooserAction(const QSharedPointer<QFileDialogOptions> &options)
390{
391 switch (options->fileMode()) {
395 if (options->acceptMode() == QFileDialogOptions::AcceptOpen)
396 return GTK_FILE_CHOOSER_ACTION_OPEN;
397 else
398 return GTK_FILE_CHOOSER_ACTION_SAVE;
401 default:
402 if (options->acceptMode() == QFileDialogOptions::AcceptOpen)
403 return GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
404 else
405 return GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER;
406 }
407}
408
409void QGtk3FileDialogHelper::setFileChooserAction()
410{
411 GtkDialog *gtkDialog = d->gtkDialog();
412
413 const GtkFileChooserAction action = gtkFileChooserAction(options());
414 gtk_file_chooser_set_action(GTK_FILE_CHOOSER(gtkDialog), action);
415}
416
417void QGtk3FileDialogHelper::applyOptions()
418{
419 GtkDialog *gtkDialog = d->gtkDialog();
421
422 gtk_window_set_title(GTK_WINDOW(gtkDialog), qUtf8Printable(opts->windowTitle()));
423 gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(gtkDialog), true);
424
425 setFileChooserAction();
426
427 const bool selectMultiple = opts->fileMode() == QFileDialogOptions::ExistingFiles;
428 gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(gtkDialog), selectMultiple);
429
430 const bool confirmOverwrite = !opts->testOption(QFileDialogOptions::DontConfirmOverwrite);
431 gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(gtkDialog), confirmOverwrite);
432
433 const bool readOnly = opts->testOption(QFileDialogOptions::ReadOnly);
434 gtk_file_chooser_set_create_folders(GTK_FILE_CHOOSER(gtkDialog), !readOnly);
435
436 const QStringList nameFilters = opts->nameFilters();
437 if (!nameFilters.isEmpty())
438 setNameFilters(nameFilters);
439
440 if (opts->initialDirectory().isLocalFile())
441 setDirectory(opts->initialDirectory());
442
443 foreach (const QUrl &filename, opts->initiallySelectedFiles())
444 selectFileInternal(filename);
445
446 const QString initialNameFilter = opts->initiallySelectedNameFilter();
447 if (!initialNameFilter.isEmpty())
448 selectNameFilter(initialNameFilter);
449
450 GtkWidget *acceptButton = gtk_dialog_get_widget_for_response(gtkDialog, GTK_RESPONSE_OK);
451 if (acceptButton) {
452 if (opts->isLabelExplicitlySet(QFileDialogOptions::Accept))
453 gtk_button_set_label(GTK_BUTTON(acceptButton), qUtf8Printable(opts->labelText(QFileDialogOptions::Accept)));
454 else if (opts->acceptMode() == QFileDialogOptions::AcceptOpen)
455 gtk_button_set_label(GTK_BUTTON(acceptButton), qUtf8Printable(QGtk3Theme::defaultStandardButtonText(QPlatformDialogHelper::Open)));
456 else
457 gtk_button_set_label(GTK_BUTTON(acceptButton), qUtf8Printable(QGtk3Theme::defaultStandardButtonText(QPlatformDialogHelper::Save)));
458 }
459
460 GtkWidget *rejectButton = gtk_dialog_get_widget_for_response(gtkDialog, GTK_RESPONSE_CANCEL);
461 if (rejectButton) {
462 if (opts->isLabelExplicitlySet(QFileDialogOptions::Reject))
463 gtk_button_set_label(GTK_BUTTON(rejectButton), qUtf8Printable(opts->labelText(QFileDialogOptions::Reject)));
464 else
465 gtk_button_set_label(GTK_BUTTON(rejectButton), qUtf8Printable(QGtk3Theme::defaultStandardButtonText(QPlatformDialogHelper::Cancel)));
466 }
467}
468
469void QGtk3FileDialogHelper::setNameFilters(const QStringList &filters)
470{
471 GtkDialog *gtkDialog = d->gtkDialog();
472 foreach (GtkFileFilter *filter, _filters)
473 gtk_file_chooser_remove_filter(GTK_FILE_CHOOSER(gtkDialog), filter);
474
475 _filters.clear();
476 _filterNames.clear();
477
478 foreach (const QString &filter, filters) {
479 GtkFileFilter *gtkFilter = gtk_file_filter_new();
480 const QString name = filter.left(filter.indexOf(u'('));
481 const QStringList extensions = cleanFilterList(filter);
482
483 gtk_file_filter_set_name(gtkFilter, qUtf8Printable(name.isEmpty() ? extensions.join(", "_L1) : name));
484 foreach (const QString &ext, extensions)
485 gtk_file_filter_add_pattern(gtkFilter, qUtf8Printable(ext));
486
487 gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(gtkDialog), gtkFilter);
488
489 _filters.insert(filter, gtkFilter);
490 _filterNames.insert(gtkFilter, filter);
491 }
492}
493
495{
496 d.reset(new QGtk3Dialog(gtk_font_chooser_dialog_new("", nullptr), this));
497 g_signal_connect_swapped(d->gtkDialog(), "notify::font", G_CALLBACK(onFontChanged), this);
498}
499
501{
502}
503
505{
506 applyOptions();
507 return d->show(flags, modality, parent);
508}
509
511{
512 d->exec();
513}
514
516{
517 d->hide();
518}
519
521{
522 PangoFontDescription *desc = pango_font_description_new();
523 pango_font_description_set_size(desc, (font.pointSizeF() > 0.0 ? font.pointSizeF() : QFontInfo(font).pointSizeF()) * PANGO_SCALE);
524 pango_font_description_set_family(desc, qUtf8Printable(QFontInfo(font).family()));
525
526 int weight = font.weight();
527 if (weight >= QFont::Black)
528 pango_font_description_set_weight(desc, PANGO_WEIGHT_HEAVY);
529 else if (weight >= QFont::ExtraBold)
530 pango_font_description_set_weight(desc, PANGO_WEIGHT_ULTRABOLD);
531 else if (weight >= QFont::Bold)
532 pango_font_description_set_weight(desc, PANGO_WEIGHT_BOLD);
533 else if (weight >= QFont::DemiBold)
534 pango_font_description_set_weight(desc, PANGO_WEIGHT_SEMIBOLD);
535 else if (weight >= QFont::Medium)
536 pango_font_description_set_weight(desc, PANGO_WEIGHT_MEDIUM);
537 else if (weight >= QFont::Normal)
538 pango_font_description_set_weight(desc, PANGO_WEIGHT_NORMAL);
539 else if (weight >= QFont::Light)
540 pango_font_description_set_weight(desc, PANGO_WEIGHT_LIGHT);
541 else if (weight >= QFont::ExtraLight)
542 pango_font_description_set_weight(desc, PANGO_WEIGHT_ULTRALIGHT);
543 else
544 pango_font_description_set_weight(desc, PANGO_WEIGHT_THIN);
545
546 int style = font.style();
547 if (style == QFont::StyleItalic)
548 pango_font_description_set_style(desc, PANGO_STYLE_ITALIC);
549 else if (style == QFont::StyleOblique)
550 pango_font_description_set_style(desc, PANGO_STYLE_OBLIQUE);
551 else
552 pango_font_description_set_style(desc, PANGO_STYLE_NORMAL);
553
554 char *str = pango_font_description_to_string(desc);
556 pango_font_description_free(desc);
557 g_free(str);
558 return name;
559}
560
562{
563 QFont font;
564 PangoFontDescription *desc = pango_font_description_from_string(qUtf8Printable(name));
565 font.setPointSizeF(static_cast<float>(pango_font_description_get_size(desc)) / PANGO_SCALE);
566
567 QString family = QString::fromUtf8(pango_font_description_get_family(desc));
568 if (!family.isEmpty())
570
571 font.setWeight(QFont::Weight(pango_font_description_get_weight(desc)));
572
573 PangoStyle style = pango_font_description_get_style(desc);
574 if (style == PANGO_STYLE_ITALIC)
576 else if (style == PANGO_STYLE_OBLIQUE)
578 else
580
581 pango_font_description_free(desc);
582 return font;
583}
584
586{
587 GtkFontChooser *gtkDialog = GTK_FONT_CHOOSER(d->gtkDialog());
588 gtk_font_chooser_set_font(gtkDialog, qUtf8Printable(qt_fontToString(font)));
589}
590
592{
593 GtkFontChooser *gtkDialog = GTK_FONT_CHOOSER(d->gtkDialog());
594 gchar *name = gtk_font_chooser_get_font(gtkDialog);
596 g_free(name);
597 return font;
598}
599
600void QGtk3FontDialogHelper::onFontChanged(QGtk3FontDialogHelper *dialog)
601{
602 emit dialog->currentFontChanged(dialog->currentFont());
603}
604
605void QGtk3FontDialogHelper::applyOptions()
606{
607 GtkDialog *gtkDialog = d->gtkDialog();
609
610 gtk_window_set_title(GTK_WINDOW(gtkDialog), qUtf8Printable(opts->windowTitle()));
611}
612
614
615#include "moc_qgtk3dialoghelpers.cpp"
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
static QColor fromRgbF(float r, float g, float b, float a=1.0)
Static convenience function that returns a QColor constructed from the RGB color values,...
Definition qcolor.cpp:2427
\inmodule QtCore
Definition qeventloop.h:16
int exec(ProcessEventsFlags flags=AllEvents)
Enters the main event loop and waits until exit() is called.
QString selectedNameFilter() const
void filterSelected(const QString &filter)
QDir directory() const
Returns the directory currently being displayed in the dialog.
void directoryEntered(const QString &directory)
\inmodule QtCore \reentrant
Definition qfileinfo.h:22
QString fileName() const
Returns the name of the file, excluding the path.
QString path() const
Returns the file's path.
\reentrant
Definition qfontinfo.h:14
qreal pointSizeF() const
Returns the point size of the matched window system font.
Definition qfont.cpp:2847
\reentrant
Definition qfont.h:20
void setStyle(Style style)
Sets the style of the font to style.
Definition qfont.cpp:1101
void setFamilies(const QStringList &)
Definition qfont.cpp:2491
Weight weight() const
Returns the weight of the font, using the same scale as the \l{QFont::Weight} enumeration.
Definition qfont.cpp:1118
qreal pointSizeF() const
Returns the point size of the font.
Definition qfont.cpp:1019
Style style() const
Returns the style of the font.
Definition qfont.cpp:1090
void setPointSizeF(qreal)
Sets the point size to pointSize.
Definition qfont.cpp:995
Weight
Qt uses a weighting scale from 1 to 1000 compatible with OpenType.
Definition qfont.h:60
@ DemiBold
Definition qfont.h:66
@ ExtraBold
Definition qfont.h:68
@ Black
Definition qfont.h:69
@ Bold
Definition qfont.h:67
@ ExtraLight
Definition qfont.h:62
@ Normal
Definition qfont.h:64
@ Light
Definition qfont.h:63
@ Medium
Definition qfont.h:65
void setWeight(Weight weight)
Sets the weight of the font to weight, using the scale defined by \l QFont::Weight enumeration.
Definition qfont.cpp:1190
@ StyleItalic
Definition qfont.h:75
@ StyleNormal
Definition qfont.h:74
@ StyleOblique
Definition qfont.h:76
virtual QString portalWindowIdentifier(QWindow *window)
void setCurrentColor(const QColor &color) override
QColor currentColor() const override
bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) override
static void onResponse(QPlatformDialogHelper *helper, int response)
QGtk3Dialog(GtkWidget *gtkWidget, QPlatformDialogHelper *helper)
GtkDialog * gtkDialog() const
bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent)
void setDirectory(const QUrl &directory) override
bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) override
QString selectedNameFilter() const override
void selectNameFilter(const QString &filter) override
void selectFile(const QUrl &filename) override
QList< QUrl > selectedFiles() const override
QUrl directory() const override
bool defaultNameFilterDisables() const override
void setCurrentFont(const QFont &font) override
bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) override
QFont currentFont() const override
static QPlatformIntegration * platformIntegration()
T value(const Key &key) const noexcept
Definition qhash.h:1044
void clear() noexcept(std::is_nothrow_destructible< Node >::value)
Removes all items from the hash and frees up all memory used by it.
Definition qhash.h:949
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition qhash.h:1283
Definition qlist.h:74
bool isEmpty() const noexcept
Definition qlist.h:390
void clear()
Definition qlist.h:417
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:311
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2823
const QSharedPointer< QColorDialogOptions > & options() const
The QPlatformDialogHelper class allows for platform-specific customization of dialogs.
void currentChanged(const QUrl &path)
static QStringList cleanFilterList(const QString &filter)
const QSharedPointer< QFileDialogOptions > & options() const
const QSharedPointer< QFontDialogOptions > & options() const
virtual QPlatformServices * services() const
static QString defaultStandardButtonText(int button)
void reset(T *other=nullptr) noexcept(noexcept(Cleanup::cleanup(std::declval< T * >())))
Deletes the existing object it is pointing to (if any), and sets its pointer to other.
\inmodule QtCore
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5857
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:1083
QString sliced(qsizetype pos) const
Definition qstring.h:341
QString left(qsizetype n) const
Returns a substring that contains the n leftmost characters of the string.
Definition qstring.cpp:5161
QByteArray toUtf8() const &
Definition qstring.h:563
\inmodule QtCore
Definition qurl.h:94
static QUrl fromLocalFile(const QString &localfile)
Returns a QUrl representation of localFile, interpreted as a local file.
Definition qurl.cpp:3354
bool isEmpty() const
Returns true if the URL has no data; otherwise returns false.
Definition qurl.cpp:1888
void clear()
Resets the content of the QUrl.
Definition qurl.cpp:1901
QString toLocalFile() const
Returns the path of this URL formatted as a local file path.
Definition qurl.cpp:3411
\inmodule QtGui
Definition qwindow.h:63
QString str
[2]
QSet< QString >::iterator it
Combined button and popup list for selecting options.
WindowModality
@ NonModal
@ ApplicationModal
static GtkFileChooserAction gtkFileChooserAction(const QSharedPointer< QFileDialogOptions > &options)
#define PREVIEW_HEIGHT
#define PREVIEW_WIDTH
static QFont qt_fontFromString(const QString &name)
static QString qt_fontToString(const QFont &font)
struct _GtkDialog GtkDialog
struct _GtkFileFilter GtkFileFilter
struct _GtkWidget GtkWidget
return ret
#define SLOT(a)
Definition qobjectdefs.h:51
#define SIGNAL(a)
Definition qobjectdefs.h:52
GLuint64 GLenum void * handle
GLuint GLuint GLfloat weight
GLbitfield flags
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLuint name
#define qUtf8Printable(string)
Definition qstring.h:1395
#define emit
#define Q_UNUSED(x)
@ desc
static QT_BEGIN_NAMESPACE QString windowTitle(HWND hwnd)
view show()
[18] //! [19]
QFileInfo fi("c:/temp/foo")
[newstuff]
QFileDialog dialog(this)
[1]
const QStringList filters({"Image files (*.png *.xpm *.jpg)", "Text files (*.txt)", "Any files (*)" })
[6]
QItemSelection * selection
[0]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent