Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: Icf3b9346117ce7149d8687e4cfa182e7586713f3
This commit is contained in:
commit
d58f3c4878
@ -77,6 +77,13 @@
|
|||||||
|
|
||||||
Q_DECLARE_METATYPE(QRegularExpression::MatchType)
|
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)
|
static QString patternToCode(QString pattern)
|
||||||
{
|
{
|
||||||
pattern.replace(QLatin1String("\\"), QLatin1String("\\\\"));
|
pattern.replace(QLatin1String("\\"), QLatin1String("\\\\"));
|
||||||
@ -173,6 +180,29 @@ void PatternLineEdit::contextMenuEvent(QContextMenuEvent *event)
|
|||||||
menu->popup(event->globalPos());
|
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)
|
RegularExpressionDialog::RegularExpressionDialog(QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
@ -230,6 +260,7 @@ void RegularExpressionDialog::refresh()
|
|||||||
offsetSpinBox->setMaximum(qMax(0, text.length() - 1));
|
offsetSpinBox->setMaximum(qMax(0, text.length() - 1));
|
||||||
|
|
||||||
escapedPatternLineEdit->setText(patternToCode(pattern));
|
escapedPatternLineEdit->setText(patternToCode(pattern));
|
||||||
|
rawStringLiteralLineEdit->setText(rawStringLiteral(pattern));
|
||||||
|
|
||||||
setTextColor(patternLineEdit, subjectTextEdit->palette().color(QPalette::Text));
|
setTextColor(patternLineEdit, subjectTextEdit->palette().color(QPalette::Text));
|
||||||
matchDetailsTreeWidget->clear();
|
matchDetailsTreeWidget->clear();
|
||||||
@ -322,15 +353,6 @@ void RegularExpressionDialog::refresh()
|
|||||||
setUpdatesEnabled(true);
|
setUpdatesEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegularExpressionDialog::copyEscapedPatternToClipboard()
|
|
||||||
{
|
|
||||||
#if QT_CONFIG(clipboard)
|
|
||||||
QClipboard *clipboard = QGuiApplication::clipboard();
|
|
||||||
if (clipboard)
|
|
||||||
clipboard->setText(escapedPatternLineEdit->text());
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegularExpressionDialog::setupUi()
|
void RegularExpressionDialog::setupUi()
|
||||||
{
|
{
|
||||||
QWidget *leftHalfContainer = setupLeftUi();
|
QWidget *leftHalfContainer = setupLeftUi();
|
||||||
@ -363,20 +385,9 @@ QWidget *RegularExpressionDialog::setupLeftUi()
|
|||||||
patternLineEdit->setClearButtonEnabled(true);
|
patternLineEdit->setClearButtonEnabled(true);
|
||||||
layout->addRow(tr("&Pattern:"), patternLineEdit);
|
layout->addRow(tr("&Pattern:"), patternLineEdit);
|
||||||
|
|
||||||
escapedPatternLineEdit = new QLineEdit;
|
rawStringLiteralLineEdit = new DisplayLineEdit;
|
||||||
escapedPatternLineEdit->setReadOnly(true);
|
layout->addRow(tr("&Raw string literal:"), rawStringLiteralLineEdit);
|
||||||
QPalette palette = escapedPatternLineEdit->palette();
|
escapedPatternLineEdit = new DisplayLineEdit;
|
||||||
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
|
|
||||||
|
|
||||||
layout->addRow(tr("&Escaped pattern:"), escapedPatternLineEdit);
|
layout->addRow(tr("&Escaped pattern:"), escapedPatternLineEdit);
|
||||||
|
|
||||||
subjectTextEdit = new QPlainTextEdit;
|
subjectTextEdit = new QPlainTextEdit;
|
||||||
|
@ -74,13 +74,13 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void refresh();
|
void refresh();
|
||||||
void copyEscapedPatternToClipboard();
|
|
||||||
void setupUi();
|
void setupUi();
|
||||||
QWidget *setupLeftUi();
|
QWidget *setupLeftUi();
|
||||||
QWidget *setupRightUi();
|
QWidget *setupRightUi();
|
||||||
void setResultUiEnabled(bool enabled);
|
void setResultUiEnabled(bool enabled);
|
||||||
|
|
||||||
QLineEdit *patternLineEdit;
|
QLineEdit *patternLineEdit;
|
||||||
|
QLineEdit *rawStringLiteralLineEdit;
|
||||||
QLineEdit *escapedPatternLineEdit;
|
QLineEdit *escapedPatternLineEdit;
|
||||||
|
|
||||||
QPlainTextEdit *subjectTextEdit;
|
QPlainTextEdit *subjectTextEdit;
|
||||||
|
@ -242,8 +242,13 @@ typedef unsigned int quint32; /* 32 bit unsigned */
|
|||||||
typedef __int64 qint64; /* 64 bit signed */
|
typedef __int64 qint64; /* 64 bit signed */
|
||||||
typedef unsigned __int64 quint64; /* 64 bit unsigned */
|
typedef unsigned __int64 quint64; /* 64 bit unsigned */
|
||||||
#else
|
#else
|
||||||
|
#ifdef __cplusplus
|
||||||
# define Q_INT64_C(c) static_cast<long long>(c ## LL) /* signed 64 bit constant */
|
# 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 */
|
# 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 long long qint64; /* 64 bit signed */
|
||||||
typedef unsigned long long quint64; /* 64 bit unsigned */
|
typedef unsigned long long quint64; /* 64 bit unsigned */
|
||||||
#endif
|
#endif
|
||||||
|
@ -1125,6 +1125,7 @@ QDisabledNetworkReply::QDisabledNetworkReply(QObject *parent,
|
|||||||
setRequest(req);
|
setRequest(req);
|
||||||
setUrl(req.url());
|
setUrl(req.url());
|
||||||
setOperation(op);
|
setOperation(op);
|
||||||
|
setFinished(true);
|
||||||
|
|
||||||
qRegisterMetaType<QNetworkReply::NetworkError>();
|
qRegisterMetaType<QNetworkReply::NetworkError>();
|
||||||
|
|
||||||
|
@ -406,6 +406,7 @@ bool QWindowsTabletSupport::translateTabletProximityEvent(WPARAM /* wParam */, L
|
|||||||
qCDebug(lcQpaTablet) << "leave proximity for device #" << m_currentDevice;
|
qCDebug(lcQpaTablet) << "leave proximity for device #" << m_currentDevice;
|
||||||
if (m_currentDevice < 0 || m_currentDevice >= m_devices.size()) // QTBUG-65120, spurious leave observed
|
if (m_currentDevice < 0 || m_currentDevice >= m_devices.size()) // QTBUG-65120, spurious leave observed
|
||||||
return false;
|
return false;
|
||||||
|
m_state = PenUp;
|
||||||
if (totalPacks > 0) {
|
if (totalPacks > 0) {
|
||||||
QWindowSystemInterface::handleTabletLeaveProximityEvent(proximityBuffer[0].pkTime,
|
QWindowSystemInterface::handleTabletLeaveProximityEvent(proximityBuffer[0].pkTime,
|
||||||
m_devices.at(m_currentDevice).currentDevice,
|
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.push_back(tabletInit(uniqueId, cursorType));
|
||||||
}
|
}
|
||||||
m_devices[m_currentDevice].currentPointerType = pointerType(currentCursor);
|
m_devices[m_currentDevice].currentPointerType = pointerType(currentCursor);
|
||||||
|
m_state = PenProximity;
|
||||||
qCDebug(lcQpaTablet) << "enter proximity for device #"
|
qCDebug(lcQpaTablet) << "enter proximity for device #"
|
||||||
<< m_currentDevice << m_devices.at(m_currentDevice);
|
<< m_currentDevice << m_devices.at(m_currentDevice);
|
||||||
QWindowSystemInterface::handleTabletEnterProximityEvent(proximityBuffer[0].pkTime,
|
QWindowSystemInterface::handleTabletEnterProximityEvent(proximityBuffer[0].pkTime,
|
||||||
@ -458,7 +460,8 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
|
|||||||
const int currentPointer = m_devices.at(m_currentDevice).currentPointerType;
|
const int currentPointer = m_devices.at(m_currentDevice).currentPointerType;
|
||||||
const qint64 uniqueId = m_devices.at(m_currentDevice).uniqueId;
|
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:
|
// 1) Absolute (pen) mode:
|
||||||
// The coordinates are scaled to the virtual desktop (by default). The user
|
// 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.
|
// can also choose to scale to the monitor or a region of the screen.
|
||||||
@ -473,8 +476,11 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
|
|||||||
const QRect virtualDesktopArea =
|
const QRect virtualDesktopArea =
|
||||||
QWindowsScreen::virtualGeometry(QGuiApplication::primaryScreen()->handle());
|
QWindowsScreen::virtualGeometry(QGuiApplication::primaryScreen()->handle());
|
||||||
|
|
||||||
qCDebug(lcQpaTablet) << __FUNCTION__ << "processing " << packetCount
|
if (QWindowsContext::verbose > 1) {
|
||||||
<< "target:" << QGuiApplicationPrivate::tabletDevicePoint(uniqueId).target;
|
qCDebug(lcQpaTablet) << __FUNCTION__ << "processing" << packetCount
|
||||||
|
<< "mode=" << m_mode << "target:"
|
||||||
|
<< QGuiApplicationPrivate::tabletDevicePoint(uniqueId).target;
|
||||||
|
}
|
||||||
|
|
||||||
const Qt::KeyboardModifiers keyboardModifiers = QWindowsKeyMapper::queryKeyboardModifiers();
|
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.
|
// This code is to delay the tablet data one cycle to sync with the mouse location.
|
||||||
QPointF globalPosF = m_oldGlobalPosF;
|
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.
|
QWindow *target = QGuiApplicationPrivate::tabletDevicePoint(uniqueId).target; // Pass to window that grabbed it.
|
||||||
QPoint globalPos = globalPosF.toPoint();
|
|
||||||
|
|
||||||
// Get Mouse Position and compare to tablet info
|
// Get Mouse Position and compare to tablet info
|
||||||
const QPoint mouseLocation = QWindowsCursor::mousePosition();
|
const QPoint mouseLocation = QWindowsCursor::mousePosition();
|
||||||
|
if (m_state == PenProximity) {
|
||||||
// Positions should be almost the same if we are in absolute
|
m_state = PenDown;
|
||||||
// mode. If they are not, use the mouse location.
|
m_mode = (mouseLocation - currentGlobalPosF).manhattanLength() > m_absoluteRange
|
||||||
if ((mouseLocation - globalPos).manhattanLength() > m_absoluteRange) {
|
? MouseMode : PenMode;
|
||||||
globalPos = mouseLocation;
|
qCDebug(lcQpaTablet) << __FUNCTION__ << "mode=" << m_mode << "pen:"
|
||||||
globalPosF = globalPos;
|
<< currentGlobalPosF << "mouse:" << mouseLocation;
|
||||||
}
|
}
|
||||||
|
if (m_mode == MouseMode)
|
||||||
|
globalPosF = mouseLocation;
|
||||||
|
const QPoint globalPos = globalPosF.toPoint();
|
||||||
|
|
||||||
if (!target)
|
if (!target)
|
||||||
target = QWindowsScreen::windowAt(globalPos, CWP_SKIPINVISIBLE | CWP_SKIPTRANSPARENT);
|
target = QWindowsScreen::windowAt(globalPos, CWP_SKIPINVISIBLE | CWP_SKIPTRANSPARENT);
|
||||||
|
@ -112,6 +112,19 @@ class QWindowsTabletSupport
|
|||||||
explicit QWindowsTabletSupport(HWND window, HCTX context);
|
explicit QWindowsTabletSupport(HWND window, HCTX context);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum Mode
|
||||||
|
{
|
||||||
|
PenMode,
|
||||||
|
MouseMode
|
||||||
|
};
|
||||||
|
|
||||||
|
enum State
|
||||||
|
{
|
||||||
|
PenUp,
|
||||||
|
PenProximity,
|
||||||
|
PenDown
|
||||||
|
};
|
||||||
|
|
||||||
~QWindowsTabletSupport();
|
~QWindowsTabletSupport();
|
||||||
|
|
||||||
static QWindowsTabletSupport *create();
|
static QWindowsTabletSupport *create();
|
||||||
@ -137,6 +150,8 @@ private:
|
|||||||
QVector<QWindowsTabletDeviceData> m_devices;
|
QVector<QWindowsTabletDeviceData> m_devices;
|
||||||
int m_currentDevice;
|
int m_currentDevice;
|
||||||
QPointF m_oldGlobalPosF;
|
QPointF m_oldGlobalPosF;
|
||||||
|
Mode m_mode = PenMode;
|
||||||
|
State m_state = PenUp;
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -84,6 +84,15 @@ void tst_QNetworkAccessManager::networkAccessible()
|
|||||||
QNetworkAccessManager::NotAccessible);
|
QNetworkAccessManager::NotAccessible);
|
||||||
QCOMPARE(manager.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);
|
manager.setNetworkAccessible(QNetworkAccessManager::Accessible);
|
||||||
|
|
||||||
QCOMPARE(spy.count(), expectedCount);
|
QCOMPARE(spy.count(), expectedCount);
|
||||||
|
@ -259,8 +259,7 @@ void tst_QSignalSpy::wait_signalEmittedTooLate()
|
|||||||
QTimer::singleShot(500, this, SIGNAL(sigFoo()));
|
QTimer::singleShot(500, this, SIGNAL(sigFoo()));
|
||||||
QSignalSpy spy(this, SIGNAL(sigFoo()));
|
QSignalSpy spy(this, SIGNAL(sigFoo()));
|
||||||
QVERIFY(!spy.wait(200));
|
QVERIFY(!spy.wait(200));
|
||||||
QTest::qWait(400);
|
QTRY_COMPARE(spy.count(), 1);
|
||||||
QCOMPARE(spy.count(), 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QSignalSpy::wait_signalEmittedMultipleTimes()
|
void tst_QSignalSpy::wait_signalEmittedMultipleTimes()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user