|
31 | 31 | #include <libinputactions/actions/CommandAction.h> |
32 | 32 | #include <libinputactions/actions/InputAction.h> |
33 | 33 | #include <libinputactions/actions/PlasmaGlobalShortcutAction.h> |
| 34 | +#include <libinputactions/actions/ReplaceTextAction.h> |
34 | 35 | #include <libinputactions/actions/SleepAction.h> |
35 | 36 | #include <libinputactions/actions/TriggerAction.h> |
| 37 | +#include <libinputactions/conditions/CanReplaceTextCondition.h> |
36 | 38 | #include <libinputactions/conditions/ConditionGroup.h> |
37 | 39 | #include <libinputactions/conditions/VariableCondition.h> |
38 | 40 | #include <libinputactions/config/ConfigIssue.h> |
@@ -154,6 +156,8 @@ void NodeParser<std::unique_ptr<Action>>::parse(const Node *node, std::unique_pt |
154 | 156 | } else if (const auto *plasmaShortcutNode = node->at("plasma_shortcut")) { |
155 | 157 | const auto shortcut = parseSeparatedString2<QString>(plasmaShortcutNode, ','); |
156 | 158 | result = std::make_unique<PlasmaGlobalShortcutAction>(shortcut.first, shortcut.second); |
| 159 | + } else if (const auto *replaceTextNode = node->at("replace_text")) { |
| 160 | + result = std::make_unique<ReplaceTextAction>(replaceTextNode->as<std::vector<TextSubstitutionRule>>(true)); |
157 | 161 | } else if (const auto *sleepActionNode = node->at("sleep")) { |
158 | 162 | result = std::make_unique<SleepAction>(sleepActionNode->as<std::chrono::milliseconds>()); |
159 | 163 | } else if (const auto *oneNode = node->at("one")) { |
@@ -218,6 +222,10 @@ std::shared_ptr<Condition> parseCondition(const Node *node, const VariableManage |
218 | 222 | return group; |
219 | 223 | } |
220 | 224 |
|
| 225 | + if (const auto *canReplaceTextNode = node->at("can_replace_text")) { |
| 226 | + return std::make_shared<CanReplaceTextCondition>(canReplaceTextNode->as<std::vector<TextSubstitutionRule>>(true)); |
| 227 | + } |
| 228 | + |
221 | 229 | if (isLegacy(node)) { |
222 | 230 | g_configIssueManager->addIssue(DeprecatedFeatureConfigIssue(node, DeprecatedFeature::LegacyConditions)); |
223 | 231 |
|
@@ -576,6 +584,14 @@ struct NodeParser<Range<T>> |
576 | 584 | }; |
577 | 585 | template struct NodeParser<Range<qreal>>; |
578 | 586 |
|
| 587 | +template<> |
| 588 | +void NodeParser<TextSubstitutionRule>::parse(const Node *node, TextSubstitutionRule &result) |
| 589 | +{ |
| 590 | + const auto regex = node->at("regex", true)->as<QRegularExpression>(); |
| 591 | + const auto newText = node->at("replace", true)->as<QString>(); |
| 592 | + result = {regex, newText}; |
| 593 | +} |
| 594 | + |
579 | 595 | template<> |
580 | 596 | void NodeParser<std::unique_ptr<TriggerAction>>::parse(const Node *node, std::unique_ptr<TriggerAction> &result) |
581 | 597 | { |
|
0 commit comments