From b57c878dfc9565e86854779ac2ccb38e5adad32b Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Sat, 13 Aug 2016 17:29:05 +0200 Subject: QGtk3FontDialogHelper: provide proper currentFontChanged() A workaround for the missing currentFontChanged() signal was added in 130f43c. Now we can remove the improper emission on accept, because by using the "notify::font" signal gives proper notifications whenever the current font selection in the dialog changes. Task-number: QTBUG-55298 Change-Id: Id9a4f32a92f0be8f466a0a0587bb2acd4c9056f7 Reviewed-by: Dmitry Shachnev Reviewed-by: Shawn Rutledge Reviewed-by: Mitch Curtis --- src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp | 8 +++++++- src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src/plugins/platformthemes') diff --git a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp index ced5fe7086..75549d47c1 100644 --- a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp +++ b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp @@ -483,6 +483,8 @@ QGtk3FontDialogHelper::QGtk3FontDialogHelper() d.reset(new QGtk3Dialog(gtk_font_chooser_dialog_new("", 0))); connect(d.data(), SIGNAL(accept()), this, SLOT(onAccepted())); connect(d.data(), SIGNAL(reject()), this, SIGNAL(reject())); + + g_signal_connect_swapped(d->gtkDialog(), "notify::font", G_CALLBACK(onFontChanged), this); } QGtk3FontDialogHelper::~QGtk3FontDialogHelper() @@ -588,11 +590,15 @@ QFont QGtk3FontDialogHelper::currentFont() const void QGtk3FontDialogHelper::onAccepted() { - emit currentFontChanged(currentFont()); emit accept(); emit fontSelected(currentFont()); } +void QGtk3FontDialogHelper::onFontChanged(QGtk3FontDialogHelper *dialog) +{ + emit dialog->currentFontChanged(dialog->currentFont()); +} + void QGtk3FontDialogHelper::applyOptions() { GtkDialog *gtkDialog = d->gtkDialog(); diff --git a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.h b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.h index c852fd05f6..40961d5201 100644 --- a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.h +++ b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.h @@ -136,6 +136,7 @@ private Q_SLOTS: void onAccepted(); private: + static void onFontChanged(QGtk3FontDialogHelper *helper); void applyOptions(); QScopedPointer d; -- cgit v1.2.3