MCPcopy Create free account
hub / github.com/Zalafina/QKeyMapper / processSetVolumeMapping

Method processSetVolumeMapping

QKeyMapper/qkeymapper_worker.cpp:2040–2227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2038}
2039
2040void QKeyMapper_Worker::processSetVolumeMapping(const QString& volumeCommand)
2041{
2042 static QRegularExpression setvolume_regex(REGEX_PATTERN_SETVOLUME);
2043 QRegularExpressionMatch match = setvolume_regex.match(volumeCommand);
2044
2045 if (!match.hasMatch()) {
2046#ifdef DEBUG_LOGOUT_ON
2047 qDebug() << "[processSetVolumeMapping] Invalid SetVolume/SetMicVolume format:" << volumeCommand;
2048#endif
2049 return;
2050 }
2051
2052 if (!m_volumeController.isInitialized()) {
2053#ifdef DEBUG_LOGOUT_ON
2054 qDebug() << "[processSetVolumeMapping] Volume controller not initialized";
2055#endif
2056 return;
2057 }
2058
2059 // Parse capture groups
2060 QString deviceTypeStr = match.captured(1); // Optional 'Mic' for capture device
2061 bool notify = !match.captured(2).isEmpty(); // Optional notify icon (🔊 or 🎤)
2062 QString sign = match.captured(3); // Optional +/- sign
2063 QString valueStr = match.captured(4); // Numeric value or Mute/MuteOn/MuteOff
2064
2065 // Determine device type
2066 int deviceType = deviceTypeStr.isEmpty() ? VOLUME_DEVICE_TYPE_PLAYBACK : VOLUME_DEVICE_TYPE_CAPTURE;
2067
2068 // Determine operation type
2069 int operationType = VOLUME_OPERATION_SET;
2070 float value = 0.0f;
2071
2072 if (valueStr == "Mute") {
2073 operationType = VOLUME_OPERATION_MUTE_TOGGLE;
2074 }
2075 else if (valueStr == "MuteOn") {
2076 operationType = VOLUME_OPERATION_MUTE_ON;
2077 }
2078 else if (valueStr == "MuteOff") {
2079 operationType = VOLUME_OPERATION_MUTE_OFF;
2080 }
2081 else {
2082 // Numeric value operation
2083 bool ok;
2084 value = valueStr.toFloat(&ok);
2085 if (!ok) {
2086#ifdef DEBUG_LOGOUT_ON
2087 qDebug() << "[processSetVolumeMapping] Invalid numeric value:" << valueStr;
2088#endif
2089 return;
2090 }
2091
2092 if (sign == "+") {
2093 operationType = VOLUME_OPERATION_INCREASE;
2094 } else if (sign == "-") {
2095 operationType = VOLUME_OPERATION_DECREASE;
2096 value = -value; // Make value negative for decrease
2097 }

Callers

nothing calls this directly

Calls 7

isInitializedMethod · 0.80
isEmptyMethod · 0.80
setVolumeMethod · 0.80
getCurrentVolumeMethod · 0.80
adjustVolumeMethod · 0.80
isMutedMethod · 0.80
setMuteMethod · 0.80

Tested by

no test coverage detected