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

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2009-08-11
0007  * Description : a combo box containing ICC profiles
0008  *
0009  * SPDX-FileCopyrightText: 2009-2010 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #ifndef DIGIKAM_ICC_PROFILES_COMBOBOX_H
0016 #define DIGIKAM_ICC_PROFILES_COMBOBOX_H
0017 
0018 // Qt includes
0019 
0020 #include <QComboBox>
0021 #include <QIcon>
0022 #include <QMenu>
0023 
0024 // Local includes
0025 
0026 #include "squeezedcombobox.h"
0027 #include "digikam_export.h"
0028 #include "iccprofile.h"
0029 
0030 namespace Digikam
0031 {
0032 
0033 class DIGIKAM_EXPORT IccProfilesComboBox : public SqueezedComboBox
0034 {
0035     Q_OBJECT
0036 
0037 public:
0038     /**
0039      * NOTE: Use the signal currentIndexChanged(int) for change notification
0040      */
0041 
0042     explicit IccProfilesComboBox(QWidget* const parent = nullptr);
0043     ~IccProfilesComboBox() override;
0044 
0045     /**
0046      * Checks the given profiles for validity, creates a suitable description (ICC profile description, file path),
0047      * removes duplicates by file path, sorts them and adds them in sorted order.
0048      */
0049     void addProfilesSqueezed(const QList<IccProfile>& profiles);
0050 
0051     /**
0052      * Add the given profile with the given description, or, if null, a standard description.
0053      * Does not test for duplicity, does not sort into existing profiles.
0054      */
0055     void addProfileSqueezed(const IccProfile& profile, const QString& description = QString());
0056 
0057     /**
0058      * Clears, does the same as addProfilesSqueezed, and restores the current entry if possible.
0059      */
0060     void replaceProfilesSqueezed(const QList<IccProfile>& profiles);
0061 
0062     /**
0063      * Sets a message the is displayed in the combo box and disables the combo box,
0064      * if the combo box is currently empty
0065      */
0066     void setNoProfileIfEmpty(const QString& message);
0067 
0068     /**
0069      * Retrieves the current profile, or a null profile if none is selected.
0070      */
0071     IccProfile currentProfile() const;
0072 
0073     /**
0074      * Sets the current profile. If profile is not in the list, sets no current item (-1)
0075      */
0076     void setCurrentProfile(const IccProfile& profile);
0077 };
0078 
0079 // ----------------------------------------------------------------------------
0080 
0081 class DIGIKAM_EXPORT IccRenderingIntentComboBox : public QComboBox
0082 {
0083     Q_OBJECT
0084 
0085 public:
0086 
0087     explicit IccRenderingIntentComboBox(QWidget* const parent = nullptr);
0088 
0089     void setIntent(int intent);
0090     int  intent() const;
0091 };
0092 
0093 // ----------------------------------------------------------------------------
0094 
0095 class DIGIKAM_EXPORT IccProfilesMenuAction : public QMenu
0096 {
0097     Q_OBJECT
0098 
0099 public:
0100 
0101     IccProfilesMenuAction(const QIcon& icon, const QString& text, QObject* const parent);
0102     IccProfilesMenuAction(const QString& text, QObject* const parent);
0103 
0104     /**
0105      * Checks the given profiles for validity, creates a suitable description (ICC profile description, file path),
0106      * removes duplicates (in newly added list) by file path, sorts them and adds them in sorted order.
0107      */
0108     void addProfiles(const QList<IccProfile>& profile);
0109 
0110     /**
0111      * Add the given profile with the given description, or, if null, a standard description.
0112      * Does not test for duplicity, does not sort into existing profiles.
0113      */
0114     void addProfile(const IccProfile& profile, const QString& description = QString());
0115 
0116     /**
0117      * Equivalent to calling clear() and addProfiles().
0118      */
0119     void replaceProfiles(const QList<IccProfile>& profile);
0120 
0121     /**
0122      * Disables if the menu is currently empty.
0123      */
0124     void disableIfEmpty();
0125 
0126     /**
0127      * Return the parent QObject.
0128      */
0129     QObject* parentObject() const;
0130 
0131 Q_SIGNALS:
0132 
0133     void triggered(const IccProfile& profile);
0134 
0135 protected Q_SLOTS:
0136 
0137     void slotTriggered(QObject*);
0138 
0139 protected:
0140 
0141     QObject*       m_parent;
0142 
0143 private:
0144 
0145     // Disable
0146     IccProfilesMenuAction(QWidget*);
0147 };
0148 
0149 } // namespace Digikam
0150 
0151 #endif // DIGIKAM_ICC_PROFILES_COMBOBOX_H