QGIS API Documentation 3.41.0-Master (3440c17df1d)
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 "qgis_gui.h"
19#include "qgis_sip.h"
20#include "qgslegendpatchshape.h"
21#include <QToolButton>
22#include <QPointer>
23#include <memory>
24
25class QgsPanelWidget;
26class QgsMessageBar;
27class QgsSymbol;
28
36class GUI_EXPORT QgsLegendPatchShapeButton : public QToolButton
37{
38 Q_OBJECT
39
40 public:
41
46 QgsLegendPatchShapeButton( QWidget *parent SIP_TRANSFERTHIS = nullptr, const QString &dialogTitle = QString() );
48
49 QSize minimumSizeHint() const override;
50 QSize sizeHint() const override;
51
58 void setSymbolType( Qgis::SymbolType type );
59
64 Qgis::SymbolType symbolType() const { return mType; }
65
72 void setPreviewSymbol( QgsSymbol *symbol SIP_TRANSFER );
73
78 void setDialogTitle( const QString &title );
79
84 QString dialogTitle() const;
85
91 QgsLegendPatchShape shape();
92
99 void setMessageBar( QgsMessageBar *bar );
100
106 QgsMessageBar *messageBar() const;
107
108 public slots:
109
115 void setShape( const QgsLegendPatchShape &shape );
116
120 void setToDefault();
121
122 signals:
123
129 void changed();
130
131 protected:
132
133 void changeEvent( QEvent *e ) override;
134 void showEvent( QShowEvent *e ) override;
135 void resizeEvent( QResizeEvent *event ) override;
136
137 // Reimplemented to detect right mouse button clicks on the button
138 void mousePressEvent( QMouseEvent *e ) override;
139
140 private slots:
141
142 void showSettingsDialog();
143
147 void prepareMenu();
148
149 void loadPatchFromStyle( const QString &name );
150
151 private:
152
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
178#endif // QGSLEGENDPATCHSHAPEBUTTON_H
SymbolType
Symbol types.
Definition qgis.h:574
@ Fill
Fill symbol.
A button for creating and modifying QgsLegendPatchShape settings.
void changed()
Emitted when the shape's settings are changed.
~QgsLegendPatchShapeButton() override
Qgis::SymbolType symbolType() const
Returns the symbol type which the button requires.
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 a 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