Skip to content
Permalink
Browse files
Potential fix for bug in trac ticket #140.
The Qt3 idiom QToolButton::setPaletteBackgroundColor() has been replaced with a Qt4 idiom of extracting the QPalette from the QToolButton, changing the color in the Window ColorRole, then adding the QPalette back in again.

Only the QGIS Options and Project Properties dialogs have been converted.  If this change fixes the bug in Windows (which I don't have access to a compiler for), then this idiom should be propagated to all instances of setPaletteBackgroundColor (e.g. vector symbology dialog).



git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5696 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
morb_au committed Aug 15, 2006
1 parent 1eff113 commit 95722bbf36eba20613096833f82ef75ce533b0dc
Showing with 114 additions and 25 deletions.
  1. +52 −13 src/gui/qgsoptions.cpp
  2. +62 −12 src/gui/qgsprojectproperties.cpp
@@ -77,7 +77,7 @@ QgsOptions::QgsOptions(QWidget *parent, Qt::WFlags fl) :
//! @todo changes this control name in gui to txtGlobalProjString
QString myProjString = QgsSpatialRefSys::getProj4FromSrsId(mGlobalSRSID);
txtGlobalWKT->setText(myProjString);

// populate combo box with ellipsoids
getEllipsoidList();
QString myEllipsoidId = settings.readEntry("/qgis/measure/ellipsoid", "WGS84");
@@ -94,25 +94,40 @@ QgsOptions::QgsOptions(QWidget *parent, Qt::WFlags fl) :
cmbTheme->insertItem(myDirList[i]);
}
}

// set the theme combo
cmbTheme->setCurrentText(settings.readEntry("/Themes","default"));
//set teh state of the checkboxes

//set the state of the checkboxes
chkAntiAliasing->setChecked(settings.value("/qgis/enable_anti_aliasing",false).toBool());

// Slightly awkard here at the settings value is true to use QImage,
// but the checkbox is true to use QPixmap
chkUseQPixmap->setChecked(!(settings.value("/qgis/use_qimage_to_render", true).toBool()));
chkAddedVisibility->setChecked(settings.value("/qgis/new_layers_visible",true).toBool());
cbxHideSplash->setChecked(settings.value("/qgis/hideSplash",false).toBool());

//set the colour for selections
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();
pbnSelectionColour->setPaletteBackgroundColor(QColor(myRed,myGreen,myBlue));
//set teh default color for canvas background
// old Qt3 idiom
// pbnSelectionColour->setPaletteBackgroundColor(QColor(myRed,myGreen,myBlue));
// new Qt4 idiom
QPalette palSelectionColour = pbnSelectionColour->palette();
palSelectionColour.setColor( QPalette::Window, QColor(myRed,myGreen,myBlue) );
pbnSelectionColour->setPalette(palSelectionColour);

//set the default color for canvas background
myRed = settings.value("/qgis/default_canvas_color_red",255).toInt();
myGreen = settings.value("/qgis/default_canvas_color_green",255).toInt();
myBlue = settings.value("/qgis/default_canvas_color_blue",255).toInt();
pbnCanvasColor->setPaletteBackgroundColor(QColor(myRed,myGreen,myBlue));
// old Qt3 idiom
// pbnCanvasColor->setPaletteBackgroundColor(QColor(myRed,myGreen,myBlue));
// new Qt4 idiom
QPalette palCanvasColor = pbnCanvasColor->palette();
palCanvasColor.setColor( QPalette::Window, QColor(myRed,myGreen,myBlue) );
pbnCanvasColor->setPalette(palCanvasColor);

capitaliseCheckBox->setChecked(settings.value("qgis/capitaliseLayerName", QVariant(false)).toBool());
}
@@ -122,19 +137,35 @@ QgsOptions::~QgsOptions(){}

void QgsOptions::on_pbnSelectionColour_clicked()
{
QColor color = QColorDialog::getColor(pbnSelectionColour->paletteBackgroundColor(),this);
// old Qt3 idiom
// QColor color = QColorDialog::getColor(pbnSelectionColour->paletteBackgroundColor(),this);
// new Qt4 idiom
QPalette palSelectionColour = pbnSelectionColour->palette();
QColor color = QColorDialog::getColor( palSelectionColour.color(QPalette::Window), this );
if (color.isValid())
{
pbnSelectionColour->setPaletteBackgroundColor(color);
// old Qt3 idiom
// pbnSelectionColour->setPaletteBackgroundColor(color);
// new Qt4 idiom
palSelectionColour.setColor( QPalette::Window, color );
pbnSelectionColour->setPalette(palSelectionColour);
}
}

