40
40
QgsDecorationTitle::QgsDecorationTitle ( QObject *parent )
41
41
: QgsDecorationItem( parent )
42
42
{
43
- mPlacement = TopLeft ;
43
+ mPlacement = TopCenter ;
44
44
mMarginUnit = QgsUnitTypes::RenderMillimeters;
45
45
46
46
setName ( " Title Label" );
@@ -53,7 +53,7 @@ void QgsDecorationTitle::projectRead()
53
53
QgsDecorationItem::projectRead ();
54
54
55
55
mLabelText = QgsProject::instance ()->readEntry ( mNameConfig , QStringLiteral ( " /Label" ), QString () );
56
- mBackgroundColor = QgsSymbolLayerUtils::decodeColor ( QgsProject::instance ()->readEntry ( mNameConfig , QStringLiteral ( " /BackgroundColor" ), QStringLiteral ( " 0,0,0,66 " ) ) );
56
+ mBackgroundColor = QgsSymbolLayerUtils::decodeColor ( QgsProject::instance ()->readEntry ( mNameConfig , QStringLiteral ( " /BackgroundColor" ), QStringLiteral ( " 0,0,0,99 " ) ) );
57
57
58
58
mMarginHorizontal = QgsProject::instance ()->readNumEntry ( mNameConfig , QStringLiteral ( " /MarginH" ), 0 );
59
59
mMarginVertical = QgsProject::instance ()->readNumEntry ( mNameConfig , QStringLiteral ( " /MarginV" ), 0 );
@@ -190,8 +190,26 @@ void QgsDecorationTitle::render( const QgsMapSettings &mapSettings, QgsRenderCon
190
190
xOffset = deviceWidth - xOffset;
191
191
horizontalAlignment = QgsTextRenderer::AlignRight;
192
192
break ;
193
+ case TopCenter: // Top Center
194
+ backgroundBar << QPointF ( 0 , 0 )
195
+ << QPointF ( deviceWidth, 0 )
196
+ << QPointF ( deviceWidth, yOffset * 2 + textHeight )
197
+ << QPointF ( 0 , yOffset * 2 + textHeight );
198
+ yOffset = yOffset + textHeight - textDescent;
199
+ xOffset = deviceWidth / 2 ;
200
+ horizontalAlignment = QgsTextRenderer::AlignCenter;
201
+ break ;
202
+ case BottomCenter: // Bottom Center
203
+ backgroundBar << QPointF ( 0 , deviceHeight )
204
+ << QPointF ( deviceWidth, deviceHeight )
205
+ << QPointF ( deviceWidth, deviceHeight - ( yOffset * 2 + textHeight ) )
206
+ << QPointF ( 0 , deviceHeight - ( yOffset * 2 + textHeight ) );
207
+ yOffset = deviceHeight - yOffset - textDescent;
208
+ xOffset = deviceWidth / 2 ;
209
+ horizontalAlignment = QgsTextRenderer::AlignCenter;
210
+ break ;
193
211
default :
194
- QgsDebugMsg ( QStringLiteral ( " Unknown placement index of %1" ).arg ( static_cast <int >( mPlacement ) ) );
212
+ QgsDebugMsg ( QStringLiteral ( " Unsupported placement index of %1" ).arg ( static_cast <int >( mPlacement ) ) );
195
213
}
196
214
197
215
// Draw background bar
0 commit comments