diff options
40 files changed, 306 insertions, 210 deletions
diff --git a/examples/widgets/widgets/analogclock/analogclock.cpp b/examples/widgets/widgets/analogclock/analogclock.cpp index 0dc2fbc708..bee316b9b7 100644 --- a/examples/widgets/widgets/analogclock/analogclock.cpp +++ b/examples/widgets/widgets/analogclock/analogclock.cpp @@ -61,7 +61,7 @@ AnalogClock::AnalogClock(QWidget *parent) //! [3] //! [4] QTimer *timer = new QTimer(this); //! [4] //! [5] - connect(timer, SIGNAL(timeout()), this, SLOT(update())); + connect(timer, &QTimer::timeout, this, QOverload<>::of(&AnalogClock::update)); //! [5] //! [6] timer->start(1000); //! [6] diff --git a/examples/widgets/widgets/calendarwidget/window.cpp b/examples/widgets/widgets/calendarwidget/window.cpp index a1c1746786..64047aaac9 100644 --- a/examples/widgets/widgets/calendarwidget/window.cpp +++ b/examples/widgets/widgets/calendarwidget/window.cpp @@ -221,8 +221,8 @@ void Window::createPreviewGroupBox() calendar->setMaximumDate(QDate(3000, 1, 1)); calendar->setGridVisible(true); - connect(calendar, SIGNAL(currentPageChanged(int,int)), - this, SLOT(reformatCalendarPage())); + connect(calendar, &QCalendarWidget::currentPageChanged, + this, &Window::reformatCalendarPage); previewLayout = new QGridLayout; previewLayout->addWidget(calendar, 0, 0, Qt::AlignCenter); @@ -306,20 +306,20 @@ void Window::createGeneralOptionsGroupBox() verticalHeaderLabel->setBuddy(verticalHeaderCombo); //! [11] - connect(localeCombo, SIGNAL(currentIndexChanged(int)), - this, SLOT(localeChanged(int))); - connect(firstDayCombo, SIGNAL(currentIndexChanged(int)), - this, SLOT(firstDayChanged(int))); - connect(selectionModeCombo, SIGNAL(currentIndexChanged(int)), - this, SLOT(selectionModeChanged(int))); - connect(gridCheckBox, SIGNAL(toggled(bool)), - calendar, SLOT(setGridVisible(bool))); - connect(navigationCheckBox, SIGNAL(toggled(bool)), - calendar, SLOT(setNavigationBarVisible(bool))); - connect(horizontalHeaderCombo, SIGNAL(currentIndexChanged(int)), - this, SLOT(horizontalHeaderChanged(int))); - connect(verticalHeaderCombo, SIGNAL(currentIndexChanged(int)), - this, SLOT(verticalHeaderChanged(int))); + connect(localeCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), + this, &Window::localeChanged); + connect(firstDayCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), + this, &Window::firstDayChanged); + connect(selectionModeCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), + this, &Window::selectionModeChanged); + connect(gridCheckBox, &QCheckBox::toggled, + calendar, &QCalendarWidget::setGridVisible); + connect(navigationCheckBox, &QCheckBox::toggled, + calendar, &QCalendarWidget::setNavigationBarVisible); + connect(horizontalHeaderCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), + this, &Window::horizontalHeaderChanged); + connect(verticalHeaderCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), + this, &Window::verticalHeaderChanged); //! [11] QHBoxLayout *checkBoxLayout = new QHBoxLayout; @@ -382,14 +382,14 @@ void Window::createDatesGroupBox() maximumDateLabel->setBuddy(maximumDateEdit); //! [13] //! [14] - connect(currentDateEdit, SIGNAL(dateChanged(QDate)), - calendar, SLOT(setSelectedDate(QDate))); - connect(calendar, SIGNAL(selectionChanged()), - this, SLOT(selectedDateChanged())); - connect(minimumDateEdit, SIGNAL(dateChanged(QDate)), - this, SLOT(minimumDateChanged(QDate))); - connect(maximumDateEdit, SIGNAL(dateChanged(QDate)), - this, SLOT(maximumDateChanged(QDate))); + connect(currentDateEdit, &QDateEdit::dateChanged, + calendar, &QCalendarWidget::setSelectedDate); + connect(calendar, &QCalendarWidget::selectionChanged, + this, &Window::selectedDateChanged); + connect(minimumDateEdit, &QDateEdit::dateChanged, + this, &Window::minimumDateChanged); + connect(maximumDateEdit, &QDateEdit::dateChanged, + this, &Window::maximumDateChanged); //! [14] QGridLayout *dateBoxLayout = new QGridLayout; @@ -439,20 +439,20 @@ void Window::createTextFormatsGroupBox() mayFirstCheckBox = new QCheckBox(tr("May &1 in red")); //! [17] //! [18] - connect(weekdayColorCombo, SIGNAL(currentIndexChanged(int)), - this, SLOT(weekdayFormatChanged())); - connect(weekdayColorCombo, SIGNAL(currentIndexChanged(int)), - this, SLOT(reformatCalendarPage())); - connect(weekendColorCombo, SIGNAL(currentIndexChanged(int)), - this, SLOT(weekendFormatChanged())); - connect(weekendColorCombo, SIGNAL(currentIndexChanged(int)), - this, SLOT(reformatCalendarPage())); - connect(headerTextFormatCombo, SIGNAL(currentIndexChanged(QString)), - this, SLOT(reformatHeaders())); - connect(firstFridayCheckBox, SIGNAL(toggled(bool)), - this, SLOT(reformatCalendarPage())); - connect(mayFirstCheckBox, SIGNAL(toggled(bool)), - this, SLOT(reformatCalendarPage())); + connect(weekdayColorCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), + this, &Window::weekdayFormatChanged); + connect(weekdayColorCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), + this, &Window::reformatCalendarPage); + connect(weekendColorCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), + this, &Window::weekendFormatChanged); + connect(weekendColorCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), + this, &Window::reformatCalendarPage); + connect(headerTextFormatCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), + this, &Window::reformatHeaders); + connect(firstFridayCheckBox, &QCheckBox::toggled, + this, &Window::reformatCalendarPage); + connect(mayFirstCheckBox, &QCheckBox::toggled, + this, &Window::reformatCalendarPage); //! [18] QHBoxLayout *checkBoxLayout = new QHBoxLayout; diff --git a/examples/widgets/widgets/codeeditor/codeeditor.cpp b/examples/widgets/widgets/codeeditor/codeeditor.cpp index 7e56a75294..8e29860669 100644 --- a/examples/widgets/widgets/codeeditor/codeeditor.cpp +++ b/examples/widgets/widgets/codeeditor/codeeditor.cpp @@ -58,9 +58,9 @@ CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent) { lineNumberArea = new LineNumberArea(this); - connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int))); - connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int))); - connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine())); + connect(this, &CodeEditor::blockCountChanged, this, &CodeEditor::updateLineNumberAreaWidth); + connect(this, &CodeEditor::updateRequest, this, &CodeEditor::updateLineNumberArea); + connect(this, &CodeEditor::cursorPositionChanged, this, &CodeEditor::highlightCurrentLine); updateLineNumberAreaWidth(0); highlightCurrentLine(); diff --git a/examples/widgets/widgets/lineedits/window.cpp b/examples/widgets/widgets/lineedits/window.cpp index 0926f6f20b..33f09d544d 100644 --- a/examples/widgets/widgets/lineedits/window.cpp +++ b/examples/widgets/widgets/lineedits/window.cpp @@ -123,16 +123,16 @@ Window::Window(QWidget *parent) //! [4] //! [5] - connect(echoComboBox, SIGNAL(activated(int)), - this, SLOT(echoChanged(int))); - connect(validatorComboBox, SIGNAL(activated(int)), - this, SLOT(validatorChanged(int))); - connect(alignmentComboBox, SIGNAL(activated(int)), - this, SLOT(alignmentChanged(int))); - connect(inputMaskComboBox, SIGNAL(activated(int)), - this, SLOT(inputMaskChanged(int))); - connect(accessComboBox, SIGNAL(activated(int)), - this, SLOT(accessChanged(int))); + connect(echoComboBox, QOverload<int>::of(&QComboBox::activated), + this, &Window::echoChanged); + connect(validatorComboBox, QOverload<int>::of(&QComboBox::activated), + this, &Window::validatorChanged); + connect(alignmentComboBox, QOverload<int>::of(&QComboBox::activated), + this, &Window::alignmentChanged); + connect(inputMaskComboBox, QOverload<int>::of(&QComboBox::activated), + this, &Window::inputMaskChanged); + connect(accessComboBox, QOverload<int>::of(&QComboBox::activated), + this, &Window::accessChanged); //! [5] //! [6] diff --git a/examples/widgets/widgets/mousebuttons/main.cpp b/examples/widgets/widgets/mousebuttons/main.cpp index 28be0ffddf..e35a442181 100644 --- a/examples/widgets/widgets/mousebuttons/main.cpp +++ b/examples/widgets/widgets/mousebuttons/main.cpp @@ -68,7 +68,7 @@ int main(int argv, char **args) testArea->setText("To test your mouse with Qt, press buttons in this area.\nYou may also scroll or tilt your mouse wheel."); QPushButton *quitButton = new QPushButton("Quit"); - QObject::connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit())); + QObject::connect(quitButton, &QPushButton::clicked, qApp, &QCoreApplication::quit); QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(testArea); diff --git a/examples/widgets/widgets/movie/movieplayer.cpp b/examples/widgets/widgets/movie/movieplayer.cpp index 61e85537a3..3003bfb541 100644 --- a/examples/widgets/widgets/movie/movieplayer.cpp +++ b/examples/widgets/widgets/movie/movieplayer.cpp @@ -69,13 +69,12 @@ MoviePlayer::MoviePlayer(QWidget *parent) createControls(); createButtons(); - connect(movie, SIGNAL(frameChanged(int)), this, SLOT(updateFrameSlider())); - connect(movie, SIGNAL(stateChanged(QMovie::MovieState)), - this, SLOT(updateButtons())); - connect(fitCheckBox, SIGNAL(clicked()), this, SLOT(fitToWindow())); - connect(frameSlider, SIGNAL(valueChanged(int)), this, SLOT(goToFrame(int))); - connect(speedSpinBox, SIGNAL(valueChanged(int)), - movie, SLOT(setSpeed(int))); + connect(movie, &QMovie::frameChanged, this, &MoviePlayer::updateFrameSlider); + connect(movie, &QMovie::stateChanged, this, &MoviePlayer::updateButtons); + connect(fitCheckBox, &QCheckBox::clicked, this, &MoviePlayer::fitToWindow); + connect(frameSlider, &QSlider::valueChanged, this, &MoviePlayer::goToFrame); + connect(speedSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), + movie, &QMovie::setSpeed); mainLayout = new QVBoxLayout; mainLayout->addWidget(movieLabel); @@ -182,32 +181,32 @@ void MoviePlayer::createButtons() openButton->setIcon(style()->standardIcon(QStyle::SP_DialogOpenButton)); openButton->setIconSize(iconSize); openButton->setToolTip(tr("Open File")); - connect(openButton, SIGNAL(clicked()), this, SLOT(open())); + connect(openButton, &QToolButton::clicked, this, &MoviePlayer::open); playButton = new QToolButton; playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); playButton->setIconSize(iconSize); playButton->setToolTip(tr("Play")); - connect(playButton, SIGNAL(clicked()), movie, SLOT(start())); + connect(playButton, &QToolButton::clicked, movie, &QMovie::start); pauseButton = new QToolButton; pauseButton->setCheckable(true); pauseButton->setIcon(style()->standardIcon(QStyle::SP_MediaPause)); pauseButton->setIconSize(iconSize); pauseButton->setToolTip(tr("Pause")); - connect(pauseButton, SIGNAL(clicked(bool)), movie, SLOT(setPaused(bool))); + connect(pauseButton, &QToolButton::clicked, movie, &QMovie::setPaused); stopButton = new QToolButton; stopButton->setIcon(style()->standardIcon(QStyle::SP_MediaStop)); stopButton->setIconSize(iconSize); stopButton->setToolTip(tr("Stop")); - connect(stopButton, SIGNAL(clicked()), movie, SLOT(stop())); + connect(stopButton, &QToolButton::clicked, movie, &QMovie::stop); quitButton = new QToolButton; quitButton->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton)); quitButton->setIconSize(iconSize); quitButton->setToolTip(tr("Quit")); - connect(quitButton, SIGNAL(clicked()), this, SLOT(close())); + connect(quitButton, &QToolButton::clicked, this, &MoviePlayer::close); buttonsLayout = new QHBoxLayout; buttonsLayout->addStretch(); diff --git a/examples/widgets/widgets/scribble/mainwindow.cpp b/examples/widgets/widgets/scribble/mainwindow.cpp index b8d01d505c..58dc42c076 100644 --- a/examples/widgets/widgets/scribble/mainwindow.cpp +++ b/examples/widgets/widgets/scribble/mainwindow.cpp @@ -151,40 +151,40 @@ void MainWindow::createActions() { openAct = new QAction(tr("&Open..."), this); openAct->setShortcuts(QKeySequence::Open); - connect(openAct, SIGNAL(triggered()), this, SLOT(open())); + connect(openAct, &QAction::triggered, this, &MainWindow::open); foreach (QByteArray format, QImageWriter::supportedImageFormats()) { QString text = tr("%1...").arg(QString(format).toUpper()); QAction *action = new QAction(text, this); action->setData(format); - connect(action, SIGNAL(triggered()), this, SLOT(save())); + connect(action, &QAction::triggered, this, &MainWindow::save); saveAsActs.append(action); } printAct = new QAction(tr("&Print..."), this); - connect(printAct, SIGNAL(triggered()), scribbleArea, SLOT(print())); + connect(printAct, &QAction::triggered, scribbleArea, &ScribbleArea::print); exitAct = new QAction(tr("E&xit"), this); exitAct->setShortcuts(QKeySequence::Quit); - connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); + connect(exitAct, &QAction::triggered, this, &MainWindow::close); penColorAct = new QAction(tr("&Pen Color..."), this); - connect(penColorAct, SIGNAL(triggered()), this, SLOT(penColor())); + connect(penColorAct, &QAction::triggered, this, &MainWindow::penColor); penWidthAct = new QAction(tr("Pen &Width..."), this); - connect(penWidthAct, SIGNAL(triggered()), this, SLOT(penWidth())); + connect(penWidthAct, &QAction::triggered, this, &MainWindow::penWidth); clearScreenAct = new QAction(tr("&Clear Screen"), this); clearScreenAct->setShortcut(tr("Ctrl+L")); - connect(clearScreenAct, SIGNAL(triggered()), - scribbleArea, SLOT(clearImage())); + connect(clearScreenAct, &QAction::triggered, + scribbleArea, &ScribbleArea::clearImage); aboutAct = new QAction(tr("&About"), this); - connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); + connect(aboutAct, &QAction::triggered, this, &MainWindow::about); aboutQtAct = new QAction(tr("About &Qt"), this); - connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt())); + connect(aboutQtAct, &QAction::triggered, qApp, &QApplication::aboutQt); } //! [14] diff --git a/examples/widgets/widgets/shapedclock/shapedclock.cpp b/examples/widgets/widgets/shapedclock/shapedclock.cpp index af0cd01be5..8e7d831938 100644 --- a/examples/widgets/widgets/shapedclock/shapedclock.cpp +++ b/examples/widgets/widgets/shapedclock/shapedclock.cpp @@ -57,12 +57,12 @@ ShapedClock::ShapedClock(QWidget *parent) : QWidget(parent, Qt::FramelessWindowHint | Qt::WindowSystemMenuHint) { QTimer *timer = new QTimer(this); - connect(timer, SIGNAL(timeout()), this, SLOT(update())); + connect(timer, &QTimer::timeout, this, QOverload<>::of(&ShapedClock::update)); timer->start(1000); QAction *quitAction = new QAction(tr("E&xit"), this); quitAction->setShortcut(tr("Ctrl+Q")); - connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); + connect(quitAction, &QAction::triggered, qApp, &QCoreApplication::quit); addAction(quitAction); setContextMenuPolicy(Qt::ActionsContextMenu); diff --git a/examples/widgets/widgets/sliders/slidersgroup.cpp b/examples/widgets/widgets/sliders/slidersgroup.cpp index 365a003047..3bccdd687a 100644 --- a/examples/widgets/widgets/sliders/slidersgroup.cpp +++ b/examples/widgets/widgets/sliders/slidersgroup.cpp @@ -69,11 +69,11 @@ SlidersGroup::SlidersGroup(Qt::Orientation orientation, const QString &title, dial = new QDial; dial->setFocusPolicy(Qt::StrongFocus); - connect(slider, SIGNAL(valueChanged(int)), scrollBar, SLOT(setValue(int))); - connect(scrollBar, SIGNAL(valueChanged(int)), dial, SLOT(setValue(int))); - connect(dial, SIGNAL(valueChanged(int)), slider, SLOT(setValue(int))); + connect(slider, &QSlider::valueChanged, scrollBar, &QScrollBar::setValue); + connect(scrollBar, &QScrollBar::valueChanged, dial, &QDial::setValue); + connect(dial, &QDial::valueChanged, slider, &QSlider::setValue); //! [0] //! [1] - connect(dial, SIGNAL(valueChanged(int)), this, SIGNAL(valueChanged(int))); + connect(dial, &QDial::valueChanged, this, &SlidersGroup::valueChanged); //! [1] //! [2] //! [2] //! [3] diff --git a/examples/widgets/widgets/sliders/window.cpp b/examples/widgets/widgets/sliders/window.cpp index 16467e71be..d73fafec10 100644 --- a/examples/widgets/widgets/sliders/window.cpp +++ b/examples/widgets/widgets/sliders/window.cpp @@ -68,13 +68,13 @@ Window::Window(QWidget *parent) //! [0] //! [1] - connect(horizontalSliders, SIGNAL(valueChanged(int)), + connect(horizontalSliders, &SlidersGroup::valueChanged, //! [1] //! [2] - verticalSliders, SLOT(setValue(int))); - connect(verticalSliders, SIGNAL(valueChanged(int)), - valueSpinBox, SLOT(setValue(int))); - connect(valueSpinBox, SIGNAL(valueChanged(int)), - horizontalSliders, SLOT(setValue(int))); + verticalSliders, &SlidersGroup::setValue); + connect(verticalSliders, &SlidersGroup::valueChanged, + valueSpinBox, &QSpinBox::setValue); + connect(valueSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), + horizontalSliders, &SlidersGroup::setValue); QHBoxLayout *layout = new QHBoxLayout; layout->addWidget(controlsGroup); @@ -121,25 +121,25 @@ void Window::createControls(const QString &title) orientationCombo->addItem(tr("Vertical slider-like widgets")); //! [6] //! [7] - connect(orientationCombo, SIGNAL(activated(int)), + connect(orientationCombo, QOverload<int>::of(&QComboBox::activated), //! [7] //! [8] - stackedWidget, SLOT(setCurrentIndex(int))); - connect(minimumSpinBox, SIGNAL(valueChanged(int)), - horizontalSliders, SLOT(setMinimum(int))); - connect(minimumSpinBox, SIGNAL(valueChanged(int)), - verticalSliders, SLOT(setMinimum(int))); - connect(maximumSpinBox, SIGNAL(valueChanged(int)), - horizontalSliders, SLOT(setMaximum(int))); - connect(maximumSpinBox, SIGNAL(valueChanged(int)), - verticalSliders, SLOT(setMaximum(int))); - connect(invertedAppearance, SIGNAL(toggled(bool)), - horizontalSliders, SLOT(invertAppearance(bool))); - connect(invertedAppearance, SIGNAL(toggled(bool)), - verticalSliders, SLOT(invertAppearance(bool))); - connect(invertedKeyBindings, SIGNAL(toggled(bool)), - horizontalSliders, SLOT(invertKeyBindings(bool))); - connect(invertedKeyBindings, SIGNAL(toggled(bool)), - verticalSliders, SLOT(invertKeyBindings(bool))); + stackedWidget, &QStackedWidget::setCurrentIndex); + connect(minimumSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), + horizontalSliders, &SlidersGroup::setMinimum); + connect(minimumSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), + verticalSliders, &SlidersGroup::setMinimum); + connect(maximumSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), + horizontalSliders, &SlidersGroup::setMaximum); + connect(maximumSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), + verticalSliders, &SlidersGroup::setMaximum); + connect(invertedAppearance, &QCheckBox::toggled, + horizontalSliders, &SlidersGroup::invertAppearance); + connect(invertedAppearance, &QCheckBox::toggled, + verticalSliders, &SlidersGroup::invertAppearance); + connect(invertedKeyBindings, &QCheckBox::toggled, + horizontalSliders, &SlidersGroup::invertKeyBindings); + connect(invertedKeyBindings, &QCheckBox::toggled, + verticalSliders, &SlidersGroup::invertKeyBindings); QGridLayout *controlsLayout = new QGridLayout; controlsLayout->addWidget(minimumLabel, 0, 0); diff --git a/examples/widgets/widgets/spinboxes/window.cpp b/examples/widgets/widgets/spinboxes/window.cpp index eb660faace..fd7c5b527e 100644 --- a/examples/widgets/widgets/spinboxes/window.cpp +++ b/examples/widgets/widgets/spinboxes/window.cpp @@ -176,8 +176,8 @@ void Window::createDateTimeEdits() formatComboBox->addItem("hh:mm ap"); //! [9] //! [10] - connect(formatComboBox, SIGNAL(activated(QString)), - this, SLOT(setFormatString(QString))); + connect(formatComboBox, QOverload<const QString &>::of(&QComboBox::activated), + this, &Window::setFormatString); //! [10] setFormatString(formatComboBox->currentText()); @@ -256,9 +256,9 @@ void Window::createDoubleSpinBoxes() priceSpinBox->setPrefix("$"); priceSpinBox->setValue(99.99); - connect(precisionSpinBox, SIGNAL(valueChanged(int)), + connect(precisionSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), //! [17] - this, SLOT(changePrecision(int))); + this, &Window::changePrecision); groupSeparatorSpinBox_d = new QDoubleSpinBox; groupSeparatorSpinBox_d->setRange(-99999999, 99999999); diff --git a/examples/widgets/widgets/styles/widgetgallery.cpp b/examples/widgets/widgets/styles/widgetgallery.cpp index d44547d905..dbe82c547b 100644 --- a/examples/widgets/widgets/styles/widgetgallery.cpp +++ b/examples/widgets/widgets/styles/widgetgallery.cpp @@ -79,19 +79,19 @@ WidgetGallery::WidgetGallery(QWidget *parent) //! [0] //! [1] - connect(styleComboBox, SIGNAL(activated(QString)), + connect(styleComboBox, QOverload<const QString &>::of(&QComboBox::activated), //! [1] //! [2] - this, SLOT(changeStyle(QString))); - connect(useStylePaletteCheckBox, SIGNAL(toggled(bool)), - this, SLOT(changePalette())); - connect(disableWidgetsCheckBox, SIGNAL(toggled(bool)), - topLeftGroupBox, SLOT(setDisabled(bool))); - connect(disableWidgetsCheckBox, SIGNAL(toggled(bool)), - topRightGroupBox, SLOT(setDisabled(bool))); - connect(disableWidgetsCheckBox, SIGNAL(toggled(bool)), - bottomLeftTabWidget, SLOT(setDisabled(bool))); - connect(disableWidgetsCheckBox, SIGNAL(toggled(bool)), - bottomRightGroupBox, SLOT(setDisabled(bool))); + this, &WidgetGallery::changeStyle); + connect(useStylePaletteCheckBox, &QCheckBox::toggled, + this, &WidgetGallery::changePalette); + connect(disableWidgetsCheckBox, &QCheckBox::toggled, + topLeftGroupBox, &QGroupBox::setDisabled); + connect(disableWidgetsCheckBox, &QCheckBox::toggled, + topRightGroupBox, &QGroupBox::setDisabled); + connect(disableWidgetsCheckBox, &QCheckBox::toggled, + bottomLeftTabWidget, &QGroupBox::setDisabled); + connect(disableWidgetsCheckBox, &QCheckBox::toggled, + bottomRightGroupBox, &QGroupBox::setDisabled); //! [2] //! [3] @@ -279,7 +279,7 @@ void WidgetGallery::createProgressBar() progressBar->setValue(0); QTimer *timer = new QTimer(this); - connect(timer, SIGNAL(timeout()), this, SLOT(advanceProgressBar())); + connect(timer, &QTimer::timeout, this, &WidgetGallery::advanceProgressBar); timer->start(1000); } //! [13] diff --git a/examples/widgets/widgets/stylesheet/mainwindow.cpp b/examples/widgets/widgets/stylesheet/mainwindow.cpp index eb4b3a2424..f187c007dd 100644 --- a/examples/widgets/widgets/stylesheet/mainwindow.cpp +++ b/examples/widgets/widgets/stylesheet/mainwindow.cpp @@ -64,8 +64,8 @@ MainWindow::MainWindow(QWidget *parent) statusBar()->addWidget(new QLabel(tr("Ready"))); - connect(ui.exitAction, SIGNAL(triggered()), qApp, SLOT(quit())); - connect(ui.aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); + connect(ui.exitAction, &QAction::triggered, qApp, &QApplication::quit); + connect(ui.aboutQtAction, &QAction::triggered, qApp, &QApplication::aboutQt); } void MainWindow::on_editStyleAction_triggered() diff --git a/examples/widgets/widgets/validators/ledwidget.cpp b/examples/widgets/widgets/validators/ledwidget.cpp index 65248741b5..462f416c86 100644 --- a/examples/widgets/widgets/validators/ledwidget.cpp +++ b/examples/widgets/widgets/validators/ledwidget.cpp @@ -56,7 +56,7 @@ LEDWidget::LEDWidget(QWidget *parent) setPixmap(offPixmap); flashTimer.setInterval(200); flashTimer.setSingleShot(true); - connect(&flashTimer, SIGNAL(timeout()), this, SLOT(extinguish())); + connect(&flashTimer, &QTimer::timeout, this, &LEDWidget::extinguish); }; void LEDWidget::extinguish() diff --git a/examples/widgets/widgets/validators/localeselector.cpp b/examples/widgets/widgets/validators/localeselector.cpp index 2f702c9753..7253fea9ec 100644 --- a/examples/widgets/widgets/validators/localeselector.cpp +++ b/examples/widgets/widgets/validators/localeselector.cpp @@ -79,7 +79,8 @@ LocaleSelector::LocaleSelector(QWidget *parent) if (curIndex != -1) setCurrentIndex(curIndex); - connect(this, SIGNAL(activated(int)), this, SLOT(emitLocaleSelected(int))); + connect(this, QOverload<int>::of(&LocaleSelector::activated), + this, &LocaleSelector::emitLocaleSelected); } void LocaleSelector::emitLocaleSelected(int index) diff --git a/examples/widgets/widgets/windowflags/controllerwindow.cpp b/examples/widgets/widgets/windowflags/controllerwindow.cpp index c19f23c513..e2abad89f4 100644 --- a/examples/widgets/widgets/windowflags/controllerwindow.cpp +++ b/examples/widgets/widgets/windowflags/controllerwindow.cpp @@ -62,7 +62,8 @@ ControllerWindow::ControllerWindow(QWidget *parent) createHintsGroupBox(); quitButton = new QPushButton(tr("&Quit")); - connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit())); + connect(quitButton, &QPushButton::clicked, + qApp, &QApplication::quit); QHBoxLayout *bottomLayout = new QHBoxLayout; bottomLayout->addStretch(); @@ -220,7 +221,8 @@ void ControllerWindow::createHintsGroupBox() QCheckBox *ControllerWindow::createCheckBox(const QString &text) { QCheckBox *checkBox = new QCheckBox(text); - connect(checkBox, SIGNAL(clicked()), this, SLOT(updatePreview())); + connect(checkBox, &QCheckBox::clicked, + this, &ControllerWindow::updatePreview); return checkBox; } //! [7] @@ -229,7 +231,8 @@ QCheckBox *ControllerWindow::createCheckBox(const QString &text) QRadioButton *ControllerWindow::createRadioButton(const QString &text) { QRadioButton *button = new QRadioButton(text); - connect(button, SIGNAL(clicked()), this, SLOT(updatePreview())); + connect(button, &QRadioButton::clicked, + this, &ControllerWindow::updatePreview); return button; } //! [8] diff --git a/examples/widgets/widgets/windowflags/previewwindow.cpp b/examples/widgets/widgets/windowflags/previewwindow.cpp index 725a134daf..09e26fd7e4 100644 --- a/examples/widgets/widgets/windowflags/previewwindow.cpp +++ b/examples/widgets/widgets/windowflags/previewwindow.cpp @@ -61,7 +61,8 @@ PreviewWindow::PreviewWindow(QWidget *parent) textEdit->setLineWrapMode(QTextEdit::NoWrap); closeButton = new QPushButton(tr("&Close")); - connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); + connect(closeButton, &QPushButton::clicked, + this, &PreviewWindow::close); QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(textEdit); diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index 0bddf89b15..343ed70196 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -992,8 +992,14 @@ int QEventDispatcherWin32::remainingTime(int timerId) quint64 currentTime = qt_msectime(); for (const WinTimerInfo *t : qAsConst(d->timerVec)) { - if (t && t->timerId == timerId) // timer found, return time to wait - return t->timeout > currentTime ? t->timeout - currentTime : 0; + if (t && t->timerId == timerId) { + // timer found, return time to wait + + if (d->internalHwnd) + return t->timeout > currentTime ? t->timeout - currentTime : 0; + else + return t->interval; + } } #ifndef QT_NO_DEBUG diff --git a/src/corelib/mimetypes/qmimeglobpattern.cpp b/src/corelib/mimetypes/qmimeglobpattern.cpp index fd06f6ab6b..e353ba10cc 100644 --- a/src/corelib/mimetypes/qmimeglobpattern.cpp +++ b/src/corelib/mimetypes/qmimeglobpattern.cpp @@ -142,7 +142,7 @@ bool QMimeGlobPattern::matchFileName(const QString &inputFilename) const return (m_pattern == filename); // Other (quite rare) patterns, like "*.anim[1-9j]": use slow but correct method - QRegularExpression rx(QRegularExpression::anchoredPattern(QRegularExpression::wildcardToRegularExpression(m_pattern))); + QRegularExpression rx(QRegularExpression::wildcardToRegularExpression(m_pattern)); return rx.match(filename).hasMatch(); } diff --git a/src/gui/kernel/qplatformdialoghelper.cpp b/src/gui/kernel/qplatformdialoghelper.cpp index 8b3a2ad193..d14d575056 100644 --- a/src/gui/kernel/qplatformdialoghelper.cpp +++ b/src/gui/kernel/qplatformdialoghelper.cpp @@ -41,6 +41,7 @@ #include <QtCore/QCoreApplication> #include <QtCore/QVariant> +#include <QtCore/QRegularExpression> #include <QtCore/QSharedData> #if QT_CONFIG(settings) #include <QtCore/QSettings> @@ -779,18 +780,19 @@ void QPlatformFileDialogHelper::setOptions(const QSharedPointer<QFileDialogOptio m_options = options; } -const char *QPlatformFileDialogHelper::filterRegExp = +const char QPlatformFileDialogHelper::filterRegExp[] = "^(.*)\\(([a-zA-Z0-9_.,*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$"; // Makes a list of filters from a normal filter string "Image Files (*.png *.jpg)" QStringList QPlatformFileDialogHelper::cleanFilterList(const QString &filter) { - QRegExp regexp(QString::fromLatin1(filterRegExp)); + QRegularExpression regexp(QString::fromLatin1(filterRegExp)); Q_ASSERT(regexp.isValid()); QString f = filter; - int i = regexp.indexIn(f); - if (i >= 0) - f = regexp.cap(2); + QRegularExpressionMatch match; + filter.indexOf(regexp, 0, &match); + if (match.hasMatch()) + f = match.captured(2); return f.split(QLatin1Char(' '), QString::SkipEmptyParts); } diff --git a/src/gui/kernel/qplatformdialoghelper.h b/src/gui/kernel/qplatformdialoghelper.h index 0832e19dc3..f09bec12da 100644 --- a/src/gui/kernel/qplatformdialoghelper.h +++ b/src/gui/kernel/qplatformdialoghelper.h @@ -414,7 +414,7 @@ public: void setOptions(const QSharedPointer<QFileDialogOptions> &options); static QStringList cleanFilterList(const QString &filter); - static const char *filterRegExp; + static const char filterRegExp[]; Q_SIGNALS: void fileSelected(const QUrl &file); diff --git a/src/network/ssl/qocspresponse.cpp b/src/network/ssl/qocspresponse.cpp index acc24047e7..1466364af2 100644 --- a/src/network/ssl/qocspresponse.cpp +++ b/src/network/ssl/qocspresponse.cpp @@ -53,11 +53,10 @@ QT_BEGIN_NAMESPACE The QOcspResponse class represents the revocation status of a server's certficate, received by the client-side socket during the TLS handshake. QSslSocket must be - configured with OCSP stapling enabled. A non-empty response corresponds to the - certificate that can be obtained from QSslConfiguration::peerCertificate(). + configured with OCSP stapling enabled. - \sa QSslSocket, QSslSocket::ocspResponse(), isNull(), clear(), certificateStatus(), - revocationReason(), responder(), OcspCertificateStatus, OcspRevocationReason, + \sa QSslSocket, QSslSocket::ocspResponse(), certificateStatus(), + revocationReason(), responder(), subject(), OcspCertificateStatus, OcspRevocationReason, QSslConfiguration::setOcspStaplingEnabled(), QSslConfiguration::ocspStaplingEnabled(), QSslConfiguration::peerCertificate() */ @@ -110,9 +109,10 @@ QT_BEGIN_NAMESPACE /*! \since 5.13 - Creates a new, null OCSP response. + Creates a new response with status OcspCertificateStatus::Unknown + and revocation reason OcspRevocationReason::None. - \sa isNull() + \sa OcspCertificateStatus */ QOcspResponse::QOcspResponse() : d(new QOcspResponsePrivate) @@ -132,7 +132,7 @@ QOcspResponse::QOcspResponse(const QOcspResponse &other) /*! \since 5.13 - Move-constructs a QOcspResponse instance. + Move-constructs a QOcspResponse instance from \a other. */ QOcspResponse::QOcspResponse(QOcspResponse &&other) Q_DECL_NOTHROW { @@ -177,35 +177,6 @@ QOcspResponse &QOcspResponse::operator=(QOcspResponse &&other) Q_DECL_NOTHROW /*! \since 5.13 - Returns \c true for default-constructed OCSP responses and also if during a - handshake no definitive OCSP response, or no response was received at all. - - \sa QOcspResponse(), QSslSocket::ocspResponse() -*/ -bool QOcspResponse::isNull() const -{ - return d->isNull; -} - -/*! - \since 5.13 - - Resets this QOcspResponse to its default, null state. - - \sa QOcspResponse(), isNull() -*/ -void QOcspResponse::clear() -{ - - d->certificateStatus = OcspCertificateStatus::Unknown; - d->revocationReason = OcspRevocationReason::None; - d->isNull = true; - d->signerCert.clear(); -} - -/*! - \since 5.13 - Returns the certificate status. \sa OcspCertificateStatus @@ -235,4 +206,14 @@ QSslCertificate QOcspResponse::responder() const return d->signerCert; } +/*! + \since 5.13 + + This function returns a certificate, for which this response was issued. +*/ +QSslCertificate QOcspResponse::subject() const +{ + return d->subjectCert; +} + QT_END_NAMESPACE diff --git a/src/network/ssl/qocspresponse.h b/src/network/ssl/qocspresponse.h index 163acd535f..5cff625b84 100644 --- a/src/network/ssl/qocspresponse.h +++ b/src/network/ssl/qocspresponse.h @@ -84,13 +84,11 @@ public: QOcspResponse &operator = (const QOcspResponse &other); QOcspResponse &operator = (QOcspResponse &&other) Q_DECL_NOTHROW; - bool isNull() const; - void clear(); - OcspCertificateStatus certificateStatus() const; OcspRevocationReason revocationReason() const; class QSslCertificate responder() const; + QSslCertificate subject() const; private: diff --git a/src/network/ssl/qocspresponse_p.h b/src/network/ssl/qocspresponse_p.h index 652b2bfca7..44480df633 100644 --- a/src/network/ssl/qocspresponse_p.h +++ b/src/network/ssl/qocspresponse_p.h @@ -63,9 +63,9 @@ public: OcspCertificateStatus certificateStatus = OcspCertificateStatus::Unknown; OcspRevocationReason revocationReason = OcspRevocationReason::None; - bool isNull = true; QSslCertificate signerCert; + QSslCertificate subjectCert; }; QT_END_NAMESPACE diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 68de9dedaa..fc9a44f896 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -1155,16 +1155,16 @@ QSsl::SslProtocol QSslSocket::sessionProtocol() const /*! \since 5.13 - This function returns Online Certificate Status Protocol response that - a server may send during a TLS handshake using OCSP stapling. If no - definitive or no response was received at all, the response is empty. + This function returns Online Certificate Status Protocol responses that + a server may send during a TLS handshake using OCSP stapling. The vector + is empty if no definitive response or no response at all was received. - \sa QSslConfiguration::setOcspStaplingEnabled(), QOcspResponse::isNull() + \sa QSslConfiguration::setOcspStaplingEnabled() */ -QOcspResponse QSslSocket::ocspResponse() const +QVector<QOcspResponse> QSslSocket::ocspResponses() const { Q_D(const QSslSocket); - return d->ocspResponse; + return d->ocspResponses; } /*! @@ -2150,7 +2150,7 @@ void QSslSocketPrivate::init() shutdown = false; pendingClose = false; flushTriggered = false; - ocspResponse.clear(); + ocspResponses.clear(); // we don't want to clear the ignoreErrorsList, so // that it is possible setting it before connecting @@ -2891,8 +2891,6 @@ bool QSslSocketPrivate::isMatchingHostname(const QSslCertificate &cert, const QS if (QHostAddress(*it).isEqual(hostAddress, QHostAddress::StrictConversion)) return true; } - - return false; } const QString lowerPeerName = QString::fromLatin1(QUrl::toAce(peerName)); diff --git a/src/network/ssl/qsslsocket.h b/src/network/ssl/qsslsocket.h index 8dfb9f2018..4a695a6b01 100644 --- a/src/network/ssl/qsslsocket.h +++ b/src/network/ssl/qsslsocket.h @@ -61,6 +61,7 @@ class QSslConfiguration; class QSslEllipticCurve; class QSslPreSharedKeyAuthenticator; class QOcspResponse; +template<class> class QVector; class QSslSocketPrivate; class Q_NETWORK_EXPORT QSslSocket : public QTcpSocket @@ -143,7 +144,7 @@ public: QList<QSslCertificate> peerCertificateChain() const; QSslCipher sessionCipher() const; QSsl::SslProtocol sessionProtocol() const; - QOcspResponse ocspResponse() const; + QVector<QOcspResponse> ocspResponses() const; // Private keys, for server sockets. void setPrivateKey(const QSslKey &key); diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index a7c681920e..15b2b4c2cf 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -1458,9 +1458,7 @@ bool QSslSocketBackendPrivate::checkOcspStatus() Q_ASSERT(mode == QSslSocket::SslClientMode); // See initSslContext() for SslServerMode Q_ASSERT(configuration.peerVerifyMode != QSslSocket::VerifyNone); - ocspResponse.clear(); - QOcspResponsePrivate *dResponse = ocspResponse.d.data(); - + ocspResponses.clear(); ocspErrorDescription.clear(); ocspErrors.clear(); @@ -1556,7 +1554,9 @@ bool QSslSocketBackendPrivate::checkOcspStatus() // Let's make sure the response is for the correct certificate - we // can re-create this CertID using our peer's certificate and its // issuer's public key. - dResponse->isNull = false; + ocspResponses.push_back(QOcspResponse()); + QOcspResponsePrivate *dResponse = ocspResponses.back().d.data(); + dResponse->subjectCert = configuration.peerCertificate; bool matchFound = false; if (configuration.peerCertificate.isSelfSigned()) { dResponse->signerCert = configuration.peerCertificate; @@ -1599,7 +1599,7 @@ bool QSslSocketBackendPrivate::checkOcspStatus() // This is unexpected, treat as SslHandshakeError, OCSP_check_validity assumes this pointer // to be != nullptr. ocspErrors.clear(); - ocspResponse.clear(); + ocspResponses.clear(); ocspErrorDescription = QSslSocket::tr("Failed to extract 'this update time' from the SingleResponse"); return false; } diff --git a/src/network/ssl/qsslsocket_p.h b/src/network/ssl/qsslsocket_p.h index 31eee478ee..daa9be23f4 100644 --- a/src/network/ssl/qsslsocket_p.h +++ b/src/network/ssl/qsslsocket_p.h @@ -66,7 +66,7 @@ class QSslContext; #endif #include <QtCore/qstringlist.h> - +#include <QtCore/qvector.h> #include <private/qringbuffer_p.h> #if defined(Q_OS_MAC) @@ -208,7 +208,7 @@ protected: bool verifyErrorsHaveBeenIgnored(); bool paused; bool flushTriggered; - QOcspResponse ocspResponse; + QVector<QOcspResponse> ocspResponses; }; #if QT_CONFIG(securetransport) || QT_CONFIG(schannel) diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp index 794674c427..1ed162482e 100644 --- a/src/widgets/widgets/qmdisubwindow.cpp +++ b/src/widgets/widgets/qmdisubwindow.cpp @@ -3341,8 +3341,11 @@ void QMdiSubWindow::mouseMoveEvent(QMouseEvent *mouseEvent) } if ((mouseEvent->buttons() & Qt::LeftButton) || d->isInInteractiveMode) { - if ((d->isResizeOperation() && d->resizeEnabled) || (d->isMoveOperation() && d->moveEnabled)) - d->setNewGeometry(mapToParent(mouseEvent->pos())); + if ((d->isResizeOperation() && d->resizeEnabled) || (d->isMoveOperation() && d->moveEnabled)) { + // As setNewGeometry moves the window, it invalidates the pos() value of any mouse move events that are + // currently queued in the event loop. Map to parent using globalPos() instead. + d->setNewGeometry(parentWidget()->mapFromGlobal(mouseEvent->globalPos())); + } return; } diff --git a/tests/auto/corelib/kernel/qtimer/BLACKLIST b/tests/auto/corelib/kernel/qtimer/BLACKLIST deleted file mode 100644 index e5136624d8..0000000000 --- a/tests/auto/corelib/kernel/qtimer/BLACKLIST +++ /dev/null @@ -1,3 +0,0 @@ -[remainingTime] -windows -osx diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp index 8d194dafc1..3b10547dc4 100644 --- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp +++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp @@ -51,6 +51,8 @@ private slots: void singleShotTimeout(); void timeout(); void remainingTime(); + void remainingTimeInitial_data(); + void remainingTimeInitial(); void remainingTimeDuringActivation_data(); void remainingTimeDuringActivation(); void basic_chrono(); @@ -133,14 +135,41 @@ void tst_QTimer::remainingTime() QCOMPARE(timeoutSpy.count(), 0); int remainingTime = timer.remainingTime(); - QVERIFY2(qAbs(remainingTime - 150) < 50, qPrintable(QString::number(remainingTime))); + QVERIFY2(remainingTime >= 50 && remainingTime <= 200, qPrintable(QString::number(remainingTime))); QVERIFY(timeoutSpy.wait()); QCOMPARE(timeoutSpy.count(), 1); // the timer is still active, so it should have a non-zero remaining time remainingTime = timer.remainingTime(); - QVERIFY2(remainingTime > 150, qPrintable(QString::number(remainingTime))); + QVERIFY2(remainingTime >= 50, qPrintable(QString::number(remainingTime))); +} + +void tst_QTimer::remainingTimeInitial_data() +{ + QTest::addColumn<int>("startTimeMs"); + QTest::addColumn<Qt::TimerType>("timerType"); + + QTest::addRow("precise time 0ms") << 0 << Qt::PreciseTimer; + QTest::addRow("precise time 1ms") << 1 << Qt::PreciseTimer; + QTest::addRow("precise time 10ms") << 10 << Qt::PreciseTimer; + + QTest::addRow("coarse time 0ms") << 0 << Qt::CoarseTimer; + QTest::addRow("coarse time 1ms") << 1 << Qt::CoarseTimer; + QTest::addRow("coarse time 10ms") << 10 << Qt::CoarseTimer; +} + +void tst_QTimer::remainingTimeInitial() +{ + QFETCH(int, startTimeMs); + QFETCH(Qt::TimerType, timerType); + + QTimer timer; + timer.setTimerType(timerType); + timer.start(startTimeMs); + + const int rt = timer.remainingTime(); + QVERIFY2(rt >= 0 && rt <= startTimeMs, qPrintable(QString::number(rt))); } void tst_QTimer::remainingTimeDuringActivation_data() @@ -228,7 +257,7 @@ void tst_QTimer::basic_chrono() QCOMPARE(timeoutSpy.count(), 0); milliseconds rt = timer.remainingTimeAsDuration(); - QVERIFY2(qAbs(rt.count() - 150) < 50, qPrintable(QString::number(rt.count()))); + QVERIFY2(rt.count() >= 50 && rt.count() <= 200, qPrintable(QString::number(rt.count()))); timeoutSpy.clear(); timer.setSingleShot(true); diff --git a/tests/auto/network/access/qnetworkreply/certs/qt-test-server-host-network-cacert.pem b/tests/auto/network/access/qnetworkreply/certs/qt-test-server-host-network-cacert.pem new file mode 100644 index 0000000000..5bdce3a3f9 --- /dev/null +++ b/tests/auto/network/access/qnetworkreply/certs/qt-test-server-host-network-cacert.pem @@ -0,0 +1,16 @@ +-----BEGIN CERTIFICATE----- +MIIClzCCAgACCQDeuuUc2HkfKDANBgkqhkiG9w0BAQQFADCBjzELMAkGA1UEChMC +UXQxGTAXBgNVBAsTEENvcmUgQW5kIE5ldHdvcmsxGzAZBgkqhkiG9w0BCQEWDG5v +Ym9keS5xdC5pbzENMAsGA1UEBxMET3NsbzENMAsGA1UECBMET3NsbzELMAkGA1UE +BhMCTk8xHTAbBgNVBAMTFHF0LXRlc3Qtc2VydmVyLmxvY2FsMB4XDTE5MDEyNTE1 +NDE0N1oXDTQ5MDExNzE1NDE0N1owgY8xCzAJBgNVBAoTAlF0MRkwFwYDVQQLExBD +b3JlIEFuZCBOZXR3b3JrMRswGQYJKoZIhvcNAQkBFgxub2JvZHkucXQuaW8xDTAL +BgNVBAcTBE9zbG8xDTALBgNVBAgTBE9zbG8xCzAJBgNVBAYTAk5PMR0wGwYDVQQD +ExRxdC10ZXN0LXNlcnZlci5sb2NhbDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkC +gYEAzarbb9Y0yafxwL7kQRgZ4gLJIuan1boDLp4oevRfGndfd6kRO49+8C7Gnus6 +2RLXwQxR6CRSPyPDQgwRxvIcoUL+tMJpg633cLEYFcwgKGIw8CwV5jMZr8PrHMCR +9xFolFD4STcIMtc+dd+jvGkAFd7Nhw9cAmuCyAF9avAd3HMCAwEAATANBgkqhkiG +9w0BAQQFAAOBgQB1dxK3Ia4sCpvSikKLaf1ZXu+9GKaNWKJe9bWex9/RmNOla9N2 +FIh6/CfaPFDy/OXCkyEiGg78iyg/DgqVoa9JJGV3diI6berisHMPJpv1syyz9YEU +G3RQUClPcPV6EcedyqCdpbnIFtiSZbtJ0ZBGef4KzBN3rTmPucKb+bhMPg== +-----END CERTIFICATE----- diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 61f0f70ea7..0d6828797a 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -550,8 +550,15 @@ static void setupSslServer(QSslSocket* serverSocket) } #ifdef QT_TEST_SERVER +#ifdef QT_TEST_SERVER_NAME +// In this case, each server is assigned a unique hostname. Use the wildcard SSL +// certificate (*.test-net.qt.local). const QString tst_QNetworkReply::certsFilePath = "/certs/qt-test-net-cacert.pem"; #else +// Otherwise, select the single-name SSL certificate (qt-test-server.local) instead. +const QString tst_QNetworkReply::certsFilePath = "/certs/qt-test-server-host-network-cacert.pem"; +#endif // QT_TEST_SERVER_NAME +#else const QString tst_QNetworkReply::certsFilePath = "/certs/qt-test-server-cacert.pem"; #endif diff --git a/tests/auto/network/ssl/qsslsocket/certs/127-0-0-1-as-CN.crt b/tests/auto/network/ssl/qsslsocket/certs/127-0-0-1-as-CN.crt new file mode 100644 index 0000000000..2253469392 --- /dev/null +++ b/tests/auto/network/ssl/qsslsocket/certs/127-0-0-1-as-CN.crt @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIC/jCCAeagAwIBAgIJALBykhTMGxyEMA0GCSqGSIb3DQEBCwUAMBQxEjAQBgNV +BAMMCTEyNy4wLjAuMTAeFw0xOTAxMjUyMjU5NDFaFw0xOTAyMjQyMjU5NDFaMBQx +EjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC +ggEBALMEo10Xd6e5ot4Rg99VejDV/WNdAhY6+2Ilzuc+1XdzDpEQCuqWY2hAGX9m +QXyFSR+UcpJWoUFUtJLsArXgRnxT+seHuemrLZGZOkDStUhKNpxfwOmhIT+sLocw +qXCwNf9oG4//3evGwGqJhLDpGUhTNVCAMaalb1yrcXskYEkWdelzCTMzoirVvbS2 +6PH3kE+WPaBehMFruLtp+v7btnVIA305DwFy4CLq+HHFq59BbxRWxhRSkfXM8w+d +g05P3VNpEb8Apn4rQ+n/xRz7oZs0Aou4GZG5JAgiLOibbVBK+xnD/UW/txeFWfRZ +1dzIi4yAKkdwIhPAg+pP1G6tgZMCAwEAAaNTMFEwHQYDVR0OBBYEFNGZZgb9dbVY +FKkkoQp/oAQ2/B51MB8GA1UdIwQYMBaAFNGZZgb9dbVYFKkkoQp/oAQ2/B51MA8G +A1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAFvHy0RE96TDw6Q2pfCY +aMz/X8dMAEMz5XqC7ImcztVg6VTRHpiw+QFQGqCLwNNuwkD9/pZ3IgVzSbRQw3oW +HO7wD30NFl17LQMONBdcmR9FO5ruBh8G0Q1tmeKNtuwjzF3LAkj/J3tAn6eVmHi5 +75WEK/vQgy9XElN6EC6TgC/4B5/DPdZuEMdL7AP8ADLq9UVf8JC9c4QjU9G1Ce2R +PzNwkhkLvtLlcxFcXciuc+oGhLENoJ2ZYHctT/ReOuBoRWEwIB1AeCWxitxjBZ6t +lmZ+UewuzJ7y1X5maQZr7w3o8f6DwqwYrmMd45tS6jkHHAJlaCs/yCfVnLBwZ1l4 +NeM= +-----END CERTIFICATE----- diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index 8367977648..f34a0e8665 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -1722,6 +1722,14 @@ void tst_QSslSocket::isMatchingHostname() cert = certs.first(); QCOMPARE(QSslSocketPrivate::isMatchingHostname(cert, QString::fromUtf8("192.5.8.16")), true); QCOMPARE(QSslSocketPrivate::isMatchingHostname(cert, QString::fromUtf8("fe80::3c29:2fa1:dd44:765")), true); + + /* openssl req -x509 -nodes -new -newkey rsa -keyout /dev/null -out 127-0-0-1-as-CN.crt \ + -subj "/CN=127.0.0.1" + */ + certs = QSslCertificate::fromPath(testDataDir + "certs/127-0-0-1-as-CN.crt"); + QVERIFY(!certs.isEmpty()); + cert = certs.first(); + QCOMPARE(QSslSocketPrivate::isMatchingHostname(cert, QString::fromUtf8("127.0.0.1")), true); } void tst_QSslSocket::wildcard() diff --git a/tests/auto/testserver.pri b/tests/auto/testserver.pri index 0042571115..54c8b51d49 100644 --- a/tests/auto/testserver.pri +++ b/tests/auto/testserver.pri @@ -62,7 +62,19 @@ isEmpty(TESTSERVER_VERSION) { # Make check with server "qt-test-server.qt-test-net" as a fallback } else { # Make check with docker test servers - DNSDOMAIN = test-net.qt.local + equals(QMAKE_HOST.os, Linux) { + # For the platform supporting docker bridge network, each container is + # assigned a unique hostname and connected to the same network domain + # to communicate with the others. + DEFINES += QT_TEST_SERVER_NAME + DNSDOMAIN = test-net.qt.local + } else { + # For the others, the containers are deployed into a virtual machine + # using the host network. All the containers share the same hostname of + # the virtual machine, and they are connected to the same network domain. + # NOTE: In Windows, Apple Bonjour only works within a single local domain. + DNSDOMAIN = local + } equals(QMAKE_HOST.os, Darwin) { # There is no docker bridge on macOS. It is impossible to ping a container. @@ -86,9 +98,6 @@ isEmpty(TESTSERVER_VERSION) { TESTSERVER_COMPOSE_FILE = \ $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose-for-windows.yml - # Bonjour only works within a single broadcast domain. - DNSDOMAIN = local - # The connection configuration for the target machine MACHINE_CONFIG = (docker-machine config qt-test-server) @@ -104,7 +113,6 @@ isEmpty(TESTSERVER_VERSION) { CONFIG += PowerShell } else { TESTSERVER_COMPOSE_FILE = $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose.yml - DEFINES += QT_TEST_SERVER_NAME # The environment variables passed to the docker-compose file TEST_ENV = 'TEST_DOMAIN=$$DNSDOMAIN' diff --git a/tests/testserver/common/ssl.sh b/tests/testserver/common/ssl.sh index 8a4728ad4d..2593a22979 100755 --- a/tests/testserver/common/ssl.sh +++ b/tests/testserver/common/ssl.sh @@ -35,5 +35,6 @@ set -ex # install ssl_certs and test data su $USER -c "mkdir -p -m 700 ~/ssl-certs/private" -su $USER -c "cp $CONFIG/ssl/qt-test-server-cert.pem ~/ssl-certs/" +su $USER -c \ + "cp $CONFIG/ssl/${test_cert:-qt-test-server-cert.pem} ~/ssl-certs/qt-test-server-cert.pem" su $USER -c "cp $CONFIG/ssl/private/qt-test-server-key.pem ~/ssl-certs/private/" diff --git a/tests/testserver/common/testdata/ssl/qt-test-server-host-network-cacert.pem b/tests/testserver/common/testdata/ssl/qt-test-server-host-network-cacert.pem new file mode 100644 index 0000000000..5bdce3a3f9 --- /dev/null +++ b/tests/testserver/common/testdata/ssl/qt-test-server-host-network-cacert.pem @@ -0,0 +1,16 @@ +-----BEGIN CERTIFICATE----- +MIIClzCCAgACCQDeuuUc2HkfKDANBgkqhkiG9w0BAQQFADCBjzELMAkGA1UEChMC +UXQxGTAXBgNVBAsTEENvcmUgQW5kIE5ldHdvcmsxGzAZBgkqhkiG9w0BCQEWDG5v +Ym9keS5xdC5pbzENMAsGA1UEBxMET3NsbzENMAsGA1UECBMET3NsbzELMAkGA1UE +BhMCTk8xHTAbBgNVBAMTFHF0LXRlc3Qtc2VydmVyLmxvY2FsMB4XDTE5MDEyNTE1 +NDE0N1oXDTQ5MDExNzE1NDE0N1owgY8xCzAJBgNVBAoTAlF0MRkwFwYDVQQLExBD +b3JlIEFuZCBOZXR3b3JrMRswGQYJKoZIhvcNAQkBFgxub2JvZHkucXQuaW8xDTAL +BgNVBAcTBE9zbG8xDTALBgNVBAgTBE9zbG8xCzAJBgNVBAYTAk5PMR0wGwYDVQQD +ExRxdC10ZXN0LXNlcnZlci5sb2NhbDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkC +gYEAzarbb9Y0yafxwL7kQRgZ4gLJIuan1boDLp4oevRfGndfd6kRO49+8C7Gnus6 +2RLXwQxR6CRSPyPDQgwRxvIcoUL+tMJpg633cLEYFcwgKGIw8CwV5jMZr8PrHMCR +9xFolFD4STcIMtc+dd+jvGkAFd7Nhw9cAmuCyAF9avAd3HMCAwEAATANBgkqhkiG +9w0BAQQFAAOBgQB1dxK3Ia4sCpvSikKLaf1ZXu+9GKaNWKJe9bWex9/RmNOla9N2 +FIh6/CfaPFDy/OXCkyEiGg78iyg/DgqVoa9JJGV3diI6berisHMPJpv1syyz9YEU +G3RQUClPcPV6EcedyqCdpbnIFtiSZbtJ0ZBGef4KzBN3rTmPucKb+bhMPg== +-----END CERTIFICATE----- diff --git a/tests/testserver/docker-compose-for-macOS.yml b/tests/testserver/docker-compose-for-macOS.yml index bbd1f71a62..aa610dfb88 100644 --- a/tests/testserver/docker-compose-for-macOS.yml +++ b/tests/testserver/docker-compose-for-macOS.yml @@ -25,6 +25,7 @@ services: - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}" environment: - test_domain=${TEST_DOMAIN} + - test_cert="qt-test-server-host-network-cacert.pem" squid: image: qt-test-server-squid:9c32f41b19aca3d778733c4d8fb0ecc5955e893c diff --git a/tests/testserver/docker-compose-for-windows.yml b/tests/testserver/docker-compose-for-windows.yml index bbd1f71a62..aa610dfb88 100644 --- a/tests/testserver/docker-compose-for-windows.yml +++ b/tests/testserver/docker-compose-for-windows.yml @@ -25,6 +25,7 @@ services: - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}" environment: - test_domain=${TEST_DOMAIN} + - test_cert="qt-test-server-host-network-cacert.pem" squid: image: qt-test-server-squid:9c32f41b19aca3d778733c4d8fb0ecc5955e893c |