IconProvider is a Qt/ Sailfish Os helper library. With it you can define sets of icons from qrc or local resources then access them with a single id. Also with monochrome png you can add a colour on the fly, making it mobile friendly.
- simple, only consist of 1 class to add to your project
- wokrs with qrc or plain url
- can add color on monochrome png
- qml ready, just register IconProvider as a service, use regular image:// url
Some example
You can use IconProvider from both Qt and Qml
Registering a new provider "MyProvider"
// from the main process // get a ref to the view QScopedPointerview(SailfishApp::createView()); // create a new provider, register it for qml, add qrc and additional resources from "qml/images" IconProvider::init(view.data(),"MyProvider", "qml/images");
qrc example
resources/img/sdcard.png
from Qml
// use of the provider, by id plus applying a colour ListElement { icon:"image://MyProvider/img/sdcard?#ff0000"; desc:"Icon from qrc"; }
Install
Install is really simple and only require to add the lib to your project. Steps assume you use the default names and locations
- Copy the src/IconProvider directory into your src directory
- Edit the project's .pro file and include iconprovider.pri reference
From Github or inside the .tgz you will find a full qtcreator project.
Download
You can get IconProvider from the github repository
Editing .pro file
Here the .pro file for the sample application
TARGET = harbour-test_iconprovider CONFIG += sailfishapp include(src/iconprovider/iconprovider.pri) SOURCES += src/harbour-test_iconprovider.cpp OTHER_FILES += qml/harbour-test_iconprovider.qml \ qml/cover/*.qml \ qml/pages/*.qml \ qml/images/*.png \ rpm/harbour-test_iconprovider.changes \ rpm/harbour-test_iconprovider.spec \ rpm/harbour-test_iconprovider.yaml \ harbour-test_iconprovider.desktop SAILFISHAPP_ICONS = 86x86 108x108 128x128 256x256 RESOURCES += harbour-test_iconprovider.qrc DISTFILES += harbour-test_iconprovider.qrc \ qml/img/*.png