[Development] QAction-like API for QML

Shawn Rutledge shawn.t.rutledge at gmail.com
Tue Dec 18 20:26:32 CET 2012


On 18 December 2012 19:35, Alan Alpert <416365416c at gmail.com> wrote:
> How is this going to work? If no iconSource or imageSource exists on
> the Action then the delegate in QtQuickControls uses
> "image://icons/<action-name>.png"?

Yes that's what I was thinking.

Pros:
- after you name the action, you don't repeat yourself (the action
name is part of the icon filename)
- don't need to worry about the exact path to find the icon; that's an
application-wide issue, not something to specify as part of each
action
- makes it clear an action is abstract, so maybe no qualms about
pre-creating them in C++, because there's nothing that looks like view
functionality
- the naming convention exists already on Linux
(/usr/share/icons/theme-name/32x32/actions/*.png for example)
- the image provider could still reuse QIcon by having its own
QHash<QString, QIcon> m_iconCache or something like that
- most of the time you can avoid giving an iconSource at all.  If you
do that in QML, then I suppose the image provider will have to use
QIcon to generate the other sizes and modes?

Cons:
- if we don't put the icon in the action, is it even possible to
specify icons for different sizes and modes in QML?  or are you just
stuck with a fixed icon image, or the auto-generated variants, if you
give the iconSource?

> Or would that be in the
> QtQuickControls, that the delegate renders that url if no source is
> found? While an image provider would be perfect for this, it would
> probably have to go in QtQuickControls and then it can't be in the
> Action type (unless this is a QtQuickControls specific Action type,
> which I don't think is a good idea).

Yep.



More information about the Development mailing list