mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-18 00:03:05 -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
|
Landscape
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum UndoCommand
|
||||||
|
{
|
||||||
|
UndoPageSymbol,
|
||||||
|
};
|
||||||
|
|
||||||
explicit QgsLayoutItemPage( QgsLayout *layout /TransferThis/ );
|
explicit QgsLayoutItemPage( QgsLayout *layout /TransferThis/ );
|
||||||
%Docstring
|
%Docstring
|
||||||
Constructor for QgsLayoutItemPage, with the specified parent ``layout``.
|
Constructor for QgsLayoutItemPage, with the specified parent ``layout``.
|
||||||
|
@ -47,6 +47,9 @@ QgsLayoutPagePropertiesWidget::QgsLayoutPagePropertiesWidget( QWidget *parent, Q
|
|||||||
mLockAspectRatio->setWidthSpinBox( mWidthSpin );
|
mLockAspectRatio->setWidthSpinBox( mWidthSpin );
|
||||||
mLockAspectRatio->setHeightSpinBox( mHeightSpin );
|
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( mPageSizeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutPagePropertiesWidget::pageSizeChanged );
|
||||||
connect( mPageOrientationComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutPagePropertiesWidget::orientationChanged );
|
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( mWidthSpin, static_cast< void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutPagePropertiesWidget::setToCustomSize );
|
||||||
connect( mHeightSpin, 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( mPaperSizeDDBtn, QgsLayoutObject::PresetPaperSize );
|
||||||
registerDataDefinedButton( mWidthDDBtn, QgsLayoutObject::ItemWidth );
|
registerDataDefinedButton( mWidthDDBtn, QgsLayoutObject::ItemWidth );
|
||||||
registerDataDefinedButton( mHeightDDBtn, QgsLayoutObject::ItemHeight );
|
registerDataDefinedButton( mHeightDDBtn, QgsLayoutObject::ItemHeight );
|
||||||
@ -142,6 +146,13 @@ void QgsLayoutPagePropertiesWidget::setToCustomSize()
|
|||||||
mPageOrientationComboBox->setEnabled( false );
|
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()
|
void QgsLayoutPagePropertiesWidget::showCurrentPageSize()
|
||||||
{
|
{
|
||||||
QgsLayoutSize paperSize = mPage->pageSize();
|
QgsLayoutSize paperSize = mPage->pageSize();
|
||||||
|
@ -47,6 +47,7 @@ class QgsLayoutPagePropertiesWidget : public QgsLayoutItemBaseWidget, private Ui
|
|||||||
void orientationChanged( int index );
|
void orientationChanged( int index );
|
||||||
void updatePageSize();
|
void updatePageSize();
|
||||||
void setToCustomSize();
|
void setToCustomSize();
|
||||||
|
void symbolChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -65,6 +65,12 @@ class CORE_EXPORT QgsLayoutItemPage : public QgsLayoutItem
|
|||||||
Landscape //!< Landscape orientation
|
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.
|
* Constructor for QgsLayoutItemPage, with the specified parent \a layout.
|
||||||
*/
|
*/
|
||||||
|
@ -44,6 +44,12 @@ void QgsLayoutPageCollection::setPageStyleSymbol( QgsFillSymbol *symbol )
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
mPageStyleSymbol.reset( static_cast<QgsFillSymbol *>( symbol->clone() ) );
|
mPageStyleSymbol.reset( static_cast<QgsFillSymbol *>( symbol->clone() ) );
|
||||||
|
|
||||||
|
for ( QgsLayoutItemPage *page : qgis::as_const( mPages ) )
|
||||||
|
{
|
||||||
|
page->update();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsLayoutPageCollection::reflow()
|
void QgsLayoutPageCollection::reflow()
|
||||||
|
@ -6,15 +6,15 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>660</width>
|
<width>397</width>
|
||||||
<height>368</height>
|
<height>409</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>New Item Properties</string>
|
<string>New Item Properties</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,1">
|
||||||
<item row="3" column="1">
|
<item row="3" column="0">
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
@ -27,7 +27,36 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</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">
|
<widget class="QGroupBox" name="groupBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Page size</string>
|
<string>Page size</string>
|
||||||
@ -178,26 +207,31 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<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>
|
<customwidget>
|
||||||
<class>QgsRatioLockButton</class>
|
<class>QgsRatioLockButton</class>
|
||||||
<extends>QToolButton</extends>
|
<extends>QToolButton</extends>
|
||||||
<header>qgsratiolockbutton.h</header>
|
<header>qgsratiolockbutton.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
|
||||||
<class>QgsDoubleSpinBox</class>
|
|
||||||
<extends>QDoubleSpinBox</extends>
|
|
||||||
<header>qgsdoublespinbox.h</header>
|
|
||||||
</customwidget>
|
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>QgsLayoutUnitsComboBox</class>
|
<class>QgsLayoutUnitsComboBox</class>
|
||||||
<extends>QComboBox</extends>
|
<extends>QComboBox</extends>
|
||||||
<header>qgslayoutunitscombobox.h</header>
|
<header>qgslayoutunitscombobox.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>QgsPropertyOverrideButton</class>
|
<class>QgsSymbolButton</class>
|
||||||
<extends>QToolButton</extends>
|
<extends>QToolButton</extends>
|
||||||
<header>qgspropertyoverridebutton.h</header>
|
<header>qgssymbolbutton.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
|
@ -42,6 +42,8 @@ class TestQgsLayoutPage : public QObject
|
|||||||
void decodePageOrientation();
|
void decodePageOrientation();
|
||||||
void grid();
|
void grid();
|
||||||
void transparentPaper(); //test totally transparent paper style
|
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
|
void hiddenPages(); //test hidden page boundaries
|
||||||
|
|
||||||
@ -187,6 +189,45 @@ void TestQgsLayoutPage::transparentPaper()
|
|||||||
QVERIFY( checker.testLayout( mReport ) );
|
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()
|
void TestQgsLayoutPage::hiddenPages()
|
||||||
{
|
{
|
||||||
QgsProject p;
|
QgsProject p;
|
||||||
@ -195,24 +236,20 @@ void TestQgsLayoutPage::hiddenPages()
|
|||||||
page->setPageSize( QgsLayoutSize( 297, 210, QgsUnitTypes::LayoutMillimeters ) );
|
page->setPageSize( QgsLayoutSize( 297, 210, QgsUnitTypes::LayoutMillimeters ) );
|
||||||
l.pageCollection()->addPage( page.release() );
|
l.pageCollection()->addPage( page.release() );
|
||||||
|
|
||||||
#if 0 //TODO
|
|
||||||
QgsSimpleFillSymbolLayer *simpleFill = new QgsSimpleFillSymbolLayer();
|
QgsSimpleFillSymbolLayer *simpleFill = new QgsSimpleFillSymbolLayer();
|
||||||
QgsFillSymbol *fillSymbol = new QgsFillSymbol();
|
std::unique_ptr< QgsFillSymbol > fillSymbol = qgis::make_unique< QgsFillSymbol >();
|
||||||
fillSymbol->changeSymbolLayer( 0, simpleFill );
|
fillSymbol->changeSymbolLayer( 0, simpleFill );
|
||||||
simpleFill->setColor( Qt::blue );
|
simpleFill->setColor( Qt::blue );
|
||||||
simpleFill->setStrokeColor( Qt::transparent );
|
simpleFill->setStrokeColor( Qt::transparent );
|
||||||
mComposition->setPageStyleSymbol( fillSymbol );
|
l.pageCollection()->setPageStyleSymbol( fillSymbol.get() );
|
||||||
delete fillSymbol;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
l.context().setPagesVisible( false );
|
l.context().setPagesVisible( false );
|
||||||
#if 0 //TODO
|
|
||||||
QgsCompositionChecker checker( QStringLiteral( "composerpaper_hidden" ), mComposition );
|
QgsLayoutChecker checker( QStringLiteral( "composerpaper_hidden" ), &l );
|
||||||
checker.setControlPathPrefix( QStringLiteral( "composer_paper" ) );
|
checker.setControlPathPrefix( QStringLiteral( "composer_paper" ) );
|
||||||
bool result = checker.testComposition( mReport );
|
bool result = checker.testLayout( mReport );
|
||||||
mComposition->setPagesVisible( true );
|
|
||||||
QVERIFY( result );
|
QVERIFY( result );
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QGSTEST_MAIN( TestQgsLayoutPage )
|
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