Merge "Merge remote-tracking branch 'origin/5.15' into dev"

This commit is contained in:
Qt Forward Merge Bot 2019-09-22 22:28:32 +02:00
commit e4ce8d1070
107 changed files with 1663 additions and 1435 deletions

View File

@ -766,7 +766,7 @@
"debug_and_release": {
"label": "Compile libs in debug and release mode",
"autoDetect": "input.debug == ''",
"condition": "config.darwin || config.win32",
"condition": "config.darwin || (config.win32 && !config.gcc)",
"output": [ "publicFeature", "publicQtConfig", "debugAndRelease" ]
},
"force_debug_info": {

View File

@ -142,6 +142,9 @@
pendingAdditiveOperator and \c pendingMultiplicativeOperator
variables don't need to be initialized explicitly, because the
QString constructor initializes them to empty strings.
It is also possible to initialize those variable directly in the
header. This is called \c member-initializaton and avoids a long
initialization list.
\snippet widgets/calculator/calculator.cpp 1
\snippet widgets/calculator/calculator.cpp 2

View File

@ -95,7 +95,7 @@
\snippet widgets/tooltips/sortingbox.h 2
We keep all the shape items in a QList, and we keep three
We keep all the shape items in a QVector, and we keep three
QPainterPath objects holding the shapes of a circle, a square and
a triangle. We also need to have a pointer to an item when it is
moving, and we need to know its previous position.

View File

@ -50,7 +50,9 @@
#include "analogclock.h"
#include <QtWidgets>
#include <QPainter>
#include <QTime>
#include <QTimer>
//! [0] //! [1]
AnalogClock::AnalogClock(QWidget *parent)

View File

@ -50,8 +50,6 @@
#include "button.h"
#include <QtWidgets>
//! [0]
Button::Button(const QString &text, QWidget *parent)
: QToolButton(parent)

View File

@ -48,21 +48,18 @@
**
****************************************************************************/
#include "button.h"
#include "calculator.h"
#include "button.h"
#include <QtWidgets>
#include <cmath>
#include <QGridLayout>
#include <QLineEdit>
#include <QtMath>
//! [0]
Calculator::Calculator(QWidget *parent)
: QWidget(parent)
: QWidget(parent), sumInMemory(0.0), sumSoFar(0.0)
, factorSoFar(0.0), waitingForOperand(true)
{
sumInMemory = 0.0;
sumSoFar = 0.0;
factorSoFar = 0.0;
waitingForOperand = true;
//! [0]
//! [1]
@ -78,9 +75,8 @@ Calculator::Calculator(QWidget *parent)
//! [2]
//! [4]
for (int i = 0; i < NumDigitButtons; ++i) {
for (int i = 0; i < NumDigitButtons; ++i)
digitButtons[i] = createButton(QString::number(i), SLOT(digitClicked()));
}
Button *pointButton = createButton(tr("."), SLOT(pointClicked()));
Button *changeSignButton = createButton(tr("\302\261"), SLOT(changeSignClicked()));
@ -194,6 +190,8 @@ void Calculator::additiveOperatorClicked()
//! [10] //! [11]
{
Button *clickedButton = qobject_cast<Button *>(sender());
if (!clickedButton)
return;
QString clickedOperator = clickedButton->text();
double operand = display->text().toDouble();
@ -233,6 +231,8 @@ void Calculator::additiveOperatorClicked()
void Calculator::multiplicativeOperatorClicked()
{
Button *clickedButton = qobject_cast<Button *>(sender());
if (!clickedButton)
return;
QString clickedOperator = clickedButton->text();
double operand = display->text().toDouble();

View File

@ -48,7 +48,7 @@
**
****************************************************************************/
#include <QtWidgets>
#include <QApplication>
#include "window.h"

View File

@ -48,10 +48,18 @@
**
****************************************************************************/
#include <QtWidgets>
#include "window.h"
#include <QCalendarWidget>
#include <QCheckBox>
#include <QComboBox>
#include <QDateEdit>
#include <QGridLayout>
#include <QGroupBox>
#include <QLabel>
#include <QLocale>
#include <QTextCharFormat>
//! [0]
Window::Window(QWidget *parent)
: QWidget(parent)
@ -166,13 +174,12 @@ void Window::reformatHeaders()
QString text = headerTextFormatCombo->currentText();
QTextCharFormat format;
if (text == tr("Bold")) {
if (text == tr("Bold"))
format.setFontWeight(QFont::Bold);
} else if (text == tr("Italic")) {
else if (text == tr("Italic"))
format.setFontItalic(true);
} else if (text == tr("Green")) {
else if (text == tr("Green"))
format.setForeground(Qt::green);
}
calendar->setHeaderTextFormat(format);
}
//! [7]

View File

@ -50,11 +50,14 @@
#include "characterwidget.h"
#include <QtWidgets>
#include <QFontDatabase>
#include <QMouseEvent>
#include <QPainter>
#include <QToolTip>
//! [0]
CharacterWidget::CharacterWidget(QWidget *parent)
: QWidget(parent), columns(16), lastKey(-1)
: QWidget(parent)
{
calculateSquareSize();
setMouseTracking(true);
@ -172,16 +175,16 @@ void CharacterWidget::paintEvent(QPaintEvent *event)
QFontMetrics fontMetrics(displayFont);
painter.setPen(QPen(Qt::black));
for (int row = beginRow; row <= endRow; ++row) {
for (int column = beginColumn; column <= endColumn; ++column) {
int key = row * columns + column;
painter.setClipRect(column * squareSize, row * squareSize, squareSize, squareSize);
if (key == lastKey)
painter.fillRect(column*squareSize + 1, row*squareSize + 1, squareSize, squareSize, QBrush(Qt::red));
painter.fillRect(column * squareSize + 1, row * squareSize + 1,
squareSize, squareSize, QBrush(Qt::red));
painter.drawText(column*squareSize + (squareSize / 2) - fontMetrics.horizontalAdvance(QChar(key))/2,
painter.drawText(column * squareSize + (squareSize / 2) -
fontMetrics.horizontalAdvance(QChar(key)) / 2,
row * squareSize + 4 + fontMetrics.ascent(),
QString(QChar(key)));
}

View File

@ -88,9 +88,9 @@ private:
void calculateSquareSize();
QFont displayFont;
int columns;
int lastKey;
int squareSize;
int columns = 16;
int lastKey = -1;
int squareSize = 0;
};
//! [0]

View File

@ -48,13 +48,27 @@
**
****************************************************************************/
#include <QtWidgets>
#include "characterwidget.h"
#include "mainwindow.h"
#include "characterwidget.h"
#include <QApplication>
#include <QBoxLayout>
#include <QCheckBox>
#include <QClipboard>
#include <QDesktopWidget>
#include <QDialog>
#include <QDialogButtonBox>
#include <QFontComboBox>
#include <QLabel>
#include <QLineEdit>
#include <QMenuBar>
#include <QPlainTextEdit>
#include <QPushButton>
#include <QScrollArea>
#include <QStatusBar>
#include <QTextStream>
//! [0]
Q_DECLARE_METATYPE(QFontComboBox::FontFilter)
MainWindow::MainWindow(QWidget *parent)

View File

@ -48,10 +48,11 @@
**
****************************************************************************/
#include <QtWidgets>
#include "codeeditor.h"
#include <QPainter>
#include <QTextBlock>
//![constructor]
CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent)
@ -157,8 +158,8 @@ void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event)
//![extraAreaPaintEvent_1]
QTextBlock block = firstVisibleBlock();
int blockNumber = block.blockNumber();
int top = (int) blockBoundingGeometry(block).translated(contentOffset()).top();
int bottom = top + (int) blockBoundingRect(block).height();
int top = qRound(blockBoundingGeometry(block).translated(contentOffset()).top());
int bottom = top + qRound(blockBoundingRect(block).height());
//![extraAreaPaintEvent_1]
//![extraAreaPaintEvent_2]
@ -172,7 +173,7 @@ void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event)
block = block.next();
top = bottom;
bottom = top + (int) blockBoundingRect(block).height();
bottom = top + qRound(blockBoundingRect(block).height());
++blockNumber;
}
}

View File

