Core: Replace new "Action" by an "ActionBuilder"

This needs not be stored somewhere but does its work latest
at destruction automatically.

Change-Id: If929f5a5ccc15b085f110d8d9db8f72ff2a5fac5
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
hjk
2023-11-09 10:51:53 +01:00
committed by Eike Ziller
parent 09f43e79cf
commit ab8ba7f264
5 changed files with 352 additions and 351 deletions

View File

@@ -321,15 +321,7 @@ public:
SystemEditor *m_systemEditor = nullptr;
// actions
QAction *m_focusToEditor = nullptr;
QAction *m_newAction = nullptr;
QAction *m_openAction = nullptr;
QAction *m_openWithAction = nullptr;
QAction *m_openFromDeviceAction = nullptr;
QAction *m_saveAllAction = nullptr;
QAction *m_exitAction = nullptr;
QAction *m_optionsAction = nullptr;
QAction *m_loggerAction = nullptr;
QAction *m_toggleLeftSideBarAction = nullptr;
QAction *m_toggleRightSideBarAction = nullptr;
QAction *m_toggleMenubarAction = nullptr;
@@ -338,11 +330,6 @@ public:
QAction *m_setModeSelectorStyleHiddenAction = nullptr;
QAction *m_setModeSelectorStyleIconsOnlyAction = nullptr;
Action m_aboutIdeAction;
Action m_aboutPluginsAction;
Action m_changeLogAction;
Action m_contactAction;
QToolButton *m_toggleLeftSideBarButton = nullptr;
QToolButton *m_toggleRightSideBarButton = nullptr;
QList<std::function<bool()>> m_preCloseListeners;
@@ -1569,19 +1556,18 @@ void ICorePrivate::registerDefaultActions()
// Return to editor shortcut: Note this requires Qt to fix up
// handling of shortcut overrides in menus, item views, combos....
m_focusToEditor = new QAction(Tr::tr("Return to Editor"), this);
Command *cmd = ActionManager::registerAction(m_focusToEditor, Constants::S_RETURNTOEDITOR);
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_Escape));
connect(m_focusToEditor, &QAction::triggered, this, &ICorePrivate::setFocusToEditor);
ActionBuilder focusToEditor(this, Constants::S_RETURNTOEDITOR);
focusToEditor.setText(Tr::tr("Return to Editor"));
focusToEditor.setDefaultKeySequence(QKeySequence(Qt::Key_Escape));
focusToEditor.setOnTriggered(this, [] { setFocusToEditor(); });
// New File Action
QIcon icon = Icon::fromTheme("document-new");
m_newAction = new QAction(icon, Tr::tr("&New Project..."), this);
cmd = ActionManager::registerAction(m_newAction, Constants::NEW);
cmd->setDefaultKeySequence(QKeySequence("Ctrl+Shift+N"));
mfile->addAction(cmd, Constants::G_FILE_NEW);
connect(m_newAction, &QAction::triggered, this, [] {
// New Project Action
ActionBuilder newProjectAction(this, Constants::NEW);
newProjectAction.setText(Tr::tr("&New Project..."));
newProjectAction.setIcon(Icon::fromTheme("document-new"));
newProjectAction.setDefaultKeySequence(QKeySequence("Ctrl+Shift+N"));
newProjectAction.setContainer(Constants::M_FILE, Constants::G_FILE_NEW);
newProjectAction.setOnTriggered(this, [] {
if (!ICore::isNewItemDialogRunning()) {
ICore::showNewItemDialog(
Tr::tr("New Project", "Title of dialog"),
@@ -1594,42 +1580,45 @@ void ICorePrivate::registerDefaultActions()
}
});
auto action = new QAction(icon, Tr::tr("New File..."), this);
cmd = ActionManager::registerAction(action, Constants::NEW_FILE);
cmd->setDefaultKeySequence(QKeySequence::New);
mfile->addAction(cmd, Constants::G_FILE_NEW);
connect(action, &QAction::triggered, this, [] {
// New File Action
ActionBuilder newFileAction(this, Constants::NEW_FILE);
newFileAction.setText(Tr::tr("New File..."));
newFileAction.setIcon(Icon::fromTheme("document-new"));
newFileAction.setDefaultKeySequence(QKeySequence::New);
newFileAction.setContainer(Constants::M_FILE, Constants::G_FILE_NEW);
newFileAction.setOnTriggered(this, [] {
if (!ICore::isNewItemDialogRunning()) {
ICore::showNewItemDialog(Tr::tr("New File", "Title of dialog"),
Utils::filtered(Core::IWizardFactory::allWizardFactories(),
Utils::equal(&Core::IWizardFactory::kind,
Core::IWizardFactory::FileWizard)),
FilePath());
ICore::showNewItemDialog(
Tr::tr("New File", "Title of dialog"),
Utils::filtered(Core::IWizardFactory::allWizardFactories(),
Utils::equal(&Core::IWizardFactory::kind,
Core::IWizardFactory::FileWizard)),
FilePath());
} else {
ICore::raiseWindow(ICore::newItemDialog());
}
});
// Open Action
icon = Icon::fromTheme("document-open");
m_openAction = new QAction(icon, Tr::tr("&Open File or Project..."), this);
cmd = ActionManager::registerAction(m_openAction, Constants::OPEN);
cmd->setDefaultKeySequence(QKeySequence::Open);
mfile->addAction(cmd, Constants::G_FILE_OPEN);
connect(m_openAction, &QAction::triggered, this, &ICorePrivate::openFile);
ActionBuilder openAction(this, Constants::OPEN);
openAction.setText(Tr::tr("&Open File or Project..."));
openAction.setIcon(Icon::fromTheme("document-open"));
openAction.setDefaultKeySequence(QKeySequence::Open);
openAction.setContainer(Constants::M_FILE, Constants::G_FILE_OPEN);
openAction.setOnTriggered(this, [] { openFile(); });
// Open With Action
m_openWithAction = new QAction(Tr::tr("Open File &With..."), this);
cmd = ActionManager::registerAction(m_openWithAction, Constants::OPEN_WITH);
mfile->addAction(cmd, Constants::G_FILE_OPEN);
connect(m_openWithAction, &QAction::triggered, m_core, &ICore::openFileWith);
ActionBuilder openWithAction(this, Constants::OPEN_WITH);
openWithAction.setText(Tr::tr("Open File &With..."));
openWithAction.setContainer(Constants::M_FILE, Constants::G_FILE_OPEN);
openWithAction.setOnTriggered(this, &ICore::openFileWith);
if (FSEngine::isAvailable()) {
// Open From Device Action
m_openFromDeviceAction = new QAction(Tr::tr("Open From Device..."), this);
cmd = ActionManager::registerAction(m_openFromDeviceAction, Constants::OPEN_FROM_DEVICE);
mfile->addAction(cmd, Constants::G_FILE_OPEN);
connect(m_openFromDeviceAction, &QAction::triggered, this, &ICorePrivate::openFileFromDevice);
ActionBuilder openFromDeviceAction(this, Constants::OPEN_FROM_DEVICE);
openFromDeviceAction.setText(Tr::tr("Open From Device..."));
openFromDeviceAction.setContainer(Constants::M_FILE, Constants::G_FILE_OPEN);
openFromDeviceAction.setOnTriggered(this, [this] { openFileFromDevice(); });
}
// File->Recent Files Menu
@@ -1639,128 +1628,128 @@ void ICorePrivate::registerDefaultActions()
ac->setOnAllDisabledBehavior(ActionContainer::Show);
// Save Action
icon = Icon::fromTheme("document-save");
QAction *tmpaction = new QAction(icon, Tr::tr("&Save"), this);
tmpaction->setEnabled(false);
cmd = ActionManager::registerAction(tmpaction, Constants::SAVE);
cmd->setDefaultKeySequence(QKeySequence::Save);
cmd->setAttribute(Command::CA_UpdateText);
cmd->setDescription(Tr::tr("Save"));
mfile->addAction(cmd, Constants::G_FILE_SAVE);
ActionBuilder saveAction(this, Constants::SAVE);
saveAction.setText(Tr::tr("&Save"));
saveAction.setIcon(Icon::fromTheme("document-save"));
saveAction.setEnabled(false);
saveAction.setDefaultKeySequence(QKeySequence::Save);
saveAction.setCommandAttribute(Command::CA_UpdateText);
saveAction.setCommandDescription(Tr::tr("Save"));
saveAction.setContainer(Constants::M_FILE, Constants::G_FILE_SAVE);
// Save As Action
icon = Icon::fromTheme("document-save-as");
tmpaction = new QAction(icon, Tr::tr("Save &As..."), this);
tmpaction->setEnabled(false);
cmd = ActionManager::registerAction(tmpaction, Constants::SAVEAS);
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? Tr::tr("Ctrl+Shift+S") : QString()));
cmd->setAttribute(Command::CA_UpdateText);
cmd->setDescription(Tr::tr("Save As..."));
mfile->addAction(cmd, Constants::G_FILE_SAVE);
ActionBuilder saveAsAction(this, Constants::SAVEAS);
saveAsAction.setText(Tr::tr("Save &As..."));
saveAsAction.setIcon(Icon::fromTheme("document-save-as"));
saveAsAction.setEnabled(false);
saveAsAction.setDefaultKeySequence(Tr::tr("Ctrl+Shift+S"), QString());
saveAsAction.setCommandAttribute(Command::CA_UpdateText);
saveAsAction.setCommandDescription(Tr::tr("Save As..."));
saveAsAction.setContainer(Constants::M_FILE, Constants::G_FILE_SAVE);
// SaveAll Action
DocumentManager::registerSaveAllAction();
// Print Action
icon = Icon::fromTheme("document-print");
tmpaction = new QAction(icon, Tr::tr("&Print..."), this);
tmpaction->setEnabled(false);
cmd = ActionManager::registerAction(tmpaction, Constants::PRINT);
cmd->setDefaultKeySequence(QKeySequence::Print);
mfile->addAction(cmd, Constants::G_FILE_PRINT);
ActionBuilder printAction(this, Constants::PRINT);
printAction.setText(Tr::tr("&Print..."));
printAction.setIcon(Icon::fromTheme("document-print"));
printAction.setEnabled(false);
printAction.setDefaultKeySequence(QKeySequence::Print);
printAction.setContainer(Constants::M_FILE, Constants::G_FILE_PRINT);
// Exit Action
icon = Icon::fromTheme("application-exit");
m_exitAction = new QAction(icon, Tr::tr("E&xit"), this);
m_exitAction->setMenuRole(QAction::QuitRole);
cmd = ActionManager::registerAction(m_exitAction, Constants::EXIT);
cmd->setDefaultKeySequence(QKeySequence(Tr::tr("Ctrl+Q")));
mfile->addAction(cmd, Constants::G_FILE_OTHER);
connect(m_exitAction, &QAction::triggered, m_core, &ICore::exit);
ActionBuilder exitAction(this, Constants::EXIT);
exitAction.setText(Tr::tr("E&xit"));
exitAction.setIcon(Icon::fromTheme("application-exit"));
exitAction.setMenuRole(QAction::QuitRole);
exitAction.setDefaultKeySequence(Tr::tr("Ctrl+Q"));
exitAction.setContainer(Constants::M_FILE, Constants::G_FILE_OTHER);
exitAction.setOnTriggered(this, &ICore::exit);
// Undo Action
icon = Icon::fromTheme("edit-undo");
tmpaction = new QAction(icon, Tr::tr("&Undo"), this);
cmd = ActionManager::registerAction(tmpaction, Constants::UNDO);
cmd->setDefaultKeySequence(QKeySequence::Undo);
cmd->setAttribute(Command::CA_UpdateText);
cmd->setDescription(Tr::tr("Undo"));
medit->addAction(cmd, Constants::G_EDIT_UNDOREDO);
tmpaction->setEnabled(false);
ActionBuilder undoAction(this, Constants::UNDO);
undoAction.setText(Tr::tr("&Undo"));
undoAction.setIcon(Icon::fromTheme("edit-undo"));
undoAction.setDefaultKeySequence(QKeySequence::Undo);
undoAction.setCommandAttribute(Command::CA_UpdateText);
undoAction.setCommandDescription(Tr::tr("Undo"));
undoAction.setContainer(Constants::M_EDIT, Constants::G_EDIT_UNDOREDO);
undoAction.setEnabled(false);
// Redo Action
icon = Icon::fromTheme("edit-redo");
tmpaction = new QAction(icon, Tr::tr("&Redo"), this);
cmd = ActionManager::registerAction(tmpaction, Constants::REDO);
cmd->setDefaultKeySequence(QKeySequence::Redo);
cmd->setAttribute(Command::CA_UpdateText);
cmd->setDescription(Tr::tr("Redo"));
medit->addAction(cmd, Constants::G_EDIT_UNDOREDO);
tmpaction->setEnabled(false);
ActionBuilder redoAction(this, Constants::REDO);
redoAction.setIcon(Icon::fromTheme("edit-redo"));
redoAction.setText(Tr::tr("&Redo"));
redoAction.setDefaultKeySequence(QKeySequence::Redo);
redoAction.setCommandAttribute(Command::CA_UpdateText);
redoAction.setCommandDescription(Tr::tr("Redo"));
redoAction.setContainer(Constants::M_EDIT, Constants::G_EDIT_UNDOREDO);
redoAction.setEnabled(false);
// Cut Action
icon = Icon::fromTheme("edit-cut");
tmpaction = new QAction(icon, Tr::tr("Cu&t"), this);
cmd = ActionManager::registerAction(tmpaction, Constants::CUT);
cmd->setDefaultKeySequence(QKeySequence::Cut);
medit->addAction(cmd, Constants::G_EDIT_COPYPASTE);
tmpaction->setEnabled(false);
ActionBuilder cutAction(this, Constants::CUT);
cutAction.setText(Tr::tr("Cu&t"));
cutAction.setIcon(Icon::fromTheme("edit-cut"));
cutAction.setDefaultKeySequence(QKeySequence::Cut);
cutAction.setContainer(Constants::M_EDIT, Constants::G_EDIT_COPYPASTE);
cutAction.setEnabled(false);
// Copy Action
icon = Icon::fromTheme("edit-copy");
tmpaction = new QAction(icon, Tr::tr("&Copy"), this);
cmd = ActionManager::registerAction(tmpaction, Constants::COPY);
cmd->setDefaultKeySequence(QKeySequence::Copy);
medit->addAction(cmd, Constants::G_EDIT_COPYPASTE);
tmpaction->setEnabled(false);
ActionBuilder copyAction(this, Constants::COPY);
copyAction.setText(Tr::tr("&Copy"));
copyAction.setIcon(Icon::fromTheme("edit-copy"));
copyAction.setDefaultKeySequence(QKeySequence::Copy);
copyAction.setContainer(Constants::M_EDIT, Constants::G_EDIT_COPYPASTE);
copyAction.setEnabled(false);
// Paste Action
icon = Icon::fromTheme("edit-paste");
tmpaction = new QAction(icon, Tr::tr("&Paste"), this);
cmd = ActionManager::registerAction(tmpaction, Constants::PASTE);
cmd->setDefaultKeySequence(QKeySequence::Paste);
medit->addAction(cmd, Constants::G_EDIT_COPYPASTE);
tmpaction->setEnabled(false);
ActionBuilder pasteAction(this, Constants::PASTE);
pasteAction.setText(Tr::tr("&Paste"));
pasteAction.setIcon(Icon::fromTheme("edit-paste"));
pasteAction.setDefaultKeySequence(QKeySequence::Paste);
pasteAction.setContainer(Constants::M_EDIT, Constants::G_EDIT_COPYPASTE);
pasteAction.setEnabled(false);
// Select All
icon = Icon::fromTheme("edit-select-all");
tmpaction = new QAction(icon, Tr::tr("Select &All"), this);
cmd = ActionManager::registerAction(tmpaction, Constants::SELECTALL);
cmd->setDefaultKeySequence(QKeySequence::SelectAll);
medit->addAction(cmd, Constants::G_EDIT_SELECTALL);
tmpaction->setEnabled(false);
ActionBuilder selectAllAction(this, Constants::SELECTALL);
selectAllAction.setText(Tr::tr("Select &All"));
selectAllAction.setIcon(Icon::fromTheme("edit-select-all"));
selectAllAction.setDefaultKeySequence(QKeySequence::SelectAll);
selectAllAction.setContainer(Constants::M_EDIT, Constants::G_EDIT_SELECTALL);
selectAllAction.setEnabled(false);
// Goto Action
icon = Icon::fromTheme("go-jump");
tmpaction = new QAction(icon, Tr::tr("&Go to Line..."), this);
cmd = ActionManager::registerAction(tmpaction, Constants::GOTO);
cmd->setDefaultKeySequence(QKeySequence(Tr::tr("Ctrl+L")));
medit->addAction(cmd, Constants::G_EDIT_OTHER);
tmpaction->setEnabled(false);
ActionBuilder gotoLineAction(this, Constants::GOTO);
gotoLineAction.setText(Tr::tr("&Go to Line..."));
gotoLineAction.setIcon(Icon::fromTheme("go-jump"));
gotoLineAction.setDefaultKeySequence(QKeySequence(Tr::tr("Ctrl+L")));
gotoLineAction.setContainer(Constants::M_EDIT, Constants::G_EDIT_OTHER);
gotoLineAction.setEnabled(false);
// Zoom In Action
icon = Icon::fromTheme("zoom-in");
tmpaction = new QAction(icon, Tr::tr("Zoom In"), this);
cmd = ActionManager::registerAction(tmpaction, Constants::ZOOM_IN);
cmd->setDefaultKeySequence(QKeySequence(Tr::tr("Ctrl++")));
tmpaction->setEnabled(false);
ActionBuilder zoomInAction(this, Constants::ZOOM_IN);
zoomInAction.setText(Tr::tr("Zoom In"));
zoomInAction.setIcon(Icon::fromTheme("zoom-in"));
zoomInAction.setDefaultKeySequence(QKeySequence(Tr::tr("Ctrl++")));
zoomInAction.setEnabled(false);
// Zoom Out Action
icon = Icon::fromTheme("zoom-out");
tmpaction = new QAction(icon, Tr::tr("Zoom Out"), this);
cmd = ActionManager::registerAction(tmpaction, Constants::ZOOM_OUT);
ActionBuilder zoomOutAction(this, Constants::ZOOM_OUT);
zoomOutAction.setText(Tr::tr("Zoom Out"));
zoomOutAction.setIcon(Icon::fromTheme("zoom-out"));
if (useMacShortcuts)
cmd->setDefaultKeySequences({QKeySequence(Tr::tr("Ctrl+-")), QKeySequence(Tr::tr("Ctrl+Shift+-"))});
zoomOutAction.setDefaultKeySequences({QKeySequence(Tr::tr("Ctrl+-")), QKeySequence(Tr::tr("Ctrl+Shift+-"))});
else
cmd->setDefaultKeySequence(QKeySequence(Tr::tr("Ctrl+-")));
tmpaction->setEnabled(false);
zoomOutAction.setDefaultKeySequence(Tr::tr("Ctrl+-"));
zoomOutAction.setEnabled(false);
// Zoom Reset Action
icon = Icon::fromTheme("zoom-original");
tmpaction = new QAction(icon, Tr::tr("Original Size"), this);
cmd = ActionManager::registerAction(tmpaction, Constants::ZOOM_RESET);
cmd->setDefaultKeySequence(QKeySequence(Core::useMacShortcuts ? Tr::tr("Meta+0") : Tr::tr("Ctrl+0")));
tmpaction->setEnabled(false);
ActionBuilder zoomOriginalAction(this, Constants::ZOOM_RESET);
zoomOriginalAction.setText(Tr::tr("Original Size"));
zoomOriginalAction.setIcon(Icon::fromTheme("zoom-original"));
zoomOriginalAction.setDefaultKeySequence(Tr::tr("Meta+0"), Tr::tr("Ctrl+0"));
zoomOriginalAction.setEnabled(false);
// Debug Qt Creator menu
mtools->appendGroup(Constants::G_TOOLS_DEBUG);
@@ -1768,21 +1757,21 @@ void ICorePrivate::registerDefaultActions()
mtoolsdebug->menu()->setTitle(Tr::tr("Debug %1").arg(QGuiApplication::applicationDisplayName()));
mtools->addMenu(mtoolsdebug, Constants::G_TOOLS_DEBUG);
m_loggerAction = new QAction(Tr::tr("Show Logs..."), this);
cmd = ActionManager::registerAction(m_loggerAction, Constants::LOGGER);
mtoolsdebug->addAction(cmd);
connect(m_loggerAction, &QAction::triggered, this, [] { LoggingViewer::showLoggingView(); });
ActionBuilder loggerAction(this, Constants::LOGGER);
loggerAction.setText(Tr::tr("Show Logs..."));
loggerAction.setContainer(Constants::M_TOOLS_DEBUG);
loggerAction.setOnTriggered(this, &LoggingViewer::showLoggingView);
// Options Action
medit->appendGroup(Constants::G_EDIT_PREFERENCES);
medit->addSeparator(Constants::G_EDIT_PREFERENCES);
m_optionsAction = new QAction(Tr::tr("Pr&eferences..."), this);
m_optionsAction->setMenuRole(QAction::PreferencesRole);
cmd = ActionManager::registerAction(m_optionsAction, Constants::OPTIONS);
cmd->setDefaultKeySequence(QKeySequence::Preferences);
medit->addAction(cmd, Constants::G_EDIT_PREFERENCES);
connect(m_optionsAction, &QAction::triggered, this, [] { ICore::showOptionsDialog(Id()); });
ActionBuilder optionsAction(this, Constants::OPTIONS);
optionsAction.setText(Tr::tr("Pr&eferences..."));
optionsAction.setMenuRole(QAction::PreferencesRole);
optionsAction.setDefaultKeySequence(QKeySequence::Preferences);
optionsAction.setContainer(Constants::M_EDIT, Constants::G_EDIT_PREFERENCES);
optionsAction.setOnTriggered(this, [] { ICore::showOptionsDialog(Id()); });
mwindow->addSeparator(Constants::G_WINDOW_LIST);
@@ -1790,7 +1779,7 @@ void ICorePrivate::registerDefaultActions()
// Minimize Action
QAction *minimizeAction = new QAction(Tr::tr("Minimize"), this);
minimizeAction->setEnabled(false); // actual implementation in WindowSupport
cmd = ActionManager::registerAction(minimizeAction, Constants::MINIMIZE_WINDOW);
Command *cmd = ActionManager::registerAction(minimizeAction, Constants::MINIMIZE_WINDOW);
cmd->setDefaultKeySequence(QKeySequence(Tr::tr("Ctrl+M")));
mwindow->addAction(cmd, Constants::G_WINDOW_SIZE);
@@ -1805,7 +1794,7 @@ void ICorePrivate::registerDefaultActions()
QAction *toggleFullScreenAction = new QAction(Tr::tr("Full Screen"), this);
toggleFullScreenAction->setCheckable(!HostOsInfo::isMacHost());
toggleFullScreenAction->setEnabled(false); // actual implementation in WindowSupport
cmd = ActionManager::registerAction(toggleFullScreenAction, Constants::TOGGLE_FULLSCREEN);
Command *cmd = ActionManager::registerAction(toggleFullScreenAction, Constants::TOGGLE_FULLSCREEN);
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? Tr::tr("Ctrl+Meta+F") : Tr::tr("Ctrl+Shift+F11")));
if (HostOsInfo::isMacHost())
cmd->setAttribute(Command::CA_UpdateText);
@@ -1824,36 +1813,36 @@ void ICorePrivate::registerDefaultActions()
}
// Show Left Sidebar Action
m_toggleLeftSideBarAction = new QAction(Utils::Icons::TOGGLE_LEFT_SIDEBAR.icon(),
Tr::tr(Constants::TR_SHOW_LEFT_SIDEBAR),
this);
m_toggleLeftSideBarAction->setCheckable(true);
cmd = ActionManager::registerAction(m_toggleLeftSideBarAction, Constants::TOGGLE_LEFT_SIDEBAR);
cmd->setAttribute(Command::CA_UpdateText);
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? Tr::tr("Ctrl+0") : Tr::tr("Alt+0")));
connect(m_toggleLeftSideBarAction, &QAction::triggered,
this, [this](bool visible) { setSidebarVisible(visible, Side::Left); });
ProxyAction *toggleLeftSideBarProxyAction =
ProxyAction::proxyActionWithIcon(cmd->action(), Utils::Icons::TOGGLE_LEFT_SIDEBAR_TOOLBAR.icon());
m_toggleLeftSideBarButton->setDefaultAction(toggleLeftSideBarProxyAction);
mview->addAction(cmd, Constants::G_VIEW_VIEWS);
m_toggleLeftSideBarAction->setEnabled(false);
ActionBuilder toggleLeftSideBarAction(this, Constants::TOGGLE_LEFT_SIDEBAR);
toggleLeftSideBarAction.setIcon(Utils::Icons::TOGGLE_LEFT_SIDEBAR.icon());
toggleLeftSideBarAction.setText(Tr::tr(Constants::TR_SHOW_LEFT_SIDEBAR));
toggleLeftSideBarAction.setCheckable(true);
toggleLeftSideBarAction.setCommandAttribute(Command::CA_UpdateText);
toggleLeftSideBarAction.setDefaultKeySequence(Tr::tr("Ctrl+0"), Tr::tr("Alt+0"));
toggleLeftSideBarAction.setContainer(Constants::M_VIEW, Constants::G_VIEW_VIEWS);
toggleLeftSideBarAction.setOnTriggered(this,
[this](bool visible) { setSidebarVisible(visible, Side::Left); });
m_toggleLeftSideBarAction = toggleLeftSideBarAction.contextAction();
m_toggleLeftSideBarButton->setDefaultAction(ProxyAction::proxyActionWithIcon(
toggleLeftSideBarAction.commandAction(), Utils::Icons::TOGGLE_LEFT_SIDEBAR_TOOLBAR.icon()));
m_toggleLeftSideBarButton->setEnabled(false);
// Show Right Sidebar Action
m_toggleRightSideBarAction = new QAction(Utils::Icons::TOGGLE_RIGHT_SIDEBAR.icon(),
Tr::tr(Constants::TR_SHOW_RIGHT_SIDEBAR),
this);
m_toggleRightSideBarAction->setCheckable(true);
cmd = ActionManager::registerAction(m_toggleRightSideBarAction, Constants::TOGGLE_RIGHT_SIDEBAR);
cmd->setAttribute(Command::CA_UpdateText);
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? Tr::tr("Ctrl+Shift+0") : Tr::tr("Alt+Shift+0")));
connect(m_toggleRightSideBarAction, &QAction::triggered,
this, [this](bool visible) { setSidebarVisible(visible, Side::Right); });
ProxyAction *toggleRightSideBarProxyAction =
ProxyAction::proxyActionWithIcon(cmd->action(), Utils::Icons::TOGGLE_RIGHT_SIDEBAR_TOOLBAR.icon());
m_toggleRightSideBarButton->setDefaultAction(toggleRightSideBarProxyAction);
mview->addAction(cmd, Constants::G_VIEW_VIEWS);
m_toggleRightSideBarButton->setEnabled(false);
ActionBuilder toggleRightSideBarAction(this, Constants::TOGGLE_RIGHT_SIDEBAR);
toggleRightSideBarAction.setIcon(Utils::Icons::TOGGLE_RIGHT_SIDEBAR.icon());
toggleRightSideBarAction.setText(Tr::tr(Constants::TR_SHOW_RIGHT_SIDEBAR));
toggleRightSideBarAction.setCheckable(true);
toggleRightSideBarAction.setCommandAttribute(Command::CA_UpdateText);
toggleRightSideBarAction.setDefaultKeySequence(Tr::tr("Ctrl+Shift+0"), Tr::tr("Alt+Shift+0"));
toggleRightSideBarAction.setContainer(Constants::M_VIEW, Constants::G_VIEW_VIEWS);
toggleRightSideBarAction.setEnabled(false);
toggleRightSideBarAction.setOnTriggered(this,
[this](bool visible) { setSidebarVisible(visible, Side::Right); });
m_toggleRightSideBarAction = toggleRightSideBarAction.contextAction();
m_toggleRightSideBarButton->setDefaultAction(ProxyAction::proxyActionWithIcon(
toggleRightSideBarAction.commandAction(), Utils::Icons::TOGGLE_RIGHT_SIDEBAR_TOOLBAR.icon()));
// Show Menubar Action
if (globalMenuBar() && !globalMenuBar()->isNativeMenuBar()) {
@@ -1889,49 +1878,49 @@ void ICorePrivate::registerDefaultActions()
mhelp->addSeparator(Constants::G_HELP_ABOUT);
// About IDE Action
m_aboutIdeAction.setId(Constants::ABOUT_QTCREATOR);
m_aboutIdeAction.setIcon(Icon::fromTheme("help-about"));
m_aboutIdeAction.setText(
(HostOsInfo::isMacHost() ? Tr::tr("About &%1") : Tr::tr("About &%1..."))
.arg(QGuiApplication::applicationDisplayName()));
m_aboutIdeAction.setMenuRole(QAction::AboutRole);
m_aboutIdeAction.setContainer(Constants::M_HELP, Constants::G_HELP_ABOUT);
m_aboutIdeAction.setEnabled(true);
m_aboutIdeAction.setOnTriggered(this, [this] { aboutQtCreator(); });
ActionBuilder aboutIdeAction(this, Constants::ABOUT_QTCREATOR);
aboutIdeAction.setIcon(Icon::fromTheme("help-about"));
aboutIdeAction.setText(
(HostOsInfo::isMacHost() ? Tr::tr("About &%1") : Tr::tr("About &%1..."))
.arg(QGuiApplication::applicationDisplayName()));
aboutIdeAction.setMenuRole(QAction::AboutRole);
aboutIdeAction.setContainer(Constants::M_HELP, Constants::G_HELP_ABOUT);
aboutIdeAction.setEnabled(true);
aboutIdeAction.setOnTriggered(this, [this] { aboutQtCreator(); });
// About Plugins Action
m_aboutPluginsAction.setId(Constants::ABOUT_PLUGINS);
m_aboutPluginsAction.setText(Tr::tr("About &Plugins..."));
m_aboutPluginsAction.setMenuRole(QAction::ApplicationSpecificRole);
m_aboutPluginsAction.setContainer(Constants::M_HELP, Constants::G_HELP_ABOUT);
m_aboutPluginsAction.setEnabled(true);
m_aboutPluginsAction.setOnTriggered(this, [this] { aboutPlugins(); });
ActionBuilder aboutPluginsAction(this, Constants::ABOUT_PLUGINS);
aboutPluginsAction.setText(Tr::tr("About &Plugins..."));
aboutPluginsAction.setMenuRole(QAction::ApplicationSpecificRole);
aboutPluginsAction.setContainer(Constants::M_HELP, Constants::G_HELP_ABOUT);
aboutPluginsAction.setEnabled(true);
aboutPluginsAction.setOnTriggered(this, [this] { aboutPlugins(); });
// About Qt Action
// aboutQtAction.setId(Constants:: ABOUT_QT);
// ActionBuilder aboutQtAction(this, Constants:: ABOUT_QT);
// aboutQtAction.setText(Tr::tr("About &Qt..."), this);
// aboutQtAction.setContainer(Constants::M_HELP, Constants::G_HELP_ABOUT);
// aboutQtAction.setEnabled(true);
// aboutQtAction.setOnTriggered(this, &QApplication::aboutQt);
// Change Log Action
m_changeLogAction.setId(Constants::CHANGE_LOG);
m_changeLogAction.setText(Tr::tr("Change Log..."));
m_changeLogAction.setMenuRole(QAction::ApplicationSpecificRole);
m_changeLogAction.setContainer(Constants::M_HELP, Constants::G_HELP_ABOUT);
m_changeLogAction.setEnabled(true);
m_changeLogAction.setOnTriggered(this, [this] { changeLog(); });
ActionBuilder changeLogAction(this, Constants::CHANGE_LOG);
changeLogAction.setText(Tr::tr("Change Log..."));
changeLogAction.setMenuRole(QAction::ApplicationSpecificRole);
changeLogAction.setContainer(Constants::M_HELP, Constants::G_HELP_ABOUT);
changeLogAction.setEnabled(true);
changeLogAction.setOnTriggered(this, [this] { changeLog(); });
// Contact
m_contactAction.setId("QtCreator.Contact");
m_contactAction.setText(Tr::tr("Contact..."));
m_contactAction.setContainer(Constants::M_HELP, Constants::G_HELP_ABOUT);
m_contactAction.setEnabled(true);
m_contactAction.setOnTriggered(this, [this] { contact(); });
ActionBuilder contactAction(this, "QtCreator.Contact");
contactAction.setText(Tr::tr("Contact..."));
contactAction.setContainer(Constants::M_HELP, Constants::G_HELP_ABOUT);
contactAction.setEnabled(true);
contactAction.setOnTriggered(this, [this] { contact(); });
// About sep
if (!HostOsInfo::isMacHost()) { // doesn't have the "About" actions in the Help menu
tmpaction = new QAction(this);
auto tmpaction = new QAction(this);
tmpaction->setSeparator(true);
cmd = ActionManager::registerAction(tmpaction, "QtCreator.Help.Sep.About");
mhelp->addAction(cmd, Constants::G_HELP_ABOUT);