Skip to content
Permalink
Browse files
Real fix for trac ticket #140, but not covering all instances of that…
… bug yet.

Buttons where the background color is meaningful are now rendered in classic Windows style in the Project Properties and Options menus.  (Windows XP style only has bitmaps for button backgrounds.)

This bug also occurs on (at least) the vector properties dialog, and fixes for that will be committed later.



git-svn-id: http://svn.osgeo.org/qgis/trunk@5871 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
morb_au committed Sep 24, 2006
1 parent d12fb0e commit ecff6a99f7ad38f9be77b1b239ae97fe4032a2b8
Showing with 75 additions and 37 deletions.
  1. +20 −14 src/gui/qgsoptions.cpp
  2. +15 −0 src/gui/qgsoptions.h
  3. +25 −21 src/gui/qgsprojectproperties.cpp
  4. +15 −2 src/gui/qgsprojectproperties.h
@@ -22,12 +22,16 @@
#include "qgisapp.h"
#include "qgslayerprojectionselector.h"
#include "qgsspatialrefsys.h"

#include <QFileDialog>
#include <QSettings>
#include <QColorDialog>

#include <cassert>
#include <iostream>
#include <sqlite3.h>


/**
* \class QgsOptions - Set user options and preferences
* Constructor
@@ -113,21 +117,25 @@ QgsOptions::QgsOptions(QWidget *parent, Qt::WFlags fl) :
int myBlue = settings.value("/qgis/default_selection_color_blue",0).toInt();
// 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);
// new Qt4 idiom - see http://lists.trolltech.com/qt4-preview-feedback/2005-04/thread00270-0.html for reasoning
#ifdef Q_WS_WIN
// Coloured buttons do not work under the Windows XP style - use plain Windows instead
pbnSelectionColour->setStyle(&mWindowsStyle);
#endif
pbnSelectionColour->setPalette( QColor(myRed,myGreen,myBlue) );

//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();
// 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);
// new Qt4 idiom - see http://lists.trolltech.com/qt4-preview-feedback/2005-04/thread00270-0.html for reasoning
#ifdef Q_WS_WIN
// Coloured buttons do not work under the Windows XP style - use plain Windows instead
pbnCanvasColor->setStyle(&mWindowsStyle);
#endif
pbnCanvasColor->setPalette( QColor(myRed,myGreen,myBlue) );

capitaliseCheckBox->setChecked(settings.value("qgis/capitaliseLayerName", QVariant(false)).toBool());
}
@@ -146,9 +154,8 @@ void QgsOptions::on_pbnSelectionColour_clicked()
{
// old Qt3 idiom
// pbnSelectionColour->setPaletteBackgroundColor(color);
// new Qt4 idiom
palSelectionColour.setColor( QPalette::Window, color );
pbnSelectionColour->setPalette(palSelectionColour);
// new Qt4 idiom - see http://lists.trolltech.com/qt4-preview-feedback/2005-04/thread00270-0.html for reasoning
pbnSelectionColour->setPalette(color);
}
}

@@ -163,9 +170,8 @@ void QgsOptions::on_pbnCanvasColor_clicked()
{
// old Qt3 idiom
// pbnCanvasColor->setPaletteBackgroundColor(color);
// new Qt4 idiom
palCanvasColor.setColor( QPalette::Window, color );
pbnCanvasColor->setPalette(palCanvasColor);
// new Qt4 idiom - see http://lists.trolltech.com/qt4-preview-feedback/2005-04/thread00270-0.html for reasoning
pbnCanvasColor->setPalette(color);
}
}
void QgsOptions::themeChanged(const QString &newThemeName)
@@ -18,8 +18,16 @@
/* $Id$ */
#ifndef QGSOPTIONS_H
#define QGSOPTIONS_H

#include "ui_qgsoptionsbase.h"
#include "qgisgui.h"

#ifdef Q_WS_WIN
#include <QWindowsStyle>
#endif



