QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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:
47 QgsLegendPatchShapeButton( QWidget *parent SIP_TRANSFERTHIS = nullptr, const QString &dialogTitle = QString() );
49
50 QSize minimumSizeHint() const override;
51 QSize sizeHint() const override;
52
60
65 Qgis::SymbolType symbolType() const { return mType; }
66
73 void setPreviewSymbol( QgsSymbol *symbol SIP_TRANSFER );
74
79 void setDialogTitle( const QString &title );
80
85 QString dialogTitle() const;
86
92 QgsLegendPatchShape shape();
93
100 void setMessageBar( QgsMessageBar *bar );
101
107 QgsMessageBar *messageBar() const;
108
109 public slots:
110
116 void setShape( const QgsLegendPatchShape &shape );
117
121 void setToDefault();
122
123 signals:
124
130 void changed();
131
132 protected:
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 QgsLegendPatchShape mShape;
153
154 QSize mSizeHint;
155
156 QString mDialogTitle;
157
159
160 std::unique_ptr<QgsSymbol> mPreviewSymbol;
161
162 QgsMessageBar *mMessageBar = nullptr;
163
164 QMenu *mMenu = nullptr;
165
166 QSize mIconSize;
167
168 bool mIsDefault = true;
169
173 void updatePreview();
174};
175
176#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