Skip to content

Commit

Permalink
Port ability to show/hide rulers
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jul 11, 2017
1 parent 1b93cda commit 9b9126c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/app/layout/qgslayoutdesignerdialog.cpp
Expand Up @@ -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 );
Expand Down Expand Up @@ -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();
Expand Down
5 changes: 5 additions & 0 deletions src/app/layout/qgslayoutdesignerdialog.h
Expand Up @@ -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:

/**
Expand Down
16 changes: 16 additions & 0 deletions src/ui/layout/qgslayoutdesignerbase.ui
Expand Up @@ -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"/>
Expand Down Expand Up @@ -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"/>
Expand Down

0 comments on commit 9b9126c

Please sign in to comment.