moderately less ugly

svn path=/trunk/KDE/kdelibs/; revision=1188638
This commit is contained in:
Aaron J. Seigo 2010-10-22 19:52:05 +00:00
parent 681452d32d
commit ab99a3a048

View File

@ -31,8 +31,6 @@ template <class T>
class ActionWidgetInterface : public ThemedWidgetInterface<T> class ActionWidgetInterface : public ThemedWidgetInterface<T>
{ {
public: public:
QAction *action;
ActionWidgetInterface(T *parent) ActionWidgetInterface(T *parent)
: ThemedWidgetInterface<T>(parent), : ThemedWidgetInterface<T>(parent),
action(0) action(0)
@ -57,20 +55,20 @@ public:
void syncToAction() void syncToAction()
{ {
if (!action) { if (!action) {
ThemedWidgetInterface<T>::q->setIcon(QIcon()); this->q->setIcon(QIcon());
ThemedWidgetInterface<T>::q->setText(QString()); this->q->setText(QString());
ThemedWidgetInterface<T>::q->setEnabled(false); this->q->setEnabled(false);
return; return;
} }
//we don't get told *what* changed, just that something changed //we don't get told *what* changed, just that something changed
//so we update everything we care about //so we update everything we care about
ThemedWidgetInterface<T>::q->setIcon(action->icon()); this->q->setIcon(action->icon());
ThemedWidgetInterface<T>::q->setText(action->iconText()); this->q->setText(action->iconText());
ThemedWidgetInterface<T>::q->setEnabled(action->isEnabled()); this->q->setEnabled(action->isEnabled());
ThemedWidgetInterface<T>::q->setVisible(action->isVisible()); this->q->setVisible(action->isVisible());
if (!ThemedWidgetInterface<T>::q->toolTip().isEmpty()) { if (!this->q->toolTip().isEmpty()) {
ThemedWidgetInterface<T>::q->setToolTip(action->text()); this->q->setToolTip(action->text());
} }
changed(); changed();
@ -79,19 +77,21 @@ public:
void setAction(QAction *a) void setAction(QAction *a)
{ {
if (action) { if (action) {
QObject::disconnect(action, 0, ThemedWidgetInterface<T>::q, 0); QObject::disconnect(action, 0, this->q, 0);
QObject::disconnect(ThemedWidgetInterface<T>::q, 0, action, 0); QObject::disconnect(this->q, 0, action, 0);
} }
action = a; action = a;
if (action) { if (action) {
QObject::connect(action, SIGNAL(changed()), ThemedWidgetInterface<T>::q, SLOT(syncToAction())); QObject::connect(action, SIGNAL(changed()), this->q, SLOT(syncToAction()));
QObject::connect(action, SIGNAL(destroyed(QObject*)), ThemedWidgetInterface<T>::q, SLOT(clearAction())); QObject::connect(action, SIGNAL(destroyed(QObject*)), this->q, SLOT(clearAction()));
QObject::connect(ThemedWidgetInterface<T>::q, SIGNAL(clicked()), action, SLOT(trigger())); QObject::connect(this->q, SIGNAL(clicked()), action, SLOT(trigger()));
syncToAction(); syncToAction();
} }
} }
QAction *action;
}; };
} // namespace Plasma } // namespace Plasma