Skip to content
Permalink
Browse files

don't set parent of QFontDialog to avoid the stylesheet font (fixes #…

  • Loading branch information
jef-n committed Feb 21, 2015
1 parent d001c9d commit fe21378416184ceeb0d48802c01e26939f3d5167
@@ -28,8 +28,7 @@
#include "qgsexpressionbuilderdialog.h"
#include "qgsproject.h"
#include "qgsrelationmanager.h"
#include <QColorDialog>
#include <QFontDialog>
#include "qgisgui.h"

QgsComposerAttributeTableWidget::QgsComposerAttributeTableWidget( QgsComposerAttributeTableV2* table, QgsComposerFrame* frame )
: QgsComposerItemBaseWidget( 0, table )
@@ -283,29 +282,20 @@ void QgsComposerAttributeTableWidget::on_mMarginSpinBox_valueChanged( double d )
void QgsComposerAttributeTableWidget::on_mHeaderFontPushButton_clicked()
{
if ( !mComposerTable )
{
return;
}

bool ok;
#if defined(Q_OS_MAC) && defined(QT_MAC_USE_COCOA)
// Native Mac dialog works only for Qt Carbon
QFont newFont = QFontDialog::getFont( &ok, mComposerTable->headerFont(), this, tr( "Select Font" ), QFontDialog::DontUseNativeDialog );
#else
QFont newFont = QFontDialog::getFont( &ok, mComposerTable->headerFont(), this, tr( "Select Font" ) );
#endif
if ( ok )
QFont newFont = QgisGui::getFont( ok, mComposerTable->headerFont(), tr( "Select Font" ) );
if ( !ok )
{
QgsComposition* composition = mComposerTable->composition();
QgsComposition *composition = mComposerTable->composition();
if ( composition )
{
composition->beginMultiFrameCommand( mComposerTable, tr( "Table header font" ) );
}

mComposerTable->setHeaderFont( newFont );

if ( composition )
{
composition->endMultiFrameCommand();
}
}
}

@@ -336,24 +326,17 @@ void QgsComposerAttributeTableWidget::on_mContentFontPushButton_clicked()
}

bool ok;
#if defined(Q_OS_MAC) && defined(QT_MAC_USE_COCOA)
// Native Mac dialog works only for Qt Carbon
QFont newFont = QFontDialog::getFont( &ok, mComposerTable->contentFont(), this, tr( "Select Font" ), QFontDialog::DontUseNativeDialog );
#else
QFont newFont = QFontDialog::getFont( &ok, mComposerTable->contentFont(), this, tr( "Select Font" ) );
#endif
QFont newFont = QgisGui::getFont( ok, mComposerTable->contentFont(), tr( "Select Font" ) );
if ( ok )
{
QgsComposition* composition = mComposerTable->composition();
if ( composition )
{
composition->beginMultiFrameCommand( mComposerTable, tr( "Table content font" ) );
}

mComposerTable->setContentFont( newFont );

if ( composition )
{
composition->endMultiFrameCommand();
}
}
}

