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