QGIS/src/gui/qgsproxystyle.h
Nyall Dawson dfa6b6ae19 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.
2018-03-11 10:23:18 +11:00

45 lines
1.6 KiB
C++

/***************************************************************************
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