Skip to content
Permalink
Browse files

Fix restoring selection color from project and allow alpha values for…

… selection color

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14710 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Nov 18, 2010
1 parent 2a55908 commit 7f7202d5dbfa9c3f6dd95923178ca795c9a3a51a
Showing with 35 additions and 8 deletions.
  1. +15 −2 src/app/qgisapp.cpp
  2. +9 −2 src/app/qgsoptions.cpp
  3. +11 −4 src/app/qgsprojectproperties.cpp
@@ -3163,10 +3163,12 @@ void QgisApp::fileNew( bool thePromptToSaveFlag )
int myRed = settings.value( "/qgis/default_selection_color_red", 255 ).toInt();
int myGreen = settings.value( "/qgis/default_selection_color_green", 255 ).toInt();
int myBlue = settings.value( "/qgis/default_selection_color_blue", 0 ).toInt();
int myAlpha = settings.value( "/qgis/default_selection_color_alpha", 255 ).toInt();
prj->writeEntry( "Gui", "/SelectionColorRedPart", myRed );
prj->writeEntry( "Gui", "/SelectionColorGreenPart", myGreen );
prj->writeEntry( "Gui", "/SelectionColorBluePart", myBlue );
QgsRenderer::setSelectionColor( QColor( myRed, myGreen, myBlue ) );
prj->writeEntry( "Gui", "/SelectionColorAlphaPart", myAlpha );
QgsRenderer::setSelectionColor( QColor( myRed, myGreen, myBlue, myAlpha ) );

//set the canvas to the default background color
//the default can be set in qgisoptions
@@ -3429,6 +3431,18 @@ bool QgisApp::addProject( QString projectFile )
mMapCanvas->setCanvasColor( myColor ); //this is fill color before rendering starts
QgsDebugMsg( "Canvas background color restored..." );

//set the color for selections
QSettings settings;
int defaultRed = settings.value( "/qgis/default_selection_color_red", 255 ).toInt();
int defaultGreen = settings.value( "/qgis/default_selection_color_green", 255 ).toInt();
int defaultBlue = settings.value( "/qgis/default_selection_color_blue", 0 ).toInt();
int defaultAlpha = settings.value( "/qgis/default_selection_color_alpha", 255 ).toInt();
int myRed = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorRedPart", defaultRed );
int myGreen = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorGreenPart", defaultGreen );
int myBlue = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorGreenPart", defaultBlue );
int myAlpha = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorAlphaPart", defaultAlpha );
QgsRenderer::setSelectionColor( QColor( myRed, myGreen, myBlue, myAlpha ) );

mMapCanvas->updateScale();
QgsDebugMsg( "Scale restored..." );

@@ -3437,7 +3451,6 @@ bool QgisApp::addProject( QString projectFile )
// specific plug-in state

// add this to the list of recently used project files
QSettings settings;
saveRecentProjectPath( projectFile, settings );

QApplication::restoreOverrideCursor();
@@ -258,7 +258,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
int myRed = settings.value( "/qgis/default_selection_color_red", 255 ).toInt();
int myGreen = settings.value( "/qgis/default_selection_color_green", 255 ).toInt();
int myBlue = settings.value( "/qgis/default_selection_color_blue", 0 ).toInt();
pbnSelectionColor->setColor( QColor( myRed, myGreen, myBlue ) );
int myAlpha = settings.value( "/qgis/default_selection_color_alpha", 255 ).toInt();
pbnSelectionColor->setColor( QColor( myRed, myGreen, myBlue, myAlpha ) );

//set the default color for canvas background
myRed = settings.value( "/qgis/default_canvas_color_red", 255 ).toInt();
@@ -403,7 +404,12 @@ QgsOptions::~QgsOptions()

void QgsOptions::on_pbnSelectionColor_clicked()
{
QColor color = QColorDialog::getColor( pbnSelectionColor->color(), this );
#if QT_VERSION >= 0x040500
QColor color = QColorDialog::getColor( pbnSelectionColor->color(), 0, tr( "Selection color" ), QColorDialog::ShowAlphaChannel );
#else
QColor color = QColorDialog::getColor( pbnSelectionColor->color() );
#endif

if ( color.isValid() )
{
pbnSelectionColor->setColor( color );
@@ -612,6 +618,7 @@ void QgsOptions::saveOptions()
settings.setValue( "/qgis/default_selection_color_red", myColor.red() );
settings.setValue( "/qgis/default_selection_color_green", myColor.green() );
settings.setValue( "/qgis/default_selection_color_blue", myColor.blue() );
settings.setValue( "/qgis/default_selection_color_alpha", myColor.alpha() );

//set the default color for canvas background
myColor = pbnCanvasColor->color();
@@ -79,8 +79,8 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
if ( automaticPrecision )
{
radAutomatic->setChecked( true );
spinBoxDP->setDisabled( true );
labelDP->setDisabled( true );
spinBoxDP->setDisabled( true );
labelDP->setDisabled( true );
}
else
{
@@ -96,7 +96,8 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
int myRedInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorRedPart", 255 );
int myGreenInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorGreenPart", 255 );
int myBlueInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorBluePart", 0 );
QColor myColor = QColor( myRedInt, myGreenInt, myBlueInt );
int myAlphaInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorAlphaPart", 255 );
QColor myColor = QColor( myRedInt, myGreenInt, myBlueInt, myAlphaInt );
pbnSelectionColor->setColor( myColor );

//get the color for map canvas background and set button color accordingly (default white)
@@ -315,6 +316,7 @@ void QgsProjectProperties::apply()
QgsProject::instance()->writeEntry( "Gui", "/SelectionColorRedPart", myColor.red() );
QgsProject::instance()->writeEntry( "Gui", "/SelectionColorGreenPart", myColor.green() );
QgsProject::instance()->writeEntry( "Gui", "/SelectionColorBluePart", myColor.blue() );
QgsProject::instance()->writeEntry( "Gui", "/SelectionColorAlphaPart", myColor.alpha() );
QgsRenderer::setSelectionColor( myColor );

//set the color for canvas
@@ -366,7 +368,12 @@ void QgsProjectProperties::showProjectionsTab()

void QgsProjectProperties::on_pbnSelectionColor_clicked()
{
QColor color = QColorDialog::getColor( pbnSelectionColor->color(), this );
#if QT_VERSION >= 0x040500
QColor color = QColorDialog::getColor( pbnSelectionColor->color(), 0, tr( "Selection color" ), QColorDialog::ShowAlphaChannel );
#else
QColor color = QColorDialog::getColor( pbnSelectionColor->color() );
#endif

if ( color.isValid() )
{
pbnSelectionColor->setColor( color );

0 comments on commit 7f7202d

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