mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-08-03 22:35:45 +02:00
project: use qmldir for QML singletons registration
This simplifies registration and helps with IDE Intellisense for singleton components. Change-Id: Ifb424491c0fa4777ecc76ec947d57287eea94cfc
This commit is contained in:
parent
154ce53e2d
commit
66e31bea1e
12 changed files with 21 additions and 16 deletions
|
@ -219,6 +219,7 @@ execute_process(
|
||||||
${PYTHON_EXEC} ${SCRIPTS_DIR}/gen_qml_qrc.py ${GEN_QRC_ARGS}
|
${PYTHON_EXEC} ${SCRIPTS_DIR}/gen_qml_qrc.py ${GEN_QRC_ARGS}
|
||||||
WORKING_DIRECTORY ${APP_SRC_DIR})
|
WORKING_DIRECTORY ${APP_SRC_DIR})
|
||||||
set(QML_RESOURCES_QML ${APP_SRC_DIR}/qml.qrc)
|
set(QML_RESOURCES_QML ${APP_SRC_DIR}/qml.qrc)
|
||||||
|
|
||||||
# Image and misc. resources
|
# Image and misc. resources
|
||||||
# check files in the resources directory and force a reconfigure if it
|
# check files in the resources directory and force a reconfigure if it
|
||||||
# changes
|
# changes
|
||||||
|
@ -230,6 +231,11 @@ execute_process(
|
||||||
WORKING_DIRECTORY ${APP_SRC_DIR})
|
WORKING_DIRECTORY ${APP_SRC_DIR})
|
||||||
set(QML_RESOURCES ${APP_SRC_DIR}/resources.qrc)
|
set(QML_RESOURCES ${APP_SRC_DIR}/resources.qrc)
|
||||||
|
|
||||||
|
# Find modules (QtCreator) under the root source dir.
|
||||||
|
list(APPEND QML_DIRS ${APP_SRC_DIR})
|
||||||
|
set(QML_IMPORT_PATH ${QML_DIRS}
|
||||||
|
CACHE STRING "Qt Creator extra qml import paths" FORCE)
|
||||||
|
|
||||||
# library compatibility (boost, libnotify, etc.)
|
# library compatibility (boost, libnotify, etc.)
|
||||||
add_definitions(-DQT_NO_KEYWORDS)
|
add_definitions(-DQT_NO_KEYWORDS)
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,8 @@ def gen_qml_qrc(with_webengine):
|
||||||
continue
|
continue
|
||||||
filtered = [k for k in files if k.endswith('.qml') or
|
filtered = [k for k in files if k.endswith('.qml') or
|
||||||
k.endswith('.js') or k.endswith('.html') or
|
k.endswith('.js') or k.endswith('.html') or
|
||||||
k.endswith('.css') or k.endswith('.conf')]
|
k.endswith('.css') or k.endswith('.conf') or
|
||||||
|
k == 'qmldir']
|
||||||
# if there are no files of interest in this directory, skip it
|
# if there are no files of interest in this directory, skip it
|
||||||
if not filtered:
|
if not filtered:
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -32,7 +32,7 @@ import re
|
||||||
# script as set in the project CMakeLists, which should in turn be
|
# script as set in the project CMakeLists, which should in turn be
|
||||||
# where the resources.qrc will be located (currently 'src/app').
|
# where the resources.qrc will be located (currently 'src/app').
|
||||||
resdir = os.path.join('..', '..', 'resources')
|
resdir = os.path.join('..', '..', 'resources')
|
||||||
qmlfile = os.path.join('constant', 'JamiResources.qml')
|
qmlfile = os.path.join('net/jami/Constants', 'JamiResources.qml')
|
||||||
resfile = os.path.join('resources.qrc')
|
resfile = os.path.join('resources.qrc')
|
||||||
|
|
||||||
print("Generating resource.qrc file ...")
|
print("Generating resource.qrc file ...")
|
||||||
|
|
4
src/app/.gitignore
vendored
Normal file
4
src/app/.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
# auto-gen files
|
||||||
|
resources.qrc
|
||||||
|
qml.qrc
|
||||||
|
net/jami/Constants/JamiResources.qml
|
|
@ -416,6 +416,9 @@ MainApplication::initQmlLayer()
|
||||||
auto videoProvider = new VideoProvider(lrcInstance_->avModel(), this);
|
auto videoProvider = new VideoProvider(lrcInstance_->avModel(), this);
|
||||||
engine_->rootContext()->setContextProperty("videoProvider", videoProvider);
|
engine_->rootContext()->setContextProperty("videoProvider", videoProvider);
|
||||||
|
|
||||||
|
// Find modules (runtime) under the root source dir.
|
||||||
|
engine_->addImportPath("qrc:/");
|
||||||
|
|
||||||
engine_->load(QUrl(QStringLiteral("qrc:/MainApplicationWindow.qml")));
|
engine_->load(QUrl(QStringLiteral("qrc:/MainApplicationWindow.qml")));
|
||||||
qCWarning(app_) << "Main window loaded using" << getRenderInterfaceString();
|
qCWarning(app_) << "Main window loaded using" << getRenderInterfaceString();
|
||||||
}
|
}
|
||||||
|
|
5
src/app/net/jami/Constants/qmldir
Normal file
5
src/app/net/jami/Constants/qmldir
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
singleton JamiStrings 1.1 JamiStrings.qml
|
||||||
|
singleton JamiQmlUtils 1.1 JamiQmlUtils.qml
|
||||||
|
singleton JamiTheme 1.1 JamiTheme.qml
|
||||||
|
singleton JamiResources 1.1 JamiResources.qml
|
||||||
|
singleton MsgSeq 1.1 MsgSeq.qml
|
|
@ -232,13 +232,6 @@ registerTypes(QQmlEngine* engine,
|
||||||
QML_REGISTERNAMESPACE(NS_MODELS, MessageList::staticMetaObject, "MessageList");
|
QML_REGISTERNAMESPACE(NS_MODELS, MessageList::staticMetaObject, "MessageList");
|
||||||
QML_REGISTERNAMESPACE(NS_MODELS, PluginStatus::staticMetaObject, "PluginStatus");
|
QML_REGISTERNAMESPACE(NS_MODELS, PluginStatus::staticMetaObject, "PluginStatus");
|
||||||
|
|
||||||
// Qml singleton components
|
|
||||||
QML_REGISTERSINGLETONTYPE_URL(NS_CONSTANTS, "qrc:/constant/JamiTheme.qml", JamiTheme);
|
|
||||||
QML_REGISTERSINGLETONTYPE_URL(NS_MODELS, "qrc:/constant/JamiQmlUtils.qml", JamiQmlUtils);
|
|
||||||
QML_REGISTERSINGLETONTYPE_URL(NS_CONSTANTS, "qrc:/constant/JamiStrings.qml", JamiStrings);
|
|
||||||
QML_REGISTERSINGLETONTYPE_URL(NS_CONSTANTS, "qrc:/constant/JamiResources.qml", JamiResources);
|
|
||||||
QML_REGISTERSINGLETONTYPE_URL(NS_CONSTANTS, "qrc:/constant/MsgSeq.qml", MsgSeq);
|
|
||||||
|
|
||||||
QML_REGISTERSINGLETONTYPE_POBJECT(NS_CONSTANTS, app, "MainApplication")
|
QML_REGISTERSINGLETONTYPE_POBJECT(NS_CONSTANTS, app, "MainApplication")
|
||||||
QML_REGISTERSINGLETONTYPE_POBJECT(NS_CONSTANTS, screenInfo, "CurrentScreenInfo")
|
QML_REGISTERSINGLETONTYPE_POBJECT(NS_CONSTANTS, screenInfo, "CurrentScreenInfo")
|
||||||
QML_REGISTERSINGLETONTYPE_POBJECT(NS_CONSTANTS, lrcInstance, "LRCInstance")
|
QML_REGISTERSINGLETONTYPE_POBJECT(NS_CONSTANTS, lrcInstance, "LRCInstance")
|
||||||
|
|
|
@ -38,13 +38,6 @@ class ScreenInfo;
|
||||||
class MainApplication;
|
class MainApplication;
|
||||||
class ConnectivityMonitor;
|
class ConnectivityMonitor;
|
||||||
|
|
||||||
// Hack for QtCreator autocomplete (part 1)
|
|
||||||
// https://bugreports.qt.io/browse/QTCREATORBUG-20569
|
|
||||||
namespace dummy {
|
|
||||||
Q_NAMESPACE
|
|
||||||
Q_CLASSINFO("RegisterEnumClassesUnscoped", "false")
|
|
||||||
} // namespace dummy
|
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
#define QML_REGISTERSINGLETON_TYPE(NS, T) \
|
#define QML_REGISTERSINGLETON_TYPE(NS, T) \
|
||||||
qmlRegisterSingletonType<T>(NS, MODULE_VER_MAJ, MODULE_VER_MIN, #T, T::create);
|
qmlRegisterSingletonType<T>(NS, MODULE_VER_MAJ, MODULE_VER_MIN, #T, T::create);
|
||||||
|
|
Loading…
Add table
Reference in a new issue