22 #include <QtCore/QPointer>
23 #include <QtGui/QApplication>
24 #include <QtGui/QLabel>
26 class KToolBarLabelAction::Private
29 QPointer<QAction>
buddy;
30 QPointer<QLabel>
label;
59 foreach (
QWidget* widget, associatedWidgets() )
60 if (
QToolBar* toolBar = qobject_cast<QToolBar*>( widget ) )
61 if (
QLabel*
label = qobject_cast<QLabel*>( toolBar->widgetForAction(
this ) ) )
62 labels.append(
label );
64 foreach (
QWidget* widget, buddy->associatedWidgets() )
65 if (
QToolBar* toolBar = qobject_cast<QToolBar*>( widget ) ) {
66 QWidget* newBuddy = toolBar->widgetForAction( buddy );
68 label->setBuddy( newBuddy );
80 if ( event->type() == QEvent::ActionChanged ) {
81 if ( d->label && text() != d->label->text() ) {
83 d->label->setText(text());
92 if ( d->label && d->buddy && event->type() == QEvent::PolishRequest && watched == d->label) {
93 foreach (
QWidget* widget, d->buddy->associatedWidgets() ) {
94 if (
QToolBar* toolBar = qobject_cast<QToolBar*>( widget ) ) {
95 QWidget* newBuddy = toolBar->widgetForAction( d->buddy );
96 d->label->setBuddy( newBuddy );
101 return KAction::eventFilter( watched, event );
108 return KAction::createWidget(_parent);
110 d->label =
new QLabel( parent );
116 d->label->setBackgroundRole( QPalette::Button );
117 d->label->setAlignment( (QApplication::isRightToLeft() ? Qt::AlignRight : Qt::AlignLeft) |
119 d->label->adjustSize();
120 d->label->setText(text());
121 d->label->installEventFilter(
this );
127 #include "ktoolbarlabelaction.moc"