76 {
79
81
82 if (!windowActionCollection) {
83 qWarning() << "We haven't got an action collection";
84 return;
85 }
86
88
89 QMap<QKeySequence, QStringList> shortcutMap;
90
91
92
93 Q_FOREACH(QAction *action, windowActionCollection->
actions()) {
94
95 if (action->property("tool_action").isValid()) {
96 QStringList tools = action->property(
"tool_action").toStringList();
97
99
100 action->setEnabled(true);
102 }
103 else {
104 if (tools.contains(
activeToolId) || action->property(
"always_enabled").toBool()) {
105
106 action->setEnabled(true);
108 }
109 else {
110
111 action->setDisabled(true);
112 }
113 }
114 }
115 else {
116 globalActions << action->objectName();
117 }
118
119 Q_FOREACH(QKeySequence keySequence, action->shortcuts()) {
120
121 if (keySequence.toString() != "") {
122 if (shortcutMap.contains(keySequence)) {
123 shortcutMap[keySequence].append(action->objectName());
124 }
125 else {
126 shortcutMap[keySequence] =
QStringList() << action->objectName();
127 }
128 }
129 }
130 }
131
132
133 Q_FOREACH(const QKeySequence &k, shortcutMap.keys()) {
134 if (shortcutMap[k].
size() > 1) {
136
137 bool toolActionFound = false;
138 Q_FOREACH(const QString &action, actions) {
140 toolActionFound = true;
141 }
142 }
143 Q_FOREACH(const QString &action, actions) {
144 if (toolActionFound && globalActions.contains(action)) {
145
146 windowActionCollection->
action(action)->setEnabled(
false);
148 }
149 }
150
151 }
152 }
153
155 }
QList< QString > QStringList
QStringList disabledGlobalActions
A container for a set of QAction objects.
QAction * action(int index) const
QList< QAction * > actions() const
KisKActionCollection * actionCollection
int size(const Forest< T > &forest)