[QGIS Commit] r14710 - trunk/qgis/src/app

svn_qgis at osgeo.org svn_qgis at osgeo.org
Thu Nov 18 07:20:44 EST 2010


Author: mhugent
Date: 2010-11-18 04:20:44 -0800 (Thu, 18 Nov 2010)
New Revision: 14710

Modified:
   trunk/qgis/src/app/qgisapp.cpp
   trunk/qgis/src/app/qgsoptions.cpp
   trunk/qgis/src/app/qgsprojectproperties.cpp
Log:
Fix restoring selection color from project and allow alpha values for selection color

Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp	2010-11-18 10:44:43 UTC (rev 14709)
+++ trunk/qgis/src/app/qgisapp.cpp	2010-11-18 12:20:44 UTC (rev 14710)
@@ -3163,10 +3163,12 @@
   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 @@
   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 @@
   // specific plug-in state
 
   // add this to the list of recently used project files
-  QSettings settings;
   saveRecentProjectPath( projectFile, settings );
 
   QApplication::restoreOverrideCursor();

Modified: trunk/qgis/src/app/qgsoptions.cpp
===================================================================
--- trunk/qgis/src/app/qgsoptions.cpp	2010-11-18 10:44:43 UTC (rev 14709)
+++ trunk/qgis/src/app/qgsoptions.cpp	2010-11-18 12:20:44 UTC (rev 14710)
@@ -258,7 +258,8 @@
   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 @@
 
 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 @@
   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();

Modified: trunk/qgis/src/app/qgsprojectproperties.cpp
===================================================================
--- trunk/qgis/src/app/qgsprojectproperties.cpp	2010-11-18 10:44:43 UTC (rev 14709)
+++ trunk/qgis/src/app/qgsprojectproperties.cpp	2010-11-18 12:20:44 UTC (rev 14710)
@@ -79,8 +79,8 @@
   if ( automaticPrecision )
   {
     radAutomatic->setChecked( true );
-     spinBoxDP->setDisabled( true );
-     labelDP->setDisabled( true );
+    spinBoxDP->setDisabled( true );
+    labelDP->setDisabled( true );
   }
   else
   {
@@ -96,7 +96,8 @@
   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 @@
   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::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 );



More information about the QGIS-commit mailing list