20#include "KoSelectAction.h"
24#include <tqwhatsthis.h>
27#include <tdepopupmenu.h>
28#include <tdeapplication.h>
30#include <tdetoolbar.h>
31#include <tdetoolbarbutton.h>
32#include <kiconloader.h>
35class KoSelectAction::KoSelectActionPrivate
38 KoSelectActionPrivate()
40 m_popup = new TDEPopupMenu(0L, "KoLineStyleAction::popup");
41 m_currentSelection = 0;
44 ~KoSelectActionPrivate()
51 int m_currentSelection;
55 TQObject* parent, const char* name) : TDEAction(text, icon, 0, parent, name)
57 d = new KoSelectActionPrivate;
64 const char* slot, TQObject* parent, const char* name) : TDEAction(text, icon, 0, parent, name)
66 d = new KoSelectActionPrivate;
72KoSelectAction::~KoSelectAction()
87int KoSelectAction::plug(TQWidget* widget, int index)
90 if (kapp && !kapp->authorizeTDEAction(name()))
92 kdDebug(129) << "TDEAction::plug( " << widget << ", " << index << " )" << endl;
93 if ( widget->inherits( "TQPopupMenu") )
95 TQPopupMenu* menu = static_cast<TQPopupMenu* >( widget );
101 id = menu->insertItem( kapp->iconLoader()->loadIcon(icon(), TDEIcon::Small),
105 menu->setItemEnabled( id, false );
107 addContainer( menu, id );
108 connect( menu, TQ_SIGNAL( destroyed() ), this, TQ_SLOT( slotDestroyed() ) );
110 return containerCount() - 1;
112 else if ( widget->inherits( "TDEToolBar" ) )
118 if ( icon().isEmpty() && ! iconSet().isNull() ) {
120 TQ_SLOT( slotActivated() ), isEnabled(), plainText(),
123 TDEInstance *instance;
125 if ( m_parentCollection ) {
126 instance = m_parentCollection->instance();
128 instance = TDEGlobal::instance();
131 bar-> insertButton( icon(), id_, TQ_SIGNAL( clicked() ), this,
132 TQ_SLOT( slotActivated() ), isEnabled(), plainText(),
136 addContainer( bar, id_ );
141 connect( bar, TQ_SIGNAL( destroyed() ), this, TQ_SLOT( slotDestroyed() ) );
145 return containerCount() - 1;
147 else if ( widget->inherits( "TQMenuBar" ) )
149 TQMenuBar *bar = static_cast<TQMenuBar * >( widget );
158 addContainer( bar, id );
159 connect( bar, TQ_SIGNAL( destroyed() ), this, TQ_SLOT( slotDestroyed() ) );
161 return containerCount() - 1;
175 return d->m_currentSelection;
181 popupMenu()->setItemChecked(d->m_currentSelection, false);
182 popupMenu()->setItemChecked(index, true);
185 d->m_currentSelection = index;
193#include "KoSelectAction.moc"
TDEPopupMenu * popupMenu() const Returns a pointer to the popup menu.
virtual int currentSelection() Returns the index of the currently selected item.
virtual void execute(int index) Execute an item.
void selectionChanged(int) Emited when the selection changed.
KoSelectAction(const TQString &text, const TQString &icon, TQObject *parent=0, const char *name=0) Constructs a KoSelectAction with a text and an icon.
void popup(const TQPoint &global) Shows the popup menu.
virtual void setCurrentSelection(int index) Set which item that should be selected.
void setShowCurrentSelection(bool show) If the current selection selection should be shown or not in the menu.
TQIconSet iconSet() const
virtual bool isEnabled() const
virtual TQString text() const
virtual TQString whatsThis() const
static int getToolButtonID()
|