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