File indexing completed on 2024-12-22 04:12:39
0001 /* 0002 * SPDX-FileCopyrightText: 2012 Dmitry Kazakov <dimula73@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "kis_abstract_shortcut.h" 0008 0009 #include "kis_abstract_input_action.h" 0010 0011 0012 class Q_DECL_HIDDEN KisAbstractShortcut::Private 0013 { 0014 public: 0015 KisAbstractInputAction *action; 0016 int shortcutIndex; 0017 }; 0018 0019 KisAbstractShortcut::KisAbstractShortcut(KisAbstractInputAction *action, int index) 0020 : m_d(new Private) 0021 { 0022 m_d->action = action; 0023 m_d->shortcutIndex = index; 0024 } 0025 0026 KisAbstractShortcut::~KisAbstractShortcut() 0027 { 0028 delete m_d; 0029 } 0030 0031 KisAbstractInputAction* KisAbstractShortcut::action() const 0032 { 0033 return m_d->action; 0034 } 0035 0036 void KisAbstractShortcut::setAction(KisAbstractInputAction* action) 0037 { 0038 m_d->action = action; 0039 } 0040 0041 int KisAbstractShortcut::shortcutIndex() const 0042 { 0043 return m_d->shortcutIndex; 0044 } 0045 0046 bool KisAbstractShortcut::compareKeys(const QSet<Qt::Key> &keys1, 0047 const QSet<Qt::Key> &keys2) 0048 { 0049 if (keys1.size() != keys2.size()) return false; 0050 0051 Q_FOREACH (Qt::Key key, keys1) { 0052 if (!keys2.contains(key)) return false; 0053 } 0054 return true; 0055 } 0056 0057 bool KisAbstractShortcut::isAvailable(KisInputActionGroupsMask groupMask) const 0058 { 0059 return 0060 (action()->inputActionGroup(m_d->shortcutIndex) & groupMask) && 0061 action()->isAvailable(); 0062 }