1 /***************************************************************************** 2 * Copyright (C) 2004 Csaba Karai <krusader@users.sourceforge.net> * 3 * Copyright (C) 2004-2019 Krusader Krew [https://krusader.org] * 4 * * 5 * This file is part of Krusader [https://krusader.org]. * 6 * * 7 * Krusader is free software: you can redistribute it and/or modify * 8 * it under the terms of the GNU General Public License as published by * 9 * the Free Software Foundation, either version 2 of the License, or * 10 * (at your option) any later version. * 11 * * 12 * Krusader is distributed in the hope that it will be useful, * 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 * GNU General Public License for more details. * 16 * * 17 * You should have received a copy of the GNU General Public License * 18 * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * 19 *****************************************************************************/ 20 21 #ifndef PROFILEMANAGER_H 22 #define PROFILEMANAGER_H 23 24 // QtCore 25 #include <QString> 26 // QtWidgets 27 #include <QPushButton> 28 29 /** 30 * A generic profile manager: Profiles are arbitray configurations groups and the manager handles 31 * saving/loading multiple groups to/from the configuration. 32 * 33 * A manager instance is responsible for a profile type specified by a type name: 34 * "Panel", "SelectionProfile", "SearcherProfile", "SynchronizerProfile", ... 35 * 36 * Profiles are numbered in the configuration group name and have an additional name property. E.g. 37 * 38 * [Panel - 2] 39 * Name=Media Profile 40 * ... 41 * 42 * This class is view and model at the same time :/ 43 * The GUI button opens a popup menu for selecting, creating, overwriting and removing profiles. 44 */ 45 class ProfileManager : public QPushButton 46 { 47 Q_OBJECT 48 49 public: 50 explicit ProfileManager(QString profileType, QWidget * parent = 0); 51 52 /** 53 * @param profileType Type of the profile (sync, search, ...) 54 * @return A list of all available profile-names 55 */ 56 static QStringList availableProfiles(QString profileType); 57 58 QStringList getNames(); 59 60 public slots: 61 void profilePopup(); 62 63 void newProfile(QString defaultName = QString()); 64 void deleteProfile(QString name); 65 void overwriteProfile(QString name); 66 bool loadProfile(QString name); 67 68 signals: 69 void saveToProfile(QString profileName); 70 void loadFromProfile(QString profileName); 71 72 private: 73 QString profileType; 74 QStringList profileList; 75 }; 76 77 #endif /* PROFILEMANAGER_H */ 78