Results 1 to 5 of 5

Thread: Missing action icons

  1. #1
    Join Date
    Feb 2006
    Location
    Enschede, NL, EU
    Posts
    19
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Missing action icons

    I'm encountering some difficulties with using KDE's default tool/menu icon schemes... I'm using KStdGuiItem::add() and KStdGuiItem::remove() to dress up some buttons but I only get a white "default icon". KStdActions on the other hand work fine in the Menus

  2. #2
    Join Date
    Jan 2006
    Location
    N.B. Canada
    Posts
    47
    Thanked 8 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Missing action icons

    What version of KDE/kdelibs are you using? Also what icon theme are you using? Can you post the code where you are using these please. When you call KStdGuiItem::add(), what does hasIcon() return. You need to use one of the iconSet() methods to get the icon. Also what KStdAction works, since there is no KStdAction::add().

    From quickly looking at the docs and source, this is KstdGuiItem::add():
    Qt Code:
    1. KGuiItem KStdGuiItem::add()
    2. {
    3. return KGuiItem(i18n("Add"), "add");
    4. }
    To copy to clipboard, switch view to plain text mode 

    which calls constructor to KGuiItem:

    Qt Code:
    1. KGuiItem::KGuiItem( const QString &text, const QString &iconName, const QString &toolTip, const QString &whatsThis )
    2. {
    3. d = new KGuiItemPrivate;
    4. d->m_text = text;
    5. d->m_toolTip = toolTip;
    6. d->m_whatsThis = whatsThis;
    7. setIconName( iconName );
    8. }
    To copy to clipboard, switch view to plain text mode 

    and finally setIconName():
    Qt Code:
    1. void KGuiItem::setIconName( const QString &iconName )
    2. {
    3. d->m_iconName = iconName;
    4. d->m_iconSet = QIconSet();
    5. d->m_hasIcon = !iconName.isEmpty();
    6. }
    To copy to clipboard, switch view to plain text mode 

    We can see here that the setIconName method just creates a null QIconSet. hasIcon() should return true, since iconName is not empty. To get the icon you need to use one of the iconSet() methods, which actually creates the icons using KIconLoader:

    Qt Code:
    1. QIconSet KGuiItem::iconSet( KIcon::Group group, int size, KInstance* instance ) const
    2. {
    3. if( d->m_hasIcon )
    4. {
    5. if( !d->m_iconName.isEmpty())
    6. {
    7. // some caching here would(?) come handy
    8. return instance->iconLoader()->loadIconSet( d->m_iconName, group, size, true, false );
    9. }
    10. else
    11. {
    12. return d->m_iconSet;
    13. }
    14. }
    15. else
    16. return QIconSet();
    17. }
    To copy to clipboard, switch view to plain text mode 

    So really the only I can think of is that it can't find the "add" icon, at least not for the size or gorup you want. It is interesting that from 3.4 to 3.5 the only thing that really changed reagarding this was using just "add" instead of "edit_add". Dunno...

    Bojan
    The march of progress:
    C:
    printf("%10.2f", x);
    C++:
    cout << setw(10) << setprecision(2) << showpoint << x;
    Java:
    java.text.NumberFormat formatter = java.text.NumberFormat.getNumberInstance();
    formatter.setMinimumFractionDigits(2);
    formatter.setMaximumFractionDigits(2);
    String s = formatter.format(x);
    for (int i = s.length(); i < 10; i++) System.out.print(' ');
    System.out.print(s);

  3. #3
    Join Date
    Feb 2006
    Location
    Enschede, NL, EU
    Posts
    19
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Missing action icons

    I'm using KDE 3.4.2b with Qt3.3.4
    I'm using the crystalsvg icon theme

    I was actually just initializing the KPushButtons with the (KStdGUIItem::KGuiItem*,QWidget*,const char*); constructor, which does seem to work since it adds text labels, but adds an empty icon...

    I solved the problem for now by using KGlobal::iconLoader() to look for icons, but still don't have neat add or remove icons and settled for "ok" and "cancel" for the time being;

  4. #4
    Join Date
    Jan 2006
    Location
    N.B. Canada
    Posts
    47
    Thanked 8 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Missing action icons

    Does KDE 3.4.2b mean beta? Maybe you should compare the relevant kdelibs code (kstdguiitem.cpp, kguiitem.cpp and kpushbutton.cpp) to the code in the docs for final 3.4.2. Also just out of curiosty, try passing a new KGuiItem(i18n("Add"), "add") and new KGuiItem(i18n("Add"), "edit_add"), to the KPushButton's constructor. In your icons folder, is there add.png or edit_add.png for 16x16 and 22x22? This matters, if there is edit_add.png and no add.png, and the code is ending up calling "add" as the icon name, KIconLoader will probably fail to find it. That's why you usually see same icons multiple times with different names, because they could be called differently, especially in different contexts. You said you tried KGlobal::iconLoader(), but couldn't find the icons. So it definitly looks like it can't find the icon, since otherwise, as far as I can see, the button's iconset should be null, which definitly isn't the "empty document/default/unknown" icon.

    [EDIT]Ok, I think the problem is that Crystalsvg doesn't actually have an "add" icon. In my crystalsvg icon folder there are no "add" icons of any sort. The icon theme I use, does. It has an edit_add.png. However if I switch my icon theme to CrystalSVG, and do KStdGuiItem::add(), the loaded icon is an "add" icon from another icon theme installed on my system. My guess is that, since KIconLoader tries really hard to find an icon for you, if it can't find an icon from your current theme, it maybe looks for it in other icon themes. My best guess is that there is no "add" icon on your system at all.[/EDIT]

    Bojan
    Last edited by Bojan; 19th February 2006 at 23:35.
    The march of progress:
    C:
    printf("%10.2f", x);
    C++:
    cout << setw(10) << setprecision(2) << showpoint << x;
    Java:
    java.text.NumberFormat formatter = java.text.NumberFormat.getNumberInstance();
    formatter.setMinimumFractionDigits(2);
    formatter.setMaximumFractionDigits(2);
    String s = formatter.format(x);
    for (int i = s.length(); i < 10; i++) System.out.print(' ');
    System.out.print(s);

  5. #5
    Join Date
    Feb 2006
    Location
    Enschede, NL, EU
    Posts
    19
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Missing action icons

    I looked through the folders again and couldn't find an add or remove icon either... I guess that's been the problem all along :P

Similar Threads

  1. StandardPixmap is missing important icons
    By claudio in forum Qt Programming
    Replies: 3
    Last Post: 19th February 2014, 20:47
  2. Action editor and MultiSize Icons
    By mcosta in forum Qt Tools
    Replies: 4
    Last Post: 28th May 2008, 20:29
  3. Icons missing => segmentation fault
    By antonio.r.tome in forum Qt Programming
    Replies: 4
    Last Post: 8th March 2006, 17:30
  4. Toolbar & Icons missing
    By raphaelf in forum Qt Tools
    Replies: 2
    Last Post: 27th February 2006, 23:19
  5. No action checked in an exclusive action group
    By SkripT in forum Qt Programming
    Replies: 12
    Last Post: 13th February 2006, 07:19

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.