ktoolbarlabelaction class

Felix Berger bflat1 at gmx.net
Sun Dec 12 19:28:24 GMT 2004


On Sunday 12 December 2004 20:08, David Faure wrote:

> Shouldn't the squeezing be optional? I find it a bit surprising that a
> toolbarlabel is necessarily squeezed.

This is not the case. When the constructor 

KToolBarLabelAction(const QString &text,
        const KShortcut &cut,
        const QObject *receiver, const char *slot,
        KActionCollection *parent, const char *name);

a QLabel is used internally. What I was referring to was the third constructor

KToolBarLabelAction(QLabel* label, 
      const KShortcut &cut, 
      const QObject *receiver,
      const char *slot,
      KActionCollection* parent, 
      const char *name)

which takes an already instantiated QLabel or subcalass thereof as first 
parameter. In the test I wrote I used the KSqueezedTextLabel as such a 
parameter and ran into the problems which are addressed by the patch.

> OTOH if one doesn't want squeezing 
> then QLabel+KActionWidget is enough and KToolbarLabelAction doesn't provide
> much more, does it? OK, there's the setBackgroundMode call which might not
> be obvious.

and the label's name which has to be "kde toolbar widget" otherwise it is not 
rendered correctly in some styles, e.g. Keramik.

> The class should probably have a d pointer (although, technically,
> m_label could always be turned into a d pointer later since it's not used
> inline).

I can do that.

> Some minor nitpicks on the KSqueezeTextLabel patch:
> -  } else {
> +  }
> +  else {
> Not very useful change :)

I'm sorry about that, I added a lot of debug messages to find out what was 
going wrong. I'll revert this change.

> +void KSqueezedTextLabel::setAlignment( int alignment)
> missing space

ok, I'll check all spaces.

> About the line saying that setName(...) doesn't work: I guess that's
> because it's too late already. How about Q_ASSERT( label->name() = "kde
> toolbar widget" ); instead, and mentioning this in the docu, so that users
> of the class know that they have to use that name for the widget (like Konq
> does).

It's already mentioned in the doxygen commentary above the constructor, but 
the Q_ASSERT is a great idea, I'll add it immediately.

Felix Berger
-- 
Use Debian GNU/Linux!
http://www.felix.beldesign.de/




More information about the kde-core-devel mailing list