[network/kdeconnect-kde/release/26.08] /: Remote keyboard: Support sending meta
Albert Vaca Cintora <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 873abd6bb9763e1e0abea98715ca91769ba352b2 by Albert Vaca Cintora.
Committed on 13/08/2026 at 20:09.
Pushed by albertvaka into branch 'release/26.08'.
Remote keyboard: Support sending meta
(cherry picked from commit 4d11a9e8ea667b3eae5d4e09bdb3a103bbe15f0d)
M +1 -1 cli/kdeconnect-cli.cpp
M +2 -2 declarativeplugin/qml/RemoteKeyboard.qml
M +7 -5 plugins/remotekeyboard/remotekeyboardplugin.cpp
M +8 -2 plugins/remotekeyboard/remotekeyboardplugin.h
https://invent.kde.org/network/kdeconnect-kde/-/commit/873abd6bb9763e1e0abea98715ca91769ba352b2
diff --git a/cli/kdeconnect-cli.cpp b/cli/kdeconnect-cli.cpp
index 213a7c008..52224b949 100644
--- a/cli/kdeconnect-cli.cpp
+++ b/cli/kdeconnect-cli.cpp
@@ -395,7 +395,7 @@ int main(int argc, char **argv)
if (in.open(stdin, QIODevice::ReadOnly | QIODevice::Unbuffered)) {
while (!in.atEnd()) {
QByteArray line = in.readLine(); // sanitize to ASCII-codes > 31?
- msg.setArguments({QString::fromLatin1(line), -1, false, false, false});
+ msg.setArguments({QString::fromLatin1(line), -1, false, false, false, false});
blockOnReply(QDBusConnection::sessionBus().asyncCall(msg));
}
in.close();
diff --git a/declarativeplugin/qml/RemoteKeyboard.qml b/declarativeplugin/qml/RemoteKeyboard.qml
index 737195029..696d038be 100644
--- a/declarativeplugin/qml/RemoteKeyboard.qml
+++ b/declarativeplugin/qml/RemoteKeyboard.qml
@@ -32,7 +32,7 @@ QQC2.TextField {
Connections {
target: root.remoteKeyboard
- function onKeyPressReceived(key: string, specialKey: int, shift: bool, ctrl: bool, alt: bool): void {
+ function onKeyPressReceived(key: string, specialKey: int, shift: bool, ctrl: bool, alt: bool, meta: bool): void {
//console.log("XXX received keypress key=" + key + " special=" + specialKey + " shift=" + shift + " ctrl=" + ctrl + " text=" + text + " cursorPos=" + cursorPosition);
// interpret some special keys:
if (specialKey === 12 || specialKey === 14) { // Return/Esc -> clear
@@ -69,7 +69,7 @@ QQC2.TextField {
sanitized += key.charAt(i);
}
}
- if (sanitized.length > 0 && !ctrl && !alt) {
+ if (sanitized.length > 0 && !ctrl && !alt && !meta) {
// insert sanitized at current pos:
const pos = cursorPosition;
text = text.substring(0, pos)
diff --git a/plugins/remotekeyboard/remotekeyboardplugin.cpp b/plugins/remotekeyboard/remotekeyboardplugin.cpp
index d0d6a631f..00131f5bf 100644
--- a/plugins/remotekeyboard/remotekeyboardplugin.cpp
+++ b/plugins/remotekeyboard/remotekeyboardplugin.cpp
@@ -68,9 +68,10 @@ void RemoteKeyboardPlugin::receivePacket(const NetworkPacket &np)
// qCWarning(KDECONNECT_PLUGIN_REMOTEKEYBOARD) << "Received keypress" << np;
Q_EMIT keyPressReceived(np.get<QString>(QStringLiteral("key")),
np.get<int>(QStringLiteral("specialKey"), 0),
- np.get<int>(QStringLiteral("shift"), false),
- np.get<int>(QStringLiteral("ctrl"), false),
- np.get<int>(QStringLiteral("alt"), 0));
+ np.get<bool>(QStringLiteral("shift"), false),
+ np.get<bool>(QStringLiteral("ctrl"), false),
+ np.get<bool>(QStringLiteral("alt"), false),
+ np.get<bool>(QStringLiteral("super"), false));
} else if (np.type() == PACKET_TYPE_MOUSEPAD_KEYBOARDSTATE) {
// qCWarning(KDECONNECT_PLUGIN_REMOTEKEYBOARD) << "Received keyboardstate" << np;
if (m_remoteState != np.get<bool>(QStringLiteral("state"))) {
@@ -80,7 +81,7 @@ void RemoteKeyboardPlugin::receivePacket(const NetworkPacket &np)
}
}
-void RemoteKeyboardPlugin::sendKeyPress(const QString &key, int specialKey, bool shift, bool ctrl, bool alt, bool sendAck) const
+void RemoteKeyboardPlugin::sendKeyPress(const QString &key, int specialKey, bool shift, bool ctrl, bool alt, bool super, bool sendAck) const
{
NetworkPacket np(PACKET_TYPE_MOUSEPAD_REQUEST,
{{QStringLiteral("key"), key},
@@ -88,6 +89,7 @@ void RemoteKeyboardPlugin::sendKeyPress(const QString &key, int specialKey, bool
{QStringLiteral("shift"), shift},
{QStringLiteral("ctrl"), ctrl},
{QStringLiteral("alt"), alt},
+ {QStringLiteral("super"), super},
{QStringLiteral("sendAck"), sendAck}});
sendPacket(np);
}
@@ -110,7 +112,7 @@ void RemoteKeyboardPlugin::sendQKeyEvent(const QVariantMap &keyEvent, bool sendA
text = QKeySequence(key).toString().toLower();
}
- sendKeyPress(text, k, modifiers & Qt::ShiftModifier, modifiers & Qt::ControlModifier, modifiers & Qt::AltModifier, sendAck);
+ sendKeyPress(text, k, modifiers & Qt::ShiftModifier, modifiers & Qt::ControlModifier, modifiers & Qt::AltModifier, modifiers & Qt::MetaModifier, sendAck);
}
int RemoteKeyboardPlugin::translateQtKey(int qtKey) const
diff --git a/plugins/remotekeyboard/remotekeyboardplugin.h b/plugins/remotekeyboard/remotekeyboardplugin.h
index c53dee6bb..bbb3ef09d 100644
--- a/plugins/remotekeyboard/remotekeyboardplugin.h
+++ b/plugins/remotekeyboard/remotekeyboardplugin.h
@@ -36,11 +36,17 @@ public:
return m_remoteState;
}
- Q_SCRIPTABLE void sendKeyPress(const QString &key, int specialKey = 0, bool shift = false, bool ctrl = false, bool alt = false, bool sendAck = true) const;
+ Q_SCRIPTABLE void sendKeyPress(const QString &key,
+ int specialKey = 0,
+ bool shift = false,
+ bool ctrl = false,
+ bool alt = false,
+ bool super = false,
+ bool sendAck = true) const;
Q_SCRIPTABLE void sendQKeyEvent(const QVariantMap &keyEvent, bool sendAck = true) const;
Q_SCRIPTABLE int translateQtKey(int qtKey) const;
Q_SIGNALS:
- Q_SCRIPTABLE void keyPressReceived(const QString &key, int specialKey = 0, bool shift = false, bool ctrl = false, bool alt = false);
+ Q_SCRIPTABLE void keyPressReceived(const QString &key, int specialKey = 0, bool shift = false, bool ctrl = false, bool alt = false, bool super = false);
Q_SCRIPTABLE void remoteStateChanged(bool state);
};