ClearCase: Use ActionBuilder

Change-Id: I8c71a0e86fe6658240910bf8ddf650bf7da581a9
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
hjk
2023-12-19 10:11:30 +01:00
parent a26c373708
commit ee921a25d5

View File

@@ -614,123 +614,154 @@ ClearCasePluginPrivate::ClearCasePluginPrivate()
clearcaseMenu->menu()->setTitle(Tr::tr("C&learCase")); clearcaseMenu->menu()->setTitle(Tr::tr("C&learCase"));
toolsContainer->addMenu(clearcaseMenu); toolsContainer->addMenu(clearcaseMenu);
m_menuAction = clearcaseMenu->menu()->menuAction(); m_menuAction = clearcaseMenu->menu()->menuAction();
Command *command;
m_checkOutAction = new ParameterAction(Tr::tr("Check Out..."), Tr::tr("Check &Out \"%1\"..."), ParameterAction::AlwaysEnabled, this); ActionBuilder checkOut(this, CMD_ID_CHECKOUT);
command = ActionManager::registerAction(m_checkOutAction, CMD_ID_CHECKOUT, checkOut.setParameterText(Tr::tr("Check &Out \"%1\"..."), Tr::tr("Check Out..."),
context); ActionBuilder::AlwaysEnabled);
command->setAttribute(Command::CA_UpdateText); checkOut.bindContextAction(&m_checkOutAction);
command->setDefaultKeySequence(QKeySequence(useMacShortcuts ? Tr::tr("Meta+L,Meta+O") : Tr::tr("Alt+L,Alt+O"))); checkOut.setContext(context);
connect(m_checkOutAction, &QAction::triggered, this, &ClearCasePluginPrivate::checkOutCurrentFile); checkOut.setCommandAttribute(Command::CA_UpdateText);
clearcaseMenu->addAction(command); checkOut.setDefaultKeySequence(Tr::tr("Meta+L,Meta+O"), Tr::tr("Alt+L,Alt+O"));
m_commandLocator->appendCommand(command); checkOut.addOnTriggered(this, &ClearCasePluginPrivate::checkOutCurrentFile);
checkOut.addToContainer(CMD_ID_CLEARCASE_MENU);
m_commandLocator->appendCommand(checkOut.command());
m_checkInCurrentAction = new ParameterAction(Tr::tr("Check &In..."), Tr::tr("Check &In \"%1\"..."), ParameterAction::AlwaysEnabled, this); ActionBuilder checkInCurrent(this, CMD_ID_CHECKIN);
command = ActionManager::registerAction(m_checkInCurrentAction, CMD_ID_CHECKIN, context); checkInCurrent.setParameterText(Tr::tr("Check &In \"%1\"..."), Tr::tr("Check &In..."),
command->setAttribute(Command::CA_UpdateText); ActionBuilder::AlwaysEnabled);
command->setDefaultKeySequence(QKeySequence(useMacShortcuts ? Tr::tr("Meta+L,Meta+I") : Tr::tr("Alt+L,Alt+I"))); checkInCurrent.bindContextAction(&m_checkInCurrentAction);
connect(m_checkInCurrentAction, &QAction::triggered, this, &ClearCasePluginPrivate::startCheckInCurrentFile); checkInCurrent.setContext(context);
clearcaseMenu->addAction(command); checkInCurrent.setCommandAttribute(Command::CA_UpdateText);
m_commandLocator->appendCommand(command); checkInCurrent.setDefaultKeySequence(Tr::tr("Meta+L,Meta+I"), Tr::tr("Alt+L,Alt+I"));
checkInCurrent.addOnTriggered(this, &ClearCasePluginPrivate::startCheckInCurrentFile);
checkInCurrent.addToContainer(CMD_ID_CLEARCASE_MENU);
m_commandLocator->appendCommand(checkInCurrent.command());
m_undoCheckOutAction = new ParameterAction(Tr::tr("Undo Check Out"), Tr::tr("&Undo Check Out \"%1\""), ParameterAction::AlwaysEnabled, this); ActionBuilder undoCheckOut(this, CMD_ID_UNDOCHECKOUT);
command = ActionManager::registerAction(m_undoCheckOutAction, CMD_ID_UNDOCHECKOUT, context); undoCheckOut.setParameterText("&Undo Check Out \"%1\"", Tr::tr("Undo Check Out"),
command->setAttribute(Command::CA_UpdateText); ActionBuilder::AlwaysEnabled);
command->setDefaultKeySequence(QKeySequence(useMacShortcuts ? Tr::tr("Meta+L,Meta+U") : Tr::tr("Alt+L,Alt+U"))); undoCheckOut.bindContextAction(&m_undoCheckOutAction);
connect(m_undoCheckOutAction, &QAction::triggered, this, &ClearCasePluginPrivate::undoCheckOutCurrent); undoCheckOut.setContext(context);
clearcaseMenu->addAction(command); undoCheckOut.setCommandAttribute(Command::CA_UpdateText);
m_commandLocator->appendCommand(command); undoCheckOut.setDefaultKeySequence(Tr::tr("Meta+L,Meta+U"), Tr::tr("Alt+L,Alt+U"));
undoCheckOut.addOnTriggered(this, &ClearCasePluginPrivate::undoCheckOutCurrent);
undoCheckOut.addToContainer(CMD_ID_CLEARCASE_MENU);
m_commandLocator->appendCommand(undoCheckOut.command());
m_undoHijackAction = new ParameterAction(Tr::tr("Undo Hijack"), Tr::tr("Undo Hi&jack \"%1\""), ParameterAction::AlwaysEnabled, this); ActionBuilder undoHijack(this, CMD_ID_UNDOHIJACK);
command = ActionManager::registerAction(m_undoHijackAction, CMD_ID_UNDOHIJACK, context); undoHijack.setParameterText(Tr::tr("Undo Hi&jack \"%1\""), Tr::tr("Undo Hijack"),
command->setAttribute(Command::CA_UpdateText); ActionBuilder::AlwaysEnabled);
command->setDefaultKeySequence(QKeySequence(useMacShortcuts ? Tr::tr("Meta+L,Meta+R") : Tr::tr("Alt+L,Alt+R"))); undoHijack.bindContextAction(&m_undoHijackAction);
connect(m_undoHijackAction, &QAction::triggered, this, &ClearCasePluginPrivate::undoHijackCurrent); undoHijack.setContext(context);
clearcaseMenu->addAction(command); undoHijack.setCommandAttribute(Command::CA_UpdateText);
m_commandLocator->appendCommand(command); undoHijack.setDefaultKeySequence(Tr::tr("Meta+L,Meta+R"), Tr::tr("Alt+L,Alt+R"));
undoHijack.addOnTriggered(this, &ClearCasePluginPrivate::undoHijackCurrent);
undoHijack.addToContainer(CMD_ID_CLEARCASE_MENU);
m_commandLocator->appendCommand(undoHijack.command());
clearcaseMenu->addSeparator(context); clearcaseMenu->addSeparator(context);
m_diffCurrentAction = new ParameterAction(Tr::tr("Diff Current File"), Tr::tr("&Diff \"%1\""), ParameterAction::EnabledWithParameter, this); ActionBuilder diffCurrent(this, CMD_ID_DIFF_CURRENT);
command = ActionManager::registerAction(m_diffCurrentAction, diffCurrent.setParameterText(Tr::tr("&Diff \"%1\""), Tr::tr("Diff Current File"),
CMD_ID_DIFF_CURRENT, context); ActionBuilder::EnabledWithParameter);
command->setAttribute(Command::CA_UpdateText); diffCurrent.bindContextAction(&m_diffCurrentAction);
command->setDefaultKeySequence(QKeySequence(useMacShortcuts ? Tr::tr("Meta+L,Meta+D") : Tr::tr("Alt+L,Alt+D"))); diffCurrent.setContext(context);
connect(m_diffCurrentAction, &QAction::triggered, this, &ClearCasePluginPrivate::diffCurrentFile); diffCurrent.setCommandAttribute(Command::CA_UpdateText);
clearcaseMenu->addAction(command); diffCurrent.setDefaultKeySequence(Tr::tr("Meta+L,Meta+D"), Tr::tr("Alt+L,Alt+D"));
m_commandLocator->appendCommand(command); diffCurrent.addOnTriggered(this, &ClearCasePluginPrivate::diffCurrentFile);
diffCurrent.addToContainer(CMD_ID_CLEARCASE_MENU);
m_commandLocator->appendCommand(diffCurrent.command());
m_historyCurrentAction = new ParameterAction(Tr::tr("History Current File"), Tr::tr("&History \"%1\""), ParameterAction::EnabledWithParameter, this); ActionBuilder historyCurrent(this, CMD_ID_HISTORY_CURRENT);
command = ActionManager::registerAction(m_historyCurrentAction, historyCurrent.setParameterText(Tr::tr("&History \"%1\""), Tr::tr("History Current File"),
CMD_ID_HISTORY_CURRENT, context); ActionBuilder::EnabledWithParameter);
command->setAttribute(Command::CA_UpdateText); historyCurrent.bindContextAction(&m_historyCurrentAction);
command->setDefaultKeySequence(QKeySequence(useMacShortcuts ? Tr::tr("Meta+L,Meta+H") : Tr::tr("Alt+L,Alt+H"))); historyCurrent.setContext(context);
connect(m_historyCurrentAction, &QAction::triggered, this, historyCurrent.setCommandAttribute(Command::CA_UpdateText);
&ClearCasePluginPrivate::historyCurrentFile); historyCurrent.setDefaultKeySequence(Tr::tr("Meta+L,Meta+H"), Tr::tr("Alt+L,Alt+H"));
clearcaseMenu->addAction(command); historyCurrent.addOnTriggered(this, &ClearCasePluginPrivate::historyCurrentFile);
m_commandLocator->appendCommand(command); historyCurrent.addToContainer(CMD_ID_CLEARCASE_MENU);
m_commandLocator->appendCommand(historyCurrent.command());
m_annotateCurrentAction = new ParameterAction(Tr::tr("Annotate Current File"), Tr::tr("&Annotate \"%1\""), ParameterAction::EnabledWithParameter, this); ActionBuilder annotateCurrent(this, CMD_ID_ANNOTATE);
command = ActionManager::registerAction(m_annotateCurrentAction, annotateCurrent.setParameterText(Tr::tr("&Annotate \"%1\""),Tr::tr("Annotate Current File"),
CMD_ID_ANNOTATE, context); ActionBuilder::EnabledWithParameter);
command->setAttribute(Command::CA_UpdateText); annotateCurrent.bindContextAction(&m_annotateCurrentAction);
command->setDefaultKeySequence(QKeySequence(useMacShortcuts ? Tr::tr("Meta+L,Meta+A") : Tr::tr("Alt+L,Alt+A"))); annotateCurrent.setContext(context);
connect(m_annotateCurrentAction, &QAction::triggered, this, annotateCurrent.setCommandAttribute(Command::CA_UpdateText);
&ClearCasePluginPrivate::annotateCurrentFile); annotateCurrent.setDefaultKeySequence(Tr::tr("Meta+L,Meta+A"), Tr::tr("Alt+L,Alt+A"));
clearcaseMenu->addAction(command); annotateCurrent.addOnTriggered(this, &ClearCasePluginPrivate::annotateCurrentFile);
m_commandLocator->appendCommand(command); annotateCurrent.addToContainer(CMD_ID_CLEARCASE_MENU);
m_commandLocator->appendCommand(annotateCurrent.command());
m_addFileAction = new ParameterAction(Tr::tr("Add File..."), Tr::tr("Add File \"%1\""), ParameterAction::EnabledWithParameter, this); ActionBuilder addFile(this, CMD_ID_ADD_FILE);
command = ActionManager::registerAction(m_addFileAction, CMD_ID_ADD_FILE, context); addFile.setParameterText(Tr::tr("Add File \"%1\""), Tr::tr("Add File..."),
command->setAttribute(Command::CA_UpdateText); ActionBuilder::EnabledWithParameter);
connect(m_addFileAction, &QAction::triggered, this, &ClearCasePluginPrivate::addCurrentFile); addFile.bindContextAction(&m_addFileAction);
clearcaseMenu->addAction(command); addFile.setContext(context);
addFile.setCommandAttribute(Command::CA_UpdateText);
addFile.addOnTriggered(this, &ClearCasePluginPrivate::addCurrentFile);
addFile.addToContainer(CMD_ID_CLEARCASE_MENU);
clearcaseMenu->addSeparator(context); clearcaseMenu->addSeparator(context);
m_diffActivityAction = new QAction(Tr::tr("Diff A&ctivity..."), this); ActionBuilder diffActivity(this, CMD_ID_DIFF_ACTIVITY);
m_diffActivityAction->setEnabled(false); diffActivity.setText(Tr::tr("Diff A&ctivity..."));
command = ActionManager::registerAction(m_diffActivityAction, CMD_ID_DIFF_ACTIVITY, context); diffActivity.bindContextAction(&m_diffActivityAction);
connect(m_diffActivityAction, &QAction::triggered, this, &ClearCasePluginPrivate::diffActivity); diffActivity.setContext(context);
clearcaseMenu->addAction(command); diffActivity.setEnabled(false);
m_commandLocator->appendCommand(command); diffActivity.addOnTriggered(this, &ClearCasePluginPrivate::diffActivity);
diffActivity.addToContainer(CMD_ID_CLEARCASE_MENU);
m_commandLocator->appendCommand(diffActivity.command());
m_checkInActivityAction = new ParameterAction(Tr::tr("Ch&eck In Activity"), Tr::tr("Chec&k In Activity \"%1\"..."), ParameterAction::EnabledWithParameter, this); ActionBuilder checkInActivity(this, CMD_ID_CHECKIN_ACTIVITY);
m_checkInActivityAction->setEnabled(false); checkInActivity.setParameterText(Tr::tr("Chec&k In Activity \"%1\"..."), Tr::tr("Ch&eck In Activity"),
command = ActionManager::registerAction(m_checkInActivityAction, CMD_ID_CHECKIN_ACTIVITY, context); ActionBuilder::EnabledWithParameter);
connect(m_checkInActivityAction, &QAction::triggered, this, &ClearCasePluginPrivate::startCheckInActivity); checkInActivity.bindContextAction(&m_checkInActivityAction);
command->setAttribute(Command::CA_UpdateText); checkInActivity.setContext(context);
clearcaseMenu->addAction(command); checkInActivity.setEnabled(false);
m_commandLocator->appendCommand(command); checkInActivity.addOnTriggered(this, &ClearCasePluginPrivate::startCheckInActivity);
checkInActivity.setCommandAttribute(Command::CA_UpdateText);
checkInActivity.addToContainer(CMD_ID_CLEARCASE_MENU);
m_commandLocator->appendCommand(checkInActivity.command());
clearcaseMenu->addSeparator(context); clearcaseMenu->addSeparator(context);
m_updateIndexAction = new QAction(Tr::tr("Update Index"), this); ActionBuilder updateIndex(this, CMD_ID_UPDATEINDEX);
command = ActionManager::registerAction(m_updateIndexAction, CMD_ID_UPDATEINDEX, context); updateIndex.setText(Tr::tr("Update Index"));
connect(m_updateIndexAction, &QAction::triggered, this, &ClearCasePluginPrivate::updateIndex); updateIndex.bindContextAction(&m_updateIndexAction);
clearcaseMenu->addAction(command); updateIndex.setContext(context);
updateIndex.addOnTriggered(this, &ClearCasePluginPrivate::updateIndex);
updateIndex.addToContainer(CMD_ID_CLEARCASE_MENU);
m_updateViewAction = new ParameterAction(Tr::tr("Update View"), Tr::tr("U&pdate View \"%1\""), ParameterAction::EnabledWithParameter, this); ActionBuilder updateView(this, CMD_ID_UPDATE_VIEW);
command = ActionManager::registerAction(m_updateViewAction, CMD_ID_UPDATE_VIEW, context); updateView.setParameterText(Tr::tr("U&pdate View \"%1\""), Tr::tr("Update View"),
connect(m_updateViewAction, &QAction::triggered, this, &ClearCasePluginPrivate::updateView); ActionBuilder::EnabledWithParameter);
command->setAttribute(Command::CA_UpdateText); updateView.bindContextAction(&m_updateViewAction);
clearcaseMenu->addAction(command); updateView.setContext(context);
updateView.setCommandAttribute(Command::CA_UpdateText);
updateView.addOnTriggered(this, &ClearCasePluginPrivate::updateView);
updateView.addToContainer(CMD_ID_CLEARCASE_MENU);
clearcaseMenu->addSeparator(context); clearcaseMenu->addSeparator(context);
m_checkInAllAction = new QAction(Tr::tr("Check In All &Files..."), this); ActionBuilder checkInAll(this, CMD_ID_CHECKIN_ALL);
command = ActionManager::registerAction(m_checkInAllAction, CMD_ID_CHECKIN_ALL, context); checkInAll.setText(Tr::tr("Check In All &Files..."));
command->setDefaultKeySequence(QKeySequence(useMacShortcuts ? Tr::tr("Meta+L,Meta+F") : Tr::tr("Alt+L,Alt+F"))); checkInAll.bindContextAction(&m_checkInAllAction);
connect(m_checkInAllAction, &QAction::triggered, this, &ClearCasePluginPrivate::startCheckInAll); checkInAll.setContext(context);
clearcaseMenu->addAction(command); checkInAll.setDefaultKeySequence(Tr::tr("Meta+L,Meta+F"), Tr::tr("Alt+L,Alt+F"));
m_commandLocator->appendCommand(command); checkInAll.addOnTriggered(this, &ClearCasePluginPrivate::startCheckInAll);
checkInAll.addToContainer(CMD_ID_CLEARCASE_MENU);
m_commandLocator->appendCommand(checkInAll.command());
m_statusAction = new QAction(Tr::tr("View &Status"), this); ActionBuilder status(this, CMD_ID_STATUS);
command = ActionManager::registerAction(m_statusAction, CMD_ID_STATUS, context); status.setText(Tr::tr("View &Status"));
command->setDefaultKeySequence(QKeySequence(useMacShortcuts ? Tr::tr("Meta+L,Meta+S") : Tr::tr("Alt+L,Alt+S"))); status.bindContextAction(&m_statusAction);
connect(m_statusAction, &QAction::triggered, this, &ClearCasePluginPrivate::viewStatus); status.setContext(context);
clearcaseMenu->addAction(command); status.setDefaultKeySequence(Tr::tr("Meta+L,Meta+S"), Tr::tr("Alt+L,Alt+S"));
m_commandLocator->appendCommand(command); status.addOnTriggered(this, &ClearCasePluginPrivate::viewStatus);
status.addToContainer(CMD_ID_CLEARCASE_MENU);
m_commandLocator->appendCommand(status.command());
} }
// called before closing the submit editor // called before closing the submit editor