2 #include "ui_musiccolordialog.h"
5 #include <QButtonGroup>
6 #include <QPainterPath>
12 setMouseTracking(
true);
13 setMinimumSize(QSize(360, 120));
24 #if TTK_QT_VERSION_CHECK(6,0,0)
25 float vh, vs, vl = -100.0f;
27 qreal vh, vs, vl = -100.0f;
53 QPainter painter(
this);
54 painter.setRenderHint(QPainter::Antialiasing,
true);
55 painter.setBrush(Qt::NoBrush);
57 const int ntRight = rect().right();
58 const int ntBottm = rect().bottom();
59 QColor colorStart, colorDatum, colorFinal;
61 for(
int it = 0; it < ntRight + 1; ++it)
67 QLinearGradient linearGradient;
68 linearGradient.setStart(QPointF(it, 0));
69 linearGradient.setFinalStop(QPointF(it, ntBottm));
70 linearGradient.setColorAt(0.0, colorStart);
71 linearGradient.setColorAt(0.5, colorDatum);
72 linearGradient.setColorAt(1.0, colorFinal);
74 painter.setPen(QPen(linearGradient, 1));
75 painter.drawLine(QPointF(it, 0), QPointF(it, ntBottm));
78 painter.setPen(QPen(Qt::black, 2));
81 painter.setPen(QPen(Qt::white, 2));
95 if(event->button() == Qt::LeftButton)
105 if(event->buttons() & Qt::LeftButton && !(
event->buttons() & Qt::RightButton))
119 if(path.contains(event->pos()))
121 QToolTip::showText(mapToGlobal(event->pos()) + QPoint(0, 5), tr(
"Adjust hue and brightness"),
this, QRect(
m_ptVernierPos - QPoint(8, 8), QSize(16, 16)));
140 m_dblVernierPercentX(0),
143 setMouseTracking(
true);
144 setMinimumWidth(360);
145 setMinimumHeight(16);
146 setMaximumHeight(24);
170 QPainter painter(
this);
171 painter.setRenderHint(QPainter::Antialiasing,
true);
172 painter.setBrush(Qt::NoBrush);
174 const int ntRight = rect().right();
175 const int ntBottm = rect().bottom();
177 #if TTK_QT_VERSION_CHECK(6,0,0)
178 float vh, vs, vl = -100.0f;
180 qreal vh, vs, vl = -100.0f;
182 m_color.getHslF(&vh, &vs, &vl);
184 QColor colorCenter, colorStart, colorFinal;
185 colorCenter.setHslF(vh, 0.5, vl);
186 colorStart.setHslF(vh, 1, vl);
187 colorFinal.setHslF(vh, 0, vl);
189 QLinearGradient linearGradient;
190 linearGradient.setStart(QPointF(0, 0));
191 linearGradient.setFinalStop(QPointF(ntRight, 0));
192 linearGradient.setColorAt(0.0, colorStart);
193 linearGradient.setColorAt(1.0, colorFinal);
195 painter.fillRect(rect(), linearGradient);
198 painter.setPen(QPen(Qt::black, 2));
199 painter.drawEllipse(ptfCenter, 5, 5);
201 painter.setPen(QPen(Qt::white, 2));
202 painter.drawEllipse(ptfCenter, 7, 7);
214 if(event->button() == Qt::LeftButton)
224 if(event->buttons() & Qt::LeftButton && !(
event->buttons() & Qt::RightButton))
227 if(rect().contains(event->pos()))
236 path.addEllipse(QPointF(
m_dblVernierX, rect().bottom() / 2.0), 7, 7);
238 if(path.contains(event->pos()))
240 QToolTip::showText(mapToGlobal(event->pos()) + QPoint(0, 5), tr(
"Adjust hue and brightness"),
this, QRect(event->pos() - QPoint(8, 8), QSize(16, 16)));
260 setFixedSize(
size());
263 m_ui->topTitleCloseButton->setIcon(QIcon(
":/functions/btn_close_hover"));
265 m_ui->topTitleCloseButton->setCursor(QCursor(Qt::PointingHandCursor));
266 m_ui->topTitleCloseButton->setToolTip(tr(
"Close"));
267 connect(
m_ui->topTitleCloseButton, SIGNAL(clicked()), SLOT(close()));
271 m_ui->confirmButton->setCursor(QCursor(Qt::PointingHandCursor));
272 m_ui->cancelButton->setCursor(QCursor(Qt::PointingHandCursor));
275 m_ui->confirmButton->setFocusPolicy(Qt::NoFocus);
276 m_ui->cancelButton->setFocusPolicy(Qt::NoFocus);
279 connect(
m_ui->wgtPalette, SIGNAL(
colorChanged(QColor)),
m_ui->wgtSaturationIndicator, SLOT(setBaseColor(QColor)));
281 connect(
m_ui->wgtSaturationIndicator, SIGNAL(saturationChanged(
double)),
m_ui->wgtPalette, SLOT(setSaturation(
double)));
283 m_ui->wgtPalette->initialize();
285 QButtonGroup *buttonGroup =
new QButtonGroup(
this);
286 buttonGroup->addButton(
m_ui->topTitleCloseButton, 0);
287 buttonGroup->addButton(
m_ui->confirmButton, 1);
288 buttonGroup->addButton(
m_ui->cancelButton, 2);
309 return dialog.
exec() ? dialog.
color() : QColor();
320 m_ui->wgtPalette->setColor(color);
321 m_ui->wgtSaturationIndicator->setSaturation(color.hslSaturationF());
329 case 2: reject();
break;
330 case 1: accept();
break;
#define TTKStaticCast(x, y)
MusicHlPalette(QWidget *parent=nullptr)
MusicHlSaturationPalette(QWidget *parent=nullptr)
virtual void mousePressEvent(QMouseEvent *event) overridefinal
void saturationChanged(double dblSaturation)
void colorChanged(const QColor &color)
Ui::MusicColorDialog * m_ui
void setSaturation(double dblsaturation)
virtual void resizeEvent(QResizeEvent *event) overridefinal
void setBaseColor(const QColor &color)
virtual void mousePressEvent(QMouseEvent *event) overridefinal
void setColor(const QColor &color)
void setColor(const QColor &color)
void buttonClicked(int index)
virtual void mouseMoveEvent(QMouseEvent *event) overridefinal
virtual void resizeEvent(QResizeEvent *event) overridefinal
static const QString PushButtonStyle04
void colorChanged(const QColor &color)
virtual void paintEvent(QPaintEvent *event) overridefinal
static QColor popup(QWidget *parent=nullptr, const QColor &color={})
The class of the moving dialog base.
double m_dblVernierPercentX
#define QtButtonGroupConnect(p, q, f, s)
Button group connect.
QPointF m_ptfVernierPercentPos
MusicColorDialog(QWidget *parent=nullptr)
static const QString ToolButtonStyle04
The class of the get color table widget.
virtual void paintEvent(QPaintEvent *event) overridefinal
void setSaturation(double dblsaturation)
double saturation() const
virtual void mouseMoveEvent(QMouseEvent *event) overridefinal