Skip to content
Permalink
Browse files

Add default grid and guide settings to composer options page

  • Loading branch information
nyalldawson committed Nov 19, 2013
1 parent c12956c commit 8f7b4c1f0dca740919a1b1a2cceccb27fdead36c
Showing with 161 additions and 13 deletions.
  1. +18 −0 src/app/qgsoptions.cpp
  2. +25 −11 src/core/composer/qgscomposition.cpp
  3. +4 −0 src/core/composer/qgscomposition.h
  4. +114 −2 src/ui/qgsoptionsbase.ui
@@ -731,6 +731,15 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
mGridStyleComboBox->setCurrentIndex( 1 );
}

//grid defaults
mGridResolutionSpinBox->setValue( settings.value( "/Composer/defaultSnapGridResolution", 10.0 ).toDouble() );
mGridToleranceSpinBox->setValue( settings.value( "/Composer/defaultSnapGridTolerance", 2 ).toDouble() );
mOffsetXSpinBox->setValue( settings.value( "/Composer/defaultSnapGridOffsetX", 0 ).toDouble() );
mOffsetYSpinBox->setValue( settings.value( "/Composer/defaultSnapGridOffsetY", 0 ).toDouble() );

//guide defaults
mGuideToleranceSpinBox->setValue( settings.value( "/Composer/defaultSnapGuideTolerance", 2 ).toDouble() );

//
// Locale settings
//
@@ -1304,6 +1313,15 @@ void QgsOptions::saveOptions()
settings.setValue( "/Composer/gridStyle", "Crosses" );
}

//grid defaults
settings.setValue( "/Composer/defaultSnapGridResolution", mGridResolutionSpinBox->value() );
settings.setValue( "/Composer/defaultSnapGridTolerance", mGridToleranceSpinBox->value() );
settings.setValue( "/Composer/defaultSnapGridOffsetX", mOffsetXSpinBox->value() );
settings.setValue( "/Composer/defaultSnapGridOffsetY", mOffsetYSpinBox->value() );

//guide defaults
settings.setValue( "/Composer/defaultSnapGuideTolerance", mGuideToleranceSpinBox->value() );

//
// Locale settings
//
@@ -60,14 +60,14 @@ QgsComposition::QgsComposition( QgsMapRenderer* mapRenderer )
, mUseAdvancedEffects( true )
, mSnapToGrid( false )
, mGridVisible( false )
, mSnapGridResolution( 10.0 )
, mSnapGridTolerance( 2 )
, mSnapGridOffsetX( 0.0 )
, mSnapGridOffsetY( 0.0 )
, mSnapGridResolution( 0 )
, mSnapGridTolerance( 0 )
, mSnapGridOffsetX( 0 )
, mSnapGridOffsetY( 0 )
, mAlignmentSnap( true )
, mGuidesVisible( true )
, mSmartGuides( true )
, mAlignmentSnapTolerance( 2 )
, mAlignmentSnapTolerance( 0 )
, mSelectionHandles( 0 )
, mActiveItemCommand( 0 )
, mActiveMultiFrameCommand( 0 )
@@ -84,6 +84,9 @@ QgsComposition::QgsComposition( QgsMapRenderer* mapRenderer )
mSelectionHandles->setZValue( 500 );

mPrintResolution = 300; //hardcoded default

//load default composition settings
loadDefaults();
loadSettings();
}

@@ -100,22 +103,23 @@ QgsComposition::QgsComposition()
mUseAdvancedEffects( true ),
mSnapToGrid( false ),
mGridVisible( false ),
mSnapGridResolution( 10.0 ),
mSnapGridTolerance( 2 ),
mSnapGridOffsetX( 0.0 ),
mSnapGridOffsetY( 0.0 ),
mSnapGridResolution( 0 ),
mSnapGridTolerance( 0 ),
mSnapGridOffsetX( 0 ),
mSnapGridOffsetY( 0 ),
mAlignmentSnap( true ),
mGuidesVisible( true ),
mSmartGuides( true ),
mAlignmentSnapTolerance( 2 ),
mAlignmentSnapTolerance( 0 ),
mSelectionHandles( 0 ),
mActiveItemCommand( 0 ),
mActiveMultiFrameCommand( 0 ),
mAtlasComposition( this ),
mPreventCursorChange( false )
{
//load default composition settings
loadDefaults();
loadSettings();

}

QgsComposition::~QgsComposition()
@@ -131,6 +135,16 @@ QgsComposition::~QgsComposition()
delete mActiveMultiFrameCommand;
}

void QgsComposition::loadDefaults()
{
QSettings settings;
mSnapGridResolution = settings.value( "/Composer/defaultSnapGridResolution", 10.0 ).toDouble();
mSnapGridTolerance = settings.value( "/Composer/defaultSnapGridTolerance", 2 ).toDouble();
mSnapGridOffsetX = settings.value( "/Composer/defaultSnapGridOffsetX", 0 ).toDouble();
mSnapGridOffsetY = settings.value( "/Composer/defaultSnapGridOffsetY", 0 ).toDouble();
mAlignmentSnapTolerance = settings.value( "/Composer/defaultSnapGuideTolerance", 2 ).toDouble();
}

void QgsComposition::setPaperSize( double width, double height )
{
mPageWidth = width;
@@ -485,6 +485,10 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene
@return 0 in case of success*/
int boundingRectOfSelectedItems( QRectF& bRect );

/**Loads default composer settings*/
void loadDefaults();

/**Loads composer settings which may change, eg grid color*/
void loadSettings();

void connectAddRemoveCommandSignals( QgsAddRemoveItemCommand* c );
@@ -2888,8 +2888,7 @@
</widget>
</item>
<item>
<widget class="QFontComboBox" name="mComposerFontComboBox">
</widget>
<widget class="QFontComboBox" name="mComposerFontComboBox"/>
</item>
</layout>
</item>
@@ -2926,6 +2925,119 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_24">
<property name="title">
<string>Grid defaults</string>
</property>
<layout class="QGridLayout" name="gridLayout_11">
<item row="0" column="0">
<widget class="QLabel" name="label_61">
<property name="text">
<string>Spacing</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="mGridResolutionSpinBox">
<property name="suffix">
<string> mm</string>
</property>
<property name="minimum">
<double>0.500000000000000</double>
</property>
<property name="maximum">
<double>9999.000000000000000</double>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_63">
<property name="text">
<string>Grid offset</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="3">
<layout class="QHBoxLayout" name="horizontalLayout_36">
<item>
<widget class="QDoubleSpinBox" name="mOffsetXSpinBox">
<property name="prefix">
<string>x: </string>
</property>
<property name="maximum">
<double>9999.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="mOffsetYSpinBox">
<property name="prefix">
<string>y: </string>
</property>
<property name="suffix">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_62">
<property name="text">
<string>Snap tolerance</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="mGridToleranceSpinBox">
<property name="prefix">
<string/>
</property>
<property name="suffix">
<string> mm</string>
</property>
<property name="value">
<double>2.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_25">
<property name="title">
<string>Guide defaults</string>
</property>
<layout class="QGridLayout" name="gridLayout_12">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_37">
<item>
<widget class="QLabel" name="label_64">
<property name="text">
<string>Snap tolerance</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="mGuideToleranceSpinBox">
<property name="prefix">
<string/>
</property>
<property name="suffix">
<string> mm</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_10">
<property name="orientation">

0 comments on commit 8f7b4c1

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