diff options
| author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2014-12-04 15:53:35 +0100 |
|---|---|---|
| committer | Mitch Curtis <mitch.curtis@digia.com> | 2015-01-15 10:33:50 +0100 |
| commit | 5abfd7c00bc7ebfec2f059adc9bc22eb989ae10d (patch) | |
| tree | dbd5e9f03523ed09fa59c766ea5f3fd7aabb9c18 /src/controls/Private/qquickcontrolsettings.cpp | |
| parent | bbe7cac483b600cf6825deb4c73b93d769939bfc (diff) | |
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 <gatis.paeglis@digia.com>
Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>
Diffstat (limited to 'src/controls/Private/qquickcontrolsettings.cpp')
| -rw-r--r-- | src/controls/Private/qquickcontrolsettings.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/controls/Private/qquickcontrolsettings.cpp b/src/controls/Private/qquickcontrolsettings.cpp index eca533d76..ca57f3941 100644 --- a/src/controls/Private/qquickcontrolsettings.cpp +++ b/src/controls/Private/qquickcontrolsettings.cpp @@ -35,6 +35,7 @@ #include <qquickitem.h> #include <qcoreapplication.h> #include <qqmlengine.h> +#include <qlibrary.h> #include <qdir.h> #include <QTouchDevice> #include <QGuiApplication> @@ -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())); |
