QColorDialog: Use pmf-style connects
Port all string-based signal/slots connections to pmf-style connects. Change-Id: If1075a5a8a4d018e060e7d18ee59c8fc4c0a5207 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> (cherry picked from commit 7dd4a7b2133b9a6aa4f67a3ff5760303af68ac54) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
2e9347dfce
commit
d84b6079f8
@ -104,16 +104,16 @@ public:
|
|||||||
void retranslateStrings();
|
void retranslateStrings();
|
||||||
bool supportsColorPicking() const;
|
bool supportsColorPicking() const;
|
||||||
|
|
||||||
void _q_addCustom();
|
void addCustom();
|
||||||
void _q_setCustom(int index, QRgb color);
|
void _q_setCustom(int index, QRgb color);
|
||||||
|
|
||||||
void _q_newHsv(int h, int s, int v);
|
void newHsv(int h, int s, int v);
|
||||||
void _q_newColorTypedIn(QRgb rgb);
|
void newColorTypedIn(QRgb rgb);
|
||||||
void _q_nextCustom(int, int);
|
void nextCustom(int, int);
|
||||||
void _q_newCustom(int, int);
|
void newCustom(int, int);
|
||||||
void _q_newStandard(int, int);
|
void newStandard(int, int);
|
||||||
void _q_pickScreenColor();
|
void pickScreenColor();
|
||||||
void _q_updateColorPicking();
|
void updateColorPicking();
|
||||||
void updateColorLabelText(const QPoint &);
|
void updateColorLabelText(const QPoint &);
|
||||||
void updateColorPicking(const QPoint &pos);
|
void updateColorPicking(const QPoint &pos);
|
||||||
void releaseColorPicking();
|
void releaseColorPicking();
|
||||||
@ -1491,7 +1491,7 @@ void QColorShower::updateQColor()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//sets all widgets to display h,s,v
|
//sets all widgets to display h,s,v
|
||||||
void QColorDialogPrivate::_q_newHsv(int h, int s, int v)
|
void QColorDialogPrivate::newHsv(int h, int s, int v)
|
||||||
{
|
{
|
||||||
if (!nativeDialogInUse) {
|
if (!nativeDialogInUse) {
|
||||||
cs->setHsv(h, s, v);
|
cs->setHsv(h, s, v);
|
||||||
@ -1505,7 +1505,7 @@ void QColorDialogPrivate::setCurrentRgbColor(QRgb rgb)
|
|||||||
{
|
{
|
||||||
if (!nativeDialogInUse) {
|
if (!nativeDialogInUse) {
|
||||||
cs->setRgb(rgb);
|
cs->setRgb(rgb);
|
||||||
_q_newColorTypedIn(rgb);
|
newColorTypedIn(rgb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1538,7 +1538,7 @@ bool QColorDialogPrivate::selectColor(const QColor &col)
|
|||||||
const int index = int(match - standardColors);
|
const int index = int(match - standardColors);
|
||||||
const int column = index / standardColorRows;
|
const int column = index / standardColorRows;
|
||||||
const int row = index % standardColorRows;
|
const int row = index % standardColorRows;
|
||||||
_q_newStandard(row, column);
|
newStandard(row, column);
|
||||||
standard->setCurrent(row, column);
|
standard->setCurrent(row, column);
|
||||||
standard->setSelected(row, column);
|
standard->setSelected(row, column);
|
||||||
standard->setFocus();
|
standard->setFocus();
|
||||||
@ -1554,7 +1554,7 @@ bool QColorDialogPrivate::selectColor(const QColor &col)
|
|||||||
const int index = int(match - customColors);
|
const int index = int(match - customColors);
|
||||||
const int column = index / customColorRows;
|
const int column = index / customColorRows;
|
||||||
const int row = index % customColorRows;
|
const int row = index % customColorRows;
|
||||||
_q_newCustom(row, column);
|
newCustom(row, column);
|
||||||
custom->setCurrent(row, column);
|
custom->setCurrent(row, column);
|
||||||
custom->setSelected(row, column);
|
custom->setSelected(row, column);
|
||||||
custom->setFocus();
|
custom->setFocus();
|
||||||
@ -1577,7 +1577,7 @@ QColor QColorDialogPrivate::grabScreenColor(const QPoint &p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//sets all widgets except cs to display rgb
|
//sets all widgets except cs to display rgb
|
||||||
void QColorDialogPrivate::_q_newColorTypedIn(QRgb rgb)
|
void QColorDialogPrivate::newColorTypedIn(QRgb rgb)
|
||||||
{
|
{
|
||||||
if (!nativeDialogInUse) {
|
if (!nativeDialogInUse) {
|
||||||
int h, s, v;
|
int h, s, v;
|
||||||
@ -1587,12 +1587,12 @@ void QColorDialogPrivate::_q_newColorTypedIn(QRgb rgb)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QColorDialogPrivate::_q_nextCustom(int r, int c)
|
void QColorDialogPrivate::nextCustom(int r, int c)
|
||||||
{
|
{
|
||||||
nextCust = r + customColorRows * c;
|
nextCust = r + customColorRows * c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QColorDialogPrivate::_q_newCustom(int r, int c)
|
void QColorDialogPrivate::newCustom(int r, int c)
|
||||||
{
|
{
|
||||||
const int i = r + customColorRows * c;
|
const int i = r + customColorRows * c;
|
||||||
setCurrentRgbColor(QColorDialogOptions::customColor(i));
|
setCurrentRgbColor(QColorDialogOptions::customColor(i));
|
||||||
@ -1600,14 +1600,14 @@ void QColorDialogPrivate::_q_newCustom(int r, int c)
|
|||||||
standard->setSelected(-1,-1);
|
standard->setSelected(-1,-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QColorDialogPrivate::_q_newStandard(int r, int c)
|
void QColorDialogPrivate::newStandard(int r, int c)
|
||||||
{
|
{
|
||||||
setCurrentRgbColor(QColorDialogOptions::standardColor(r + c * 6));
|
setCurrentRgbColor(QColorDialogOptions::standardColor(r + c * 6));
|
||||||
if (custom)
|
if (custom)
|
||||||
custom->setSelected(-1,-1);
|
custom->setSelected(-1,-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QColorDialogPrivate::_q_pickScreenColor()
|
void QColorDialogPrivate::pickScreenColor()
|
||||||
{
|
{
|
||||||
Q_Q(QColorDialog);
|
Q_Q(QColorDialog);
|
||||||
|
|
||||||
@ -1740,7 +1740,8 @@ void QColorDialogPrivate::initWidgets()
|
|||||||
#ifndef QT_NO_SHORTCUT
|
#ifndef QT_NO_SHORTCUT
|
||||||
lblBasicColors->setBuddy(standard);
|
lblBasicColors->setBuddy(standard);
|
||||||
#endif
|
#endif
|
||||||
q->connect(standard, SIGNAL(selected(int,int)), SLOT(_q_newStandard(int,int)));
|
QObjectPrivate::connect(standard, &QColorWell::selected,
|
||||||
|
this, &QColorDialogPrivate::newStandard);
|
||||||
leftLay->addWidget(lblBasicColors);
|
leftLay->addWidget(lblBasicColors);
|
||||||
leftLay->addWidget(standard);
|
leftLay->addWidget(standard);
|
||||||
|
|
||||||
@ -1750,7 +1751,8 @@ void QColorDialogPrivate::initWidgets()
|
|||||||
leftLay->addWidget(eyeDropperButton);
|
leftLay->addWidget(eyeDropperButton);
|
||||||
lblScreenColorInfo = new QLabel("\n"_L1);
|
lblScreenColorInfo = new QLabel("\n"_L1);
|
||||||
leftLay->addWidget(lblScreenColorInfo);
|
leftLay->addWidget(lblScreenColorInfo);
|
||||||
q->connect(eyeDropperButton, SIGNAL(clicked()), SLOT(_q_pickScreenColor()));
|
QObjectPrivate::connect(eyeDropperButton, &QPushButton::clicked,
|
||||||
|
this, &QColorDialogPrivate::pickScreenColor);
|
||||||
} else {
|
} else {
|
||||||
eyeDropperButton = nullptr;
|
eyeDropperButton = nullptr;
|
||||||
lblScreenColorInfo = nullptr;
|
lblScreenColorInfo = nullptr;
|
||||||
@ -1762,10 +1764,10 @@ void QColorDialogPrivate::initWidgets()
|
|||||||
custom = new QColorWell(q, customColorRows, colorColumns, QColorDialogOptions::customColors());
|
custom = new QColorWell(q, customColorRows, colorColumns, QColorDialogOptions::customColors());
|
||||||
custom->setAcceptDrops(true);
|
custom->setAcceptDrops(true);
|
||||||
|
|
||||||
q->connect(custom, SIGNAL(selected(int,int)), SLOT(_q_newCustom(int,int)));
|
QObjectPrivate::connect(custom, &QColorWell::selected, this, &QColorDialogPrivate::newCustom);
|
||||||
q->connect(custom, SIGNAL(currentChanged(int,int)), SLOT(_q_nextCustom(int,int)));
|
QObjectPrivate::connect(custom, &QColorWell::currentChanged, this, &QColorDialogPrivate::nextCustom);
|
||||||
|
|
||||||
q->connect(custom, &QWellArray::colorChanged, q, [this] (int index, QRgb color) {
|
QObject::connect(custom, &QWellArray::colorChanged, q, [this] (int index, QRgb color) {
|
||||||
QColorDialogOptions::setCustomColor(index, color);
|
QColorDialogOptions::setCustomColor(index, color);
|
||||||
if (custom)
|
if (custom)
|
||||||
custom->update();
|
custom->update();
|
||||||
@ -1779,7 +1781,7 @@ void QColorDialogPrivate::initWidgets()
|
|||||||
leftLay->addWidget(custom);
|
leftLay->addWidget(custom);
|
||||||
|
|
||||||
addCusBt = new QPushButton(q);
|
addCusBt = new QPushButton(q);
|
||||||
QObject::connect(addCusBt, SIGNAL(clicked()), q, SLOT(_q_addCustom()));
|
QObjectPrivate::connect(addCusBt, &QPushButton::clicked, this, &QColorDialogPrivate::addCustom);
|
||||||
leftLay->addWidget(addCusBt);
|
leftLay->addWidget(addCusBt);
|
||||||
} else {
|
} else {
|
||||||
// better color picker size for small displays
|
// better color picker size for small displays
|
||||||
@ -1827,16 +1829,17 @@ void QColorDialogPrivate::initWidgets()
|
|||||||
pickLay->addStretch();
|
pickLay->addStretch();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QObject::connect(cp, SIGNAL(newCol(int,int)), lp, SLOT(setCol(int,int)));
|
QObject::connect(cp, &QColorPicker::newCol, lp, qOverload<int, int>(&QColorLuminancePicker::setCol));
|
||||||
QObject::connect(lp, SIGNAL(newHsv(int,int,int)), q, SLOT(_q_newHsv(int,int,int)));
|
QObjectPrivate::connect(lp, &QColorLuminancePicker::newHsv, this, &QColorDialogPrivate::newHsv);
|
||||||
|
|
||||||
rightLay->addStretch();
|
rightLay->addStretch();
|
||||||
|
|
||||||
cs = new QColorShower(q);
|
cs = new QColorShower(q);
|
||||||
pickLay->setContentsMargins(cs->gl->contentsMargins());
|
pickLay->setContentsMargins(cs->gl->contentsMargins());
|
||||||
QObject::connect(cs, SIGNAL(newCol(QRgb)), q, SLOT(_q_newColorTypedIn(QRgb)));
|
QObjectPrivate::connect(cs, &QColorShower::newCol,
|
||||||
QObject::connect(cs, SIGNAL(currentColorChanged(QColor)),
|
this, &QColorDialogPrivate::newColorTypedIn);
|
||||||
q, SIGNAL(currentColorChanged(QColor)));
|
QObject::connect(cs, &QColorShower::currentColorChanged,
|
||||||
|
q, &QColorDialog::currentColorChanged);
|
||||||
#if defined(QT_SMALL_COLORDIALOG)
|
#if defined(QT_SMALL_COLORDIALOG)
|
||||||
topLay->addWidget(cs);
|
topLay->addWidget(cs);
|
||||||
#else
|
#else
|
||||||
@ -1849,14 +1852,15 @@ void QColorDialogPrivate::initWidgets()
|
|||||||
mainLay->addWidget(buttons);
|
mainLay->addWidget(buttons);
|
||||||
|
|
||||||
ok = buttons->addButton(QDialogButtonBox::Ok);
|
ok = buttons->addButton(QDialogButtonBox::Ok);
|
||||||
QObject::connect(ok, SIGNAL(clicked()), q, SLOT(accept()));
|
QObject::connect(ok, &QPushButton::clicked, q, &QColorDialog::accept);
|
||||||
ok->setDefault(true);
|
ok->setDefault(true);
|
||||||
cancel = buttons->addButton(QDialogButtonBox::Cancel);
|
cancel = buttons->addButton(QDialogButtonBox::Cancel);
|
||||||
QObject::connect(cancel, SIGNAL(clicked()), q, SLOT(reject()));
|
QObject::connect(cancel, &QPushButton::clicked, q, &QColorDialog::reject);
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
updateTimer = new QTimer(q);
|
updateTimer = new QTimer(q);
|
||||||
QObject::connect(updateTimer, SIGNAL(timeout()), q, SLOT(_q_updateColorPicking()));
|
QObjectPrivate::connect(updateTimer, &QTimer::timeout,
|
||||||
|
this, qOverload<>(&QColorDialogPrivate::updateColorPicking));
|
||||||
#endif
|
#endif
|
||||||
retranslateStrings();
|
retranslateStrings();
|
||||||
}
|
}
|
||||||
@ -1864,9 +1868,12 @@ void QColorDialogPrivate::initWidgets()
|
|||||||
void QColorDialogPrivate::initHelper(QPlatformDialogHelper *h)
|
void QColorDialogPrivate::initHelper(QPlatformDialogHelper *h)
|
||||||
{
|
{
|
||||||
QColorDialog *d = q_func();
|
QColorDialog *d = q_func();
|
||||||
QObject::connect(h, SIGNAL(currentColorChanged(QColor)), d, SIGNAL(currentColorChanged(QColor)));
|
auto *colorDialogHelper = static_cast<QPlatformColorDialogHelper*>(h);
|
||||||
QObject::connect(h, SIGNAL(colorSelected(QColor)), d, SIGNAL(colorSelected(QColor)));
|
QObject::connect(colorDialogHelper, &QPlatformColorDialogHelper::currentColorChanged,
|
||||||
static_cast<QPlatformColorDialogHelper *>(h)->setOptions(options);
|
d, &QColorDialog::currentColorChanged);
|
||||||
|
QObject::connect(colorDialogHelper, &QPlatformColorDialogHelper::colorSelected,
|
||||||
|
d, &QColorDialog::colorSelected);
|
||||||
|
colorDialogHelper->setOptions(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QColorDialogPrivate::helperPrepareShow(QPlatformDialogHelper *)
|
void QColorDialogPrivate::helperPrepareShow(QPlatformDialogHelper *)
|
||||||
@ -1874,7 +1881,7 @@ void QColorDialogPrivate::helperPrepareShow(QPlatformDialogHelper *)
|
|||||||
options->setWindowTitle(q_func()->windowTitle());
|
options->setWindowTitle(q_func()->windowTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
void QColorDialogPrivate::_q_addCustom()
|
void QColorDialogPrivate::addCustom()
|
||||||
{
|
{
|
||||||
QColorDialogOptions::setCustomColor(nextCust, cs->currentColor());
|
QColorDialogOptions::setCustomColor(nextCust, cs->currentColor());
|
||||||
if (custom)
|
if (custom)
|
||||||
@ -2232,7 +2239,7 @@ void QColorDialog::changeEvent(QEvent *e)
|
|||||||
QDialog::changeEvent(e);
|
QDialog::changeEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QColorDialogPrivate::_q_updateColorPicking()
|
void QColorDialogPrivate::updateColorPicking()
|
||||||
{
|
{
|
||||||
#ifndef QT_NO_CURSOR
|
#ifndef QT_NO_CURSOR
|
||||||
Q_Q(QColorDialog);
|
Q_Q(QColorDialog);
|
||||||
|
@ -73,15 +73,6 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(QColorDialog)
|
Q_DISABLE_COPY(QColorDialog)
|
||||||
|
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_addCustom())
|
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_newHsv(int h, int s, int v))
|
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_newColorTypedIn(QRgb rgb))
|
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_nextCustom(int, int))
|
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_newCustom(int, int))
|
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_newStandard(int, int))
|
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_pickScreenColor())
|
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_updateColorPicking())
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(QColorDialog::ColorDialogOptions)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(QColorDialog::ColorDialogOptions)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user