summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/doc/src/cmake/cmake-configure-variables.qdoc4
-rw-r--r--src/network/access/qbytedatabuffer_p.h2
-rw-r--r--src/network/access/qhttp2connection.cpp77
-rw-r--r--src/network/access/qhttp2connection_p.h24
-rw-r--r--src/plugins/styles/modernwindows/qwindows11style.cpp17
-rw-r--r--src/plugins/styles/modernwindows/qwindows11style_p.h3
6 files changed, 100 insertions, 27 deletions
diff --git a/src/corelib/doc/src/cmake/cmake-configure-variables.qdoc b/src/corelib/doc/src/cmake/cmake-configure-variables.qdoc
index 42cb3ecb42b..b8e5e038a33 100644
--- a/src/corelib/doc/src/cmake/cmake-configure-variables.qdoc
+++ b/src/corelib/doc/src/cmake/cmake-configure-variables.qdoc
@@ -142,6 +142,10 @@ effectively disables release package signing even in Release or RelWithDebInfo
builds. When not set, the default behavior is to use release package signing in
build types other than Debug.
+This variable is not supposed to be set in CMake project files. Rather set it
+when configuring your project on the command line or in the CMake settings of
+your IDE.
+
\sa {androiddeployqt}
*/
diff --git a/src/network/access/qbytedatabuffer_p.h b/src/network/access/qbytedatabuffer_p.h
index a119093cf7e..036b562d06a 100644
--- a/src/network/access/qbytedatabuffer_p.h
+++ b/src/network/access/qbytedatabuffer_p.h
@@ -280,6 +280,8 @@ public:
}
return false;
}
+
+ const QByteArray &last() const { return buffers.last(); }
};
QT_END_NAMESPACE
diff --git a/src/network/access/qhttp2connection.cpp b/src/network/access/qhttp2connection.cpp
index 2895e8335d2..c0b07ddd652 100644
--- a/src/network/access/qhttp2connection.cpp
+++ b/src/network/access/qhttp2connection.cpp
@@ -34,8 +34,38 @@ using namespace Http2;
\sa QHttp2Connection
*/
-QHttp2Stream::QHttp2Stream(QHttp2Connection *connection, quint32 streamID) noexcept
- : QObject(connection), m_streamID(streamID)
+/*!
+ \struct QHttp2Stream::Configuration
+ \inmodule QtNetwork
+ \internal
+
+ \brief Configuration options for a QHttp2Stream.
+
+ The Configuration struct holds options that control stream behavior.
+
+ \sa QHttp2Connection::createStream()
+*/
+
+/*!
+ \variable QHttp2Stream::Configuration::useDownloadBuffer
+
+ Controls whether incoming DATA frames, from QHttp2Stream::dataReceived(),
+ are buffered. The default is \c true.
+
+ You may disable buffering for client-initiated streams when the
+ application processes DATA immediately.
+
+ Buffering must remain enabled for pushed streams. A pushed stream can
+ receive DATA before the application becomes aware of them and the buffered
+ DATA is required to deliver the pushed response.
+
+ \sa QHttp2Stream::downloadBuffer(), QHttp2Stream::takeDownloadBuffer(),
+ QHttp2Configuration::serverPushEnabled(), QHttp2Stream::dataReceived()
+*/
+
+QHttp2Stream::QHttp2Stream(QHttp2Connection *connection, quint32 streamID,
+ Configuration configuration) noexcept
+ : QObject(connection), m_streamID(streamID), m_configuration(configuration)
{
Q_ASSERT(connection);
Q_ASSERT(streamID); // stream id 0 is reserved for connection control messages
@@ -213,6 +243,12 @@ QHttp2Stream::~QHttp2Stream() noexcept {
Returns the buffer containing the data received from the remote peer.
*/
+/*!
+ \fn QHttp2Stream::Configuration QHttp2Stream::configuration() const
+
+ Returns the configuration of this stream.
+*/
+
void QHttp2Stream::finishWithError(Http2::Http2Error errorCode, const QString &message)
{
qCDebug(qHttp2ConnectionLog, "[%p] stream %u finished with error: %ls (error code: %u)",
@@ -697,8 +733,14 @@ void QHttp2Stream::handleDATA(const Frame &inboundFrame)
inboundFrame.dataSize());
if (endStream)
transitionState(StateTransition::CloseRemote);
- emit dataReceived(fragment, endStream);
- m_downloadBuffer.append(std::move(fragment));
+ const auto shouldBuffer = m_configuration.useDownloadBuffer && !fragment.isEmpty();
+ if (shouldBuffer) {
+ // Only non-empty fragments get appended!
+ m_downloadBuffer.append(std::move(fragment));
+ emit dataReceived(m_downloadBuffer.last(), endStream);
+ } else {
+ emit dataReceived(fragment, endStream);
+ }
}
if (!endStream && m_recvWindow < connection->streamInitialReceiveWindowSize / 2) {
@@ -885,23 +927,35 @@ QHttp2Connection *QHttp2Connection::createDirectServerConnection(QIODevice *sock
}
/*!
- Creates a stream on this connection.
+ \fn QH2Expected<QHttp2Stream *, QHttp2Connection::CreateStreamError> QHttp2Connection::createStream()
+ Creates a stream on this connection, using the default QHttp2Stream::Configuration.
+
+//! [createStream]
Automatically picks the next available stream ID and returns a pointer to
the new stream, if possible. Otherwise returns an error.
\sa QHttp2Connection::CreateStreamError, QHttp2Stream
+//! [createStream]
+ \sa createStream(QHttp2Stream::Configuration)
+*/
+
+/*!
+ Creates a stream with \a configuration on this connection.
+
+ \include qhttp2connection.cpp createStream
*/
-QH2Expected<QHttp2Stream *, QHttp2Connection::CreateStreamError> QHttp2Connection::createStream()
+QH2Expected<QHttp2Stream *, QHttp2Connection::CreateStreamError>
+QHttp2Connection::createStream(QHttp2Stream::Configuration configuration)
{
Q_ASSERT(m_connectionType == Type::Client); // This overload is just for clients
if (m_nextStreamID > lastValidStreamID)
return { QHttp2Connection::CreateStreamError::StreamIdsExhausted };
- return createLocalStreamInternal();
+ return createLocalStreamInternal(configuration);
}
QH2Expected<QHttp2Stream *, QHttp2Connection::CreateStreamError>
-QHttp2Connection::createLocalStreamInternal()
+QHttp2Connection::createLocalStreamInternal(QHttp2Stream::Configuration conf)
{
if (m_goingAway)
return { QHttp2Connection::CreateStreamError::ReceivedGOAWAY };
@@ -909,7 +963,7 @@ QHttp2Connection::createLocalStreamInternal()
if (size_t(m_peerMaxConcurrentStreams) <= size_t(numActiveLocalStreams()))
return { QHttp2Connection::CreateStreamError::MaxConcurrentStreamsReached };
- if (QHttp2Stream *ptr = createStreamInternal_impl(streamID)) {
+ if (QHttp2Stream *ptr = createStreamInternal_impl(streamID, conf)) {
m_nextStreamID += 2;
return {ptr};
}
@@ -917,7 +971,8 @@ QHttp2Connection::createLocalStreamInternal()
return { QHttp2Connection::CreateStreamError::UnknownError };
}
-QHttp2Stream *QHttp2Connection::createStreamInternal_impl(quint32 streamID)
+QHttp2Stream *QHttp2Connection::createStreamInternal_impl(quint32 streamID,
+ QHttp2Stream::Configuration conf)
{
Q_ASSERT(streamID > m_lastIncomingStreamID || streamID >= m_nextStreamID);
@@ -930,7 +985,7 @@ QHttp2Stream *QHttp2Connection::createStreamInternal_impl(quint32 streamID)
if (!result.inserted)
return nullptr;
QPointer<QHttp2Stream> &stream = result.iterator.value();
- stream = new QHttp2Stream(this, streamID);
+ stream = new QHttp2Stream(this, streamID, conf);
stream->m_recvWindow = streamInitialReceiveWindowSize;
stream->m_sendWindow = streamInitialSendWindowSize;
diff --git a/src/network/access/qhttp2connection_p.h b/src/network/access/qhttp2connection_p.h
index f3f14145278..e2af7d7ab33 100644
--- a/src/network/access/qhttp2connection_p.h
+++ b/src/network/access/qhttp2connection_p.h
@@ -101,6 +101,11 @@ public:
Q_ENUM(State)
constexpr static quint8 DefaultPriority = 127;
+ struct Configuration
+ {
+ bool useDownloadBuffer = true;
+ };
+
~QHttp2Stream() noexcept;
// HTTP2 things
@@ -124,6 +129,8 @@ public:
QByteDataBuffer takeDownloadBuffer() noexcept { return std::exchange(m_downloadBuffer, {}); }
void clearDownloadBuffer() { m_downloadBuffer.clear(); }
+ Configuration configuration() const { return m_configuration; }
+
Q_SIGNALS:
void headersReceived(const HPack::HttpHeader &headers, bool endStream);
void headersUpdated();
@@ -154,7 +161,8 @@ private Q_SLOTS:
private:
friend class QHttp2Connection;
- QHttp2Stream(QHttp2Connection *connection, quint32 streamID) noexcept;
+ QHttp2Stream(QHttp2Connection *connection, quint32 streamID,
+ Configuration configuration) noexcept;
[[nodiscard]] QHttp2Connection *getConnection() const
{
@@ -201,6 +209,8 @@ private:
bool m_isReserved = false;
bool m_owningByteDevice = false;
+ const Configuration m_configuration;
+
friend tst_QHttp2Connection;
};
@@ -235,7 +245,12 @@ public:
createDirectServerConnection(QIODevice *socket, const QHttp2Configuration &config);
~QHttp2Connection();
- [[nodiscard]] QH2Expected<QHttp2Stream *, CreateStreamError> createStream();
+ [[nodiscard]] QH2Expected<QHttp2Stream *, CreateStreamError> createStream()
+ {
+ return createStream(QHttp2Stream::Configuration{});
+ }
+ [[nodiscard]] QH2Expected<QHttp2Stream *, CreateStreamError>
+ createStream(QHttp2Stream::Configuration config);
QHttp2Stream *getStream(quint32 streamId) const;
QHttp2Stream *promisedStream(const QUrl &streamKey) const
@@ -278,8 +293,9 @@ private:
friend class QHttp2Stream;
[[nodiscard]] QIODevice *getSocket() const { return qobject_cast<QIODevice *>(parent()); }
- QH2Expected<QHttp2Stream *, QHttp2Connection::CreateStreamError> createLocalStreamInternal();
- QHttp2Stream *createStreamInternal_impl(quint32 streamID);
+ QH2Expected<QHttp2Stream *, QHttp2Connection::CreateStreamError>
+ createLocalStreamInternal(QHttp2Stream::Configuration = {});
+ QHttp2Stream *createStreamInternal_impl(quint32 streamID, QHttp2Stream::Configuration = {});
bool isInvalidStream(quint32 streamID) noexcept;
bool streamWasResetLocally(quint32 streamID) noexcept;
diff --git a/src/plugins/styles/modernwindows/qwindows11style.cpp b/src/plugins/styles/modernwindows/qwindows11style.cpp
index ff2d4bd845f..e9b90d787bc 100644
--- a/src/plugins/styles/modernwindows/qwindows11style.cpp
+++ b/src/plugins/styles/modernwindows/qwindows11style.cpp
@@ -596,7 +596,7 @@ void QWindows11Style::drawComplexControl(ComplexControl control, const QStyleOpt
if (sub & SC_ComboBoxArrow) {
QRectF rect = proxy()->subControlRect(CC_ComboBox, option, SC_ComboBoxArrow, widget);
painter->setFont(d->assetFont);
- painter->setPen(controlTextColor(option));
+ painter->setPen(controlTextColor(option, true));
painter->drawText(rect, Qt::AlignCenter, fluentIcon(Icon::ChevronDownMed));
}
if (state & State_KeyboardFocusChange && hasFocus) {
@@ -887,7 +887,7 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption
if (isOn) {
painter->setFont(d->assetFont);
- painter->setPen(controlTextColor(option, QPalette::Window));
+ painter->setPen(controlTextColor(option));
qreal clipWidth = 1.0;
const QString str = fluentIcon(Icon::AcceptMedium);
QFontMetrics fm(d->assetFont);
@@ -907,7 +907,7 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption
QFont f(d->assetFont);
f.setPointSize(6);
painter->setFont(f);
- painter->setPen(controlTextColor(option, QPalette::Window));
+ painter->setPen(controlTextColor(option));
painter->drawText(rect, Qt::AlignCenter, fluentIcon(Icon::Dash12));
}
}
@@ -1214,7 +1214,7 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
case QStyle::CE_ComboBoxLabel:
#if QT_CONFIG(combobox)
if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
- painter->setPen(controlTextColor(option));
+ painter->setPen(controlTextColor(option, true));
QStyleOptionComboBox newOption = *cb;
newOption.rect.adjust(4,0,-4,0);
QCommonStyle::drawControl(element, &newOption, painter, widget);
@@ -2737,7 +2737,7 @@ QBrush QWindows11Style::inputFillBrush(const QStyleOption *option, const QWidget
return winUI3Color(fillControlDefault);
}
-QColor QWindows11Style::controlTextColor(const QStyleOption *option, QPalette::ColorRole role) const
+QColor QWindows11Style::controlTextColor(const QStyleOption *option, bool ignoreIsChecked) const
{
using namespace StyleOptionHelper;
static constexpr WINUI3Color colorEnums[2][4] = {
@@ -2750,12 +2750,9 @@ QColor QWindows11Style::controlTextColor(const QStyleOption *option, QPalette::C
if (option->palette.isBrushSet(QPalette::Current, QPalette::ButtonText))
return option->palette.buttonText().color();
- const int colorIndex = isChecked(option) ? 1 : 0;
+ const int colorIndex = !ignoreIsChecked && isChecked(option) ? 1 : 0;
const auto state = calcControlState(option);
- const auto alpha = winUI3Color(colorEnums[colorIndex][int(state)]);
- QColor col = option->palette.color(role);
- col.setAlpha(alpha.alpha());
- return col;
+ return winUI3Color(colorEnums[colorIndex][int(state)]);
}
void QWindows11Style::drawLineEditFrame(QPainter *p, const QRectF &rect, const QStyleOption *o, bool isEditable) const
diff --git a/src/plugins/styles/modernwindows/qwindows11style_p.h b/src/plugins/styles/modernwindows/qwindows11style_p.h
index 96c2c4136e0..9d0cdda3e33 100644
--- a/src/plugins/styles/modernwindows/qwindows11style_p.h
+++ b/src/plugins/styles/modernwindows/qwindows11style_p.h
@@ -104,8 +104,7 @@ private:
QBrush controlFillBrush(const QStyleOption *option, ControlType controlType) const;
QBrush inputFillBrush(const QStyleOption *option, const QWidget *widget) const;
// ControlType::ControlAlt can be mapped to QPalette directly
- QColor controlTextColor(const QStyleOption *option,
- QPalette::ColorRole role = QPalette::ButtonText) const;
+ QColor controlTextColor(const QStyleOption *option, bool ignoreIsChecked = false) const;
void drawLineEditFrame(QPainter *p, const QRectF &rect, const QStyleOption *o, bool isEditable = true) const;
inline QColor winUI3Color(enum WINUI3Color col) const;