File indexing completed on 2024-05-12 15:58:10

0001 /*
0002  *  SPDX-FileCopyrightText: 2007 Cyrille Berger <cberger@cberger.net>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef _KIS_BOOKMARKED_CONFIGURATION_MANAGER_H_
0008 #define _KIS_BOOKMARKED_CONFIGURATION_MANAGER_H_
0009 
0010 #include <QList>
0011 #include "kis_serializable_configuration.h"
0012 
0013 class QString;
0014 class KLocalizedString;
0015 
0016 #include "kritaimage_export.h"
0017 
0018 class KRITAIMAGE_EXPORT KisBookmarkedConfigurationManager
0019 {
0020 public:
0021     static const char ConfigDefault[];
0022     static const char ConfigLastUsed[];
0023 public:
0024     /**
0025      * @param configEntryGroup name of the configuration entry with the
0026      * bookmarked configurations.
0027      */
0028     KisBookmarkedConfigurationManager(const QString & configEntryGroup, KisSerializableConfigurationFactory*);
0029     ~KisBookmarkedConfigurationManager();
0030     /**
0031      * Load the configuration.
0032      */
0033     KisSerializableConfigurationSP load(const QString & configname) const;
0034     /**
0035      * Save the configuration.
0036      */
0037     void save(const QString & configname, const KisSerializableConfigurationSP);
0038     /**
0039      * @return true if the configuration configname exists
0040      */
0041     bool exists(const QString & configname) const;
0042     /**
0043      * @return the list of the names of configurations.
0044      */
0045     QList<QString> configurations() const;
0046     /**
0047      * @return the default configuration
0048      */
0049     KisSerializableConfigurationSP defaultConfiguration() const;
0050     /**
0051      * Remove a bookmarked configuration
0052      */
0053     void remove(const QString & name);
0054     /**
0055      * Generate an unique name, for instance when the user is creating a new
0056      * entry.
0057      * @param base the base of the new name, including a "%1" for incrementing
0058      *      the number, for instance : "New Configuration %1", then this function
0059      *      will return the string where %1 will be replaced by the lowest number
0060      *      and be inexistant in the lists of configuration
0061      */
0062     QString uniqueName(const KLocalizedString & base);
0063 
0064 
0065 
0066 private:
0067     QString configEntryGroup() const;
0068 private:
0069     struct Private;
0070     Private* const d;
0071 };
0072 
0073 #endif