/* This file is part of the KDE libraries SPDX-FileCopyrightText: 1999 Reginald Stadlbauer SPDX-FileCopyrightText: 1999 Simon Hausmann SPDX-FileCopyrightText: 2000 Nicolas Hadacek SPDX-FileCopyrightText: 2000 Kurt Granroth SPDX-FileCopyrightText: 2000 Michael Koch SPDX-FileCopyrightText: 2001 Holger Freyther SPDX-FileCopyrightText: 2002 Ellis Whitehead SPDX-FileCopyrightText: 2002 Joseph Wenninger SPDX-FileCopyrightText: 2005-2006 Hamish Rodda SPDX-License-Identifier: LGPL-2.0-only */ #include #include #include #include #include class KActionConflictDetector : public QObject { Q_OBJECT public: explicit KActionConflictDetector(QObject *parent = nullptr) : QObject(parent) { } bool eventFilter(QObject *watched, QEvent *event) override { if (event->type() == QEvent::Shortcut && qobject_cast(watched)) { QShortcutEvent *se = static_cast(event); if (se->isAmbiguous()) { KMessageBox::information(nullptr, // No widget to be seen around here i18n("The key sequence '%1' is ambiguous. Use 'Configure Keyboard Shortcuts'\n" "from the 'Settings' menu to solve the ambiguity.\n" "No action will be triggered.", se->key().toString(QKeySequence::NativeText)), i18nc("@title:window", "Ambiguous shortcut detected")); return true; } } return QObject::eventFilter(watched, event); } }; void _k_installConflictDetector() { QCoreApplication *app = QCoreApplication::instance(); app->installEventFilter(new KActionConflictDetector(app)); } Q_COREAPP_STARTUP_FUNCTION(_k_installConflictDetector) #include "kactionconflictdetector.moc"