70 {
73
75
76 if (!windowActionCollection) {
77 qWarning() << "We haven't got an action collection";
78 return;
79 }
80
82
83 QMap<QKeySequence, QStringList> shortcutMap;
84
85
86
87 Q_FOREACH(QAction *action, windowActionCollection->
actions()) {
88
89 if (action->property("tool_action").isValid()) {
90 QStringList tools = action->property(
"tool_action").toStringList();
91
93
94 action->setEnabled(true);
96 }
97 else {
98 if (tools.contains(
activeToolId) || action->property(
"always_enabled").toBool()) {
99
100 action->setEnabled(true);
102 }
103 else {
104
105 action->setDisabled(true);
106 }
107 }
108 }
109 else {
110 globalActions << action->objectName();
111 }
112
113 Q_FOREACH(QKeySequence keySequence, action->shortcuts()) {
114
115 if (keySequence.toString() != "") {
116 if (shortcutMap.contains(keySequence)) {
117 shortcutMap[keySequence].append(action->objectName());
118 }
119 else {
120 shortcutMap[keySequence] =
QStringList() << action->objectName();
121 }
122 }
123 }
124 }
125
126
127 Q_FOREACH(const QKeySequence &k, shortcutMap.keys()) {
128 if (shortcutMap[k].
size() > 1) {
130
131 bool toolActionFound = false;
132 Q_FOREACH(const QString &action, actions) {
134 toolActionFound = true;
135 }
136 }
137 Q_FOREACH(const QString &action, actions) {
138 if (toolActionFound && globalActions.contains(action)) {
139
140 windowActionCollection->
action(action)->setEnabled(
false);
142 }
143 }
144
145 }
146 }
147
149 }
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)