Wavelength
Privacy-focused, cross-platform, and open-source communication application
Loading...
Searching...
No Matches
ClickableColorPreview Class Referencefinal

A small, clickable widget that displays a solid color preview. More...

#include <clickable_color_preview.h>

Inheritance diagram for ClickableColorPreview:
Collaboration diagram for ClickableColorPreview:

Public Slots

void SetColor (const QColor &color)
 Sets the background color to be displayed by the preview widget. Updates the widget's palette and triggers a repaint. If the color is invalid, a transparent background is set.
 

Signals

void clicked ()
 Emitted when the widget is clicked with the left mouse button.
 

Public Member Functions

 ClickableColorPreview (QWidget *parent=nullptr)
 Constructs a ClickableColorPreview widget. Sets a fixed size, enables the pointing hand cursor, and configures background drawing.
 

Protected Member Functions

void mousePressEvent (QMouseEvent *event) override
 Overridden mouse press event handler. Emits the clicked() signal if the left mouse button is pressed.
 
void paintEvent (QPaintEvent *event) override
 Overridden paint event handler. Draws the widget's appearance. Fills the background with the color set in the palette (via SetColor) and draws a thin border around the widget.
 

Detailed Description

A small, clickable widget that displays a solid color preview.

This widget is typically used in settings panels to show a color and allow the user to click it, usually to open a color picker dialog. It displays the color set by SetColor() as its background and draws a thin border around itself. It emits a clicked() signal when pressed with the left mouse button.

Constructor & Destructor Documentation

◆ ClickableColorPreview()

ClickableColorPreview::ClickableColorPreview ( QWidget * parent = nullptr)
explicit

Constructs a ClickableColorPreview widget. Sets a fixed size, enables the pointing hand cursor, and configures background drawing.

Parameters
parentOptional parent widget.

Member Function Documentation

◆ clicked

void ClickableColorPreview::clicked ( )
signal

Emitted when the widget is clicked with the left mouse button.

Here is the caller graph for this function:

◆ mousePressEvent()

void ClickableColorPreview::mousePressEvent ( QMouseEvent * event)
overrideprotected

Overridden mouse press event handler. Emits the clicked() signal if the left mouse button is pressed.

Parameters
eventThe mouse event.
Here is the call graph for this function:

◆ paintEvent()

void ClickableColorPreview::paintEvent ( QPaintEvent * event)
overrideprotected

Overridden paint event handler. Draws the widget's appearance. Fills the background with the color set in the palette (via SetColor) and draws a thin border around the widget.

Parameters
eventThe paint event.

◆ SetColor

void ClickableColorPreview::SetColor ( const QColor & color)
slot

Sets the background color to be displayed by the preview widget. Updates the widget's palette and triggers a repaint. If the color is invalid, a transparent background is set.

Parameters
colorThe QColor to display.

The documentation for this class was generated from the following files: