2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2009-01-14 12:25:54 +01:00
|
|
|
#include "actioncontainer_p.h"
|
2012-06-05 14:22:20 +02:00
|
|
|
#include "actionmanager.h"
|
2009-01-13 13:07:29 +01:00
|
|
|
|
2023-09-14 12:15:19 +02:00
|
|
|
#include "../coreconstants.h"
|
|
|
|
|
#include "../icontext.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-01-20 14:24:44 +01:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QTimer>
|
|
|
|
|
#include <QAction>
|
|
|
|
|
#include <QMenuBar>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(Core::Internal::MenuActionContainer*)
|
|
|
|
|
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
using namespace Utils;
|
|
|
|
|
|
2014-11-16 10:52:41 +02:00
|
|
|
namespace Core {
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
/*!
|
2020-02-12 13:26:28 +01:00
|
|
|
\class Core::ActionContainer
|
2020-06-12 16:04:30 +02:00
|
|
|
\inheaderfile coreplugin/actionmanager/actioncontainer.h
|
2020-02-12 13:26:28 +01:00
|
|
|
\ingroup mainclasses
|
|
|
|
|
\inmodule QtCreator
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2020-02-12 13:26:28 +01:00
|
|
|
\brief The ActionContainer class represents a menu or menu bar in \QC.
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-05-04 15:09:31 +02:00
|
|
|
You don't create instances of this class directly, but instead use the
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
\l{ActionManager::createMenu()}, \l{ActionManager::createMenuBar()} and
|
|
|
|
|
\l{ActionManager::createTouchBar()} functions.
|
2009-05-04 15:09:31 +02:00
|
|
|
Retrieve existing action containers for an ID with
|
|
|
|
|
\l{ActionManager::actionContainer()}.
|
|
|
|
|
|
|
|
|
|
Within a menu or menu bar you can group menus and items together by defining groups
|
|
|
|
|
(the order of the groups is defined by the order of the \l{ActionContainer::appendGroup()} calls), and
|
2020-02-12 13:26:28 +01:00
|
|
|
adding menus or actions to these groups. If no custom groups are defined, an action container
|
2009-05-04 15:09:31 +02:00
|
|
|
has three default groups \c{Core::Constants::G_DEFAULT_ONE}, \c{Core::Constants::G_DEFAULT_TWO}
|
|
|
|
|
and \c{Core::Constants::G_DEFAULT_THREE}.
|
|
|
|
|
|
2020-02-12 13:26:28 +01:00
|
|
|
You can specify whether the menu represented by this action container should
|
|
|
|
|
be automatically disabled or hidden whenever it only contains disabled items
|
2020-02-21 14:47:59 +01:00
|
|
|
and submenus by setting the corresponding \l setOnAllDisabledBehavior(). The
|
|
|
|
|
default is ActionContainer::Disable for menus, and ActionContainer::Show for
|
|
|
|
|
menu bars.
|
2008-12-02 12:01:29 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
2020-02-21 14:47:59 +01:00
|
|
|
\enum Core::ActionContainer::OnAllDisabledBehavior
|
2020-02-12 13:26:28 +01:00
|
|
|
Defines what happens when the represented menu is empty or contains only
|
|
|
|
|
disabled or invisible items.
|
2010-12-16 11:49:47 +01:00
|
|
|
\value Disable
|
2009-05-04 15:09:31 +02:00
|
|
|
The menu will be visible but disabled.
|
2010-12-16 11:49:47 +01:00
|
|
|
\value Hide
|
2020-02-12 13:26:28 +01:00
|
|
|
The menu will not be visible until the state of the subitems changes.
|
2010-12-16 11:49:47 +01:00
|
|
|
\value Show
|
|
|
|
|
The menu will still be visible and active.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
2020-02-21 14:47:59 +01:00
|
|
|
\fn Core::ActionContainer::setOnAllDisabledBehavior(OnAllDisabledBehavior behavior)
|
2010-12-16 11:49:47 +01:00
|
|
|
Defines the \a behavior of the menu represented by this action container for the case
|
|
|
|
|
whenever it only contains disabled items and submenus.
|
|
|
|
|
The default is ActionContainer::Disable for menus, and ActionContainer::Show for menu bars.
|
|
|
|
|
\sa ActionContainer::OnAllDisabledBehavior
|
|
|
|
|
\sa ActionContainer::onAllDisabledBehavior()
|
2008-12-02 12:01:29 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
2020-02-21 14:47:59 +01:00
|
|
|
\fn Core::ActionContainer::onAllDisabledBehavior() const
|
2020-02-12 13:26:28 +01:00
|
|
|
Returns the behavior of the menu represented by this action container for the case
|
2009-05-04 15:09:31 +02:00
|
|
|
whenever it only contains disabled items and submenus.
|
2010-12-16 11:49:47 +01:00
|
|
|
The default is ActionContainer::Disable for menus, and ActionContainer::Show for menu bars.
|
2020-02-21 14:47:59 +01:00
|
|
|
\sa OnAllDisabledBehavior
|
|
|
|
|
\sa setOnAllDisabledBehavior()
|
2008-12-02 12:01:29 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
2020-02-21 14:47:59 +01:00
|
|
|
\fn int Core::ActionContainer::id() const
|
2009-05-04 15:09:31 +02:00
|
|
|
\internal
|
2008-12-02 12:01:29 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
2020-02-21 14:47:59 +01:00
|
|
|
\fn QMenu *Core::ActionContainer::menu() const
|
2009-05-04 15:09:31 +02:00
|
|
|
Returns the QMenu instance that is represented by this action container, or
|
|
|
|
|
0 if this action container represents a menu bar.
|
2008-12-02 12:01:29 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
2020-02-21 14:47:59 +01:00
|
|
|
\fn QMenuBar *Core::ActionContainer::menuBar() const
|
2009-05-04 15:09:31 +02:00
|
|
|
Returns the QMenuBar instance that is represented by this action container, or
|
|
|
|
|
0 if this action container represents a menu.
|
2008-12-02 12:01:29 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
2020-06-26 13:59:38 +02:00
|
|
|
\fn QAction *Core::ActionContainer::insertLocation(Utils::Id group) const
|
2009-05-04 15:09:31 +02:00
|
|
|
Returns an action representing the \a group,
|
|
|
|
|
that could be used with \c{QWidget::insertAction}.
|
2008-12-02 12:01:29 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
2020-06-26 13:59:38 +02:00
|
|
|
\fn void Core::ActionContainer::appendGroup(Utils::Id group)
|
2020-02-12 13:26:28 +01:00
|
|
|
Adds \a group to the action container.
|
|
|
|
|
|
|
|
|
|
Use groups to segment your action container into logical parts. You can add
|
|
|
|
|
actions and menus directly into groups.
|
2009-05-04 15:09:31 +02:00
|
|
|
\sa addAction()
|
|
|
|
|
\sa addMenu()
|
2008-12-02 12:01:29 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
2020-06-26 13:59:38 +02:00
|
|
|
\fn void Core::ActionContainer::addAction(Core::Command *action, Utils::Id group = Id())
|
2009-05-04 15:09:31 +02:00
|
|
|
Add the \a action as a menu item to this action container. The action is added as the
|
|
|
|
|
last item of the specified \a group.
|
|
|
|
|
\sa appendGroup()
|
|
|
|
|
\sa addMenu()
|
2008-12-02 12:01:29 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
2020-06-26 13:59:38 +02:00
|
|
|
\fn void Core::ActionContainer::addMenu(Core::ActionContainer *menu, Utils::Id group = Utils::Id())
|
2009-05-04 15:09:31 +02:00
|
|
|
Add the \a menu as a submenu to this action container. The menu is added as the
|
|
|
|
|
last item of the specified \a group.
|
|
|
|
|
\sa appendGroup()
|
|
|
|
|
\sa addAction()
|
2008-12-02 12:01:29 +01:00
|
|
|
*/
|
|
|
|
|
|
2020-02-12 13:26:28 +01:00
|
|
|
/*!
|
2020-02-21 14:47:59 +01:00
|
|
|
\fn void Core::ActionContainer::addMenu(Core::ActionContainer *before, Core::ActionContainer *menu)
|
2020-02-12 13:26:28 +01:00
|
|
|
Add \a menu as a submenu to this action container before the menu specified
|
|
|
|
|
by \a before.
|
|
|
|
|
\sa appendGroup()
|
|
|
|
|
\sa addAction()
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
2020-02-21 14:47:59 +01:00
|
|
|
\fn Core::ActionContainer::clear()
|
2020-02-12 13:26:28 +01:00
|
|
|
|
|
|
|
|
Clears this menu and submenus from all actions and submenus. However, does
|
|
|
|
|
does not destroy the submenus and commands, just removes them from their
|
|
|
|
|
parents.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
2020-06-26 13:59:38 +02:00
|
|
|
\fn Core::ActionContainer::insertGroup(Utils::Id before, Utils::Id group)
|
2020-02-12 13:26:28 +01:00
|
|
|
|
|
|
|
|
Inserts \a group to the action container before the group specified by
|
|
|
|
|
\a before.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
2020-02-21 14:47:59 +01:00
|
|
|
\fn virtual Utils::TouchBar *Core::ActionContainer::touchBar() const
|
2020-02-12 13:26:28 +01:00
|
|
|
|
|
|
|
|
Returns the touch bar that is represented by this action container.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
2020-06-26 13:59:38 +02:00
|
|
|
\fn Core::ActionContainer::addSeparator(const Core::Context &context, Utils::Id group, QAction **outSeparator)
|
2020-02-12 13:26:28 +01:00
|
|
|
|
|
|
|
|
Adds a separator to the end of the given \a group to the action container,
|
|
|
|
|
which is enabled for a given \a context. Returns the created separator
|
|
|
|
|
action, \a outSeparator.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2009-01-14 12:25:54 +01:00
|
|
|
// ---------- ActionContainerPrivate ------------
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
/*!
|
2009-01-14 12:25:54 +01:00
|
|
|
\class Core::Internal::ActionContainerPrivate
|
2009-01-14 11:25:00 +01:00
|
|
|
\internal
|
2008-12-02 12:01:29 +01:00
|
|
|
*/
|
|
|
|
|
|
2023-09-01 14:30:35 +02:00
|
|
|
ActionContainerPrivate::ActionContainerPrivate(Id id, ActionManagerPrivate *actionManagerPrivate)
|
|
|
|
|
: m_onAllDisabledBehavior(Disable)
|
|
|
|
|
, m_id(id)
|
|
|
|
|
, m_actionManagerPrivate(actionManagerPrivate)
|
|
|
|
|
, m_updateRequested(false)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2011-11-11 12:16:20 +01:00
|
|
|
appendGroup(Constants::G_DEFAULT_ONE);
|
|
|
|
|
appendGroup(Constants::G_DEFAULT_TWO);
|
|
|
|
|
appendGroup(Constants::G_DEFAULT_THREE);
|
2010-11-12 13:45:13 +01:00
|
|
|
scheduleUpdate();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-12-16 11:49:47 +01:00
|
|
|
void ActionContainerPrivate::setOnAllDisabledBehavior(OnAllDisabledBehavior behavior)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-12-16 11:49:47 +01:00
|
|
|
m_onAllDisabledBehavior = behavior;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-12-16 11:49:47 +01:00
|
|
|
ActionContainer::OnAllDisabledBehavior ActionContainerPrivate::onAllDisabledBehavior() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-12-16 11:49:47 +01:00
|
|
|
return m_onAllDisabledBehavior;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2013-05-26 00:29:33 +02:00
|
|
|
void ActionContainerPrivate::appendGroup(Id groupId)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2011-01-20 14:24:44 +01:00
|
|
|
m_groups.append(Group(groupId));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2013-05-26 00:29:33 +02:00
|
|
|
void ActionContainerPrivate::insertGroup(Id before, Id groupId)
|
2012-02-17 08:55:17 +01:00
|
|
|
{
|
|
|
|
|
QList<Group>::iterator it = m_groups.begin();
|
|
|
|
|
while (it != m_groups.end()) {
|
|
|
|
|
if (it->id == before) {
|
|
|
|
|
m_groups.insert(it, Group(groupId));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
++it;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-26 00:29:33 +02:00
|
|
|
QList<Group>::const_iterator ActionContainerPrivate::findGroup(Id groupId) const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2011-01-20 14:24:44 +01:00
|
|
|
QList<Group>::const_iterator it = m_groups.constBegin();
|
|
|
|
|
while (it != m_groups.constEnd()) {
|
|
|
|
|
if (it->id == groupId)
|
|
|
|
|
break;
|
|
|
|
|
++it;
|
|
|
|
|
}
|
|
|
|
|
return it;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-05-26 00:29:33 +02:00
|
|
|
QAction *ActionContainerPrivate::insertLocation(Id groupId) const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2011-01-20 14:24:44 +01:00
|
|
|
QList<Group>::const_iterator it = findGroup(groupId);
|
2018-07-21 21:11:46 +02:00
|
|
|
QTC_ASSERT(it != m_groups.constEnd(), return nullptr);
|
2011-01-20 14:24:44 +01:00
|
|
|
return insertLocation(it);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
QAction *ActionContainerPrivate::actionForItem(QObject *item) const
|
|
|
|
|
{
|
|
|
|
|
if (auto cmd = qobject_cast<Command *>(item)) {
|
|
|
|
|
return cmd->action();
|
|
|
|
|
} else if (auto container = qobject_cast<ActionContainerPrivate *>(item)) {
|
|
|
|
|
if (container->containerAction())
|
|
|
|
|
return container->containerAction();
|
|
|
|
|
}
|
|
|
|
|
QTC_ASSERT(false, return nullptr);
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-20 14:24:44 +01:00
|
|
|
QAction *ActionContainerPrivate::insertLocation(QList<Group>::const_iterator group) const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2011-01-20 14:24:44 +01:00
|
|
|
if (group == m_groups.constEnd())
|
2018-07-21 21:11:46 +02:00
|
|
|
return nullptr;
|
2011-01-20 14:24:44 +01:00
|
|
|
++group;
|
|
|
|
|
while (group != m_groups.constEnd()) {
|
|
|
|
|
if (!group->items.isEmpty()) {
|
|
|
|
|
QObject *item = group->items.first();
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
QAction *action = actionForItem(item);
|
|
|
|
|
if (action)
|
|
|
|
|
return action;
|
2011-01-20 14:24:44 +01:00
|
|
|
}
|
|
|
|
|
++group;
|
|
|
|
|
}
|
2018-07-21 21:11:46 +02:00
|
|
|
return nullptr;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2013-05-26 00:29:33 +02:00
|
|
|
void ActionContainerPrivate::addAction(Command *command, Id groupId)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2011-01-20 14:24:44 +01:00
|
|
|
if (!canAddAction(command))
|
|
|
|
|
return;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-11-11 12:16:20 +01:00
|
|
|
const Id actualGroupId = groupId.isValid() ? groupId : Id(Constants::G_DEFAULT_TWO);
|
2011-01-20 14:24:44 +01:00
|
|
|
QList<Group>::const_iterator groupIt = findGroup(actualGroupId);
|
2011-11-11 12:16:20 +01:00
|
|
|
QTC_ASSERT(groupIt != m_groups.constEnd(), qDebug() << "Can't find group"
|
|
|
|
|
<< groupId.name() << "in container" << id().name(); return);
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
m_groups[groupIt - m_groups.constBegin()].items.append(command);
|
2016-02-02 09:10:54 +02:00
|
|
|
connect(command, &Command::activeStateChanged, this, &ActionContainerPrivate::scheduleUpdate);
|
|
|
|
|
connect(command, &QObject::destroyed, this, &ActionContainerPrivate::itemDestroyed);
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
|
|
|
|
|
QAction *beforeAction = insertLocation(groupIt);
|
|
|
|
|
insertAction(beforeAction, command);
|
|
|
|
|
|
2010-11-12 13:45:13 +01:00
|
|
|
scheduleUpdate();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2013-05-26 00:29:33 +02:00
|
|
|
void ActionContainerPrivate::addMenu(ActionContainer *menu, Id groupId)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2018-07-21 21:11:46 +02:00
|
|
|
auto containerPrivate = static_cast<ActionContainerPrivate *>(menu);
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
QTC_ASSERT(containerPrivate->canBeAddedToContainer(this), return);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-11-11 12:16:20 +01:00
|
|
|
const Id actualGroupId = groupId.isValid() ? groupId : Id(Constants::G_DEFAULT_TWO);
|
2011-01-20 14:24:44 +01:00
|
|
|
QList<Group>::const_iterator groupIt = findGroup(actualGroupId);
|
|
|
|
|
QTC_ASSERT(groupIt != m_groups.constEnd(), return);
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
m_groups[groupIt - m_groups.constBegin()].items.append(menu);
|
|
|
|
|
connect(menu, &QObject::destroyed, this, &ActionContainerPrivate::itemDestroyed);
|
|
|
|
|
|
2011-01-20 14:24:44 +01:00
|
|
|
QAction *beforeAction = insertLocation(groupIt);
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
insertMenu(beforeAction, menu);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-11-12 13:45:13 +01:00
|
|
|
scheduleUpdate();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2018-10-10 13:21:53 +02:00
|
|
|
void ActionContainerPrivate::addMenu(ActionContainer *before, ActionContainer *menu)
|
2011-06-28 19:58:19 +02:00
|
|
|
{
|
2018-07-21 21:11:46 +02:00
|
|
|
auto containerPrivate = static_cast<ActionContainerPrivate *>(menu);
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
QTC_ASSERT(containerPrivate->canBeAddedToContainer(this), return);
|
2011-06-28 19:58:19 +02:00
|
|
|
|
2019-07-24 13:43:54 +02:00
|
|
|
for (Group &group : m_groups) {
|
2018-10-10 13:21:53 +02:00
|
|
|
const int insertionPoint = group.items.indexOf(before);
|
|
|
|
|
if (insertionPoint >= 0) {
|
|
|
|
|
group.items.insert(insertionPoint, menu);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-02-02 09:10:54 +02:00
|
|
|
connect(menu, &QObject::destroyed, this, &ActionContainerPrivate::itemDestroyed);
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
|
|
|
|
|
auto beforePrivate = static_cast<ActionContainerPrivate *>(before);
|
|
|
|
|
QAction *beforeAction = beforePrivate->containerAction();
|
|
|
|
|
if (beforeAction)
|
|
|
|
|
insertMenu(beforeAction, menu);
|
|
|
|
|
|
2011-06-28 19:58:19 +02:00
|
|
|
scheduleUpdate();
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-26 00:29:33 +02:00
|
|
|
Command *ActionContainerPrivate::addSeparator(const Context &context, Id group, QAction **outSeparator)
|
2012-06-05 14:22:20 +02:00
|
|
|
{
|
|
|
|
|
static int separatorIdCount = 0;
|
2018-07-21 21:11:46 +02:00
|
|
|
auto separator = new QAction(this);
|
2012-06-05 14:22:20 +02:00
|
|
|
separator->setSeparator(true);
|
2013-01-15 13:28:17 +01:00
|
|
|
Id sepId = id().withSuffix(".Separator.").withSuffix(++separatorIdCount);
|
|
|
|
|
Command *cmd = ActionManager::registerAction(separator, sepId, context);
|
2012-06-05 14:22:20 +02:00
|
|
|
addAction(cmd, group);
|
|
|
|
|
if (outSeparator)
|
|
|
|
|
*outSeparator = separator;
|
|
|
|
|
return cmd;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-21 10:58:06 +01:00
|
|
|
void ActionContainerPrivate::clear()
|
|
|
|
|
{
|
2019-07-24 13:43:54 +02:00
|
|
|
for (Group &group : m_groups) {
|
2022-10-07 14:46:06 +02:00
|
|
|
for (QObject *item : std::as_const(group.items)) {
|
2018-07-21 21:11:46 +02:00
|
|
|
if (auto command = qobject_cast<Command *>(item)) {
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
removeAction(command);
|
2016-02-02 09:10:54 +02:00
|
|
|
disconnect(command, &Command::activeStateChanged,
|
|
|
|
|
this, &ActionContainerPrivate::scheduleUpdate);
|
|
|
|
|
disconnect(command, &QObject::destroyed, this, &ActionContainerPrivate::itemDestroyed);
|
2018-07-21 21:11:46 +02:00
|
|
|
} else if (auto container = qobject_cast<ActionContainer *>(item)) {
|
2011-01-21 10:58:06 +01:00
|
|
|
container->clear();
|
2016-02-02 09:10:54 +02:00
|
|
|
disconnect(container, &QObject::destroyed,
|
|
|
|
|
this, &ActionContainerPrivate::itemDestroyed);
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
removeMenu(container);
|
2011-01-21 10:58:06 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
group.items.clear();
|
|
|
|
|
}
|
|
|
|
|
scheduleUpdate();
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-21 13:25:04 +02:00
|
|
|
void ActionContainerPrivate::itemDestroyed(QObject *sender)
|
2011-01-20 15:28:34 +01:00
|
|
|
{
|
2019-07-24 13:43:54 +02:00
|
|
|
for (Group &group : m_groups) {
|
2022-07-21 13:25:04 +02:00
|
|
|
if (group.items.removeAll(sender) > 0)
|
2011-01-20 15:28:34 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-11 12:16:20 +01:00
|
|
|
Id ActionContainerPrivate::id() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2011-01-20 14:24:44 +01:00
|
|
|
return m_id;
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-01-20 14:24:44 +01:00
|
|
|
QMenu *ActionContainerPrivate::menu() const
|
|
|
|
|
{
|
2018-07-21 21:11:46 +02:00
|
|
|
return nullptr;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2011-01-20 14:24:44 +01:00
|
|
|
QMenuBar *ActionContainerPrivate::menuBar() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2018-07-21 21:11:46 +02:00
|
|
|
return nullptr;
|
2011-01-20 14:24:44 +01:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
TouchBar *ActionContainerPrivate::touchBar() const
|
|
|
|
|
{
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-10 00:59:50 +01:00
|
|
|
bool ActionContainerPrivate::canAddAction(Command *action)
|
2011-01-20 14:24:44 +01:00
|
|
|
{
|
2012-01-27 07:52:03 -05:00
|
|
|
return action && action->action();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-04-22 17:36:09 +02:00
|
|
|
void ActionContainerPrivate::scheduleUpdate()
|
|
|
|
|
{
|
2023-09-01 14:30:35 +02:00
|
|
|
m_actionManagerPrivate->scheduleContainerUpdate(this);
|
2010-04-22 17:36:09 +02:00
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
// ---------- MenuActionContainer ------------
|
|
|
|
|
|
|
|
|
|
/*!
|
2009-01-14 11:25:00 +01:00
|
|
|
\class Core::Internal::MenuActionContainer
|
|
|
|
|
\internal
|
2008-12-02 12:01:29 +01:00
|
|
|
*/
|
|
|
|
|
|
2023-09-01 14:30:35 +02:00
|
|
|
MenuActionContainer::MenuActionContainer(Id id, ActionManagerPrivate *actionManagerPrivate)
|
|
|
|
|
: ActionContainerPrivate(id, actionManagerPrivate)
|
|
|
|
|
, m_menu(new QMenu)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2015-01-06 14:00:34 +01:00
|
|
|
m_menu->setObjectName(id.toString());
|
2018-11-07 10:47:12 +01:00
|
|
|
m_menu->menuAction()->setMenuRole(QAction::NoRole);
|
2010-12-16 11:49:47 +01:00
|
|
|
setOnAllDisabledBehavior(Disable);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2015-01-06 14:00:34 +01:00
|
|
|
MenuActionContainer::~MenuActionContainer()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2015-01-06 14:00:34 +01:00
|
|
|
delete m_menu;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QMenu *MenuActionContainer::menu() const
|
|
|
|
|
{
|
|
|
|
|
return m_menu;
|
|
|
|
|
}
|
|
|
|
|
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
QAction *MenuActionContainer::containerAction() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
return m_menu->menuAction();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
void MenuActionContainer::insertAction(QAction *before, Command *command)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
m_menu->insertAction(before, command->action());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MenuActionContainer::insertMenu(QAction *before, ActionContainer *container)
|
|
|
|
|
{
|
|
|
|
|
QMenu *menu = container->menu();
|
|
|
|
|
QTC_ASSERT(menu, return);
|
2018-06-14 15:04:52 +02:00
|
|
|
menu->setParent(m_menu, menu->windowFlags()); // work around issues with Qt Wayland (QTBUG-68636)
|
2008-12-02 12:01:29 +01:00
|
|
|
m_menu->insertMenu(before, menu);
|
|
|
|
|
}
|
|
|
|
|
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
void MenuActionContainer::removeAction(Command *command)
|
2011-01-21 10:58:06 +01:00
|
|
|
{
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
m_menu->removeAction(command->action());
|
2011-01-21 10:58:06 +01:00
|
|
|
}
|
|
|
|
|
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
void MenuActionContainer::removeMenu(ActionContainer *container)
|
2011-01-21 10:58:06 +01:00
|
|
|
{
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
QMenu *menu = container->menu();
|
|
|
|
|
QTC_ASSERT(menu, return);
|
2011-01-21 10:58:06 +01:00
|
|
|
m_menu->removeAction(menu->menuAction());
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-01 14:30:35 +02:00
|
|
|
bool MenuActionContainer::update()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-12-16 11:49:47 +01:00
|
|
|
if (onAllDisabledBehavior() == Show)
|
2008-12-02 12:01:29 +01:00
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
bool hasitems = false;
|
2010-06-28 17:28:10 +02:00
|
|
|
QList<QAction *> actions = m_menu->actions();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2022-10-07 14:46:06 +02:00
|
|
|
for (const Group &group : std::as_const(m_groups)) {
|
|
|
|
|
for (QObject *item : std::as_const(group.items)) {
|
2018-07-21 21:11:46 +02:00
|
|
|
if (auto container = qobject_cast<ActionContainerPrivate*>(item)) {
|
2011-01-20 14:24:44 +01:00
|
|
|
actions.removeAll(container->menu()->menuAction());
|
|
|
|
|
if (container == this) {
|
2011-12-22 14:44:14 +01:00
|
|
|
QByteArray warning = Q_FUNC_INFO + QByteArray(" container '");
|
|
|
|
|
if (this->menu())
|
|
|
|
|
warning += this->menu()->title().toLocal8Bit();
|
|
|
|
|
warning += "' contains itself as subcontainer";
|
|
|
|
|
qWarning("%s", warning.constData());
|
2011-01-20 14:24:44 +01:00
|
|
|
continue;
|
|
|
|
|
}
|
2023-09-01 14:30:35 +02:00
|
|
|
if (container->update()) {
|
2011-01-20 14:24:44 +01:00
|
|
|
hasitems = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2018-07-21 21:11:46 +02:00
|
|
|
} else if (auto command = qobject_cast<Command *>(item)) {
|
2011-01-20 14:24:44 +01:00
|
|
|
actions.removeAll(command->action());
|
2022-09-14 15:34:49 +02:00
|
|
|
if (command->isActive()
|
|
|
|
|
&& !(HostOsInfo::isMacHost()
|
|
|
|
|
&& command->action()->menuRole() == QAction::ApplicationSpecificRole)) {
|
2011-01-20 14:24:44 +01:00
|
|
|
hasitems = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
QTC_ASSERT(false, continue);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
2011-01-20 14:24:44 +01:00
|
|
|
if (hasitems)
|
|
|
|
|
break;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2010-06-28 17:28:10 +02:00
|
|
|
if (!hasitems) {
|
|
|
|
|
// look if there were actions added that we don't control and check if they are enabled
|
2022-10-07 14:46:06 +02:00
|
|
|
for (const QAction *action : std::as_const(actions)) {
|
2010-06-28 17:28:10 +02:00
|
|
|
if (!action->isSeparator() && action->isEnabled()) {
|
|
|
|
|
hasitems = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-12-16 11:49:47 +01:00
|
|
|
if (onAllDisabledBehavior() == Hide)
|
2010-11-12 13:45:13 +01:00
|
|
|
m_menu->menuAction()->setVisible(hasitems);
|
2010-12-16 11:49:47 +01:00
|
|
|
else if (onAllDisabledBehavior() == Disable)
|
2010-11-12 13:45:13 +01:00
|
|
|
m_menu->menuAction()->setEnabled(hasitems);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
return hasitems;
|
|
|
|
|
}
|
|
|
|
|
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
bool MenuActionContainer::canBeAddedToContainer(ActionContainerPrivate *container) const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
return qobject_cast<MenuActionContainer *>(container)
|
|
|
|
|
|| qobject_cast<MenuBarActionContainer *>(container);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ---------- MenuBarActionContainer ------------
|
|
|
|
|
|
|
|
|
|
/*!
|
2009-01-14 11:25:00 +01:00
|
|
|
\class Core::Internal::MenuBarActionContainer
|
|
|
|
|
\internal
|
2008-12-02 12:01:29 +01:00
|
|
|
*/
|
|
|
|
|
|
2023-09-01 14:30:35 +02:00
|
|
|
MenuBarActionContainer::MenuBarActionContainer(Id id, ActionManagerPrivate *actionManagerPrivate)
|
|
|
|
|
: ActionContainerPrivate(id, actionManagerPrivate)
|
|
|
|
|
, m_menuBar(nullptr)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-12-16 11:49:47 +01:00
|
|
|
setOnAllDisabledBehavior(Show);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MenuBarActionContainer::setMenuBar(QMenuBar *menuBar)
|
|
|
|
|
{
|
|
|
|
|
m_menuBar = menuBar;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QMenuBar *MenuBarActionContainer::menuBar() const
|
|
|
|
|
{
|
|
|
|
|
return m_menuBar;
|
|
|
|
|
}
|
|
|
|
|
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
QAction *MenuBarActionContainer::containerAction() const
|
|
|
|
|
{
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MenuBarActionContainer::insertAction(QAction *before, Command *command)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
m_menuBar->insertAction(before, command->action());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
void MenuBarActionContainer::insertMenu(QAction *before, ActionContainer *container)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
QMenu *menu = container->menu();
|
|
|
|
|
QTC_ASSERT(menu, return);
|
2018-06-14 15:04:52 +02:00
|
|
|
menu->setParent(m_menuBar, menu->windowFlags()); // work around issues with Qt Wayland (QTBUG-68636)
|
2008-12-02 12:01:29 +01:00
|
|
|
m_menuBar->insertMenu(before, menu);
|
|
|
|
|
}
|
|
|
|
|
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
void MenuBarActionContainer::removeAction(Command *command)
|
2011-01-21 10:58:06 +01:00
|
|
|
{
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
m_menuBar->removeAction(command->action());
|
2011-01-21 10:58:06 +01:00
|
|
|
}
|
|
|
|
|
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
void MenuBarActionContainer::removeMenu(ActionContainer *container)
|
2011-01-21 10:58:06 +01:00
|
|
|
{
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
QMenu *menu = container->menu();
|
|
|
|
|
QTC_ASSERT(menu, return);
|
2011-01-21 10:58:06 +01:00
|
|
|
m_menuBar->removeAction(menu->menuAction());
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-01 14:30:35 +02:00
|
|
|
bool MenuBarActionContainer::update()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-12-16 11:49:47 +01:00
|
|
|
if (onAllDisabledBehavior() == Show)
|
2008-12-02 12:01:29 +01:00
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
bool hasitems = false;
|
|
|
|
|
QList<QAction *> actions = m_menuBar->actions();
|
|
|
|
|
for (int i=0; i<actions.size(); ++i) {
|
|
|
|
|
if (actions.at(i)->isVisible()) {
|
|
|
|
|
hasitems = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-16 11:49:47 +01:00
|
|
|
if (onAllDisabledBehavior() == Hide)
|
2008-12-02 12:01:29 +01:00
|
|
|
m_menuBar->setVisible(hasitems);
|
2010-12-16 11:49:47 +01:00
|
|
|
else if (onAllDisabledBehavior() == Disable)
|
2008-12-02 12:01:29 +01:00
|
|
|
m_menuBar->setEnabled(hasitems);
|
|
|
|
|
|
|
|
|
|
return hasitems;
|
|
|
|
|
}
|
2009-01-14 11:25:00 +01:00
|
|
|
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
bool MenuBarActionContainer::canBeAddedToContainer(ActionContainerPrivate *) const
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ---------- TouchBarActionContainer ------------
|
|
|
|
|
|
|
|
|
|
const char ID_PREFIX[] = "io.qt.qtcreator.";
|
|
|
|
|
|
2023-09-01 14:30:35 +02:00
|
|
|
TouchBarActionContainer::TouchBarActionContainer(Id id,
|
|
|
|
|
ActionManagerPrivate *actionManagerPrivate,
|
|
|
|
|
const QIcon &icon,
|
|
|
|
|
const QString &text)
|
|
|
|
|
: ActionContainerPrivate(id, actionManagerPrivate)
|
|
|
|
|
, m_touchBar(std::make_unique<TouchBar>(id.withPrefix(ID_PREFIX).name(), icon, text))
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TouchBarActionContainer::~TouchBarActionContainer() = default;
|
|
|
|
|
|
|
|
|
|
TouchBar *TouchBarActionContainer::touchBar() const
|
|
|
|
|
{
|
|
|
|
|
return m_touchBar.get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QAction *TouchBarActionContainer::containerAction() const
|
|
|
|
|
{
|
|
|
|
|
return m_touchBar->touchBarAction();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QAction *TouchBarActionContainer::actionForItem(QObject *item) const
|
|
|
|
|
{
|
|
|
|
|
if (Command *command = qobject_cast<Command *>(item))
|
|
|
|
|
return command->touchBarAction();
|
|
|
|
|
return ActionContainerPrivate::actionForItem(item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TouchBarActionContainer::insertAction(QAction *before, Command *command)
|
|
|
|
|
{
|
|
|
|
|
m_touchBar->insertAction(before,
|
|
|
|
|
command->id().withPrefix(ID_PREFIX).name(),
|
|
|
|
|
command->touchBarAction());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TouchBarActionContainer::insertMenu(QAction *before, ActionContainer *container)
|
|
|
|
|
{
|
|
|
|
|
TouchBar *touchBar = container->touchBar();
|
|
|
|
|
QTC_ASSERT(touchBar, return);
|
|
|
|
|
m_touchBar->insertTouchBar(before, touchBar);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TouchBarActionContainer::removeAction(Command *command)
|
|
|
|
|
{
|
|
|
|
|
m_touchBar->removeAction(command->touchBarAction());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TouchBarActionContainer::removeMenu(ActionContainer *container)
|
|
|
|
|
{
|
|
|
|
|
TouchBar *touchBar = container->touchBar();
|
|
|
|
|
QTC_ASSERT(touchBar, return);
|
|
|
|
|
m_touchBar->removeTouchBar(touchBar);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TouchBarActionContainer::canBeAddedToContainer(ActionContainerPrivate *container) const
|
|
|
|
|
{
|
|
|
|
|
return qobject_cast<TouchBarActionContainer *>(container);
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-01 14:30:35 +02:00
|
|
|
bool TouchBarActionContainer::update()
|
2009-01-14 11:25:00 +01:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-16 10:52:41 +02:00
|
|
|
} // namespace Internal
|
2015-02-26 13:58:00 +01:00
|
|
|
|
2020-02-12 13:26:28 +01:00
|
|
|
/*!
|
|
|
|
|
Adds a separator to the end of \a group to the action container.
|
|
|
|
|
|
|
|
|
|
Returns the created separator.
|
|
|
|
|
*/
|
2015-02-26 13:58:00 +01:00
|
|
|
Command *ActionContainer::addSeparator(Id group)
|
|
|
|
|
{
|
|
|
|
|
static const Context context(Constants::C_GLOBAL);
|
|
|
|
|
return addSeparator(context, group);
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-16 10:52:41 +02:00
|
|
|
} // namespace Core
|