@ -80,7 +80,7 @@ protected:
private slots:
void updateLineNumberAreaWidth(int newBlockCount);
void highlightCurrentLine();
void updateLineNumberArea(const QRect &, int);
void updateLineNumberArea(const QRect &rect, int dy);
private:
QWidget *lineNumberArea;
@ -92,16 +92,17 @@ private:
class LineNumberArea : public QWidget
{
public:
LineNumberArea(CodeEditor *editor) : QWidget(editor) {
codeEditor = editor;
}
LineNumberArea(CodeEditor *editor) : QWidget(editor), codeEditor(editor)
{}
QSize sizeHint() const override {
QSize sizeHint() const override
{
return QSize(codeEditor->lineNumberAreaWidth(), 0);
}
protected:
void paintEvent(QPaintEvent *event) override {
void paintEvent(QPaintEvent *event) override
{
codeEditor->lineNumberAreaPaintEvent(event);
}

View File

@ -48,7 +48,7 @@
**
****************************************************************************/
#include <QtWidgets>
#include <QApplication>
#include "codeeditor.h"

View File

@ -50,7 +50,8 @@
#include "digitalclock.h"
#include <QtWidgets>
#include <QTime>
#include <QTimer>
//! [0]
DigitalClock::DigitalClock(QWidget *parent)

View File

@ -48,10 +48,15 @@
**
****************************************************************************/
#include <QtWidgets>
#include "window.h"
#include <QCheckBox>
#include <QGridLayout>
#include <QGroupBox>
#include <QMenu>
#include <QPushButton>
#include <QRadioButton>
//! [0]
Window::Window(QWidget *parent)
: QWidget(parent)

View File

@ -50,7 +50,8 @@
#include "iconpreviewarea.h"
#include <QtWidgets>
#include <QGridLayout>
#include <QLabel>
//! [0]
IconPreviewArea::IconPreviewArea(QWidget *parent)

View File

@ -50,7 +50,7 @@
#include "iconsizespinbox.h"
#include <QtWidgets>
#include <QRegularExpression>
//! [0]
IconSizeSpinBox::IconSizeSpinBox(QWidget *parent)

View File

@ -51,7 +51,7 @@
#include "imagedelegate.h"
#include "iconpreviewarea.h"
#include <QtWidgets>
#include <QComboBox>
//! [0]
ImageDelegate::ImageDelegate(QObject *parent)

View File

@ -48,14 +48,29 @@
**
****************************************************************************/
#include <QtWidgets>
#include "mainwindow.h"
#include "iconpreviewarea.h"
#include "iconsizespinbox.h"
#include "imagedelegate.h"
#include "mainwindow.h"
#include <memory>
#include <QApplication>
#include <QButtonGroup>
#include <QCheckBox>
#include <QFileDialog>
#include <QHeaderView>
#include <QFormLayout>
#include <QGridLayout>
#include <QGroupBox>
#include <QImageReader>
#include <QLabel>
#include <QMenuBar>
#include <QMessageBox>
#include <QRadioButton>
#include <QScreen>
#include <QStandardPaths>
#include <QStyleFactory>
#include <QTableWidget>
#include <QWindow>
//! [40]
enum { OtherSize = QStyle::PM_CustomBase };

View File

@ -50,7 +50,24 @@
#include "imageviewer.h"
#include <QtWidgets>
#include <QApplication>
#include <QClipboard>
#include <QColorSpace>
#include <QDir>
#include <QFileDialog>
#include <QImageReader>
#include <QImageWriter>
#include <QLabel>
#include <QMenuBar>
#include <QMessageBox>
#include <QMimeData>
#include <QPainter>
#include <QScreen>
#include <QScrollArea>
#include <QScrollBar>
#include <QStandardPaths>
#include <QStatusBar>
#if defined(QT_PRINTSUPPORT_LIB)
#include <QtPrintSupport/qtprintsupportglobal.h>
#if QT_CONFIG(printdialog)
@ -60,8 +77,8 @@
//! [0]
ImageViewer::ImageViewer(QWidget *parent)
: QMainWindow(parent), imageLabel(new QLabel),
scrollArea(new QScrollArea), scaleFactor(1)
: QMainWindow(parent), imageLabel(new QLabel)
, scrollArea(new QScrollArea)
{
imageLabel->setBackgroundRole(QPalette::Base);
imageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);

View File

@ -98,7 +98,7 @@ private:
QImage image;
QLabel *imageLabel;
QScrollArea *scrollArea;
double scaleFactor;
double scaleFactor = 1;
#ifndef QT_NO_PRINTER
QPrinter printer;

View File

@ -48,10 +48,14 @@
**
****************************************************************************/
#include <QtWidgets>
#include "window.h"
#include <QComboBox>
#include <QGridLayout>
#include <QGroupBox>
#include <QLabel>
#include <QLineEdit>
//! [0]
Window::Window(QWidget *parent)
: QWidget(parent)
@ -197,6 +201,7 @@ void Window::echoChanged(int index)
break;
case 3:
echoLineEdit->setEchoMode(QLineEdit::NoEcho);
break;
}
}
//! [9]
@ -215,6 +220,7 @@ void Window::validatorChanged(int index)
case 2:
validatorLineEdit->setValidator(new QDoubleValidator(-999.0,
999.0, 2, validatorLineEdit));
break;
}
validatorLineEdit->clear();
@ -233,6 +239,7 @@ void Window::alignmentChanged(int index)
break;
case 2:
alignmentLineEdit->setAlignment(Qt::AlignRight);
break;
}
}
//! [11]
@ -254,6 +261,7 @@ void Window::inputMaskChanged(int index)
break;
case 3:
inputMaskLineEdit->setInputMask(">AAAAA-AAAAA-AAAAA-AAAAA-AAAAA;#");
break;
}
}
//! [12]
@ -267,6 +275,7 @@ void Window::accessChanged(int index)
break;
case 1:
accessLineEdit->setReadOnly(true);
break;
}
}
//! [13]

View File

@ -50,7 +50,15 @@
#include "movieplayer.h"
#include <QtWidgets>
#include <QCheckBox>
#include <QFileDialog>
#include <QLabel>
#include <QMovie>
#include <QSlider>
#include <QSpinBox>
#include <QStyle>
#include <QToolButton>
#include <QVBoxLayout>
MoviePlayer::MoviePlayer(QWidget *parent)
: QWidget(parent)

View File

@ -48,11 +48,17 @@
**
****************************************************************************/
#include <QtWidgets>
#include "mainwindow.h"
#include "scribblearea.h"
#include <QApplication>
#include <QColorDialog>
#include <QFileDialog>
#include <QImageWriter>
#include <QInputDialog>
#include <QMenuBar>
#include <QMessageBox>
//! [0]
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), scribbleArea(new ScribbleArea(this))
@ -71,12 +77,11 @@ MainWindow::MainWindow(QWidget *parent)
void MainWindow::closeEvent(QCloseEvent *event)
//! [1] //! [2]
{
if (maybeSave()) {
if (maybeSave())
event->accept();
} else {
else
event->ignore();
}
}
//! [2]
//! [3]
@ -231,12 +236,11 @@ bool MainWindow::maybeSave()
"Do you want to save your changes?"),
QMessageBox::Save | QMessageBox::Discard
| QMessageBox::Cancel);
if (ret == QMessageBox::Save) {
if (ret == QMessageBox::Save)
return saveFile("png");
} else if (ret == QMessageBox::Cancel) {
else if (ret == QMessageBox::Cancel)
return false;
}
}
return true;
}
//! [18]
@ -252,10 +256,8 @@ bool MainWindow::saveFile(const QByteArray &fileFormat)
tr("%1 Files (*.%2);;All Files (*)")
.arg(QString::fromLatin1(fileFormat.toUpper()))
.arg(QString::fromLatin1(fileFormat)));
if (fileName.isEmpty()) {
if (fileName.isEmpty())
return false;
} else {
return scribbleArea->saveImage(fileName, fileFormat.constData());
}
}
//! [20]

View File

@ -50,7 +50,9 @@
#include "scribblearea.h"
#include <QtWidgets>
#include <QMouseEvent>
#include <QPainter>
#if defined(QT_PRINTSUPPORT_LIB)
#include <QtPrintSupport/qtprintsupportglobal.h>
#if QT_CONFIG(printdialog)
@ -64,10 +66,6 @@ ScribbleArea::ScribbleArea(QWidget *parent)
: QWidget(parent)
{
setAttribute(Qt::WA_StaticContents);
modified = false;
scribbling = false;
myPenWidth = 1;
myPenColor = Qt::blue;
}
//! [0]
@ -98,9 +96,8 @@ bool ScribbleArea::saveImage(const QString &fileName, const char *fileFormat)
if (visibleImage.save(fileName, fileFormat)) {
modified = false;
return true;
} else {
return false;
}
return false;
}
//! [4]

View File

@ -88,10 +88,10 @@ private:
void drawLineTo(const QPoint &endPoint);
void resizeImage(QImage *image, const QSize &newSize);
bool modified;
bool scribbling;
int myPenWidth;
QColor myPenColor;
bool modified = false;
bool scribbling = false;
int myPenWidth = 1;
QColor myPenColor = Qt::blue;
QImage image;
QPoint lastPoint;
};

View File

@ -48,10 +48,15 @@
**
****************************************************************************/
#include <QtWidgets>
#include "shapedclock.h"
#include <QAction>
#include <QCoreApplication>
#include <QMouseEvent>
#include <QPainter>
#include <QTime>
#include <QTimer>
//! [0]
ShapedClock::ShapedClock(QWidget *parent)
: QWidget(parent, Qt::FramelessWindowHint | Qt::WindowSystemMenuHint)

View File

