Terminal: Add context menu & Settings button

Fixes: QTCREATORBUG-28937
Change-Id: I9dab5da0adccb8cff4d4e824ead0eba3e27eef5c
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-03-23 12:28:44 +01:00
parent a485f18a94
commit af809b3a52
5 changed files with 32 additions and 3 deletions

View File

@@ -26,6 +26,7 @@
#include <QElapsedTimer>
#include <QGlyphRun>
#include <QLoggingCategory>
#include <QMenu>
#include <QPaintEvent>
#include <QPainter>
#include <QPainterPath>
@@ -232,6 +233,7 @@ void TerminalWidget::setupActions()
connect(&a.copy, &QAction::triggered, this, ifHasFocus(&TerminalWidget::copyToClipboard));
connect(&a.paste, &QAction::triggered, this, ifHasFocus(&TerminalWidget::pasteFromClipboard));
connect(&a.clearSelection, &QAction::triggered, this, ifHasFocus(&TerminalWidget::clearSelection));
connect(&a.clearTerminal, &QAction::triggered, this, ifHasFocus(&TerminalWidget::clearContents));
// clang-format on
}
@@ -1078,7 +1080,17 @@ void TerminalWidget::mousePressEvent(QMouseEvent *event)
event->accept();
updateViewport();
} else if (event->button() == Qt::RightButton) {
if (m_selection) {
if (event->modifiers() == Qt::ShiftModifier) {
QMenu *contextMenu = new QMenu(this);
contextMenu->addAction(&TerminalCommands::widgetActions().copy);
contextMenu->addAction(&TerminalCommands::widgetActions().paste);
contextMenu->addSeparator();
contextMenu->addAction(&TerminalCommands::widgetActions().clearTerminal);
contextMenu->addSeparator();
contextMenu->addAction(TerminalCommands::openSettingsAction());
contextMenu->popup(event->globalPos());
} else if (m_selection) {
copyToClipboard();
setSelection(std::nullopt);
} else {