void QgsOptions::on_pbnCanvasColor_clicked()
{
QColor color = QColorDialog::getColor(pbnCanvasColor->paletteBackgroundColor(),this);
// old Qt3 idiom
// QColor color = QColorDialog::getColor(pbnCanvasColor->paletteBackgroundColor(),this);
// new Qt4 idiom
QPalette palCanvasColor = pbnCanvasColor->palette();
QColor color = QColorDialog::getColor( palCanvasColor.color(QPalette::Window), this );
if (color.isValid())
{
pbnCanvasColor->setPaletteBackgroundColor(color);
// old Qt3 idiom
// pbnCanvasColor->setPaletteBackgroundColor(color);
// new Qt4 idiom
palCanvasColor.setColor( QPalette::Window, color );
pbnCanvasColor->setPalette(palCanvasColor);
}
}
void QgsOptions::themeChanged(const QString &newThemeName)
@@ -187,17 +218,25 @@ void QgsOptions::saveOptions()
settings.writeEntry("/Projections/defaultProjectionSRSID",(int)mGlobalSRSID);

settings.writeEntry("/qgis/measure/ellipsoid", getEllipsoidAcronym(cmbEllipsoid->currentText()));

//set the colour for selections
QColor myColor = pbnSelectionColour->paletteBackgroundColor();
// old Qt3 idiom
// QColor myColor = pbnSelectionColour->paletteBackgroundColor();
// new Qt4 idiom
QColor myColor = pbnSelectionColour->palette().color(QPalette::Window);
int myRed = settings.writeEntry("/qgis/default_selection_color_red",myColor.red());
int myGreen = settings.writeEntry("/qgis/default_selection_color_green",myColor.green());
int myBlue = settings.writeEntry("/qgis/default_selection_color_blue",myColor.blue());
//set teh default color for canvas background
myColor = pbnCanvasColor->paletteBackgroundColor();

//set the default color for canvas background
// old Qt3 idiom
// myColor = pbnCanvasColor->paletteBackgroundColor();
// new Qt4 idiom
myColor = pbnCanvasColor->palette().color(QPalette::Window);
myRed = settings.writeEntry("/qgis/default_canvas_color_red",myColor.red());
myGreen = settings.writeEntry("/qgis/default_canvas_color_green",myColor.green());
myBlue = settings.writeEntry("/qgis/default_canvas_color_blue",myColor.blue());

//all done
accept();
}
@@ -106,20 +106,37 @@
int myGreenInt = QgsProject::instance()->readNumEntry("Digitizing","/LineColorGreenPart",0);
int myBlueInt = QgsProject::instance()->readNumEntry("Digitizing","/LineColorBluePart",0);
QColor myColour = QColor(myRedInt,myGreenInt,myBlueInt);
pbnDigitisedLineColour->setPaletteBackgroundColor (myColour);
// old Qt3 idiom
// pbnDigitisedLineColour->setPaletteBackgroundColor (myColour);
// new Qt4 idiom
QPalette palDigitisedLineColour = pbnDigitisedLineColour->palette();
palDigitisedLineColour.setColor( QPalette::Window, myColour );
pbnDigitisedLineColour->setPalette(palDigitisedLineColour);


//get the colour selections and set the button colour accordingly
myRedInt = QgsProject::instance()->readNumEntry("Gui","/SelectionColorRedPart",255);
myGreenInt = QgsProject::instance()->readNumEntry("Gui","/SelectionColorGreenPart",255);
myBlueInt = QgsProject::instance()->readNumEntry("Gui","/SelectionColorBluePart",0);
myColour = QColor(myRedInt,myGreenInt,myBlueInt);
pbnSelectionColour->setPaletteBackgroundColor (myColour);
// old Qt3 idiom
// pbnSelectionColour->setPaletteBackgroundColor (myColour);
// new Qt4 idiom
QPalette palSelectionColour = pbnSelectionColour->palette();
palSelectionColour.setColor( QPalette::Window, myColour );
pbnSelectionColour->setPalette(palSelectionColour);

//get the colour for map canvas background and set button colour accordingly (default white)
myRedInt = QgsProject::instance()->readNumEntry("Gui","/CanvasColorRedPart",255);
myGreenInt = QgsProject::instance()->readNumEntry("Gui","/CanvasColorGreenPart",255);
myBlueInt = QgsProject::instance()->readNumEntry("Gui","/CanvasColorBluePart",255);
myColour = QColor(myRedInt,myGreenInt,myBlueInt);
pbnCanvasColor->setPaletteBackgroundColor (myColour);
// old Qt3 idiom
// pbnCanvasColor->setPaletteBackgroundColor (myColour);
// new Qt4 idiom
QPalette palCanvasColor = pbnCanvasColor->palette();
palCanvasColor.setColor( QPalette::Window, myColour );
pbnCanvasColor->setPalette(palCanvasColor);
}

