Skip to content

Commit

Permalink
Real fix for trac ticket #140, but not covering all instances of that…
Browse files Browse the repository at this point in the history
… 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/qgis@5871 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
morb_au committed Sep 24, 2006
1 parent 1a3bc56 commit c6937e7
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 37 deletions.
34 changes: 20 additions & 14 deletions src/gui/qgsoptions.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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());
}
Expand All @@ -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);
}
}

Expand All @@ -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)
Expand Down
15 changes: 15 additions & 0 deletions src/gui/qgsoptions.h
Expand Up @@ -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
Expand Down Expand Up @@ -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
46 changes: 25 additions & 21 deletions src/gui/qgsprojectproperties.cpp
Expand Up @@ -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
Expand All @@ -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);
Expand All @@ -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()
Expand Down Expand Up @@ -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);

}
}

Expand All @@ -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);
}
}

Expand All @@ -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()
Expand Down
17 changes: 15 additions & 2 deletions src/gui/qgsprojectproperties.h
Expand Up @@ -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
Expand Down Expand Up @@ -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 c6937e7

Please sign in to comment.