Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
proxytranslator.h
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant
4
5#ifndef PROXYTRANSLATOR_H
6#define PROXYTRANSLATOR_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <private/qqmldebugserviceinterfaces_p.h>
20#include <private/qqmlglobal_p.h>
21
22#include <QtCore/qstring.h>
23#include <QtCore/qurl.h>
24#include <QtCore/qtranslator.h>
25
26#include <memory>
27
28QT_BEGIN_NAMESPACE
29
30class ProxyTranslator : public QTranslator
31{
32 Q_OBJECT
33public:
34 QString translate(const char *context, const char *sourceText, const char *disambiguation, int n) const override;
35 bool isEmpty() const override;
36
37 QString currentUILanguages() const;
38 void setLanguage(const QUrl &context, const QLocale &locale);
39 void addEngine(QQmlEngine *engine);
40 void removeEngine(QQmlEngine *engine);
41
42 bool hasTranslation(const TranslationBindingInformation &translationBindingInformation) const;
43 static QString
44 translationFromInformation(const TranslationBindingInformation &translationBindingInformation);
45 static QQmlSourceLocation sourceLocationFromInformation(const TranslationBindingInformation &translationBindingInformation);
46Q_SIGNALS:
47 void languageChanged(const QLocale &locale);
48
49private:
50 void resetTranslationFound() const;
51 bool translationFound() const;
52 QList<QQmlEngine *> m_engines;
53 std::unique_ptr<QTranslator> m_qtTranslator;
54 std::unique_ptr<QTranslator> m_qmlTranslator;
55 bool m_enable = false;
56 QString m_currentUILanguages;
57 mutable bool m_translationFound = false;
58};
59
61
62#endif // PROXYTRANSLATOR_H
Combined button and popup list for selecting options.