tool activate()

Sven Langkamp longamp at reallygood.de
Tue Mar 22 01:18:35 CET 2005


On Monday 21 March 2005 14:49, Casper Boemann wrote:
> On Monday 21 March 2005 14:34, Adrian Page wrote:
> > Yes, using clear() should do what is wanted. It's called before a
> > new tool is made active.
> >
> > Adrian
>
> great
>
> now if I could just figure out why activate is called twice when I click
>
> like:
> "click my tool"
> activate(my tool)
> clear(my tool)
> activate(my tool)
> "click another tool"
> clear(my tool)
>
> also I think activate shadows the KAction activate - is that on purpose and
> could that be the explaination
> activate is called which is actually our version of activate
> it ALSO signals activated which is connected to activate
> we are called again
>
> I'm confused

Looks like the activate slot is connected twice.
Once in the constructor of the KRadioAction in the tool setup method:
> void KisToolPen::setup(KActionCollection *collection)
> {
> 	m_action = static_cast<KRadioAction *>(collection -> action(name()));
> 
> 	if (m_action == 0) {
> 		m_action = new KRadioAction(i18n("Tool &Pen"),
> 					    "pencil", Qt::SHIFT+Qt::Key_P, this,
> 					    SLOT(activate()), collection,
> 					    name());
and the other time in KisView::setInputDevice:
> 		for (vKisTool::iterator it = tools.begin(); it != tools.end(); it++) {
> 			KisTool *tool = *it;
> 			KAction *toolAction = tool -> action();
> 
> 			connect(toolAction, SIGNAL(activated()), tool, SLOT(activate()));
> 		}


More information about the kimageshop mailing list