Changeset View
Changeset View
Standalone View
Standalone View
src/kactioncollection.cpp
Show First 20 Lines • Show All 364 Lines • ▼ Show 20 Line(s) | 361 | { | |||
---|---|---|---|---|---|
365 | 365 | | |||
366 | // Remove the action from all widgets | 366 | // Remove the action from all widgets | ||
367 | for (QWidget *widget : qAsConst(d->associatedWidgets)) { | 367 | for (QWidget *widget : qAsConst(d->associatedWidgets)) { | ||
368 | widget->removeAction(action); | 368 | widget->removeAction(action); | ||
369 | } | 369 | } | ||
370 | 370 | | |||
371 | action->disconnect(this); | 371 | action->disconnect(this); | ||
372 | 372 | | |||
373 | #if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 0) | ||||
373 | emit removed(action); //deprecated | 374 | emit removed(action); //deprecated | ||
375 | #endif | ||||
374 | return action; | 376 | return action; | ||
375 | } | 377 | } | ||
376 | 378 | | |||
377 | QAction *KActionCollection::addAction(KStandardAction::StandardAction actionType, const QObject *receiver, const char *member) | 379 | QAction *KActionCollection::addAction(KStandardAction::StandardAction actionType, const QObject *receiver, const char *member) | ||
378 | { | 380 | { | ||
379 | QAction *action = KStandardAction::create(actionType, receiver, member, this); | 381 | QAction *action = KStandardAction::create(actionType, receiver, member, this); | ||
380 | return action; | 382 | return action; | ||
381 | } | 383 | } | ||
▲ Show 20 Lines • Show All 342 Lines • ▼ Show 20 Line(s) | |||||
724 | void KActionCollection::slotActionTriggered() | 726 | void KActionCollection::slotActionTriggered() | ||
725 | { | 727 | { | ||
726 | QAction *action = qobject_cast<QAction *>(sender()); | 728 | QAction *action = qobject_cast<QAction *>(sender()); | ||
727 | if (action) { | 729 | if (action) { | ||
728 | emit actionTriggered(action); | 730 | emit actionTriggered(action); | ||
729 | } | 731 | } | ||
730 | } | 732 | } | ||
731 | 733 | | |||
734 | #if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 0) | ||||
732 | void KActionCollection::slotActionHighlighted() | 735 | void KActionCollection::slotActionHighlighted() | ||
733 | { | 736 | { | ||
734 | slotActionHovered(); | 737 | slotActionHovered(); | ||
735 | } | 738 | } | ||
739 | #endif | ||||
736 | 740 | | |||
737 | void KActionCollection::slotActionHovered() | 741 | void KActionCollection::slotActionHovered() | ||
738 | { | 742 | { | ||
739 | QAction *action = qobject_cast<QAction *>(sender()); | 743 | QAction *action = qobject_cast<QAction *>(sender()); | ||
740 | if (action) { | 744 | if (action) { | ||
745 | #if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 0) | ||||
741 | emit actionHighlighted(action); | 746 | emit actionHighlighted(action); | ||
747 | #endif | ||||
742 | emit actionHovered(action); | 748 | emit actionHovered(action); | ||
743 | } | 749 | } | ||
744 | } | 750 | } | ||
745 | 751 | | |||
746 | void KActionCollectionPrivate::_k_actionDestroyed(QObject *obj) | 752 | void KActionCollectionPrivate::_k_actionDestroyed(QObject *obj) | ||
747 | { | 753 | { | ||
748 | // obj isn't really a QAction anymore. So make sure we don't do fancy stuff | 754 | // obj isn't really a QAction anymore. So make sure we don't do fancy stuff | ||
749 | // with it. | 755 | // with it. | ||
750 | QAction *action = static_cast<QAction *>(obj); | 756 | QAction *action = static_cast<QAction *>(obj); | ||
751 | 757 | | |||
752 | if (!unlistAction(action)) { | 758 | if (!unlistAction(action)) { | ||
753 | return; | 759 | return; | ||
754 | } | 760 | } | ||
755 | 761 | | |||
756 | //HACK the object we emit is partly destroyed | 762 | //HACK the object we emit is partly destroyed | ||
763 | #if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 0) | ||||
757 | emit q->removed(action); //deprecated. remove in KDE5 | 764 | emit q->removed(action); //deprecated. remove in KDE5 | ||
765 | #endif | ||||
758 | } | 766 | } | ||
759 | 767 | | |||
760 | void KActionCollection::connectNotify(const QMetaMethod &signal) | 768 | void KActionCollection::connectNotify(const QMetaMethod &signal) | ||
761 | { | 769 | { | ||
762 | if (d->connectHovered && d->connectTriggered) { | 770 | if (d->connectHovered && d->connectTriggered) { | ||
763 | return; | 771 | return; | ||
764 | } | 772 | } | ||
765 | 773 | | |||
766 | if (signal.methodSignature() == "actionHighlighted(QAction*)" || | 774 | if ( | ||
775 | #if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 0) | ||||
776 | signal.methodSignature() == "actionHighlighted(QAction*)" || | ||||
777 | #endif | ||||
767 | signal.methodSignature() == "actionHovered(QAction*)") { | 778 | signal.methodSignature() == "actionHovered(QAction*)") { | ||
768 | if (!d->connectHovered) { | 779 | if (!d->connectHovered) { | ||
769 | d->connectHovered = true; | 780 | d->connectHovered = true; | ||
770 | for (QAction *action : qAsConst(d->actions)) { | 781 | for (QAction *action : qAsConst(d->actions)) { | ||
771 | connect(action, &QAction::hovered, | 782 | connect(action, &QAction::hovered, | ||
772 | this, &KActionCollection::slotActionHovered); | 783 | this, &KActionCollection::slotActionHovered); | ||
773 | } | 784 | } | ||
774 | } | 785 | } | ||
▲ Show 20 Lines • Show All 104 Lines • Show Last 20 Lines |