From 240686b7ea35e143589aa826f6930138dea982f3 Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Fri, 3 Mar 2023 09:12:12 +0100 Subject: [PATCH] Terminal: Start with disabled copy action The copy action should only be enabled once a selection exists. In the beginning no selection can exist, therefore the copy action is disabled. Previously this lead to a bug where only the second "Enter" keypress was passed on to the terminal. Change-Id: Iac01c273f70a50a4fc131bd6a2bbb1507705b853 Reviewed-by: Cristian Adam --- src/plugins/terminal/terminalwidget.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/plugins/terminal/terminalwidget.cpp b/src/plugins/terminal/terminalwidget.cpp index 58f370913a3..86af9fb4f11 100644 --- a/src/plugins/terminal/terminalwidget.cpp +++ b/src/plugins/terminal/terminalwidget.cpp @@ -79,12 +79,6 @@ TerminalWidget::TerminalWidget(QWidget *parent, const OpenTerminalParameters &op connect(&m_flushDelayTimer, &QTimer::timeout, this, [this]() { flushVTerm(true); }); - connect(&m_copyAction, &QAction::triggered, this, &TerminalWidget::copyToClipboard); - connect(&m_pasteAction, &QAction::triggered, this, &TerminalWidget::pasteFromClipboard); - connect(&m_clearSelectionAction, &QAction::triggered, this, &TerminalWidget::clearSelection); - connect(&m_zoomInAction, &QAction::triggered, this, &TerminalWidget::zoomIn); - connect(&m_zoomOutAction, &QAction::triggered, this, &TerminalWidget::zoomOut); - connect(&TerminalSettings::instance(), &AspectContainer::applied, this, [this] { m_layoutVersion++; // Setup colors first, as setupFont will redraw the screen. @@ -228,6 +222,7 @@ void TerminalWidget::setupColors() void TerminalWidget::setupActions() { + m_copyAction.setEnabled(false); m_copyAction.setShortcuts( {QKeySequence(HostOsInfo::isMacHost() ? QLatin1String("Ctrl+C") : QLatin1String("Ctrl+Shift+C")), @@ -240,6 +235,12 @@ void TerminalWidget::setupActions() m_zoomInAction.setShortcuts({QKeySequence("Ctrl++"), QKeySequence("Ctrl+Shift++")}); m_zoomOutAction.setShortcut(QKeySequence("Ctrl+-")); + connect(&m_copyAction, &QAction::triggered, this, &TerminalWidget::copyToClipboard); + connect(&m_pasteAction, &QAction::triggered, this, &TerminalWidget::pasteFromClipboard); + connect(&m_clearSelectionAction, &QAction::triggered, this, &TerminalWidget::clearSelection); + connect(&m_zoomInAction, &QAction::triggered, this, &TerminalWidget::zoomIn); + connect(&m_zoomOutAction, &QAction::triggered, this, &TerminalWidget::zoomOut); + addActions({&m_copyAction, &m_pasteAction, &m_clearSelectionAction, &m_zoomInAction, &m_zoomOutAction}); }