LeechCraft
0.6.70-18450-gabe19ee3b0
Modular cross-platform feature rich live environment.
Toggle main menu visibility
Loading...
Searching...
No Matches
colorbutton.cpp
Go to the documentation of this file.
1
/**********************************************************************
2
* LeechCraft - modular cross-platform feature rich internet client.
3
* Copyright (C) 2006-2014 Georg Rudoy
4
*
5
* Distributed under the Boost Software License, Version 1.0.
6
* (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7
**********************************************************************/
8
9
#include "
colorbutton.h
"
10
#include <QColorDialog>
11
12
namespace
LC::Util
13
{
14
ColorButton::ColorButton
(QWidget *parent)
15
: QPushButton { parent }
16
{
17
connect (
this
,
18
&QPushButton::released,
19
this
,
20
&ColorButton::HandleSelector);
21
22
SetColor
(Qt::black);
23
}
24
25
QColor
ColorButton::GetColor
()
const
26
{
27
return
Color_;
28
}
29
30
void
ColorButton::SetColor
(
const
QColor& color)
31
{
32
if
(Color_ == color)
33
return
;
34
35
Color_ = color;
36
emit
colorChanged
(Color_);
37
38
QPixmap px { iconSize () };
39
px.fill (Color_);
40
setIcon (px);
41
}
42
43
void
ColorButton::HandleSelector ()
44
{
45
const
auto
color = QColorDialog::getColor (Color_,
46
this
,
47
tr (
"Select color"
),
48
QColorDialog::ShowAlphaChannel);
49
if
(!color.isValid ())
50
return
;
51
52
SetColor
(color);
53
}
54
}
LC::Util::ColorButton::GetColor
QColor GetColor() const
Returns the current color represented by this button.
Definition
colorbutton.cpp:25
LC::Util::ColorButton::ColorButton
ColorButton(QWidget *parent=nullptr)
Constructs the button with the given parent.
Definition
colorbutton.cpp:14
LC::Util::ColorButton::colorChanged
void colorChanged(const QColor &color)
Emitted when the color is changed.
LC::Util::ColorButton::SetColor
void SetColor(const QColor &color)
Sets the color represented by this button.
Definition
colorbutton.cpp:30
colorbutton.h
LC::Util
Definition
icoreproxy.h:34
src
util
gui
colorbutton.cpp
Generated by
1.17.0