Thiago Macieira wrote:

> If you compile them with qrc, then they register themselves.

Basically that would mean that qrc knows how to deal with inheritance 
declarations in the icon theme index.theme files?

> Sorry, I don't know the API.

It aims to be very simple and allow application developers to install an 
"icontheme.rcc" file in a QSP::AppDataLocation, which is then used for all 
theme lookups. It could of course be extended to load a plugin/shared library 
if there's a significant advantage in what one can do with that approach. But 
in that case it might even be possible to use a kind of plugin that Qt loads 
automatically during global startup?

Q_GLOBAL_STATIC(QString, _themeOverride)
// Support for icon themes in RCC files.
// The intended use case is standalone apps on Windows / MacOS / etc.
// For this reason we use AppDataLocation: BINDIR/data on Windows, Resources on 
OS X
void initRCCIconTheme()
{
    const QString iconThemeRcc = 
QStandardPaths::locate(QStandardPaths::AppDataLocation, 
QStringLiteral("icontheme.rcc"));
    if (!iconThemeRcc.isEmpty()) {
        const QString iconThemeName = QStringLiteral("kf5_rcc_theme");
        const QString iconSubdir = QStringLiteral("/icons/") + iconThemeName;
        if (QResource::registerResource(iconThemeRcc, iconSubdir)) {
            if (QFileInfo::exists(QLatin1Char(':') + iconSubdir + 
QStringLiteral("/index.theme"))) {
                // Tell Qt about the theme
                // Note that since qtbase commit a8621a3f8, this means the QPA 
(i.e. KIconLoader) will NOT be used.
                QIcon::setThemeName(iconThemeName); // Qt looks under :/icons 
automatically
                // Tell KIconTheme about the theme, in case KIconLoader is used 
directly
                *_themeOverride() = iconThemeName;
            } else {
                qWarning() << "No index.theme found in" << iconThemeRcc;
                QResource::unregisterResource(iconThemeRcc, iconSubdir);
            }
        } else {
            qWarning() << "Invalid rcc file" << iconThemeRcc;
        }
    }
}
Q_COREAPP_STARTUP_FUNCTION(initRCCIconTheme)

_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to