qt.cfg: Add Q_DECLARE_TR_FUNCTIONS() and others (#1677)
Add unknownMacro Q_DECLARE_TR_FUNCTIONS found via daca@home. Add function QCoreApplication::translate() and macro QT_DECLARE_DEPRECATED_TR_FUNCTIONS() the unknownMacro depends on. Reference: https://doc.qt.io/qt-5/qcoreapplication.html#Q_DECLARE_TR_FUNCTIONS https://doc.qt.io/qt-5/qcoreapplication.html#translate
This commit is contained in:
parent
bf85767829
commit
61f911d39a
23
cfg/qt.cfg
23
cfg/qt.cfg
|
@ -1247,6 +1247,27 @@
|
||||||
<strz/>
|
<strz/>
|
||||||
</arg>
|
</arg>
|
||||||
</function>
|
</function>
|
||||||
|
<!-- QString QCoreApplication::translate(const char *context, const char *sourceText, const char *disambiguation = nullptr, int n = -1) //static -->
|
||||||
|
<function name="QCoreApplication::translate">
|
||||||
|
<noreturn>false</noreturn>
|
||||||
|
<returnValue type="QString"/>
|
||||||
|
<use-retval/>
|
||||||
|
<leak-ignore/>
|
||||||
|
<arg nr="1">
|
||||||
|
<not-uninit/>
|
||||||
|
</arg>
|
||||||
|
<arg nr="2">
|
||||||
|
<not-null/>
|
||||||
|
<not-uninit/>
|
||||||
|
<strz/>
|
||||||
|
<not-bool/>
|
||||||
|
</arg>
|
||||||
|
<arg nr="3" default="NULL">
|
||||||
|
<not-bool/>
|
||||||
|
</arg>
|
||||||
|
<arg nr="4" default="-1">
|
||||||
|
</arg>
|
||||||
|
</function>
|
||||||
<container id="qtContainer" opLessAllowed="false">
|
<container id="qtContainer" opLessAllowed="false">
|
||||||
<type templateParameter="0"/>
|
<type templateParameter="0"/>
|
||||||
<size>
|
<size>
|
||||||
|
@ -1310,8 +1331,10 @@
|
||||||
<define name="Q_CLASSINFO(Name, Value)" value=""/>
|
<define name="Q_CLASSINFO(Name, Value)" value=""/>
|
||||||
<define name="Q_DECL_EXPORT" value=""/>
|
<define name="Q_DECL_EXPORT" value=""/>
|
||||||
<define name="Q_DECL_IMPORT" value=""/>
|
<define name="Q_DECL_IMPORT" value=""/>
|
||||||
|
<define name="QT_DECLARE_DEPRECATED_TR_FUNCTIONS(context)" value="static inline QString trUtf8(const char *sourceText, const char *disambiguation = Q_NULLPTR, int n = -1) { return QCoreApplication::translate(#context, sourceText, disambiguation, n); }"/>
|
||||||
<define name="Q_DECLARE_FLAGS(x,y)" value=""/>
|
<define name="Q_DECLARE_FLAGS(x,y)" value=""/>
|
||||||
<define name="Q_DECLARE_PRIVATE(Class)" value="inline Class##Private* d_func() { return reinterpret_cast<Class##Private*>(qGetPtrHelper(d_ptr)); } inline const Class##Private d_func() const { return reinterpret_cast<const Class##Private *>(qGetPtrHelper(d_ptr)); } friend class Class##Private;"/>
|
<define name="Q_DECLARE_PRIVATE(Class)" value="inline Class##Private* d_func() { return reinterpret_cast<Class##Private*>(qGetPtrHelper(d_ptr)); } inline const Class##Private d_func() const { return reinterpret_cast<const Class##Private *>(qGetPtrHelper(d_ptr)); } friend class Class##Private;"/>
|
||||||
|
<define name="Q_DECLARE_TR_FUNCTIONS(context)" value="public: static inline QString tr(const char *sourceText, const char *disambiguation = Q_NULLPTR, int n = -1) { return QCoreApplication::translate(#context, sourceText, disambiguation, n); } QT_DECLARE_DEPRECATED_TR_FUNCTIONS(context) private:"/>
|
||||||
<define name="Q_DISABLE_COPY(C)" value="C(C&);C& operator=(const C&);"/>
|
<define name="Q_DISABLE_COPY(C)" value="C(C&);C& operator=(const C&);"/>
|
||||||
<define name="Q_ENUM(X)" value=""/>
|
<define name="Q_ENUM(X)" value=""/>
|
||||||
<define name="Q_ENUMS(X)" value=""/>
|
<define name="Q_ENUMS(X)" value=""/>
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <QtPlugin>
|
#include <QtPlugin>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
|
||||||
void QString1(QString s)
|
void QString1(QString s)
|
||||||
|
@ -39,6 +40,31 @@ public:
|
||||||
~MacroTest1();
|
~MacroTest1();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class MacroTest2 {
|
||||||
|
Q_DECLARE_TR_FUNCTIONS(MacroTest2)
|
||||||
|
|
||||||
|
public:
|
||||||
|
MacroTest2();
|
||||||
|
~MacroTest2();
|
||||||
|
};
|
||||||
|
|
||||||
|
void MacroTest2_test()
|
||||||
|
{
|
||||||
|
// TODO: remove suppression when #9002 is fixed
|
||||||
|
// cppcheck-suppress checkLibraryFunction
|
||||||
|
QString str = MacroTest2::tr("hello");
|
||||||
|
QByteArray ba = str.toLatin1();
|
||||||
|
printf(ba.data());
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEPRECATED
|
||||||
|
// TODO: remove suppression when #9002 is fixed
|
||||||
|
// cppcheck-suppress checkLibraryFunction
|
||||||
|
str = MacroTest2::trUtf8("test2");
|
||||||
|
ba = str.toLatin1();
|
||||||
|
printf(ba.data());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void validCode(int * pIntPtr)
|
void validCode(int * pIntPtr)
|
||||||
{
|
{
|
||||||
if (QFile::exists("test")) {
|
if (QFile::exists("test")) {
|
||||||
|
|
Loading…
Reference in New Issue