@ -50,7 +50,10 @@
#include "slidersgroup.h"
#include <QtWidgets>
#include <QBoxLayout>
#include <QDial>
#include <QScrollBar>
#include <QSlider>
//! [0]
SlidersGroup::SlidersGroup(Qt::Orientation orientation, const QString &title,

View File

@ -48,11 +48,16 @@
**
****************************************************************************/
#include <QtWidgets>
#include "slidersgroup.h"
#include "window.h"
#include <QCheckBox>
#include <QComboBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QSpinBox>
#include <QStackedWidget>
//! [0]
Window::Window(QWidget *parent)
: QWidget(parent)

View File

@ -48,10 +48,16 @@
**
****************************************************************************/
#include <QtWidgets>
#include "window.h"
#include <QCheckBox>
#include <QComboBox>
#include <QDateTimeEdit>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QSpinBox>
//! [0]
Window::Window(QWidget *parent)
: QWidget(parent)

View File

@ -50,7 +50,10 @@
#include "norwegianwoodstyle.h"
#include <QtWidgets>
#include <QComboBox>
#include <QPainter>
#include <QPushButton>
#include <QStyleFactory>
NorwegianWoodStyle::NorwegianWoodStyle() :
QProxyStyle(QStyleFactory::create("windows"))

View File

@ -51,7 +51,24 @@
#include "widgetgallery.h"
#include "norwegianwoodstyle.h"
#include <QtWidgets>
#include <QApplication>
#include <QCheckBox>
#include <QComboBox>
#include <QDateTimeEdit>
#include <QDial>
#include <QGridLayout>
#include <QGroupBox>
#include <QLabel>
#include <QLineEdit>
#include <QProgressBar>
#include <QPushButton>
#include <QRadioButton>
#include <QScrollBar>
#include <QSpinBox>
#include <QStyleFactory>
#include <QTableWidget>
#include <QTextEdit>
#include <QTimer>
//! [0]
WidgetGallery::WidgetGallery(QWidget *parent)

View File

@ -48,7 +48,7 @@
**
****************************************************************************/
#include <QtWidgets>
#include <QApplication>
#include "mainwindow.h"

View File

@ -48,11 +48,11 @@
**
****************************************************************************/
#include <QtWidgets>
#include "mainwindow.h"
#include "stylesheeteditor.h"
#include <QMessageBox>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{

View File

@ -51,7 +51,7 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QtWidgets>
#include <QMainWindow>
#include "ui_mainwindow.h"

View File

@ -50,7 +50,9 @@
#include "stylesheeteditor.h"
#include <QtWidgets>
#include <QFile>
#include <QRegularExpression>
#include <QStyleFactory>
StyleSheetEditor::StyleSheetEditor(QWidget *parent)
: QDialog(parent)

View File

@ -48,8 +48,6 @@
**
****************************************************************************/
#include <QtWidgets>
#include "mainwindow.h"
#include "tabletapplication.h"
#include "tabletcanvas.h"

View File

@ -48,14 +48,19 @@
**
****************************************************************************/
#include <QtWidgets>
#include "mainwindow.h"
#include "tabletcanvas.h"
#include <QApplication>
#include <QColorDialog>
#include <QDir>
#include <QFileDialog>
#include <QMenuBar>
#include <QMessageBox>
//! [0]
MainWindow::MainWindow(TabletCanvas *canvas)
: m_canvas(canvas), m_colorDialog(nullptr)
: m_canvas(canvas)
{
createMenus();
setWindowTitle(tr("Tablet Example"));

View File

@ -81,7 +81,7 @@ private:
void createMenus();
TabletCanvas *m_canvas;
QColorDialog *m_colorDialog;
QColorDialog *m_colorDialog = nullptr;
};
//! [0]

View File

@ -50,8 +50,6 @@
#include "tabletapplication.h"
#include <QtWidgets>
//! [0]
bool TabletApplication::event(QEvent *event)
{

View File

@ -48,21 +48,16 @@
**
****************************************************************************/
#include <QtWidgets>
#include <math.h>
#include "tabletcanvas.h"
#include <QCoreApplication>
#include <QPainter>
#include <QtMath>
//! [0]
TabletCanvas::TabletCanvas()
: QWidget(nullptr)
, m_alphaChannelValuator(TangentialPressureValuator)
, m_colorSaturationValuator(NoValuator)
, m_lineWidthValuator(PressureValuator)
, m_color(Qt::red)
, m_brush(m_color)
: QWidget(nullptr), m_brush(m_color)
, m_pen(m_brush, 1.0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)
, m_deviceDown(false)
{
resize(500, 500);
setAutoFillBackground(true);
@ -138,7 +133,7 @@ void TabletCanvas::tabletEvent(QTabletEvent *event)
void TabletCanvas::initPixmap()
{
qreal dpr = devicePixelRatioF();
QPixmap newPixmap = QPixmap(width() * dpr, height() * dpr);
QPixmap newPixmap = QPixmap(qRound(width() * dpr), qRound(height() * dpr));
newPixmap.setDevicePixelRatio(dpr);
newPixmap.fill(Qt::white);
QPainter painter(&newPixmap);
@ -208,7 +203,7 @@ void TabletCanvas::paintPixmap(QPainter &painter, QTabletEvent *event)
const QString error(tr("This input device is not supported by the example."));
#if QT_CONFIG(statustip)
QStatusTipEvent status(error);
QApplication::sendEvent(this, &status);
QCoreApplication::sendEvent(this, &status);
#else
qWarning() << error;
#endif
@ -219,7 +214,7 @@ void TabletCanvas::paintPixmap(QPainter &painter, QTabletEvent *event)
const QString error(tr("Unknown tablet device - treating as stylus"));
#if QT_CONFIG(statustip)
QStatusTipEvent status(error);
QApplication::sendEvent(this, &status);
QCoreApplication::sendEvent(this, &status);
#else
qWarning() << error;
#endif
@ -261,7 +256,8 @@ void TabletCanvas::updateBrush(const QTabletEvent *event)
m_color.setAlpha(255);
break;
case TiltValuator:
m_color.setAlpha(maximum(abs(vValue - 127), abs(hValue - 127)));
m_color.setAlpha(std::max(std::abs(vValue - 127),
std::abs(hValue - 127)));
break;
default:
m_color.setAlpha(255);
@ -288,7 +284,8 @@ void TabletCanvas::updateBrush(const QTabletEvent *event)
m_pen.setWidthF(pressureToWidth(event->pressure()));
break;
case TiltValuator:
m_pen.setWidthF(maximum(abs(vValue - 127), abs(hValue - 127)) / 12);
m_pen.setWidthF(std::max(std::abs(vValue - 127),
std::abs(hValue - 127)) / 12);
break;
default:
m_pen.setWidthF(1);

View File

@ -51,14 +51,13 @@
#ifndef TABLETCANVAS_H
#define TABLETCANVAS_H
#include <QWidget>
#include <QBrush>
#include <QColor>
#include <QPen>
#include <QPixmap>
#include <QPoint>
#include <QTabletEvent>
#include <QColor>
#include <QBrush>
#include <QPen>
#include <QPoint>
#include <QWidget>
QT_BEGIN_NAMESPACE
class QPaintEvent;
@ -92,8 +91,6 @@ public:
{ return m_color; }
void setTabletDevice(QTabletEvent *event)
{ updateCursor(event); }
int maximum(int a, int b)
{ return a > b ? a : b; }
protected:
void tabletEvent(QTabletEvent *event) override;
@ -108,19 +105,19 @@ private:
void updateBrush(const QTabletEvent *event);
void updateCursor(const QTabletEvent *event);
Valuator m_alphaChannelValuator;
Valuator m_colorSaturationValuator;
Valuator m_lineWidthValuator;
QColor m_color;
Valuator m_alphaChannelValuator = TangentialPressureValuator;
Valuator m_colorSaturationValuator = NoValuator;
Valuator m_lineWidthValuator = PressureValuator;
QColor m_color = Qt::red;
QPixmap m_pixmap;
QBrush m_brush;
QPen m_pen;
bool m_deviceDown;
bool m_deviceDown = false;
struct Point {
QPointF pos;
qreal pressure;
qreal rotation;
qreal pressure = 0;
qreal rotation = 0;
} lastPoint;
};
//! [0]

View File

@ -50,16 +50,16 @@
#include "tetrixboard.h"
#include <QtWidgets>
#include <QKeyEvent>
#include <QLabel>
#include <QPainter>
//! [0]
TetrixBoard::TetrixBoard(QWidget *parent)
: QFrame(parent)
: QFrame(parent), isStarted(false), isPaused(false)
{
setFrameStyle(QFrame::Panel | QFrame::Sunken);
setFocusPolicy(Qt::StrongFocus);
isStarted = false;
isPaused = false;
clearBoard();
nextPiece.setRandomShape();
@ -396,7 +396,7 @@ bool TetrixBoard::tryMove(const TetrixPiece &newPiece, int newX, int newY)
//! [36]
void TetrixBoard::drawSquare(QPainter &painter, int x, int y, TetrixShape shape)
{
static const QRgb colorTable[8] = {
static constexpr QRgb colorTable[8] = {
0x000000, 0xCC6666, 0x66CC66, 0x6666CC,
0xCCCC66, 0xCC66CC, 0x66CCCC, 0xDAAA00
};

View File

@ -62,7 +62,7 @@ void TetrixPiece::setRandomShape()
//! [1]
void TetrixPiece::setShape(TetrixShape shape)
{
static const int coordsTable[8][4][2] = {
static constexpr int coordsTable[8][4][2] = {
{ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } },
{ { 0, -1 }, { 0, 0 }, { -1, 0 }, { -1, 1 } },
{ { 0, -1 }, { 0, 0 }, { 1, 0 }, { 1, 1 } },

View File

@ -48,23 +48,24 @@
**
****************************************************************************/
#include <QtWidgets>
#include "tetrixboard.h"
#include "tetrixwindow.h"
#include <QCoreApplication>
#include <QGridLayout>
#include <QLabel>
#include <QLCDNumber>
#include <QPushButton>
//! [0]
TetrixWindow::TetrixWindow(QWidget *parent)
: QWidget(parent)
: QWidget(parent), board(new TetrixBoard)
{
board = new TetrixBoard;
//! [0]
nextPieceLabel = new QLabel;
nextPieceLabel->setFrameStyle(QFrame::Box | QFrame::Raised);
nextPieceLabel->setAlignment(Qt::AlignCenter);
board->setNextPieceLabel(nextPieceLabel);
//! [1]
scoreLcd = new QLCDNumber(5);
scoreLcd->setSegmentStyle(QLCDNumber::Filled);
@ -86,7 +87,7 @@ TetrixWindow::TetrixWindow(QWidget *parent)
connect(startButton, &QPushButton::clicked, board, &TetrixBoard::start);
//! [4] //! [5]
connect(quitButton , &QPushButton::clicked, qApp, &QApplication::quit);
connect(quitButton , &QPushButton::clicked, qApp, &QCoreApplication::quit);
connect(pauseButton, &QPushButton::clicked, board, &TetrixBoard::pause);
#if __cplusplus >= 201402L
connect(board, &TetrixBoard::scoreChanged,

View File

@ -48,7 +48,7 @@
**
****************************************************************************/
#include <QtWidgets>
#include <QApplication>
#include "sortingbox.h"

View File

@ -50,7 +50,13 @@
#include "sortingbox.h"
#include <QtWidgets>
#include <QMouseEvent>
#include <QIcon>
#include <QPainter>
#include <QRandomGenerator>
#include <QStyle>
#include <QToolButton>
#include <QToolTip>
//! [0]
SortingBox::SortingBox(QWidget *parent)
@ -277,12 +283,12 @@ QToolButton *SortingBox::createToolButton(const QString &toolTip,
QPoint SortingBox::initialItemPosition(const QPainterPath &path)
{
int x;
int y = (height() - (int)path.controlPointRect().height()) / 2;
int y = (height() - qRound(path.controlPointRect().height()) / 2);
if (shapeItems.size() == 0)
x = ((3 * width()) / 2 - (int)path.controlPointRect().width()) / 2;
x = ((3 * width()) / 2 - qRound(path.controlPointRect().width())) / 2;
else
x = (width() / shapeItems.size()
- (int)path.controlPointRect().width()) / 2;
- qRound(path.controlPointRect().width())) / 2;
return QPoint(x, y);
}

View File

@ -99,7 +99,7 @@ private:
const char *member);
//! [2]
QList<ShapeItem> shapeItems;
QVector<ShapeItem> shapeItems;
QPainterPath circlePath;
QPainterPath squarePath;
QPainterPath trianglePath;

View File

@ -50,7 +50,7 @@
#include "validatorwidget.h"
#include <QtWidgets>
#include <QIntValidator>
ValidatorWidget::ValidatorWidget(QWidget *parent)
: QWidget(parent)

View File

@ -50,11 +50,13 @@
#include "wigglywidget.h"
#include <QtWidgets>
#include <QFontMetrics>
#include <QPainter>
#include <QTimerEvent>
//! [0]
WigglyWidget::WigglyWidget(QWidget *parent)
: QWidget(parent)
: QWidget(parent), step(0)
{
setBackgroundRole(QPalette::Midlight);
setAutoFillBackground(true);
@ -63,7 +65,6 @@ WigglyWidget::WigglyWidget(QWidget *parent)
newFont.setPointSize(newFont.pointSize() + 20);
setFont(newFont);
step = 0;
timer.start(60, this);
}
//! [0]
@ -72,7 +73,7 @@ WigglyWidget::WigglyWidget(QWidget *parent)
void WigglyWidget::paintEvent(QPaintEvent * /* event */)
//! [1] //! [2]
{
static const int sineTable[16] = {
static constexpr int sineTable[16] = {
0, 38, 71, 92, 100, 92, 71, 38, 0, -38, -71, -92, -100, -92, -71, -38
};

View File

@ -48,10 +48,15 @@
**
****************************************************************************/
#include <QtWidgets>
#include "controllerwindow.h"
#include <QCheckBox>
#include <QCoreApplication>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QPushButton>
#include <QRadioButton>
//! [0]
ControllerWindow::ControllerWindow(QWidget *parent)
: QWidget(parent)
@ -63,7 +68,7 @@ ControllerWindow::ControllerWindow(QWidget *parent)
quitButton = new QPushButton(tr("&Quit"));
connect(quitButton, &QPushButton::clicked,
qApp, &QApplication::quit);
qApp, &QCoreApplication::quit);
QHBoxLayout *bottomLayout = new QHBoxLayout;
bottomLayout->addStretch();
@ -83,26 +88,25 @@ ControllerWindow::ControllerWindow(QWidget *parent)
//! [1]
void ControllerWindow::updatePreview()
{
Qt::WindowFlags flags = 0;
Qt::WindowFlags flags;
if (windowRadioButton->isChecked()) {
if (windowRadioButton->isChecked())
flags = Qt::Window;
} else if (dialogRadioButton->isChecked()) {
else if (dialogRadioButton->isChecked())
flags = Qt::Dialog;
} else if (sheetRadioButton->isChecked()) {
else if (sheetRadioButton->isChecked())
flags = Qt::Sheet;
} else if (drawerRadioButton->isChecked()) {
else if (drawerRadioButton->isChecked())
flags = Qt::Drawer;
} else if (popupRadioButton->isChecked()) {
else if (popupRadioButton->isChecked())
flags = Qt::Popup;
} else if (toolRadioButton->isChecked()) {
else if (toolRadioButton->isChecked())
flags = Qt::Tool;
} else if (toolTipRadioButton->isChecked()) {
else if (toolTipRadioButton->isChecked())
flags = Qt::ToolTip;
} else if (splashScreenRadioButton->isChecked()) {
else if (splashScreenRadioButton->isChecked())
flags = Qt::SplashScreen;
//! [1] //! [2]
}
//! [2] //! [3]
if (msWindowsFixedSizeDialogCheckBox->isChecked())

View File

@ -50,7 +50,9 @@
#include "previewwindow.h"
#include <QtWidgets>
#include <QPushButton>
#include <QTextEdit>
#include <QVBoxLayout>
//! [0]
PreviewWindow::PreviewWindow(QWidget *parent)
@ -81,23 +83,22 @@ void PreviewWindow::setWindowFlags(Qt::WindowFlags flags)
QString text;
Qt::WindowFlags type = (flags & Qt::WindowType_Mask);
if (type == Qt::Window) {
if (type == Qt::Window)
text = "Qt::Window";
} else if (type == Qt::Dialog) {
else if (type == Qt::Dialog)
text = "Qt::Dialog";
} else if (type == Qt::Sheet) {
else if (type == Qt::Sheet)
text = "Qt::Sheet";
} else if (type == Qt::Drawer) {
else if (type == Qt::Drawer)
text = "Qt::Drawer";
} else if (type == Qt::Popup) {
else if (type == Qt::Popup)
text = "Qt::Popup";
} else if (type == Qt::Tool) {
else if (type == Qt::Tool)
text = "Qt::Tool";
} else if (type == Qt::ToolTip) {
else if (type == Qt::ToolTip)
text = "Qt::ToolTip";
} else if (type == Qt::SplashScreen) {
else if (type == Qt::SplashScreen)
text = "Qt::SplashScreen";
}
if (flags & Qt::MSWindowsFixedSizeDialogHint)
text += "\n| Qt::MSWindowsFixedSizeDialogHint";

View File

@ -17,7 +17,7 @@ include(g++-base.conf)
MAKEFILE_GENERATOR = MINGW
QMAKE_PLATFORM = win32 mingw
CONFIG += debug_and_release debug_and_release_target precompile_header
CONFIG += precompile_header
DEFINES += UNICODE _UNICODE WIN32 MINGW_HAS_SECURE_API=1
QMAKE_COMPILER_DEFINES += __GNUC__ _WIN32
# can't add 'DEFINES += WIN64' and 'QMAKE_COMPILER_DEFINES += _WIN64' defines for

View File

@ -19,6 +19,7 @@ CONFIG += flat debug_and_release debug_and_release_target precom
# MSVC 2017 15.8+ fixed std::aligned_storage but compilation fails without
# _ENABLE_EXTENDED_ALIGNED_STORAGE flag since the fix breaks binary compatibility.
DEFINES += UNICODE _UNICODE WIN32 _ENABLE_EXTENDED_ALIGNED_STORAGE
DEFINES_RELEASE += NDEBUG
QMAKE_COMPILER_DEFINES += _WIN32
contains(QMAKE_TARGET.arch, x86_64) {
DEFINES += WIN64

View File

@ -11,6 +11,7 @@ CONFIG = package_manifest $$CONFIG incremental flat precompile_
# MSVC 2017 15.8+ fixed std::aligned_storage but compilation fails without
# _ENABLE_EXTENDED_ALIGNED_STORAGE flag since the fix breaks binary compatibility.
DEFINES += UNICODE WIN32 QT_LARGEFILE_SUPPORT Q_BYTE_ORDER=Q_LITTLE_ENDIAN _ENABLE_EXTENDED_ALIGNED_STORAGE
DEFINES_RELEASE += NDEBUG
QMAKE_COMPILER_DEFINES += _WIN32
DEPLOYMENT_PLUGIN += qwinrt

View File

@ -26,4 +26,10 @@ CONFIG = \
unset(today)
}
CONFIG(debug, debug|release) {
DEFINES += $$DEFINES_DEBUG
} else {
DEFINES += $$DEFINES_RELEASE
}
load(toolchain)

View File

@ -5,7 +5,7 @@ defineReplace(qtPlatformTargetSuffix) {
else: CONFIG(debug, debug|release) {
!debug_and_release|build_pass {
mac: return($${suffix}_debug)
win32: return($${suffix}d)
win32:!gcc: return($${suffix}d)
}
}
return($$suffix)

View File

@ -9,7 +9,7 @@ uic.depend_command = $$QMAKE_UIC_DEP -d ${QMAKE_FILE_IN}
uic.output = $$UI_DIR/$${QMAKE_MOD_UIC}${QMAKE_FILE_BASE}$${first(QMAKE_EXT_H)}
uic.input = FORMS
uic.variable_out = GENERATED_FILES
uic.CONFIG += no_link target_predeps dep_lines
uic.CONFIG += no_link target_predeps dep_lines dep_existing_only
uic.name = UIC ${QMAKE_FILE_IN}
silent:uic.commands = @echo uic ${QMAKE_FILE_IN} && $$uic.commands
QMAKE_EXTRA_COMPILERS += uic

View File

@ -3,6 +3,11 @@ isEmpty(QMAKE_INCDIR_VULKAN) {
# headers are found out-of-the-box on typical Windows setups.
QMAKE_INCDIR_VULKAN = $$(VULKAN_SDK)/include
# Do not add default include paths as that can knock std headers
# out of their stride due to their usage of #include_next.
contains(QMAKE_DEFAULT_INCDIRS, $$QMAKE_INCDIR_VULKAN): \
QMAKE_INCDIR_VULKAN =
# Do not export the include dir but resolve it on every qmake call.
QMAKE_EXPORT_INCDIR_VULKAN = -
}

View File

@ -1144,6 +1144,26 @@
\snippet code/doc_src_qmake-manual.pro 27
\target DEFINES_DEBUG
\section1 DEFINES_DEBUG
Specifies preprocessor defines for the debug configuration. The values of
this variable get added to \l{DEFINES} before the project is loaded. This
variable is typically set in \l{#QMAKESPEC}{qmake.conf} and rarely needs
to be modified.
This variable was introduced in Qt 5.13.2.
\target DEFINES_RELEASE
\section1 DEFINES_RELEASE
Specifies preprocessor defines for the release configuration. The values of
this variable get added to \l{DEFINES} before the project is loaded. This
variable is typically set in \l{#QMAKESPEC}{qmake.conf} and rarely needs
to be modified.
This variable was introduced in Qt 5.13.2.
\target DEF_FILE
\section1 DEF_FILE
@ -4795,6 +4815,11 @@
\li explicit_dependencies
\li The dependencies for the output only get generated from the depends
member and from nowhere else.
\row
\li dep_existing_only
\li Every dependency that is a result of .depend_command is checked for
existence. Non-existing dependencies are ignored.
This value was introduced in Qt 5.13.2.
\row
\li dep_lines
\li The output from the .depend_command is interpreted to be one file

View File

@ -1856,7 +1856,8 @@ void MakefileGenerator::callExtraCompilerDependCommand(const ProString &extraCom
const QString &inpf,
const QString &tmp_out,
bool dep_lines,
QStringList *deps)
QStringList *deps,
bool existingDepsOnly)
{
char buff[256];
QString dep_cmd = replaceExtraCompilerVariables(tmp_dep_cmd, inpf, tmp_out, LocalShell);
@ -1885,6 +1886,8 @@ void MakefileGenerator::callExtraCompilerDependCommand(const ProString &extraCom
warn_msg(WarnDeprecated, ".depend_command for extra compiler %s"
" prints paths relative to source directory",
extraCompiler.toLatin1().constData());
} else if (existingDepsOnly) {
file.clear();
} else {
file = absFile; // fallback for generated resources
}
@ -2013,6 +2016,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
}
t << Qt::endl;
}
const bool existingDepsOnly = config.contains("dep_existing_only");
QStringList tmp_dep = project->values(ProKey(*it + ".depends")).toQStringList();
if (config.indexOf("combine") != -1) {
if (tmp_out.contains(QRegExp("(^|[^$])\\$\\{QMAKE_(?!VAR_)"))) {
@ -2029,7 +2033,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
inputs += Option::fixPathToTargetOS(inpf, false);
if(!tmp_dep_cmd.isEmpty() && doDepends()) {
callExtraCompilerDependCommand(*it, dep_cd_cmd, tmp_dep_cmd, inpf,
tmp_out, dep_lines, &deps);
tmp_out, dep_lines, &deps, existingDepsOnly);
}
}
for(int i = 0; i < inputs.size(); ) {
@ -2078,7 +2082,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
cmd.replace("$(" + (*it3) + ")", "$(QMAKE_COMP_" + (*it3)+")");
if(!tmp_dep_cmd.isEmpty() && doDepends()) {
callExtraCompilerDependCommand(*it, dep_cd_cmd, tmp_dep_cmd, inpf,
tmp_out, dep_lines, &deps);
tmp_out, dep_lines, &deps, existingDepsOnly);
//use the depend system to find includes of these included files
QStringList inc_deps;
for(int i = 0; i < deps.size(); ++i) {

View File

@ -86,7 +86,8 @@ protected:
QString resolveDependency(const QDir &outDir, const QString &file);
void callExtraCompilerDependCommand(const ProString &extraCompiler, const QString &dep_cd_cmd,
const QString &tmp_dep_cmd, const QString &inpf,
const QString &tmp_out, bool dep_lines, QStringList *deps);
const QString &tmp_out, bool dep_lines, QStringList *deps,
bool existingDepsOnly);
void writeExtraCompilerTargets(QTextStream &t);
void writeExtraCompilerVariables(QTextStream &t);
bool writeDummyMakefile(QTextStream &t);

View File

@ -272,10 +272,6 @@ void NmakeMakefileGenerator::init()
if (project->isActiveConfig("debug")) {
project->values("QMAKE_CLEAN").append(targetBase + ".ilk");
project->values("QMAKE_CLEAN").append(targetBase + ".idb");
} else {
ProStringList &defines = project->values("DEFINES");
if (!defines.contains("NDEBUG"))
defines.append("NDEBUG");
}
if (project->values("QMAKE_APP_FLAG").isEmpty() && project->isActiveConfig("dll")) {

View File

@ -2126,7 +2126,6 @@ VCResourceCompilerTool::VCResourceCompilerTool()
ShowProgress(linkProgressNotSet),
SuppressStartupBanner(unset)
{
PreprocessorDefinitions = QStringList("NDEBUG");
}
// VCDeploymentTool --------------------------------------------

View File

@ -1050,9 +1050,6 @@ void VcprojGenerator::initConfiguration()
initDeploymentTool();
initWinDeployQtTool();
initPreLinkEventTools();
if (!isDebug)
conf.compiler.PreprocessorDefinitions += "NDEBUG";
}
void VcprojGenerator::initCompilerTool()

View File

@ -53,6 +53,7 @@ CONFIG(debug, debug|release) {
}
!isEmpty(BUILD_PASS): BUILDSUBDIR = $$lower($$BUILD_PASS)/
else: BUILDSUBDIR = $$PWD/
# c++11 is needed by MinGW to get support for unordered_map.
CONFIG += stl exceptions c++11 c++14

View File

@ -74,7 +74,7 @@ QT_BEGIN_NAMESPACE
# define QLIBRARY_AS_DEBUG true
#endif
#if defined(Q_OS_UNIX)
#if defined(Q_OS_UNIX) || (defined(Q_CC_MINGW) && !QT_CONFIG(debug_and_release))
// We don't use separate debug and release libs on UNIX, so we want
// to allow loading plugins, regardless of how they were built.
# define QT_NO_DEBUG_PLUGIN_CHECK

View File

@ -50,8 +50,6 @@
#include "private/qfreelist_p.h"
#include "private/qlocking_p.h"
#include <chrono>
QT_BEGIN_NAMESPACE
/*
@ -67,9 +65,6 @@ QT_BEGIN_NAMESPACE
*/
namespace {
using ms = std::chrono::milliseconds;
enum {
StateMask = 0x3,
StateLockedForRead = 0x1,
@ -279,7 +274,7 @@ bool QReadWriteLock::tryLockForRead(int timeout)
d = d_ptr.loadAcquire();
continue;
}
return d->lockForRead(lock, timeout);
return d->lockForRead(timeout);
}
}
@ -383,7 +378,7 @@ bool QReadWriteLock::tryLockForWrite(int timeout)
d = d_ptr.loadAcquire();
continue;
}
return d->lockForWrite(lock, timeout);
return d->lockForWrite(timeout);
}
}
@ -466,9 +461,9 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co
}
bool QReadWriteLockPrivate::lockForRead(std::unique_lock<std::mutex> &lock, int timeout)
bool QReadWriteLockPrivate::lockForRead(int timeout)
{
Q_ASSERT(!mutex.try_lock()); // mutex must be locked when entering this function
Q_ASSERT(!mutex.tryLock()); // mutex must be locked when entering this function
QElapsedTimer t;
if (timeout > 0)
@ -482,10 +477,10 @@ bool QReadWriteLockPrivate::lockForRead(std::unique_lock<std::mutex> &lock, int
if (elapsed > timeout)
return false;
waitingReaders++;
readerCond.wait_for(lock, ms{timeout - elapsed});
readerCond.wait(&mutex, timeout - elapsed);
} else {
waitingReaders++;
readerCond.wait(lock);
readerCond.wait(&mutex);
}
waitingReaders--;
}
@ -494,9 +489,9 @@ bool QReadWriteLockPrivate::lockForRead(std::unique_lock<std::mutex> &lock, int
return true;
}
bool QReadWriteLockPrivate::lockForWrite(std::unique_lock<std::mutex> &lock, int timeout)
bool QReadWriteLockPrivate::lockForWrite(int timeout)
{
Q_ASSERT(!mutex.try_lock()); // mutex must be locked when entering this function
Q_ASSERT(!mutex.tryLock()); // mutex must be locked when entering this function
QElapsedTimer t;
if (timeout > 0)
@ -511,15 +506,15 @@ bool QReadWriteLockPrivate::lockForWrite(std::unique_lock<std::mutex> &lock, int
if (waitingReaders && !waitingWriters && !writerCount) {
// We timed out and now there is no more writers or waiting writers, but some
// readers were queueud (probably because of us). Wake the waiting readers.
readerCond.notify_all();
readerCond.wakeAll();
}
return false;
}
waitingWriters++;
writerCond.wait_for(lock, ms{timeout - elapsed});
writerCond.wait(&mutex, timeout - elapsed);
} else {
waitingWriters++;
writerCond.wait(lock);
writerCond.wait(&mutex);
}
waitingWriters--;
}
@ -532,11 +527,11 @@ bool QReadWriteLockPrivate::lockForWrite(std::unique_lock<std::mutex> &lock, int
void QReadWriteLockPrivate::unlock()
{
Q_ASSERT(!mutex.try_lock()); // mutex must be locked when entering this function
Q_ASSERT(!mutex.tryLock()); // mutex must be locked when entering this function
if (waitingWriters)
writerCond.notify_one();
writerCond.wakeOne();
else if (waitingReaders)
readerCond.notify_all();
readerCond.wakeAll();
}
bool QReadWriteLockPrivate::recursiveLockForRead(int timeout)
@ -552,7 +547,7 @@ bool QReadWriteLockPrivate::recursiveLockForRead(int timeout)
return true;
}
if (!lockForRead(lock, timeout))
if (!lockForRead(timeout))
return false;
currentReaders.insert(self, 1);
@ -570,7 +565,7 @@ bool QReadWriteLockPrivate::recursiveLockForWrite(int timeout)
return true;
}
if (!lockForWrite(lock, timeout))
if (!lockForWrite(timeout))
return false;
currentWriter = self;

View File

@ -54,9 +54,7 @@
#include <QtCore/private/qglobal_p.h>
#include <QtCore/qhash.h>
#include <mutex>
#include <condition_variable>
#include <QtCore/qwaitcondition.h>
QT_REQUIRE_CONFIG(thread);
@ -68,9 +66,9 @@ public:
explicit QReadWriteLockPrivate(bool isRecursive = false)
: recursive(isRecursive) {}
std::mutex mutex;
std::condition_variable writerCond;
std::condition_variable readerCond;
QMutex mutex;
QWaitCondition writerCond;
QWaitCondition readerCond;
int readerCount = 0;
int writerCount = 0;
int waitingReaders = 0;
@ -78,8 +76,8 @@ public:
const bool recursive;
//Called with the mutex locked
bool lockForWrite(std::unique_lock<std::mutex> &lock, int timeout);
bool lockForRead(std::unique_lock<std::mutex> &lock, int timeout);
bool lockForWrite(int timeout);
bool lockForRead(int timeout);
void unlock();
//memory management

View File

@ -1,18 +1,22 @@
# custom tests
defineTest(qtConfLibrary_freetype) {
input = $$eval($${2}.alias)
isEmpty(config.input.$${input}.incdir) {
TRY_INCLUDEPATHS = $$EXTRA_INCLUDEPATH $$QMAKE_INCDIR_X11
haiku: TRY_INCLUDEPATHS += /system/develop/headers
TRY_INCLUDEPATHS += $$QMAKE_DEFAULT_INCDIR
TRY_INCLUDEPATHS += $$QMAKE_DEFAULT_INCDIRS
for (p, TRY_INCLUDEPATHS) {
includedir = $$p/freetype2
exists($$includedir) {
$${1}.includedir = $$includedir
export($${1}.includedir)
return(true)
config.input.$${input}.incdir = $$includedir
export(config.input.$${input}.incdir)
break()
}
}
return(true)
}
qtConfLibrary_inline($$1, $$2): return(true)
return(false)
}
# Check for Direct X shader compiler 'fxc'.

View File

@ -931,6 +931,30 @@ QWheelEvent::~QWheelEvent()
\endlist
*/
/*!
\fn QPoint QWheelEvent::position() const
Returns the position of the mouse cursor relative to the widget
that received the event.
If you move your widgets around in response to mouse events,
use globalPosition() instead of this function.
\sa globalPosition()
*/
/*!
\fn QPoint QWheelEvent::globalPosition() const
Returns the global position of the mouse pointer \e{at the time
of the event}. This is important on asynchronous window systems
such as X11; whenever you move your widgets around in response to
mouse events, globalPosition() can differ a lot from the current
cursor position returned by QCursor::pos().
\sa position()
*/
#if QT_DEPRECATED_SINCE(5, 15)
/*!
\fn int QWheelEvent::delta() const

View File

@ -960,6 +960,7 @@ public:
friend class QGuiApplicationPrivate;
friend class QApplication;
friend class QApplicationPrivate;
friend class QQuickPointerTouchEvent;
};
#if QT_DEPRECATED_SINCE(5, 0)

View File

@ -67,7 +67,8 @@ public:
state(Qt::TouchPointReleased),
pressure(-1),
rotation(0),
ellipseDiameters(0, 0)
ellipseDiameters(0, 0),
stationaryWithModifiedProperty(false)
{ }
inline QTouchEventTouchPointPrivate *detach()
@ -91,6 +92,7 @@ public:
QSizeF ellipseDiameters;
QVector2D velocity;
QTouchEvent::TouchPoint::InfoFlags flags;
bool stationaryWithModifiedProperty : 1;
QVector<QPointF> rawScreenPositions;
};

View File

@ -1040,7 +1040,9 @@ QList<QScreen *> QGuiApplication::screens()
The \a point is in relation to the virtualGeometry() of each set of virtual
siblings. If the point maps to more than one set of virtual siblings the first
match is returned.
match is returned. If you wish to search only the virtual desktop siblings
of a known screen (for example siblings of the screen of your application
window \c QWidget::windowHandle()->screen()), use QScreen::virtualSiblingAt().
\since 5.10
*/
@ -2847,10 +2849,12 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
if (touchPoint.state() == Qt::TouchPointStationary) {
if (touchInfo.touchPoint.velocity() != touchPoint.velocity()) {
touchInfo.touchPoint.setVelocity(touchPoint.velocity());
touchPoint.d->stationaryWithModifiedProperty = true;
stationaryTouchPointChangedProperty = true;
}
if (!qFuzzyCompare(touchInfo.touchPoint.pressure(), touchPoint.pressure())) {
touchInfo.touchPoint.setPressure(touchPoint.pressure());
touchPoint.d->stationaryWithModifiedProperty = true;
stationaryTouchPointChangedProperty = true;
}
} else {

View File

@ -715,8 +715,10 @@ QHighDpiScaling::ScaleAndOrigin QHighDpiScaling::scaleAndOrigin(const QWindow *w
{
if (!m_active)
return { qreal(1), QPoint() };
QScreen *screen = window ? window->screen() : QGuiApplication::primaryScreen();
return scaleAndOrigin(screen, nativePosition);
const bool searchScreen = !window || window->isTopLevel();
return scaleAndOrigin(screen, searchScreen ? nativePosition : nullptr);
}
#endif //QT_NO_HIGHDPISCALING

View File

@ -699,6 +699,25 @@ void QScreenPrivate::updatePrimaryOrientation()
primaryOrientation = geometry.width() >= geometry.height() ? Qt::LandscapeOrientation : Qt::PortraitOrientation;
}
/*!
Returns the screen at \a point within the set of \l QScreen::virtualSiblings(),
or \c nullptr if outside of any screen.
The \a point is in relation to the virtualGeometry() of each set of virtual
siblings.
\since 5.15
*/
QScreen *QScreen::virtualSiblingAt(const QPoint &point)
{
const auto &siblings = virtualSiblings();
for (QScreen *sibling : siblings) {
if (sibling->geometry().contains(point))
return sibling;
}
return nullptr;
}
/*!
Creates and returns a pixmap constructed by grabbing the contents
of the given \a window restricted by QRect(\a x, \a y, \a width,

View File

@ -125,6 +125,7 @@ public:
QRect availableGeometry() const;
QList<QScreen *> virtualSiblings() const;
QScreen *virtualSiblingAt(const QPoint &point);
QSize virtualSize() const;
QRect virtualGeometry() const;

View File

@ -1022,7 +1022,7 @@ void QShaderDescriptionPrivate::loadDoc(const QJsonDocument &doc)
return;
}
Q_ASSERT(ref.load() == 1); // must be detached
Q_ASSERT(ref.loadRelaxed() == 1); // must be detached
inVars.clear();
outVars.clear();

View File

@ -1970,9 +1970,12 @@ void QTextDocument::print(QPagedPaintDevice *printer) const
QRectF body = QRectF(QPointF(0, 0), d->pageSize);
QPointF pageNumberPos;
qreal sourceDpiX = qt_defaultDpiX();
qreal sourceDpiY = qt_defaultDpiY();
const qreal dpiScaleX = qreal(printer->logicalDpiX()) / sourceDpiX;
const qreal dpiScaleY = qreal(printer->logicalDpiY()) / sourceDpiY;
if (documentPaginated) {
qreal sourceDpiX = qt_defaultDpi();
qreal sourceDpiY = sourceDpiX;
QPaintDevice *dev = doc->documentLayout()->paintDevice();
if (dev) {
@ -1980,9 +1983,6 @@ void QTextDocument::print(QPagedPaintDevice *printer) const
sourceDpiY = dev->logicalDpiY();
}
const qreal dpiScaleX = qreal(printer->logicalDpiX()) / sourceDpiX;
const qreal dpiScaleY = qreal(printer->logicalDpiY()) / sourceDpiY;
// scale to dpi
p.scale(dpiScaleX, dpiScaleY);
@ -2011,15 +2011,21 @@ void QTextDocument::print(QPagedPaintDevice *printer) const
// copy the custom object handlers
layout->d_func()->handlers = documentLayout()->d_func()->handlers;
int dpiy = p.device()->logicalDpiY();
int margin = (int) ((2/2.54)*dpiy); // 2 cm margins
// 2 cm margins, scaled to device in QTextDocumentLayoutPrivate::layoutFrame
const int horizontalMargin = int((2/2.54)*sourceDpiX);
const int verticalMargin = int((2/2.54)*sourceDpiY);
QTextFrameFormat fmt = doc->rootFrame()->frameFormat();
fmt.setMargin(margin);
fmt.setLeftMargin(horizontalMargin);
fmt.setRightMargin(horizontalMargin);
fmt.setTopMargin(verticalMargin);
fmt.setBottomMargin(verticalMargin);
doc->rootFrame()->setFrameFormat(fmt);
// pageNumberPos must be in device coordinates, so scale to device here
const int dpiy = p.device()->logicalDpiY();
body = QRectF(0, 0, printer->width(), printer->height());
pageNumberPos = QPointF(body.width() - margin,
body.height() - margin
pageNumberPos = QPointF(body.width() - horizontalMargin * dpiScaleX,
body.height() - verticalMargin * dpiScaleY
+ QFontMetrics(doc->defaultFont(), p.device()).ascent()
+ 5 * dpiy / 72.0);
clonedDoc->setPageSize(body.size());

View File

@ -2915,24 +2915,24 @@ QRectF QTextDocumentLayoutPrivate::layoutFrame(QTextFrame *f, int layoutFrom, in
{
QTextFrameFormat fformat = f->frameFormat();
// set sizes of this frame from the format
QFixed tm = QFixed::fromReal(fformat.topMargin());
QFixed tm = QFixed::fromReal(scaleToDevice(fformat.topMargin())).round();
if (tm != fd->topMargin) {
fd->topMargin = tm;
fullLayout = true;
}
QFixed bm = QFixed::fromReal(fformat.bottomMargin());
QFixed bm = QFixed::fromReal(scaleToDevice(fformat.bottomMargin())).round();
if (bm != fd->bottomMargin) {
fd->bottomMargin = bm;
fullLayout = true;
}
fd->leftMargin = QFixed::fromReal(fformat.leftMargin());
fd->rightMargin = QFixed::fromReal(fformat.rightMargin());
QFixed b = QFixed::fromReal(fformat.border());
fd->leftMargin = QFixed::fromReal(scaleToDevice(fformat.leftMargin())).round();
fd->rightMargin = QFixed::fromReal(scaleToDevice(fformat.rightMargin())).round();
QFixed b = QFixed::fromReal(scaleToDevice(fformat.border())).round();
if (b != fd->border) {
fd->border = b;
fullLayout = true;
}
QFixed p = QFixed::fromReal(fformat.padding());
QFixed p = QFixed::fromReal(scaleToDevice(fformat.padding())).round();
if (p != fd->padding) {
fd->padding = p;
fullLayout = true;

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
@ -493,8 +493,10 @@ template<> void QSharedDataPointer<QNetworkProxyPrivate>::detach()
}
/*!
Constructs a QNetworkProxy with DefaultProxy type; the proxy type is
determined by applicationProxy(), which defaults to NoProxy.
Constructs a QNetworkProxy with DefaultProxy type.
The proxy type is determined by applicationProxy(), which defaults to
NoProxy or a system-wide proxy if one is configured.
\sa setType(), setApplicationProxy()
*/

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2019 The Qt Company Ltd.
** Copyright (C) 2016 Jolla Ltd, author: <gunnar.sletta@jollamobile.com>
** Contact: https://www.qt.io/licensing/
**
@ -91,6 +91,9 @@ Q_LOGGING_CATEGORY(qLcEvdevTouch, "qt.qpa.input")
#ifndef ABS_MT_TRACKING_ID
#define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */
#endif
#ifndef ABS_MT_PRESSURE
#define ABS_MT_PRESSURE 0x3a
#endif
#ifndef SYN_MT_REPORT
#define SYN_MT_REPORT 2
#endif

View File

@ -81,6 +81,11 @@ void QWasmBackingStore::updateTexture()
if (m_dirty.isNull())
return;
if (m_recreateTexture && m_texture->isCreated()) {
m_recreateTexture = false;
m_texture->destroy();
}
if (!m_texture->isCreated()) {
m_texture->setMinificationFilter(QOpenGLTexture::Nearest);
m_texture->setMagnificationFilter(QOpenGLTexture::Nearest);
@ -146,9 +151,7 @@ void QWasmBackingStore::resize(const QSize &size, const QRegion &staticContents)
m_image = QImage(size * window()->devicePixelRatio(), QImage::Format_RGB32);
m_image.setDevicePixelRatio(window()->devicePixelRatio());
if (m_texture->isCreated())
m_texture->destroy();
m_recreateTexture = true;
}
QImage QWasmBackingStore::toImage() const

View File

@ -64,6 +64,7 @@ private:
QImage m_image;
QScopedPointer<QOpenGLTexture> m_texture;
QRegion m_dirty;
bool m_recreateTexture = false;
};
QT_END_NAMESPACE

View File

@ -139,6 +139,8 @@ QPlatformCursor *QWasmScreen::cursor() const
void QWasmScreen::resizeMaximizedWindows()
{
if (!screen())
return;
QPlatformScreen::resizeMaximizedWindows();
}

View File

@ -1937,8 +1937,10 @@ void QWindowsWindow::handleGeometryChange()
{
const QRect previousGeometry = m_data.geometry;
m_data.geometry = geometry_sys();
if (testFlag(WithinDpiChanged))
return; // QGuiApplication will send resize
if (testFlag(WithinDpiChanged)
&& QWindowsContext::instance()->screenManager().screenForHwnd(m_data.hwnd) != screen()) {
return; // QGuiApplication will send resize when screen actually changes
}
QWindowSystemInterface::handleGeometryChange(window(), m_data.geometry);
// QTBUG-32121: OpenGL/normal windows (with exception of ANGLE) do not receive
// expose events when shrinking, synthesize.

View File

@ -1914,7 +1914,12 @@ void QIBaseDriver::qHandleEventNotification(void *updatedResultBuffer)
if (counts[0]) {
if (eBuffer->subscriptionState == QIBaseEventBuffer::Subscribed) {
#if QT_DEPRECATED_SINCE(5, 15)
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
emit notification(i.key());
QT_WARNING_POP
#endif
emit notification(i.key(), QSqlDriver::UnknownSource, QVariant());
}
else if (eBuffer->subscriptionState == QIBaseEventBuffer::Starting)

View File

@ -1692,7 +1692,12 @@ void QPSQLDriver::_q_handleNotification(int)
if (notify->extra)
payload = d->isUtf8 ? QString::fromUtf8(notify->extra) : QString::fromLatin1(notify->extra);
#endif
#if QT_DEPRECATED_SINCE(5, 15)
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
emit notification(name);
QT_WARNING_POP
#endif
QSqlDriver::NotificationSource source = (notify->be_pid == PQbackendPID(d->connection)) ? QSqlDriver::SelfSource : QSqlDriver::OtherSource;
emit notification(name, source, payload);
}

View File

@ -1044,7 +1044,12 @@ void QSQLiteDriver::handleNotification(const QString &tableName, qint64 rowid)
{
Q_D(const QSQLiteDriver);
if (d->notificationid.contains(tableName)) {
#if QT_DEPRECATED_SINCE(5, 15)
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
emit notification(tableName);
QT_WARNING_POP
#endif
emit notification(tableName, QSqlDriver::UnknownSource, QVariant(rowid));
}
}

View File

@ -110,6 +110,9 @@ QSqlDriver::~QSqlDriver()
that the driver subscribes to. \a name identifies the event notification.
\sa subscribeToNotification()
\obsolete use QSqlDriver::notification(const QString &name, QSqlDriver::NotificationSource source, const QVariant &payload)
instead
*/
/*!

View File

@ -135,7 +135,10 @@ public Q_SLOTS:
virtual bool cancelQuery();
Q_SIGNALS:
#if QT_DEPRECATED_SINCE(5, 15)
QT_DEPRECATED_X("Use the 3-args version of notification() instead.")
void notification(const QString &name);
#endif
void notification(const QString &name, QSqlDriver::NotificationSource source, const QVariant &payload);
protected:

View File

@ -58,8 +58,7 @@
#include <QtCore/qdiriterator.h>
#include <QtCore/qtemporarydir.h>
#include <QtCore/qthread.h>
#include <QtCore/qwaitcondition.h>
#include <QtCore/qmutex.h>
#include <QtCore/private/qlocking_p.h>
#include <QtCore/qtestsupport_core.h>
@ -85,6 +84,9 @@
#include <cmath>
#include <numeric>
#include <algorithm>
#include <condition_variable>
#include <mutex>
#include <chrono>
#include <stdarg.h>
#include <stdio.h>
@ -406,7 +408,7 @@ int Q_TESTLIB_EXPORT defaultKeyDelay()
return keyDelay;
}
#if QT_CONFIG(thread)
static int defaultTimeout()
static std::chrono::milliseconds defaultTimeout()
{
if (timeout == -1) {
bool ok = false;
@ -415,7 +417,7 @@ static int defaultTimeout()
if (!ok || timeout <= 0)
timeout = 5*60*1000;
}
return timeout;
return std::chrono::milliseconds{timeout};
}
#endif
@ -1008,53 +1010,81 @@ void TestMethods::invokeTestOnData(int index) const
class WatchDog : public QThread
{
enum Expectation {
ThreadStart,
TestFunctionStart,
TestFunctionEnd,
ThreadEnd,
};
bool waitFor(std::unique_lock<std::mutex> &m, Expectation e) {
auto expectation = [this, e] { return expecting != e; };
switch (e) {
case TestFunctionEnd:
return waitCondition.wait_for(m, defaultTimeout(), expectation);
case ThreadStart:
case ThreadEnd:
case TestFunctionStart:
waitCondition.wait(m, expectation);
return true;
}
Q_UNREACHABLE();
return false;
}
public:
WatchDog()
{
QMutexLocker locker(&mutex);
timeout.storeRelaxed(-1);
std::unique_lock<std::mutex> locker(mutex);
expecting = ThreadStart;
start();
waitCondition.wait(&mutex);
waitFor(locker, ThreadStart);
}
~WatchDog() {
{
QMutexLocker locker(&mutex);
timeout.storeRelaxed(0);
waitCondition.wakeAll();
const auto locker = qt_scoped_lock(mutex);
expecting = ThreadEnd;
waitCondition.notify_all();
}
wait();
}
void beginTest() {
QMutexLocker locker(&mutex);
timeout.storeRelaxed(defaultTimeout());
waitCondition.wakeAll();
const auto locker = qt_scoped_lock(mutex);
expecting = TestFunctionEnd;
waitCondition.notify_all();
}
void testFinished() {
QMutexLocker locker(&mutex);
timeout.storeRelaxed(-1);
waitCondition.wakeAll();
const auto locker = qt_scoped_lock(mutex);
expecting = TestFunctionStart;
waitCondition.notify_all();
}
void run() override {
QMutexLocker locker(&mutex);
waitCondition.wakeAll();
std::unique_lock<std::mutex> locker(mutex);
expecting = TestFunctionStart;
waitCondition.notify_all();
while (true) {
int t = timeout.loadRelaxed();
if (!t)
break;
if (Q_UNLIKELY(!waitCondition.wait(&mutex, t))) {
switch (expecting) {
case ThreadEnd:
return;
case ThreadStart:
Q_UNREACHABLE();
case TestFunctionStart:
case TestFunctionEnd:
if (Q_UNLIKELY(!waitFor(locker, expecting))) {
stackTrace();
qFatal("Test function timed out");
}
}
}
}
private:
QBasicAtomicInt timeout;
QMutex mutex;
QWaitCondition waitCondition;
std::mutex mutex;
std::condition_variable waitCondition;
Expectation expecting;
};
#else // !QT_CONFIG(thread)

View File

@ -3271,10 +3271,14 @@ bool QWizard::nativeEvent(const QByteArray &eventType, void *message, long *resu
MSG *windowsMessage = static_cast<MSG *>(message);
const bool winEventResult = d->vistaHelper->handleWinEvent(windowsMessage, result);
if (QVistaHelper::vistaState() != d->vistaState) {
d->vistaState = QVistaHelper::vistaState();
// QTBUG-78300: When Qt::AA_NativeWindows is set, delay further
// window creation until after the platform window creation events.
if (windowsMessage->message == WM_GETICON) {
d->vistaStateChanged = true;
d->vistaState = QVistaHelper::vistaState();
setWizardStyle(AeroStyle);
}
}
return winEventResult;
} else {
return QDialog::nativeEvent(eventType, message, result);

View File

@ -115,7 +115,7 @@ public:
BspTreeIndex,
NoIndex = -1
};
Q_ENUM(ItemIndexMethod)
enum SceneLayer {
ItemLayer = 0x1,
BackgroundLayer = 0x2,

View File

@ -324,15 +324,10 @@ void QMenuBarPrivate::popupAction(QAction *action, bool activateFirst)
QPoint pos(q->mapToGlobal(QPoint(adjustedActionRect.left(), adjustedActionRect.bottom() + 1)));
QSize popup_size = activeMenu->sizeHint();
//we put the popup menu on the screen containing the bottom-center of the action rect
QScreen *popupScreen = q->window()->windowHandle()->screen();
QPoint bottomMiddlePos = pos + QPoint(adjustedActionRect.width() / 2, 0);
const auto &siblings = popupScreen->virtualSiblings();
for (QScreen *sibling : siblings) {
if (sibling->geometry().contains(bottomMiddlePos)) {
popupScreen = sibling;
break;
}
}
QScreen *menubarScreen = q->window()->windowHandle()->screen();
QScreen *popupScreen = menubarScreen->virtualSiblingAt(pos + QPoint(adjustedActionRect.width() / 2, 0));
if (!popupScreen)
popupScreen = menubarScreen;
QRect screenRect = popupScreen->geometry();
pos = QPoint(qMax(pos.x(), screenRect.x()), qMax(pos.y(), screenRect.y()));
const bool fitUp = (pos.y() - popup_size.height() >= screenRect.top());

View File

@ -22,7 +22,7 @@ android:!android-embedded {
RESOURCES += android_testdata.qrc
}
win32 {
win32:debug_and_release {
CONFIG(debug, debug|release): LIBS += -Lstaticplugin/debug
else: LIBS += -Lstaticplugin/release
} else {

View File

@ -12,7 +12,7 @@ msvc: DEFINES += WIN32_MSVC
target.path = $$[QT_INSTALL_TESTS]/tst_qlibrary
INSTALLS += target
win32 {
win32:debug_and_release {
CONFIG(debug, debug|release) {
DESTDIR = ../debug/
} else {

View File

@ -13,12 +13,18 @@ msvc: DEFINES += WIN32_MSVC
# We want to test if we can load a shared library with *any* filename...
win32 {
CONFIG(debug, debug|release) {
debug_and_release {
CONFIG(debug, debug|release)) {
BUILD_FOLDER = debug
} else {
BUILD_FOLDER = release
}
DESTDIR = ../$$BUILD_FOLDER/
} else {
BUILD_FOLDER =
DESTDIR = ../
}
# vcproj and Makefile generators refer to target differently
contains(TEMPLATE,vc.*) {

View File

@ -3,7 +3,7 @@ TARGET = ../tst_qlibrary
QT = core testlib
SOURCES = ../tst_qlibrary.cpp
win32 {
win32:debug_and_release {
CONFIG(debug, debug|release) {
TARGET = ../../debug/tst_qlibrary
} else {

Some files were not shown because too many files have changed in this diff Show More