Changeset View
Changeset View
Standalone View
Standalone View
src/scriptengines/qml/plasmoid/appletinterface.cpp
Show First 20 Lines • Show All 432 Lines • ▼ Show 20 Line(s) | |||||
433 | QList<QAction *> AppletInterface::contextualActions() const | 433 | QList<QAction *> AppletInterface::contextualActions() const | ||
434 | { | 434 | { | ||
435 | QList<QAction *> actions; | 435 | QList<QAction *> actions; | ||
436 | Plasma::Applet *a = applet(); | 436 | Plasma::Applet *a = applet(); | ||
437 | if (a->failedToLaunch()) { | 437 | if (a->failedToLaunch()) { | ||
438 | return actions; | 438 | return actions; | ||
439 | } | 439 | } | ||
440 | 440 | | |||
441 | foreach (const QString &name, m_actions) { | 441 | for (const QString &name : qAsConst(m_actions)) { | ||
442 | QAction *action = a->actions()->action(name); | 442 | QAction *action = a->actions()->action(name); | ||
443 | 443 | | |||
444 | if (action) { | 444 | if (action) { | ||
445 | actions << action; | 445 | actions << action; | ||
446 | } | 446 | } | ||
447 | } | 447 | } | ||
448 | 448 | | |||
449 | return actions; | 449 | return actions; | ||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | 498 | { | |||
499 | Plasma::Applet *a = applet(); | 499 | Plasma::Applet *a = applet(); | ||
500 | QAction *action = a->actions()->action(name); | 500 | QAction *action = a->actions()->action(name); | ||
501 | delete action; | 501 | delete action; | ||
502 | m_actions.removeAll(name); | 502 | m_actions.removeAll(name); | ||
503 | } | 503 | } | ||
504 | 504 | | |||
505 | void AppletInterface::clearActions() | 505 | void AppletInterface::clearActions() | ||
506 | { | 506 | { | ||
507 | Q_FOREACH (const QString &action, m_actions) { | 507 | const auto oldActionsList = m_actions; | ||
508 | for (const QString &action : oldActionsList) { | ||||
508 | removeAction(action); | 509 | removeAction(action); | ||
509 | } | 510 | } | ||
510 | } | 511 | } | ||
511 | 512 | | |||
512 | QAction *AppletInterface::action(QString name) const | 513 | QAction *AppletInterface::action(QString name) const | ||
513 | { | 514 | { | ||
514 | return applet()->actions()->action(name); | 515 | return applet()->actions()->action(name); | ||
515 | } | 516 | } | ||
▲ Show 20 Lines • Show All 246 Lines • ▼ Show 20 Line(s) | 751 | if (event->type() == QEvent::KeyPress) { | |||
762 | } | 763 | } | ||
763 | 764 | | |||
764 | //add any actions of the corona | 765 | //add any actions of the corona | ||
765 | if (applet()->containment() && applet()->containment()->corona()) { | 766 | if (applet()->containment() && applet()->containment()->corona()) { | ||
766 | actions << applet()->containment()->corona()->actions()->actions(); | 767 | actions << applet()->containment()->corona()->actions()->actions(); | ||
767 | } | 768 | } | ||
768 | 769 | | |||
769 | bool keySequenceUsed = false; | 770 | bool keySequenceUsed = false; | ||
770 | foreach (auto a, actions) { | 771 | for (auto a : qAsConst(actions)) { | ||
771 | 772 | | |||
772 | if (a->shortcut().isEmpty()) { | 773 | if (a->shortcut().isEmpty()) { | ||
773 | continue; | 774 | continue; | ||
774 | } | 775 | } | ||
775 | 776 | | |||
776 | //this will happen on a normal, non emacs shortcut | 777 | //this will happen on a normal, non emacs shortcut | ||
777 | if (seq.matches(a->shortcut()) == QKeySequence::ExactMatch) { | 778 | if (seq.matches(a->shortcut()) == QKeySequence::ExactMatch) { | ||
778 | event->accept(); | 779 | event->accept(); | ||
▲ Show 20 Lines • Show All 106 Lines • Show Last 20 Lines |