Terminal: Support Ctrl+C/V on Windows

When a selection is present, let Ctrl+C work as copy
on Windows.

Remove sending ESC key in clearSelection as it interfered
with a Paste after copy.

Change-Id: I92db7f263e1eb433bca8aa5500fcecb637a23f90
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-08-31 10:50:08 +02:00
parent 95a3087a7b
commit 616a0c0f77
4 changed files with 29 additions and 20 deletions

View File

@@ -605,13 +605,21 @@ void TerminalWidget::initActions()
moveCursorWordRight.setText(Tr::tr("Move Cursor Word Right"));
close.setText(Tr::tr("Close Terminal"));
ActionManager::registerAction(&copy, Constants::COPY, context)
->setDefaultKeySequences({QKeySequence(
HostOsInfo::isMacHost() ? QLatin1String("Ctrl+C") : QLatin1String("Ctrl+Shift+C"))});
auto copyCmd = ActionManager::registerAction(&copy, Constants::COPY, context);
auto pasteCmd = ActionManager::registerAction(&paste, Constants::PASTE, context);
ActionManager::registerAction(&paste, Constants::PASTE, context)
->setDefaultKeySequences({QKeySequence(
HostOsInfo::isMacHost() ? QLatin1String("Ctrl+V") : QLatin1String("Ctrl+Shift+V"))});
if (HostOsInfo::isMacHost()) {
copyCmd->setDefaultKeySequence(QKeySequence(QLatin1String("Ctrl+C")));
pasteCmd->setDefaultKeySequence(QKeySequence(QLatin1String("Ctrl+V")));
} else if (HostOsInfo::isLinuxHost()) {
copyCmd->setDefaultKeySequence(QKeySequence(QLatin1String("Ctrl+Shift+C")));
pasteCmd->setDefaultKeySequence(QKeySequence(QLatin1String("Ctrl+Shift+V")));
} else if (HostOsInfo::isWindowsHost()) {
copyCmd->setDefaultKeySequences(
{QKeySequence(QLatin1String("Ctrl+C")), QKeySequence(QLatin1String("Ctrl+Shift+C"))});
pasteCmd->setDefaultKeySequences(
{QKeySequence(QLatin1String("Ctrl+V")), QKeySequence(QLatin1String("Ctrl+Shift+V"))});
}
ActionManager::registerAction(&clearSelection, Constants::CLEARSELECTION, context);