2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-01-12 09:45:19 +01:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-01-12 09:45:19 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-01-12 09:45:19 +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:58:39 +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.
|
2011-01-12 09:45:19 +01:00
|
|
|
**
|
2016-01-15 14:58:39 +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.
|
2011-01-12 09:45:19 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-01-12 09:45:19 +01:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2011-01-12 09:45:19 +01:00
|
|
|
|
|
|
|
|
#include "utils_global.h"
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QPointer>
|
|
|
|
|
#include <QAction>
|
2011-01-12 09:45:19 +01:00
|
|
|
|
|
|
|
|
namespace Utils {
|
|
|
|
|
|
|
|
|
|
class QTCREATOR_UTILS_EXPORT ProxyAction : public QAction
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
enum Attribute {
|
2011-01-31 15:16:52 +01:00
|
|
|
Hide = 0x01,
|
|
|
|
|
UpdateText = 0x02,
|
|
|
|
|
UpdateIcon = 0x04
|
2011-01-12 09:45:19 +01:00
|
|
|
};
|
|
|
|
|
Q_DECLARE_FLAGS(Attributes, Attribute)
|
|
|
|
|
|
2018-05-07 17:33:02 +02:00
|
|
|
explicit ProxyAction(QObject *parent = nullptr);
|
2011-01-12 09:45:19 +01:00
|
|
|
|
|
|
|
|
void initialize(QAction *action);
|
|
|
|
|
|
|
|
|
|
void setAction(QAction *action);
|
|
|
|
|
QAction *action() const;
|
|
|
|
|
|
|
|
|
|
bool shortcutVisibleInToolTip() const;
|
|
|
|
|
void setShortcutVisibleInToolTip(bool visible);
|
|
|
|
|
|
|
|
|
|
void setAttribute(Attribute attribute);
|
|
|
|
|
void removeAttribute(Attribute attribute);
|
|
|
|
|
bool hasAttribute(Attribute attribute);
|
|
|
|
|
|
|
|
|
|
static QString stringWithAppendedShortcut(const QString &str, const QKeySequence &shortcut);
|
2016-04-25 12:25:10 +02:00
|
|
|
static ProxyAction *proxyActionWithIcon(QAction *original, const QIcon &newIcon);
|
2011-01-12 09:45:19 +01:00
|
|
|
|
2016-06-28 22:31:02 +03:00
|
|
|
private:
|
2011-01-12 09:45:19 +01:00
|
|
|
void actionChanged();
|
|
|
|
|
void updateState();
|
|
|
|
|
void updateToolTipWithKeySequence();
|
|
|
|
|
void disconnectAction();
|
|
|
|
|
void connectAction();
|
|
|
|
|
void update(QAction *action, bool initialize);
|
|
|
|
|
|
2018-11-11 20:37:40 +02:00
|
|
|
QPointer<QAction> m_action;
|
|
|
|
|
Attributes m_attributes;
|
2018-07-23 10:45:40 +02:00
|
|
|
bool m_showShortcut = false;
|
2011-01-12 09:45:19 +01:00
|
|
|
QString m_toolTip;
|
2018-07-23 10:45:40 +02:00
|
|
|
bool m_block = false;
|
2011-01-12 09:45:19 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Utils
|
|
|
|
|
|
|
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(Utils::ProxyAction::Attributes)
|