From 5abfd7c00bc7ebfec2f059adc9bc22eb989ae10d Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 4 Dec 2014 15:53:35 +0100 Subject: Let style plugins bundle resources Add internal hooks that get called for style plugins that implement them. The hooks allow standalone style bundles to initialize their resources (to make them visible to controls) and to specify the QRC location of its QML files, eg. qrc:/path/to/Style. Change-Id: I29c4e337e893f7aa65af7b05ff467e15bc84bf43 Reviewed-by: Gatis Paeglis Reviewed-by: Mitch Curtis --- src/controls/Private/qquickcontrolsettings.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/controls/Private/qquickcontrolsettings.cpp b/src/controls/Private/qquickcontrolsettings.cpp index eca533d7..ca57f394 100644 --- a/src/controls/Private/qquickcontrolsettings.cpp +++ b/src/controls/Private/qquickcontrolsettings.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -128,11 +129,29 @@ QQuickControlSettings::QQuickControlSettings(QQmlEngine *engine) if (fromResource(path)) path = path.remove(0, 3); // remove qrc from the path - if (!QDir(path).exists()) { + QDir dir(path); + if (!dir.exists()) { QString unknownStyle = m_name; m_name = defaultStyleName(); m_path = styleImportPath(engine, m_name); qWarning() << "WARNING: Cannot find style" << unknownStyle << "- fallback:" << styleFilePath(); + } else { + typedef bool (*StyleInitFunc)(); + typedef const char *(*StylePathFunc)(); + + foreach (const QString &fileName, dir.entryList()) { + if (QLibrary::isLibrary(fileName)) { + QLibrary lib(dir.absoluteFilePath(fileName)); + StyleInitFunc initFunc = (StyleInitFunc) lib.resolve("qt_quick_controls_style_init"); + if (initFunc) + initFunc(); + StylePathFunc pathFunc = (StylePathFunc) lib.resolve("qt_quick_controls_style_path"); + if (pathFunc) + m_path = QString::fromLocal8Bit(pathFunc()); + if (initFunc || pathFunc) + break; + } + } } connect(this, SIGNAL(styleNameChanged()), SIGNAL(styleChanged())); -- cgit v1.2.1