/**
* \class QgsOptions
* \brief Set user options and preferences
@@ -79,8 +87,15 @@ class QgsOptions :public QDialog, private Ui::QgsOptionsBase
private:
//! Pointer to our parent
QWidget *qparent;

//!Global default projection used for new layers added that have no projection
long mGlobalSRSID;

#ifdef Q_WS_WIN
//! Holds the classic Windows style that is used to render buttons with a background color
QWindowsStyle mWindowsStyle;
#endif

};

#endif // #ifndef QGSOPTIONS_H
@@ -108,10 +108,12 @@
QColor myColour = QColor(myRedInt,myGreenInt,myBlueInt);
// old Qt3 idiom
// pbnDigitisedLineColour->setPaletteBackgroundColor (myColour);
// new Qt4 idiom
QPalette palDigitisedLineColour = pbnDigitisedLineColour->palette();
palDigitisedLineColour.setColor( QPalette::Window, myColour );
pbnDigitisedLineColour->setPalette(palDigitisedLineColour);
// new Qt4 idiom - see http://lists.trolltech.com/qt4-preview-feedback/2005-04/thread00270-0.html for reasoning
#ifdef Q_WS_WIN
// Coloured buttons do not work under the Windows XP style - use plain Windows instead
pbnDigitisedLineColour->setStyle(&mWindowsStyle);
#endif
pbnDigitisedLineColour->setPalette(myColour);


//get the colour selections and set the button colour accordingly
@@ -121,10 +123,12 @@
myColour = QColor(myRedInt,myGreenInt,myBlueInt);
// old Qt3 idiom
// pbnSelectionColour->setPaletteBackgroundColor (myColour);
// new Qt4 idiom
QPalette palSelectionColour = pbnSelectionColour->palette();
palSelectionColour.setColor( QPalette::Window, myColour );
pbnSelectionColour->setPalette(palSelectionColour);
// new Qt4 idiom - see http://lists.trolltech.com/qt4-preview-feedback/2005-04/thread00270-0.html for reasoning
#ifdef Q_WS_WIN
// Coloured buttons do not work under the Windows XP style - use plain Windows instead
pbnSelectionColour->setStyle(&mWindowsStyle);
#endif
pbnSelectionColour->setPalette(myColour);

//get the colour for map canvas background and set button colour accordingly (default white)
myRedInt = QgsProject::instance()->readNumEntry("Gui","/CanvasColorRedPart",255);
@@ -133,10 +137,12 @@
myColour = QColor(myRedInt,myGreenInt,myBlueInt);
// old Qt3 idiom
// pbnCanvasColor->setPaletteBackgroundColor (myColour);
// new Qt4 idiom
QPalette palCanvasColor = pbnCanvasColor->palette();
palCanvasColor.setColor( QPalette::Window, myColour );
pbnCanvasColor->setPalette(palCanvasColor);
// new Qt4 idiom - see http://lists.trolltech.com/qt4-preview-feedback/2005-04/thread00270-0.html for reasoning
#ifdef Q_WS_WIN
// Coloured buttons do not work under the Windows XP style - use plain Windows instead
pbnCanvasColor->setStyle(&mWindowsStyle);
#endif
pbnCanvasColor->setPalette(myColour);
}

QgsProjectProperties::~QgsProjectProperties()
@@ -339,9 +345,9 @@ void QgsProjectProperties::on_pbnDigitisedLineColour_clicked()
{
// old Qt3 idiom
// pbnDigitisedLineColour->setPaletteBackgroundColor(color);
// new Qt4 idiom
palDigitisedLineColour.setColor( QPalette::Window, color );
pbnDigitisedLineColour->setPalette(palDigitisedLineColour);
// new Qt4 idiom - see http://lists.trolltech.com/qt4-preview-feedback/2005-04/thread00270-0.html for reasoning
pbnDigitisedLineColour->setPalette(color);

}
}

@@ -356,9 +362,8 @@ void QgsProjectProperties::on_pbnSelectionColour_clicked()
{
// old Qt3 idiom
// pbnSelectionColour->setPaletteBackgroundColor(color);
// new Qt4 idiom
palSelectionColour.setColor( QPalette::Window, color );
pbnSelectionColour->setPalette(palSelectionColour);
// new Qt4 idiom - see http://lists.trolltech.com/qt4-preview-feedback/2005-04/thread00270-0.html for reasoning
pbnSelectionColour->setPalette(color);
}
}

@@ -373,9 +378,8 @@ void QgsProjectProperties::on_pbnCanvasColor_clicked()
{
// old Qt3 idiom
// pbnCanvasColor->setPaletteBackgroundColor(color);
// new Qt4 idiom
palCanvasColor.setColor( QPalette::Window, color );
pbnCanvasColor->setPalette(palCanvasColor);
// new Qt4 idiom - see http://lists.trolltech.com/qt4-preview-feedback/2005-04/thread00270-0.html for reasoning
pbnCanvasColor->setPalette(color);
}
}
void QgsProjectProperties::on_pbnHelp_clicked()
@@ -21,7 +21,12 @@
#include "ui_qgsprojectpropertiesbase.h"
#include "qgis.h"
#include "qgisgui.h"
class QColor;

#ifdef Q_WS_WIN
#include <QWindowsStyle>
#endif

class QColor;

/*! Dialog to set project level properties
@@ -112,6 +117,14 @@ public slots:
void refresh();
//! notification of when on the fly projections are enabled / disabled
void projectionEnabled(bool);

private:
static const int context_id = 361087368;
static const int context_id = 361087368;

#ifdef Q_WS_WIN
//! Holds the classic Windows style that is used to render buttons with a background color
QWindowsStyle mWindowsStyle;
#endif


};

0 comments on commit ecff6a9

Please sign in to comment.