QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgslegendpatchshapebutton.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslegendpatchshapebutton.h
3 -----------------
4 Date : April 2020
5 Copyright : (C) 2020 by Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15#ifndef QGSLEGENDPATCHSHAPEBUTTON_H
16#define QGSLEGENDPATCHSHAPEBUTTON_H
17
18#include <memory>
19
20#include "qgis_gui.h"
21#include "qgis_sip.h"
22#include "qgslegendpatchshape.h"
23
24#include <QPointer>
25#include <QToolButton>
26
27class QgsPanelWidget;
28class QgsMessageBar;
29class QgsSymbol;
30
38class GUI_EXPORT QgsLegendPatchShapeButton : public QToolButton
39{
40 Q_OBJECT
41
42 public:
43
48 QgsLegendPatchShapeButton( QWidget *parent SIP_TRANSFERTHIS = nullptr, const QString &dialogTitle = QString() );
50
51 QSize minimumSizeHint() const override;
52 QSize sizeHint() const override;
53
61
66 Qgis::SymbolType symbolType() const { return mType; }
67
74 void setPreviewSymbol( QgsSymbol *symbol SIP_TRANSFER );
75
80 void setDialogTitle( const QString &title );
81
86 QString dialogTitle() const;
87
93 QgsLegendPatchShape shape();
94
101 void setMessageBar( QgsMessageBar *bar );
102
108 QgsMessageBar *messageBar() const;
109
110 public slots:
111
117 void setShape( const QgsLegendPatchShape &shape );
118
122 void setToDefault();
123
124 signals:
125
131 void changed();
132
133 protected:
134 void changeEvent( QEvent *e ) override;
135 void showEvent( QShowEvent *e ) override;
136 void resizeEvent( QResizeEvent *event ) override;
137
138 // Reimplemented to detect right mouse button clicks on the button
139 void mousePressEvent( QMouseEvent *e ) override;
140
141 private slots:
142
143 void showSettingsDialog();
144
148 void prepareMenu();
149
150 void loadPatchFromStyle( const QString &name );
151
152 private:
153 QgsLegendPatchShape mShape;
154
155 QSize mSizeHint;
156
157 QString mDialogTitle;
158
160
161 std::unique_ptr<QgsSymbol> mPreviewSymbol;
162
163 QgsMessageBar *mMessageBar = nullptr;
164
165 QMenu *mMenu = nullptr;
166
167 QSize mIconSize;
168
169 bool mIsDefault = true;
170
174 void updatePreview();
175};
176
177#endif // QGSLEGENDPATCHSHAPEBUTTON_H
SymbolType
Symbol types.
Definition qgis.h:610
@ Fill
Fill symbol.
Definition qgis.h:613
void setSymbolType(Qgis::SymbolType type)
Sets the symbol type which the button requires.
QgsLegendPatchShapeButton(QWidget *parent=nullptr, const QString &dialogTitle=QString())
Construct a new patch shape button with the specified parent widget.
void mousePressEvent(QMouseEvent *e) override
void resizeEvent(QResizeEvent *event) override
void changed()
Emitted when the shape's settings are changed.
QString dialogTitle() const
Returns the title for the symbol settings dialog window.
~QgsLegendPatchShapeButton() override
Qgis::SymbolType symbolType() const
Returns the symbol type which the button requires.
void showEvent(QShowEvent *e) override
Represents a patch shape for use in map legends.
A bar for displaying non-blocking messages to the user.
Base class for any widget that can be shown as an inline panel.
Abstract base class for all rendered symbols.
Definition qgssymbol.h:231
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_TRANSFER
Definition qgis_sip.h:36