| 132 | } |
| 133 | |
| 134 | void ButtonRebindsFilter::loadConfig(const KConfigGroup &group) |
| 135 | { |
| 136 | Q_ASSERT(QLatin1StringView("ButtonRebinds") == group.name()); |
| 137 | if (m_inputDevice) { |
| 138 | KWin::input()->removeInputDevice(m_inputDevice.get()); |
| 139 | m_inputDevice.reset(); |
| 140 | } |
| 141 | KWin::input()->uninstallInputEventFilter(this); |
| 142 | for (auto &action : m_actions) { |
| 143 | action.clear(); |
| 144 | } |
| 145 | |
| 146 | bool foundActions = false; |
| 147 | |
| 148 | const auto mouseButtonEnum = QMetaEnum::fromType<Qt::MouseButtons>(); |
| 149 | const auto mouseGroup = group.group(QStringLiteral("Mouse")); |
| 150 | const auto mouseGroupKeys = mouseGroup.keyList(); |
| 151 | for (const QString &configKey : mouseGroupKeys) { |
| 152 | const int mappedButton = mouseButtonEnum.keyToValue(configKey.toLatin1()); |
| 153 | if (mappedButton != -1) { |
| 154 | const auto action = mouseGroup.readEntry(configKey, QStringList()); |
| 155 | insert(Pointer, {QString(), static_cast<uint>(mappedButton), 0}, action); |
| 156 | foundActions = true; |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | const auto tabletsGroup = group.group(QStringLiteral("Tablet")); |
| 161 | const auto tablets = tabletsGroup.groupList(); |
| 162 | for (const auto &tabletName : tablets) { |
| 163 | const auto tabletGroup = tabletsGroup.group(tabletName); |
| 164 | const auto tabletButtons = tabletGroup.keyList(); |
| 165 | for (const auto &buttonName : tabletButtons) { |
| 166 | const auto entry = tabletGroup.readEntry(buttonName, QStringList()); |
| 167 | bool ok = false; |
| 168 | const uint button = buttonName.toUInt(&ok); |
| 169 | if (ok) { |
| 170 | foundActions = true; |
| 171 | insert(TabletPad, {tabletName, button, 0}, entry); |
| 172 | } |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | const auto tabletToolsGroup = group.group(QStringLiteral("TabletTool")); |
| 177 | const auto tabletTools = tabletToolsGroup.groupList(); |
| 178 | for (const auto &tabletToolName : tabletTools) { |
| 179 | const auto toolGroup = tabletToolsGroup.group(tabletToolName); |
| 180 | const auto tabletToolButtons = toolGroup.keyList(); |
| 181 | for (const auto &buttonName : tabletToolButtons) { |
| 182 | const auto entry = toolGroup.readEntry(buttonName, QStringList()); |
| 183 | bool ok = false; |
| 184 | const uint button = buttonName.toUInt(&ok); |
| 185 | if (ok) { |
| 186 | foundActions = true; |
| 187 | insert(TabletToolButtonType, {tabletToolName, button, 0}, entry); |
| 188 | } |
| 189 | } |
| 190 | } |
| 191 |
nothing calls this directly
no test coverage detected