On Saturday 05 February 2011 21:35:10 Stefan Majewsky wrote: > Hi, > > if a Qt fairy (pun intended) would visit me and grant me one wish, it > would be native Qt support for KStandardDirs (through a platform > plugin or whatever). Instead of > > > QSvgRenderer renderer(KStandardDirs::locate("appdata", > > "themes/default.svgz")); > > I want to write e.g. > > > QSvgRenderer renderer("%/appdata/themes/default.svgz"); > > The "%" is just an example. This syntax is similar to Qt's embedded resources: > > QSvgRenderer renderer(":/themes/default.svgz"); In your main() function, create an instance of the attached class (somewhere at the beginning, before you access anything with '%foo'). That's all you have to do. Looks like a cool idea to have this available in any KDE powered app.
Docs: http://doc.qt.nokia.com/latest/qabstractfileengine.html http://doc.qt.nokia.com/latest/qabstractfileenginehandler.html -- Arno Rehn a...@arnorehn.de
class KStandardDirsFileEngineHandler : public QAbstractFileEngineHandler { public: QAbstractFileEngine *create(const QString& fileName) const { if (!fileName.startsWith('%')) return 0; // strip off '%/' QString path = fileName.mid(2); int firstSeperator = path.indexOf('/'); QString key = path.left(firstSeperator); path = path.mid(firstSeperator + 1); return QAbstractFileEngine::create(KStandardDirs::locate(key.toLatin1(), path)); } };
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<