Terminal: Use new ActionBuilder syntax

Change-Id: I1d739ca80f41073a55755816468c47f743838f81
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
hjk
2023-12-20 18:04:44 +01:00
parent f2cb979aa3
commit 58396a5da1

View File

@@ -228,44 +228,43 @@ void TerminalPane::initActions()
{
using namespace Constants;
ActionBuilder newTerminalAction(this, NEWTERMINAL);
newTerminalAction.setText(Tr::tr("New Terminal"));
newTerminalAction.setIcon(NEW_TERMINAL_ICON.icon());
newTerminalAction.setToolTip(Tr::tr("Create a new Terminal."));
newTerminalAction.setContext(m_selfContext);
newTerminalAction.setDefaultKeySequences({QKeySequence(
HostOsInfo::isMacHost() ? QLatin1String("Ctrl+T") : QLatin1String("Ctrl+Shift+T"))});
newTerminalAction.addOnTriggered(this, [this] { openTerminal({}); });
m_newTerminalAction = newTerminalAction.commandAction();
ActionBuilder(this, NEWTERMINAL)
.setText(Tr::tr("New Terminal"))
.bindContextAction(&m_newTerminalAction)
.setIcon(NEW_TERMINAL_ICON.icon())
.setToolTip(Tr::tr("Create a new Terminal."))
.setContext(m_selfContext)
.setDefaultKeySequence("Ctrl+T", "Ctrl+Shift+T")
.addOnTriggered(this, [this] { openTerminal({}); });
ActionBuilder closeTerminalAction(this, CLOSETERMINAL);
closeTerminalAction.setText(Tr::tr("Close Terminal"));
closeTerminalAction.setIcon(CLOSE_TERMINAL_ICON.icon());
closeTerminalAction.setToolTip(Tr::tr("Close the current Terminal."));
closeTerminalAction.setContext(m_selfContext);
closeTerminalAction.addOnTriggered(this, [this] { removeTab(m_tabWidget.currentIndex()); });
m_closeTerminalAction = closeTerminalAction.commandAction();
ActionBuilder(this, CLOSETERMINAL)
.setText(Tr::tr("Close Terminal"))
.bindContextAction(&m_closeTerminalAction)
.setIcon(CLOSE_TERMINAL_ICON.icon())
.setToolTip(Tr::tr("Close the current Terminal."))
.setContext(m_selfContext)
.addOnTriggered(this, [this] { removeTab(m_tabWidget.currentIndex()); });
ActionBuilder nextTerminalAction(this, NEXTTERMINAL);
nextTerminalAction.setText(Tr::tr("Next Terminal"));
nextTerminalAction.setContext(m_selfContext);
nextTerminalAction.setDefaultKeySequences(
ActionBuilder(this, NEXTTERMINAL)
.setText(Tr::tr("Next Terminal"))
.setContext(m_selfContext)
.setDefaultKeySequences(
{QKeySequence("Alt+Tab"),
QKeySequence(HostOsInfo::isMacHost() ? QLatin1String("Ctrl+Shift+[")
: QLatin1String("Ctrl+PgUp"))});
nextTerminalAction.addOnTriggered(this, [this] {
: QLatin1String("Ctrl+PgUp"))})
.addOnTriggered(this, [this] {
if (canNavigate())
goToNext();
});
ActionBuilder prevTerminalAction(this, PREVTERMINAL);
prevTerminalAction.setText(Tr::tr("Previous Terminal"));
prevTerminalAction.setContext(m_selfContext);
prevTerminalAction.setDefaultKeySequences(
ActionBuilder(this, PREVTERMINAL)
.setText(Tr::tr("Previous Terminal"))
.setContext(m_selfContext)
.setDefaultKeySequences(
{QKeySequence("Alt+Shift+Tab"),
QKeySequence(HostOsInfo::isMacHost() ? QLatin1String("Ctrl+Shift+]")
: QLatin1String("Ctrl+PgDown"))});
prevTerminalAction.addOnTriggered(this, [this] {
: QLatin1String("Ctrl+PgDown"))})
.addOnTriggered(this, [this] {
if (canPrevious())
goToPrev();
});