File indexing completed on 2024-12-22 05:01:10

0001 /*
0002     xfaceconfigurator.cpp
0003 
0004     KMail, the KDE mail client.
0005     SPDX-FileCopyrightText: 2004 Jakob Schröter <js@camaya.net>
0006     SPDX-FileCopyrightText: 2002 the KMail authors.
0007     See file AUTHORS for details
0008 
0009     SPDX-License-Identifier: GPL-2.0-only
0010 */
0011 
0012 #pragma once
0013 
0014 #include <QProcess>
0015 #include <QWidget>
0016 
0017 namespace Ui
0018 {
0019 class XFaceConfigurator;
0020 }
0021 
0022 namespace KMail
0023 {
0024 class XFaceConfigurator : public QWidget
0025 {
0026     Q_OBJECT
0027 public:
0028     enum Mode {
0029         DontSend,
0030         SendFace,
0031         SendXFace,
0032         SendBoth,
0033     };
0034     Q_ENUM(Mode)
0035 
0036     explicit XFaceConfigurator(QWidget *parent = nullptr);
0037     ~XFaceConfigurator() override;
0038 
0039     [[nodiscard]] bool isXFaceEnabled() const;
0040     void setXFaceEnabled(bool enable);
0041 
0042     [[nodiscard]] QString xface() const;
0043     void setXFace(const QString &text);
0044 
0045     [[nodiscard]] bool isFaceEnabled() const;
0046     void setFaceEnabled(bool enable);
0047 
0048     [[nodiscard]] QString face() const;
0049     void setFace(const QString &text);
0050 
0051 private:
0052     void crunch(const QImage &image);
0053     [[nodiscard]] bool pngquant(const QImage &image);
0054 
0055 private:
0056     void modeChanged(int);
0057 
0058     void compressFace(const QImage &);
0059     void compressFaceDone(const QByteArray &, bool fromPngquant);
0060     void compressXFace(const QImage &);
0061     void updateFace();
0062     void updateXFace();
0063 
0064     void pngquantFinished(int, QProcess::ExitStatus);
0065 
0066     std::unique_ptr<Ui::XFaceConfigurator> mUi;
0067     QProcess *const mPngquantProc;
0068 };
0069 } // namespace KMail