Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Correctly set base style for QgsLayerTreeViewProxyStyle
Creates a new QgsProxyStyle subclass of QProxyStyle which automatically sets the base style to match the current application style (creating a new QStyle object, since setting the base style takes ownership). Additionally, QgsProxyStyle correctly parents the style to a parent widget, avoiding leaks since calling QWidget::setStyle doesn't transfer ownership. Fixes incorrect theme used for layer tree view since addition of indicator icons.
- Loading branch information
1 parent
0c1ceb3
commit dfa6b6a
Showing
12 changed files
with
139 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/qgsproxystyle.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
class QgsProxyStyle : QProxyStyle | ||
{ | ||
%Docstring | ||
A QProxyStyle subclass which correctly sets the base style to match | ||
the QGIS application style, and handles object lifetime by correctly | ||
parenting to a parent widget. | ||
|
||
.. versionadded:: 3.2 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsproxystyle.h" | ||
%End | ||
public: | ||
|
||
explicit QgsProxyStyle( QWidget *parent /Transfer/ ); | ||
%Docstring | ||
Constructor for QgsProxyStyle. Ownership is transferred to the ``parent`` widget. | ||
|
||
The base style for the QProxyStyle will be set to match the current QGIS application style. | ||
%End | ||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/qgsproxystyle.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
|
||
|
||
|
||
|
||
class QgsCategorizedSymbolRendererWidget : QgsRendererWidget | ||
{ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/*************************************************************************** | ||
qgsproxystyle.cpp | ||
----------------- | ||
Date : March 2018 | ||
Copyright : (C) 2018 by Nyall Dawson | ||
Email : nyall dot dawson at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsproxystyle.h" | ||
#include <QStyleFactory> | ||
#include <QStyle> | ||
#include <QApplication> | ||
|
||
QgsProxyStyle::QgsProxyStyle( QWidget *parent ) | ||
: QProxyStyle( nullptr ) // no base style yet - it transfer ownership, so we need a NEW QStyle object for the base style | ||
{ | ||
// get application style | ||
QString appStyle = QApplication::style()->objectName(); | ||
if ( !appStyle.isEmpty() ) | ||
{ | ||
if ( QStyle *style = QStyleFactory::create( appStyle ) ) | ||
setBaseStyle( style ); | ||
} | ||
|
||
// set lifetime to match parent widget's | ||
setParent( parent ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/*************************************************************************** | ||
qgsproxystyle.h | ||
--------------- | ||
Date : March 2018 | ||
Copyright : (C) 2018 by Nyall Dawson | ||
Email : nyall dot dawson at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSPROXYSTYLE_H | ||
#define QGSPROXYSTYLE_H | ||
|
||
#include "qgis_sip.h" | ||
#include "qgsgui.h" | ||
#include <QProxyStyle> | ||
|
||
/** | ||
* A QProxyStyle subclass which correctly sets the base style to match | ||
* the QGIS application style, and handles object lifetime by correctly | ||
* parenting to a parent widget. | ||
* \since QGIS 3.2 | ||
* \ingroup gui | ||
*/ | ||
class GUI_EXPORT QgsProxyStyle : public QProxyStyle | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
|
||
/** | ||
* Constructor for QgsProxyStyle. Ownership is transferred to the \a parent widget. | ||
* | ||
* The base style for the QProxyStyle will be set to match the current QGIS application style. | ||
*/ | ||
explicit QgsProxyStyle( QWidget *parent SIP_TRANSFER ); | ||
}; | ||
|
||
#endif // QGSPROXYSTYLE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters