2017-06-25 16:25 GMT+02:00 Elvis Stansvik <[email protected]>:
> 2017-06-25 13:25 GMT+02:00 René J.V. Bertin <[email protected]>:
>> On Sunday June 25 2017 10:04:09 Elvis Stansvik wrote:
>>
>>> Say you have
>> ...
>>>
>>> perhaps with inheritances icontheme4 -> icontheme3 -> icontheme2 -> 
>>> icontheme1.
>>
>> Yes, something like that, with the last item in the chain being the hicolor 
>> theme.
>>
>>> Then shouldn't you be able to just generate something like:
>>>
>>> iconthemes.rcc:
>>>
>>> <RCC>
>>>   <qresource prefix="/icons">
>>>     <file>icontheme1/actions/16/some_action.svg</file>
>>>     <file>icontheme1/...</file>
>>>     <file>icontheme1/index.theme</file>
>> ...
>>>   </qresource>
>>> </RCC>
>>>
>>> I.e. putting the iconthemes side by side in :/icons in the RCC namespace.
>>>
>>> If the application then QIcon::setThemeName("icontheme4"), I think it
>>> should just work? Why do you need to merge the index.theme files?
>>
>> I haven't tried (I suppose I could :)) but you're undoubtedly right given 
>> that you seem to have more experience than I do in this domain.
>>
>> Maybe it will indeed suffice to invoke `rcc --project` in the individual 
>> icon theme directories, and then merge the resulting .qrc files more or less 
>> as you showed, or even invoke it in the icon themeS directory (if it 
>> contains only the themes of interest).
>> I tried that, but keep getting a runtime error that no index.theme is found 
>> (via 
>> `QFileInfo::exists(QStringLiteral(":/icons/kf5_rcc_theme/index.theme"))`)
>>
>> I'll try once more to explain what I'm trying to do:
>>
>> The main underlying issue is that the combined/merged theme contains a lot 
>> of icons. That makes it quite important to be able to use some kind of 
>> generator even if you do the rcc creation once only and mostly by hand. The 
>> starting point for this whole exploration was on the one hand the automatic 
>> binary resource generation in the build system of the Breeze icon theme, and 
>> the RCC registration hook I showed from the KIconThemes framework. And the 
>> trigger for it all was the fact that I find Breeze utterly inappropriate for 
>> use on Mac (many KDE devs are dogmatic about blending in with native look 
>> and feel, and IMHO Breeze just doesn't, despite the fact there isn't really 
>> an official Mac system icon theme that I know of).
>
> Alright, I don't know about the KF stuff, but I just made a test case like
>
> icons
> icons/theme1
> icons/theme1/index.theme
> icons/theme1/scalable
> icons/theme1/scalable/actions
> icons/theme1/scalable/actions/test-icon1.svg
> icons/theme2
> icons/theme2/index.theme
> icons/theme2/scalable
> icons/theme2/scalable/actions
> icons/theme2/scalable/actions/test-icon2.svg
> icons/theme3
> icons/theme3/index.theme
> icons/theme3/scalable
> icons/theme3/scalable/actions
> icons/theme3/scalable/actions/test-icon3.svg
> icontest.pro
> main.cpp
> theme1.qrc
> theme2.qrc
> theme3.qrc
>
> where the theme inheritance is theme3 -> theme2 -> theme1 -> hicolor, and with
>
> theme1.qrc:
>
> <RCC>
>     <qresource prefix="/">
>         <file>icons/theme1/scalable/actions/test-icon1.svg</file>
>         <file>icons/theme1/index.theme</file>
>     </qresource>
> </RCC>
>
> theme2.qrc:
>
> <RCC>
>     <qresource prefix="/">
>         <file>icons/theme2/scalable/actions/test-icon2.svg</file>
>         <file>icons/theme2/index.theme</file>
>     </qresource>
> </RCC>
>
> theme3.qrc:
>
> <RCC>
>     <qresource prefix="/">
>         <file>icons/theme3/scalable/actions/test-icon3.svg</file>
>         <file>icons/theme3/index.theme</file>
>     </qresource>
> </RCC>
>
> main.cpp:
>
> #include <QApplication>
> #include <QIcon>
> #include <QtGlobal>
> #include <QtDebug>
> #include <QTimer>
>
> int main(int argc, char *argv[]) {
>     QApplication app(argc, argv);
>
>     QIcon::setThemeName("theme3");
>
>     Q_ASSERT(!QIcon::fromTheme("test-icon1").isNull());
>     Q_ASSERT(!QIcon::fromTheme("test-icon2").isNull());
>     Q_ASSERT(!QIcon::fromTheme("test-icon3").isNull());
>
>     QTimer::singleShot(0, &app, &QApplication::quit);
>
>     return app.exec();
> }
>
> and finally:
>
> icontest.qrc:
>
> TEMPLATE = app
> QT += widgets
> CONFIG += debug
> CONFIG -= app_bundle
> TARGET = icontest
> INCLUDEPATH += .
>
> SOURCES += main.cpp
> RESOURCES += theme1.qrc theme2.qrc theme3.qrc
>
> And it seems to work on both Linux and macOS.
>
> So I think what you want to do should be possible.

For completeness, the theme index files here were:

icons/theme1/index.theme:

[Icon Theme]
Name=Test Theme 1
Comment=Test Theme 1
Hidden=true
Directories=scalable/actions
Inherits=hicolor

[scalable/actions]
MinSize=1
Size=128
MaxSize=512
Context=Actions
Type=Scalable

icons/theme2/index.theme:

[Icon Theme]
Name=Test Theme 2
Comment=Test Theme 2
Hidden=true
Directories=scalable/actions
Inherits=theme1

[scalable/actions]
MinSize=1
Size=128
MaxSize=512
Context=Actions
Type=Scalable

and

icons/theme3/index.theme:

[Icon Theme]
Name=Test Theme 3
Comment=Test Theme 3
Hidden=true
Directories=scalable/actions
Inherits=theme2

[scalable/actions]
MinSize=1
Size=128
MaxSize=512
Context=Actions
Type=Scalable

Elvis

>
> Elvis
>
>>
>>> (Though I realize now that this is actually not a good test case for
>>> whether the inheritance works, since even if it didn't work, the icon
>>> engine will fall back to the "hicolor" theme, as mandated by the
>>> spec.)
>>
>> True, but it does show that both resources are found.
>>
>>
>> R.
_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to