Commit c191821b authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Fix clazy warnings in keyboard KCM

parent 4e2f4a67
......@@ -103,7 +103,7 @@ void PreviewPluginsModel::setCheckedPlugins(const QStringList &list)
m_checkedRows = QVector<bool>(m_plugins.size(), false);
for (const QString &name : plugins) {
for (const QString &name : qAsConst(plugins)) {
const int row = indexOfPlugin(name);
if (row != -1) {
m_checkedRows[row] = true;
......
......@@ -130,7 +130,7 @@ static QString keySymToString(KeySym keysym) {
if (static_cast<KeySym>(xkbKeysym) == keysym) {
str = xkbKeysymToUtf8(xkbKeysym);
for (const auto &c : str) {
for (const auto &c : qAsConst(str)) {
if (!c.isPrint() && !c.isNull()) {
str = "";
break;
......
......@@ -351,11 +351,11 @@ bool XEventNotifier::processXkbEvents(xcb_generic_event_t* event)
_xkb_event *xkbevt = reinterpret_cast<_xkb_event *>(event);
if( XEventNotifier::isGroupSwitchEvent(xkbevt) ) {
// qDebug() << "group switch event";
emit(layoutChanged());
Q_EMIT emit(layoutChanged());
}
else if( XEventNotifier::isLayoutSwitchEvent(xkbevt) ) {
// qDebug() << "layout switch event";
emit(layoutMapChanged());
Q_EMIT emit(layoutMapChanged());
}
return true;
}
......
......@@ -80,11 +80,11 @@ bool XInputEventNotifier::processOtherEvents(xcb_generic_event_t* event)
{
int newDeviceType = getNewDeviceEventType(event);
if( newDeviceType == DEVICE_KEYBOARD ) {
emit(newKeyboardDevice());
Q_EMIT emit(newKeyboardDevice());
}
else if( newDeviceType == DEVICE_POINTER ) {
emit(newPointerDevice());
emit(newKeyboardDevice()); // arghhh, looks like X resets xkb map even when only pointer device is connected
Q_EMIT emit(newPointerDevice());
Q_EMIT emit(newKeyboardDevice()); // arghhh, looks like X resets xkb map even when only pointer device is connected
}
return true;
}
......
......@@ -191,7 +191,7 @@ void GlobalAccelModel::save()
void GlobalAccelModel::exportToConfig(const KConfigBase &config)
{
for (const auto& component : m_components) {
for (const auto& component : qAsConst(m_components)) {
if (component.checked) {
KConfigGroup mainGroup(&config, component.id);
KConfigGroup group(&mainGroup, "Global Shortcuts");
......@@ -205,7 +205,8 @@ void GlobalAccelModel::exportToConfig(const KConfigBase &config)
void GlobalAccelModel::importConfig(const KConfigBase &config)
{
for (const auto componentGroupName : config.groupList()) {
const auto groupList = config.groupList();
for (const auto &componentGroupName : groupList) {
auto component = std::find_if(m_components.begin(), m_components.end(), [&] (const Component &c) {
return c.id == componentGroupName;
});
......@@ -219,7 +220,8 @@ void GlobalAccelModel::importConfig(const KConfigBase &config)
continue;
}
KConfigGroup shortcutsGroup(&componentGroup, "Global Shortcuts");
for (const auto& key : shortcutsGroup.keyList()) {
const QStringList keys = shortcutsGroup.keyList();
for (const auto& key : keys) {
auto action = std::find_if(component->actions.begin(), component->actions.end(), [&] (const Action &a) {
return a.id == key;
});
......@@ -268,10 +270,10 @@ void GlobalAccelModel::addApplication(const QString &desktopFileName, const QStr
return;
}
qCDebug(KCMKEYS) << "inserting at " << pos - m_components.begin();
emit beginInsertRows(QModelIndex(), pos - m_components.begin(), pos - m_components.begin());
beginInsertRows(QModelIndex(), pos - m_components.begin(), pos - m_components.begin());
auto c = loadComponent(infoReply.value());
m_components.insert(pos, c);
emit endInsertRows();
endInsertRows();
});
});
}
......
......@@ -237,6 +237,7 @@ void KCMKeys::requestKeySequence(QQuickItem *context, const QModelIndex &index,
: i18n("Shortcut %1 is already assigned to action '%2' of %3.\nDo you want to reassign it?", keysString, actionName, componentName);
const QString title = i18nc("@title:window", "Found conflict");
auto dialog = new QDialog;
dialog->setWindowTitle(title);
if (context && context->window()) {
dialog->winId(); // so it creates windowHandle
dialog->windowHandle()->setTransientParent(QQuickRenderControl::renderWindowFor(context->window()));
......@@ -247,7 +248,7 @@ void KCMKeys::requestKeySequence(QQuickItem *context, const QModelIndex &index,
QMessageBox::Question, message, {}, QString(), nullptr, KMessageBox::NoExec);
dialog->show();
connect(dialog, &QDialog::finished, this, [this, index, conflict, newSequence, oldSequence] (int result) {
connect(dialog, &QDialog::finished, this, [index, conflict, newSequence, oldSequence] (int result) {
auto model = const_cast<BaseModel*>(static_cast<const BaseModel*>(index.model()));
if (result != QDialogButtonBox::Yes) {
// Also emit if we are not changing anything, to force the frontend to update and be consistent
......
......@@ -32,6 +32,8 @@ constexpr int dbusTimeout = 5; //milliseconds
KeysData::KeysData(QObject *parent, const QVariantList &args)
{
Q_UNUSED(parent)
Q_UNUSED(args)
}
bool KeysData::isDefaults() const
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment