[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: KKeyDialog and KAccel
From:       Andreas Beckermann <b_mann () gmx ! de>
Date:       2002-05-02 15:38:14
[Download RAW message or body]

On Thursday 02 May 2002 16:19, Ellis Whitehead wrote:
> Hi Andi,

Hi again

> > - I need to provide a KActionCollection object, which is unaccessible
> > from my central widget.
>
> You can probably create a new KActionCollection the same way you create the
> KAccel object:
>
> - pAccel = new KAccel( pWidget );
> + pCollection = new KActionCollection( pWidget );
>
> Then for individual shortcuts:
> - pAccel->insert( ... );
> + new KAction( ..., pCollection );
>
> Do you think this might work for you without having a work-around feel?

Yes this looks good, thanks!
I did not even think about this...

> > - when I use QWidget::key[Press|Release]Event() it's hard to find out
> > which action was used. Best solution seems to be a QMap or a Q*List which
> > store the actions in the widget - beside the KMainWindow. Since I can't
> > access actionCollection() I can't iterate the accels either.
>
> Hmm...  Could you explain the purpose of keyPressEvent() with shortcuts?
> There are some cases where this is unfortunately necessary, but usually you
> would just provide the accel or action with the slot that it should
> activate.

Slots are in games often very unhandy. For example I have a hack in kpoker 
which I'd like to get rid of:
slotExchangeCard1();
slotExchangeCard2();
slotExchangeCard3();
slotExchangeCard4();
slotExchangeCard5();
They all simply call setHeld(n); , where n is the number of the slot... All of 
this in a single keyPressEvent() would be nicer.
For a dynamic number of cards (in this example) the problem gets worse. Ok 
dynamic number of cards may be quite unrealistic... so speaking about real 
time strategy games - dynamic number of unit groups or something like this. 
Then I had to use a lot of sender() hacks which makes it very difficult to 
use the same function without the KAction signals.

I have not yet tried to add another KActionCollection object, but it looks 
like the correct solution. I'll port some existing games in a few weeks (once 
I passed my exams).

> Regards,
> Ellis

CU
Andi
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic