Skip to content
Permalink
Browse files

Port ability to show/hide rulers

  • Loading branch information
nyalldawson committed Jul 11, 2017
1 parent 1b93cda commit 9b9126cdce8e55cddcfc1b421d29054fde2f7659
@@ -100,6 +100,15 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla
viewLayout->addWidget( mHorizontalRuler, 0, 1 );
viewLayout->addWidget( mVerticalRuler, 1, 0 );

//initial state of rulers
bool showRulers = settings.value( QStringLiteral( "LayoutDesigner/showRulers" ), true ).toBool();
mActionShowRulers->setChecked( showRulers );
mHorizontalRuler->setVisible( showRulers );
mVerticalRuler->setVisible( showRulers );
mRulerLayoutFix->setVisible( showRulers );
mActionShowRulers->blockSignals( false );
connect( mActionShowRulers, &QAction::triggered, this, &QgsLayoutDesignerDialog::showRulers );

mView = new QgsLayoutView();
//mView->setMapCanvas( mQgis->mapCanvas() );
mView->setContentsMargins( 0, 0, 0, 0 );
@@ -265,6 +274,17 @@ void QgsLayoutDesignerDialog::activate()
#endif
}

void QgsLayoutDesignerDialog::showRulers( bool visible )
{
//show or hide rulers
mHorizontalRuler->setVisible( visible );
mVerticalRuler->setVisible( visible );
mRulerLayoutFix->setVisible( visible );

QgsSettings settings;
settings.setValue( QStringLiteral( "LayoutDesigner/showRulers" ), visible );
}

void QgsLayoutDesignerDialog::closeEvent( QCloseEvent * )
{
emit aboutToClose();
@@ -101,6 +101,11 @@ class QgsLayoutDesignerDialog: public QMainWindow, private Ui::QgsLayoutDesigner
*/
void activate();

/**
* Toggles whether or not the rulers should be \a visible.
*/
void showRulers( bool visible );

signals:

/**
@@ -106,6 +106,8 @@
<addaction name="mActionZoomActual"/>
<addaction name="mActionZoomAll"/>
<addaction name="mActionZoomToWidth"/>
<addaction name="separator"/>
<addaction name="mActionShowRulers"/>
</widget>
<addaction name="mLayoutMenu"/>
<addaction name="mMenuView"/>
@@ -253,6 +255,20 @@
<string>Zoom to Width</string>
</property>
</action>
<action name="mActionShowRulers">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Show Ru&amp;lers</string>
</property>
<property name="toolTip">
<string>Show rulers</string>
</property>
<property name="shortcut">
<string>Ctrl+R</string>
</property>
</action>
</widget>
<resources>
<include location="../../../images/images.qrc"/>

0 comments on commit 9b9126c

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