Files
qt-creator/src/plugins/texteditor/texteditoractionhandler.h

66 lines
1.7 KiB
C
Raw Normal View History

// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
2008-12-02 16:19:05 +01:00
#pragma once
2008-12-02 12:01:29 +01:00
#include "texteditor_global.h"
#include <utils/id.h>
#include <QObject>
2008-12-02 12:01:29 +01:00
#include <functional>
namespace Core {
class IEditor;
}
2008-12-02 12:01:29 +01:00
namespace TextEditor {
class TextEditorWidget;
2008-12-02 12:01:29 +01:00
namespace Internal { class TextEditorActionHandlerPrivate; }
2008-12-02 12:01:29 +01:00
// Redirects slots from global actions to the respective editor.
class TEXTEDITOR_EXPORT TextEditorActionHandler final
2008-12-02 12:01:29 +01:00
{
TextEditorActionHandler(const TextEditorActionHandler &) = delete;
TextEditorActionHandler &operator=(const TextEditorActionHandler &) = delete;
2008-12-02 12:01:29 +01:00
public:
enum OptionalActionsMask {
None = 0,
Format = 1,
UnCommentSelection = 2,
UnCollapseAll = 4,
FollowSymbolUnderCursor = 8,
FollowTypeUnderCursor = 16,
JumpToFileUnderCursor = 32,
RenameSymbol = 64,
FindUsage = 128,
CallHierarchy = 256
2008-12-02 12:01:29 +01:00
};
using TextEditorWidgetResolver = std::function<TextEditorWidget *(Core::IEditor *)>;
2008-12-02 12:01:29 +01:00
TextEditorActionHandler(Utils::Id editorId,
Utils::Id contextId,
uint optionalActions = None,
const TextEditorWidgetResolver &resolver = {});
uint optionalActions() const;
~TextEditorActionHandler();
void updateCurrentEditor();
void updateActions();
using Predicate = std::function<bool(Core::IEditor *editor)>;
void setCanUndoCallback(const Predicate &callback);
void setCanRedoCallback(const Predicate &callback);
private:
Internal::TextEditorActionHandlerPrivate *d;
2008-12-02 12:01:29 +01:00
};
} // namespace TextEditor