summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-03-18 01:00:11 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-03-18 01:00:11 +0100
commitd58f3c4878b78699bd23507352a2f55881d9b76f (patch)
tree577e5fe415ed1741a7a6938451ba54bbbdcf1490
parent6c7fff8c91d68912797fa84360ab374b858f44c4 (diff)
parentf6f40014c417aa90d4c805719e70910f522047e4 (diff)
Merge remote-tracking branch 'origin/5.11' into dev
-rw-r--r--examples/widgets/tools/regularexpression/regularexpressiondialog.cpp57
-rw-r--r--examples/widgets/tools/regularexpression/regularexpressiondialog.h2
-rw-r--r--src/corelib/global/qglobal.h5
-rw-r--r--src/network/access/qnetworkreplyimpl.cpp1
-rw-r--r--src/plugins/platforms/windows/qwindowstabletsupport.cpp32
-rw-r--r--src/plugins/platforms/windows/qwindowstabletsupport.h15
-rw-r--r--tests/auto/network/access/qnetworkaccessmanager/tst_qnetworkaccessmanager.cpp9
-rw-r--r--tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp3
8 files changed, 87 insertions, 37 deletions
diff --git a/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp b/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp
index 67d0db4bed..8fbf143cbd 100644
--- a/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp
+++ b/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp
@@ -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;
diff --git a/examples/widgets/tools/regularexpression/regularexpressiondialog.h b/examples/widgets/tools/regularexpression/regularexpressiondialog.h
index f7d64085fc..ba5b38b5e3 100644
--- a/examples/widgets/tools/regularexpression/regularexpressiondialog.h
+++ b/examples/widgets/tools/regularexpression/regularexpressiondialog.h
@@ -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;
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index cd4b4a29a9..33885021ba 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -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
diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp
index 54930a351a..a794b492e7 100644
--- a/src/network/access/qnetworkreplyimpl.cpp
+++ b/src/network/access/qnetworkreplyimpl.cpp
@@ -1125,6 +1125,7 @@ QDisabledNetworkReply::QDisabledNetworkReply(QObject *parent,
setRequest(req);
setUrl(req.url());
setOperation(op);
+ setFinished(true);
qRegisterMetaType<QNetworkReply::NetworkError>();
diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.cpp b/src/plugins/platforms/windows/qwindowstabletsupport.cpp
index dcad23e446..280519d39d 100644
--- a/src/plugins/platforms/windows/qwindowstabletsupport.cpp
+++ b/src/plugins/platforms/windows/qwindowstabletsupport.cpp
@@ -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);
diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.h b/src/plugins/platforms/windows/qwindowstabletsupport.h
index 7878e962e1..340818c3f7 100644
--- a/src/plugins/platforms/windows/qwindowstabletsupport.h
+++ b/src/plugins/platforms/windows/qwindowstabletsupport.h
@@ -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
diff --git a/tests/auto/network/access/qnetworkaccessmanager/tst_qnetworkaccessmanager.cpp b/tests/auto/network/access/qnetworkaccessmanager/tst_qnetworkaccessmanager.cpp
index bc2e2822cb..120b1c4b66 100644
--- a/tests/auto/network/access/qnetworkaccessmanager/tst_qnetworkaccessmanager.cpp
+++ b/tests/auto/network/access/qnetworkaccessmanager/tst_qnetworkaccessmanager.cpp
@@ -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);
diff --git a/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp b/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp
index 3aef916c38..df241c030e 100644
--- a/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp
+++ b/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp
@@ -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()