-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqgscolordialog.h
125 lines (98 loc) · 3.61 KB
/
qgscolordialog.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/***************************************************************************
qgscolordialog.h - color selection dialog
---------------------
begin : March 19, 2013
copyright : (C) 2013 by Larry Shaffer
email : larrys at dakcarto 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 QGSCOLORDIALOG_H
#define QGSCOLORDIALOG_H
#include <QColorDialog>
#include "ui_qgscolordialog.h"
#include "qgis_gui.h"
#include "qgis.h"
#include "qgshelp.h"
class QColor;
/**
* \ingroup gui
* \class QgsColorDialog
* A custom QGIS dialog for selecting a color. Has many improvements over the standard Qt color picker dialog, including
* hue wheel supports, color swatches, and a color sampler.
* \since QGIS 2.5
*/
class GUI_EXPORT QgsColorDialog : public QDialog, private Ui::QgsColorDialogBase
{
Q_OBJECT
public:
/**
* Create a new color picker dialog
* \param parent parent widget
* \param fl window flags
* \param color initial color for dialog
*/
QgsColorDialog( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags,
const QColor &color = QColor() );
/**
* Returns the current color for the dialog
* \returns dialog color
*/
QColor color() const;
/**
* Sets the title for the color dialog
* \param title title for dialog box
*/
void setTitle( const QString &title );
/**
* Sets whether opacity modification (transparency) is permitted
* for the color dialog. Defaults to true.
* \param allowOpacity set to false to disable opacity modification
* \since QGIS 3.0
*/
void setAllowOpacity( const bool allowOpacity );
/**
* Return a color selection from a color dialog.
* \param initialColor the initial color of the selection dialog.
* \param parent parent widget
* \param title the title of the dialog.
* \param allowOpacity set to true to allow modification of color opacity value (transparency)
* \returns Selected color on accepted() or initialColor on rejected().
* \see getLiveColor
*/
static QColor getColor( const QColor &initialColor, QWidget *parent, const QString &title = QString(),
const bool allowOpacity = false );
signals:
/**
* Emitted when the dialog's color changes
* \param color current color
*/
void currentColorChanged( const QColor &color );
public slots:
/**
* Sets the current color for the dialog
* \param color desired color
*/
void setColor( const QColor &color );
protected:
void closeEvent( QCloseEvent *e ) override;
private slots:
void mButtonBox_accepted();
void mButtonBox_rejected();
void mButtonBox_clicked( QAbstractButton *button );
void discardColor();
void showHelp();
private:
QColor mPreviousColor;
bool mAllowOpacity = true;
/**
* Saves all dialog and widget settings
*/
void saveSettings();
};
#endif // #ifndef QGSCOLORDIALOG_H