• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

Konsole

  • kde-4.14
  • applications
  • konsole
  • src
ProfileManager.h
Go to the documentation of this file.
1 /*
2  This source file is part of Konsole, a terminal emulator.
3 
4  Copyright 2006-2008 by Robert Knight <robertknight@gmail.com>
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  02110-1301 USA.
20 */
21 
22 #ifndef PROFILEMANAGER_H
23 #define PROFILEMANAGER_H
24 
25 // Qt
26 #include <QtGui/QKeySequence>
27 #include <QtCore/QHash>
28 #include <QtCore/QList>
29 #include <QtCore/QSet>
30 #include <QtCore/QStringList>
31 #include <QtCore/QVariant>
32 #include <QtCore/QStack>
33 
34 // Konsole
35 #include "Profile.h"
36 
37 namespace Konsole
38 {
48 class KONSOLEPRIVATE_EXPORT ProfileManager : public QObject
49 {
50  Q_OBJECT
51 
52 public:
57  ProfileManager();
58 
62  virtual ~ProfileManager();
63 
67  static ProfileManager* instance();
68 
79  QList<Profile::Ptr> allProfiles();
80 
84  QList<Profile::Ptr> loadedProfiles() const;
85 
91  void loadAllProfiles();
92 
107  Profile::Ptr loadProfile(const QString& path);
108 
113  QStringList availableProfilePaths() const;
114 
118  QStringList availableProfileNames() const;
119 
124  void addProfile(Profile::Ptr type);
125 
134  bool deleteProfile(Profile::Ptr profile);
135 
149  void changeProfile(Profile::Ptr profile , QHash<Profile::Property, QVariant> propertyMap,
150  bool persistent = true);
151 
155  void setDefaultProfile(Profile::Ptr profile);
156 
160  Profile::Ptr defaultProfile() const;
161 
167  Profile::Ptr fallbackProfile() const;
168 
173  void setFavorite(Profile::Ptr profile , bool favorite);
174 
178  QSet<Profile::Ptr> findFavorites();
179 
180  QList<Profile::Ptr> sortedFavorites();
181 
182  /*
183  * Sorts the profile list by menuindex; those without an menuindex, sort by name.
184  * The menuindex list is first and then the non-menuindex list.
185  *
186  * @param list The profile list to sort
187  */
188  void sortProfiles(QList<Profile::Ptr>& list);
189 
193  void setShortcut(Profile::Ptr profile , const QKeySequence& shortcut);
194 
196  QKeySequence shortcut(Profile::Ptr profile) const;
197 
207  QList<QKeySequence> shortcuts();
208 
213  Profile::Ptr findByShortcut(const QKeySequence& shortcut);
214 
215 signals:
216 
218  void profileAdded(Profile::Ptr ptr);
220  void profileRemoved(Profile::Ptr ptr);
222  void profileChanged(Profile::Ptr ptr);
223 
230  void favoriteStatusChanged(Profile::Ptr profile , bool favorite);
231 
238  void shortcutChanged(Profile::Ptr profile , const QKeySequence& newShortcut);
239 
240 public slots:
242  void saveSettings();
243 
244 protected slots:
245 
246 private slots:
247 
248 private:
249  // loads the mappings between shortcut key sequences and
250  // profile paths
251  void loadShortcuts();
252  // saves the mappings between shortcut key sequences and
253  // profile paths
254  void saveShortcuts();
255 
256  //loads the set of favorite profiles
257  void loadFavorites();
258  //saves the set of favorite profiles
259  void saveFavorites();
260 
261  // records which profile is set as the default profile
262  // Note: it does not save the profile itself into disk. That is
263  // what saveProfile() does.
264  void saveDefaultProfile();
265 
266  // saves a profile to a file
267  // returns the path to which the profile was saved, which will
268  // be the same as the path property of profile if valid or a newly generated path
269  // otherwise
270  QString saveProfile(Profile::Ptr profile);
271 
272  QSet<Profile::Ptr> _profiles; // list of all loaded profiles
273  QSet<Profile::Ptr> _favorites; // list of favorite profiles
274 
275  Profile::Ptr _defaultProfile;
276  Profile::Ptr _fallbackProfile;
277 
278  bool _loadedAllProfiles; // set to true after loadAllProfiles has been called
279  bool _loadedFavorites; // set to true after loadFavorites has been called
280 
281  struct ShortcutData {
282  Profile::Ptr profileKey;
283  QString profilePath;
284  };
285  QMap<QKeySequence, ShortcutData> _shortcuts; // shortcut keys -> profile path
286 };
287 
295 template <class T>
296 class PopStackOnExit
297 {
298 public:
299  explicit PopStackOnExit(QStack<T>& stack) : _stack(stack) , _count(stack.count()) {}
300  ~PopStackOnExit() {
301  while (_stack.count() > _count)
302  _stack.pop();
303  }
304 private:
305  QStack<T>& _stack;
306  int _count;
307 };
308 }
309 #endif //PROFILEMANAGER_H
QStack::pop
T pop()
Konsole::ProfileManager
Manages profiles which specify various settings for terminal sessions and their displays.
Definition: ProfileManager.h:48
QMap< QKeySequence, ShortcutData >
QHash
QObject
QSet
QString
QList
QStringList
Konsole::Profile::Ptr
KSharedPtr< Profile > Ptr
Definition: Profile.h:67
Konsole::PopStackOnExit::~PopStackOnExit
~PopStackOnExit()
Definition: ProfileManager.h:300
QKeySequence
KONSOLEPRIVATE_EXPORT
#define KONSOLEPRIVATE_EXPORT
Definition: konsole_export.h:33
Konsole::PopStackOnExit::PopStackOnExit
PopStackOnExit(QStack< T > &stack)
Definition: ProfileManager.h:299
Konsole::PopStackOnExit
PopStackOnExit is a utility to remove all values from a QStack which are added during the lifetime of...
Definition: ProfileManager.h:296
QStack< T >
Profile.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:27 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Konsole

Skip menu "Konsole"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal