Skip to content
Permalink
Browse files

Merge pull request #5104 from nyalldawson/composer_tweaks

Composer tweaks
  • Loading branch information
nyalldawson committed Sep 2, 2017
2 parents d915242 + 9d3c9e1 commit 46264414bc5959d52349bec2b0a41c886f8c162d
@@ -50,6 +50,7 @@ QgsComposerLabelWidget::QgsComposerLabelWidget( QgsComposerLabel *label ): QgsCo
}

connect( mFontButton, &QgsFontButton::changed, this, &QgsComposerLabelWidget::fontChanged );
connect( mJustifyRadioButton, &QRadioButton::clicked, this, &QgsComposerLabelWidget::justifyClicked );
}

void QgsComposerLabelWidget::on_mHtmlCheckBox_stateChanged( int state )
@@ -96,6 +97,17 @@ void QgsComposerLabelWidget::fontChanged()
}
}

void QgsComposerLabelWidget::justifyClicked()
{
if ( mComposerLabel )
{
mComposerLabel->beginCommand( tr( "Label alignment changed" ) );
mComposerLabel->setHAlign( Qt::AlignJustify );
mComposerLabel->update();
mComposerLabel->endCommand();
}
}

void QgsComposerLabelWidget::on_mMarginXDoubleSpinBox_valueChanged( double d )
{
if ( mComposerLabel )
@@ -240,6 +252,7 @@ void QgsComposerLabelWidget::setGuiElementValues()
mMiddleRadioButton->setChecked( mComposerLabel->vAlign() == Qt::AlignVCenter );
mBottomRadioButton->setChecked( mComposerLabel->vAlign() == Qt::AlignBottom );
mLeftRadioButton->setChecked( mComposerLabel->hAlign() == Qt::AlignLeft );
mJustifyRadioButton->setChecked( mComposerLabel->hAlign() == Qt::AlignJustify );
mCenterRadioButton->setChecked( mComposerLabel->hAlign() == Qt::AlignHCenter );
mRightRadioButton->setChecked( mComposerLabel->hAlign() == Qt::AlignRight );
mFontColorButton->setColor( mComposerLabel->fontColor() );
@@ -264,6 +277,7 @@ void QgsComposerLabelWidget::blockAllSignals( bool block )
mLeftRadioButton->blockSignals( block );
mCenterRadioButton->blockSignals( block );
mRightRadioButton->blockSignals( block );
mJustifyRadioButton->blockSignals( block );
mFontColorButton->blockSignals( block );
mFontButton->blockSignals( block );
}
@@ -49,6 +49,7 @@ class QgsComposerLabelWidget: public QgsComposerItemBaseWidget, private Ui::QgsC
private slots:
void setGuiElementValues();
void fontChanged();
void justifyClicked();

private:
QgsComposerLabel *mComposerLabel = nullptr;
@@ -233,15 +233,15 @@ void QgsComposerScaleBarWidget::on_mNumberOfSegmentsSpinBox_valueChanged( int i
mComposerScaleBar->endCommand();
}

void QgsComposerScaleBarWidget::on_mHeightSpinBox_valueChanged( int i )
void QgsComposerScaleBarWidget::on_mHeightSpinBox_valueChanged( double d )
{
if ( !mComposerScaleBar )
{
return;
}
mComposerScaleBar->beginCommand( tr( "Scalebar height changed" ), QgsComposerMergeCommand::ScaleBarHeight );
disconnectUpdateSignal();
mComposerScaleBar->setHeight( i );
mComposerScaleBar->setHeight( d );
mComposerScaleBar->update();
connectUpdateSignal();
mComposerScaleBar->endCommand();
@@ -562,6 +562,8 @@ void QgsComposerScaleBarWidget::blockMemberSignals( bool block )
mSegmentSizeRadioGroup.blockSignals( block );
mMapItemComboBox->blockSignals( block );
mFontButton->blockSignals( block );
mMinWidthSpinBox->blockSignals( block );
mMaxWidthSpinBox->blockSignals( block );
}

