@@ -24,11 +24,12 @@ email : tim@linfiniti.com
24
24
#include " qgsdecorationcopyright.h"
25
25
#include " qgsdecorationcopyrightdialog.h"
26
26
27
+ #include " qgisapp.h"
27
28
#include " qgsapplication.h"
28
29
#include " qgslogger.h"
29
30
#include " qgsmapcanvas.h"
30
31
#include " qgsproject.h"
31
- #include " qgisapp .h"
32
+ #include " qgssymbollayerutils .h"
32
33
33
34
#include < QPainter>
34
35
#include < QMenu>
@@ -64,23 +65,22 @@ void QgsDecorationCopyright::projectRead()
64
65
// there is no font setting in the UI, so just use the Qt/QGIS default font (what mQFont gets when created)
65
66
// mQFont.setFamily( QgsProject::instance()->readEntry( "CopyrightLabel", "/FontName", "Sans Serif" ) );
66
67
// mQFont.setPointSize( QgsProject::instance()->readNumEntry( "CopyrightLabel", "/FontSize", 9 ) );
67
- QgsProject *prj = QgsProject::instance ();
68
- mLabelQString = prj ->readEntry ( mNameConfig , QStringLiteral ( " /Label" ), defString );
68
+
69
+ mLabelQString = QgsProject::instance () ->readEntry ( mNameConfig , QStringLiteral ( " /Label" ), defString );
69
70
mMarginHorizontal = QgsProject::instance ()->readNumEntry ( mNameConfig , QStringLiteral ( " /MarginH" ), 0 );
70
71
mMarginVertical = QgsProject::instance ()->readNumEntry ( mNameConfig , QStringLiteral ( " /MarginV" ), 0 );
71
- mLabelQColor . setNamedColor ( prj ->readEntry ( mNameConfig , QStringLiteral ( " /Color" ), QStringLiteral ( " #000000" ) ) ); // default color is black
72
+ mColor = QgsSymbolLayerUtils::decodeColor ( QgsProject::instance () ->readEntry ( mNameConfig , QStringLiteral ( " /Color" ), QStringLiteral ( " #000000" ) ) );
72
73
}
73
74
74
75
void QgsDecorationCopyright::saveToProject ()
75
76
{
76
77
QgsDecorationItem::saveToProject ();
77
- QgsProject *prj = QgsProject::instance ();
78
- prj->writeEntry ( mNameConfig , QStringLiteral ( " /FontName" ), mQFont .family () );
79
- prj->writeEntry ( mNameConfig , QStringLiteral ( " /FontSize" ), mQFont .pointSize () );
80
- prj->writeEntry ( mNameConfig , QStringLiteral ( " /Label" ), mLabelQString );
81
- prj->writeEntry ( mNameConfig , QStringLiteral ( " /Color" ), mLabelQColor .name () );
82
- prj->writeEntry ( mNameConfig , QStringLiteral ( " /MarginH" ), mMarginHorizontal );
83
- prj->writeEntry ( mNameConfig , QStringLiteral ( " /MarginV" ), mMarginVertical );
78
+ QgsProject::instance ()->writeEntry ( mNameConfig , QStringLiteral ( " /FontName" ), mQFont .family () );
79
+ QgsProject::instance ()->writeEntry ( mNameConfig , QStringLiteral ( " /FontSize" ), mQFont .pointSize () );
80
+ QgsProject::instance ()->writeEntry ( mNameConfig , QStringLiteral ( " /Label" ), mLabelQString );
81
+ QgsProject::instance ()->writeEntry ( mNameConfig , QStringLiteral ( " /Color" ), QgsSymbolLayerUtils::encodeColor ( mColor ) );
82
+ QgsProject::instance ()->writeEntry ( mNameConfig , QStringLiteral ( " /MarginH" ), mMarginHorizontal );
83
+ QgsProject::instance ()->writeEntry ( mNameConfig , QStringLiteral ( " /MarginV" ), mMarginVertical );
84
84
}
85
85
86
86
// Slot called when the buffer menu item is activated
@@ -104,8 +104,9 @@ void QgsDecorationCopyright::render( const QgsMapSettings &mapSettings, QgsRende
104
104
QTextDocument text;
105
105
text.setDefaultFont ( mQFont );
106
106
// To set the text color in a QTextDocument we use a CSS style
107
+
107
108
QString style = " <style type=\" text/css\" > p {color: " +
108
- mLabelQColor . name ( ) + " }</style>" ;
109
+ QString ( " rgba( %1, %2, %3, %4 ) " ). arg ( mColor . red () ). arg ( mColor . green () ). arg ( mColor . blue () ). arg ( QString::number ( mColor . alphaF (), ' f ' , 2 ) ) + " }</style>" ;
109
110
text.setHtml ( style + " <p>" + mLabelQString + " </p>" );
110
111
QSizeF size = text.size ();
111
112
0 commit comments