mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-26 00:02:08 -05:00
Port hide pages action from composer
This commit is contained in:
parent
aa7beaad6a
commit
c8eaeb8f93
@ -151,6 +151,23 @@ class QgsLayoutContext
|
|||||||
.. seealso:: boundingBoxesVisible()
|
.. seealso:: boundingBoxesVisible()
|
||||||
%End
|
%End
|
||||||
|
|
||||||
|
void setPagesVisible( bool visible );
|
||||||
|
%Docstring
|
||||||
|
Sets whether the page items should be ``visible`` in the layout. Removing
|
||||||
|
them will prevent both display of the page boundaries in layout views and
|
||||||
|
will also prevent them from being rendered in layout exports.
|
||||||
|
.. seealso:: pagesVisible()
|
||||||
|
%End
|
||||||
|
|
||||||
|
bool pagesVisible() const;
|
||||||
|
%Docstring
|
||||||
|
Returns whether the page items are be visible in the layout. This setting
|
||||||
|
effects both display of the page boundaries in layout views and
|
||||||
|
whether they will be rendered in layout exports.
|
||||||
|
.. seealso:: setPagesVisible()
|
||||||
|
:rtype: bool
|
||||||
|
%End
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -149,6 +149,7 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla
|
|||||||
connect( mActionSmartGuides, &QAction::triggered, this, &QgsLayoutDesignerDialog::snapToItems );
|
connect( mActionSmartGuides, &QAction::triggered, this, &QgsLayoutDesignerDialog::snapToItems );
|
||||||
|
|
||||||
connect( mActionShowBoxes, &QAction::triggered, this, &QgsLayoutDesignerDialog::showBoxes );
|
connect( mActionShowBoxes, &QAction::triggered, this, &QgsLayoutDesignerDialog::showBoxes );
|
||||||
|
connect( mActionShowPage, &QAction::triggered, this, &QgsLayoutDesignerDialog::showPages );
|
||||||
|
|
||||||
mView = new QgsLayoutView();
|
mView = new QgsLayoutView();
|
||||||
//mView->setMapCanvas( mQgis->mapCanvas() );
|
//mView->setMapCanvas( mQgis->mapCanvas() );
|
||||||
@ -557,6 +558,7 @@ void QgsLayoutDesignerDialog::setCurrentLayout( QgsLayout *layout )
|
|||||||
mActionSnapGuides->setChecked( mLayout->snapper().snapToGuides() );
|
mActionSnapGuides->setChecked( mLayout->snapper().snapToGuides() );
|
||||||
mActionSmartGuides->setChecked( mLayout->snapper().snapToItems() );
|
mActionSmartGuides->setChecked( mLayout->snapper().snapToItems() );
|
||||||
mActionShowBoxes->setChecked( mLayout->context().boundingBoxesVisible() );
|
mActionShowBoxes->setChecked( mLayout->context().boundingBoxesVisible() );
|
||||||
|
mActionShowPage->setChecked( mLayout->context().pagesVisible() );
|
||||||
|
|
||||||
connect( mLayout->undoStack()->stack(), &QUndoStack::canUndoChanged, mActionUndo, &QAction::setEnabled );
|
connect( mLayout->undoStack()->stack(), &QUndoStack::canUndoChanged, mActionUndo, &QAction::setEnabled );
|
||||||
connect( mLayout->undoStack()->stack(), &QUndoStack::canRedoChanged, mActionRedo, &QAction::setEnabled );
|
connect( mLayout->undoStack()->stack(), &QUndoStack::canRedoChanged, mActionRedo, &QAction::setEnabled );
|
||||||
@ -671,6 +673,12 @@ void QgsLayoutDesignerDialog::showBoxes( bool visible )
|
|||||||
mSelectTool->mouseHandles()->update();
|
mSelectTool->mouseHandles()->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QgsLayoutDesignerDialog::showPages( bool visible )
|
||||||
|
{
|
||||||
|
mLayout->context().setPagesVisible( visible );
|
||||||
|
mLayout->pageCollection()->redraw();
|
||||||
|
}
|
||||||
|
|
||||||
void QgsLayoutDesignerDialog::snapToGrid( bool enabled )
|
void QgsLayoutDesignerDialog::snapToGrid( bool enabled )
|
||||||
{
|
{
|
||||||
mLayout->snapper().setSnapToGrid( enabled );
|
mLayout->snapper().setSnapToGrid( enabled );
|
||||||
|
@ -130,6 +130,11 @@ class QgsLayoutDesignerDialog: public QMainWindow, private Ui::QgsLayoutDesigner
|
|||||||
*/
|
*/
|
||||||
void showBoxes( bool visible );
|
void showBoxes( bool visible );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggles whether the layout pages should be \a visible.
|
||||||
|
*/
|
||||||
|
void showPages( bool visible );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggles whether snapping to the page grid is \a enabled.
|
* Toggles whether snapping to the page grid is \a enabled.
|
||||||
*/
|
*/
|
||||||
|
@ -97,3 +97,8 @@ void QgsLayoutContext::setBoundingBoxesVisible( bool visible )
|
|||||||
{
|
{
|
||||||
mBoundingBoxesVisible = visible;
|
mBoundingBoxesVisible = visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QgsLayoutContext::setPagesVisible( bool visible )
|
||||||
|
{
|
||||||
|
mPagesVisible = visible;
|
||||||
|
}
|
||||||
|
@ -163,6 +163,22 @@ class CORE_EXPORT QgsLayoutContext
|
|||||||
*/
|
*/
|
||||||
void setBoundingBoxesVisible( bool visible );
|
void setBoundingBoxesVisible( bool visible );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether the page items should be \a visible in the layout. Removing
|
||||||
|
* them will prevent both display of the page boundaries in layout views and
|
||||||
|
* will also prevent them from being rendered in layout exports.
|
||||||
|
* \see pagesVisible()
|
||||||
|
*/
|
||||||
|
void setPagesVisible( bool visible );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the page items are be visible in the layout. This setting
|
||||||
|
* effects both display of the page boundaries in layout views and
|
||||||
|
* whether they will be rendered in layout exports.
|
||||||
|
* \see setPagesVisible()
|
||||||
|
*/
|
||||||
|
bool pagesVisible() const { return mPagesVisible; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Flags mFlags = 0;
|
Flags mFlags = 0;
|
||||||
@ -174,6 +190,7 @@ class CORE_EXPORT QgsLayoutContext
|
|||||||
|
|
||||||
bool mGridVisible = false;
|
bool mGridVisible = false;
|
||||||
bool mBoundingBoxesVisible = true;
|
bool mBoundingBoxesVisible = true;
|
||||||
|
bool mPagesVisible = true;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -165,7 +165,7 @@ void QgsLayoutItemPage::redraw()
|
|||||||
|
|
||||||
void QgsLayoutItemPage::draw( QgsRenderContext &context, const QStyleOptionGraphicsItem * )
|
void QgsLayoutItemPage::draw( QgsRenderContext &context, const QStyleOptionGraphicsItem * )
|
||||||
{
|
{
|
||||||
if ( !context.painter() || !mLayout /*|| !mLayout->pagesVisible() */ )
|
if ( !context.painter() || !mLayout || !mLayout->context().pagesVisible() )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -145,6 +145,7 @@
|
|||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="mActionShowRulers"/>
|
<addaction name="mActionShowRulers"/>
|
||||||
<addaction name="mActionShowBoxes"/>
|
<addaction name="mActionShowBoxes"/>
|
||||||
|
<addaction name="mActionShowPage"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="mToolbarMenu"/>
|
<addaction name="mToolbarMenu"/>
|
||||||
<addaction name="mPanelsMenu"/>
|
<addaction name="mPanelsMenu"/>
|
||||||
@ -980,6 +981,17 @@
|
|||||||
<string>Simulate Color Blindness (&Deuteranope)</string>
|
<string>Simulate Color Blindness (&Deuteranope)</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="mActionShowPage">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Show Pages</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Show pages</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../../../images/images.qrc"/>
|
<include location="../../../images/images.qrc"/>
|
||||||
|
@ -20,6 +20,10 @@
|
|||||||
#include "qgslayoutitemregistry.h"
|
#include "qgslayoutitemregistry.h"
|
||||||
#include "qgis.h"
|
#include "qgis.h"
|
||||||
#include "qgsproject.h"
|
#include "qgsproject.h"
|
||||||
|
#include "qgssymbol.h"
|
||||||
|
#include "qgssinglesymbolrenderer.h"
|
||||||
|
#include "qgsfillsymbollayer.h"
|
||||||
|
#include "qgslinesymbollayer.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include "qgstest.h"
|
#include "qgstest.h"
|
||||||
|
|
||||||
@ -37,6 +41,8 @@ class TestQgsLayoutPage : public QObject
|
|||||||
void decodePageOrientation();
|
void decodePageOrientation();
|
||||||
void grid();
|
void grid();
|
||||||
|
|
||||||
|
void hiddenPages(); //test hidden page boundaries
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString mReport;
|
QString mReport;
|
||||||
|
|
||||||
@ -159,5 +165,33 @@ void TestQgsLayoutPage::grid()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestQgsLayoutPage::hiddenPages()
|
||||||
|
{
|
||||||
|
QgsProject p;
|
||||||
|
QgsLayout l( &p );
|
||||||
|
QgsLayoutItemPage *page = new QgsLayoutItemPage( &l );
|
||||||
|
page->setPageSize( QgsLayoutSize( 297, 210, QgsUnitTypes::LayoutMillimeters ) );
|
||||||
|
l.pageCollection()->addPage( page );
|
||||||
|
|
||||||
|
#if 0 //TODO
|
||||||
|
QgsSimpleFillSymbolLayer *simpleFill = new QgsSimpleFillSymbolLayer();
|
||||||
|
QgsFillSymbol *fillSymbol = new QgsFillSymbol();
|
||||||
|
fillSymbol->changeSymbolLayer( 0, simpleFill );
|
||||||
|
simpleFill->setColor( Qt::blue );
|
||||||
|
simpleFill->setStrokeColor( Qt::transparent );
|
||||||
|
mComposition->setPageStyleSymbol( fillSymbol );
|
||||||
|
delete fillSymbol;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
l.context().setPagesVisible( false );
|
||||||
|
#if 0 //TODO
|
||||||
|
QgsCompositionChecker checker( QStringLiteral( "composerpaper_hidden" ), mComposition );
|
||||||
|
checker.setControlPathPrefix( QStringLiteral( "composer_paper" ) );
|
||||||
|
bool result = checker.testComposition( mReport );
|
||||||
|
mComposition->setPagesVisible( true );
|
||||||
|
QVERIFY( result );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
QGSTEST_MAIN( TestQgsLayoutPage )
|
QGSTEST_MAIN( TestQgsLayoutPage )
|
||||||
#include "testqgslayoutpage.moc"
|
#include "testqgslayoutpage.moc"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user