aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor/codecchooser.h
blob: a56cb38660d560d95b8c0995382ddc1c5516ea7e (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
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include "texteditor_global.h"

#include <QComboBox>

QT_BEGIN_NAMESPACE
class QTextCodec;
QT_END_NAMESPACE

namespace TextEditor {

class TEXTEDITOR_EXPORT CodecChooser : public QComboBox
{
    Q_OBJECT

public:
    enum class Filter { All, SingleByte };
    explicit CodecChooser(Filter filter = Filter::All);
    void prependNone();
    QTextCodec *currentCodec() const;
    QTextCodec *codecAt(int index) const;
    void setAssignedCodec(QTextCodec *codec, const QString &name = {});
    QByteArray assignedCodecName() const;

signals:
    void codecChanged(QTextCodec *codec);

private:
    QList<QTextCodec *> m_codecs;
};

} // namespace TextEditor