parent
a969a38991
commit
497146cc23
@ -1 +1 @@
|
||||
SOURCES/qtbase-everywhere-src-6.7.1.tar.xz
|
||||
SOURCES/qtbase-everywhere-src-6.8.1.tar.xz
|
||||
|
@ -1 +1 @@
|
||||
d056b7d9ab0a16c15dbfac5a4d8e489af2ea23df SOURCES/qtbase-everywhere-src-6.7.1.tar.xz
|
||||
ac3cfaee831310f03288ab32adc7ccc60b501205 SOURCES/qtbase-everywhere-src-6.8.1.tar.xz
|
||||
|
@ -1,232 +0,0 @@
|
||||
From b1e75376cc3adfc7da5502a277dfe9711f3e0536 Mon Sep 17 00:00:00 2001
|
||||
From: Mårten Nordheim <marten.nordheim@qt.io>
|
||||
Date: Tue, 25 Jun 2024 17:09:35 +0200
|
||||
Subject: [PATCH] HTTP2: Delay any communication until encrypted() can be responded to
|
||||
|
||||
We have the encrypted() signal that lets users do extra checks on the
|
||||
established connection. It is emitted as BlockingQueued, so the HTTP
|
||||
thread stalls until it is done emitting. Users can potentially call
|
||||
abort() on the QNetworkReply at that point, which is passed as a Queued
|
||||
call back to the HTTP thread. That means that any currently queued
|
||||
signal emission will be processed before the abort() call is processed.
|
||||
|
||||
In the case of HTTP2 it is a little special since it is multiplexed and
|
||||
the code is built to start requests as they are available. This means
|
||||
that, while the code worked fine for HTTP1, since one connection only
|
||||
has one request, it is not working for HTTP2, since we try to send more
|
||||
requests in-between the encrypted() signal and the abort() call.
|
||||
|
||||
This patch changes the code to delay any communication until the
|
||||
encrypted() signal has been emitted and processed, for HTTP2 only.
|
||||
It's done by adding a few booleans, both to know that we have to return
|
||||
early and so we can keep track of what events arose and what we need to
|
||||
resume once enough time has passed that any abort() call must have been
|
||||
processed.
|
||||
|
||||
Fixes: QTBUG-126610
|
||||
Pick-to: 6.8 6.7 6.5 6.2 5.15 5.12
|
||||
Change-Id: Ic25a600c278203256e35f541026f34a8783235ae
|
||||
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
|
||||
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
|
||||
---
|
||||
|
||||
diff --git a/src/network/access/qhttp2protocolhandler.cpp b/src/network/access/qhttp2protocolhandler.cpp
|
||||
index 0abd99b9..3631b13d 100644
|
||||
--- a/src/network/access/qhttp2protocolhandler.cpp
|
||||
+++ b/src/network/access/qhttp2protocolhandler.cpp
|
||||
@@ -303,12 +303,12 @@ bool QHttp2ProtocolHandler::sendRequest()
|
||||
}
|
||||
}
|
||||
|
||||
- if (!prefaceSent && !sendClientPreface())
|
||||
- return false;
|
||||
-
|
||||
if (!requests.size())
|
||||
return true;
|
||||
|
||||
+ if (!prefaceSent && !sendClientPreface())
|
||||
+ return false;
|
||||
+
|
||||
m_channel->state = QHttpNetworkConnectionChannel::WritingState;
|
||||
// Check what was promised/pushed, maybe we do not have to send a request
|
||||
// and have a response already?
|
||||
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
|
||||
index 67669896..1e4161d1 100644
|
||||
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
|
||||
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
|
||||
@@ -209,6 +209,10 @@ void QHttpNetworkConnectionChannel::abort()
|
||||
bool QHttpNetworkConnectionChannel::sendRequest()
|
||||
{
|
||||
Q_ASSERT(protocolHandler);
|
||||
+ if (waitingForPotentialAbort) {
|
||||
+ needInvokeSendRequest = true;
|
||||
+ return false; // this return value is unused
|
||||
+ }
|
||||
return protocolHandler->sendRequest();
|
||||
}
|
||||
|
||||
@@ -221,21 +225,28 @@ bool QHttpNetworkConnectionChannel::sendRequest()
|
||||
void QHttpNetworkConnectionChannel::sendRequestDelayed()
|
||||
{
|
||||
QMetaObject::invokeMethod(this, [this] {
|
||||
- Q_ASSERT(protocolHandler);
|
||||
if (reply)
|
||||
- protocolHandler->sendRequest();
|
||||
+ sendRequest();
|
||||
}, Qt::ConnectionType::QueuedConnection);
|
||||
}
|
||||
|
||||
void QHttpNetworkConnectionChannel::_q_receiveReply()
|
||||
{
|
||||
Q_ASSERT(protocolHandler);
|
||||
+ if (waitingForPotentialAbort) {
|
||||
+ needInvokeReceiveReply = true;
|
||||
+ return;
|
||||
+ }
|
||||
protocolHandler->_q_receiveReply();
|
||||
}
|
||||
|
||||
void QHttpNetworkConnectionChannel::_q_readyRead()
|
||||
{
|
||||
Q_ASSERT(protocolHandler);
|
||||
+ if (waitingForPotentialAbort) {
|
||||
+ needInvokeReadyRead = true;
|
||||
+ return;
|
||||
+ }
|
||||
protocolHandler->_q_readyRead();
|
||||
}
|
||||
|
||||
@@ -1239,7 +1250,18 @@ void QHttpNetworkConnectionChannel::_q_encrypted()
|
||||
if (!h2RequestsToSend.isEmpty()) {
|
||||
// Similar to HTTP/1.1 counterpart below:
|
||||
const auto &pair = std::as_const(h2RequestsToSend).first();
|
||||
+ waitingForPotentialAbort = true;
|
||||
emit pair.second->encrypted();
|
||||
+
|
||||
+ // We don't send or handle any received data until any effects from
|
||||
+ // emitting encrypted() have been processed. This is necessary
|
||||
+ // because the user may have called abort(). We may also abort the
|
||||
+ // whole connection if the request has been aborted and there is
|
||||
+ // no more requests to send.
|
||||
+ QMetaObject::invokeMethod(this,
|
||||
+ &QHttpNetworkConnectionChannel::checkAndResumeCommunication,
|
||||
+ Qt::QueuedConnection);
|
||||
+
|
||||
// In case our peer has sent us its settings (window size, max concurrent streams etc.)
|
||||
// let's give _q_receiveReply a chance to read them first ('invokeMethod', QueuedConnection).
|
||||
}
|
||||
@@ -1257,6 +1279,28 @@ void QHttpNetworkConnectionChannel::_q_encrypted()
|
||||
QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
+
|
||||
+void QHttpNetworkConnectionChannel::checkAndResumeCommunication()
|
||||
+{
|
||||
+ Q_ASSERT(connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2
|
||||
+ || connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2Direct);
|
||||
+
|
||||
+ // Because HTTP/2 requires that we send a SETTINGS frame as the first thing we do, and respond
|
||||
+ // to a SETTINGS frame with an ACK, we need to delay any handling until we can ensure that any
|
||||
+ // effects from emitting encrypted() have been processed.
|
||||
+ // This function is called after encrypted() was emitted, so check for changes.
|
||||
+
|
||||
+ if (!reply && h2RequestsToSend.isEmpty())
|
||||
+ abort();
|
||||
+ waitingForPotentialAbort = false;
|
||||
+ if (needInvokeReadyRead)
|
||||
+ _q_readyRead();
|
||||
+ if (needInvokeReceiveReply)
|
||||
+ _q_receiveReply();
|
||||
+ if (needInvokeSendRequest)
|
||||
+ sendRequest();
|
||||
+}
|
||||
+
|
||||
void QHttpNetworkConnectionChannel::requeueHttp2Requests()
|
||||
{
|
||||
const auto h2RequestsToSendCopy = std::exchange(h2RequestsToSend, {});
|
||||
diff --git a/src/network/access/qhttpnetworkconnectionchannel_p.h b/src/network/access/qhttpnetworkconnectionchannel_p.h
|
||||
index c42290fe..061f20fd 100644
|
||||
--- a/src/network/access/qhttpnetworkconnectionchannel_p.h
|
||||
+++ b/src/network/access/qhttpnetworkconnectionchannel_p.h
|
||||
@@ -74,6 +74,10 @@ public:
|
||||
QAbstractSocket *socket;
|
||||
bool ssl;
|
||||
bool isInitialized;
|
||||
+ bool waitingForPotentialAbort = false;
|
||||
+ bool needInvokeReceiveReply = false;
|
||||
+ bool needInvokeReadyRead = false;
|
||||
+ bool needInvokeSendRequest = false;
|
||||
ChannelState state;
|
||||
QHttpNetworkRequest request; // current request, only used for HTTP
|
||||
QHttpNetworkReply *reply; // current reply for this request, only used for HTTP
|
||||
@@ -146,6 +150,8 @@ public:
|
||||
void closeAndResendCurrentRequest();
|
||||
void resendCurrentRequest();
|
||||
|
||||
+ void checkAndResumeCommunication();
|
||||
+
|
||||
bool isSocketBusy() const;
|
||||
bool isSocketWriting() const;
|
||||
bool isSocketWaiting() const;
|
||||
diff --git a/tests/auto/network/access/http2/tst_http2.cpp b/tests/auto/network/access/http2/tst_http2.cpp
|
||||
index 74be5afd..9e5f94e3 100644
|
||||
--- a/tests/auto/network/access/http2/tst_http2.cpp
|
||||
+++ b/tests/auto/network/access/http2/tst_http2.cpp
|
||||
@@ -106,6 +106,8 @@ private slots:
|
||||
|
||||
void duplicateRequestsWithAborts();
|
||||
|
||||
+ void abortOnEncrypted();
|
||||
+
|
||||
protected slots:
|
||||
// Slots to listen to our in-process server:
|
||||
void serverStarted(quint16 port);
|
||||
@@ -1479,6 +1481,48 @@ void tst_Http2::duplicateRequestsWithAborts()
|
||||
QCOMPARE(finishedCount, ExpectedSuccessfulRequests);
|
||||
}
|
||||
|
||||
+void tst_Http2::abortOnEncrypted()
|
||||
+{
|
||||
+#if !QT_CONFIG(ssl)
|
||||
+ QSKIP("TLS support is needed for this test");
|
||||
+#else
|
||||
+ clearHTTP2State();
|
||||
+ serverPort = 0;
|
||||
+
|
||||
+ ServerPtr targetServer(newServer(defaultServerSettings, H2Type::h2Direct));
|
||||
+
|
||||
+ QMetaObject::invokeMethod(targetServer.data(), "startServer", Qt::QueuedConnection);
|
||||
+ runEventLoop();
|
||||
+
|
||||
+ nRequests = 1;
|
||||
+ nSentRequests = 0;
|
||||
+
|
||||
+ const auto url = requestUrl(H2Type::h2Direct);
|
||||
+ QNetworkRequest request(url);
|
||||
+ request.setAttribute(QNetworkRequest::Http2DirectAttribute, true);
|
||||
+
|
||||
+ std::unique_ptr<QNetworkReply> reply{manager->get(request)};
|
||||
+ reply->ignoreSslErrors();
|
||||
+ connect(reply.get(), &QNetworkReply::encrypted, reply.get(), [reply = reply.get()](){
|
||||
+ reply->abort();
|
||||
+ });
|
||||
+ connect(reply.get(), &QNetworkReply::errorOccurred, this, &tst_Http2::replyFinishedWithError);
|
||||
+
|
||||
+ runEventLoop();
|
||||
+ STOP_ON_FAILURE
|
||||
+
|
||||
+ QCOMPARE(nRequests, 0);
|
||||
+ QCOMPARE(reply->error(), QNetworkReply::OperationCanceledError);
|
||||
+
|
||||
+ const bool res = QTest::qWaitFor(
|
||||
+ [this, server = targetServer.get()]() {
|
||||
+ return serverGotSettingsACK || prefaceOK || nSentRequests > 0;
|
||||
+ },
|
||||
+ 500);
|
||||
+ QVERIFY(!res);
|
||||
+#endif // QT_CONFIG(ssl)
|
||||
+}
|
||||
+
|
||||
void tst_Http2::serverStarted(quint16 port)
|
||||
{
|
||||
serverPort = port;
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,569 @@
|
||||
From aa7d479be0df3e118580e87f30e061445dfb37e3 Mon Sep 17 00:00:00 2001
|
||||
From: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
|
||||
Date: Fri, 02 Feb 2024 15:45:20 +0100
|
||||
Subject: [PATCH] Introduce emoji-segmenter to 3rdparty code
|
||||
|
||||
This is a parser for emoji sequences developed by Google
|
||||
which is used in multiple other projects for parsing
|
||||
sequences of characters to see if they should be represented
|
||||
as color emojis or as monochrome text.
|
||||
|
||||
[ChangeLog][Third-Party Code] Added the emoji-segmenter to
|
||||
third party code, for supporting complex emoji sequences.
|
||||
This can be configured using the -emojisegmenter option.
|
||||
|
||||
Task-number: QTBUG-111801
|
||||
Change-Id: I7f87b0751415024d29f074d133850027f0003e29
|
||||
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
|
||||
---
|
||||
|
||||
diff --git a/config_help.txt b/config_help.txt
|
||||
index 039582da..417c2067 100644
|
||||
--- a/config_help.txt
|
||||
+++ b/config_help.txt
|
||||
@@ -295,6 +295,7 @@ Gui, printing, widget options:
|
||||
|
||||
-cups ................ Enable CUPS support [auto] (Unix only)
|
||||
|
||||
+ -emojisegmenter ...... Enable complex emoji sequences [yes]
|
||||
-fontconfig .......... Enable Fontconfig support [auto] (Unix only)
|
||||
-freetype ............ Select used FreeType [system/qt/no]
|
||||
-harfbuzz ............ Select used HarfBuzz-NG [system/qt/no]
|
||||
diff --git a/src/3rdparty/emoji-segmenter/CONTRIBUTING.md b/src/3rdparty/emoji-segmenter/CONTRIBUTING.md
|
||||
new file mode 100644
|
||||
index 00000000..db177d4a
|
||||
--- /dev/null
|
||||
+++ b/src/3rdparty/emoji-segmenter/CONTRIBUTING.md
|
||||
@@ -0,0 +1,28 @@
|
||||
+# How to Contribute
|
||||
+
|
||||
+We'd love to accept your patches and contributions to this project. There are
|
||||
+just a few small guidelines you need to follow.
|
||||
+
|
||||
+## Contributor License Agreement
|
||||
+
|
||||
+Contributions to this project must be accompanied by a Contributor License
|
||||
+Agreement. You (or your employer) retain the copyright to your contribution;
|
||||
+this simply gives us permission to use and redistribute your contributions as
|
||||
+part of the project. Head over to <https://cla.developers.google.com/> to see
|
||||
+your current agreements on file or to sign a new one.
|
||||
+
|
||||
+You generally only need to submit a CLA once, so if you've already submitted one
|
||||
+(even if it was for a different project), you probably don't need to do it
|
||||
+again.
|
||||
+
|
||||
+## Code reviews
|
||||
+
|
||||
+All submissions, including submissions by project members, require review. We
|
||||
+use GitHub pull requests for this purpose. Consult
|
||||
+[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
|
||||
+information on using pull requests.
|
||||
+
|
||||
+## Community Guidelines
|
||||
+
|
||||
+This project follows
|
||||
+[Google's Open Source Community Guidelines](https://opensource.google.com/conduct/).
|
||||
diff --git a/src/3rdparty/emoji-segmenter/NEWS b/src/3rdparty/emoji-segmenter/NEWS
|
||||
new file mode 100644
|
||||
index 00000000..3fd07f1c
|
||||
--- /dev/null
|
||||
+++ b/src/3rdparty/emoji-segmenter/NEWS
|
||||
@@ -0,0 +1,28 @@
|
||||
+Overview of changes leading to 0.4.0
|
||||
+Friday, November 15, 2024
|
||||
+====================================
|
||||
+
|
||||
+* Add `make size` targe to
|
||||
+ determine binary size.
|
||||
+* Set has_vs for
|
||||
+ emoji_keycap_sequence
|
||||
+
|
||||
+Overview of changes leading to 0.3.0
|
||||
+Tuesday, September 5, 2024
|
||||
+====================================
|
||||
+
|
||||
+* Add segmentation for variation
|
||||
+ selector pairs, VS15 and VS16,
|
||||
+ needed for font-variant-emoji.
|
||||
+
|
||||
+Overview of changes leading to 0.2.0
|
||||
+Tuesday, Februar 20, 2024
|
||||
+====================================
|
||||
+
|
||||
+* Change Ragel mode to -F1
|
||||
+
|
||||
+Overview of changes leading to 0.1.0
|
||||
+Tuesday, January 29, 2019
|
||||
+====================================
|
||||
+
|
||||
+* Initial release
|
||||
diff --git a/src/3rdparty/emoji-segmenter/README.md b/src/3rdparty/emoji-segmenter/README.md
|
||||
new file mode 100644
|
||||
index 00000000..571a1a45
|
||||
--- /dev/null
|
||||
+++ b/src/3rdparty/emoji-segmenter/README.md
|
||||
@@ -0,0 +1,103 @@
|
||||
+Emoji Segmenter
|
||||
+===
|
||||
+
|
||||
+This repository contains a Ragel grammar and generated C code for segmenting
|
||||
+runs of text into text-presentation and emoji-presentation runs. It is currently
|
||||
+used in projects such as Chromium and Pango for deciding which preferred
|
||||
+presentation, color or text, a run of text should have.
|
||||
+
|
||||
+The goal is to stay very close to the grammar definitions in [Unicode Technical
|
||||
+Standard #51](http://www.unicode.org/reports/tr51/).
|
||||
+
|
||||
+API
|
||||
+===
|
||||
+
|
||||
+By including the `emoji_presentation_scanner.c` file, you will be able to call
|
||||
+the following API
|
||||
+
|
||||
+```
|
||||
+scan_emoji_presentation (emoji_text_iter_t p,
|
||||
+ const emoji_text_iter_t pe,
|
||||
+ bool* is_emoji,
|
||||
+ bool* has_vs)
|
||||
+```
|
||||
+
|
||||
+This API call will scan `emoji_text_iter_t p` for the next grammar-token and
|
||||
+return an iterator that points to the end of the next token. An end iterator
|
||||
+needs be specified as `pe` so that the scanner can compare against this and
|
||||
+knows where to stop. In the reference parameter `is_emoji` it returns whether
|
||||
+this token has emoji-presentation text-presentation, `has_vs` is set to true
|
||||
+if the token contains a variation selector.
|
||||
+
|
||||
+A grammar token is either a combination of an emoji plus variation selector 15
|
||||
+for text presentation, an emoji presentation sequence (emoji + VS16), an emoji
|
||||
+presentation emoji or emoji sequence, or a single text presentation character.
|
||||
+
|
||||
+`emoji_text_iter_t` is an iterator type over a buffer of the character classes
|
||||
+that are defined at the beginning of the the Ragel file, e.g. `EMOJI`,
|
||||
+`EMOJI_TEXT_PRESENTATION`, `REGIONAL_INDICATOR`, `KEYCAP_BASE`, etc.
|
||||
+
|
||||
+By typedef'ing `emoji_text_iter_t` to your own iterator type, you can implement
|
||||
+an adapter class that iterates over an input text buffer in any encoding, and on
|
||||
+dereferencing returns the correct Ragel class by implementing something similar
|
||||
+to the following Unicode character class to Ragel class mapping, example taken
|
||||
+from Chromium:
|
||||
+
|
||||
+```
|
||||
+char EmojiSegmentationCategory(UChar32 codepoint) {
|
||||
+ // Specific ones first.
|
||||
+ if (codepoint == kCombiningEnclosingKeycapCharacter)
|
||||
+ return COMBINING_ENCLOSING_KEYCAP;
|
||||
+ if (codepoint == kCombiningEnclosingCircleBackslashCharacter)
|
||||
+ return COMBINING_ENCLOSING_CIRCLE_BACKSLASH;
|
||||
+ if (codepoint == kZeroWidthJoinerCharacter)
|
||||
+ return ZWJ;
|
||||
+ if (codepoint == kVariationSelector15Character)
|
||||
+ return VS15;
|
||||
+ if (codepoint == kVariationSelector16Character)
|
||||
+ return VS16;
|
||||
+ if (codepoint == 0x1F3F4)
|
||||
+ return TAG_BASE;
|
||||
+ if ((codepoint >= 0xE0030 && codepoint <= 0xE0039) ||
|
||||
+ (codepoint >= 0xE0061 && codepoint <= 0xE007A))
|
||||
+ return TAG_SEQUENCE;
|
||||
+ if (codepoint == 0xE007F)
|
||||
+ return TAG_TERM;
|
||||
+ if (Character::IsEmojiModifierBase(codepoint))
|
||||
+ return EMOJI_MODIFIER_BASE;
|
||||
+ if (Character::IsModifier(codepoint))
|
||||
+ return EMOJI_MODIFIER;
|
||||
+ if (Character::IsRegionalIndicator(codepoint))
|
||||
+ return REGIONAL_INDICATOR;
|
||||
+ if (Character::IsEmojiKeycapBase(codepoint))
|
||||
+ return KEYCAP_BASE;
|
||||
+
|
||||
+ if (Character::IsEmojiEmojiDefault(codepoint))
|
||||
+ return EMOJI_EMOJI_PRESENTATION;
|
||||
+ if (Character::IsEmojiTextDefault(codepoint))
|
||||
+ return EMOJI_TEXT_PRESENTATION;
|
||||
+ if (Character::IsEmoji(codepoint))
|
||||
+ return EMOJI;
|
||||
+
|
||||
+ // Ragel state machine will interpret unknown category as "any".
|
||||
+ return kMaxEmojiScannerCategory;
|
||||
+}
|
||||
+```
|
||||
+
|
||||
+Update/Build requisites
|
||||
+===
|
||||
+
|
||||
+You need to have ragel installed if you want to modify the grammar and generate a new C file as output.
|
||||
+
|
||||
+`apt-get install ragel`
|
||||
+
|
||||
+then run
|
||||
+
|
||||
+`make`
|
||||
+
|
||||
+to update the `emoji_presentation_scanner.c` and `emoji_presentation_scanner_vs.c` output C source file.
|
||||
+
|
||||
+Contributing
|
||||
+===
|
||||
+
|
||||
+See the CONTRIBUTING.md file for how to contribute.
|
||||
diff --git a/src/3rdparty/emoji-segmenter/REUSE.toml b/src/3rdparty/emoji-segmenter/REUSE.toml
|
||||
new file mode 100644
|
||||
index 00000000..53d2dc47
|
||||
--- /dev/null
|
||||
+++ b/src/3rdparty/emoji-segmenter/REUSE.toml
|
||||
@@ -0,0 +1,7 @@
|
||||
+version = 1
|
||||
+
|
||||
+[[annotations]]
|
||||
+path = ["**"]
|
||||
+precedence = "closest"
|
||||
+SPDX-FileCopyrightText = "Copyright 2019 Google LLC"
|
||||
+SPDX-License-Identifier = "Apache-2.0"
|
||||
diff --git a/src/3rdparty/emoji-segmenter/emoji_presentation_scanner.c b/src/3rdparty/emoji-segmenter/emoji_presentation_scanner.c
|
||||
new file mode 100644
|
||||
index 00000000..00b7700a
|
||||
--- /dev/null
|
||||
+++ b/src/3rdparty/emoji-segmenter/emoji_presentation_scanner.c
|
||||
@@ -0,0 +1,251 @@
|
||||
+
|
||||
+#line 1 "emoji_presentation_scanner.rl"
|
||||
+/* Copyright 2019 Google LLC
|
||||
+ *
|
||||
+ * Licensed under the Apache License, Version 2.0 (the "License");
|
||||
+ * you may not use this file except in compliance with the License.
|
||||
+ * You may obtain a copy of the License at
|
||||
+ *
|
||||
+ * https://www.apache.org/licenses/LICENSE-2.0
|
||||
+ *
|
||||
+ * Unless required by applicable law or agreed to in writing, software
|
||||
+ * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
+ * See the License for the specific language governing permissions and
|
||||
+ * limitations under the License.
|
||||
+ */
|
||||
+
|
||||
+#include <stdbool.h>
|
||||
+
|
||||
+#ifndef EMOJI_LINKAGE
|
||||
+#define EMOJI_LINKAGE static
|
||||
+#endif
|
||||
+
|
||||
+
|
||||
+#line 23 "emoji_presentation_scanner.c"
|
||||
+static const unsigned char _emoji_presentation_trans_keys[] = {
|
||||
+ 0u, 13u, 14u, 15u, 0u, 13u, 9u, 12u, 10u, 12u, 10u, 10u, 4u, 12u, 4u, 12u,
|
||||
+ 6u, 6u, 9u, 12u, 8u, 8u, 8u, 10u, 9u, 14u, 0
|
||||
+};
|
||||
+
|
||||
+static const char _emoji_presentation_key_spans[] = {
|
||||
+ 14, 2, 14, 4, 3, 1, 9, 9,
|
||||
+ 1, 4, 1, 3, 6
|
||||
+};
|
||||
+
|
||||
+static const char _emoji_presentation_index_offsets[] = {
|
||||
+ 0, 15, 18, 33, 38, 42, 44, 54,
|
||||
+ 64, 66, 71, 73, 77
|
||||
+};
|
||||
+
|
||||
+static const char _emoji_presentation_indicies[] = {
|
||||
+ 1, 1, 1, 2, 0, 0, 0, 1,
|
||||
+ 0, 0, 0, 0, 0, 1, 0, 4,
|
||||
+ 5, 3, 6, 6, 7, 8, 9, 9,
|
||||
+ 10, 11, 9, 9, 9, 9, 9, 12,
|
||||
+ 9, 5, 13, 14, 15, 0, 13, 16,
|
||||
+ 17, 16, 13, 0, 17, 16, 16, 16,
|
||||
+ 16, 16, 13, 16, 17, 16, 17, 16,
|
||||
+ 16, 16, 16, 5, 13, 14, 15, 16,
|
||||
+ 5, 18, 5, 13, 19, 20, 18, 14,
|
||||
+ 21, 23, 22, 13, 22, 5, 13, 14,
|
||||
+ 15, 16, 4, 16, 0
|
||||
+};
|
||||
+
|
||||
+static const char _emoji_presentation_trans_targs[] = {
|
||||
+ 2, 4, 6, 2, 1, 2, 3, 3,
|
||||
+ 7, 2, 8, 9, 12, 0, 2, 5,
|
||||
+ 2, 5, 2, 10, 11, 2, 2, 2
|
||||
+};
|
||||
+
|
||||
+static const char _emoji_presentation_trans_actions[] = {
|
||||
+ 1, 2, 2, 3, 0, 4, 7, 2,
|
||||
+ 2, 8, 0, 7, 2, 0, 9, 10,
|
||||
+ 11, 2, 12, 0, 10, 13, 14, 15
|
||||
+};
|
||||
+
|
||||
+static const char _emoji_presentation_to_state_actions[] = {
|
||||
+ 0, 0, 5, 0, 0, 0, 0, 0,
|
||||
+ 0, 0, 0, 0, 0
|
||||
+};
|
||||
+
|
||||
+static const char _emoji_presentation_from_state_actions[] = {
|
||||
+ 0, 0, 6, 0, 0, 0, 0, 0,
|
||||
+ 0, 0, 0, 0, 0
|
||||
+};
|
||||
+
|
||||
+static const char _emoji_presentation_eof_trans[] = {
|
||||
+ 1, 4, 0, 1, 17, 1, 17, 17,
|
||||
+ 19, 19, 22, 23, 17
|
||||
+};
|
||||
+
|
||||
+static const int emoji_presentation_start = 2;
|
||||
+
|
||||
+static const int emoji_presentation_en_text_and_emoji_run = 2;
|
||||
+
|
||||
+
|
||||
+#line 26 "emoji_presentation_scanner.rl"
|
||||
+
|
||||
+
|
||||
+
|
||||
+#line 100 "emoji_presentation_scanner.rl"
|
||||
+
|
||||
+
|
||||
+EMOJI_LINKAGE emoji_text_iter_t
|
||||
+scan_emoji_presentation (emoji_text_iter_t p,
|
||||
+ const emoji_text_iter_t pe,
|
||||
+ bool* is_emoji,
|
||||
+ bool* has_vs)
|
||||
+{
|
||||
+ emoji_text_iter_t ts;
|
||||
+ emoji_text_iter_t te;
|
||||
+ const emoji_text_iter_t eof = pe;
|
||||
+
|
||||
+ (void)ts;
|
||||
+
|
||||
+ unsigned act;
|
||||
+ int cs;
|
||||
+
|
||||
+
|
||||
+#line 100 "emoji_presentation_scanner.c"
|
||||
+ {
|
||||
+ cs = emoji_presentation_start;
|
||||
+ ts = 0;
|
||||
+ te = 0;
|
||||
+ act = 0;
|
||||
+ }
|
||||
+
|
||||
+#line 106 "emoji_presentation_scanner.c"
|
||||
+ {
|
||||
+ int _slen;
|
||||
+ int _trans;
|
||||
+ const unsigned char *_keys;
|
||||
+ const char *_inds;
|
||||
+ if ( p == pe )
|
||||
+ goto _test_eof;
|
||||
+_resume:
|
||||
+ switch ( _emoji_presentation_from_state_actions[cs] ) {
|
||||
+ case 6:
|
||||
+#line 1 "NONE"
|
||||
+ {ts = p;}
|
||||
+ break;
|
||||
+#line 118 "emoji_presentation_scanner.c"
|
||||
+ }
|
||||
+
|
||||
+ _keys = _emoji_presentation_trans_keys + (cs<<1);
|
||||
+ _inds = _emoji_presentation_indicies + _emoji_presentation_index_offsets[cs];
|
||||
+
|
||||
+ _slen = _emoji_presentation_key_spans[cs];
|
||||
+ _trans = _inds[ _slen > 0 && _keys[0] <=(*p) &&
|
||||
+ (*p) <= _keys[1] ?
|
||||
+ (*p) - _keys[0] : _slen ];
|
||||
+
|
||||
+_eof_trans:
|
||||
+ cs = _emoji_presentation_trans_targs[_trans];
|
||||
+
|
||||
+ if ( _emoji_presentation_trans_actions[_trans] == 0 )
|
||||
+ goto _again;
|
||||
+
|
||||
+ switch ( _emoji_presentation_trans_actions[_trans] ) {
|
||||
+ case 9:
|
||||
+#line 94 "emoji_presentation_scanner.rl"
|
||||
+ {te = p+1;{ *is_emoji = false; *has_vs = true; return te; }}
|
||||
+ break;
|
||||
+ case 15:
|
||||
+#line 95 "emoji_presentation_scanner.rl"
|
||||
+ {te = p+1;{ *is_emoji = true; *has_vs = true; return te; }}
|
||||
+ break;
|
||||
+ case 4:
|
||||
+#line 96 "emoji_presentation_scanner.rl"
|
||||
+ {te = p+1;{ *is_emoji = true; *has_vs = false; return te; }}
|
||||
+ break;
|
||||
+ case 8:
|
||||
+#line 97 "emoji_presentation_scanner.rl"
|
||||
+ {te = p+1;{ *is_emoji = false; *has_vs = false; return te; }}
|
||||
+ break;
|
||||
+ case 13:
|
||||
+#line 94 "emoji_presentation_scanner.rl"
|
||||
+ {te = p;p--;{ *is_emoji = false; *has_vs = true; return te; }}
|
||||
+ break;
|
||||
+ case 14:
|
||||
+#line 95 "emoji_presentation_scanner.rl"
|
||||
+ {te = p;p--;{ *is_emoji = true; *has_vs = true; return te; }}
|
||||
+ break;
|
||||
+ case 11:
|
||||
+#line 96 "emoji_presentation_scanner.rl"
|
||||
+ {te = p;p--;{ *is_emoji = true; *has_vs = false; return te; }}
|
||||
+ break;
|
||||
+ case 12:
|
||||
+#line 97 "emoji_presentation_scanner.rl"
|
||||
+ {te = p;p--;{ *is_emoji = false; *has_vs = false; return te; }}
|
||||
+ break;
|
||||
+ case 3:
|
||||
+#line 96 "emoji_presentation_scanner.rl"
|
||||
+ {{p = ((te))-1;}{ *is_emoji = true; *has_vs = false; return te; }}
|
||||
+ break;
|
||||
+ case 1:
|
||||
+#line 1 "NONE"
|
||||
+ { switch( act ) {
|
||||
+ case 2:
|
||||
+ {{p = ((te))-1;} *is_emoji = true; *has_vs = true; return te; }
|
||||
+ break;
|
||||
+ case 3:
|
||||
+ {{p = ((te))-1;} *is_emoji = true; *has_vs = false; return te; }
|
||||
+ break;
|
||||
+ case 4:
|
||||
+ {{p = ((te))-1;} *is_emoji = false; *has_vs = false; return te; }
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ break;
|
||||
+ case 10:
|
||||
+#line 1 "NONE"
|
||||
+ {te = p+1;}
|
||||
+#line 95 "emoji_presentation_scanner.rl"
|
||||
+ {act = 2;}
|
||||
+ break;
|
||||
+ case 2:
|
||||
+#line 1 "NONE"
|
||||
+ {te = p+1;}
|
||||
+#line 96 "emoji_presentation_scanner.rl"
|
||||
+ {act = 3;}
|
||||
+ break;
|
||||
+ case 7:
|
||||
+#line 1 "NONE"
|
||||
+ {te = p+1;}
|
||||
+#line 97 "emoji_presentation_scanner.rl"
|
||||
+ {act = 4;}
|
||||
+ break;
|
||||
+#line 188 "emoji_presentation_scanner.c"
|
||||
+ }
|
||||
+
|
||||
+_again:
|
||||
+ switch ( _emoji_presentation_to_state_actions[cs] ) {
|
||||
+ case 5:
|
||||
+#line 1 "NONE"
|
||||
+ {ts = 0;}
|
||||
+ break;
|
||||
+#line 195 "emoji_presentation_scanner.c"
|
||||
+ }
|
||||
+
|
||||
+ if ( ++p != pe )
|
||||
+ goto _resume;
|
||||
+ _test_eof: {}
|
||||
+ if ( p == eof )
|
||||
+ {
|
||||
+ if ( _emoji_presentation_eof_trans[cs] > 0 ) {
|
||||
+ _trans = _emoji_presentation_eof_trans[cs] - 1;
|
||||
+ goto _eof_trans;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+#line 118 "emoji_presentation_scanner.rl"
|
||||
+
|
||||
+
|
||||
+ /* Should not be reached. */
|
||||
+ *is_emoji = false;
|
||||
+ *has_vs = false;
|
||||
+ return p;
|
||||
+}
|
||||
diff --git a/src/3rdparty/emoji-segmenter/patch/0001-Compile-with-warnings-are-errors.patch b/src/3rdparty/emoji-segmenter/patch/0001-Compile-with-warnings-are-errors.patch
|
||||
new file mode 100644
|
||||
index 00000000..0cc1868c
|
||||
--- /dev/null
|
||||
+++ b/src/3rdparty/emoji-segmenter/patch/0001-Compile-with-warnings-are-errors.patch
|
||||
@@ -0,0 +1,26 @@
|
||||
+From 4ced1426e27320e00b0dd28693df5d95c648d230 Mon Sep 17 00:00:00 2001
|
||||
+From: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
|
||||
+Date: Thu, 14 Nov 2024 09:42:11 +0100
|
||||
+Subject: [PATCH] Compile with warnings-are-errors
|
||||
+
|
||||
+Change-Id: Icea8febefc90f3f047143e5b76ff511145c0dcae
|
||||
+---
|
||||
+ src/3rdparty/emoji-segmenter/emoji_presentation_scanner.c | 2 ++
|
||||
+ 1 file changed, 2 insertions(+)
|
||||
+
|
||||
+diff --git a/src/3rdparty/emoji-segmenter/emoji_presentation_scanner.c b/src/3rdparty/emoji-segmenter/emoji_presentation_scanner.c
|
||||
+index 56e2e78033..ce7e01846c 100644
|
||||
+--- a/src/3rdparty/emoji-segmenter/emoji_presentation_scanner.c
|
||||
++++ b/src/3rdparty/emoji-segmenter/emoji_presentation_scanner.c
|
||||
+@@ -101,6 +101,8 @@ scan_emoji_presentation (emoji_text_iter_t p,
|
||||
+ emoji_text_iter_t te;
|
||||
+ const emoji_text_iter_t eof = pe;
|
||||
+
|
||||
++ (void)ts;
|
||||
++
|
||||
+ unsigned act;
|
||||
+ int cs;
|
||||
+
|
||||
+--
|
||||
+2.40.0.windows.1
|
||||
+
|
||||
diff --git a/src/3rdparty/emoji-segmenter/qt_attribution.json b/src/3rdparty/emoji-segmenter/qt_attribution.json
|
||||
new file mode 100644
|
||||
index 00000000..64083381
|
||||
--- /dev/null
|
||||
+++ b/src/3rdparty/emoji-segmenter/qt_attribution.json
|
||||
@@ -0,0 +1,16 @@
|
||||
+{
|
||||
+ "Id": "emoji-segmenter",
|
||||
+ "Name": "Emoji Segmenter",
|
||||
+ "QDocModule": "qtgui",
|
||||
+ "QtUsage": "Used in QtGui for parsing complex emoji sequences. Can be configured using the -emojisegmenter option.",
|
||||
+ "SecurityCritical": true,
|
||||
+
|
||||
+ "Description": "A parser for emoji sequences.",
|
||||
+ "Homepage": "https://github.com/google/emoji-segmenter",
|
||||
+ "Version": "0.4.0",
|
||||
+ "DownloadLocation": "https://github.com/google/emoji-segmenter/releases/tag/0.4.0",
|
||||
+
|
||||
+ "License": "Apache License 2.0",
|
||||
+ "LicenseId": "Apache-2.0",
|
||||
+ "Copyright": "Copyright 2019 Google LLC"
|
||||
+}
|
||||
diff --git a/src/gui/configure.cmake b/src/gui/configure.cmake
|
||||
index 0e53f512..44bef7d3 100644
|
||||
--- a/src/gui/configure.cmake
|
||||
+++ b/src/gui/configure.cmake
|
||||
@@ -689,6 +689,12 @@ qt_feature("direct2d1_1" PRIVATE
|
||||
LABEL "Direct 2D 1.1"
|
||||
CONDITION QT_FEATURE_direct2d AND TEST_d2d1_1
|
||||
)
|
||||
+qt_feature("emojisegmenter" PUBLIC PRIVATE
|
||||
+ SECTION "Fonts"
|
||||
+ LABEL "Emoji Segmenter"
|
||||
+ PURPOSE "Supports parsing complex emoji sequences for better font resolution."
|
||||
+)
|
||||
+qt_feature_definition("emojisegmenter" "QT_NO_EMOJISEGMENTER" NEGATE VALUE "1")
|
||||
qt_feature("evdev" PRIVATE
|
||||
LABEL "evdev"
|
||||
CONDITION QT_FEATURE_thread AND TEST_evdev
|
||||
@@ -1285,6 +1291,7 @@ qt_feature("wayland" PUBLIC
|
||||
|
||||
qt_configure_add_summary_section(NAME "Qt Gui")
|
||||
qt_configure_add_summary_entry(ARGS "accessibility")
|
||||
+qt_configure_add_summary_entry(ARGS "emojisegmenter")
|
||||
qt_configure_add_summary_entry(ARGS "freetype")
|
||||
qt_configure_add_summary_entry(ARGS "system-freetype")
|
||||
qt_configure_add_summary_entry(ARGS "harfbuzz")
|
||||
diff --git a/src/gui/qt_cmdline.cmake b/src/gui/qt_cmdline.cmake
|
||||
index 446618eb..5465b2c6 100644
|
||||
--- a/src/gui/qt_cmdline.cmake
|
||||
+++ b/src/gui/qt_cmdline.cmake
|
||||
@@ -10,6 +10,7 @@ qt_commandline_option(eglfs TYPE boolean)
|
||||
qt_commandline_option(evdev TYPE boolean)
|
||||
qt_commandline_option(fontconfig TYPE boolean)
|
||||
qt_commandline_option(freetype TYPE enum VALUES no qt system)
|
||||
+qt_commandline_option(emojisegmenter TYPE boolean)
|
||||
qt_commandline_option(gbm TYPE boolean)
|
||||
qt_commandline_option(gif TYPE boolean)
|
||||
qt_commandline_option(harfbuzz TYPE enum VALUES no qt system)
|
@ -1,310 +0,0 @@
|
||||
From d0b4e8a601bc2f81ddb23c124acc99defa26c02f Mon Sep 17 00:00:00 2001
|
||||
From: Jan Grulich <jgrulich@redhat.com>
|
||||
Date: Fri, 22 Mar 2024 12:12:51 +0100
|
||||
Subject: [PATCH] QGtk3Theme: Add support for xdg-desktop-portal to get color scheme
|
||||
|
||||
Use xdg-desktop-portal to get color scheme used by GNOME. Recent GNOME
|
||||
versions use this as primary way to switch between light and dark theme.
|
||||
Make this a preferred way to get color scheme and fallback to previous
|
||||
methods in case xdg-desktop-portal cannot be used. Also update app theme
|
||||
on runtime when color scheme changes, not only when theme is changed.
|
||||
|
||||
[ChangeLog][Platform Specific Changes][Linux] Add support for
|
||||
xdg-desktop-portal to get color scheme in QGtk3Theme.
|
||||
|
||||
Fixes: QTBUG-116197
|
||||
Change-Id: Ib3ffad405bc795ed6f4de4af411efc45721662b9
|
||||
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
|
||||
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
|
||||
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
|
||||
---
|
||||
|
||||
diff --git a/src/plugins/platformthemes/gtk3/CMakeLists.txt b/src/plugins/platformthemes/gtk3/CMakeLists.txt
|
||||
index becfccc..6d3c7bf 100644
|
||||
--- a/src/plugins/platformthemes/gtk3/CMakeLists.txt
|
||||
+++ b/src/plugins/platformthemes/gtk3/CMakeLists.txt
|
||||
@@ -35,6 +35,13 @@
|
||||
Qt::GuiPrivate
|
||||
)
|
||||
|
||||
+qt_internal_extend_target(QGtk3ThemePlugin CONDITION QT_FEATURE_dbus
|
||||
+ SOURCES
|
||||
+ qgtk3portalinterface.cpp
|
||||
+ LIBRARIES
|
||||
+ Qt::DBus
|
||||
+)
|
||||
+
|
||||
qt_internal_extend_target(QGtk3ThemePlugin CONDITION QT_FEATURE_xlib
|
||||
LIBRARIES
|
||||
X11::X11
|
||||
diff --git a/src/plugins/platformthemes/gtk3/qgtk3portalinterface.cpp b/src/plugins/platformthemes/gtk3/qgtk3portalinterface.cpp
|
||||
new file mode 100644
|
||||
index 0000000..1ffdda7
|
||||
--- /dev/null
|
||||
+++ b/src/plugins/platformthemes/gtk3/qgtk3portalinterface.cpp
|
||||
@@ -0,0 +1,123 @@
|
||||
+// Copyright (C) 2024 The Qt Company Ltd.
|
||||
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
+
|
||||
+//
|
||||
+// W A R N I N G
|
||||
+// -------------
|
||||
+//
|
||||
+// This file is not part of the Qt API. It exists purely as an
|
||||
+// implementation detail. This header file may change from version to
|
||||
+// version without notice, or even be removed.
|
||||
+//
|
||||
+// We mean it.
|
||||
+//
|
||||
+
|
||||
+#include "qgtk3portalinterface_p.h"
|
||||
+#include "qgtk3storage_p.h"
|
||||
+
|
||||
+#include <QtDBus/QDBusArgument>
|
||||
+#include <QtDBus/QDBusConnection>
|
||||
+#include <QtDBus/QDBusMessage>
|
||||
+#include <QtDBus/QDBusPendingCall>
|
||||
+#include <QtDBus/QDBusPendingCallWatcher>
|
||||
+#include <QtDBus/QDBusPendingReply>
|
||||
+#include <QtDBus/QDBusVariant>
|
||||
+#include <QtDBus/QtDBus>
|
||||
+
|
||||
+QT_BEGIN_NAMESPACE
|
||||
+
|
||||
+Q_LOGGING_CATEGORY(lcQGtk3PortalInterface, "qt.qpa.gtk");
|
||||
+
|
||||
+using namespace Qt::StringLiterals;
|
||||
+
|
||||
+static constexpr QLatin1StringView appearanceInterface("org.freedesktop.appearance");
|
||||
+static constexpr QLatin1StringView colorSchemeKey("color-scheme");
|
||||
+
|
||||
+const QDBusArgument &operator>>(const QDBusArgument &argument, QMap<QString, QVariantMap> &map)
|
||||
+{
|
||||
+ argument.beginMap();
|
||||
+ map.clear();
|
||||
+
|
||||
+ while (!argument.atEnd()) {
|
||||
+ QString key;
|
||||
+ QVariantMap value;
|
||||
+ argument.beginMapEntry();
|
||||
+ argument >> key >> value;
|
||||
+ argument.endMapEntry();
|
||||
+ map.insert(key, value);
|
||||
+ }
|
||||
+
|
||||
+ argument.endMap();
|
||||
+ return argument;
|
||||
+}
|
||||
+
|
||||
+QGtk3PortalInterface::QGtk3PortalInterface(QGtk3Storage *s)
|
||||
+ : m_storage(s) {
|
||||
+ qRegisterMetaType<QDBusVariant>();
|
||||
+ qDBusRegisterMetaType<QMap<QString, QVariantMap>>();
|
||||
+
|
||||
+ queryColorScheme();
|
||||
+
|
||||
+ if (!s) {
|
||||
+ qCDebug(lcQGtk3PortalInterface) << "QGtk3PortalInterface instantiated without QGtk3Storage."
|
||||
+ << "No reaction to runtime theme changes.";
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+Qt::ColorScheme QGtk3PortalInterface::colorScheme() const
|
||||
+{
|
||||
+ return m_colorScheme;
|
||||
+}
|
||||
+
|
||||
+void QGtk3PortalInterface::queryColorScheme() {
|
||||
+ QDBusConnection connection = QDBusConnection::sessionBus();
|
||||
+ QDBusMessage message = QDBusMessage::createMethodCall(
|
||||
+ "org.freedesktop.portal.Desktop"_L1,
|
||||
+ "/org/freedesktop/portal/desktop"_L1,
|
||||
+ "org.freedesktop.portal.Settings"_L1, "ReadAll"_L1);
|
||||
+ message << QStringList{ appearanceInterface };
|
||||
+
|
||||
+ QDBusPendingCall pendingCall = connection.asyncCall(message);
|
||||
+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall, this);
|
||||
+ QObject::connect(
|
||||
+ watcher, &QDBusPendingCallWatcher::finished, this,
|
||||
+ [this](QDBusPendingCallWatcher *watcher) {
|
||||
+ QDBusPendingReply<QMap<QString, QVariantMap>> reply = *watcher;
|
||||
+ if (reply.isValid()) {
|
||||
+ QMap<QString, QVariantMap> settings = reply.value();
|
||||
+ if (!settings.isEmpty()) {
|
||||
+ settingChanged(appearanceInterface, colorSchemeKey,
|
||||
+ QDBusVariant(settings.value(appearanceInterface).value(colorSchemeKey)));
|
||||
+ }
|
||||
+ } else {
|
||||
+ qCDebug(lcQGtk3PortalInterface) << "Failed to query org.freedesktop.portal.Settings: "
|
||||
+ << reply.error().message();
|
||||
+ }
|
||||
+ watcher->deleteLater();
|
||||
+ });
|
||||
+
|
||||
+ QDBusConnection::sessionBus().connect(
|
||||
+ "org.freedesktop.portal.Desktop"_L1, "/org/freedesktop/portal/desktop"_L1,
|
||||
+ "org.freedesktop.portal.Settings"_L1, "SettingChanged"_L1, this,
|
||||
+ SLOT(settingChanged(QString, QString, QDBusVariant)));
|
||||
+}
|
||||
+
|
||||
+void QGtk3PortalInterface::settingChanged(const QString &group, const QString &key,
|
||||
+ const QDBusVariant &value)
|
||||
+{
|
||||
+ if (group == appearanceInterface && key == colorSchemeKey) {
|
||||
+ const uint colorScheme = value.variant().toUInt();
|
||||
+ // From org.freedesktop.portal.Settings.xml
|
||||
+ // "1" - Prefer dark appearance
|
||||
+ Qt::ColorScheme newColorScheme = colorScheme == 1 ? Qt::ColorScheme::Dark : Qt::ColorScheme::Light;
|
||||
+ if (m_colorScheme != newColorScheme) {
|
||||
+ m_colorScheme = newColorScheme;
|
||||
+ if (m_storage)
|
||||
+ m_storage->handleThemeChange();
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+QT_END_NAMESPACE
|
||||
+
|
||||
+#include "moc_qgtk3portalinterface_p.cpp"
|
||||
diff --git a/src/plugins/platformthemes/gtk3/qgtk3portalinterface_p.h b/src/plugins/platformthemes/gtk3/qgtk3portalinterface_p.h
|
||||
new file mode 100644
|
||||
index 0000000..25a5f58
|
||||
--- /dev/null
|
||||
+++ b/src/plugins/platformthemes/gtk3/qgtk3portalinterface_p.h
|
||||
@@ -0,0 +1,49 @@
|
||||
+// Copyright (C) 2024 The Qt Company Ltd.
|
||||
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
+
|
||||
+#ifndef QGTK3PORTALINTERFACE_H
|
||||
+#define QGTK3PORTALINTERFACE_H
|
||||
+
|
||||
+//
|
||||
+// W A R N I N G
|
||||
+// -------------
|
||||
+//
|
||||
+// This file is not part of the Qt API. It exists purely as an
|
||||
+// implementation detail. This header file may change from version to
|
||||
+// version without notice, or even be removed.
|
||||
+//
|
||||
+// We mean it.
|
||||
+//
|
||||
+
|
||||
+#include <QtCore/QObject>
|
||||
+#include <QtCore/QLoggingCategory>
|
||||
+
|
||||
+QT_BEGIN_NAMESPACE
|
||||
+
|
||||
+class QDBusVariant;
|
||||
+class QGtk3Storage;
|
||||
+
|
||||
+Q_DECLARE_LOGGING_CATEGORY(lcQGtk3PortalInterface);
|
||||
+
|
||||
+class QGtk3PortalInterface : public QObject
|
||||
+{
|
||||
+ Q_OBJECT
|
||||
+public:
|
||||
+ QGtk3PortalInterface(QGtk3Storage *s);
|
||||
+ ~QGtk3PortalInterface() = default;
|
||||
+
|
||||
+ Qt::ColorScheme colorScheme() const;
|
||||
+
|
||||
+private Q_SLOTS:
|
||||
+ void settingChanged(const QString &group, const QString &key,
|
||||
+ const QDBusVariant &value);
|
||||
+private:
|
||||
+ void queryColorScheme();
|
||||
+
|
||||
+ Qt::ColorScheme m_colorScheme = Qt::ColorScheme::Unknown;
|
||||
+ QGtk3Storage *m_storage = nullptr;
|
||||
+};
|
||||
+
|
||||
+QT_END_NAMESPACE
|
||||
+
|
||||
+#endif // QGTK3PORTALINTERFACE_H
|
||||
diff --git a/src/plugins/platformthemes/gtk3/qgtk3storage.cpp b/src/plugins/platformthemes/gtk3/qgtk3storage.cpp
|
||||
index 90c0282..2877b28 100644
|
||||
--- a/src/plugins/platformthemes/gtk3/qgtk3storage.cpp
|
||||
+++ b/src/plugins/platformthemes/gtk3/qgtk3storage.cpp
|
||||
@@ -21,6 +21,9 @@
|
||||
QGtk3Storage::QGtk3Storage()
|
||||
{
|
||||
m_interface.reset(new QGtk3Interface(this));
|
||||
+#if QT_CONFIG(dbus)
|
||||
+ m_portalInterface.reset(new QGtk3PortalInterface(this));
|
||||
+#endif
|
||||
populateMap();
|
||||
}
|
||||
|
||||
@@ -273,7 +276,6 @@
|
||||
*/
|
||||
void QGtk3Storage::handleThemeChange()
|
||||
{
|
||||
- clear();
|
||||
populateMap();
|
||||
QWindowSystemInterface::handleThemeChange();
|
||||
}
|
||||
@@ -331,21 +333,32 @@
|
||||
static QString m_themeName;
|
||||
|
||||
// Distiguish initialization, theme change or call without theme change
|
||||
+ Qt::ColorScheme newColorScheme = Qt::ColorScheme::Unknown;
|
||||
const QString newThemeName = themeName();
|
||||
- if (m_themeName == newThemeName)
|
||||
+
|
||||
+#if QT_CONFIG(dbus)
|
||||
+ // Prefer color scheme we get from xdg-desktop-portal as this is what GNOME
|
||||
+ // relies on these days
|
||||
+ newColorScheme = m_portalInterface->colorScheme();
|
||||
+#endif
|
||||
+
|
||||
+ if (newColorScheme == Qt::ColorScheme::Unknown) {
|
||||
+ // Derive color scheme from theme name
|
||||
+ newColorScheme = newThemeName.contains("dark"_L1, Qt::CaseInsensitive)
|
||||
+ ? Qt::ColorScheme::Dark : m_interface->colorSchemeByColors();
|
||||
+ }
|
||||
+
|
||||
+ if (m_themeName == newThemeName && m_colorScheme == newColorScheme)
|
||||
return;
|
||||
|
||||
clear();
|
||||
|
||||
- // Derive color scheme from theme name
|
||||
- m_colorScheme = newThemeName.contains("dark"_L1, Qt::CaseInsensitive)
|
||||
- ? Qt::ColorScheme::Dark : m_interface->colorSchemeByColors();
|
||||
-
|
||||
if (m_themeName.isEmpty()) {
|
||||
- qCDebug(lcQGtk3Interface) << "GTK theme initialized:" << newThemeName << m_colorScheme;
|
||||
+ qCDebug(lcQGtk3Interface) << "GTK theme initialized:" << newThemeName << newColorScheme;
|
||||
} else {
|
||||
- qCDebug(lcQGtk3Interface) << "GTK theme changed to:" << newThemeName << m_colorScheme;
|
||||
+ qCDebug(lcQGtk3Interface) << "GTK theme changed to:" << newThemeName << newColorScheme;
|
||||
}
|
||||
+ m_colorScheme = newColorScheme;
|
||||
m_themeName = newThemeName;
|
||||
|
||||
// create standard mapping or load from Json file?
|
||||
diff --git a/src/plugins/platformthemes/gtk3/qgtk3storage_p.h b/src/plugins/platformthemes/gtk3/qgtk3storage_p.h
|
||||
index 37c5bf5..4519226 100644
|
||||
--- a/src/plugins/platformthemes/gtk3/qgtk3storage_p.h
|
||||
+++ b/src/plugins/platformthemes/gtk3/qgtk3storage_p.h
|
||||
@@ -16,6 +16,9 @@
|
||||
//
|
||||
|
||||
#include "qgtk3interface_p.h"
|
||||
+#if QT_CONFIG(dbus)
|
||||
+#include "qgtk3portalinterface_p.h"
|
||||
+#endif
|
||||
|
||||
#include <QtCore/QJsonDocument>
|
||||
#include <QtCore/QCache>
|
||||
@@ -205,7 +208,9 @@
|
||||
PaletteMap m_palettes;
|
||||
|
||||
std::unique_ptr<QGtk3Interface> m_interface;
|
||||
-
|
||||
+#if QT_CONFIG(dbus)
|
||||
+ std::unique_ptr<QGtk3PortalInterface> m_portalInterface;
|
||||
+#endif
|
||||
|
||||
Qt::ColorScheme m_colorScheme = Qt::ColorScheme::Unknown;
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue