Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
4#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
5
7#include "qgtk3theme.h"
8
9#include <qeventloop.h>
10#include <qwindow.h>
11#include <qcolor.h>
12#include <qdebug.h>
13#include <qfont.h>
14#include <qfileinfo.h>
15
16#include <private/qguiapplication_p.h>
17#include <private/qgenericunixservices_p.h>
18#include <qpa/qplatformintegration.h>
19#include <qpa/qplatformfontdatabase.h>
20
21#undef signals
22#include <gtk/gtk.h>
23#include <gdk/gdk.h>
24#include <pango/pango.h>
25
26#if QT_CONFIG(xlib) && defined(GDK_WINDOWING_X11)
27#include <gdk/gdkx.h>
28#endif
29
30#ifdef GDK_WINDOWING_WAYLAND
31#include <gdk/gdkwayland.h>
32#endif
33
34// The size of the preview we display for selected image files. We set height
35// larger than width because generally there is more free space vertically
36// than horizontally (setting the preview image will always expand the width of
37// the dialog, but usually not the height). The image's aspect ratio will always
38// be preserved.
39#define PREVIEW_WIDTH 256
40#define PREVIEW_HEIGHT 512
41
43
44using namespace Qt::StringLiterals;
45
47{
48public:
49 QGtk3Dialog(GtkWidget *gtkWidget, QPlatformDialogHelper *helper);
51
52 GtkDialog *gtkDialog() const;
53
54 void exec();
55 bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent);
56 void hide();
57
58protected:
59 static void onResponse(QPlatformDialogHelper *helper, int response);
60
61private:
62 GtkWidget *gtkWidget;
64 Qt::WindowModality modality;
65};
66
68 : gtkWidget(gtkWidget)
69 , helper(helper)
70{
71 g_signal_connect_swapped(G_OBJECT(gtkWidget), "response", G_CALLBACK(onResponse), helper);
72 g_signal_connect(G_OBJECT(gtkWidget), "delete-event", G_CALLBACK(gtk_widget_hide_on_delete), NULL);
73}
74
76{
77 gtk_clipboard_store(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD));
78 gtk_widget_destroy(gtkWidget);
79}
80
82{
83 return GTK_DIALOG(gtkWidget);
84}
85
87{
88 if (modality == Qt::ApplicationModal) {
89 // block input to the whole app, including other GTK dialogs
90 gtk_dialog_run(gtkDialog());
91 } else {
92 // block input to the window, allow input to other GTK dialogs
93 QEventLoop loop;
94 loop.connect(helper, SIGNAL(accept()), SLOT(quit()));
95 loop.connect(helper, SIGNAL(reject()), SLOT(quit()));
96 loop.exec();
97 }
98}
99
100bool QGtk3Dialog::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent)
101{
103 this->modality = modality;
104
105 gtk_widget_realize(gtkWidget); // creates X window
106
107 GdkWindow *gdkWindow = gtk_widget_get_window(gtkWidget);
108 if (parent) {
109 if (false) {
110#if defined(GDK_WINDOWING_WAYLAND) && GTK_CHECK_VERSION(3, 22, 0)
111 } else if (GDK_IS_WAYLAND_WINDOW(gdkWindow)) {
112 const auto unixServices = dynamic_cast<QGenericUnixServices *>(
114 if (unixServices) {
115 const auto handle = unixServices->portalWindowIdentifier(parent);
116 if (handle.startsWith("wayland:"_L1)) {
117 auto handleBa = handle.sliced(8).toUtf8();
118 gdk_wayland_window_set_transient_for_exported(gdkWindow, handleBa.data());
119 }
120 }
121#endif
122#if QT_CONFIG(xlib) && defined(GDK_WINDOWING_X11)
123 } else if (GDK_IS_X11_WINDOW(gdkWindow)) {
124 GdkDisplay *gdkDisplay = gdk_window_get_display(gdkWindow);
125 XSetTransientForHint(gdk_x11_display_get_xdisplay(gdkDisplay),
126 gdk_x11_window_get_xid(gdkWindow),
127 parent->winId());
128#endif
129 }
130 }
131
132 if (modality != Qt::NonModal) {
133 gdk_window_set_modal_hint(gdkWindow, true);
134 }
135
136 gtk_widget_show(gtkWidget);
137 gdk_window_focus(gdkWindow, GDK_CURRENT_TIME);
138 return true;
139}
140
142{
143 gtk_widget_hide(gtkWidget);
144}
145
147{
148 if (response == GTK_RESPONSE_OK)
149 emit helper->accept();
150 else
151 emit helper->reject();
152}
153
155{
156 d.reset(new QGtk3Dialog(gtk_color_chooser_dialog_new("", nullptr), this));
157 g_signal_connect_swapped(d->gtkDialog(), "notify::rgba", G_CALLBACK(onColorChanged), this);
158}
159
163
164bool QGtk3ColorDialogHelper::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent)
165{
166 applyOptions();
167 return d->show(flags, modality, parent);
168}
169
171{
172 d->exec();
173}
174
176{
177 d->hide();
178}
179
181{
182 GtkDialog *gtkDialog = d->gtkDialog();
183 if (color.alpha() < 255)
184 gtk_color_chooser_set_use_alpha(GTK_COLOR_CHOOSER(gtkDialog), true);
185 GdkRGBA gdkColor;
186 gdkColor.red = color.redF();
187 gdkColor.green = color.greenF();
188 gdkColor.blue = color.blueF();
189 gdkColor.alpha = color.alphaF();
190 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(gtkDialog), &gdkColor);
191}
192
194{
195 GtkDialog *gtkDialog = d->gtkDialog();
196 GdkRGBA gdkColor;
197 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(gtkDialog), &gdkColor);
198 return QColor::fromRgbF(gdkColor.red, gdkColor.green, gdkColor.blue, gdkColor.alpha);
199}
200
201void QGtk3ColorDialogHelper::onColorChanged(QGtk3ColorDialogHelper *dialog)
202{
203 emit dialog->currentColorChanged(dialog->currentColor());
204}
205
206void QGtk3ColorDialogHelper::applyOptions()
207{
208 GtkDialog *gtkDialog = d->gtkDialog();
209 gtk_window_set_title(GTK_WINDOW(gtkDialog), qUtf8Printable(options()->windowTitle()));
210
211 gtk_color_chooser_set_use_alpha(GTK_COLOR_CHOOSER(gtkDialog), options()->testOption(QColorDialogOptions::ShowAlphaChannel));
212}
213
215{
216 d.reset(new QGtk3Dialog(gtk_file_chooser_dialog_new("", nullptr,
217 GTK_FILE_CHOOSER_ACTION_OPEN,
220 NULL), this));
221
222 g_signal_connect(GTK_FILE_CHOOSER(d->gtkDialog()), "selection-changed", G_CALLBACK(onSelectionChanged), this);
223 g_signal_connect_swapped(GTK_FILE_CHOOSER(d->gtkDialog()), "current-folder-changed", G_CALLBACK(onCurrentFolderChanged), this);
224 g_signal_connect_swapped(GTK_FILE_CHOOSER(d->gtkDialog()), "notify::filter", G_CALLBACK(onFilterChanged), this);
225
226 previewWidget = gtk_image_new();
227 g_signal_connect(G_OBJECT(d->gtkDialog()), "update-preview", G_CALLBACK(onUpdatePreview), this);
228 gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(d->gtkDialog()), previewWidget);
229}
230
234
235bool QGtk3FileDialogHelper::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent)
236{
237 _dir.clear();
238 _selection.clear();
239
240 applyOptions();
241 return d->show(flags, modality, parent);
242}
243
245{
246 d->exec();
247}
248
250{
251 // After GtkFileChooserDialog has been hidden, gtk_file_chooser_get_current_folder()
252 // & gtk_file_chooser_get_filenames() will return bogus values -> cache the actual
253 // values before hiding the dialog
254 _dir = directory();
255 _selection = selectedFiles();
256
257 d->hide();
258}
259
261{
262 return false;
263}
264
266{
267 GtkDialog *gtkDialog = d->gtkDialog();
268 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(gtkDialog), qUtf8Printable(directory.toLocalFile()));
269}
270
272{
273 // While GtkFileChooserDialog is hidden, gtk_file_chooser_get_current_folder()
274 // returns a bogus value -> return the cached value before hiding
275 if (!_dir.isEmpty())
276 return _dir;
277
278 QString ret;
279 GtkDialog *gtkDialog = d->gtkDialog();
280 gchar *folder = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(gtkDialog));
281 if (folder) {
282 ret = QString::fromUtf8(folder);
283 g_free(folder);
284 }
285 return QUrl::fromLocalFile(ret);
286}
287
289{
290 setFileChooserAction();
291 selectFileInternal(filename);
292}
293
294void QGtk3FileDialogHelper::selectFileInternal(const QUrl &filename)
295{
296 GtkDialog *gtkDialog = d->gtkDialog();
297 if (options()->acceptMode() == QFileDialogOptions::AcceptSave) {
298 QFileInfo fi(filename.toLocalFile());
299 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(gtkDialog), qUtf8Printable(fi.path()));
300 gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(gtkDialog), qUtf8Printable(fi.fileName()));
301 } else {
302 gtk_file_chooser_select_filename(GTK_FILE_CHOOSER(gtkDialog), qUtf8Printable(filename.toLocalFile()));
303 }
304}
305
307{
308 // While GtkFileChooserDialog is hidden, gtk_file_chooser_get_filenames()
309 // returns a bogus value -> return the cached value before hiding
310 if (!_selection.isEmpty())
311 return _selection;
312
313 QList<QUrl> selection;
314 GtkDialog *gtkDialog = d->gtkDialog();
315 GSList *filenames = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(gtkDialog));
316 for (GSList *it = filenames; it; it = it->next)
317 selection += QUrl::fromLocalFile(QString::fromUtf8((const char*)it->data));
318 g_slist_free(filenames);
319 return selection;
320}
321
323{
324 applyOptions();
325}
326
328{
329 GtkFileFilter *gtkFilter = _filters.value(filter);
330 if (gtkFilter) {
331 GtkDialog *gtkDialog = d->gtkDialog();
332 gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(gtkDialog), gtkFilter);
333 }
334}
335
337{
338 GtkDialog *gtkDialog = d->gtkDialog();
339 GtkFileFilter *gtkFilter = gtk_file_chooser_get_filter(GTK_FILE_CHOOSER(gtkDialog));
340 return _filterNames.value(gtkFilter);
341}
342
343void QGtk3FileDialogHelper::onSelectionChanged(GtkDialog *gtkDialog, QGtk3FileDialogHelper *helper)
344{
346 gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(gtkDialog));
347 if (filename) {
348 selection = QString::fromUtf8(filename);
349 g_free(filename);
350 }
352}
353
354void QGtk3FileDialogHelper::onCurrentFolderChanged(QGtk3FileDialogHelper *dialog)
355{
357}
358
359void QGtk3FileDialogHelper::onFilterChanged(QGtk3FileDialogHelper *dialog)
360{
362}
363
364void QGtk3FileDialogHelper::onUpdatePreview(GtkDialog *gtkDialog, QGtk3FileDialogHelper *helper)
365{
366 gchar *filename = gtk_file_chooser_get_preview_filename(GTK_FILE_CHOOSER(gtkDialog));
367 if (!filename) {
368 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(gtkDialog), false);
369 return;
370 }
371
372 // Don't attempt to open anything which isn't a regular file. If a named pipe,
373 // this may hang.
374 QFileInfo fileinfo(filename);
375 if (!fileinfo.exists() || !fileinfo.isFile()) {
376 g_free(filename);
377 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(gtkDialog), false);
378 return;
379 }
380
381 // This will preserve the image's aspect ratio.
382 GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file_at_size(filename, PREVIEW_WIDTH, PREVIEW_HEIGHT, 0);
383 g_free(filename);
384 if (pixbuf) {
385 gtk_image_set_from_pixbuf(GTK_IMAGE(helper->previewWidget), pixbuf);
386 g_object_unref(pixbuf);
387 }
388 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(gtkDialog), pixbuf ? true : false);
389}
390
391static GtkFileChooserAction gtkFileChooserAction(const QSharedPointer<QFileDialogOptions> &options)
392{
393 switch (options->fileMode()) {
397 if (options->acceptMode() == QFileDialogOptions::AcceptOpen)
398 return GTK_FILE_CHOOSER_ACTION_OPEN;
399 else
400 return GTK_FILE_CHOOSER_ACTION_SAVE;
403 default:
404 if (options->acceptMode() == QFileDialogOptions::AcceptOpen)
405 return GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
406 else
407 return GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER;
408 }
409}
410
411void QGtk3FileDialogHelper::setFileChooserAction()
412{
413 GtkDialog *gtkDialog = d->gtkDialog();
414
415 const GtkFileChooserAction action = gtkFileChooserAction(options());
416 gtk_file_chooser_set_action(GTK_FILE_CHOOSER(gtkDialog), action);
417}
418
419void QGtk3FileDialogHelper::applyOptions()
420{
421 GtkDialog *gtkDialog = d->gtkDialog();
422 const QSharedPointer<QFileDialogOptions> &opts = options();
423
424 gtk_window_set_title(GTK_WINDOW(gtkDialog), qUtf8Printable(opts->windowTitle()));
425 gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(gtkDialog), true);
426
427 setFileChooserAction();
428
429 const bool selectMultiple = opts->fileMode() == QFileDialogOptions::ExistingFiles;
430 gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(gtkDialog), selectMultiple);
431
432 const bool confirmOverwrite = !opts->testOption(QFileDialogOptions::DontConfirmOverwrite);
433 gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(gtkDialog), confirmOverwrite);
434
435 const bool readOnly = opts->testOption(QFileDialogOptions::ReadOnly);
436 gtk_file_chooser_set_create_folders(GTK_FILE_CHOOSER(gtkDialog), !readOnly);
437
438 const QStringList nameFilters = opts->nameFilters();
439 if (!nameFilters.isEmpty())
440 setNameFilters(nameFilters);
441
442 if (opts->initialDirectory().isLocalFile())
443 setDirectory(opts->initialDirectory());
444
445 foreach (const QUrl &filename, opts->initiallySelectedFiles())
446 selectFileInternal(filename);
447
448 const QString initialNameFilter = opts->initiallySelectedNameFilter();
449 if (!initialNameFilter.isEmpty())
450 selectNameFilter(initialNameFilter);
451
452 GtkWidget *acceptButton = gtk_dialog_get_widget_for_response(gtkDialog, GTK_RESPONSE_OK);
453 if (acceptButton) {
454 if (opts->isLabelExplicitlySet(QFileDialogOptions::Accept))
455 gtk_button_set_label(GTK_BUTTON(acceptButton), qUtf8Printable(opts->labelText(QFileDialogOptions::Accept)));
456 else if (opts->acceptMode() == QFileDialogOptions::AcceptOpen)
457 gtk_button_set_label(GTK_BUTTON(acceptButton), qUtf8Printable(QGtk3Theme::defaultStandardButtonText(QPlatformDialogHelper::Open)));
458 else
459 gtk_button_set_label(GTK_BUTTON(acceptButton), qUtf8Printable(QGtk3Theme::defaultStandardButtonText(QPlatformDialogHelper::Save)));
460 }
461
462 GtkWidget *rejectButton = gtk_dialog_get_widget_for_response(gtkDialog, GTK_RESPONSE_CANCEL);
463 if (rejectButton) {
464 if (opts->isLabelExplicitlySet(QFileDialogOptions::Reject))
465 gtk_button_set_label(GTK_BUTTON(rejectButton), qUtf8Printable(opts->labelText(QFileDialogOptions::Reject)));
466 else
467 gtk_button_set_label(GTK_BUTTON(rejectButton), qUtf8Printable(QGtk3Theme::defaultStandardButtonText(QPlatformDialogHelper::Cancel)));
468 }
469}
470
471void QGtk3FileDialogHelper::setNameFilters(const QStringList &filters)
472{
473 GtkDialog *gtkDialog = d->gtkDialog();
474 foreach (GtkFileFilter *filter, _filters)
475 gtk_file_chooser_remove_filter(GTK_FILE_CHOOSER(gtkDialog), filter);
476
477 _filters.clear();
478 _filterNames.clear();
479
480 foreach (const QString &filter, filters) {
481 GtkFileFilter *gtkFilter = gtk_file_filter_new();
482 const QString name = filter.left(filter.indexOf(u'('));
483 const QStringList extensions = cleanFilterList(filter);
484
485 gtk_file_filter_set_name(gtkFilter, qUtf8Printable(name.isEmpty() ? extensions.join(", "_L1) : name));
486 foreach (const QString &ext, extensions)
487 gtk_file_filter_add_pattern(gtkFilter, qUtf8Printable(ext));
488
489 gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(gtkDialog), gtkFilter);
490
491 _filters.insert(filter, gtkFilter);
492 _filterNames.insert(gtkFilter, filter);
493 }
494}
495
497{
498 d.reset(new QGtk3Dialog(gtk_font_chooser_dialog_new("", nullptr), this));
499 g_signal_connect_swapped(d->gtkDialog(), "notify::font", G_CALLBACK(onFontChanged), this);
500}
501
505
506bool QGtk3FontDialogHelper::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent)
507{
508 applyOptions();
509 return d->show(flags, modality, parent);
510}
511
513{
514 d->exec();
515}
516
518{
519 d->hide();
520}
521
523{
524 PangoFontDescription *desc = pango_font_description_new();
525 pango_font_description_set_size(desc, (font.pointSizeF() > 0.0 ? font.pointSizeF() : QFontInfo(font).pointSizeF()) * PANGO_SCALE);
526 pango_font_description_set_family(desc, qUtf8Printable(QFontInfo(font).family()));
527
528 int weight = font.weight();
529 if (weight >= QFont::Black)
530 pango_font_description_set_weight(desc, PANGO_WEIGHT_HEAVY);
531 else if (weight >= QFont::ExtraBold)
532 pango_font_description_set_weight(desc, PANGO_WEIGHT_ULTRABOLD);
533 else if (weight >= QFont::Bold)
534 pango_font_description_set_weight(desc, PANGO_WEIGHT_BOLD);
535 else if (weight >= QFont::DemiBold)
536 pango_font_description_set_weight(desc, PANGO_WEIGHT_SEMIBOLD);
537 else if (weight >= QFont::Medium)
538 pango_font_description_set_weight(desc, PANGO_WEIGHT_MEDIUM);
539 else if (weight >= QFont::Normal)
540 pango_font_description_set_weight(desc, PANGO_WEIGHT_NORMAL);
541 else if (weight >= QFont::Light)
542 pango_font_description_set_weight(desc, PANGO_WEIGHT_LIGHT);
543 else if (weight >= QFont::ExtraLight)
544 pango_font_description_set_weight(desc, PANGO_WEIGHT_ULTRALIGHT);
545 else
546 pango_font_description_set_weight(desc, PANGO_WEIGHT_THIN);
547
548 int style = font.style();
549 if (style == QFont::StyleItalic)
550 pango_font_description_set_style(desc, PANGO_STYLE_ITALIC);
551 else if (style == QFont::StyleOblique)
552 pango_font_description_set_style(desc, PANGO_STYLE_OBLIQUE);
553 else
554 pango_font_description_set_style(desc, PANGO_STYLE_NORMAL);
555
556 char *str = pango_font_description_to_string(desc);
558 pango_font_description_free(desc);
559 g_free(str);
560 return name;
561}
562
564{
565 QFont font;
566 PangoFontDescription *desc = pango_font_description_from_string(qUtf8Printable(name));
567 font.setPointSizeF(static_cast<float>(pango_font_description_get_size(desc)) / PANGO_SCALE);
568
569 QString family = QString::fromUtf8(pango_font_description_get_family(desc));
570 if (!family.isEmpty())
572
573 font.setWeight(QFont::Weight(pango_font_description_get_weight(desc)));
574
575 PangoStyle style = pango_font_description_get_style(desc);
576 if (style == PANGO_STYLE_ITALIC)
578 else if (style == PANGO_STYLE_OBLIQUE)
580 else
582
583 pango_font_description_free(desc);
584 return font;
585}
586
588{
589 GtkFontChooser *gtkDialog = GTK_FONT_CHOOSER(d->gtkDialog());
590 gtk_font_chooser_set_font(gtkDialog, qUtf8Printable(qt_fontToString(font)));
591}
592
594{
595 GtkFontChooser *gtkDialog = GTK_FONT_CHOOSER(d->gtkDialog());
596 gchar *name = gtk_font_chooser_get_font(gtkDialog);
598 g_free(name);
599 return font;
600}
601
602void QGtk3FontDialogHelper::onFontChanged(QGtk3FontDialogHelper *dialog)
603{
604 emit dialog->currentFontChanged(dialog->currentFont());
605}
606
607void QGtk3FontDialogHelper::applyOptions()
608{
609 GtkDialog *gtkDialog = d->gtkDialog();
610 const QSharedPointer<QFontDialogOptions> &opts = options();
611
612 gtk_window_set_title(GTK_WINDOW(gtkDialog), qUtf8Printable(opts->windowTitle()));
613}
614
616
617#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)
\reentrant
Definition qfontinfo.h:16
qreal pointSizeF() const
Returns the point size of the matched window system font.
Definition qfont.cpp:3131
\reentrant
Definition qfont.h:22
void setStyle(Style style)
Sets the style of the font to style.
Definition qfont.cpp:1116
void setFamilies(const QStringList &)
Definition qfont.cpp:2721
Weight weight() const
Returns the weight of the font, using the same scale as the \l{QFont::Weight} enumeration.
Definition qfont.cpp:1133
qreal pointSizeF() const
Returns the point size of the font.
Definition qfont.cpp:1034
Style style() const
Returns the style of the font.
Definition qfont.cpp:1105
void setPointSizeF(qreal)
Sets the point size to pointSize.
Definition qfont.cpp:1010
Weight
Qt uses a weighting scale from 1 to 1000 compatible with OpenType.
Definition qfont.h:63
@ DemiBold
Definition qfont.h:69
@ ExtraBold
Definition qfont.h:71
@ Black
Definition qfont.h:72
@ Bold
Definition qfont.h:70
@ ExtraLight
Definition qfont.h:65
@ Normal
Definition qfont.h:67
@ Light
Definition qfont.h:66
@ Medium
Definition qfont.h:68
void setWeight(Weight weight)
Sets the weight of the font to weight, using the scale defined by \l QFont::Weight enumeration.
Definition qfont.cpp:1205
@ StyleItalic
Definition qfont.h:78
@ StyleNormal
Definition qfont.h:77
@ StyleOblique
Definition qfont.h:79
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:1054
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:951
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition qhash.h:1303
bool isEmpty() const noexcept
Definition qlist.h:401
void clear()
Definition qlist.h:434
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
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
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
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
QString left(qsizetype n) const &
Definition qstring.h:363
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:192
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:6018
\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:3368
bool isEmpty() const
Returns true if the URL has no data; otherwise returns false.
Definition qurl.cpp:1896
void clear()
Resets the content of the QUrl.
Definition qurl.cpp:1909
QString toLocalFile() const
Returns the path of this URL formatted as a local file path.
Definition qurl.cpp:3425
\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:52
#define SIGNAL(a)
Definition qobjectdefs.h:53
GLuint64 GLenum void * handle
GLuint GLuint GLfloat weight
GLuint color
[2]
GLbitfield flags
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLuint name
#define qUtf8Printable(string)
Definition qstring.h:1535
#define emit
#define Q_UNUSED(x)
static QString windowTitle(HWND hwnd)
view show()
[18] //! [19]
QFileDialog dialog(this)
[1]
const QStringList filters({"Image files (*.png *.xpm *.jpg)", "Text files (*.txt)", "Any files (*)" })
[6]
QItemSelection * selection
[0]