summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-01-15 01:00:38 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-01-15 01:00:39 +0100
commitc3123c757a2301445ac286ce2c8af20959151e21 (patch)
treec8f5421725d0fe0cfe8a29136937e54d6f3f95c2 /src/gui
parent2cbc5f6f7ae8ba580126a7cafc1898377c2a2407 (diff)
parent7a59d6f138ff8799170cc03d709525ab965d703a (diff)
Merge remote-tracking branch 'origin/5.14' into 5.15
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qevent.cpp28
-rw-r--r--src/gui/text/qtextmarkdownimporter.cpp14
2 files changed, 31 insertions, 11 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index c69cc8ce6f..3362294435 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -667,9 +667,9 @@ QHoverEvent::~QHoverEvent()
if that widget does not handle the event they are sent to the
focus widget. Wheel events are generated for both mouse wheels
and trackpad scroll gestures. There are two ways to read the
- wheel event delta: angleDelta() returns the delta in wheel
- degrees. This value is always provided. pixelDelta() returns
- the delta in screen pixels and is available on platforms that
+ wheel event delta: angleDelta() returns the deltas in wheel
+ degrees. These values are always provided. pixelDelta() returns
+ the deltas in screen pixels, and is available on platforms that
have high-resolution trackpads, such as \macos. If that is the
case, source() will return Qt::MouseEventSynthesizedBySystem.
@@ -852,7 +852,7 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
by \a globalPos.
\a pixelDelta contains the scrolling distance in pixels on screen, while
- \a angleDelta contains the wheel rotation distance. \a pixelDelta is
+ \a angleDelta contains the wheel rotation angle. \a pixelDelta is
optional and can be null.
The mouse and keyboard states at the time of the event are specified by
@@ -914,10 +914,16 @@ QWheelEvent::~QWheelEvent()
/*!
\fn QPoint QWheelEvent::angleDelta() const
- Returns the distance that the wheel is rotated, in eighths of a
- degree. A positive value indicates that the wheel was rotated
- forwards away from the user; a negative value indicates that the
- wheel was rotated backwards toward the user.
+ Returns the relative amount that the wheel was rotated, in eighths of a
+ degree. A positive value indicates that the wheel was rotated forwards away
+ from the user; a negative value indicates that the wheel was rotated
+ backwards toward the user. \c angleDelta().y() provides the angle through
+ which the common vertical mouse wheel was rotated since the previous event.
+ \c angleDelta().x() provides the angle through which the horizontal mouse
+ wheel was rotated, if the mouse has a horizontal wheel; otherwise it stays
+ at zero. Some mice allow the user to tilt the wheel to perform horizontal
+ scrolling, and some touchpads support a horizontal scrolling gesture; that
+ will also appear in \c angleDelta().x().
Most mouse types work in steps of 15 degrees, in which case the
delta value is a multiple of 120; i.e., 120 units * 1/8 = 15 degrees.
@@ -926,7 +932,9 @@ QWheelEvent::~QWheelEvent()
that are less than 120 units (less than 15 degrees). To support this
possibility, you can either cumulatively add the delta values from events
until the value of 120 is reached, then scroll the widget, or you can
- partially scroll the widget in response to each wheel event.
+ partially scroll the widget in response to each wheel event. But to
+ provide a more native feel, you should prefer \l pixelDelta() on platforms
+ where it's available.
Example:
@@ -937,6 +945,8 @@ QWheelEvent::~QWheelEvent()
\li scrolling is about to begin, but the distance did not yet change (Qt::ScrollBegin),
\li or scrolling has ended and the distance did not change anymore (Qt::ScrollEnd).
\endlist
+
+ \see pixelDelta()
*/
/*!
diff --git a/src/gui/text/qtextmarkdownimporter.cpp b/src/gui/text/qtextmarkdownimporter.cpp
index 78d18a714b..88965046ce 100644
--- a/src/gui/text/qtextmarkdownimporter.cpp
+++ b/src/gui/text/qtextmarkdownimporter.cpp
@@ -207,7 +207,12 @@ int QTextMarkdownImporter::cbEnterBlock(int blockType, void *det)
charFmt.setFontWeight(QFont::Bold);
blockFmt.setHeadingLevel(int(detail->level));
m_needsInsertBlock = false;
- m_cursor->insertBlock(blockFmt, charFmt);
+ if (m_doc->isEmpty()) {
+ m_cursor->setBlockFormat(blockFmt);
+ m_cursor->setCharFormat(charFmt);
+ } else {
+ m_cursor->insertBlock(blockFmt, charFmt);
+ }
qCDebug(lcMD, "H%d", detail->level);
} break;
case MD_BLOCK_LI: {
@@ -592,7 +597,12 @@ void QTextMarkdownImporter::insertBlock()
blockFormat.setMarker(m_markerType);
if (!m_listStack.isEmpty())
blockFormat.setIndent(m_listStack.count());
- m_cursor->insertBlock(blockFormat, charFormat);
+ if (m_doc->isEmpty()) {
+ m_cursor->setBlockFormat(blockFormat);
+ m_cursor->setCharFormat(charFormat);
+ } else {
+ m_cursor->insertBlock(blockFormat, charFormat);
+ }
if (m_needsInsertList) {
m_listStack.push(m_cursor->createList(m_listFormat));
} else if (!m_listStack.isEmpty() && m_listItem) {