1 /*
2  * This file is part of KMail.
3  * SPDX-FileCopyrightText: 2009 Constantin Berzan <exit3219@gmail.com>
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  */
7 
8 #pragma once
9 
10 // Qt
11 #include <QVector>
12 
13 // KDE
14 #include <KCodecAction>
15 
16 // TODO since the reader is now in a separate lib, we can probably have this
17 // class for the composer only.  The reader can use KCodecAction directly anyway.
18 class CodecAction : public KCodecAction
19 {
20     Q_OBJECT
21 
22 public:
23     enum Mode {
24         ComposerMode, ///< Used in the composer.  Show a 'Default' menu entry,
25         ///  which uses one of the preferred codecs.  Also show 'us-ascii'.
26         ReaderMode ///< Used in the reader.  Show an 'Auto' entry for each language,
27         ///  and detect any charset.
28     };
29 
30     explicit CodecAction(Mode mode, QObject *parent = nullptr);
31     ~CodecAction() override;
32 
33     /**
34       The name of the charset, if a specific encoding was selected, or a list
35       containing the names of the preferred charsets, if 'Default' was selected in Composer
36       mode.  In Reader mode it probably makes more sense to use KCodecAction::currentCodec()
37       and KCodecAction::currentAutoDetectScript().
38     */
39     Q_REQUIRED_RESULT QVector<QByteArray> mimeCharsets() const;
40 
41     void setAutoCharset();
42     void setCharset(const QByteArray &charset);
43 
44 private:
45     const CodecAction::Mode mMode;
46 };
47 
48