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 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551
|
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgscolorbutton.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
class QgsColorButton : QToolButton
{
%Docstring(signature="appended")
A cross platform button subclass for selecting colors. Will open a color
chooser dialog when clicked. Offers live updates to button from color
chooser dialog. An attached drop-down menu allows for copying and
pasting colors, picking colors from the screen, and selecting colors
from color swatch grids.
%End
%TypeHeaderCode
#include "qgscolorbutton.h"
%End
%ConvertToSubClassCode
if ( qobject_cast<QgsColorButton *>( sipCpp ) )
sipType = sipType_QgsColorButton;
else
sipType = NULL;
%End
public:
enum Behavior /BaseType=IntEnum/
{
ShowDialog,
SignalOnly
};
QgsColorButton( QWidget *parent /TransferThis/ = 0, const QString &cdt = QString(), QgsColorSchemeRegistry *registry = 0 );
%Docstring
Construct a new color ramp button. Use ``parent`` to attach a parent
QWidget to the dialog. Use ``cdt`` string to define the title to show in
the color ramp dialog Use a color scheme ``registry`` for color swatch
grids to show in the drop-down menu. If not specified, the button will
use the global color scheme registry instead
%End
virtual QSize minimumSizeHint() const;
virtual QSize sizeHint() const;
QColor color() const;
%Docstring
Returns the currently selected color.
:return: currently selected color
.. seealso:: :py:func:`setColor`
%End
void setAllowOpacity( bool allowOpacity );
%Docstring
Sets whether opacity modification (transparency) is permitted for the
color. Defaults to ``False``.
:param allowOpacity: set to ``True`` to allow opacity modification
.. seealso:: :py:func:`allowOpacity`
%End
bool allowOpacity() const;
%Docstring
Returns whether opacity modification (transparency) is permitted for the
color.
:return: ``True`` if opacity modification is allowed
.. seealso:: :py:func:`setAllowOpacity`
%End
void setColorDialogTitle( const QString &title );
%Docstring
Set the title for the color chooser dialog window.
:param title: Title for the color chooser dialog
.. seealso:: :py:func:`colorDialogTitle`
%End
QString colorDialogTitle() const;
%Docstring
Returns the title for the color chooser dialog window.
:return: title for the color chooser dialog
.. seealso:: :py:func:`setColorDialogTitle`
%End
void setShowMenu( bool showMenu );
%Docstring
Sets whether the drop-down menu should be shown for the button. The
default behavior is to show the menu.
:param showMenu: set to ``False`` to hide the drop-down menu
.. seealso:: :py:func:`showMenu`
%End
bool showMenu() const;
%Docstring
Returns whether the drop-down menu is shown for the button.
:return: ``True`` if drop-down menu is shown
.. seealso:: :py:func:`setShowMenu`
%End
void setBehavior( Behavior behavior );
%Docstring
Sets the behavior for when the button is clicked. The default behavior
is to show a color picker dialog.
:param behavior: behavior when button is clicked
.. seealso:: :py:func:`behavior`
%End
Behavior behavior() const;
%Docstring
Returns the behavior for when the button is clicked.
:return: behavior when button is clicked
.. seealso:: :py:func:`setBehavior`
%End
void setDefaultColor( const QColor &color );
%Docstring
Sets the default color for the button, which is shown in the button's
drop-down menu for the "default color" option.
:param color: default color for the button. Set to an invalid QColor to
disable the default color option.
.. seealso:: :py:func:`defaultColor`
%End
QColor defaultColor() const;
%Docstring
Returns the default color for the button, which is shown in the button's
drop-down menu for the "default color" option.
:return: default color for the button. Returns an invalid QColor if the
default color option is disabled.
.. seealso:: :py:func:`setDefaultColor`
%End
void setShowNoColor( const bool showNoColorOption );
%Docstring
Sets whether the "no color" option should be shown in the button's
drop-down menu. If selected, the "no color" option sets the color
button's color to a totally transparent color.
:param showNoColorOption: set to ``True`` to show the no color option.
This is disabled by default.
.. seealso:: :py:func:`showNoColor`
.. seealso:: :py:func:`setNoColorString`
.. note::
The "no color" option is only shown if the color button is set to show an alpha channel in the color
dialog
%End
bool showNoColor() const;
%Docstring
Returns whether the "no color" option is shown in the button's drop-down
menu. If selected, the "no color" option sets the color button's color
to a totally transparent color.
:return: ``True`` if the no color option is shown.
.. seealso:: :py:func:`setShowNoColor`
.. seealso:: :py:func:`noColorString`
.. note::
The "no color" option is only shown if the color button is set to show an alpha channel in the color
dialog
%End
void setNoColorString( const QString &noColorString );
%Docstring
Sets the string to use for the "no color" option in the button's
drop-down menu.
:param noColorString: string to use for the "no color" menu option
.. seealso:: :py:func:`noColorString`
.. seealso:: :py:func:`setShowNoColor`
.. note::
The "no color" option is only shown if the color button is set to show an alpha channel in the color
dialog
%End
void setShowNull( bool showNull, const QString &nullString = QString() );
%Docstring
Sets whether a set to null (clear) option is shown in the button's
drop-down menu.
:param showNull: set to ``True`` to show a null option
:param nullString: translated string to use for the null option. If not
set, a default "Clear Color" string will be used.
.. seealso:: :py:func:`showNull`
.. seealso:: :py:func:`isNull`
%End
bool showNull() const;
%Docstring
Returns whether the set to null (clear) option is shown in the button's
drop-down menu.
.. seealso:: :py:func:`setShowNull`
.. seealso:: :py:func:`isNull`
%End
bool isNull() const;
%Docstring
Returns ``True`` if the current color is null.
.. seealso:: :py:func:`setShowNull`
.. seealso:: :py:func:`showNull`
%End
QString noColorString() const;
%Docstring
Returns the string used for the "no color" option in the button's
drop-down menu.
:return: string used for the "no color" menu option
.. seealso:: :py:func:`setNoColorString`
.. seealso:: :py:func:`showNoColor`
.. note::
The "no color" option is only shown if the color button is set to show an alpha channel in the color
dialog
%End
void setContext( const QString &context );
%Docstring
Sets the context string for the color button. The context string is
passed to all color swatch grids shown in the button's drop-down menu,
to allow them to customize their display colors based on the context.
:param context: context string for the color button's color swatch grids
.. seealso:: :py:func:`context`
%End
QString context() const;
%Docstring
Returns the context string for the color button. The context string is
passed to all color swatch grids shown in the button's drop-down menu,
to allow them to customize their display colors based on the context.
:return: context string for the color button's color swatch grids
.. seealso:: :py:func:`setContext`
%End
void setColorSchemeRegistry( QgsColorSchemeRegistry *registry );
%Docstring
Sets the color scheme registry for the button, which controls the color
swatch grids that are shown in the button's drop-down menu.
:param registry: color scheme registry for the button. Set to 0 to hide
all color swatch grids from the button's drop-down
menu.
.. seealso:: :py:func:`colorSchemeRegistry`
%End
QgsColorSchemeRegistry *colorSchemeRegistry();
%Docstring
Returns the color scheme registry for the button, which controls the
color swatch grids that are shown in the button's drop-down menu.
:return: color scheme registry for the button. If returned value is 0
then all color swatch grids are hidden from the button's
drop-down menu.
.. seealso:: :py:func:`setColorSchemeRegistry`
%End
void linkToProjectColor( const QString &name );
%Docstring
Sets the button to link to an existing project color, by color ``name``.
This changes the behavior of the button to a "linked" mode.
Specifically, the button will show the linked color and respond to
changes in the project color scheme by refreshing the displayed color
automatically. Additionally, the button's menu will show items specific
to linked color mode, including an option to "unlink" from the project
color.
.. seealso:: :py:func:`linkedProjectColorName`
.. seealso:: :py:func:`unlink`
.. versionadded:: 3.6
%End
QString linkedProjectColorName() const;
%Docstring
Returns the linked project color name, if set.
.. seealso:: :py:func:`linkToProjectColor`
.. versionadded:: 3.6
%End
static QPixmap createMenuIcon( const QColor &color, bool showChecks = true );
%Docstring
Creates an icon for displaying a ``color`` in a drop-down menu.
If ``showChecks`` set to ``True``, then a checkboard pattern will be
shown behind semi-transparent colors.
.. versionadded:: 3.6
%End
public slots:
void setColor( const QColor &color );
%Docstring
Sets the current color for the button. Will emit a colorChanged signal
if the color is different to the previous color.
:param color: new color for the button
.. seealso:: :py:func:`color`
%End
void setButtonBackground( const QColor &color = QColor() );
%Docstring
Sets the background pixmap for the button based upon color and
transparency. Call directly to update background after adding/removing
QColorDialog.ShowAlphaChannel option but the color has not changed, i.e.
:py:func:`~QgsColorButton.setColor` wouldn't update button and you want
the button to retain the set color's alpha component regardless
:param color: Color for button background. If no color is specified, the
button's current color will be used
%End
void copyColor();
%Docstring
Copies the current color to the clipboard
.. seealso:: :py:func:`pasteColor`
%End
void pasteColor();
%Docstring
Pastes a color from the clipboard to the color button. If clipboard does
not contain a valid color or string representation of a color, then no
change is applied.
.. seealso:: :py:func:`copyColor`
%End
void activatePicker();
%Docstring
Activates the color picker tool, which allows for sampling a color from
anywhere on the screen
%End
void setToNoColor();
%Docstring
Sets color to a totally transparent color.
.. note::
If the color button is not set to show an opacity channel in the color
dialog then the color will not be changed.
.. seealso:: :py:func:`setToNull`
%End
void setToDefaultColor();
%Docstring
Sets color to the button's default color, if set.
.. seealso:: :py:func:`setDefaultColor`
.. seealso:: :py:func:`defaultColor`
.. seealso:: :py:func:`setToNull`
%End
void setToNull();
%Docstring
Sets color to null.
.. seealso:: :py:func:`setToDefaultColor`
.. seealso:: :py:func:`setToNoColor`
.. seealso:: :py:func:`cleared`
%End
void unlink();
%Docstring
Unlinks the button from a project color.
.. seealso:: :py:func:`unlinked`
.. seealso:: :py:func:`linkToProjectColor`
.. versionadded:: 3.6
%End
signals:
void colorChanged( const QColor &color );
%Docstring
Emitted whenever a new color is set for the button. The color is always
valid. In case the new color is the same no signal is emitted, to avoid
infinite loops.
:param color: New color
%End
void colorClicked( const QColor &color );
%Docstring
Emitted when the button is clicked, if the button's behavior is set to
SignalOnly
:param color: button color
.. seealso:: :py:func:`setBehavior`
.. seealso:: :py:func:`behavior`
%End
void cleared();
%Docstring
Emitted when the color is cleared (set to null).
.. seealso:: :py:func:`setToNull`
.. versionadded:: 3.12
%End
void unlinked();
%Docstring
Emitted when the color is unlinked, e.g. when it was previously set to
link to a project color and is now no longer linked.
.. seealso:: :py:func:`unlink`
.. seealso:: :py:func:`linkToProjectColor`
.. versionadded:: 3.6
%End
protected:
virtual bool event( QEvent *e );
virtual void changeEvent( QEvent *e );
virtual void showEvent( QShowEvent *e );
virtual void resizeEvent( QResizeEvent *event );
static const QPixmap &transparentBackground();
%Docstring
Returns a checkboard pattern pixmap for use as a background to
transparent colors
%End
virtual void mousePressEvent( QMouseEvent *e );
%Docstring
Reimplemented to detect right mouse button clicks on the color button
and allow dragging colors
%End
virtual void mouseMoveEvent( QMouseEvent *e );
%Docstring
Reimplemented to allow dragging colors from button
%End
virtual void mouseReleaseEvent( QMouseEvent *e );
%Docstring
Reimplemented to allow color picking
%End
virtual void keyPressEvent( QKeyEvent *e );
%Docstring
Reimplemented to allow canceling color pick via keypress, and sample via
space bar press
%End
virtual void dragEnterEvent( QDragEnterEvent *e );
%Docstring
Reimplemented to accept dragged colors
%End
virtual void dragLeaveEvent( QDragLeaveEvent *e );
%Docstring
Reimplemented to reset button appearance after drag leave
%End
virtual void dropEvent( QDropEvent *e );
%Docstring
Reimplemented to accept dropped colors
%End
virtual void wheelEvent( QWheelEvent *event );
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgscolorbutton.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
|