Skip to content
Permalink
Browse files

Address title decoration review comments

  • Loading branch information
nirvn committed Nov 15, 2018
1 parent 8027c90 commit 58795aa68931359d7b466abb707c88b0bccc7b09
@@ -107,7 +107,7 @@ void QgsDecorationTitle::render( const QgsMapSettings &mapSettings, QgsRenderCon
context.painter()->setRenderHint( QPainter::Antialiasing, true );

QString displayString = QgsExpression::replaceExpressionText( mLabelText, &context.expressionContext() );
QStringList displayStringList = displayString.split( QStringLiteral( "\n" ) );
QStringList displayStringList = displayString.split( '\n' );

QFontMetricsF fm( mTextFormat.scaledFont( context ) );
QFontMetricsF textMetrics = QgsTextRenderer::fontMetrics( context, mTextFormat );
@@ -23,6 +23,7 @@
#include "qgshelp.h"
#include "qgsmapcanvas.h"
#include "qgssettings.h"
#include "qgsgui.h"

#include <QColorDialog>
#include <QColor>
@@ -35,12 +36,16 @@ QgsDecorationTitleDialog::QgsDecorationTitleDialog( QgsDecorationTitle &deco, QW
, mDeco( deco )
{
setupUi( this );

QgsGui::enableAutoGeometryRestore( this );

connect( buttonBox, &QDialogButtonBox::accepted, this, &QgsDecorationTitleDialog::buttonBox_accepted );
connect( buttonBox, &QDialogButtonBox::rejected, this, &QgsDecorationTitleDialog::buttonBox_rejected );
connect( mInsertExpressionButton, &QPushButton::clicked, this, &QgsDecorationTitleDialog::mInsertExpressionButton_clicked );
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsDecorationTitleDialog::showHelp );

QgsSettings settings;
restoreGeometry( settings.value( QStringLiteral( "Windows/DecorationTitle/geometry" ) ).toByteArray() );
// once the documentation for this dialog is added, remove the line below
buttonBox->button( QDialogButtonBox::Help )->setVisible( false );

QPushButton *applyButton = buttonBox->button( QDialogButtonBox::Apply );
connect( applyButton, &QAbstractButton::clicked, this, &QgsDecorationTitleDialog::apply );
@@ -66,12 +71,12 @@ QgsDecorationTitleDialog::QgsDecorationTitleDialog( QgsDecorationTitle &deco, QW
pbnBackgroundColor->setColorDialogTitle( tr( "Select Background Bar Color" ) );

// placement
cboPlacement->addItem( tr( "Top left" ), QgsDecorationItem::TopLeft );
cboPlacement->addItem( tr( "Top center" ), QgsDecorationItem::TopCenter );
cboPlacement->addItem( tr( "Top right" ), QgsDecorationItem::TopRight );
cboPlacement->addItem( tr( "Bottom left" ), QgsDecorationItem::BottomLeft );
cboPlacement->addItem( tr( "Bottom center" ), QgsDecorationItem::BottomCenter );
cboPlacement->addItem( tr( "Bottom right" ), QgsDecorationItem::BottomRight );
cboPlacement->addItem( tr( "Top Left" ), QgsDecorationItem::TopLeft );
cboPlacement->addItem( tr( "Top Center" ), QgsDecorationItem::TopCenter );
cboPlacement->addItem( tr( "Top Right" ), QgsDecorationItem::TopRight );
cboPlacement->addItem( tr( "Bottom Left" ), QgsDecorationItem::BottomLeft );
cboPlacement->addItem( tr( "Bottom Center" ), QgsDecorationItem::BottomCenter );
cboPlacement->addItem( tr( "Bottom Right" ), QgsDecorationItem::BottomRight );
cboPlacement->setCurrentIndex( cboPlacement->findData( mDeco.placement() ) );
spnHorizontal->setValue( mDeco.mMarginHorizontal );
spnVertical->setValue( mDeco.mMarginVertical );
@@ -84,12 +89,6 @@ QgsDecorationTitleDialog::QgsDecorationTitleDialog( QgsDecorationTitle &deco, QW
mButtonFontStyle->setTextFormat( mDeco.textFormat() );
}

QgsDecorationTitleDialog::~QgsDecorationTitleDialog()
{
QgsSettings settings;
settings.setValue( QStringLiteral( "Windows/DecorationTitle/geometry" ), saveGeometry() );
}

void QgsDecorationTitleDialog::buttonBox_accepted()
{
apply();
@@ -134,3 +133,8 @@ void QgsDecorationTitleDialog::apply()
mDeco.setEnabled( grpEnable->isChecked() );
mDeco.update();
}

void QgsDecorationTitleDialog::showHelp()
{
QgsHelp::openHelp( QStringLiteral( "introduction/general_tools.html#title-label" ) );
}
@@ -30,12 +30,12 @@ class APP_EXPORT QgsDecorationTitleDialog : public QDialog, private Ui::QgsDecor

public:
QgsDecorationTitleDialog( QgsDecorationTitle &deco, QWidget *parent = nullptr );
~QgsDecorationTitleDialog() override;

private slots:
void buttonBox_accepted();
void buttonBox_rejected();
void mInsertExpressionButton_clicked();
void showHelp();
void apply();

protected:
@@ -24,7 +24,7 @@
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>

0 comments on commit 58795aa

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