2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#include <coreplugin/core_global.h>
|
|
|
|
|
|
2015-07-22 23:26:40 +03:00
|
|
|
#include <utils/hostosinfo.h>
|
2020-06-26 13:59:38 +02:00
|
|
|
#include <utils/id.h>
|
2015-07-22 23:26:40 +03:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QObject>
|
2009-10-01 16:38:08 +02:00
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QAction;
|
|
|
|
|
class QKeySequence;
|
2014-10-01 17:52:57 +02:00
|
|
|
class QToolButton;
|
2009-10-01 16:38:08 +02:00
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
namespace Core {
|
2022-05-31 09:43:56 +02:00
|
|
|
namespace Internal {
|
|
|
|
|
class ActionManagerPrivate;
|
|
|
|
|
class CommandPrivate;
|
|
|
|
|
} // namespace Internal
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2022-05-31 09:43:56 +02:00
|
|
|
class ActionManager;
|
2010-06-25 12:56:16 +02:00
|
|
|
class Context;
|
|
|
|
|
|
2018-02-02 13:39:18 +01:00
|
|
|
constexpr bool useMacShortcuts = Utils::HostOsInfo::isMacHost();
|
2012-05-23 13:25:51 +02:00
|
|
|
|
2009-01-14 13:17:53 +01:00
|
|
|
class CORE_EXPORT Command : public QObject
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
enum CommandAttribute {
|
2011-01-18 13:25:42 +01:00
|
|
|
CA_Hide = 1,
|
|
|
|
|
CA_UpdateText = 2,
|
|
|
|
|
CA_UpdateIcon = 4,
|
2011-02-09 15:23:48 +01:00
|
|
|
CA_NonConfigurable = 8
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
2011-01-12 09:45:19 +01:00
|
|
|
Q_DECLARE_FLAGS(CommandAttributes, CommandAttribute)
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2022-05-31 09:43:56 +02:00
|
|
|
~Command();
|
|
|
|
|
|
|
|
|
|
void setDefaultKeySequence(const QKeySequence &key);
|
|
|
|
|
void setDefaultKeySequences(const QList<QKeySequence> &keys);
|
|
|
|
|
QList<QKeySequence> defaultKeySequences() const;
|
|
|
|
|
QList<QKeySequence> keySequences() const;
|
|
|
|
|
QKeySequence keySequence() const;
|
2012-01-06 17:13:18 +01:00
|
|
|
// explicitly set the description (used e.g. in shortcut settings)
|
|
|
|
|
// default is to use the action text for actions, or the whatsThis for shortcuts,
|
|
|
|
|
// or, as a last fall back if these are empty, the command ID string
|
|
|
|
|
// override the default e.g. if the text is context dependent and contains file names etc
|
2022-05-31 09:43:56 +02:00
|
|
|
void setDescription(const QString &text);
|
|
|
|
|
QString description() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2022-05-31 09:43:56 +02:00
|
|
|
Utils::Id id() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2022-05-31 09:43:56 +02:00
|
|
|
QAction *action() const;
|
|
|
|
|
Context context() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2022-05-31 09:43:56 +02:00
|
|
|
void setAttribute(CommandAttribute attr);
|
|
|
|
|
void removeAttribute(CommandAttribute attr);
|
|
|
|
|
bool hasAttribute(CommandAttribute attr) const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2022-05-31 09:43:56 +02:00
|
|
|
bool isActive() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2022-05-31 09:43:56 +02:00
|
|
|
void setKeySequences(const QList<QKeySequence> &keys);
|
|
|
|
|
QString stringWithAppendedShortcut(const QString &str) const;
|
2014-11-04 14:58:48 +01:00
|
|
|
void augmentActionWithShortcutToolTip(QAction *action) const;
|
2014-10-01 17:52:57 +02:00
|
|
|
static QToolButton *toolButtonWithAppendedShortcut(QAction *action, Command *cmd);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2022-05-31 09:43:56 +02:00
|
|
|
bool isScriptable() const;
|
|
|
|
|
bool isScriptable(const Context &) const;
|
2010-12-20 10:35:30 +01:00
|
|
|
|
2022-05-31 09:43:56 +02:00
|
|
|
void setTouchBarText(const QString &text);
|
|
|
|
|
QString touchBarText() const;
|
|
|
|
|
void setTouchBarIcon(const QIcon &icon);
|
|
|
|
|
QIcon touchBarIcon() const;
|
|
|
|
|
QAction *touchBarAction() const;
|
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
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
signals:
|
|
|
|
|
void keySequenceChanged();
|
2010-04-22 17:36:09 +02:00
|
|
|
void activeStateChanged();
|
2022-05-31 09:43:56 +02:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
friend class ActionManager;
|
|
|
|
|
friend class Internal::ActionManagerPrivate;
|
|
|
|
|
|
|
|
|
|
Command(Utils::Id id);
|
|
|
|
|
|
|
|
|
|
Internal::CommandPrivate *d;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Core
|
|
|
|
|
|
2011-01-12 09:45:19 +01:00
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(Core::Command::CommandAttributes)
|