mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
Improved i18n API for QML plugins
This commit is contained in:
parent
39a79b8c88
commit
1a4d53fb4c
|
@ -127,6 +127,8 @@ if (PySide2_FOUND AND Shiboken2_FOUND AND PythonLibs_FOUND)
|
|||
set(ENABLE_PYTHON_PLUGINS TRUE)
|
||||
endif()
|
||||
|
||||
find_package(LibIntl)
|
||||
|
||||
# Git revision
|
||||
if (EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
||||
find_package(Git QUIET)
|
||||
|
|
9
cmake/FindLibIntl.cmake
Normal file
9
cmake/FindLibIntl.cmake
Normal file
|
@ -0,0 +1,9 @@
|
|||
find_path(LibIntl_INCLUDE_DIRS NAMES libintl.h)
|
||||
find_library(LibIntl_LIBRARIES NAMES intl libintl)
|
||||
include(CheckCXXSymbolExists)
|
||||
check_cxx_symbol_exists(gettext libintl.h LibIntl_SYMBOL_FOUND)
|
||||
if (LibIntl_SYMBOL_FOUND)
|
||||
set(LibIntl_FOUND TRUE)
|
||||
else()
|
||||
set(LibIntl_FOUND FALSE)
|
||||
endif()
|
|
@ -183,7 +183,6 @@ set(SRCS ${SRCS}
|
|||
plugins/qml/api/events/qmlmouseevent.cpp
|
||||
plugins/qml/api/events/qmlwheelevent.cpp
|
||||
plugins/qml/api/events/qmlkeyevent.cpp
|
||||
plugins/qml/api/i18n/qmli18n.cpp
|
||||
popupwindow/popuplocationbar.cpp
|
||||
popupwindow/popupstatusbarmessage.cpp
|
||||
popupwindow/popupwebview.cpp
|
||||
|
@ -258,6 +257,10 @@ set(SRCS ${SRCS}
|
|||
webtab/webtab.cpp
|
||||
)
|
||||
|
||||
if (LibIntl_FOUND)
|
||||
set(SRCS ${SRCS} plugins/qml/api/i18n/qmli18n.cpp)
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
set(SRCS ${SRCS} other/registerqappassociation.cpp)
|
||||
endif()
|
||||
|
@ -323,6 +326,11 @@ qt5_add_resources(SRCS
|
|||
|
||||
add_library(FalkonPrivate SHARED ${SRCS})
|
||||
|
||||
# define macro to for LibIntl_FOUND
|
||||
if (LibIntl_FOUND)
|
||||
target_compile_definitions(FalkonPrivate PRIVATE LibIntl_FOUND=1)
|
||||
endif()
|
||||
|
||||
get_property(QT_WEBENGINE_INCLUDE_DIRS TARGET Qt5::WebEngine PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
|
||||
target_include_directories(FalkonPrivate SYSTEM PUBLIC ${QT_WEBENGINE_INCLUDE_DIRS})
|
||||
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
#include <QObject>
|
||||
#include <libintl.h>
|
||||
|
||||
// libintl.h redefines inline which causes MSVC to abort compilation with the message
|
||||
// fatal error C1189: #error : The C++ Standard Library forbids macroizing keywords
|
||||
#undef inline
|
||||
|
||||
class QmlI18n : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
|
@ -42,7 +42,10 @@
|
|||
#include "api/events/qmlqzobjects.h"
|
||||
#include "api/events/qmlmouseevent.h"
|
||||
#include "api/events/qmlwheelevent.h"
|
||||
#include "api/i18n/qmli18n.h"
|
||||
|
||||
#ifdef LibIntl_FOUND
|
||||
#include "qml/api/i18n/qmli18n.h"
|
||||
#endif
|
||||
|
||||
#include <QQmlEngine>
|
||||
#include <QQmlContext>
|
||||
|
@ -168,6 +171,7 @@ void QmlPlugins::registerQmlTypes()
|
|||
// WheelEvents
|
||||
qmlRegisterUncreatableType<QmlWheelEvent>("org.kde.falkon", 1, 0, "WheelEvent", "Unable to register type: WheelEvent");
|
||||
|
||||
#ifdef LibIntl_FOUND
|
||||
// i18n
|
||||
qmlRegisterSingletonType<QmlI18n>("org.kde.falkon", 1, 0, "I18n", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * {
|
||||
Q_UNUSED(scriptEngine)
|
||||
|
@ -175,4 +179,5 @@ void QmlPlugins::registerQmlTypes()
|
|||
auto *object = new QmlI18n(pluginName);
|
||||
return object;
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user