QGIS API Documentation
4.3.0-Master (91d4a333d5d)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
qgscolorpickerhelper.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgscolorpickerhelper.h
3
---------------
4
Date : November 2026
5
Copyright : (C) 2026 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 QGSCOLORPICKERHELPER_H
16
#define QGSCOLORPICKERHELPER_H
17
18
#include "qgis_gui.h"
19
#include "
qgis_sip.h
"
20
21
#include <QColor>
22
#include <QObject>
23
#include <QPoint>
24
#include <QPointer>
25
26
#define SIP_NO_FILE
27
28
class
QWidget;
29
class
QScreen;
30
class
QWindow;
31
class
QTimer;
32
33
43
class
GUI_EXPORT
QgsColorPickerHelper
:
public
QObject
44
{
45
Q_OBJECT
46
47
public
:
51
QgsColorPickerHelper
( QObject *parent
SIP_TRANSFERTHIS
);
52
~QgsColorPickerHelper
()
override
;
53
54
public
slots:
55
59
void
activate
(
int
sampleRadius = 0 );
60
61
signals:
62
66
void
colorPicked
(
const
QColor &color );
67
71
void
colorHovered
(
const
QColor &color );
72
76
void
canceled
();
77
78
protected
:
79
bool
eventFilter
( QObject *watched, QEvent *event )
override
;
80
private
slots:
81
82
void
hoverSampleTimeout();
83
84
private
:
85
static
QWidget *findEventWindowWidgetAndLocalPos( QObject *watched,
const
QPointF &eventPos, QPoint &outPos );
86
87
void
onColorPicked(
const
QColor &color );
88
void
cancelPicking();
89
void
stopPicking();
90
91
QColor sampleColor( QWidget *widget,
const
QPoint &pos )
const
;
92
93
static
QColor averageColor(
const
QImage &image );
94
95
bool
mPickingColor =
false
;
96
QColor mCurrentPickingColor;
97
QColor mFinalColor;
98
99
QTimer *mSampleTimer =
nullptr
;
100
QPointer<QWidget> mPendingTargetWidget;
101
QPoint mPendingLocalPos;
102
103
QList< QPointer< QWidget > > mWidgetsToCleanup;
104
105
int
mSampleRadius = 0;
106
};
107
108
109
#endif
// QGSCOLORPICKERHELPER_H
QgsColorPickerHelper::colorPicked
void colorPicked(const QColor &color)
Emitted when the user has finished picking a color from the screen.
QgsColorPickerHelper::activate
void activate(int sampleRadius=0)
Activates the color picking operation.
Definition
qgscolorpickerhelper.cpp:49
QgsColorPickerHelper::colorHovered
void colorHovered(const QColor &color)
Emitted when the user hovers over a color from the screen.
QgsColorPickerHelper::QgsColorPickerHelper
QgsColorPickerHelper(QObject *parent)
Constructor for QgsColorPickerHelper for the specified parent widget.
Definition
qgscolorpickerhelper.cpp:30
QgsColorPickerHelper::eventFilter
bool eventFilter(QObject *watched, QEvent *event) override
Definition
qgscolorpickerhelper.cpp:79
QgsColorPickerHelper::canceled
void canceled()
Emitted when the user cancels the picking operation.
qgis_sip.h
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition
qgis_sip.h:52
Generated on
for QGIS API Documentation by
1.17.0