diff options
author | Tim Jenssen <tim.jenssen@qt.io> | 2020-01-24 11:26:06 +0100 |
---|---|---|
committer | Tim Jenssen <tim.jenssen@qt.io> | 2020-02-05 14:58:52 +0000 |
commit | 4975a33ba9aa357ba2bca93e292b1fbcfb34c24e (patch) | |
tree | ee096871e60633c203232048131d51759da2cd19 /src/plugins | |
parent | 75ce6f3cd03362e6d763ae3bc21ab793a3675fce (diff) |
QmlDebug: add new debugtranslationservice
Users were asking for having the possibility to see where the translated
text will not fit in the reserved/available space.
This is more a preparation patch to get the right connectors to change the
visualization of findings or maybe log this to a file.
Task-number: QDS-1463
Change-Id: Ic0a7a930141d6eeb79964e51c0a165c69888cf5d
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/plugins')
6 files changed, 170 insertions, 2 deletions
diff --git a/src/plugins/qmltooling/qmldbg_preview/qmldbg_preview.pro b/src/plugins/qmltooling/qmldbg_preview/qmldbg_preview.pro index 08686a43e3..e1cbc393f7 100644 --- a/src/plugins/qmltooling/qmldbg_preview/qmldbg_preview.pro +++ b/src/plugins/qmltooling/qmldbg_preview/qmldbg_preview.pro @@ -3,6 +3,7 @@ QT += core-private qml-private packetprotocol-private network quick-private gui- TARGET = qmldbg_preview SOURCES += \ + $$PWD/qqmldebugtranslationservice.cpp \ $$PWD/qqmlpreviewblacklist.cpp \ $$PWD/qqmlpreviewfileengine.cpp \ $$PWD/qqmlpreviewfileloader.cpp \ @@ -12,6 +13,7 @@ SOURCES += \ $$PWD/qqmlpreviewservicefactory.cpp HEADERS += \ + $$PWD/qqmldebugtranslationservice.h \ $$PWD/qqmlpreviewblacklist.h \ $$PWD/qqmlpreviewfileengine.h \ $$PWD/qqmlpreviewfileloader.h \ diff --git a/src/plugins/qmltooling/qmldbg_preview/qqmldebugtranslationservice.cpp b/src/plugins/qmltooling/qmldbg_preview/qqmldebugtranslationservice.cpp new file mode 100644 index 0000000000..1561777202 --- /dev/null +++ b/src/plugins/qmltooling/qmldbg_preview/qqmldebugtranslationservice.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmldebugtranslationservice.h" + +QT_BEGIN_NAMESPACE + +QQmlDebugTranslationServiceImpl::QQmlDebugTranslationServiceImpl(QObject *parent) : + QQmlDebugTranslationService(1, parent) +{ +} + +void QQmlDebugTranslationServiceImpl::messageReceived(const QByteArray &message) +{ + Q_UNUSED(message) +} + +QString QQmlDebugTranslationServiceImpl::foundElidedText(QObject *textObject, const QString &layoutText, const QString &elideText) +{ + Q_UNUSED(textObject) + Q_UNUSED(layoutText) + return elideText; +} + +void QQmlDebugTranslationServiceImpl::foundTranslationBinding(QQmlTranslationBinding *binding, QObject *scopeObject, QQmlContextData *contextData) +{ + Q_UNUSED(binding) + Q_UNUSED(scopeObject) + Q_UNUSED(contextData) +} + +QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_preview/qqmldebugtranslationservice.h b/src/plugins/qmltooling/qmldbg_preview/qqmldebugtranslationservice.h new file mode 100644 index 0000000000..a337a937a5 --- /dev/null +++ b/src/plugins/qmltooling/qmldbg_preview/qqmldebugtranslationservice.h @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDEBUGMESSAGESERVICE_H +#define QDEBUGMESSAGESERVICE_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 <private/qqmldebugserviceinterfaces_p.h> + +#include <QtCore/qlogging.h> +#include <QtCore/qmutex.h> +#include <QtCore/qelapsedtimer.h> + +QT_BEGIN_NAMESPACE + +class QQmlDebugTranslationServicePrivate; + +class QQmlDebugTranslationServiceImpl : public QQmlDebugTranslationService +{ + Q_OBJECT +public: + //needs to be in sync with QQmlDebugTranslationClient in qqmldebugtranslationclient_p.h + enum Command { + ChangeLanguage, + ChangeWarningColor, + ChangeElidedTextWarningString, + SetDebugTranslationServiceLogFile, + EnableElidedTextWarning, + DisableElidedTextWarning, + TestAllLanguages + }; + QQmlDebugTranslationServiceImpl(QObject *parent = 0); + + QString foundElidedText(QObject *textObject, const QString &layoutText, const QString &elideText) override; + void foundTranslationBinding(QQmlTranslationBinding *binding, QObject *scopeObject, QQmlContextData *contextData) override; + void messageReceived(const QByteArray &message) override; +}; + +QT_END_NAMESPACE + +#endif // QDEBUGMESSAGESERVICE_H diff --git a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservice.json b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservice.json index d7e1ef1f10..5e148f8101 100644 --- a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservice.json +++ b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservice.json @@ -1,3 +1,3 @@ { - "Keys" : [ "QmlPreview" ] + "Keys" : [ "QmlPreview", "DebugTranslation" ] } diff --git a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservicefactory.cpp b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservicefactory.cpp index f0aa3226c8..6ff9805bbe 100644 --- a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservicefactory.cpp +++ b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservicefactory.cpp @@ -39,12 +39,18 @@ #include "qqmlpreviewservicefactory.h" #include "qqmlpreviewservice.h" +#include "qqmldebugtranslationservice.h" QT_BEGIN_NAMESPACE QQmlDebugService *QQmlPreviewServiceFactory::create(const QString &key) { - return key == QQmlPreviewServiceImpl::s_key ? new QQmlPreviewServiceImpl(this) : nullptr; + if (key == QQmlPreviewServiceImpl::s_key) + return new QQmlPreviewServiceImpl(this); + if (key == QQmlDebugTranslationServiceImpl::s_key) + return new QQmlDebugTranslationServiceImpl(this); + + return nullptr; } QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp index cc663cd6b3..33b6606b44 100644 --- a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp +++ b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp @@ -422,6 +422,11 @@ void QQmlDebugServerImpl::parseArguments() << tr("Sends qDebug() and similar messages over the QML debug\n" "\t\t connection. QtCreator uses this for showing debug\n" "\t\t messages in the debugger console.") << '\n' + << '\n' << QQmlDebugTranslationService::s_key << "\t- " + //: Please preserve the line breaks and formatting + << tr("helps to see if a translated text\n" + "\t\t will result in an elided text\n" + "\t\t in QML elements.") << '\n' << tr("Other services offered by qmltooling plugins that implement " "QQmlDebugServiceFactory and which can be found in the standard plugin " "paths will also be available and can be specified. If no \"services\" " |