void QgsComposerScaleBarWidget::connectUpdateSignal()
@@ -651,7 +653,7 @@ void QgsComposerScaleBarWidget::composerMapChanged( QgsComposerItem *item )
mComposerScaleBar->endCommand();
}

void QgsComposerScaleBarWidget::on_mMinWidthSpinBox_valueChanged( int )
void QgsComposerScaleBarWidget::on_mMinWidthSpinBox_valueChanged( double )
{
if ( !mComposerScaleBar )
{
@@ -666,7 +668,7 @@ void QgsComposerScaleBarWidget::on_mMinWidthSpinBox_valueChanged( int )
mComposerScaleBar->endCommand();
}

void QgsComposerScaleBarWidget::on_mMaxWidthSpinBox_valueChanged( int )
void QgsComposerScaleBarWidget::on_mMaxWidthSpinBox_valueChanged( double )
{
if ( !mComposerScaleBar )
{
@@ -35,7 +35,7 @@ class QgsComposerScaleBarWidget: public QgsComposerItemBaseWidget, private Ui::Q

public slots:

void on_mHeightSpinBox_valueChanged( int i );
void on_mHeightSpinBox_valueChanged( double d );
void on_mLineWidthSpinBox_valueChanged( double d );
void on_mSegmentSizeSpinBox_valueChanged( double d );
void on_mSegmentsLeftSpinBox_valueChanged( int i );
@@ -53,8 +53,8 @@ class QgsComposerScaleBarWidget: public QgsComposerItemBaseWidget, private Ui::Q
void on_mUnitsComboBox_currentIndexChanged( int index );
void on_mLineJoinStyleCombo_currentIndexChanged( int index );
void on_mLineCapStyleCombo_currentIndexChanged( int index );
void on_mMinWidthSpinBox_valueChanged( int i );
void on_mMaxWidthSpinBox_valueChanged( int i );
void on_mMinWidthSpinBox_valueChanged( double d );
void on_mMaxWidthSpinBox_valueChanged( double d );

private slots:
void setGuiElements();
@@ -612,7 +612,7 @@ QUrl QgsComposerLabel::createStylesheetUrl() const
stylesheet += QStringLiteral( "body { margin: %1 %2;" ).arg( std::max( mMarginY * mHtmlUnitsToMM, 0.0 ) ).arg( std::max( mMarginX * mHtmlUnitsToMM, 0.0 ) );
stylesheet += QgsFontUtils::asCSS( mFont, 0.352778 * mHtmlUnitsToMM );
stylesheet += QStringLiteral( "color: %1;" ).arg( mFontColor.name() );
stylesheet += QStringLiteral( "text-align: %1; }" ).arg( mHAlignment == Qt::AlignLeft ? "left" : mHAlignment == Qt::AlignRight ? "right" : "center" );
stylesheet += QStringLiteral( "text-align: %1; }" ).arg( mHAlignment == Qt::AlignLeft ? QStringLiteral( "left" ) : mHAlignment == Qt::AlignRight ? QStringLiteral( "right" ) : mHAlignment == Qt::AlignHCenter ? QStringLiteral( "center" ) : QStringLiteral( "justify" ) );

QByteArray ba;
ba.append( stylesheet.toUtf8() );
@@ -728,8 +728,8 @@ bool QgsComposerScaleBar::readXml( const QDomElement &itemElem, const QDomDocume
mSettings.setNumberOfSegmentsLeft( itemElem.attribute( QStringLiteral( "numSegmentsLeft" ), QStringLiteral( "0" ) ).toInt() );
mSettings.setUnitsPerSegment( itemElem.attribute( QStringLiteral( "numUnitsPerSegment" ), QStringLiteral( "1.0" ) ).toDouble() );
mSettings.setSegmentSizeMode( static_cast<QgsScaleBarSettings::SegmentSizeMode>( itemElem.attribute( QStringLiteral( "segmentSizeMode" ), QStringLiteral( "0" ) ).toInt() ) );
mSettings.setMinimumBarWidth( itemElem.attribute( QStringLiteral( "minBarWidth" ), QStringLiteral( "50" ) ).toInt() );
mSettings.setMaximumBarWidth( itemElem.attribute( QStringLiteral( "maxBarWidth" ), QStringLiteral( "150" ) ).toInt() );
mSettings.setMinimumBarWidth( itemElem.attribute( QStringLiteral( "minBarWidth" ), QStringLiteral( "50" ) ).toDouble() );
mSettings.setMaximumBarWidth( itemElem.attribute( QStringLiteral( "maxBarWidth" ), QStringLiteral( "150" ) ).toDouble() );
mSegmentMillimeters = itemElem.attribute( QStringLiteral( "segmentMillimeters" ), QStringLiteral( "0.0" ) ).toDouble();
mSettings.setMapUnitsPerScaleBarUnit( itemElem.attribute( QStringLiteral( "numMapUnitsPerScaleBarUnit" ), QStringLiteral( "1.0" ) ).toDouble() );
mSettings.setLineWidth( itemElem.attribute( QStringLiteral( "outlineWidth" ), QStringLiteral( "0.3" ) ).toDouble() );
@@ -61,8 +61,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>302</width>
<height>686</height>
<width>446</width>
<height>665</height>
</rect>
</property>
<layout class="QVBoxLayout" name="mainLayout">
@@ -126,14 +126,24 @@
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="mHorizontalAlignementLabel">
<property name="text">
<string>Font color</string>
<string>Horizontal alignment</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<item row="3" column="1">
<widget class="QgsDoubleSpinBox" name="mMarginYDoubleSpinBox">
<property name="suffix">
<string> mm</string>
</property>
<property name="minimum">
<double>-99.989999999999995</double>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QRadioButton" name="mTopRadioButton">
@@ -180,6 +190,20 @@
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QLabel" name="mMarginYLabel">
<property name="text">
<string>Vertical margin</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="mMarginXLabel">
<property name="text">
<string>Horizontal margin</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QgsDoubleSpinBox" name="mMarginXDoubleSpinBox">
<property name="prefix">
@@ -193,9 +217,16 @@
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Font color</string>
</property>
</widget>
</item>
<item row="5" column="0">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QRadioButton" name="mLeftRadioButton">
<property name="text">
<string>Left</string>
@@ -205,17 +236,17 @@
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="mCenterRadioButton">
<item row="0" column="3">
<widget class="QRadioButton" name="mJustifyRadioButton">
<property name="text">
<string>Center</string>
<string>Justify</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup_2</string>
</attribute>
</widget>
</item>
<item>
<item row="0" column="2">
<widget class="QRadioButton" name="mRightRadioButton">
<property name="text">
<string>Right</string>
@@ -225,39 +256,35 @@
</attribute>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>20</height>
</size>
<item row="0" column="1">
<widget class="QRadioButton" name="mCenterRadioButton">
<property name="text">
<string>Center</string>
</property>
</spacer>
<attribute name="buttonGroup">
<string notr="true">buttonGroup_2</string>
</attribute>
</widget>
</item>
</layout>
</item>
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="mHorizontalAlignementLabel">
<property name="text">
<string>Horizontal alignment</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<item row="7" column="0" colspan="2">
<widget class="QLabel" name="mVerticalAlignementLabel">
<property name="text">
<string>Vertical alignment</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="mMarginXLabel">
<item row="0" column="0" colspan="2">
<widget class="QgsFontButton" name="mFontButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Horizontal margin</string>
<string>Font</string>
</property>
</widget>
</item>
@@ -297,36 +324,6 @@
</item>
</layout>
</item>
<item row="3" column="1">
<widget class="QgsDoubleSpinBox" name="mMarginYDoubleSpinBox">
<property name="suffix">
<string> mm</string>
</property>
<property name="minimum">
<double>-99.989999999999995</double>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="mMarginYLabel">
<property name="text">
<string>Vertical margin</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QgsFontButton" name="mFontButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Font</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@@ -388,7 +385,7 @@
<resources/>
<connections/>
<buttongroups>
<buttongroup name="buttonGroup"/>
<buttongroup name="buttonGroup_2"/>
<buttongroup name="buttonGroup"/>
</buttongroups>
</ui>

0 comments on commit 4626441

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