@@ -33,6 +33,7 @@ email : sbr00pwb@users.sourceforge.net
33
33
#include " qgsproject.h"
34
34
#include " qgsunittypes.h"
35
35
#include " qgssettings.h"
36
+ #include " qgssymbollayerutils.h"
36
37
37
38
#include < QPainter>
38
39
#include < QAction>
@@ -75,10 +76,8 @@ void QgsDecorationScaleBar::projectRead()
75
76
mPreferredSize = QgsProject::instance ()->readNumEntry ( mNameConfig , QStringLiteral ( " /PreferredSize" ), 30 );
76
77
mStyleIndex = QgsProject::instance ()->readNumEntry ( mNameConfig , QStringLiteral ( " /Style" ), 0 );
77
78
mSnapping = QgsProject::instance ()->readBoolEntry ( mNameConfig , QStringLiteral ( " /Snapping" ), true );
78
- int myRedInt = QgsProject::instance ()->readNumEntry ( mNameConfig , QStringLiteral ( " /ColorRedPart" ), 0 );
79
- int myGreenInt = QgsProject::instance ()->readNumEntry ( mNameConfig , QStringLiteral ( " /ColorGreenPart" ), 0 );
80
- int myBlueInt = QgsProject::instance ()->readNumEntry ( mNameConfig , QStringLiteral ( " /ColorBluePart" ), 0 );
81
- mColor = QColor ( myRedInt, myGreenInt, myBlueInt );
79
+ mColor = QgsSymbolLayerUtils::decodeColor ( QgsProject::instance ()->readEntry ( mNameConfig , QStringLiteral ( " /Color" ), QStringLiteral ( " #000000" ) ) );
80
+ mOutlineColor = QgsSymbolLayerUtils::decodeColor ( QgsProject::instance ()->readEntry ( mNameConfig , QStringLiteral ( " /OutlineColor" ), QStringLiteral ( " #FFFFFF" ) ) );
82
81
mMarginHorizontal = QgsProject::instance ()->readNumEntry ( mNameConfig , QStringLiteral ( " /MarginH" ), 0 );
83
82
mMarginVertical = QgsProject::instance ()->readNumEntry ( mNameConfig , QStringLiteral ( " /MarginV" ), 0 );
84
83
}
@@ -89,9 +88,8 @@ void QgsDecorationScaleBar::saveToProject()
89
88
QgsProject::instance ()->writeEntry ( mNameConfig , QStringLiteral ( " /PreferredSize" ), mPreferredSize );
90
89
QgsProject::instance ()->writeEntry ( mNameConfig , QStringLiteral ( " /Snapping" ), mSnapping );
91
90
QgsProject::instance ()->writeEntry ( mNameConfig , QStringLiteral ( " /Style" ), mStyleIndex );
92
- QgsProject::instance ()->writeEntry ( mNameConfig , QStringLiteral ( " /ColorRedPart" ), mColor .red () );
93
- QgsProject::instance ()->writeEntry ( mNameConfig , QStringLiteral ( " /ColorGreenPart" ), mColor .green () );
94
- QgsProject::instance ()->writeEntry ( mNameConfig , QStringLiteral ( " /ColorBluePart" ), mColor .blue () );
91
+ QgsProject::instance ()->writeEntry ( mNameConfig , QStringLiteral ( " /Color" ), QgsSymbolLayerUtils::encodeColor ( mColor ) );
92
+ QgsProject::instance ()->writeEntry ( mNameConfig , QStringLiteral ( " /OutlineColor" ), QgsSymbolLayerUtils::encodeColor ( mOutlineColor ) );
95
93
QgsProject::instance ()->writeEntry ( mNameConfig , QStringLiteral ( " /MarginH" ), mMarginHorizontal );
96
94
QgsProject::instance ()->writeEntry ( mNameConfig , QStringLiteral ( " /MarginV" ), mMarginVertical );
97
95
}
@@ -311,7 +309,7 @@ void QgsDecorationScaleBar::render( const QgsMapSettings &mapSettings, QgsRender
311
309
312
310
// Set pen to draw with
313
311
QPen myForegroundPen ( mColor , 2 );
314
- QPen myBackgroundPen ( Qt::white , 4 );
312
+ QPen myBackgroundPen ( mOutlineColor , 4 );
315
313
316
314
// Cast myScaleBarWidth to int for drawing
317
315
int myScaleBarWidthInt = static_cast < int >( myScaleBarWidth );
@@ -434,8 +432,8 @@ void QgsDecorationScaleBar::render( const QgsMapSettings &mapSettings, QgsRender
434
432
// Do drawing of scale bar text
435
433
//
436
434
437
- QColor myBackColor = Qt::white ;
438
- QColor myForeColor = Qt::black ;
435
+ QColor myBackColor = mOutlineColor ;
436
+ QColor myForeColor = mColor ;
439
437
440
438
// Draw the minimum label buffer
441
439
context.painter ()->setPen ( myBackColor );
0 commit comments