Merge remote-tracking branch 'origin/5.11' into dev

Change-Id: Icf3b9346117ce7149d8687e4cfa182e7586713f3
This commit is contained in:
Qt Forward Merge Bot 2018-03-18 01:00:11 +01:00
commit d58f3c4878
8 changed files with 87 additions and 37 deletions

View File

@ -77,6 +77,13 @@
Q_DECLARE_METATYPE(QRegularExpression::MatchType)
static QString rawStringLiteral(QString pattern)
{
pattern.prepend(QLatin1String("R\"RX("));
pattern.append(QLatin1String(")RX\""));
return pattern;
}
static QString patternToCode(QString pattern)
{
pattern.replace(QLatin1String("\\"), QLatin1String("\\\\"));
@ -173,6 +180,29 @@ void PatternLineEdit::contextMenuEvent(QContextMenuEvent *event)
menu->popup(event->globalPos());
}
class DisplayLineEdit : public QLineEdit
{
public:
explicit DisplayLineEdit(QWidget *parent = nullptr);
};
DisplayLineEdit::DisplayLineEdit(QWidget *parent) : QLineEdit(parent)
{
setReadOnly(true);
QPalette disabledPalette = palette();
disabledPalette.setBrush(QPalette::Base, disabledPalette.brush(QPalette::Disabled, QPalette::Base));
setPalette(disabledPalette);
#if QT_CONFIG(clipboard)
QAction *copyAction = new QAction(this);
copyAction->setText(RegularExpressionDialog::tr("Copy to clipboard"));
copyAction->setIcon(QIcon(QStringLiteral(":/images/copy.png")));
connect(copyAction, &QAction::triggered, this,
[this] () { QGuiApplication::clipboard()->setText(text()); });
addAction(copyAction, QLineEdit::TrailingPosition);
#endif
}
RegularExpressionDialog::RegularExpressionDialog(QWidget *parent)
: QDialog(parent)
{
@ -230,6 +260,7 @@ void RegularExpressionDialog::refresh()
offsetSpinBox->setMaximum(qMax(0, text.length() - 1));
escapedPatternLineEdit->setText(patternToCode(pattern));
rawStringLiteralLineEdit->setText(rawStringLiteral(pattern));
setTextColor(patternLineEdit, subjectTextEdit->palette().color(QPalette::Text));
matchDetailsTreeWidget->clear();
@ -322,15 +353,6 @@ void RegularExpressionDialog::refresh()
setUpdatesEnabled(true);
}
void RegularExpressionDialog::copyEscapedPatternToClipboard()
{
#if QT_CONFIG(clipboard)
QClipboard *clipboard = QGuiApplication::clipboard();
if (clipboard)
clipboard->setText(escapedPatternLineEdit->text());
#endif
}
void RegularExpressionDialog::setupUi()
{
QWidget *leftHalfContainer = setupLeftUi();
@ -363,20 +385,9 @@ QWidget *RegularExpressionDialog::setupLeftUi()
patternLineEdit->setClearButtonEnabled(true);
layout->addRow(tr("&Pattern:"), patternLineEdit);
escapedPatternLineEdit = new QLineEdit;
escapedPatternLineEdit->setReadOnly(true);
QPalette palette = escapedPatternLineEdit->palette();
palette.setBrush(QPalette::Base, palette.brush(QPalette::Disabled, QPalette::Base));
escapedPatternLineEdit->setPalette(palette);
#if QT_CONFIG(clipboard)
QAction *copyEscapedPatternAction = new QAction(this);
copyEscapedPatternAction->setText(tr("Copy to clipboard"));
copyEscapedPatternAction->setIcon(QIcon(QStringLiteral(":/images/copy.png")));
connect(copyEscapedPatternAction, &QAction::triggered, this, &RegularExpressionDialog::copyEscapedPatternToClipboard);
escapedPatternLineEdit->addAction(copyEscapedPatternAction, QLineEdit::TrailingPosition);
#endif
rawStringLiteralLineEdit = new DisplayLineEdit;
layout->addRow(tr("&Raw string literal:"), rawStringLiteralLineEdit);
escapedPatternLineEdit = new DisplayLineEdit;
layout->addRow(tr("&Escaped pattern:"), escapedPatternLineEdit);
subjectTextEdit = new QPlainTextEdit;

View File

@ -74,13 +74,13 @@ public:
private:
void refresh();
void copyEscapedPatternToClipboard();
void setupUi();
QWidget *setupLeftUi();
QWidget *setupRightUi();
void setResultUiEnabled(bool enabled);
QLineEdit *patternLineEdit;
QLineEdit *rawStringLiteralLineEdit;
QLineEdit *escapedPatternLineEdit;
QPlainTextEdit *subjectTextEdit;

View File

@ -242,8 +242,13 @@ typedef unsigned int quint32; /* 32 bit unsigned */
typedef __int64 qint64; /* 64 bit signed */
typedef unsigned __int64 quint64; /* 64 bit unsigned */
#else
#ifdef __cplusplus
# define Q_INT64_C(c) static_cast<long long>(c ## LL) /* signed 64 bit constant */
# define Q_UINT64_C(c) static_cast<unsigned long long>(c ## ULL) /* unsigned 64 bit constant */
#else
# define Q_INT64_C(c) ((long long)(c ## LL)) /* signed 64 bit constant */
# define Q_UINT64_C(c) ((unsigned long long)(c ## ULL)) /* unsigned 64 bit constant */
#endif
typedef long long qint64; /* 64 bit signed */
typedef unsigned long long quint64; /* 64 bit unsigned */
#endif

View File

@ -1125,6 +1125,7 @@ QDisabledNetworkReply::QDisabledNetworkReply(QObject *parent,
setRequest(req);
setUrl(req.url());
setOperation(op);
setFinished(true);
qRegisterMetaType<QNetworkReply::NetworkError>();

View File

@ -406,6 +406,7 @@ bool QWindowsTabletSupport::translateTabletProximityEvent(WPARAM /* wParam */, L
qCDebug(lcQpaTablet) << "leave proximity for device #" << m_currentDevice;
if (m_currentDevice < 0 || m_currentDevice >= m_devices.size()) // QTBUG-65120, spurious leave observed
return false;
m_state = PenUp;
if (totalPacks > 0) {
QWindowSystemInterface::handleTabletLeaveProximityEvent(proximityBuffer[0].pkTime,
m_devices.at(m_currentDevice).currentDevice,
@ -438,6 +439,7 @@ bool QWindowsTabletSupport::translateTabletProximityEvent(WPARAM /* wParam */, L
m_devices.push_back(tabletInit(uniqueId, cursorType));
}
m_devices[m_currentDevice].currentPointerType = pointerType(currentCursor);
m_state = PenProximity;
qCDebug(lcQpaTablet) << "enter proximity for device #"
<< m_currentDevice << m_devices.at(m_currentDevice);
QWindowSystemInterface::handleTabletEnterProximityEvent(proximityBuffer[0].pkTime,
@ -458,7 +460,8 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
const int currentPointer = m_devices.at(m_currentDevice).currentPointerType;
const qint64 uniqueId = m_devices.at(m_currentDevice).uniqueId;
// The tablet can be used in 2 different modes, depending on it settings:
// The tablet can be used in 2 different modes (reflected in enum Mode),
// depending on its settings:
// 1) Absolute (pen) mode:
// The coordinates are scaled to the virtual desktop (by default). The user
// can also choose to scale to the monitor or a region of the screen.
@ -473,8 +476,11 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
const QRect virtualDesktopArea =
QWindowsScreen::virtualGeometry(QGuiApplication::primaryScreen()->handle());
qCDebug(lcQpaTablet) << __FUNCTION__ << "processing " << packetCount
<< "target:" << QGuiApplicationPrivate::tabletDevicePoint(uniqueId).target;
if (QWindowsContext::verbose > 1) {
qCDebug(lcQpaTablet) << __FUNCTION__ << "processing" << packetCount
<< "mode=" << m_mode << "target:"
<< QGuiApplicationPrivate::tabletDevicePoint(uniqueId).target;
}
const Qt::KeyboardModifiers keyboardModifiers = QWindowsKeyMapper::queryKeyboardModifiers();
@ -485,20 +491,24 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
// This code is to delay the tablet data one cycle to sync with the mouse location.
QPointF globalPosF = m_oldGlobalPosF;
m_oldGlobalPosF = m_devices.at(m_currentDevice).scaleCoordinates(packet.pkX, packet.pkY, virtualDesktopArea);
const QPointF currentGlobalPosF =
m_devices.at(m_currentDevice).scaleCoordinates(packet.pkX, packet.pkY, virtualDesktopArea);
m_oldGlobalPosF = currentGlobalPosF;
QWindow *target = QGuiApplicationPrivate::tabletDevicePoint(uniqueId).target; // Pass to window that grabbed it.
QPoint globalPos = globalPosF.toPoint();
// Get Mouse Position and compare to tablet info
const QPoint mouseLocation = QWindowsCursor::mousePosition();
// Positions should be almost the same if we are in absolute
// mode. If they are not, use the mouse location.
if ((mouseLocation - globalPos).manhattanLength() > m_absoluteRange) {
globalPos = mouseLocation;
globalPosF = globalPos;
if (m_state == PenProximity) {
m_state = PenDown;
m_mode = (mouseLocation - currentGlobalPosF).manhattanLength() > m_absoluteRange
? MouseMode : PenMode;
qCDebug(lcQpaTablet) << __FUNCTION__ << "mode=" << m_mode << "pen:"
<< currentGlobalPosF << "mouse:" << mouseLocation;
}
if (m_mode == MouseMode)
globalPosF = mouseLocation;
const QPoint globalPos = globalPosF.toPoint();
if (!target)
target = QWindowsScreen::windowAt(globalPos, CWP_SKIPINVISIBLE | CWP_SKIPTRANSPARENT);

View File

@ -112,6 +112,19 @@ class QWindowsTabletSupport
explicit QWindowsTabletSupport(HWND window, HCTX context);
public:
enum Mode
{
PenMode,
MouseMode
};
enum State
{
PenUp,
PenProximity,
PenDown
};
~QWindowsTabletSupport();
static QWindowsTabletSupport *create();
@ -137,6 +150,8 @@ private:
QVector<QWindowsTabletDeviceData> m_devices;
int m_currentDevice;
QPointF m_oldGlobalPosF;
Mode m_mode = PenMode;
State m_state = PenUp;
};
QT_END_NAMESPACE

View File

@ -84,6 +84,15 @@ void tst_QNetworkAccessManager::networkAccessible()
QNetworkAccessManager::NotAccessible);
QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::NotAccessible);
// When network is not accessible, all requests fail
QNetworkReply *reply = manager.get(QNetworkRequest(QUrl("http://www.example.org")));
QSignalSpy finishedSpy(reply, &QNetworkReply::finished);
QSignalSpy errorSpy(reply, QOverload<QNetworkReply::NetworkError>::of(&QNetworkReply::error));
QVERIFY(finishedSpy.wait());
QCOMPARE(reply->isFinished(), true);
QCOMPARE(reply->errorString(), QStringLiteral("Network access is disabled."));
QCOMPARE(errorSpy.count(), 1);
manager.setNetworkAccessible(QNetworkAccessManager::Accessible);
QCOMPARE(spy.count(), expectedCount);

View File

@ -259,8 +259,7 @@ void tst_QSignalSpy::wait_signalEmittedTooLate()
QTimer::singleShot(500, this, SIGNAL(sigFoo()));
QSignalSpy spy(this, SIGNAL(sigFoo()));
QVERIFY(!spy.wait(200));
QTest::qWait(400);
QCOMPARE(spy.count(), 1);
QTRY_COMPARE(spy.count(), 1);
}
void tst_QSignalSpy::wait_signalEmittedMultipleTimes()