File indexing completed on 2024-02-25 03:58:28

0001 /*
0002     SPDX-FileCopyrightText: 2003 Jason Keirstead <jason@keirstead.org>
0003     SPDX-FileCopyrightText: 2003-2006 Michel Hermier <michel.hermier@gmail.com>
0004     SPDX-FileCopyrightText: 2007 Nick Shaforostoff <shafff@ukr.net>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 #ifndef KCODECACTION_H
0009 #define KCODECACTION_H
0010 
0011 #include <kconfigwidgets_export.h>
0012 
0013 #include <KSelectAction>
0014 #include <memory>
0015 
0016 /**
0017  *  @class KCodecAction kcodecaction.h KCodecAction
0018  *
0019  *  @short Action for selecting one of several text codecs..
0020  *
0021  *  This action shows up a submenu with a list of the available codecs on the system.
0022  */
0023 class KCONFIGWIDGETS_EXPORT KCodecAction : public KSelectAction
0024 {
0025     Q_OBJECT
0026 
0027     Q_PROPERTY(QString codecName READ currentCodecName WRITE setCurrentCodec)
0028 
0029 public:
0030     explicit KCodecAction(QObject *parent, bool showAutoOptions = false);
0031 
0032     KCodecAction(const QString &text, QObject *parent, bool showAutoOptions = false);
0033 
0034     KCodecAction(const QIcon &icon, const QString &text, QObject *parent, bool showAutoOptions = false);
0035 
0036     ~KCodecAction() override;
0037 
0038 public:
0039     QString currentCodecName() const;
0040     bool setCurrentCodec(const QString &codecName);
0041 
0042 Q_SIGNALS:
0043     /**
0044      * Emitted when a codec was selected
0045      *
0046      * @param name the name of the selected encoding.
0047      *
0048      * Note that textTriggered(const QString &) is emitted too (as defined in KSelectAction).
0049      *
0050      * @since 5.103
0051      */
0052     void codecNameTriggered(const QByteArray &name);
0053 
0054     /**
0055      * Emitted when the 'Default' codec action is triggered.
0056      */
0057     void defaultItemTriggered();
0058 
0059 protected Q_SLOTS:
0060     void slotActionTriggered(QAction *) override;
0061 
0062 protected:
0063     using KSelectAction::actionTriggered;
0064 
0065 private:
0066     friend class KCodecActionPrivate;
0067     std::unique_ptr<class KCodecActionPrivate> const d;
0068 };
0069 
0070 #endif