aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor/texteditoractionhandler.h
blob: c04a791f9f3d732c1e4de7d70cc0592eacfc41e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0

#pragma once

#include "texteditor_global.h"

#include <utils/id.h>

#include <QObject>

#include <functional>

namespace Core {
class IEditor;
}

namespace TextEditor {
class TextEditorWidget;

namespace Internal { class TextEditorActionHandlerPrivate; }

// Redirects slots from global actions to the respective editor.

class TEXTEDITOR_EXPORT TextEditorActionHandler final
{
    TextEditorActionHandler(const TextEditorActionHandler &) = delete;
    TextEditorActionHandler &operator=(const TextEditorActionHandler &) = delete;

public:
    enum OptionalActionsMask {
        None = 0,
        Format = 1,
        UnCommentSelection = 2,
        UnCollapseAll = 4,
        FollowSymbolUnderCursor = 8,
        JumpToFileUnderCursor = 16,
        RenameSymbol = 32,
    };
    using TextEditorWidgetResolver = std::function<TextEditorWidget *(Core::IEditor *)>;

    TextEditorActionHandler(Utils::Id editorId,
                            Utils::Id contextId,
                            uint optionalActions = None,
                            const TextEditorWidgetResolver &resolver = {});

    uint optionalActions() const;
    ~TextEditorActionHandler();

private:
    Internal::TextEditorActionHandlerPrivate *d;
};

} // namespace TextEditor