mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +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)
|
set(ENABLE_PYTHON_PLUGINS TRUE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
find_package(LibIntl)
|
||||||
|
|
||||||
# Git revision
|
# Git revision
|
||||||
if (EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
if (EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
||||||
find_package(Git QUIET)
|
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/qmlmouseevent.cpp
|
||||||
plugins/qml/api/events/qmlwheelevent.cpp
|
plugins/qml/api/events/qmlwheelevent.cpp
|
||||||
plugins/qml/api/events/qmlkeyevent.cpp
|
plugins/qml/api/events/qmlkeyevent.cpp
|
||||||
plugins/qml/api/i18n/qmli18n.cpp
|
|
||||||
popupwindow/popuplocationbar.cpp
|
popupwindow/popuplocationbar.cpp
|
||||||
popupwindow/popupstatusbarmessage.cpp
|
popupwindow/popupstatusbarmessage.cpp
|
||||||
popupwindow/popupwebview.cpp
|
popupwindow/popupwebview.cpp
|
||||||
@ -258,6 +257,10 @@ set(SRCS ${SRCS}
|
|||||||
webtab/webtab.cpp
|
webtab/webtab.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (LibIntl_FOUND)
|
||||||
|
set(SRCS ${SRCS} plugins/qml/api/i18n/qmli18n.cpp)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
set(SRCS ${SRCS} other/registerqappassociation.cpp)
|
set(SRCS ${SRCS} other/registerqappassociation.cpp)
|
||||||
endif()
|
endif()
|
||||||
@ -323,6 +326,11 @@ qt5_add_resources(SRCS
|
|||||||
|
|
||||||
add_library(FalkonPrivate SHARED ${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)
|
get_property(QT_WEBENGINE_INCLUDE_DIRS TARGET Qt5::WebEngine PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
|
||||||
target_include_directories(FalkonPrivate SYSTEM PUBLIC ${QT_WEBENGINE_INCLUDE_DIRS})
|
target_include_directories(FalkonPrivate SYSTEM PUBLIC ${QT_WEBENGINE_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
@ -20,6 +20,10 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <libintl.h>
|
#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
|
class QmlI18n : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -42,7 +42,10 @@
|
|||||||
#include "api/events/qmlqzobjects.h"
|
#include "api/events/qmlqzobjects.h"
|
||||||
#include "api/events/qmlmouseevent.h"
|
#include "api/events/qmlmouseevent.h"
|
||||||
#include "api/events/qmlwheelevent.h"
|
#include "api/events/qmlwheelevent.h"
|
||||||
#include "api/i18n/qmli18n.h"
|
|
||||||
|
#ifdef LibIntl_FOUND
|
||||||
|
#include "qml/api/i18n/qmli18n.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <QQmlEngine>
|
#include <QQmlEngine>
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
@ -168,6 +171,7 @@ void QmlPlugins::registerQmlTypes()
|
|||||||
// WheelEvents
|
// WheelEvents
|
||||||
qmlRegisterUncreatableType<QmlWheelEvent>("org.kde.falkon", 1, 0, "WheelEvent", "Unable to register type: WheelEvent");
|
qmlRegisterUncreatableType<QmlWheelEvent>("org.kde.falkon", 1, 0, "WheelEvent", "Unable to register type: WheelEvent");
|
||||||
|
|
||||||
|
#ifdef LibIntl_FOUND
|
||||||
// i18n
|
// i18n
|
||||||
qmlRegisterSingletonType<QmlI18n>("org.kde.falkon", 1, 0, "I18n", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * {
|
qmlRegisterSingletonType<QmlI18n>("org.kde.falkon", 1, 0, "I18n", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * {
|
||||||
Q_UNUSED(scriptEngine)
|
Q_UNUSED(scriptEngine)
|
||||||
@ -175,4 +179,5 @@ void QmlPlugins::registerQmlTypes()
|
|||||||
auto *object = new QmlI18n(pluginName);
|
auto *object = new QmlI18n(pluginName);
|
||||||
return object;
|
return object;
|
||||||
});
|
});
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user