The Awesomest Conditional Expression

I was struggling for a whole day to figure out why my tiny KDE Plasma applet wouldn’t display right.

...
   22 void Foo::init()
   23 {
   24     const char *iconName = "folder-yellow";
   25 
   26     m_icon = new Plasma::IconWidget(KIcon(iconName, NULL), QString());
   27     setPopupIcon(m_icon->icon());
   28 
   29     Plasma::ToolTipManager::self()->registerWidget(this);
   30     update();
   31 
   32     registerAsDragHandle(m_icon);
   33     setAspectRatioMode(Plasma::ConstrainedSquare);
   34 }
   35 
   36 QWidget* Foo::widget()
   37 {
   38     if (m_main == NULL)
   39     {
   40         m_main = new QLabel("Hi!");
   41     }
   42 
   43     return m_main;
   44 }
   45 

I wanted it to display as an icon in the panel, but instead the “Hi” label was showing.

And then I found where KDE makes the decision:

  282         //Applet on desktop
  283         if ((!parentApplet || parentApplet->isContainment() ) && icon 
    && (!icon->svg().isEmpty() || !icon->icon().isNull())
    && ((f != Plasma::Vertical && f != Plasma::Horizontal) ||
  284             ((f == Plasma::Vertical && parentSize.width() >= minimum.width()) ||
  285              (f == Plasma::Horizontal && parentSize.height() >= minimum.height())))) {

(popupapplet.cpp).

Ah now it makes sense…

Well, the problem seems to be that if the applet fits in its panel spot, it isn’t replaced by an icon. This feature is not unreasonable but it would be nice if PopupApplet Class Reference made some mention of it.

Advertisements
This entry was posted in KDE. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s