File indexing completed on 2024-03-03 05:48:30

0001 /*
0002     SPDX-FileCopyrightText: 2014-2015 Harald Sitter <sitter@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #include "globalactioncollection.h"
0008 
0009 #include <KGlobalAccel>
0010 
0011 GlobalAction::GlobalAction(QObject *parent)
0012     : QAction(parent)
0013 {
0014 }
0015 
0016 GlobalActionCollection::GlobalActionCollection() = default;
0017 
0018 QString GlobalActionCollection::name() const
0019 {
0020     return m_name;
0021 }
0022 
0023 void GlobalActionCollection::setName(const QString &name)
0024 {
0025     m_name = name;
0026     Q_EMIT nameChanged();
0027 }
0028 
0029 QString GlobalActionCollection::displayName() const
0030 {
0031     return m_displayName;
0032 }
0033 
0034 void GlobalActionCollection::setDisplayName(const QString &displayName)
0035 {
0036     m_displayName = displayName;
0037     Q_EMIT displayNameChanged();
0038 }
0039 
0040 void GlobalActionCollection::componentComplete()
0041 {
0042     const auto childs{children()};
0043     for (QObject *item : childs) {
0044         auto *action = qobject_cast<GlobalAction *>(item);
0045         if (!action) {
0046             continue;
0047         }
0048         action->setProperty("componentName", m_name);
0049         action->setProperty("componentDisplayName", m_displayName);
0050 
0051         KGlobalAccel::setGlobalShortcut(action, action->shortcuts());
0052     }
0053 
0054     QQuickItem::componentComplete();
0055 }