mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Restore tests, add button to set page background in ui
This commit is contained in:
parent
4a1bcb3266
commit
cf7714b722
@ -28,6 +28,11 @@ class QgsLayoutItemPage : QgsLayoutItem
|
||||
Landscape
|
||||
};
|
||||
|
||||
enum UndoCommand
|
||||
{
|
||||
UndoPageSymbol,
|
||||
};
|
||||
|
||||
explicit QgsLayoutItemPage( QgsLayout *layout /TransferThis/ );
|
||||
%Docstring
|
||||
Constructor for QgsLayoutItemPage, with the specified parent ``layout``.
|
||||
|
@ -47,6 +47,9 @@ QgsLayoutPagePropertiesWidget::QgsLayoutPagePropertiesWidget( QWidget *parent, Q
|
||||
mLockAspectRatio->setWidthSpinBox( mWidthSpin );
|
||||
mLockAspectRatio->setHeightSpinBox( mHeightSpin );
|
||||
|
||||
mSymbolButton->setSymbolType( QgsSymbol::Fill );
|
||||
mSymbolButton->setSymbol( mPage->layout()->pageCollection()->pageStyleSymbol()->clone() );
|
||||
|
||||
connect( mPageSizeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutPagePropertiesWidget::pageSizeChanged );
|
||||
connect( mPageOrientationComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutPagePropertiesWidget::orientationChanged );
|
||||
|
||||
@ -55,6 +58,7 @@ QgsLayoutPagePropertiesWidget::QgsLayoutPagePropertiesWidget( QWidget *parent, Q
|
||||
connect( mWidthSpin, static_cast< void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutPagePropertiesWidget::setToCustomSize );
|
||||
connect( mHeightSpin, static_cast< void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutPagePropertiesWidget::setToCustomSize );
|
||||
|
||||
connect( mSymbolButton, &QgsSymbolButton::changed, this, &QgsLayoutPagePropertiesWidget::symbolChanged );
|
||||
registerDataDefinedButton( mPaperSizeDDBtn, QgsLayoutObject::PresetPaperSize );
|
||||
registerDataDefinedButton( mWidthDDBtn, QgsLayoutObject::ItemWidth );
|
||||
registerDataDefinedButton( mHeightDDBtn, QgsLayoutObject::ItemHeight );
|
||||
@ -142,6 +146,13 @@ void QgsLayoutPagePropertiesWidget::setToCustomSize()
|
||||
mPageOrientationComboBox->setEnabled( false );
|
||||
}
|
||||
|
||||
void QgsLayoutPagePropertiesWidget::symbolChanged()
|
||||
{
|
||||
mPage->layout()->undoStack()->beginCommand( mPage->layout()->pageCollection(), tr( "Change Page Background" ), QgsLayoutItemPage::UndoPageSymbol );
|
||||
mPage->layout()->pageCollection()->setPageStyleSymbol( static_cast< QgsFillSymbol * >( mSymbolButton->symbol() )->clone() );
|
||||
mPage->layout()->undoStack()->endCommand();
|
||||
}
|
||||
|
||||
void QgsLayoutPagePropertiesWidget::showCurrentPageSize()
|
||||
{
|
||||
QgsLayoutSize paperSize = mPage->pageSize();
|
||||
|
@ -47,6 +47,7 @@ class QgsLayoutPagePropertiesWidget : public QgsLayoutItemBaseWidget, private Ui
|
||||
void orientationChanged( int index );
|
||||
void updatePageSize();
|
||||
void setToCustomSize();
|
||||
void symbolChanged();
|
||||
|
||||
private:
|
||||
|
||||
|
@ -65,6 +65,12 @@ class CORE_EXPORT QgsLayoutItemPage : public QgsLayoutItem
|
||||
Landscape //!< Landscape orientation
|
||||
};
|
||||
|
||||
//! Page item undo commands, used for collapsing undo commands
|
||||
enum UndoCommand
|
||||
{
|
||||
UndoPageSymbol = 3000, //!< Layout page symbol change
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor for QgsLayoutItemPage, with the specified parent \a layout.
|
||||
*/
|
||||
|
@ -44,6 +44,12 @@ void QgsLayoutPageCollection::setPageStyleSymbol( QgsFillSymbol *symbol )
|
||||
return;
|
||||
|
||||
mPageStyleSymbol.reset( static_cast<QgsFillSymbol *>( symbol->clone() ) );
|
||||
|
||||
for ( QgsLayoutItemPage *page : qgis::as_const( mPages ) )
|
||||
{
|
||||
page->update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void QgsLayoutPageCollection::reflow()
|
||||
|
@ -6,15 +6,15 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>660</width>
|
||||
<height>368</height>
|
||||
<width>397</width>
|
||||
<height>409</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>New Item Properties</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="3" column="1">
|
||||
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,1">
|
||||
<item row="3" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -27,7 +27,36 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Background</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QgsSymbolButton" name="mSymbolButton">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Page size</string>
|
||||
@ -178,26 +207,31 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QgsDoubleSpinBox</class>
|
||||
<extends>QDoubleSpinBox</extends>
|
||||
<header>qgsdoublespinbox.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QgsPropertyOverrideButton</class>
|
||||
<extends>QToolButton</extends>
|
||||
<header>qgspropertyoverridebutton.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QgsRatioLockButton</class>
|
||||
<extends>QToolButton</extends>
|
||||
<header>qgsratiolockbutton.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QgsDoubleSpinBox</class>
|
||||
<extends>QDoubleSpinBox</extends>
|
||||
<header>qgsdoublespinbox.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QgsLayoutUnitsComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>qgslayoutunitscombobox.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QgsPropertyOverrideButton</class>
|
||||
<class>QgsSymbolButton</class>
|
||||
<extends>QToolButton</extends>
|
||||
<header>qgspropertyoverridebutton.h</header>
|
||||
<header>qgssymbolbutton.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
|
@ -42,6 +42,8 @@ class TestQgsLayoutPage : public QObject
|
||||
void decodePageOrientation();
|
||||
void grid();
|
||||
void transparentPaper(); //test totally transparent paper style
|
||||
void borderedPaper(); //test page with border
|
||||
void markerLinePaper(); //test page with marker line borde
|
||||
|
||||
void hiddenPages(); //test hidden page boundaries
|
||||
|
||||
@ -187,6 +189,45 @@ void TestQgsLayoutPage::transparentPaper()
|
||||
QVERIFY( checker.testLayout( mReport ) );
|
||||
}
|
||||
|
||||
void TestQgsLayoutPage::borderedPaper()
|
||||
{
|
||||
QgsProject p;
|
||||
QgsLayout l( &p );
|
||||
std::unique_ptr< QgsLayoutItemPage > page( new QgsLayoutItemPage( &l ) );
|
||||
page->setPageSize( QgsLayoutSize( 297, 210, QgsUnitTypes::LayoutMillimeters ) );
|
||||
l.pageCollection()->addPage( page.release() );
|
||||
|
||||
QgsSimpleFillSymbolLayer *simpleFill = new QgsSimpleFillSymbolLayer();
|
||||
std::unique_ptr< QgsFillSymbol > fillSymbol = qgis::make_unique< QgsFillSymbol >();
|
||||
fillSymbol->changeSymbolLayer( 0, simpleFill );
|
||||
simpleFill->setColor( Qt::white );
|
||||
simpleFill->setStrokeColor( Qt::black );
|
||||
simpleFill->setStrokeWidth( 6 );
|
||||
l.pageCollection()->setPageStyleSymbol( fillSymbol.get() );
|
||||
|
||||
QgsLayoutChecker checker( QStringLiteral( "composerpaper_bordered" ), &l );
|
||||
checker.setControlPathPrefix( QStringLiteral( "composer_paper" ) );
|
||||
QVERIFY( checker.testLayout( mReport ) );
|
||||
}
|
||||
|
||||
void TestQgsLayoutPage::markerLinePaper()
|
||||
{
|
||||
QgsProject p;
|
||||
QgsLayout l( &p );
|
||||
std::unique_ptr< QgsLayoutItemPage > page( new QgsLayoutItemPage( &l ) );
|
||||
page->setPageSize( QgsLayoutSize( 297, 210, QgsUnitTypes::LayoutMillimeters ) );
|
||||
l.pageCollection()->addPage( page.release() );
|
||||
|
||||
QgsMarkerLineSymbolLayer *markerLine = new QgsMarkerLineSymbolLayer();
|
||||
std::unique_ptr< QgsFillSymbol > markerLineSymbol = qgis::make_unique< QgsFillSymbol >();
|
||||
markerLineSymbol->changeSymbolLayer( 0, markerLine );
|
||||
l.pageCollection()->setPageStyleSymbol( markerLineSymbol.get() );
|
||||
|
||||
QgsLayoutChecker checker( QStringLiteral( "composerpaper_markerborder" ), &l );
|
||||
checker.setControlPathPrefix( QStringLiteral( "composer_paper" ) );
|
||||
QVERIFY( checker.testLayout( mReport, 0, 0 ) );
|
||||
}
|
||||
|
||||
void TestQgsLayoutPage::hiddenPages()
|
||||
{
|
||||
QgsProject p;
|
||||
@ -195,24 +236,20 @@ void TestQgsLayoutPage::hiddenPages()
|
||||
page->setPageSize( QgsLayoutSize( 297, 210, QgsUnitTypes::LayoutMillimeters ) );
|
||||
l.pageCollection()->addPage( page.release() );
|
||||
|
||||
#if 0 //TODO
|
||||
QgsSimpleFillSymbolLayer *simpleFill = new QgsSimpleFillSymbolLayer();
|
||||
QgsFillSymbol *fillSymbol = new QgsFillSymbol();
|
||||
std::unique_ptr< QgsFillSymbol > fillSymbol = qgis::make_unique< QgsFillSymbol >();
|
||||
fillSymbol->changeSymbolLayer( 0, simpleFill );
|
||||
simpleFill->setColor( Qt::blue );
|
||||
simpleFill->setStrokeColor( Qt::transparent );
|
||||
mComposition->setPageStyleSymbol( fillSymbol );
|
||||
delete fillSymbol;
|
||||
#endif
|
||||
l.pageCollection()->setPageStyleSymbol( fillSymbol.get() );
|
||||
|
||||
l.context().setPagesVisible( false );
|
||||
#if 0 //TODO
|
||||
QgsCompositionChecker checker( QStringLiteral( "composerpaper_hidden" ), mComposition );
|
||||
|
||||
QgsLayoutChecker checker( QStringLiteral( "composerpaper_hidden" ), &l );
|
||||
checker.setControlPathPrefix( QStringLiteral( "composer_paper" ) );
|
||||
bool result = checker.testComposition( mReport );
|
||||
mComposition->setPagesVisible( true );
|
||||
bool result = checker.testLayout( mReport );
|
||||
QVERIFY( result );
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
QGSTEST_MAIN( TestQgsLayoutPage )
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
Loading…
x
Reference in New Issue
Block a user