Skip to content
Permalink
Browse files

Default to layout units in new page dialog

  • Loading branch information
nyalldawson committed Jul 22, 2017
1 parent 8044353 commit 183a72e9265b949f6235470ac6188c22b271f633
Showing with 14 additions and 7 deletions.
  1. +9 −7 src/app/layout/qgslayoutaddpagesdialog.cpp
  2. +5 −0 src/app/layout/qgslayoutaddpagesdialog.h
@@ -17,7 +17,7 @@
#include "qgspagesizeregistry.h"
#include "qgssettings.h"
#include "qgslayout.h"

#include "qgslayoutmeasurementconverter.h"

QgsLayoutAddPagesDialog::QgsLayoutAddPagesDialog( QWidget *parent, Qt::WindowFlags flags )
: QDialog( parent, flags )
@@ -52,8 +52,10 @@ QgsLayoutAddPagesDialog::QgsLayoutAddPagesDialog( QWidget *parent, Qt::WindowFla

void QgsLayoutAddPagesDialog::setLayout( QgsLayout *layout )
{
mSizeUnitsComboBox->setConverter( &layout->context().measurementConverter() );
mConverter = layout->context().measurementConverter();
mSizeUnitsComboBox->setConverter( &mConverter );
mExistingPageSpinBox->setMaximum( layout->pageCollection()->pageCount() );
mSizeUnitsComboBox->setUnit( layout->units() );
}

int QgsLayoutAddPagesDialog::numberPages() const
@@ -101,19 +103,19 @@ void QgsLayoutAddPagesDialog::pageSizeChanged( int )
mSizeUnitsComboBox->setEnabled( false );
mPageOrientationComboBox->setEnabled( true );
QgsPageSize size = QgsApplication::pageSizeRegistry()->find( mPageSizeComboBox->currentData().toString() ).value( 0 );
QgsLayoutSize convertedSize = mConverter.convert( size.size, mSizeUnitsComboBox->unit() );
switch ( mPageOrientationComboBox->currentData().toInt() )
{
case QgsLayoutItemPage::Landscape:
mWidthSpin->setValue( size.size.height() );
mHeightSpin->setValue( size.size.width() );
mWidthSpin->setValue( convertedSize.height() );
mHeightSpin->setValue( convertedSize.width() );
break;

case QgsLayoutItemPage::Portrait:
mWidthSpin->setValue( size.size.width() );
mHeightSpin->setValue( size.size.height() );
mWidthSpin->setValue( convertedSize.width() );
mHeightSpin->setValue( convertedSize.height() );
break;
}
mSizeUnitsComboBox->setUnit( size.size.units() );
}
}

@@ -23,6 +23,7 @@
#include "qgslayoutsize.h"
#include "qgslayoutpoint.h"
#include "qgslayoutitem.h"
#include "qgslayoutmeasurementconverter.h"

/**
* A dialog for configuring properties of new pages to be added to a layout
@@ -78,6 +79,10 @@ class QgsLayoutAddPagesDialog : public QDialog, private Ui::QgsLayoutNewPageDial
void pageSizeChanged( int index );
void orientationChanged( int index );

private:

QgsLayoutMeasurementConverter mConverter;

};

#endif // QGSLAYOUTADDPAGESDIALOG_H

0 comments on commit 183a72e

Please sign in to comment.
You can’t perform that action at this time.