Skip to content
Permalink
Browse files

[FEATURE] Add composer settings panel, with option to set default fon…

…t for compositions
  • Loading branch information
nyalldawson committed Oct 21, 2013
1 parent 944755a commit c4e125a4f3ac5cd68a092efd542e2714ce81e9c4
@@ -681,6 +681,23 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
}
}

//
// Composer settings
//
mComposerFontComboBox->blockSignals( true );

QString composerFontFamily = settings.value( "/Composer/defaultFont" ).toString();

QFont *tempComposerFont = new QFont( composerFontFamily );
// is exact family match returned from system?
if ( tempComposerFont->family() == composerFontFamily )
{
mComposerFontComboBox->setCurrentFont( *tempComposerFont );
}
delete tempComposerFont;

mComposerFontComboBox->blockSignals( false );

//
// Locale settings
//
@@ -1211,6 +1228,12 @@ void QgsOptions::saveOptions()
}
settings.setValue( "Map/scales", myPaths );

//
// Composer settings
//
QString composerFont = mComposerFontComboBox->currentFont().family();
settings.setValue( "/Composer/defaultFont", composerFont );

//
// Locale settings
//
@@ -33,8 +33,18 @@ QgsComposerLabel::QgsComposerLabel( QgsComposition *composition ):
mExpressionFeature( 0 ), mExpressionLayer( 0 )
{
mHtmlUnitsToMM = htmlUnitsToMM();
//default font size is 10 point

//get default composer font from settings
QSettings settings;
QString defaultFontString = settings.value( "/Composer/defaultFont" ).toString();
if ( !defaultFontString.isEmpty() )
{
mFont.setFamily( defaultFontString );
}

//default to a 10 point font size
mFont.setPointSizeF( 10 );

}

QgsComposerLabel::~QgsComposerLabel()
@@ -16,6 +16,7 @@
***************************************************************************/

#include "qgscomposerlegendstyle.h"
#include "qgscomposition.h"
#include <QFont>
#include <QMap>
#include <QString>
@@ -25,6 +26,13 @@

QgsComposerLegendStyle::QgsComposerLegendStyle()
{
//get default composer font from settings
QSettings settings;
QString defaultFontString = settings.value( "/Composer/defaultFont" ).toString();
if ( !defaultFontString.isEmpty() )
{
mFont.setFamily( defaultFontString );
}
}

QgsComposerLegendStyle::~QgsComposerLegendStyle()
@@ -72,6 +72,14 @@ QgsComposerMap::QgsComposerMap( QgsComposition *composition, int x, int y, int w
mXOffset = 0.0;
mYOffset = 0.0;

//get default composer font from settings
QSettings settings;
QString defaultFontString = settings.value( "/Composer/defaultFont" ).toString();
if ( !defaultFontString.isEmpty() )
{
mGridAnnotationFont.setFamily( defaultFontString );
}

connectUpdateSlot();

//calculate mExtent based on width/height ratio and map canvas extent
@@ -235,6 +235,13 @@ void QgsComposerScaleBar::applyDefaultSettings()
mBrush.setColor( QColor( 0, 0, 0 ) );
mBrush.setStyle( Qt::SolidPattern );

//get default composer font from settings
QSettings settings;
QString defaultFontString = settings.value( "/Composer/defaultFont" ).toString();
if ( !defaultFontString.isEmpty() )
{
mFont.setFamily( defaultFontString );
}
mFont.setPointSizeF( 12.0 );
mFontColor = QColor( 0, 0, 0 );

@@ -26,6 +26,14 @@ QgsComposerTable::QgsComposerTable( QgsComposition* composition )
, mGridStrokeWidth( 0.5 )
, mGridColor( QColor( 0, 0, 0 ) )
{
//get default composer font from settings
QSettings settings;
QString defaultFontString = settings.value( "/Composer/defaultFont" ).toString();
if ( !defaultFontString.isEmpty() )
{
mHeaderFont.setFamily( defaultFontString );
mContentFont.setFamily( defaultFontString );
}
}

QgsComposerTable::~QgsComposerTable()
@@ -152,6 +152,18 @@
<normaloff>:/images/themes/default/propertyicons/map_tools.png</normaloff>:/images/themes/default/propertyicons/map_tools.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>Composer</string>
</property>
<property name="toolTip">
<string>Composer</string>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionNewComposer.svg</normaloff>:/images/themes/default/mActionNewComposer.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Digitizing</string>
@@ -2824,6 +2836,85 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="mOptionsPage_12">
<layout class="QVBoxLayout" name="verticalLayout_9">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_56">
<property name="styleSheet">
<string notr="true">font-weight:bold;</string>
</property>
<property name="text">
<string>Composer</string>
</property>
</widget>
</item>
<item>
<widget class="QScrollArea" name="mOptionsScrollArea_12">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="mOptionsScrollAreaContents_12">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>674</width>
<height>505</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_39">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Composition defaults</string>
</property>
<layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_58">
<property name="text">
<string>Default font</string>
</property>
</widget>
</item>
<item>
<widget class="QFontComboBox" name="mComposerFontComboBox">
</widget>
</item>
</layout>
</item>
<item row="7" column="0">
<spacer name="verticalSpacer_10">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="mOptionsPage_07">
<layout class="QVBoxLayout" name="verticalLayout_17">
<property name="margin">

0 comments on commit c4e125a

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