mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Make matching to known page sizes less fussy
Since all gui widgets for page sizes limit to 2 decimal places, we need to allow this much tolerance when checking the setting against known page sizes.
This commit is contained in:
parent
9e2673a178
commit
e8514be010
@ -97,8 +97,8 @@ QString QgsPageSizeRegistry::find( const QgsLayoutSize &size ) const
|
||||
QgsLayoutSize xSize = converter.convert( size, pageSize.size.units() );
|
||||
|
||||
//consider width and height values may be exchanged
|
||||
if ( ( qgsDoubleNear( xSize.width(), pageSize.size.width() ) && qgsDoubleNear( xSize.height(), pageSize.size.height() ) )
|
||||
|| ( qgsDoubleNear( xSize.height(), pageSize.size.width() ) && qgsDoubleNear( xSize.width(), pageSize.size.height() ) ) )
|
||||
if ( ( qgsDoubleNear( xSize.width(), pageSize.size.width(), 0.01 ) && qgsDoubleNear( xSize.height(), pageSize.size.height(), 0.01 ) )
|
||||
|| ( qgsDoubleNear( xSize.height(), pageSize.size.width(), 0.01 ) && qgsDoubleNear( xSize.width(), pageSize.size.height(), 0.01 ) ) )
|
||||
{
|
||||
return pageSize.name;
|
||||
}
|
||||
|
@ -131,7 +131,8 @@ void TestQgsPageSizeRegistry::findBySize()
|
||||
QCOMPARE( registry->find( QgsLayoutSize( 297, 210 ) ), QStringLiteral( "A4" ) );
|
||||
QCOMPARE( registry->find( QgsLayoutSize( 125, 176 ) ), QStringLiteral( "B6" ) );
|
||||
QCOMPARE( registry->find( QgsLayoutSize( 21, 29.7, QgsUnitTypes::LayoutCentimeters ) ), QStringLiteral( "A4" ) );
|
||||
|
||||
// must have allowance of 0.01 units - because we round to this precision in all page size widgets
|
||||
QCOMPARE( registry->find( QgsLayoutSize( 125.009, 175.991 ) ), QStringLiteral( "B6" ) );
|
||||
}
|
||||
|
||||
void TestQgsPageSizeRegistry::decodePageSize()
|
||||
|
Loading…
x
Reference in New Issue
Block a user