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

Method updateMappingKeyKeyUp

QKeyMapper/qitemsetupdialog.cpp:3343–3419  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3341}
3342
3343bool QItemSetupDialog::updateMappingKeyKeyUp(QString &mappingKey, const QString &originalKey, int rowindex)
3344{
3345 static QRegularExpression simplified_regex(R"([\r\n]+)");
3346 static QRegularExpression whitespace_reg(R"(\s+)");
3347 static QRegularExpression sendtext_regex(REGEX_PATTERN_SENDTEXT_FIND, QRegularExpression::MultilineOption);
3348 static QRegularExpression run_regex(REGEX_PATTERN_RUN_FIND);
3349 static QRegularExpression switchtab_regex(REGEX_PATTERN_SWITCHTAB_FIND);
3350 static QRegularExpression keysequencebreak_regex(REGEX_PATTERN_KEYSEQUENCEBREAK_FIND);
3351 static QRegularExpression keysequencetoggle_regex(REGEX_PATTERN_KEYSEQUENCETOGGLE_FIND);
3352 static QRegularExpression keysequencepause_regex(REGEX_PATTERN_KEYSEQUENCEPAUSE_FIND);
3353 static QRegularExpression keysequencecontinue_regex(REGEX_PATTERN_KEYSEQUENCECONTINUE_FIND);
3354 static QRegularExpression unlock_regex(REGEX_PATTERN_UNLOCK_FIND);
3355 static QRegularExpression showfbutton_regex(REGEX_PATTERN_SHOWFBUTTON_FIND);
3356 static QRegularExpression hidefbutton_regex(REGEX_PATTERN_HIDEFBUTTON_FIND);
3357 static QRegularExpression repeat_regex(REGEX_PATTERN_REPEAT_FIND);
3358 static QRegularExpression onlyonce_regex(REGEX_PATTERN_ONLYONCE_FIND);
3359 static QRegularExpression macro_regex(REGEX_PATTERN_MACRO_FIND);
3360
3361 // Extract SendText(...), Run(...), SwitchTab(...), KeySequence controls, Unlock(...), ShowFButton(...), HideFButton(...), SetVolume(...), Repeat{...}x..., and Macro(...) content to preserve them
3362 QPair<QString, QStringList> extractResult = extractSpecialPatternsWithBracketBalancing(
3363 mappingKey,
3364 sendtext_regex,
3365 run_regex,
3366 switchtab_regex,
3367 keysequencebreak_regex,
3368 keysequencetoggle_regex,
3369 keysequencepause_regex,
3370 keysequencecontinue_regex,
3371 unlock_regex,
3372 showfbutton_regex,
3373 hidefbutton_regex,
3374 QRegularExpression(),
3375 repeat_regex,
3376 onlyonce_regex,
3377 macro_regex
3378 );
3379 QString tempMappingKey = extractResult.first;
3380 QStringList preservedParts = extractResult.second;
3381
3382 tempMappingKey.replace(simplified_regex, " ");
3383 // Remove whitespace from the temporary string (excluding Run and SendText content)
3384 tempMappingKey.remove(whitespace_reg);
3385
3386 // Restore all preserved parts
3387 for (int i = 0; i < preservedParts.size(); ++i) {
3388 QString placeholder = QString("__PRESERVED_PLACEHOLDER_%1__").arg(i);
3389 tempMappingKey.replace(placeholder, preservedParts[i]);
3390 }
3391
3392 mappingKey = tempMappingKey;
3393
3394#ifdef DEBUG_LOGOUT_ON
3395 qDebug().nospace().noquote() << "[" << __func__ << "] KeyUp MappingKeyText after preserving Run(...) and SendText(...) and removing whitespace -> " << mappingKey;
3396#endif
3397
3398 ValidationResult result;
3399 if (mappingKey.isEmpty()) {
3400 result.isValid = true;

Callers

nothing calls this directly

Calls 4

splitMappingKeyStringFunction · 0.85
removeMethod · 0.80
sizeMethod · 0.80
isEmptyMethod · 0.80

Tested by

no test coverage detected