QgsProjectProperties::~QgsProjectProperties()
@@ -264,20 +281,29 @@ void QgsProjectProperties::apply()
QgsProject::instance()->writeEntry("Digitizing","/LineWidth",spinDigitisedLineWidth->value());

//set the colour of digitising lines
QColor myColour = pbnDigitisedLineColour->paletteBackgroundColor();
// old Qt3 idiom
// QColor myColour = pbnDigitisedLineColour->paletteBackgroundColor();
// new Qt4 idiom
QColor myColour = pbnDigitisedLineColour->palette().color(QPalette::Window);
QgsProject::instance()->writeEntry("Digitizing","/LineColorRedPart",myColour.red());
QgsProject::instance()->writeEntry("Digitizing","/LineColorGreenPart",myColour.green());
QgsProject::instance()->writeEntry("Digitizing","/LineColorBluePart",myColour.blue());

//set the colour for selections
myColour = pbnSelectionColour->paletteBackgroundColor();
// old Qt3 idiom
// myColour = pbnSelectionColour->paletteBackgroundColor();
// new Qt4 idiom
myColour = pbnSelectionColour->palette().color(QPalette::Window);
QgsProject::instance()->writeEntry("Gui","/SelectionColorRedPart",myColour.red());
QgsProject::instance()->writeEntry("Gui","/SelectionColorGreenPart",myColour.green());
QgsProject::instance()->writeEntry("Gui","/SelectionColorBluePart",myColour.blue());
QgsRenderer::mSelectionColor=myColour;

//set the colour for canvas
myColour = pbnCanvasColor->paletteBackgroundColor();
// old Qt3 idiom
// myColour = pbnCanvasColor->paletteBackgroundColor();
// new Qt4 idiom
myColour = pbnCanvasColor->palette().color(QPalette::Window);
QgsProject::instance()->writeEntry("Gui","/CanvasColorRedPart",myColour.red());
QgsProject::instance()->writeEntry("Gui","/CanvasColorGreenPart",myColour.green());
QgsProject::instance()->writeEntry("Gui","/CanvasColorBluePart",myColour.blue());
@@ -304,28 +330,52 @@ void QgsProjectProperties::showProjectionsTab()

void QgsProjectProperties::on_pbnDigitisedLineColour_clicked()
{
QColor color = QColorDialog::getColor(pbnDigitisedLineColour->paletteBackgroundColor(),this);
// old Qt3 idiom
// QColor color = QColorDialog::getColor(pbnDigitisedLineColour->paletteBackgroundColor(),this);
// new Qt4 idiom
QPalette palDigitisedLineColour = pbnDigitisedLineColour->palette();
QColor color = QColorDialog::getColor( palDigitisedLineColour.color(QPalette::Window), this );
if (color.isValid())
{
pbnDigitisedLineColour->setPaletteBackgroundColor(color);
// old Qt3 idiom
// pbnDigitisedLineColour->setPaletteBackgroundColor(color);
// new Qt4 idiom
palDigitisedLineColour.setColor( QPalette::Window, color );
pbnDigitisedLineColour->setPalette(palDigitisedLineColour);
}
}

void QgsProjectProperties::on_pbnSelectionColour_clicked()
{
QColor color = QColorDialog::getColor(pbnSelectionColour->paletteBackgroundColor(),this);
// old Qt3 idiom
// QColor color = QColorDialog::getColor(pbnSelectionColour->paletteBackgroundColor(),this);
// new Qt4 idiom
QPalette palSelectionColour = pbnSelectionColour->palette();
QColor color = QColorDialog::getColor( palSelectionColour.color(QPalette::Window), this );
if (color.isValid())
{
pbnSelectionColour->setPaletteBackgroundColor(color);
// old Qt3 idiom
// pbnSelectionColour->setPaletteBackgroundColor(color);
// new Qt4 idiom
palSelectionColour.setColor( QPalette::Window, color );
pbnSelectionColour->setPalette(palSelectionColour);
}
}

void QgsProjectProperties::on_pbnCanvasColor_clicked()
{
QColor color = QColorDialog::getColor(pbnCanvasColor->paletteBackgroundColor(),this);
// old Qt3 idiom
// QColor color = QColorDialog::getColor(pbnCanvasColor->paletteBackgroundColor(),this);
// new Qt4 idiom
QPalette palCanvasColor = pbnCanvasColor->palette();
QColor color = QColorDialog::getColor( palCanvasColor.color(QPalette::Window), this );
if (color.isValid())
{
pbnCanvasColor->setPaletteBackgroundColor(color);
// old Qt3 idiom
// pbnCanvasColor->setPaletteBackgroundColor(color);
// new Qt4 idiom
palCanvasColor.setColor( QPalette::Window, color );
pbnCanvasColor->setPalette(palCanvasColor);
}
}
void QgsProjectProperties::on_pbnHelp_clicked()

0 comments on commit 95722bb

Please sign in to comment.