-rw-r--r-- | microkde/kdeui/kaction.cpp | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/microkde/kdeui/kaction.cpp b/microkde/kdeui/kaction.cpp index 77d36a5..d38a6d5 100644 --- a/microkde/kdeui/kaction.cpp +++ b/microkde/kdeui/kaction.cpp | |||
@@ -167,97 +167,96 @@ KAction::KAction( const QString& text, const KShortcut& cut, | |||
167 | KAction::KAction( const QString& text, const QIconSet& pix, | 167 | KAction::KAction( const QString& text, const QIconSet& pix, |
168 | const KShortcut& cut, | 168 | const KShortcut& cut, |
169 | QObject* parent, const char* name ) | 169 | QObject* parent, const char* name ) |
170 | : QObject( parent, name ) | 170 | : QObject( parent, name ) |
171 | { | 171 | { |
172 | initPrivate( text, cut, 0, 0 ); | 172 | initPrivate( text, cut, 0, 0 ); |
173 | setIconSet( pix ); | 173 | setIconSet( pix ); |
174 | } | 174 | } |
175 | 175 | ||
176 | KAction::KAction( const QString& text, const QString& pix, | 176 | KAction::KAction( const QString& text, const QString& pix, |
177 | const KShortcut& cut, | 177 | const KShortcut& cut, |
178 | QObject* parent, const char* name ) | 178 | QObject* parent, const char* name ) |
179 | : QObject( parent, name ) | 179 | : QObject( parent, name ) |
180 | { | 180 | { |
181 | initPrivate( text, cut, 0, 0 ); | 181 | initPrivate( text, cut, 0, 0 ); |
182 | d->setIconName( pix ); | 182 | d->setIconName( pix ); |
183 | } | 183 | } |
184 | 184 | ||
185 | KAction::KAction( const QString& text, const QIconSet& pix, | 185 | KAction::KAction( const QString& text, const QIconSet& pix, |
186 | const KShortcut& cut, | 186 | const KShortcut& cut, |
187 | const QObject* receiver, const char* slot, QObject* parent, | 187 | const QObject* receiver, const char* slot, QObject* parent, |
188 | const char* name ) | 188 | const char* name ) |
189 | : QObject( parent, name ) | 189 | : QObject( parent, name ) |
190 | { | 190 | { |
191 | initPrivate( text, cut, receiver, slot ); | 191 | initPrivate( text, cut, receiver, slot ); |
192 | setIconSet( pix ); | 192 | setIconSet( pix ); |
193 | } | 193 | } |
194 | 194 | ||
195 | KAction::KAction( const QString& text, const QString& pix, | 195 | KAction::KAction( const QString& text, const QString& pix, |
196 | const KShortcut& cut, | 196 | const KShortcut& cut, |
197 | const QObject* receiver, const char* slot, QObject* parent, | 197 | const QObject* receiver, const char* slot, QObject* parent, |
198 | const char* name ) | 198 | const char* name ) |
199 | : QObject( parent, name ) | 199 | : QObject( parent, name ) |
200 | { | 200 | { |
201 | initPrivate( text, cut, receiver, slot ); | 201 | initPrivate( text, cut, receiver, slot ); |
202 | d->setIconName(pix); | 202 | d->setIconName(pix); |
203 | } | 203 | } |
204 | 204 | ||
205 | KAction::KAction( QObject* parent, const char* name ) | 205 | KAction::KAction( QObject* parent, const char* name ) |
206 | : QObject( parent, name ) | 206 | : QObject( parent, name ) |
207 | { | 207 | { |
208 | 208 | ||
209 | initPrivate( QString::null, KShortcut(), 0, 0 ); | 209 | initPrivate( QString::null, KShortcut(), 0, 0 ); |
210 | } | 210 | } |
211 | // KDE 4: remove end | 211 | // KDE 4: remove end |
212 | 212 | ||
213 | KAction::~KAction() | 213 | KAction::~KAction() |
214 | { | 214 | { |
215 | kdDebug(129) << "KAction::~KAction( this = \"" << name() << "\" )" << endl; // -- ellis | ||
216 | #ifndef KDE_NO_COMPAT | 215 | #ifndef KDE_NO_COMPAT |
217 | if (d->m_kaccel) | 216 | if (d->m_kaccel) |
218 | unplugAccel(); | 217 | unplugAccel(); |
219 | #endif | 218 | #endif |
220 | 219 | ||
221 | // If actionCollection hasn't already been destructed, | 220 | // If actionCollection hasn't already been destructed, |
222 | if ( m_parentCollection ) { | 221 | if ( m_parentCollection ) { |
223 | m_parentCollection->take( this ); | 222 | m_parentCollection->take( this ); |
224 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) | 223 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) |
225 | //US d->m_kaccelList[i]->remove( name() ); | 224 | //US d->m_kaccelList[i]->remove( name() ); |
226 | qDebug("KAction::KAction~ ...1 has top be fixed"); | 225 | qDebug("KAction::KAction~ ...1 has top be fixed"); |
227 | } | 226 | } |
228 | 227 | ||
229 | // Do not call unplugAll from here, as tempting as it sounds. | 228 | // Do not call unplugAll from here, as tempting as it sounds. |
230 | // KAction is designed around the idea that you need to plug | 229 | // KAction is designed around the idea that you need to plug |
231 | // _and_ to unplug it "manually". Unplugging leads to an important | 230 | // _and_ to unplug it "manually". Unplugging leads to an important |
232 | // slowdown when e.g. closing the window, in which case we simply | 231 | // slowdown when e.g. closing the window, in which case we simply |
233 | // want to destroy everything asap, not to remove actions one by one | 232 | // want to destroy everything asap, not to remove actions one by one |
234 | // from the GUI. | 233 | // from the GUI. |
235 | 234 | ||
236 | delete d; d = 0; | 235 | delete d; d = 0; |
237 | } | 236 | } |
238 | 237 | ||
239 | void KAction::initPrivate( const QString& text, const KShortcut& cut, | 238 | void KAction::initPrivate( const QString& text, const KShortcut& cut, |
240 | const QObject* receiver, const char* slot ) | 239 | const QObject* receiver, const char* slot ) |
241 | { | 240 | { |
242 | d = new KActionPrivate; | 241 | d = new KActionPrivate; |
243 | 242 | ||
244 | d->m_cutDefault = cut; | 243 | d->m_cutDefault = cut; |
245 | 244 | ||
246 | //US m_parentCollection = dynamic_cast<KActionCollection *>( parent() ); | 245 | //US m_parentCollection = dynamic_cast<KActionCollection *>( parent() ); |
247 | m_parentCollection = (KActionCollection *)( parent() ); | 246 | m_parentCollection = (KActionCollection *)( parent() ); |
248 | kdDebug(129) << "KAction::initPrivate(): this = " << this << " name = \"" << name() << "\" cut = " << cut.toStringInternal() << " m_parentCollection = " << m_parentCollection << endl; | 247 | kdDebug(129) << "KAction::initPrivate(): this = " << this << " name = \"" << name() << "\" cut = " << cut.toStringInternal() << " m_parentCollection = " << m_parentCollection << endl; |
249 | if ( m_parentCollection ) | 248 | if ( m_parentCollection ) |
250 | m_parentCollection->insert( this ); | 249 | m_parentCollection->insert( this ); |
251 | 250 | ||
252 | if ( receiver && slot ) | 251 | if ( receiver && slot ) |
253 | connect( this, SIGNAL( activated() ), receiver, slot ); | 252 | connect( this, SIGNAL( activated() ), receiver, slot ); |
254 | 253 | ||
255 | if( !cut.isNull() && qstrcmp( name(), "unnamed" ) == 0 ) | 254 | if( !cut.isNull() && qstrcmp( name(), "unnamed" ) == 0 ) |
256 | kdWarning(129) << "KAction::initPrivate(): trying to assign a shortcut (" << cut.toStringInternal() << ") to an unnamed action." << endl; | 255 | kdWarning(129) << "KAction::initPrivate(): trying to assign a shortcut (" << cut.toStringInternal() << ") to an unnamed action." << endl; |
257 | d->setText( text ); | 256 | d->setText( text ); |
258 | initShortcut( cut ); | 257 | initShortcut( cut ); |
259 | 258 | ||
260 | } | 259 | } |
261 | 260 | ||
262 | bool KAction::isPlugged() const | 261 | bool KAction::isPlugged() const |
263 | { | 262 | { |
@@ -390,302 +389,301 @@ void KAction::plugShortcut() | |||
390 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { | 389 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { |
391 | if( d->m_kaccelList[i] == kaccel ) | 390 | if( d->m_kaccelList[i] == kaccel ) |
392 | return; | 391 | return; |
393 | } | 392 | } |
394 | 393 | ||
395 | insertKAccel( kaccel ); | 394 | insertKAccel( kaccel ); |
396 | } | 395 | } |
397 | } | 396 | } |
398 | 397 | ||
399 | bool KAction::setShortcut( const KShortcut& cut ) | 398 | bool KAction::setShortcut( const KShortcut& cut ) |
400 | { | 399 | { |
401 | qDebug("KAction::setShortcut~ ...1 has top be fixed"); | 400 | qDebug("KAction::setShortcut~ ...1 has top be fixed"); |
402 | /*US | 401 | /*US |
403 | bool bChanged = (d->m_cut != cut); | 402 | bool bChanged = (d->m_cut != cut); |
404 | d->m_cut = cut; | 403 | d->m_cut = cut; |
405 | 404 | ||
406 | KAccel* kaccel = kaccelCurrent(); | 405 | KAccel* kaccel = kaccelCurrent(); |
407 | bool bInsertRequired = true; | 406 | bool bInsertRequired = true; |
408 | // Apply new shortcut to all existing KAccel objects | 407 | // Apply new shortcut to all existing KAccel objects |
409 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { | 408 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { |
410 | // Check whether shortcut has already been plugged into | 409 | // Check whether shortcut has already been plugged into |
411 | // the current kaccel object. | 410 | // the current kaccel object. |
412 | if( d->m_kaccelList[i] == kaccel ) | 411 | if( d->m_kaccelList[i] == kaccel ) |
413 | bInsertRequired = false; | 412 | bInsertRequired = false; |
414 | if( bChanged ) | 413 | if( bChanged ) |
415 | updateKAccelShortcut( d->m_kaccelList[i] ); | 414 | updateKAccelShortcut( d->m_kaccelList[i] ); |
416 | } | 415 | } |
417 | 416 | ||
418 | // Only insert action into KAccel if it has a valid name, | 417 | // Only insert action into KAccel if it has a valid name, |
419 | if( kaccel && bInsertRequired && qstrcmp( name(), "unnamed" ) ) | 418 | if( kaccel && bInsertRequired && qstrcmp( name(), "unnamed" ) ) |
420 | insertKAccel( kaccel ); | 419 | insertKAccel( kaccel ); |
421 | 420 | ||
422 | if( bChanged ) { | 421 | if( bChanged ) { |
423 | // KDE 4: remove | 422 | // KDE 4: remove |
424 | if ( d->m_kaccel ) | 423 | if ( d->m_kaccel ) |
425 | d->m_kaccel->setShortcut( name(), cut ); | 424 | d->m_kaccel->setShortcut( name(), cut ); |
426 | // KDE 4: remove end | 425 | // KDE 4: remove end |
427 | int len = containerCount(); | 426 | int len = containerCount(); |
428 | for( int i = 0; i < len; ++i ) | 427 | for( int i = 0; i < len; ++i ) |
429 | updateShortcut( i ); | 428 | updateShortcut( i ); |
430 | } | 429 | } |
431 | */ | 430 | */ |
432 | 431 | ||
433 | return true; | 432 | return true; |
434 | } | 433 | } |
435 | 434 | ||
436 | bool KAction::updateKAccelShortcut( KAccel* kaccel ) | 435 | bool KAction::updateKAccelShortcut( KAccel* kaccel ) |
437 | { | 436 | { |
438 | qDebug("KAction::updateKAccelShortcut~ ...1 has top be fixed"); | 437 | //qDebug("KAction::updateKAccelShortcut~ ...1 has top be fixed"); |
438 | |||
439 | // Check if action is permitted | 439 | // Check if action is permitted |
440 | /*US | 440 | /*US |
441 | if (kapp && !kapp->authorizeKAction(name())) | 441 | if (kapp && !kapp->authorizeKAction(name())) |
442 | return false; | 442 | return false; |
443 | 443 | ||
444 | bool b = true; | 444 | bool b = true; |
445 | 445 | ||
446 | if ( !kaccel->actions().actionPtr( name() ) ) { | 446 | if ( !kaccel->actions().actionPtr( name() ) ) { |
447 | if(!d->m_cut.isNull() ) { | 447 | if(!d->m_cut.isNull() ) { |
448 | kdDebug(129) << "Inserting " << name() << ", " << d->text() << ", " << d->plainText() << endl; | 448 | kdDebug(129) << "Inserting " << name() << ", " << d->text() << ", " << d->plainText() << endl; |
449 | b = kaccel->insert( name(), d->plainText(), QString::null, | 449 | b = kaccel->insert( name(), d->plainText(), QString::null, |
450 | d->m_cut, | 450 | d->m_cut, |
451 | this, SLOT(slotActivated()), | 451 | this, SLOT(slotActivated()), |
452 | isShortcutConfigurable(), isEnabled() ); | 452 | isShortcutConfigurable(), isEnabled() ); |
453 | } | 453 | } |
454 | } | 454 | } |
455 | else | 455 | else |
456 | b = kaccel->setShortcut( name(), d->m_cut ); | 456 | b = kaccel->setShortcut( name(), d->m_cut ); |
457 | 457 | ||
458 | return b; | 458 | return b; |
459 | */ | 459 | */ |
460 | return true; | 460 | return true; |
461 | } | 461 | } |
462 | 462 | ||
463 | void KAction::insertKAccel( KAccel* kaccel ) | 463 | void KAction::insertKAccel( KAccel* kaccel ) |
464 | { | 464 | { |
465 | qDebug("KAction::updateKAccelShortcut~ ...1 has top be fixed"); | 465 | //qDebug("KAction::updateKAccelShortcut~ ...1 has top be fixed"); |
466 | |||
466 | /*US | 467 | /*US |
467 | //kdDebug(129) << "KAction::insertKAccel( " << kaccel << " ): this = " << this << endl; | 468 | //kdDebug(129) << "KAction::insertKAccel( " << kaccel << " ): this = " << this << endl; |
468 | if ( !kaccel->actions().actionPtr( name() ) ) { | 469 | if ( !kaccel->actions().actionPtr( name() ) ) { |
469 | if( updateKAccelShortcut( kaccel ) ) { | 470 | if( updateKAccelShortcut( kaccel ) ) { |
470 | d->m_kaccelList.append( kaccel ); | 471 | d->m_kaccelList.append( kaccel ); |
471 | connect( kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); | 472 | connect( kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); |
472 | } | 473 | } |
473 | } | 474 | } |
474 | else | 475 | else |
475 | kdWarning(129) << "KAction::insertKAccel( kaccel = " << kaccel << " ): KAccel object already contains an action name \"" << name() << "\"" << endl; // -- ellis | 476 | kdWarning(129) << "KAction::insertKAccel( kaccel = " << kaccel << " ): KAccel object already contains an action name \"" << name() << "\"" << endl; // -- ellis |
476 | */ | 477 | */ |
477 | } | 478 | } |
478 | 479 | ||
479 | void KAction::removeKAccel( KAccel* kaccel ) | 480 | void KAction::removeKAccel( KAccel* kaccel ) |
480 | { | 481 | { |
481 | qDebug("KAction::removeKAccel~ ...1 has top be fixed"); | 482 | // qDebug("KAction::removeKAccel~ ...1 has top be fixed"); |
483 | |||
482 | /*US | 484 | /*US |
483 | //kdDebug(129) << "KAction::removeKAccel( " << i << " ): this = " << this << endl; | 485 | //kdDebug(129) << "KAction::removeKAccel( " << i << " ): this = " << this << endl; |
484 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { | 486 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { |
485 | if( d->m_kaccelList[i] == kaccel ) { | 487 | if( d->m_kaccelList[i] == kaccel ) { |
486 | kaccel->remove( name() ); | 488 | kaccel->remove( name() ); |
487 | d->m_kaccelList.remove( d->m_kaccelList.at( i ) ); | 489 | d->m_kaccelList.remove( d->m_kaccelList.at( i ) ); |
488 | disconnect( kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); | 490 | disconnect( kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); |
489 | break; | 491 | break; |
490 | } | 492 | } |
491 | } | 493 | } |
492 | */ | 494 | */ |
493 | } | 495 | } |
494 | 496 | ||
495 | // KDE 4: remove | 497 | // KDE 4: remove |
496 | void KAction::setAccel( int keyQt ) | 498 | void KAction::setAccel( int keyQt ) |
497 | { | 499 | { |
498 | setShortcut( KShortcut(keyQt) ); | 500 | setShortcut( KShortcut(keyQt) ); |
499 | } | 501 | } |
500 | // KDE 4: remove end | 502 | // KDE 4: remove end |
501 | 503 | ||
502 | void KAction::updateShortcut( int i ) | 504 | void KAction::updateShortcut( int i ) |
503 | { | 505 | { |
504 | int id = itemId( i ); | 506 | int id = itemId( i ); |
505 | 507 | ||
506 | QWidget* w = container( i ); | 508 | QWidget* w = container( i ); |
507 | if ( w->inherits( "QPopupMenu" ) ) { | 509 | if ( w->inherits( "QPopupMenu" ) ) { |
508 | QPopupMenu* menu = static_cast<QPopupMenu*>(w); | 510 | QPopupMenu* menu = static_cast<QPopupMenu*>(w); |
509 | updateShortcut( menu, id ); | 511 | updateShortcut( menu, id ); |
510 | } | 512 | } |
511 | else if ( w->inherits( "QMenuBar" ) ) | 513 | else if ( w->inherits( "QMenuBar" ) ) |
512 | //US static_cast<QMenuBar*>(w)->setAccel( d->m_cut.keyCodeQt(), id ); | 514 | //US static_cast<QMenuBar*>(w)->setAccel( d->m_cut.keyCodeQt(), id ); |
513 | //US (QMenuBar*)(w)->setAccel( d->m_cut.keyCodeQt(), id ); | 515 | //US (QMenuBar*)(w)->setAccel( d->m_cut.keyCodeQt(), id ); |
514 | qDebug("KAction::updateShortcut( int i ) ...1 has top be fixed"); | 516 | |
517 | ; //qDebug("KAction::updateShortcut( int i ) ...1 has top be fixed"); | ||
515 | 518 | ||
516 | } | 519 | } |
517 | 520 | ||
518 | void KAction::updateShortcut( QPopupMenu* menu, int id ) | 521 | void KAction::updateShortcut( QPopupMenu* menu, int id ) |
519 | { | 522 | { |
520 | /*US | 523 | /*US |
521 | //kdDebug(129) << "KAction::updateShortcut(): this = " << this << " d->m_kaccelList.count() = " << d->m_kaccelList.count() << endl; | 524 | //kdDebug(129) << "KAction::updateShortcut(): this = " << this << " d->m_kaccelList.count() = " << d->m_kaccelList.count() << endl; |
522 | // If the action has a KAccel object, | 525 | // If the action has a KAccel object, |
523 | // show the string representation of its shortcut. | 526 | // show the string representation of its shortcut. |
524 | if ( d->m_kaccel || d->m_kaccelList.count() ) { | 527 | if ( d->m_kaccel || d->m_kaccelList.count() ) { |
525 | QString s = menu->text( id ); | 528 | QString s = menu->text( id ); |
526 | int i = s.find( '\t' ); | 529 | int i = s.find( '\t' ); |
527 | if ( i >= 0 ) | 530 | if ( i >= 0 ) |
528 | s.replace( i+1, s.length()-i, d->m_cut.seq(0).toString() ); | 531 | s.replace( i+1, s.length()-i, d->m_cut.seq(0).toString() ); |
529 | else | 532 | else |
530 | s += "\t" + d->m_cut.seq(0).toString(); | 533 | s += "\t" + d->m_cut.seq(0).toString(); |
531 | 534 | ||
532 | menu->changeItem( id, s ); | 535 | menu->changeItem( id, s ); |
533 | } | 536 | } |
534 | // Otherwise insert the shortcut itself into the popup menu. | 537 | // Otherwise insert the shortcut itself into the popup menu. |
535 | else { | 538 | else { |
536 | // This is a fall-hack in case the KAction is missing a proper parent collection. | 539 | // This is a fall-hack in case the KAction is missing a proper parent collection. |
537 | // It should be removed eventually. --ellis | 540 | // It should be removed eventually. --ellis |
538 | menu->setAccel( d->m_cut.keyCodeQt(), id ); | 541 | menu->setAccel( d->m_cut.keyCodeQt(), id ); |
539 | kdWarning(129) << "KAction::updateShortcut(): name = \"" << name() << "\", cut = " << d->m_cut.toStringInternal() << "; No KAccel, probably missing a parent collection." << endl; | 542 | kdWarning(129) << "KAction::updateShortcut(): name = \"" << name() << "\", cut = " << d->m_cut.toStringInternal() << "; No KAccel, probably missing a parent collection." << endl; |
540 | } | 543 | } |
541 | */ | 544 | */ |
542 | qDebug("KAction::updateShortcut( QPopupMenu* menu, int id ) ...1 has top be fixed"); | 545 | |
546 | |||
547 | //qDebug("KAction::updateShortcut( QPopupMenu* menu, int id ) ...1 has top be fixed"); | ||
543 | 548 | ||
544 | } | 549 | } |
545 | 550 | ||
546 | const KShortcut& KAction::shortcut() const | 551 | const KShortcut& KAction::shortcut() const |
547 | { | 552 | { |
548 | return d->m_cut; | 553 | return d->m_cut; |
549 | } | 554 | } |
550 | 555 | ||
551 | const KShortcut& KAction::shortcutDefault() const | 556 | const KShortcut& KAction::shortcutDefault() const |
552 | { | 557 | { |
553 | return d->m_cutDefault; | 558 | return d->m_cutDefault; |
554 | } | 559 | } |
555 | 560 | ||
556 | QString KAction::shortcutText() const | 561 | QString KAction::shortcutText() const |
557 | { | 562 | { |
558 | return d->m_cut.toStringInternal(); | 563 | return d->m_cut.toStringInternal(); |
559 | } | 564 | } |
560 | 565 | ||
561 | void KAction::setShortcutText( const QString& s ) | 566 | void KAction::setShortcutText( const QString& s ) |
562 | { | 567 | { |
563 | setShortcut( KShortcut(s) ); | 568 | setShortcut( KShortcut(s) ); |
564 | } | 569 | } |
565 | 570 | ||
566 | int KAction::accel() const | 571 | int KAction::accel() const |
567 | { | 572 | { |
568 | qDebug("KAction::accel() ...1 has top be fixed"); | 573 | // qDebug("KAction::accel() ...1 has top be fixed"); |
569 | //US return d->m_cut.keyCodeQt(); | 574 | //US return d->m_cut.keyCodeQt(); |
570 | return 0; | 575 | return 0; |
571 | } | 576 | } |
572 | 577 | ||
573 | void KAction::setGroup( const QString& grp ) | 578 | void KAction::setGroup( const QString& grp ) |
574 | { | 579 | { |
575 | d->m_group = grp; | 580 | d->m_group = grp; |
576 | 581 | ||
577 | int len = containerCount(); | 582 | int len = containerCount(); |
578 | for( int i = 0; i < len; ++i ) | 583 | for( int i = 0; i < len; ++i ) |
579 | updateGroup( i ); | 584 | updateGroup( i ); |
580 | } | 585 | } |
581 | 586 | ||
582 | void KAction::updateGroup( int ) | 587 | void KAction::updateGroup( int ) |
583 | { | 588 | { |
584 | // DO SOMETHING | 589 | // DO SOMETHING |
585 | } | 590 | } |
586 | 591 | ||
587 | QString KAction::group() const | 592 | QString KAction::group() const |
588 | { | 593 | { |
589 | return d->m_group; | 594 | return d->m_group; |
590 | } | 595 | } |
591 | 596 | ||
592 | bool KAction::isEnabled() const | 597 | bool KAction::isEnabled() const |
593 | { | 598 | { |
594 | return d->isEnabled(); | 599 | return d->isEnabled(); |
595 | } | 600 | } |
596 | 601 | ||
597 | bool KAction::isShortcutConfigurable() const | 602 | bool KAction::isShortcutConfigurable() const |
598 | { | 603 | { |
599 | return d->m_configurable; | 604 | return d->m_configurable; |
600 | } | 605 | } |
601 | 606 | ||
602 | void KAction::setToolTip( const QString& tt ) | 607 | void KAction::setToolTip( const QString& tt ) |
603 | { | 608 | { |
604 | qDebug("KAction::setToolTip ...1 has top be fixed"); | 609 | //qDebug("KAction::setToolTip ...1 has top be fixed"); |
605 | d->setToolTip( tt ); | 610 | d->setToolTip( tt ); |
606 | 611 | ||
607 | int len = containerCount(); | 612 | int len = containerCount(); |
608 | for( int i = 0; i < len; ++i ) | 613 | for( int i = 0; i < len; ++i ) |
609 | updateToolTip( i ); | 614 | updateToolTip( i ); |
610 | } | 615 | } |
611 | 616 | ||
612 | void KAction::updateToolTip( int i ) | 617 | void KAction::updateToolTip( int i ) |
613 | { | 618 | { |
614 | qDebug("KAction::updateToolTip ...1 has top be fixed"); | 619 | //qDebug("KAction::updateToolTip ...1 has top be fixed"); |
615 | QWidget *w = container( i ); | 620 | QWidget *w = container( i ); |
616 | 621 | ||
617 | if ( w->inherits( "KToolBar" ) ) | 622 | if ( w->inherits( "KToolBar" ) ) |
618 | QToolTip::add( static_cast<KToolBar*>(w)->getWidget( itemId( i ) ), d->toolTip() ); | 623 | QToolTip::add( static_cast<KToolBar*>(w)->getWidget( itemId( i ) ), d->toolTip() ); |
619 | else if ( w->inherits( "QToolBar" ) ) | 624 | else if ( w->inherits( "QToolBar" ) ) |
620 | QToolTip::add( static_cast<KToolBar*>(w)->getWidget( itemId( i ) ), d->toolTip() ); | 625 | QToolTip::add( static_cast<KToolBar*>(w)->getWidget( itemId( i ) ), d->toolTip() ); |
621 | } | 626 | } |
622 | 627 | ||
623 | QString KAction::toolTip() const | 628 | QString KAction::toolTip() const |
624 | { | 629 | { |
625 | return d->toolTip(); | 630 | return d->toolTip(); |
626 | } | 631 | } |
627 | 632 | ||
628 | int KAction::plug( QWidget *w, int index ) | 633 | int KAction::plug( QWidget *w, int index ) |
629 | { | 634 | { |
630 | //kdDebug(129) << "KAction::plug( " << w << ", " << index << " )" << endl; | 635 | //kdDebug(129) << "KAction::plug( " << w << ", " << index << " )" << endl; |
631 | if (w == 0) { | 636 | if (w == 0) { |
632 | kdWarning(129) << "KAction::plug called with 0 argument\n"; | 637 | kdWarning(129) << "KAction::plug called with 0 argument\n"; |
633 | return -1; | 638 | return -1; |
634 | } | 639 | } |
635 | 640 | ||
636 | #ifndef NDEBUG | 641 | |
637 | KAccel* kaccel = kaccelCurrent(); | ||
638 | // If there is a shortcut, but no KAccel available | ||
639 | if( !d->m_cut.isNull() && kaccel == 0 ) { | ||
640 | kdWarning(129) << "KAction::plug(): has no KAccel object; this = " << this << " name = " << name() << " parentCollection = " << m_parentCollection << endl; // ellis | ||
641 | //US kdDebug(129) << kdBacktrace() << endl; | ||
642 | } | ||
643 | #endif | ||
644 | 642 | ||
645 | // Check if action is permitted | 643 | // Check if action is permitted |
646 | //US if (kapp && !kapp->authorizeKAction(name())) | 644 | //US if (kapp && !kapp->authorizeKAction(name())) |
647 | //US return -1; | 645 | //US return -1; |
648 | 646 | ||
649 | plugShortcut(); | 647 | plugShortcut(); |
650 | 648 | ||
651 | if ( w->inherits("QPopupMenu") ) | 649 | if ( w->inherits("QPopupMenu") ) |
652 | { | 650 | { |
653 | QPopupMenu* menu = static_cast<QPopupMenu*>( w ); | 651 | QPopupMenu* menu = static_cast<QPopupMenu*>( w ); |
654 | int id; | 652 | int id; |
655 | // Don't insert shortcut into menu if it's already in a KAccel object. | 653 | // Don't insert shortcut into menu if it's already in a KAccel object. |
656 | //qDebug("KAction::plug warning: real shortcuts not available yet. "); | 654 | //qDebug("KAction::plug warning: real shortcuts not available yet. "); |
657 | //US int keyQt = (d->m_kaccelList.count() || d->m_kaccel) ? 0 : d->m_cut.keyCodeQt(); | 655 | //US int keyQt = (d->m_kaccelList.count() || d->m_kaccel) ? 0 : d->m_cut.keyCodeQt(); |
658 | int keyQt = 0; | 656 | int keyQt = 0; |
659 | 657 | ||
660 | if ( d->hasIcon() ) | 658 | if ( d->hasIcon() ) |
661 | { | 659 | { |
662 | /*US | 660 | /*US |
663 | KInstance *instance; | 661 | KInstance *instance; |
664 | if ( m_parentCollection ) | 662 | if ( m_parentCollection ) |
665 | instance = m_parentCollection->instance(); | 663 | instance = m_parentCollection->instance(); |
666 | else | 664 | else |
667 | instance = KGlobal::instance(); | 665 | instance = KGlobal::instance(); |
668 | */ | 666 | */ |
669 | id = menu->insertItem( d->iconSet( KIcon::Small, 0/*US , instance */), d->text(), this,//dsweet | 667 | id = menu->insertItem( d->iconSet( KIcon::Small, 0/*US , instance */), d->text(), this,//dsweet |
670 | SLOT( slotActivated() ), keyQt, | 668 | SLOT( slotActivated() ), keyQt, |
671 | -1, index ); | 669 | -1, index ); |
672 | } | 670 | } |
673 | else | 671 | else |
674 | id = menu->insertItem( d->text(), this, | 672 | id = menu->insertItem( d->text(), this, |
675 | SLOT( slotActivated() ), //dsweet | 673 | SLOT( slotActivated() ), //dsweet |
676 | keyQt, -1, index ); | 674 | keyQt, -1, index ); |
677 | 675 | ||
678 | // If the shortcut is already in a KAccel object, then | 676 | // If the shortcut is already in a KAccel object, then |
679 | // we need to set the menu item's shortcut text. | 677 | // we need to set the menu item's shortcut text. |
680 | /*US if ( d->m_kaccelList.count() || d->m_kaccel ) | 678 | /*US if ( d->m_kaccelList.count() || d->m_kaccel ) |
681 | updateShortcut( menu, id ); | 679 | updateShortcut( menu, id ); |
682 | */ | 680 | */ |
683 | // call setItemEnabled only if the item really should be disabled, | 681 | // call setItemEnabled only if the item really should be disabled, |
684 | // because that method is slow and the item is per default enabled | 682 | // because that method is slow and the item is per default enabled |
685 | if ( !d->isEnabled() ) | 683 | if ( !d->isEnabled() ) |
686 | menu->setItemEnabled( id, false ); | 684 | menu->setItemEnabled( id, false ); |
687 | 685 | ||
688 | if ( !d->whatsThis().isEmpty() ) | 686 | if ( !d->whatsThis().isEmpty() ) |
689 | menu->setWhatsThis( id, whatsThisWithIcon() ); | 687 | menu->setWhatsThis( id, whatsThisWithIcon() ); |
690 | 688 | ||
691 | addContainer( menu, id ); | 689 | addContainer( menu, id ); |
@@ -730,237 +728,239 @@ int KAction::plug( QWidget *w, int index ) | |||
730 | if ( !d->toolTip().isEmpty() ) | 728 | if ( !d->toolTip().isEmpty() ) |
731 | QToolTip::add( bar->getButton(id_), d->toolTip() ); | 729 | QToolTip::add( bar->getButton(id_), d->toolTip() ); |
732 | 730 | ||
733 | addContainer( bar, id_ ); | 731 | addContainer( bar, id_ ); |
734 | 732 | ||
735 | connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); | 733 | connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); |
736 | 734 | ||
737 | if ( m_parentCollection ) | 735 | if ( m_parentCollection ) |
738 | m_parentCollection->connectHighlight( bar, this ); | 736 | m_parentCollection->connectHighlight( bar, this ); |
739 | 737 | ||
740 | return containerCount() - 1; | 738 | return containerCount() - 1; |
741 | 739 | ||
742 | } | 740 | } |
743 | 741 | ||
744 | return -1; | 742 | return -1; |
745 | } | 743 | } |
746 | 744 | ||
747 | void KAction::unplug( QWidget *w ) | 745 | void KAction::unplug( QWidget *w ) |
748 | { | 746 | { |
749 | int i = findContainer( w ); | 747 | int i = findContainer( w ); |
750 | if ( i == -1 ) | 748 | if ( i == -1 ) |
751 | return; | 749 | return; |
752 | int id = itemId( i ); | 750 | int id = itemId( i ); |
753 | 751 | ||
754 | if ( w->inherits( "QPopupMenu" ) ) | 752 | if ( w->inherits( "QPopupMenu" ) ) |
755 | { | 753 | { |
756 | QPopupMenu *menu = static_cast<QPopupMenu *>( w ); | 754 | QPopupMenu *menu = static_cast<QPopupMenu *>( w ); |
757 | menu->removeItem( id ); | 755 | menu->removeItem( id ); |
758 | } | 756 | } |
759 | else if ( w->inherits( "KToolBar" ) ) | 757 | else if ( w->inherits( "KToolBar" ) ) |
760 | { | 758 | { |
761 | KToolBar *bar = static_cast<KToolBar *>( w ); | 759 | KToolBar *bar = static_cast<KToolBar *>( w ); |
762 | bar->removeItemDelayed( id ); | 760 | bar->removeItemDelayed( id ); |
763 | } | 761 | } |
764 | else if ( w->inherits( "QMenuBar" ) ) | 762 | else if ( w->inherits( "QMenuBar" ) ) |
765 | { | 763 | { |
766 | QMenuBar *bar = static_cast<QMenuBar *>( w ); | 764 | QMenuBar *bar = static_cast<QMenuBar *>( w ); |
767 | bar->removeItem( id ); | 765 | bar->removeItem( id ); |
768 | } | 766 | } |
769 | 767 | ||
770 | removeContainer( i ); | 768 | removeContainer( i ); |
771 | 769 | ||
772 | if ( m_parentCollection ) | 770 | if ( m_parentCollection ) |
773 | m_parentCollection->disconnectHighlight( w, this ); | 771 | m_parentCollection->disconnectHighlight( w, this ); |
774 | } | 772 | } |
775 | 773 | ||
776 | void KAction::plugAccel(KAccel *kacc, bool configurable) | 774 | void KAction::plugAccel(KAccel *kacc, bool configurable) |
777 | { | 775 | { |
778 | qDebug("KAction::plugAccel ...1 has top be fixed"); | 776 | // qDebug("KAction::plugAccel ...1 has top be fixed"); |
777 | |||
779 | /*US | 778 | /*US |
780 | kdWarning(129) << "KAction::plugAccel(): call to deprecated action." << endl; | 779 | kdWarning(129) << "KAction::plugAccel(): call to deprecated action." << endl; |
781 | kdDebug(129) << kdBacktrace() << endl; | 780 | kdDebug(129) << kdBacktrace() << endl; |
782 | //kdDebug(129) << "KAction::plugAccel( kacc = " << kacc << " ): name \"" << name() << "\"" << endl; | 781 | //kdDebug(129) << "KAction::plugAccel( kacc = " << kacc << " ): name \"" << name() << "\"" << endl; |
783 | if ( d->m_kaccel ) | 782 | if ( d->m_kaccel ) |
784 | unplugAccel(); | 783 | unplugAccel(); |
785 | 784 | ||
786 | // If the parent collection's accel ptr isn't set yet | 785 | // If the parent collection's accel ptr isn't set yet |
787 | //if ( m_parentCollection && !m_parentCollection->accel() ) | 786 | //if ( m_parentCollection && !m_parentCollection->accel() ) |
788 | // m_parentCollection->setAccel( kacc ); | 787 | // m_parentCollection->setAccel( kacc ); |
789 | 788 | ||
790 | // We can only plug this action into the given KAccel object | 789 | // We can only plug this action into the given KAccel object |
791 | // if it does not already contain an action with the same name. | 790 | // if it does not already contain an action with the same name. |
792 | if ( !kacc->actions().actionPtr(name()) ) | 791 | if ( !kacc->actions().actionPtr(name()) ) |
793 | { | 792 | { |
794 | d->m_kaccel = kacc; | 793 | d->m_kaccel = kacc; |
795 | d->m_kaccel->insert(name(), d->plainText(), QString::null, | 794 | d->m_kaccel->insert(name(), d->plainText(), QString::null, |
796 | KShortcut(d->m_cut), | 795 | KShortcut(d->m_cut), |
797 | this, SLOT(slotActivated()), | 796 | this, SLOT(slotActivated()), |
798 | configurable, isEnabled()); | 797 | configurable, isEnabled()); |
799 | connect(d->m_kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed())); | 798 | connect(d->m_kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed())); |
800 | //connect(d->m_kaccel, SIGNAL(keycodeChanged()), this, SLOT(slotKeycodeChanged())); | 799 | //connect(d->m_kaccel, SIGNAL(keycodeChanged()), this, SLOT(slotKeycodeChanged())); |
801 | } | 800 | } |
802 | else | 801 | else |
803 | kdWarning(129) << "KAction::plugAccel( kacc = " << kacc << " ): KAccel object already contains an action name \"" << name() << "\"" << endl; // -- ellis | 802 | kdWarning(129) << "KAction::plugAccel( kacc = " << kacc << " ): KAccel object already contains an action name \"" << name() << "\"" << endl; // -- ellis |
804 | */ | 803 | */ |
805 | } | 804 | } |
806 | 805 | ||
807 | void KAction::unplugAccel() | 806 | void KAction::unplugAccel() |
808 | { | 807 | { |
809 | qDebug("KAction::unplugAccel ...1 has top be fixed"); | 808 | // qDebug("KAction::unplugAccel ...1 has top be fixed"); |
810 | /*US | 809 | /*US |
811 | //kdDebug(129) << "KAction::unplugAccel() " << this << " " << name() << endl; | 810 | //kdDebug(129) << "KAction::unplugAccel() " << this << " " << name() << endl; |
812 | if ( d->m_kaccel ) | 811 | if ( d->m_kaccel ) |
813 | { | 812 | { |
814 | d->m_kaccel->remove(name()); | 813 | d->m_kaccel->remove(name()); |
815 | d->m_kaccel = 0; | 814 | d->m_kaccel = 0; |
816 | } | 815 | } |
817 | */ | 816 | */ |
818 | } | 817 | } |
819 | 818 | ||
820 | void KAction::plugMainWindowAccel( QWidget *w ) | 819 | void KAction::plugMainWindowAccel( QWidget *w ) |
821 | { | 820 | { |
822 | qDebug("KAction::plugMainWindowAccel ...1 has top be fixed"); | 821 | // qDebug("KAction::plugMainWindowAccel ...1 has top be fixed"); |
822 | |||
823 | /*US | 823 | /*US |
824 | // Note: topLevelWidget() stops too early, we can't use it. | 824 | // Note: topLevelWidget() stops too early, we can't use it. |
825 | QWidget * tl = w; | 825 | QWidget * tl = w; |
826 | QWidget * n; | 826 | QWidget * n; |
827 | while ( !tl->isDialog() && ( n = tl->parentWidget() ) ) // lookup parent and store | 827 | while ( !tl->isDialog() && ( n = tl->parentWidget() ) ) // lookup parent and store |
828 | tl = n; | 828 | tl = n; |
829 | 829 | ||
830 | KMainWindow * mw = dynamic_cast<KMainWindow *>(tl); // try to see if it's a kmainwindow | 830 | KMainWindow * mw = dynamic_cast<KMainWindow *>(tl); // try to see if it's a kmainwindow |
831 | if (mw) | 831 | if (mw) |
832 | plugAccel( mw->accel() ); | 832 | plugAccel( mw->accel() ); |
833 | else | 833 | else |
834 | kdDebug(129) << "KAction::plugMainWindowAccel: Toplevel widget isn't a KMainWindow, can't plug accel. " << tl << endl; | 834 | kdDebug(129) << "KAction::plugMainWindowAccel: Toplevel widget isn't a KMainWindow, can't plug accel. " << tl << endl; |
835 | */ | 835 | */ |
836 | } | 836 | } |
837 | 837 | ||
838 | void KAction::setEnabled(bool enable) | 838 | void KAction::setEnabled(bool enable) |
839 | { | 839 | { |
840 | //kdDebug(129) << "KAction::setEnabled( " << enable << " ): this = " << this << " d->m_kaccelList.count() = " << d->m_kaccelList.count() << endl; | 840 | //kdDebug(129) << "KAction::setEnabled( " << enable << " ): this = " << this << " d->m_kaccelList.count() = " << d->m_kaccelList.count() << endl; |
841 | if ( enable == d->isEnabled() ) | 841 | if ( enable == d->isEnabled() ) |
842 | return; | 842 | return; |
843 | 843 | ||
844 | // KDE 4: remove | 844 | // KDE 4: remove |
845 | //US if (d->m_kaccel) | 845 | //US if (d->m_kaccel) |
846 | //US d->m_kaccel->setEnabled(name(), enable); | 846 | //US d->m_kaccel->setEnabled(name(), enable); |
847 | // KDE 4: remove end | 847 | // KDE 4: remove end |
848 | 848 | ||
849 | //US for ( uint i = 0; i < d->m_kaccelList.count(); i++ ) | 849 | //US for ( uint i = 0; i < d->m_kaccelList.count(); i++ ) |
850 | //US d->m_kaccelList[i]->setEnabled( name(), enable ); | 850 | //US d->m_kaccelList[i]->setEnabled( name(), enable ); |
851 | 851 | ||
852 | d->setEnabled( enable ); | 852 | d->setEnabled( enable ); |
853 | 853 | ||
854 | int len = containerCount(); | 854 | int len = containerCount(); |
855 | for( int i = 0; i < len; ++i ) | 855 | for( int i = 0; i < len; ++i ) |
856 | updateEnabled( i ); | 856 | updateEnabled( i ); |
857 | 857 | ||
858 | emit enabled( d->isEnabled() ); | 858 | emit enabled( d->isEnabled() ); |
859 | } | 859 | } |
860 | 860 | ||
861 | void KAction::updateEnabled( int i ) | 861 | void KAction::updateEnabled( int i ) |
862 | { | 862 | { |
863 | QWidget *w = container( i ); | 863 | QWidget *w = container( i ); |
864 | 864 | ||
865 | if ( w->inherits("QPopupMenu") ) | 865 | if ( w->inherits("QPopupMenu") ) |
866 | static_cast<QPopupMenu*>(w)->setItemEnabled( itemId( i ), d->isEnabled() ); | 866 | static_cast<QPopupMenu*>(w)->setItemEnabled( itemId( i ), d->isEnabled() ); |
867 | else if ( w->inherits("QMenuBar") ) | 867 | else if ( w->inherits("QMenuBar") ) |
868 | static_cast<QMenuBar*>(w)->setItemEnabled( itemId( i ), d->isEnabled() ); | 868 | static_cast<QMenuBar*>(w)->setItemEnabled( itemId( i ), d->isEnabled() ); |
869 | else if ( w->inherits( "KToolBar" ) ) | 869 | else if ( w->inherits( "KToolBar" ) ) |
870 | { | 870 | { |
871 | static_cast<KToolBar*>(w)->setItemEnabled( itemId( i ), d->isEnabled() ); | 871 | static_cast<KToolBar*>(w)->setItemEnabled( itemId( i ), d->isEnabled() ); |
872 | } | 872 | } |
873 | } | 873 | } |
874 | 874 | ||
875 | void KAction::setShortcutConfigurable( bool b ) | 875 | void KAction::setShortcutConfigurable( bool b ) |
876 | { | 876 | { |
877 | d->m_configurable = b; | 877 | d->m_configurable = b; |
878 | } | 878 | } |
879 | 879 | ||
880 | void KAction::setText( const QString& text ) | 880 | void KAction::setText( const QString& text ) |
881 | { | 881 | { |
882 | /*US | 882 | /*US |
883 | // KDE 4: remove | 883 | // KDE 4: remove |
884 | if (d->m_kaccel) { | 884 | if (d->m_kaccel) { |
885 | KAccelAction* pAction = d->m_kaccel->actions().actionPtr(name()); | 885 | KAccelAction* pAction = d->m_kaccel->actions().actionPtr(name()); |
886 | if (pAction) | 886 | if (pAction) |
887 | pAction->setLabel( text ); | 887 | pAction->setLabel( text ); |
888 | } | 888 | } |
889 | // KDE 4: remove end | 889 | // KDE 4: remove end |
890 | 890 | ||
891 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { | 891 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { |
892 | KAccelAction* pAction = d->m_kaccelList[i]->actions().actionPtr(name()); | 892 | KAccelAction* pAction = d->m_kaccelList[i]->actions().actionPtr(name()); |
893 | if (pAction) | 893 | if (pAction) |
894 | pAction->setLabel( text ); | 894 | pAction->setLabel( text ); |
895 | } | 895 | } |
896 | */ | 896 | */ |
897 | d->setText( text ); | 897 | d->setText( text ); |
898 | 898 | ||
899 | int len = containerCount(); | 899 | int len = containerCount(); |
900 | for( int i = 0; i < len; ++i ) | 900 | for( int i = 0; i < len; ++i ) |
901 | updateText( i ); | 901 | updateText( i ); |
902 | 902 | ||
903 | } | 903 | } |
904 | 904 | ||
905 | void KAction::updateText( int i ) | 905 | void KAction::updateText( int i ) |
906 | { | 906 | { |
907 | QWidget *w = container( i ); | 907 | QWidget *w = container( i ); |
908 | 908 | ||
909 | if ( w->inherits( "QPopupMenu" ) ) { | 909 | if ( w->inherits( "QPopupMenu" ) ) { |
910 | int id = itemId( i ); | 910 | int id = itemId( i ); |
911 | static_cast<QPopupMenu*>(w)->changeItem( id, d->text() ); | 911 | static_cast<QPopupMenu*>(w)->changeItem( id, d->text() ); |
912 | updateShortcut( static_cast<QPopupMenu*>(w), id ); | 912 | updateShortcut( static_cast<QPopupMenu*>(w), id ); |
913 | } | 913 | } |
914 | else if ( w->inherits( "QMenuBar" ) ) | 914 | else if ( w->inherits( "QMenuBar" ) ) |
915 | static_cast<QMenuBar*>(w)->changeItem( itemId( i ), d->text() ); | 915 | static_cast<QMenuBar*>(w)->changeItem( itemId( i ), d->text() ); |
916 | else if ( w->inherits( "KToolBar" ) ) | 916 | else if ( w->inherits( "KToolBar" ) ) |
917 | { | 917 | { |
918 | qDebug("KAction::updateText ...3 has top be fixed"); | 918 | //qDebug("KAction::updateText ...3 has top be fixed"); |
919 | QWidget *button = static_cast<KToolBar *>(w)->getWidget( itemId( i ) ); | 919 | QWidget *button = static_cast<KToolBar *>(w)->getWidget( itemId( i ) ); |
920 | if ( button->inherits( "KToolBarButton" ) ) | 920 | if ( button->inherits( "KToolBarButton" ) ) |
921 | static_cast<KToolBarButton *>(button)->setText( d->plainText() ); | 921 | static_cast<KToolBarButton *>(button)->setText( d->plainText() ); |
922 | 922 | ||
923 | } | 923 | } |
924 | } | 924 | } |
925 | 925 | ||
926 | QString KAction::text() const | 926 | QString KAction::text() const |
927 | { | 927 | { |
928 | return d->text(); | 928 | return d->text(); |
929 | } | 929 | } |
930 | 930 | ||
931 | QString KAction::plainText() const | 931 | QString KAction::plainText() const |
932 | { | 932 | { |
933 | return d->plainText( ); | 933 | return d->plainText( ); |
934 | } | 934 | } |
935 | 935 | ||
936 | void KAction::setIcon( const QString &icon ) | 936 | void KAction::setIcon( const QString &icon ) |
937 | { | 937 | { |
938 | d->setIconName( icon ); | 938 | d->setIconName( icon ); |
939 | 939 | ||
940 | // now handle any toolbars | 940 | // now handle any toolbars |
941 | int len = containerCount(); | 941 | int len = containerCount(); |
942 | for ( int i = 0; i < len; ++i ) | 942 | for ( int i = 0; i < len; ++i ) |
943 | updateIcon( i ); | 943 | updateIcon( i ); |
944 | } | 944 | } |
945 | 945 | ||
946 | void KAction::updateIcon( int id ) | 946 | void KAction::updateIcon( int id ) |
947 | { | 947 | { |
948 | QWidget* w = container( id ); | 948 | QWidget* w = container( id ); |
949 | 949 | ||
950 | if ( w->inherits( "QPopupMenu" ) ) { | 950 | if ( w->inherits( "QPopupMenu" ) ) { |
951 | int itemId_ = itemId( id ); | 951 | int itemId_ = itemId( id ); |
952 | static_cast<QPopupMenu*>(w)->changeItem( itemId_, d->iconSet( KIcon::Small ), d->text() ); | 952 | static_cast<QPopupMenu*>(w)->changeItem( itemId_, d->iconSet( KIcon::Small ), d->text() ); |
953 | updateShortcut( static_cast<QPopupMenu*>(w), itemId_ ); | 953 | updateShortcut( static_cast<QPopupMenu*>(w), itemId_ ); |
954 | } | 954 | } |
955 | else if ( w->inherits( "QMenuBar" ) ) | 955 | else if ( w->inherits( "QMenuBar" ) ) |
956 | static_cast<QMenuBar*>(w)->changeItem( itemId( id ), d->iconSet( KIcon::Small ), d->text() ); | 956 | static_cast<QMenuBar*>(w)->changeItem( itemId( id ), d->iconSet( KIcon::Small ), d->text() ); |
957 | else if ( w->inherits( "KToolBar" ) ) | 957 | else if ( w->inherits( "KToolBar" ) ) |
958 | static_cast<KToolBar *>(w)->setButtonIcon( itemId( id ), d->iconName() ); | 958 | static_cast<KToolBar *>(w)->setButtonIcon( itemId( id ), d->iconName() ); |
959 | else if ( w->inherits( "QToolBar" ) ) | 959 | else if ( w->inherits( "QToolBar" ) ) |
960 | { | 960 | { |
961 | qDebug("KAction::updateIcon has top be fixed"); | 961 | qDebug("KAction::updateIcon has top be fixed"); |
962 | //US static_cast<QToolBar *>(w)->setButtonIcon( itemId( id ), d->iconName() ); | 962 | //US static_cast<QToolBar *>(w)->setButtonIcon( itemId( id ), d->iconName() ); |
963 | } | 963 | } |
964 | } | 964 | } |
965 | 965 | ||
966 | QString KAction::icon() const | 966 | QString KAction::icon() const |
@@ -1073,97 +1073,97 @@ QPopupMenu* KAction::popupMenu( int index ) const | |||
1073 | QWidget* KAction::representative( int index ) const | 1073 | QWidget* KAction::representative( int index ) const |
1074 | { | 1074 | { |
1075 | return d->m_containers[ index ].m_representative; | 1075 | return d->m_containers[ index ].m_representative; |
1076 | } | 1076 | } |
1077 | 1077 | ||
1078 | int KAction::itemId( int index ) const | 1078 | int KAction::itemId( int index ) const |
1079 | { | 1079 | { |
1080 | return d->m_containers[ index ].m_id; | 1080 | return d->m_containers[ index ].m_id; |
1081 | } | 1081 | } |
1082 | 1082 | ||
1083 | int KAction::containerCount() const | 1083 | int KAction::containerCount() const |
1084 | { | 1084 | { |
1085 | return d->m_containers.count(); | 1085 | return d->m_containers.count(); |
1086 | } | 1086 | } |
1087 | 1087 | ||
1088 | uint KAction::kaccelCount() const | 1088 | uint KAction::kaccelCount() const |
1089 | { | 1089 | { |
1090 | return d->m_kaccelList.count(); | 1090 | return d->m_kaccelList.count(); |
1091 | } | 1091 | } |
1092 | 1092 | ||
1093 | void KAction::addContainer( QWidget* c, int id ) | 1093 | void KAction::addContainer( QWidget* c, int id ) |
1094 | { | 1094 | { |
1095 | KActionPrivate::Container p; | 1095 | KActionPrivate::Container p; |
1096 | p.m_container = c; | 1096 | p.m_container = c; |
1097 | p.m_id = id; | 1097 | p.m_id = id; |
1098 | d->m_containers.append( p ); | 1098 | d->m_containers.append( p ); |
1099 | } | 1099 | } |
1100 | 1100 | ||
1101 | void KAction::addContainer( QWidget* c, QWidget* w ) | 1101 | void KAction::addContainer( QWidget* c, QWidget* w ) |
1102 | { | 1102 | { |
1103 | KActionPrivate::Container p; | 1103 | KActionPrivate::Container p; |
1104 | p.m_container = c; | 1104 | p.m_container = c; |
1105 | p.m_representative = w; | 1105 | p.m_representative = w; |
1106 | d->m_containers.append( p ); | 1106 | d->m_containers.append( p ); |
1107 | } | 1107 | } |
1108 | 1108 | ||
1109 | void KAction::activate() | 1109 | void KAction::activate() |
1110 | { | 1110 | { |
1111 | slotActivated(); | 1111 | slotActivated(); |
1112 | } | 1112 | } |
1113 | 1113 | ||
1114 | void KAction::slotActivated() | 1114 | void KAction::slotActivated() |
1115 | { | 1115 | { |
1116 | emit activated(); | 1116 | emit activated(); |
1117 | } | 1117 | } |
1118 | 1118 | ||
1119 | void KAction::slotDestroyed() | 1119 | void KAction::slotDestroyed() |
1120 | { | 1120 | { |
1121 | kdDebug(129) << "KAction::slotDestroyed(): this = " << this << ", name = \"" << name() << "\", sender = " << sender() << endl; | 1121 | |
1122 | const QObject* o = sender(); | 1122 | const QObject* o = sender(); |
1123 | 1123 | ||
1124 | /* | 1124 | /* |
1125 | 1125 | ||
1126 | 1126 | ||
1127 | // KDE 4: remove | 1127 | // KDE 4: remove |
1128 | if ( o == d->m_kaccel ) | 1128 | if ( o == d->m_kaccel ) |
1129 | { | 1129 | { |
1130 | d->m_kaccel = 0; | 1130 | d->m_kaccel = 0; |
1131 | return; | 1131 | return; |
1132 | } | 1132 | } |
1133 | // KDE 4: remove end | 1133 | // KDE 4: remove end |
1134 | 1134 | ||
1135 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) | 1135 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) |
1136 | { | 1136 | { |
1137 | if ( o == d->m_kaccelList[i] ) | 1137 | if ( o == d->m_kaccelList[i] ) |
1138 | { | 1138 | { |
1139 | disconnect( d->m_kaccelList[i], SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); | 1139 | disconnect( d->m_kaccelList[i], SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); |
1140 | d->m_kaccelList.remove( d->m_kaccelList.at( i ) ); | 1140 | d->m_kaccelList.remove( d->m_kaccelList.at( i ) ); |
1141 | return; | 1141 | return; |
1142 | } | 1142 | } |
1143 | } | 1143 | } |
1144 | */ | 1144 | */ |
1145 | int i; | 1145 | int i; |
1146 | do | 1146 | do |
1147 | { | 1147 | { |
1148 | i = findContainer( static_cast<const QWidget*>( o ) ); | 1148 | i = findContainer( static_cast<const QWidget*>( o ) ); |
1149 | if ( i != -1 ) | 1149 | if ( i != -1 ) |
1150 | removeContainer( i ); | 1150 | removeContainer( i ); |
1151 | } while ( i != -1 ); | 1151 | } while ( i != -1 ); |
1152 | 1152 | ||
1153 | } | 1153 | } |
1154 | 1154 | ||
1155 | int KAction::findContainer( const QWidget* widget ) const | 1155 | int KAction::findContainer( const QWidget* widget ) const |
1156 | { | 1156 | { |
1157 | int pos = 0; | 1157 | int pos = 0; |
1158 | QValueList<KActionPrivate::Container>::ConstIterator it = d->m_containers.begin(); | 1158 | QValueList<KActionPrivate::Container>::ConstIterator it = d->m_containers.begin(); |
1159 | while( it != d->m_containers.end() ) | 1159 | while( it != d->m_containers.end() ) |
1160 | { | 1160 | { |
1161 | if ( (*it).m_representative == widget || (*it).m_container == widget ) | 1161 | if ( (*it).m_representative == widget || (*it).m_container == widget ) |
1162 | return pos; | 1162 | return pos; |
1163 | ++it; | 1163 | ++it; |
1164 | ++pos; | 1164 | ++pos; |
1165 | } | 1165 | } |
1166 | 1166 | ||
1167 | return -1; | 1167 | return -1; |
1168 | } | 1168 | } |
1169 | 1169 | ||