20 #include "kiconselectaction.h"
22 #include <tqpopupmenu.h>
23 #include <kiconloader.h>
25 #include <tdetoolbar.h>
26 #include <tdetoolbarbutton.h>
28 class TDEIconSelectActionPrivate
31 TDEIconSelectActionPrivate()
35 TQStringList m_iconlst;
39 TDEIconSelectAction::TDEIconSelectAction(
const TQString& text,
int accel, TQObject* parent,
const char* name)
40 : TDESelectAction(text, accel, parent, name)
42 d =
new TDEIconSelectActionPrivate;
45 TDEIconSelectAction::~TDEIconSelectAction()
50 void TDEIconSelectAction::updateIcons()
54 TQStringList lst = items();
55 for (uint
id=0;
id<lst.count(); ++id)
56 d->m_menu->changeItem(
id, SmallIconSet(d->m_iconlst[
id]), lst[
id]);
60 void TDEIconSelectAction::createPopupMenu()
64 d->m_menu = popupMenu();
69 void TDEIconSelectAction::setItems(
const TQStringList& lst,
const TQStringList& iconlst)
71 TDESelectAction::setItems(lst);
72 d->m_iconlst = iconlst;
76 int TDEIconSelectAction::plug(TQWidget* widget,
int index)
79 if (widget->inherits(
"TQPopupMenu"))
82 value = TDESelectAction::plug(widget, index);
84 else if (widget->inherits(
"TDEToolBar"))
86 TDEToolBar* bar =
static_cast<TDEToolBar*
>(widget);
87 int id = TDEAction::getToolButtonID();
90 TQString iconName = (currentItem() != -1 ? d->m_iconlst[currentItem()] :
"unknown");
93 bar->insertButton(iconName,
id,
true, plainText(), index);
94 bar->getButton(
id)->setPopup(d->m_menu,
true);
95 bar->setItemEnabled(
id, isEnabled());
96 addContainer(bar,
id);
97 connect(bar, TQ_SIGNAL(destroyed()), TQ_SLOT(slotDestroyed()));
99 value = containerCount()-1;
104 void TDEIconSelectAction::updateCurrentItem(
int id)
106 TQWidget* w = container(
id);
107 if (w->inherits(
"TDEToolBar"))
108 static_cast<TDEToolBar*
>(w)->getButton(itemId(
id))->setIcon(d->m_iconlst[currentItem()]);
110 TDESelectAction::updateCurrentItem(
id);
113 void TDEIconSelectAction::setCurrentItem(
int index)
115 TDESelectAction::setCurrentItem(index);
118 #include "kiconselectaction.moc"