Changeset View
Changeset View
Standalone View
Standalone View
src/scriptengines/qml/plasmoid/appletinterface.cpp
Show First 20 Lines • Show All 410 Lines • ▼ Show 20 Line(s) | |||||
411 | QList<QAction *> AppletInterface::contextualActions() const | 411 | QList<QAction *> AppletInterface::contextualActions() const | ||
412 | { | 412 | { | ||
413 | QList<QAction *> actions; | 413 | QList<QAction *> actions; | ||
414 | Plasma::Applet *a = applet(); | 414 | Plasma::Applet *a = applet(); | ||
415 | if (a->failedToLaunch()) { | 415 | if (a->failedToLaunch()) { | ||
416 | return actions; | 416 | return actions; | ||
417 | } | 417 | } | ||
418 | 418 | | |||
419 | foreach (const QString &name, m_actions) { | 419 | for (const QString &name : qAsConst(m_actions)) { | ||
420 | QAction *action = a->actions()->action(name); | 420 | QAction *action = a->actions()->action(name); | ||
421 | 421 | | |||
422 | if (action) { | 422 | if (action) { | ||
423 | actions << action; | 423 | actions << action; | ||
424 | } | 424 | } | ||
425 | } | 425 | } | ||
426 | 426 | | |||
427 | return actions; | 427 | return actions; | ||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | 476 | { | |||
477 | Plasma::Applet *a = applet(); | 477 | Plasma::Applet *a = applet(); | ||
478 | QAction *action = a->actions()->action(name); | 478 | QAction *action = a->actions()->action(name); | ||
479 | delete action; | 479 | delete action; | ||
480 | m_actions.removeAll(name); | 480 | m_actions.removeAll(name); | ||
481 | } | 481 | } | ||
482 | 482 | | |||
483 | void AppletInterface::clearActions() | 483 | void AppletInterface::clearActions() | ||
484 | { | 484 | { | ||
485 | Q_FOREACH (const QString &action, m_actions) { | 485 | const auto oldActionsList = m_actions; | ||
486 | for (const QString &action : oldActionsList) { | ||||
486 | removeAction(action); | 487 | removeAction(action); | ||
487 | } | 488 | } | ||
488 | } | 489 | } | ||
489 | 490 | | |||
490 | QAction *AppletInterface::action(QString name) const | 491 | QAction *AppletInterface::action(QString name) const | ||
491 | { | 492 | { | ||
492 | return applet()->actions()->action(name); | 493 | return applet()->actions()->action(name); | ||
493 | } | 494 | } | ||
▲ Show 20 Lines • Show All 246 Lines • ▼ Show 20 Line(s) | 729 | if (event->type() == QEvent::KeyPress) { | |||
740 | } | 741 | } | ||
741 | 742 | | |||
742 | //add any actions of the corona | 743 | //add any actions of the corona | ||
743 | if (applet()->containment() && applet()->containment()->corona()) { | 744 | if (applet()->containment() && applet()->containment()->corona()) { | ||
744 | actions << applet()->containment()->corona()->actions()->actions(); | 745 | actions << applet()->containment()->corona()->actions()->actions(); | ||
745 | } | 746 | } | ||
746 | 747 | | |||
747 | bool keySequenceUsed = false; | 748 | bool keySequenceUsed = false; | ||
748 | foreach (auto a, actions) { | 749 | for (auto a : qAsConst(actions)) { | ||
749 | 750 | | |||
750 | if (a->shortcut().isEmpty()) { | 751 | if (a->shortcut().isEmpty()) { | ||
751 | continue; | 752 | continue; | ||
752 | } | 753 | } | ||
753 | 754 | | |||
754 | //this will happen on a normal, non emacs shortcut | 755 | //this will happen on a normal, non emacs shortcut | ||
755 | if (seq.matches(a->shortcut()) == QKeySequence::ExactMatch) { | 756 | if (seq.matches(a->shortcut()) == QKeySequence::ExactMatch) { | ||
756 | event->accept(); | 757 | event->accept(); | ||
▲ Show 20 Lines • Show All 90 Lines • Show Last 20 Lines |