QColorDialog manual test improvements
Show debug output for rejected and currentColorChanged signals, because accepting is not the only scenario to be tested. Task-number: QTBUG-40855 Change-Id: If741ab19392e7d4314e0eff82a939d202ae86b48 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
This commit is contained in:
parent
9d9ef74a6c
commit
0ce707d1d5
@ -169,6 +169,8 @@ void ColorDialogPanel::execModal()
|
|||||||
QColorDialog dialog(this);
|
QColorDialog dialog(this);
|
||||||
applySettings(&dialog);
|
applySettings(&dialog);
|
||||||
connect(&dialog, SIGNAL(accepted()), this, SLOT(accepted()));
|
connect(&dialog, SIGNAL(accepted()), this, SLOT(accepted()));
|
||||||
|
connect(&dialog, SIGNAL(rejected()), this, SLOT(rejected()));
|
||||||
|
connect(&dialog, SIGNAL(currentColorChanged(const QColor&)), this, SLOT(currentColorChanged(const QColor&)));
|
||||||
dialog.setWindowTitle(tr("Modal Color Dialog Qt %1").arg(QLatin1String(QT_VERSION_STR)));
|
dialog.setWindowTitle(tr("Modal Color Dialog Qt %1").arg(QLatin1String(QT_VERSION_STR)));
|
||||||
dialog.exec();
|
dialog.exec();
|
||||||
}
|
}
|
||||||
@ -180,6 +182,8 @@ void ColorDialogPanel::showModal()
|
|||||||
m_modalDialog = new QColorDialog(this);
|
m_modalDialog = new QColorDialog(this);
|
||||||
m_modalDialog->setModal(true);
|
m_modalDialog->setModal(true);
|
||||||
connect(m_modalDialog.data(), SIGNAL(accepted()), this, SLOT(accepted()));
|
connect(m_modalDialog.data(), SIGNAL(accepted()), this, SLOT(accepted()));
|
||||||
|
connect(m_modalDialog.data(), SIGNAL(rejected()), this, SLOT(rejected()));
|
||||||
|
connect(m_modalDialog.data(), SIGNAL(currentColorChanged(const QColor&)), this, SLOT(currentColorChanged(const QColor&)));
|
||||||
m_modalDialog->setWindowTitle(tr("Modal Color Dialog #%1 Qt %2")
|
m_modalDialog->setWindowTitle(tr("Modal Color Dialog #%1 Qt %2")
|
||||||
.arg(++n)
|
.arg(++n)
|
||||||
.arg(QLatin1String(QT_VERSION_STR)));
|
.arg(QLatin1String(QT_VERSION_STR)));
|
||||||
@ -195,6 +199,8 @@ void ColorDialogPanel::showNonModal()
|
|||||||
static int n = 0;
|
static int n = 0;
|
||||||
m_nonModalDialog = new QColorDialog(this);
|
m_nonModalDialog = new QColorDialog(this);
|
||||||
connect(m_nonModalDialog.data(), SIGNAL(accepted()), this, SLOT(accepted()));
|
connect(m_nonModalDialog.data(), SIGNAL(accepted()), this, SLOT(accepted()));
|
||||||
|
connect(m_nonModalDialog.data(), SIGNAL(rejected()), this, SLOT(rejected()));
|
||||||
|
connect(m_nonModalDialog.data(), SIGNAL(currentColorChanged(const QColor&)), this, SLOT(currentColorChanged(const QColor&)));
|
||||||
m_nonModalDialog->setWindowTitle(tr("Non-Modal Color Dialog #%1 Qt %2")
|
m_nonModalDialog->setWindowTitle(tr("Non-Modal Color Dialog #%1 Qt %2")
|
||||||
.arg(++n)
|
.arg(++n)
|
||||||
.arg(QLatin1String(QT_VERSION_STR)));
|
.arg(QLatin1String(QT_VERSION_STR)));
|
||||||
@ -223,12 +229,24 @@ void ColorDialogPanel::accepted()
|
|||||||
const QColorDialog *d = qobject_cast<const QColorDialog *>(sender());
|
const QColorDialog *d = qobject_cast<const QColorDialog *>(sender());
|
||||||
Q_ASSERT(d);
|
Q_ASSERT(d);
|
||||||
m_result.clear();
|
m_result.clear();
|
||||||
|
qDebug() << "Current color: " << d->currentColor()
|
||||||
|
<< "Selected color: " << d->selectedColor();
|
||||||
QDebug(&m_result).nospace()
|
QDebug(&m_result).nospace()
|
||||||
<< "Current color: " << d->currentColor()
|
<< "Current color: " << d->currentColor()
|
||||||
<< "\nSelected color: " << d->selectedColor();
|
<< "\nSelected color: " << d->selectedColor();
|
||||||
QTimer::singleShot(0, this, SLOT(showAcceptedResult())); // Avoid problems with the closing (modal) dialog as parent.
|
QTimer::singleShot(0, this, SLOT(showAcceptedResult())); // Avoid problems with the closing (modal) dialog as parent.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ColorDialogPanel::rejected()
|
||||||
|
{
|
||||||
|
qDebug() << "rejected";
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorDialogPanel::currentColorChanged(const QColor &color)
|
||||||
|
{
|
||||||
|
qDebug() << color;
|
||||||
|
}
|
||||||
|
|
||||||
void ColorDialogPanel::showAcceptedResult()
|
void ColorDialogPanel::showAcceptedResult()
|
||||||
{
|
{
|
||||||
QMessageBox::information(this, tr("Color Dialog Accepted"), m_result, QMessageBox::Ok);
|
QMessageBox::information(this, tr("Color Dialog Accepted"), m_result, QMessageBox::Ok);
|
||||||
|
@ -64,6 +64,8 @@ public slots:
|
|||||||
void deleteNonModalDialog();
|
void deleteNonModalDialog();
|
||||||
void deleteModalDialog();
|
void deleteModalDialog();
|
||||||
void accepted();
|
void accepted();
|
||||||
|
void rejected();
|
||||||
|
void currentColorChanged(const QColor & color);
|
||||||
void showAcceptedResult();
|
void showAcceptedResult();
|
||||||
void restoreDefaults();
|
void restoreDefaults();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user