Skip to content

Commit 46ba390

Browse files
timlinuxmhugent
authored andcommitted
Fix transparency restoration on project load
1 parent 2c9320a commit 46ba390

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

src/core/qgsmaplayer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ class CORE_EXPORT QgsMapLayer : public QObject
201201
unsigned int getTransparency();
202202

203203
/** Mutator for transparency level. Should be between 0 and 255 */
204-
void setTransparency( unsigned int );
204+
virtual void setTransparency( unsigned int );
205205

206206
/**
207207
* If an operation returns 0 (e.g. draw()), this function

src/core/raster/qgsrasterlayer.cpp

+13-2
Original file line numberDiff line numberDiff line change
@@ -3151,7 +3151,8 @@ bool QgsRasterLayer::readSymbology( const QDomNode& layer_node, QString& errorMe
31513151
{
31523152
QgsColorRampShader* myColorRampShader = ( QgsColorRampShader* ) mRasterShader->rasterShaderFunction();
31533153

3154-
//TODO: Remove the customColorRampType check and following if() in v2.0, added for compatibility with older ( bugged ) project files
3154+
//TODO: Remove the customColorRampType check and following if() in v2.0,
3155+
//added for compatibility with older ( bugged ) project files
31553156
QDomNode customColorRampTypeNode = customColorRampNode.namedItem( "customColorRampType" );
31563157
QDomNode colorRampTypeNode = customColorRampNode.namedItem( "colorRampType" );
31573158
QString myRampType = "";
@@ -3760,7 +3761,8 @@ QString QgsRasterLayer::generateBandName( int theBandNumber )
37603761
*/
37613762
bool QgsRasterLayer::hasBand( QString const & theBandName )
37623763
{
3763-
//TODO: This function is no longer really needed and about be removed -- it is only used to see if "Palette" exists which is not the correct way to see if a band is paletted or not
3764+
//TODO: This function is no longer really needed and about be removed
3765+
//-- it is only used to see if "Palette" exists which is not the correct way to see if a band is paletted or not
37643766
QgsDebugMsg( "Looking for band : " + theBandName );
37653767

37663768
for ( int i = 1; i <= mDataProvider->bandCount(); i++ )
@@ -3984,3 +3986,12 @@ bool QgsRasterLayer::readColorTable( int theBandNumber, QList<QgsColorRampShader
39843986
return true;
39853987
}
39863988

3989+
3990+
void QgsRasterLayer::setTransparency( unsigned int theInt )
3991+
{
3992+
mTransparencyLevel = theInt;
3993+
if ( mRenderer )
3994+
{
3995+
mRenderer->setOpacity( mTransparencyLevel / 255.0 );
3996+
}
3997+
}

src/core/raster/qgsrasterlayer.h

+3
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,9 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
694694
/** \brief receive progress signal from provider */
695695
void onProgress( int, double, QString );
696696

697+
/** \brief Overload the setTransparency method from QgsMapLayer */
698+
void setTransparency( unsigned int theInt );
699+
697700
signals:
698701
/** \brief Signal for notifying listeners of long running processes */
699702
void progressUpdate( int theValue );

0 commit comments

Comments
 (0)