File indexing completed on 2024-04-28 17:06:05

0001 /*
0002     SPDX-FileCopyrightText: 2004 Csaba Karai <krusader@users.sourceforge.net>
0003     SPDX-FileCopyrightText: 2004-2022 Krusader Krew <https://krusader.org>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef PROFILEMANAGER_H
0009 #define PROFILEMANAGER_H
0010 
0011 // QtCore
0012 #include <QString>
0013 // QtWidgets
0014 #include <QPushButton>
0015 
0016 /**
0017  * A generic profile manager: Profiles are arbitrary configurations groups and the manager handles
0018  * saving/loading multiple groups to/from the configuration.
0019  *
0020  * A manager instance is responsible for a profile type specified by a type name:
0021  * "Panel", "SelectionProfile", "SearcherProfile", "SynchronizerProfile", ...
0022  *
0023  * Profiles are numbered in the configuration group name and have an additional name property. E.g.
0024  *
0025  * [Panel - 2]
0026  * Name=Media Profile
0027  * ...
0028  *
0029  * This class is view and model at the same time :/
0030  * The GUI button opens a popup menu for selecting, creating, overwriting and removing profiles.
0031  */
0032 class ProfileManager : public QPushButton
0033 {
0034     Q_OBJECT
0035 
0036 public:
0037     explicit ProfileManager(const QString &profileType, QWidget *parent = nullptr);
0038 
0039     /**
0040      * @param profileType Type of the profile (sync, search, ...)
0041      * @return A list of all available profile-names
0042      */
0043     static QStringList availableProfiles(const QString &profileType);
0044 
0045     QStringList getNames();
0046 
0047 public slots:
0048     void profilePopup();
0049 
0050     void newProfile(const QString &defaultName = QString());
0051     void deleteProfile(const QString &name);
0052     void overwriteProfile(const QString &name);
0053     bool loadProfile(const QString &name);
0054 
0055 signals:
0056     void saveToProfile(QString profileName);
0057     void loadFromProfile(QString profileName);
0058 
0059 private:
0060     QString profileType;
0061     QStringList profileList;
0062 };
0063 
0064 #endif /* PROFILEMANAGER_H */