@@ -91,12 +91,7 @@ void QgsComposerLabelWidget::on_mFontButton_clicked()
if ( mComposerLabel )
{
bool ok;
#if defined(Q_OS_MAC) && defined(QT_MAC_USE_COCOA)
// Native Mac dialog works only for Qt Carbon
QFont newFont = QFontDialog::getFont( &ok, mComposerLabel->font(), this, QString(), QFontDialog::DontUseNativeDialog );
#else
QFont newFont = QFontDialog::getFont( &ok, mComposerLabel->font(), this );
#endif
QFont newFont = QgisGui::getFont( ok, mComposerLabel->font() );
if ( ok )
{
mComposerLabel->beginCommand( tr( "Label font changed" ) );
@@ -23,9 +23,7 @@
#include "qgscomposeritemwidget.h"
#include "qgscomposermap.h"
#include "qgscomposition.h"
#include <QFontDialog>
#include <QColorDialog>
#include <QInputDialog>
#include "qgisgui.h"

#include "qgisapp.h"
#include "qgsapplication.h"
@@ -41,6 +39,7 @@
#include "qgsvectorlayer.h"

#include <QMessageBox>
#include <QInputDialog>



@@ -369,12 +368,7 @@ void QgsComposerLegendWidget::on_mTitleFontButton_clicked()
if ( mLegend )
{
bool ok;
#if defined(Q_OS_MAC) && defined(QT_MAC_USE_COCOA)
// Native Mac dialog works only for Qt Carbon
QFont newFont = QFontDialog::getFont( &ok, mLegend->style( QgsComposerLegendStyle::Title ).font(), this, QString(), QFontDialog::DontUseNativeDialog );
#else
QFont newFont = QFontDialog::getFont( &ok, mLegend->style( QgsComposerLegendStyle::Title ).font(), this );
#endif
QFont newFont = QgisGui::getFont( ok, mLegend->style( QgsComposerLegendStyle::Title ).font() );
if ( ok )
{
mLegend->beginCommand( tr( "Title font changed" ) );
@@ -391,12 +385,7 @@ void QgsComposerLegendWidget::on_mGroupFontButton_clicked()
if ( mLegend )
{
bool ok;
#if defined(Q_OS_MAC) && defined(QT_MAC_USE_COCOA)
// Native Mac dialog works only for Qt Carbon
QFont newFont = QFontDialog::getFont( &ok, mLegend->style( QgsComposerLegendStyle::Group ).font(), this, QString(), QFontDialog::DontUseNativeDialog );
#else
QFont newFont = QFontDialog::getFont( &ok, mLegend->style( QgsComposerLegendStyle::Group ).font(), this );
#endif
QFont newFont = QgisGui::getFont( ok, mLegend->style( QgsComposerLegendStyle::Group ).font() );
if ( ok )
{
mLegend->beginCommand( tr( "Legend group font changed" ) );
@@ -413,12 +402,7 @@ void QgsComposerLegendWidget::on_mLayerFontButton_clicked()
if ( mLegend )
{
bool ok;
#if defined(Q_OS_MAC) && defined(QT_MAC_USE_COCOA)
// Native Mac dialog works only for Qt Carbon
QFont newFont = QFontDialog::getFont( &ok, mLegend->style( QgsComposerLegendStyle::Subgroup ).font(), this, QString(), QFontDialog::DontUseNativeDialog );
#else
QFont newFont = QFontDialog::getFont( &ok, mLegend->style( QgsComposerLegendStyle::Subgroup ).font(), this );
#endif
QFont newFont = QgisGui::getFont( ok, mLegend->style( QgsComposerLegendStyle::Subgroup ).font() );
if ( ok )
{
mLegend->beginCommand( tr( "Legend layer font changed" ) );
@@ -435,12 +419,7 @@ void QgsComposerLegendWidget::on_mItemFontButton_clicked()
if ( mLegend )
{
bool ok;
#if defined(Q_OS_MAC) && defined(QT_MAC_USE_COCOA)
// Native Mac dialog works only for Qt Carbon
QFont newFont = QFontDialog::getFont( &ok, mLegend->style( QgsComposerLegendStyle::SymbolLabel ).font(), this, QString(), QFontDialog::DontUseNativeDialog );
#else
QFont newFont = QFontDialog::getFont( &ok, mLegend->style( QgsComposerLegendStyle::SymbolLabel ).font(), this );
#endif
QFont newFont = QgisGui::getFont( ok, mLegend->style( QgsComposerLegendStyle::SymbolLabel ).font() );
if ( ok )
{
mLegend->beginCommand( tr( "Legend item font changed" ) );
@@ -27,7 +27,6 @@
#include "qgsmaprenderer.h"
#include "qgsstylev2.h"
#include "qgssymbolv2.h"
//#include "qgssymbolv2propertiesdialog.h"
#include "qgssymbolv2selectordialog.h"
#include "qgssymbollayerv2utils.h"
#include "qgsvectorlayer.h"
@@ -39,8 +38,8 @@
#include "qgsgenericprojectionselector.h"
#include "qgsproject.h"
#include "qgsvisibilitypresets.h"
#include <QColorDialog>
#include <QFontDialog>
#include "qgisgui.h"

#include <QMessageBox>

QgsComposerMapWidget::QgsComposerMapWidget( QgsComposerMap* composerMap )
@@ -2086,12 +2085,7 @@ void QgsComposerMapWidget::on_mAnnotationFontButton_clicked()
}

bool ok;
#if defined(Q_OS_MAC) && QT_VERSION >= 0x040500 && defined(QT_MAC_USE_COCOA)
// Native Mac dialog works only for Qt Carbon
QFont newFont = QFontDialog::getFont( &ok, grid->annotationFont(), this, QString(), QFontDialog::DontUseNativeDialog );
#else
QFont newFont = QFontDialog::getFont( &ok, grid->annotationFont(), this );
#endif
QFont newFont = QgisGui::getFont( ok, grid->annotationFont() );
if ( ok )
{
mComposerMap->beginCommand( tr( "Annotation font changed" ) );
@@ -310,13 +310,7 @@ void QgsComposerScaleBarWidget::on_mFontButton_clicked()
}

bool dialogAccepted;
QFont oldFont = mComposerScaleBar->font();
#if defined(Q_OS_MAC) && defined(QT_MAC_USE_COCOA)
// Native Mac dialog works only for Qt Carbon
QFont newFont = QFontDialog::getFont( &dialogAccepted, oldFont, this, QString(), QFontDialog::DontUseNativeDialog );
#else
QFont newFont = QFontDialog::getFont( &dialogAccepted, oldFont, this );
#endif
QFont newFont = QgisGui::getFont( dialogAccepted, mComposerScaleBar->font() );
if ( dialogAccepted )
{
mComposerScaleBar->beginCommand( tr( "Scalebar font changed" ) );
@@ -24,8 +24,7 @@
#include "qgsmaplayerregistry.h"
#include "qgsvectorlayer.h"
#include "qgsexpressionbuilderdialog.h"
#include <QColorDialog>
#include <QFontDialog>
#include "qgisgui.h"

QgsComposerTableWidget::QgsComposerTableWidget( QgsComposerAttributeTable* table ): QgsComposerItemBaseWidget( 0, table ), mComposerTable( table )
{
@@ -215,12 +214,7 @@ void QgsComposerTableWidget::on_mHeaderFontPushButton_clicked()
}

bool ok;
#if defined(Q_OS_MAC) && defined(QT_MAC_USE_COCOA)
// Native Mac dialog works only for Qt Carbon
QFont newFont = QFontDialog::getFont( &ok, mComposerTable->headerFont(), this, tr( "Select Font" ), QFontDialog::DontUseNativeDialog );
#else
QFont newFont = QFontDialog::getFont( &ok, mComposerTable->headerFont(), this, tr( "Select Font" ) );
#endif
QFont newFont = QgisGui::getFont( ok, mComposerTable->headerFont(), tr( "Select Font" ) );
if ( ok )
{
mComposerTable->beginCommand( tr( "Table header font" ) );
@@ -250,12 +244,7 @@ void QgsComposerTableWidget::on_mContentFontPushButton_clicked()
}

bool ok;
#if defined(Q_OS_MAC) && defined(QT_MAC_USE_COCOA)
// Native Mac dialog works only for Qt Carbon
QFont newFont = QFontDialog::getFont( &ok, mComposerTable->contentFont(), this, tr( "Select Font" ), QFontDialog::DontUseNativeDialog );
#else
QFont newFont = QFontDialog::getFont( &ok, mComposerTable->contentFont(), this, tr( "Select Font" ) );
#endif
QFont newFont = QgisGui::getFont( ok, mComposerTable->contentFont(), tr( "Select Font" ) );
if ( ok )
{
mComposerTable->beginCommand( tr( "Table content font" ) );
@@ -25,9 +25,8 @@
#include "qgssymbolv2.h"
#include "qgssymbolv2selectordialog.h"
#include "qgisapp.h"
#include "qgisgui.h"

#include <QFontDialog>
#include <QColorDialog>
#include <QSettings>

QgsDecorationGridDialog::QgsDecorationGridDialog( QgsDecorationGrid& deco, QWidget* parent )
@@ -275,12 +274,7 @@ void QgsDecorationGridDialog::on_mPbtnUpdateFromLayer_clicked()
void QgsDecorationGridDialog::on_mAnnotationFontButton_clicked()
{
bool ok;
#if defined(Q_OS_MAC) && defined(QT_MAC_USE_COCOA)
// Native Mac dialog works only for Qt Carbon
QFont newFont = QFontDialog::getFont( &ok, mDeco.gridAnnotationFont(), 0, QString(), QFontDialog::DontUseNativeDialog );
#else
QFont newFont = QFontDialog::getFont( &ok, mDeco.gridAnnotationFont() );
#endif
QFont newFont = QgisGui::getFont( ok, mDeco.gridAnnotationFont() );
if ( ok )
{
mDeco.setGridAnnotationFont( newFont );
@@ -30,9 +30,8 @@
#include "qgsvectordataprovider.h"
#include "qgsfeatureiterator.h"
#include "qgscolordialog.h"
#include "qgisgui.h"

#include <QColorDialog>
#include <QFontDialog>
#include <QList>
#include <QMessageBox>
#include <QSettings>
@@ -494,7 +493,7 @@ void QgsDiagramProperties::on_mDisplayDiagramsGroupBox_toggled( bool checked )
void QgsDiagramProperties::on_mDiagramFontButton_clicked()
{
bool ok;
mDiagramFont = QFontDialog::getFont( &ok, mDiagramFont );
mDiagramFont = QgisGui::getFont( ok, mDiagramFont );
}


@@ -21,9 +21,9 @@
#include "qgslabel.h"
#include "qgslabelattributes.h"
#include "qgslogger.h"
#include "qgisgui.h"

#include <QColorDialog>
#include <QFontDialog>
#include <QTabWidget>
#include <QDoubleValidator>

@@ -277,12 +277,7 @@ void QgsLabelDialog::changeFont( void )

qreal fontSize = mFont.pointSizeF();
bool resultFlag;
#if defined(Q_OS_MAC) && defined(QT_MAC_USE_COCOA)
// Native Mac dialog works only for Qt Carbon
mFont = QFontDialog::getFont( &resultFlag, mFont, 0, QString(), QFontDialog::DontUseNativeDialog );
#else
mFont = QFontDialog::getFont( &resultFlag, mFont );
#endif
QFont newFont = QgisGui::getFont( resultFlag, mFont );
if ( !resultFlag )
return;

@@ -36,12 +36,6 @@
#include "qgssvgselectorwidget.h"

#include <QCheckBox>
#include <QColorDialog>
#include <QFileDialog>
#include <QFontDialog>
#include <QTextEdit>
#include <QApplication>
#include <QMessageBox>
#include <QSettings>


@@ -15,11 +15,11 @@
#include "qgisgui.h"

#include <QSettings>
#include <QObject> //for tr
#include <QImageWriter>
#include "qgsencodingfiledialog.h"
#include "qgslogger.h"
#include <memory> //for auto_ptr

#include <QFontDialog>


namespace QgisGui
@@ -188,4 +188,17 @@ namespace QgisGui
return createFileFilter_( longName, glob );
}

QFont getFont( bool &ok, const QFont &initial, const QString &title )
{
// parent is intentionally not set to 'this' as
// that would make it follow the style sheet font
// see also #12233 and #4937
#if defined(Q_OS_MAC) && defined(QT_MAC_USE_COCOA)
// Native Mac dialog works only for Qt Carbon
return QFontDialog::getFont( &ok, initial, 0, title, QFontDialog::DontUseNativeDialog );
#else
return QFontDialog::getFont( &ok, initial, 0, title );
#endif
}

} // end of QgisGui namespace
@@ -19,6 +19,8 @@
#include <QPair>
#include <QStringList>

class QFont;

/** \ingroup gui
* /namespace QgisGui
* The QgisGui namespace contains constants and helper functions used throughout the QGIS GUI.
@@ -100,6 +102,14 @@ namespace QgisGui
*/
QString GUI_EXPORT createFileFilter_( QString const &format );

/**
* Show font selection dialog
* @param ok true on ok, false on cancel
* @param initial initial font
* @param title optional dialog title
* @return QFont the selected fon
*/
QFont GUI_EXPORT getFont( bool &ok, const QFont &initial, const QString &title = QString() );
}

#endif

0 comments on commit fe21378

Please sign in to comment.
You can’t perform that action at this time.