File indexing completed on 2025-04-27 03:58:22

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2007-08-02
0007  * Description : a stack of widgets to set image file save
0008  *               options into image editor.
0009  *
0010  * SPDX-FileCopyrightText: 2007-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #ifndef DIGIKAM_FILE_SAVE_OPTIONS_BOX_H
0017 #define DIGIKAM_FILE_SAVE_OPTIONS_BOX_H
0018 
0019 // Qt includes
0020 
0021 #include <QStackedWidget>
0022 #include <QString>
0023 
0024 // Local includes
0025 
0026 #include "digikam_export.h"
0027 #include "digikam_config.h"
0028 
0029 namespace Digikam
0030 {
0031 
0032 class DIGIKAM_EXPORT FileSaveOptionsBox : public QStackedWidget
0033 {
0034     Q_OBJECT
0035 
0036 public:
0037 
0038     enum FORMAT
0039     {
0040         /**
0041          * NOTE: Order is important here:
0042          * See filesaveoptionbox.cpp which use these values to fill a stack of widgets.
0043          */
0044         NONE = 0,
0045         JPEG,
0046         PNG,
0047         TIFF,
0048 #ifdef HAVE_JASPER
0049         JP2K,
0050 #endif
0051         PGF,
0052 #ifdef HAVE_X265
0053         HEIF,
0054 #endif
0055         JXL,
0056         WEBP,
0057         AVIF
0058     };
0059 
0060 public:
0061 
0062     /**
0063      * Constructor. Don't forget to call setDialog after creation of the dialog.
0064      *
0065      * @param parent the parent for Qt's parent child mechanism
0066      */
0067     explicit FileSaveOptionsBox(QWidget* const parent = nullptr);
0068 
0069     /**
0070      * Destructor.
0071      */
0072     ~FileSaveOptionsBox() override;
0073 
0074     void applySettings();
0075 
0076     /**
0077      * Tries to discover a file format that has options to change based on a
0078      * filename.
0079      *
0080      * @param filename file name to discover the desired format from
0081      * @param fallback the fallback format to return if no format could be
0082      *                 discovered based on the filename
0083      * @return file format guessed from the file name or the given fallback
0084      *         format if no format could be guessed based on the file name
0085      */
0086     FORMAT discoverFormat(const QString& filename, FORMAT fallback = NONE);
0087 
0088     void setImageFileFormat(const QString&);
0089 
0090 private:
0091 
0092     void readSettings();
0093 
0094 private:
0095 
0096     class Private;
0097     Private* const d;
0098 };
0099 
0100 } // namespace Digikam
0101 
0102 #endif // DIGIKAM_FILE_SAVE_OPTIONS_BOX_H