Core: Use Core::Action for 'About...' stuff

... and add the necessary Action::setMenuRole()

Change-Id: I2bb309ae115c1e015ff848e0712327360ead23cd
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2023-11-09 12:04:30 +01:00
parent 9c4ba3ff21
commit d391c0c74e
3 changed files with 34 additions and 33 deletions

View File

@@ -203,6 +203,13 @@ void Action::setCheckable(bool on)
d->command->action()->setCheckable(on); d->command->action()->setCheckable(on);
} }
void Action::setMenuRole(QAction::MenuRole role)
{
d->action.setMenuRole(role);
if (d->command)
d->command->action()->setMenuRole(role);
}
Command *Action::command() const Command *Action::command() const
{ {
d->ensureCommand(); d->ensureCommand();

View File

@@ -8,16 +8,11 @@
#include "../icontext.h" #include "../icontext.h"
#include "command.h" #include "command.h"
#include <QObject> #include <QAction>
#include <QList> #include <QList>
#include <functional> #include <functional>
QT_BEGIN_NAMESPACE
class QAction;
class QString;
QT_END_NAMESPACE
namespace Core { namespace Core {
class ActionContainer; class ActionContainer;
@@ -55,6 +50,7 @@ public:
void setChecked(bool on); void setChecked(bool on);
void setVisible(bool on); void setVisible(bool on);
void setCheckable(bool on); void setCheckable(bool on);
void setMenuRole(QAction::MenuRole role);
Command *command() const; Command *command() const;
QAction *commandAction() const; QAction *commandAction() const;

View File

@@ -339,6 +339,9 @@ public:
QAction *m_setModeSelectorStyleIconsOnlyAction = nullptr; QAction *m_setModeSelectorStyleIconsOnlyAction = nullptr;
QAction *m_themeAction = nullptr; QAction *m_themeAction = nullptr;
Action m_aboutIdeAction;
Action m_aboutPluginsAction;
QToolButton *m_toggleLeftSideBarButton = nullptr; QToolButton *m_toggleLeftSideBarButton = nullptr;
QToolButton *m_toggleRightSideBarButton = nullptr; QToolButton *m_toggleRightSideBarButton = nullptr;
QList<std::function<bool()>> m_preCloseListeners; QList<std::function<bool()>> m_preCloseListeners;
@@ -1885,35 +1888,30 @@ void ICorePrivate::registerDefaultActions()
mhelp->addSeparator(Constants::G_HELP_ABOUT); mhelp->addSeparator(Constants::G_HELP_ABOUT);
// About IDE Action // About IDE Action
icon = Icon::fromTheme("help-about"); m_aboutIdeAction.setId(Constants::ABOUT_QTCREATOR);
if (HostOsInfo::isMacHost()) m_aboutIdeAction.setIcon(Icon::fromTheme("help-about"));
tmpaction = new QAction(icon, m_aboutIdeAction.setText(
Tr::tr("About &%1").arg(QGuiApplication::applicationDisplayName()), (HostOsInfo::isMacHost() ? Tr::tr("About &%1") : Tr::tr("About &%1..."))
this); // it's convention not to add dots to the about menu .arg(QGuiApplication::applicationDisplayName()));
else m_aboutIdeAction.setMenuRole(QAction::AboutRole);
tmpaction m_aboutIdeAction.setContainer(Constants::M_HELP, Constants::G_HELP_ABOUT);
= new QAction(icon, m_aboutIdeAction.setEnabled(true);
Tr::tr("About &%1...").arg(QGuiApplication::applicationDisplayName()), m_aboutIdeAction.setOnTriggered(this, [this] { aboutQtCreator(); });
this);
tmpaction->setMenuRole(QAction::AboutRole); // About Plugins Action
cmd = ActionManager::registerAction(tmpaction, Constants::ABOUT_QTCREATOR); m_aboutPluginsAction.setId(Constants::ABOUT_PLUGINS);
mhelp->addAction(cmd, Constants::G_HELP_ABOUT); m_aboutPluginsAction.setText(Tr::tr("About &Plugins..."));
tmpaction->setEnabled(true); m_aboutPluginsAction.setMenuRole(QAction::ApplicationSpecificRole);
connect(tmpaction, &QAction::triggered, this, &ICorePrivate::aboutQtCreator); m_aboutPluginsAction.setContainer(Constants::M_HELP, Constants::G_HELP_ABOUT);
m_aboutPluginsAction.setEnabled(true);
m_aboutPluginsAction.setOnTriggered(this, [this] { aboutPlugins(); });
//About Plugins Action
tmpaction = new QAction(Tr::tr("About &Plugins..."), this);
tmpaction->setMenuRole(QAction::ApplicationSpecificRole);
cmd = ActionManager::registerAction(tmpaction, Constants::ABOUT_PLUGINS);
mhelp->addAction(cmd, Constants::G_HELP_ABOUT);
tmpaction->setEnabled(true);
connect(tmpaction, &QAction::triggered, this, &ICorePrivate::aboutPlugins);
// About Qt Action // About Qt Action
// tmpaction = new QAction(Tr::tr("About &Qt..."), this); // aboutQtAction.setId(Constants:: ABOUT_QT);
// cmd = ActionManager::registerAction(tmpaction, Constants:: ABOUT_QT); // aboutQtAction.setText(Tr::tr("About &Qt..."), this);
// mhelp->addAction(cmd, Constants::G_HELP_ABOUT); // aboutQtAction.setContainer(Constants::M_HELP, Constants::G_HELP_ABOUT);
// tmpaction->setEnabled(true); // aboutQtAction.setEnabled(true);
// connect(tmpaction, &QAction::triggered, qApp, &QApplication::aboutQt); // aboutQtAction.setOnTriggered(this, &QApplication::aboutQt);
// Change Log Action // Change Log Action
tmpaction = new QAction(Tr::tr("Change Log..."), this); tmpaction = new QAction(Tr::tr("Change Log..."), this);