2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2020 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2020-05-28 12:35:25 +02:00
|
|
|
|
|
|
|
|
#include "qmldebugtranslationclient.h"
|
|
|
|
|
#include <qmldebug/qpacketprotocol.h>
|
|
|
|
|
|
2021-05-07 09:19:39 +02:00
|
|
|
#include <QUrl>
|
|
|
|
|
|
2021-03-25 02:45:40 +01:00
|
|
|
#ifdef FOUND_QML_DEBUG_TRANSLATION_PROTOCOL
|
|
|
|
|
#include <private/qqmldebugtranslationprotocol_p.h>
|
|
|
|
|
#endif
|
2020-05-28 12:35:25 +02:00
|
|
|
|
|
|
|
|
namespace QmlPreview {
|
|
|
|
|
|
|
|
|
|
QmlDebugTranslationClient::QmlDebugTranslationClient(QmlDebug::QmlDebugConnection *connection) :
|
|
|
|
|
QmlDebug::QmlDebugClient(QLatin1String("DebugTranslation"), connection)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-28 08:20:23 +02:00
|
|
|
void QmlDebugTranslationClient::changeLanguage(const QUrl &url, const QString &localeIsoCode)
|
2020-05-28 12:35:25 +02:00
|
|
|
{
|
|
|
|
|
QmlDebug::QPacket packet(dataStreamVersion());
|
2021-03-25 02:45:40 +01:00
|
|
|
#ifdef FOUND_QML_DEBUG_TRANSLATION_PROTOCOL
|
|
|
|
|
sendMessage(QQmlDebugTranslation::createChangeLanguageRequest(packet, url, localeIsoCode));
|
|
|
|
|
#else
|
|
|
|
|
const int request_change_language = 1;
|
|
|
|
|
packet << request_change_language << url << localeIsoCode;
|
2020-05-28 12:35:25 +02:00
|
|
|
sendMessage(packet.data());
|
2021-03-25 02:45:40 +01:00
|
|
|
#endif
|
2020-07-23 08:37:37 +02:00
|
|
|
|
2020-05-28 12:35:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlDebugTranslationClient::stateChanged(QmlDebug::QmlDebugClient::State state)
|
|
|
|
|
{
|
|
|
|
|
if (state == Unavailable)
|
|
|
|
|
emit debugServiceUnavailable();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace QmlPreview
|