diff --git a/src/res/qml/utilities_page/keyboard_utils/KeyboardGroupBox.qml b/src/res/qml/utilities_page/keyboard_utils/KeyboardGroupBox.qml index 58271db..4115ac1 100644 --- a/src/res/qml/utilities_page/keyboard_utils/KeyboardGroupBox.qml +++ b/src/res/qml/utilities_page/keyboard_utils/KeyboardGroupBox.qml @@ -93,6 +93,30 @@ GroupBox { } } } + RowLayout { + spacing: 18 + Layout.fillWidth: true + + MyPushButton { + text: "Ctrl-C" + Layout.preferredWidth: 150 + onClicked: { + UtilitiesTabController.sendKeyboardCtrlC() + } + } + + MyPushButton { + text: "Ctrl-V" + Layout.preferredWidth: 150 + onClicked: { + UtilitiesTabController.sendKeyboardCtrlV() + } + } + + Item { + Layout.fillWidth: true + } + } } Component.onCompleted: { keyboardGroupBox.visible = !OverlayController.desktopMode diff --git a/src/tabcontrollers/UtilitiesTabController.cpp b/src/tabcontrollers/UtilitiesTabController.cpp index 6b70ea4..5efe422 100644 --- a/src/tabcontrollers/UtilitiesTabController.cpp +++ b/src/tabcontrollers/UtilitiesTabController.cpp @@ -49,6 +49,16 @@ void UtilitiesTabController::sendKeyboardAltTab() keyboardinput::sendKeyboardAltTab(); } +void UtilitiesTabController::sendKeyboardCtrlC() +{ + keyboardinput::sendKeyboardCtrlC(); +} + +void UtilitiesTabController::sendKeyboardCtrlV() +{ + keyboardinput::sendKeyboardCtrlV(); +} + void UtilitiesTabController::sendKeyboardBackspace( const int count ) { keyboardinput::sendKeyboardBackspace( count ); diff --git a/src/tabcontrollers/UtilitiesTabController.h b/src/tabcontrollers/UtilitiesTabController.h index e97cb60..0a34a00 100644 --- a/src/tabcontrollers/UtilitiesTabController.h +++ b/src/tabcontrollers/UtilitiesTabController.h @@ -58,6 +58,8 @@ public slots: void sendKeyboardEnter(); void sendKeyboardAltTab(); void sendKeyboardAltEnter(); + void sendKeyboardCtrlC(); + void sendKeyboardCtrlV(); void sendKeyboardBackspace( const int count ); void sendMediaNextSong(); void sendMediaPreviousSong(); diff --git a/src/tabcontrollers/keyboardinput/KeyboardInput.h b/src/tabcontrollers/keyboardinput/KeyboardInput.h index d1bff88..98974d8 100644 --- a/src/tabcontrollers/keyboardinput/KeyboardInput.h +++ b/src/tabcontrollers/keyboardinput/KeyboardInput.h @@ -10,6 +10,8 @@ void sendKeyboardEnter(); void sendKeyboardBackspace( const int count ); void sendKeyboardAltTab(); void sendKeyboardAltEnter(); +void sendKeyboardCtrlC(); +void sendKeyboardCtrlV(); void sendMediaNextSong(); void sendMediaPreviousSong(); void sendMediaPausePlay(); diff --git a/src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp b/src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp index 8bfa9bb..010a257 100644 --- a/src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp +++ b/src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp @@ -33,6 +33,16 @@ void sendKeyboardAltEnter() // noop } +void sendKeyboardCtrlC() +{ + // noop +} + +void sendKeyboardCtrlV() +{ + // noop +} + void sendMediaNextSong() { // noop diff --git a/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp b/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp index 586bef5..482fafe 100644 --- a/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp +++ b/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp @@ -274,6 +274,52 @@ void sendKeyboardAltEnter() sendKeyboardInputRaw( numberOfActions, actions ); } +/*! +Sends a Ctrl + C combination to Windows. + +Used for copy in copy-paste operations. +*/ +void sendKeyboardCtrlC() +{ + constexpr auto ctrlKey = VK_CONTROL; + constexpr auto cKey = 0x43; + + const auto pressCtrl = createInputStruct( ctrlKey, KeyStatus::Down ); + const auto pressC = createInputStruct( cKey, KeyStatus::Down ); + const auto releaseC = createInputStruct( cKey, KeyStatus::Up ); + const auto releaseCtrl = createInputStruct( ctrlKey, KeyStatus::Up ); + + constexpr auto numberOfActions = 4; + + INPUT actions[numberOfActions] + = { pressCtrl, pressC, releaseC, releaseCtrl }; + + sendKeyboardInputRaw( numberOfActions, actions ); +} + +/*! +Sends a Ctrl + V combination to Windows. + +Used for paste in copy-paste operations. +*/ +void sendKeyboardCtrlV() +{ + constexpr auto ctrlKey = VK_CONTROL; + constexpr auto vKey = 0x56; + + const auto pressCtrl = createInputStruct( ctrlKey, KeyStatus::Down ); + const auto pressV = createInputStruct( vKey, KeyStatus::Down ); + const auto releaseV = createInputStruct( vKey, KeyStatus::Up ); + const auto releaseCtrl = createInputStruct( ctrlKey, KeyStatus::Up ); + + constexpr auto numberOfActions = 4; + + INPUT actions[numberOfActions] + = { pressCtrl, pressV, releaseV, releaseCtrl }; + + sendKeyboardInputRaw( numberOfActions, actions ); +} + /*! Sends a media key Next Song button to Windows. */