• 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.cpp
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 // Own
23 #include "ProfileManager.h"
24 
25 // Qt
26 #include <QtCore/QDir>
27 #include <QtCore/QFileInfo>
28 #include <QtCore/QList>
29 #include <QtCore/QString>
30 
31 // KDE
32 #include <KConfig>
33 #include <KGlobal>
34 #include <KDebug>
35 #include <KConfigGroup>
36 #include <KStandardDirs>
37 
38 // Konsole
39 #include "ProfileReader.h"
40 #include "ProfileWriter.h"
41 
42 using namespace Konsole;
43 
44 static bool profileIndexLessThan(const Profile::Ptr& p1, const Profile::Ptr& p2)
45 {
46  return p1->menuIndexAsInt() <= p2->menuIndexAsInt();
47 }
48 
49 static bool profileNameLessThan(const Profile::Ptr& p1, const Profile::Ptr& p2)
50 {
51  return QString::localeAwareCompare(p1->name(), p2->name()) <= 0;
52 }
53 
54 static bool stringLessThan(const QString& p1, const QString& p2)
55 {
56  return QString::localeAwareCompare(p1, p2) <= 0;
57 }
58 
59 static void sortByIndexProfileList(QList<Profile::Ptr>& list)
60 {
61  qStableSort(list.begin(), list.end(), profileIndexLessThan);
62 }
63 
64 static void sortByNameProfileList(QList<Profile::Ptr>& list)
65 {
66  qStableSort(list.begin(), list.end(), profileNameLessThan);
67 }
68 
69 ProfileManager::ProfileManager()
70  : _loadedAllProfiles(false)
71  , _loadedFavorites(false)
72 {
73  //load fallback profile
74  _fallbackProfile = Profile::Ptr(new FallbackProfile);
75  addProfile(_fallbackProfile);
76 
77  // lookup the default profile specified in <App>rc
78  // for stand-alone Konsole, appConfig is just konsolerc
79  // for konsolepart, appConfig might be yakuakerc, dolphinrc, katerc...
80  KSharedConfigPtr appConfig = KGlobal::config();
81  KConfigGroup group = appConfig->group("Desktop Entry");
82  QString defaultProfileFileName = group.readEntry("DefaultProfile", "");
83 
84  // if the hosting application of konsolepart does not specify its own
85  // default profile, use the default profile of stand-alone Konsole.
86  if (defaultProfileFileName.isEmpty()) {
87  KSharedConfigPtr konsoleConfig = KSharedConfig::openConfig("konsolerc");
88  group = konsoleConfig->group("Desktop Entry");
89  defaultProfileFileName = group.readEntry("DefaultProfile", "Shell.profile");
90  }
91 
92  // load the default profile
93  const QString path = KStandardDirs::locate("data", "konsole/" + defaultProfileFileName);
94  if (!path.isEmpty()) {
95  Profile::Ptr profile = loadProfile(path);
96  if (profile)
97  _defaultProfile = profile;
98  }
99 
100  Q_ASSERT(_profiles.count() > 0);
101  Q_ASSERT(_defaultProfile);
102 
103  // get shortcuts and paths of profiles associated with
104  // them - this doesn't load the shortcuts themselves,
105  // that is done on-demand.
106  loadShortcuts();
107 }
108 
109 ProfileManager::~ProfileManager()
110 {
111 }
112 
113 K_GLOBAL_STATIC(ProfileManager , theProfileManager)
114 ProfileManager* ProfileManager::instance()
115 {
116  return theProfileManager;
117 }
118 
119 Profile::Ptr ProfileManager::loadProfile(const QString& shortPath)
120 {
121  // the fallback profile has a 'special' path name, "FALLBACK/"
122  if (shortPath == _fallbackProfile->path())
123  return _fallbackProfile;
124 
125  QString path = shortPath;
126 
127  // add a suggested suffix and relative prefix if missing
128  QFileInfo fileInfo(path);
129 
130  if (fileInfo.isDir())
131  return Profile::Ptr();
132 
133  if (fileInfo.suffix() != "profile")
134  path.append(".profile");
135  if (fileInfo.path().isEmpty() || fileInfo.path() == ".")
136  path.prepend(QString("konsole") + QDir::separator());
137 
138  // if the file is not an absolute path, look it up
139  if (!fileInfo.isAbsolute())
140  path = KStandardDirs::locate("data", path);
141 
142  // if the file is not found, return immediately
143  if (path.isEmpty()) {
144  return Profile::Ptr();
145  }
146 
147  // check that we have not already loaded this profile
148  foreach(const Profile::Ptr& profile, _profiles) {
149  if (profile->path() == path)
150  return profile;
151  }
152 
153  // guard to prevent problems if a profile specifies itself as its parent
154  // or if there is recursion in the "inheritance" chain
155  // (eg. two profiles, A and B, specifying each other as their parents)
156  static QStack<QString> recursionGuard;
157  PopStackOnExit<QString> popGuardOnExit(recursionGuard);
158 
159  if (recursionGuard.contains(path)) {
160  kWarning() << "Ignoring attempt to load profile recursively from" << path;
161  return _fallbackProfile;
162  } else {
163  recursionGuard.push(path);
164  }
165 
166  // load the profile
167  ProfileReader* reader = new KDE4ProfileReader;
168 
169  Profile::Ptr newProfile = Profile::Ptr(new Profile(fallbackProfile()));
170  newProfile->setProperty(Profile::Path, path);
171 
172  QString parentProfilePath;
173  bool result = reader->readProfile(path, newProfile, parentProfilePath);
174 
175  if (!parentProfilePath.isEmpty()) {
176  Profile::Ptr parentProfile = loadProfile(parentProfilePath);
177  newProfile->setParent(parentProfile);
178  }
179 
180  delete reader;
181 
182  if (!result) {
183  kWarning() << "Could not load profile from " << path;
184  return Profile::Ptr();
185  } else {
186  addProfile(newProfile);
187  return newProfile;
188  }
189 }
190 QStringList ProfileManager::availableProfilePaths() const
191 {
192  KDE4ProfileReader kde4Reader;
193 
194  QStringList paths;
195  paths += kde4Reader.findProfiles();
196 
197  qStableSort(paths.begin(), paths.end(), stringLessThan);
198 
199  return paths;
200 }
201 
202 QStringList ProfileManager::availableProfileNames() const
203 {
204  QStringList names;
205 
206  foreach(Profile::Ptr profile, ProfileManager::instance()->allProfiles()) {
207  if (!profile->isHidden()) {
208  names.push_back(profile->name());
209  }
210  }
211 
212  qStableSort(names.begin(), names.end(), stringLessThan);
213 
214  return names;
215 }
216 
217 void ProfileManager::loadAllProfiles()
218 {
219  if (_loadedAllProfiles)
220  return;
221 
222  const QStringList& paths = availableProfilePaths();
223  foreach(const QString& path, paths) {
224  loadProfile(path);
225  }
226 
227  _loadedAllProfiles = true;
228 }
229 
230 void ProfileManager::sortProfiles(QList<Profile::Ptr>& list)
231 {
232  QList<Profile::Ptr> lackingIndices;
233  QList<Profile::Ptr> havingIndices;
234 
235  for (int i = 0; i < list.size(); ++i) {
236  // dis-regard the fallback profile
237  if (list.at(i)->path() == _fallbackProfile->path())
238  continue;
239 
240  if (list.at(i)->menuIndexAsInt() == 0)
241  lackingIndices.append(list.at(i));
242  else
243  havingIndices.append(list.at(i));
244  }
245 
246  // sort by index
247  sortByIndexProfileList(havingIndices);
248 
249  // sort alphabetically those w/o an index
250  sortByNameProfileList(lackingIndices);
251 
252  // Put those with indices in sequential order w/o any gaps
253  int i = 0;
254  for (i = 0; i < havingIndices.size(); ++i) {
255  Profile::Ptr tempProfile = havingIndices.at(i);
256  tempProfile->setProperty(Profile::MenuIndex, QString::number(i + 1));
257  havingIndices.replace(i, tempProfile);
258  }
259  // Put those w/o indices in sequential order
260  for (int j = 0; j < lackingIndices.size(); ++j) {
261  Profile::Ptr tempProfile = lackingIndices.at(j);
262  tempProfile->setProperty(Profile::MenuIndex, QString::number(j + 1 + i));
263  lackingIndices.replace(j, tempProfile);
264  }
265 
266  // combine the 2 list: first those who had indices
267  list.clear();
268  list.append(havingIndices);
269  list.append(lackingIndices);
270 }
271 
272 void ProfileManager::saveSettings()
273 {
274  // save default profile
275  saveDefaultProfile();
276 
277  // save shortcuts
278  saveShortcuts();
279 
280  // save favorites
281  saveFavorites();
282 
283  // ensure default/favorites/shortcuts settings are synced into disk
284  KSharedConfigPtr appConfig = KGlobal::config();
285  appConfig->sync();
286 }
287 
288 QList<Profile::Ptr> ProfileManager::sortedFavorites()
289 {
290  QList<Profile::Ptr> favorites = findFavorites().toList();
291 
292  sortProfiles(favorites);
293  return favorites;
294 }
295 
296 QList<Profile::Ptr> ProfileManager::allProfiles()
297 {
298  loadAllProfiles();
299 
300  return _profiles.toList();
301 }
302 
303 QList<Profile::Ptr> ProfileManager::loadedProfiles() const
304 {
305  return _profiles.toList();
306 }
307 
308 Profile::Ptr ProfileManager::defaultProfile() const
309 {
310  return _defaultProfile;
311 }
312 Profile::Ptr ProfileManager::fallbackProfile() const
313 {
314  return _fallbackProfile;
315 }
316 
317 QString ProfileManager::saveProfile(Profile::Ptr profile)
318 {
319  ProfileWriter* writer = new KDE4ProfileWriter;
320 
321  QString newPath = writer->getPath(profile);
322 
323  writer->writeProfile(newPath, profile);
324 
325  delete writer;
326 
327  return newPath;
328 }
329 
330 void ProfileManager::changeProfile(Profile::Ptr profile,
331  QHash<Profile::Property, QVariant> propertyMap, bool persistent)
332 {
333  Q_ASSERT(profile);
334 
335  // insert the changes into the existing Profile instance
336  QListIterator<Profile::Property> iter(propertyMap.keys());
337  while (iter.hasNext()) {
338  const Profile::Property property = iter.next();
339  profile->setProperty(property, propertyMap[property]);
340  }
341 
342  // never save a profile with empty name into disk!
343  persistent = persistent && !profile->name().isEmpty();
344 
345  // when changing a group, iterate through the profiles
346  // in the group and call changeProfile() on each of them
347  //
348  // this is so that each profile in the group, the profile is
349  // applied, a change notification is emitted and the profile
350  // is saved to disk
351  ProfileGroup::Ptr group = profile->asGroup();
352  if (group) {
353  foreach(const Profile::Ptr & profile, group->profiles()) {
354  changeProfile(profile, propertyMap, persistent);
355  }
356  return;
357  }
358 
359  // notify the world about the change
360  emit profileChanged(profile);
361 
362  // save changes to disk, unless the profile is hidden, in which case
363  // it has no file on disk
364  if (persistent && !profile->isHidden()) {
365  profile->setProperty(Profile::Path, saveProfile(profile));
366  }
367 }
368 
369 void ProfileManager::addProfile(Profile::Ptr profile)
370 {
371  if (_profiles.isEmpty())
372  _defaultProfile = profile;
373 
374  _profiles.insert(profile);
375 
376  emit profileAdded(profile);
377 }
378 
379 bool ProfileManager::deleteProfile(Profile::Ptr profile)
380 {
381  bool wasDefault = (profile == defaultProfile());
382 
383  if (profile) {
384  // try to delete the config file
385  if (profile->isPropertySet(Profile::Path) && QFile::exists(profile->path())) {
386  if (!QFile::remove(profile->path())) {
387  kWarning() << "Could not delete profile: " << profile->path()
388  << "The file is most likely in a directory which is read-only.";
389 
390  return false;
391  }
392  }
393 
394  // remove from favorites, profile list, shortcut list etc.
395  setFavorite(profile, false);
396  setShortcut(profile, QKeySequence());
397  _profiles.remove(profile);
398 
399  // mark the profile as hidden so that it does not show up in the
400  // Manage Profiles dialog and is not saved to disk
401  profile->setHidden(true);
402  }
403 
404  // if we just deleted the default profile,
405  // replace it with a random profile from the list
406  if (wasDefault) {
407  setDefaultProfile(_profiles.toList().first());
408  }
409 
410  emit profileRemoved(profile);
411 
412  return true;
413 }
414 
415 void ProfileManager::setDefaultProfile(Profile::Ptr profile)
416 {
417  Q_ASSERT(_profiles.contains(profile));
418 
419  _defaultProfile = profile;
420 }
421 
422 void ProfileManager::saveDefaultProfile()
423 {
424  QString path = _defaultProfile->path();
425 
426  if (path.isEmpty())
427  path = KDE4ProfileWriter().getPath(_defaultProfile);
428 
429  QFileInfo fileInfo(path);
430 
431  KSharedConfigPtr appConfig = KGlobal::config();
432  KConfigGroup group = appConfig->group("Desktop Entry");
433  group.writeEntry("DefaultProfile", fileInfo.fileName());
434 }
435 
436 QSet<Profile::Ptr> ProfileManager::findFavorites()
437 {
438  loadFavorites();
439 
440  return _favorites;
441 }
442 void ProfileManager::setFavorite(Profile::Ptr profile , bool favorite)
443 {
444  if (!_profiles.contains(profile))
445  addProfile(profile);
446 
447  if (favorite && !_favorites.contains(profile)) {
448  _favorites.insert(profile);
449  emit favoriteStatusChanged(profile, favorite);
450  } else if (!favorite && _favorites.contains(profile)) {
451  _favorites.remove(profile);
452  emit favoriteStatusChanged(profile, favorite);
453  }
454 }
455 void ProfileManager::loadShortcuts()
456 {
457  KSharedConfigPtr appConfig = KGlobal::config();
458  KConfigGroup shortcutGroup = appConfig->group("Profile Shortcuts");
459 
460  QMap<QString, QString> entries = shortcutGroup.entryMap();
461 
462  QMapIterator<QString, QString> iter(entries);
463  while (iter.hasNext()) {
464  iter.next();
465 
466  QKeySequence shortcut = QKeySequence::fromString(iter.key());
467  QString profilePath = iter.value();
468 
469  ShortcutData data;
470 
471  // if the file is not an absolute path, look it up
472  QFileInfo fileInfo(profilePath);
473  if (!fileInfo.isAbsolute()) {
474  profilePath = KStandardDirs::locate("data", "konsole/" + profilePath);
475  }
476 
477  data.profilePath = profilePath;
478  _shortcuts.insert(shortcut, data);
479  }
480 }
481 void ProfileManager::saveShortcuts()
482 {
483  KSharedConfigPtr appConfig = KGlobal::config();
484  KConfigGroup shortcutGroup = appConfig->group("Profile Shortcuts");
485  shortcutGroup.deleteGroup();
486 
487  QMapIterator<QKeySequence, ShortcutData> iter(_shortcuts);
488  while (iter.hasNext()) {
489  iter.next();
490 
491  QString shortcutString = iter.key().toString();
492 
493  // if the profile path in "Profile Shortcuts" is an absolute path,
494  // take the profile name
495  QFileInfo fileInfo(iter.value().profilePath);
496  QString profileName;
497  if (fileInfo.isAbsolute()) {
498  // Check to see if file is under KDE's data locations. If not,
499  // store full path.
500  QString location = KGlobal::dirs()->locate("data",
501  "konsole/" + fileInfo.fileName());
502  if (location.isEmpty()) {
503  profileName = iter.value().profilePath;
504  } else {
505  profileName = fileInfo.fileName();
506  }
507  } else {
508  profileName = iter.value().profilePath;
509  }
510 
511  shortcutGroup.writeEntry(shortcutString, profileName);
512  }
513 }
514 void ProfileManager::setShortcut(Profile::Ptr profile ,
515  const QKeySequence& keySequence)
516 {
517  QKeySequence existingShortcut = shortcut(profile);
518  _shortcuts.remove(existingShortcut);
519 
520  if (keySequence.isEmpty())
521  return;
522 
523  ShortcutData data;
524  data.profileKey = profile;
525  data.profilePath = profile->path();
526  // TODO - This won't work if the profile doesn't
527  // have a path yet
528  _shortcuts.insert(keySequence, data);
529 
530  emit shortcutChanged(profile, keySequence);
531 }
532 void ProfileManager::loadFavorites()
533 {
534  if (_loadedFavorites)
535  return;
536 
537  KSharedConfigPtr appConfig = KGlobal::config();
538  KConfigGroup favoriteGroup = appConfig->group("Favorite Profiles");
539 
540  QSet<QString> favoriteSet;
541 
542  if (favoriteGroup.hasKey("Favorites")) {
543  QStringList list = favoriteGroup.readEntry("Favorites", QStringList());
544  favoriteSet = QSet<QString>::fromList(list);
545  } else {
546  // if there is no favorites key at all, mark the
547  // supplied 'Shell.profile' as the only favorite
548  favoriteSet << "Shell.profile";
549  }
550 
551  // look for favorites among those already loaded
552  foreach(const Profile::Ptr& profile, _profiles) {
553  const QString& path = profile->path();
554  if (favoriteSet.contains(path)) {
555  _favorites.insert(profile);
556  favoriteSet.remove(path);
557  }
558  }
559  // load any remaining favorites
560  foreach(const QString& favorite, favoriteSet) {
561  Profile::Ptr profile = loadProfile(favorite);
562  if (profile)
563  _favorites.insert(profile);
564  }
565 
566  _loadedFavorites = true;
567 }
568 void ProfileManager::saveFavorites()
569 {
570  KSharedConfigPtr appConfig = KGlobal::config();
571  KConfigGroup favoriteGroup = appConfig->group("Favorite Profiles");
572 
573  QStringList paths;
574  foreach(const Profile::Ptr& profile, _favorites) {
575  Q_ASSERT(_profiles.contains(profile) && profile);
576 
577  QFileInfo fileInfo(profile->path());
578  QString profileName;
579 
580  if (fileInfo.isAbsolute()) {
581  // Check to see if file is under KDE's data locations. If not,
582  // store full path.
583  QString location = KGlobal::dirs()->locate("data",
584  "konsole/" + fileInfo.fileName());
585  if (location.isEmpty()) {
586  profileName = profile->path();
587  } else {
588  profileName = fileInfo.fileName();
589  }
590  } else {
591  profileName = profile->path();
592  }
593 
594  paths << profileName;
595  }
596 
597  favoriteGroup.writeEntry("Favorites", paths);
598 }
599 
600 QList<QKeySequence> ProfileManager::shortcuts()
601 {
602  return _shortcuts.keys();
603 }
604 
605 Profile::Ptr ProfileManager::findByShortcut(const QKeySequence& shortcut)
606 {
607  Q_ASSERT(_shortcuts.contains(shortcut));
608 
609  if (!_shortcuts[shortcut].profileKey) {
610  Profile::Ptr key = loadProfile(_shortcuts[shortcut].profilePath);
611  if (!key) {
612  _shortcuts.remove(shortcut);
613  return Profile::Ptr();
614  }
615  _shortcuts[shortcut].profileKey = key;
616  }
617 
618  return _shortcuts[shortcut].profileKey;
619 }
620 
621 
622 QKeySequence ProfileManager::shortcut(Profile::Ptr profile) const
623 {
624  QMapIterator<QKeySequence, ShortcutData> iter(_shortcuts);
625  while (iter.hasNext()) {
626  iter.next();
627  if (iter.value().profileKey == profile
628  || iter.value().profilePath == profile->path())
629  return iter.key();
630  }
631 
632  return QKeySequence();
633 }
634 
635 #include "ProfileManager.moc"
636 
QList::clear
void clear()
Konsole::ProfileWriter::writeProfile
virtual bool writeProfile(const QString &path, const Profile::Ptr profile)=0
Writes the properties and values from profile to the file specified by path.
QString::append
QString & append(QChar ch)
QFileInfo::path
QString path() const
Konsole::ProfileManager::availableProfilePaths
QStringList availableProfilePaths() const
Searches for available profiles on-disk and returns a list of paths of profiles which can be loaded...
Definition: ProfileManager.cpp:190
QMap::contains
bool contains(const Key &key) const
QString::localeAwareCompare
int localeAwareCompare(const QString &other) const
QListIterator::next
const T & next()
Konsole::ProfileReader::readProfile
virtual bool readProfile(const QString &path, Profile::Ptr profile, QString &parentProfile)=0
Attempts to read a profile from path and save the property values described into profile.
Konsole::ProfileManager
Manages profiles which specify various settings for terminal sessions and their displays.
Definition: ProfileManager.h:48
QList::push_back
void push_back(const T &value)
QFile::remove
bool remove()
Konsole::ProfileManager::setDefaultProfile
void setDefaultProfile(Profile::Ptr profile)
Sets the profile as the default profile for creating new sessions.
Definition: ProfileManager.cpp:415
QFileInfo::isAbsolute
bool isAbsolute() const
QString::prepend
QString & prepend(QChar ch)
QStack::push
void push(const T &t)
Konsole::KDE4ProfileReader::findProfiles
virtual QStringList findProfiles()
Returns a list of paths to profiles which this reader can read.
Definition: ProfileReader.cpp:42
Konsole::FallbackProfile
A profile which contains a number of default settings for various properties.
Definition: Profile.h:580
QList::at
const T & at(int i) const
QMap< QString, QString >
ProfileReader.h
Konsole::Profile::MenuIndex
Index of profile in the File Menu WARNING: this is currently an internal field, which is expected to ...
Definition: Profile.h:248
Konsole::ProfileGroup::Ptr
KSharedPtr< ProfileGroup > Ptr
Definition: Profile.h:602
Konsole::ProfileManager::loadAllProfiles
void loadAllProfiles()
Loads all available profiles.
Definition: ProfileManager.cpp:217
profileNameLessThan
static bool profileNameLessThan(const Profile::Ptr &p1, const Profile::Ptr &p2)
Definition: ProfileManager.cpp:49
Konsole::ProfileManager::findByShortcut
Profile::Ptr findByShortcut(const QKeySequence &shortcut)
Finds and loads the profile associated with the specified shortcut key sequence and returns a pointer...
Definition: ProfileManager.cpp:605
Konsole::ProfileManager::findFavorites
QSet< Profile::Ptr > findFavorites()
Returns the set of the user's favorite profiles.
Definition: ProfileManager.cpp:436
QFile::exists
bool exists() const
Konsole::Profile
Represents a terminal set-up which can be used to set the initial state of new terminal sessions or a...
Definition: Profile.h:60
Konsole::ProfileWriter::getPath
virtual QString getPath(const Profile::Ptr profile)=0
Returns a suitable path-name for writing profile to.
QDir::separator
QChar separator()
Konsole::Profile::Property
Property
This enum describes the available properties which a Profile may consist of.
Definition: Profile.h:77
sortByNameProfileList
static void sortByNameProfileList(QList< Profile::Ptr > &list)
Definition: ProfileManager.cpp:64
QList::size
int size() const
Konsole::ProfileManager::defaultProfile
Profile::Ptr defaultProfile() const
Returns a Profile object describing the default profile.
Definition: ProfileManager.cpp:308
QMap::keys
QList< Key > keys() const
Konsole::ProfileManager::saveSettings
void saveSettings()
Saves settings (favorites, shortcuts, default profile etc.) to disk.
Definition: ProfileManager.cpp:272
Konsole::ProfileManager::allProfiles
QList< Profile::Ptr > allProfiles()
Returns a list of all available profiles.
Definition: ProfileManager.cpp:296
QString::number
QString number(int n, int base)
QVector::contains
bool contains(const T &value) const
QList::append
void append(const T &value)
Konsole::ProfileManager::shortcuts
QList< QKeySequence > shortcuts()
Returns the list of shortcut key sequences which can be used to create new sessions based on existing...
Definition: ProfileManager.cpp:600
Konsole::ProfileManager::instance
static ProfileManager * instance()
Returns the profile manager instance.
Definition: ProfileManager.cpp:114
QMapIterator
QKeySequence::fromString
QKeySequence fromString(const QString &str, SequenceFormat format)
QObject::property
QVariant property(const char *name) const
Konsole::ProfileManager::deleteProfile
bool deleteProfile(Profile::Ptr profile)
Deletes the configuration file used to store a profile.
Definition: ProfileManager.cpp:379
QHash
QFileInfo::isDir
bool isDir() const
QMapIterator::next
Item next()
QString::isEmpty
bool isEmpty() const
stringLessThan
static bool stringLessThan(const QString &p1, const QString &p2)
Definition: ProfileManager.cpp:54
Konsole::ProfileReader
Interface for all classes which can load profile settings from a file.
Definition: ProfileReader.h:32
QSet
Konsole::ProfileManager::shortcutChanged
void shortcutChanged(Profile::Ptr profile, const QKeySequence &newShortcut)
Emitted when the shortcut for a profile is changed.
QString
QList
QMapIterator::key
const Key & key() const
QMapIterator::value
const T & value() const
QStringList
QHash::keys
QList< Key > keys() const
QFileInfo
Konsole::ProfileManager::sortProfiles
void sortProfiles(QList< Profile::Ptr > &list)
Definition: ProfileManager.cpp:230
QList::end
iterator end()
Konsole::ProfileManager::shortcut
QKeySequence shortcut(Profile::Ptr profile) const
Returns the shortcut associated with a particular profile.
Definition: ProfileManager.cpp:622
QKeySequence::isEmpty
bool isEmpty() const
QSet::contains
bool contains(const T &value) const
Konsole::KDE4ProfileWriter
Writes a KDE 4 .profile file.
Definition: ProfileWriter.h:50
Konsole::Profile::Ptr
KSharedPtr< Profile > Ptr
Definition: Profile.h:67
Konsole::ProfileManager::favoriteStatusChanged
void favoriteStatusChanged(Profile::Ptr profile, bool favorite)
Emitted when the favorite status of a profile changes.
Konsole::ProfileManager::setShortcut
void setShortcut(Profile::Ptr profile, const QKeySequence &shortcut)
Associates a shortcut with a particular profile.
Definition: ProfileManager.cpp:514
Konsole::ProfileManager::ProfileManager
ProfileManager()
Constructs a new profile manager and loads information about the available profiles.
Definition: ProfileManager.cpp:69
Konsole::ProfileManager::changeProfile
void changeProfile(Profile::Ptr profile, QHash< Profile::Property, QVariant > propertyMap, bool persistent=true)
Updates a profile with the changes specified in propertyMap.
Definition: ProfileManager.cpp:330
QSet::remove
bool remove(const T &value)
QFileInfo::suffix
QString suffix() const
ProfileWriter.h
sortByIndexProfileList
static void sortByIndexProfileList(QList< Profile::Ptr > &list)
Definition: ProfileManager.cpp:59
QKeySequence
ProfileManager.h
Konsole::ProfileManager::profileRemoved
void profileRemoved(Profile::Ptr ptr)
Emitted when a profile is removed from the manager.
Konsole::KDE4ProfileWriter::getPath
virtual QString getPath(const Profile::Ptr profile)
Returns a suitable path-name for writing profile to.
Definition: ProfileWriter.cpp:42
Konsole::ProfileManager::sortedFavorites
QList< Profile::Ptr > sortedFavorites()
Definition: ProfileManager.cpp:288
Konsole::ProfileManager::profileAdded
void profileAdded(Profile::Ptr ptr)
Emitted when a profile is added to the manager.
QSet::fromList
QSet< T > fromList(const QList< T > &list)
Konsole::ProfileManager::loadedProfiles
QList< Profile::Ptr > loadedProfiles() const
Returns a list of already loaded profiles.
Definition: ProfileManager.cpp:303
Konsole::KDE4ProfileReader
Reads a KDE 4 .profile file.
Definition: ProfileReader.h:54
QMap::insert
iterator insert(const Key &key, const T &value)
QListIterator
Konsole::ProfileManager::availableProfileNames
QStringList availableProfileNames() const
Returns a list of names of all available profiles.
Definition: ProfileManager.cpp:202
Konsole::ProfileManager::loadProfile
Profile::Ptr loadProfile(const QString &path)
Loads a profile from the specified path and registers it with the ProfileManager. ...
Definition: ProfileManager.cpp:119
Konsole::Profile::Path
(QString) Path to the profile's configuration file on-disk.
Definition: Profile.h:79
Konsole::ProfileManager::addProfile
void addProfile(Profile::Ptr type)
Registers a new type of session.
Definition: ProfileManager.cpp:369
Konsole::ProfileManager::setFavorite
void setFavorite(Profile::Ptr profile, bool favorite)
Specifies whether a profile should be included in the user's list of favorite profiles.
Definition: ProfileManager.cpp:442
Konsole::PopStackOnExit
PopStackOnExit is a utility to remove all values from a QStack which are added during the lifetime of...
Definition: ProfileManager.h:296
Konsole::ProfileManager::~ProfileManager
virtual ~ProfileManager()
Destroys the ProfileManager.
Definition: ProfileManager.cpp:109
Konsole::ProfileManager::fallbackProfile
Profile::Ptr fallbackProfile() const
Returns a Profile object with hard-coded settings which is always available.
Definition: ProfileManager.cpp:312
QList::begin
iterator begin()
Konsole::ProfileManager::profileChanged
void profileChanged(Profile::Ptr ptr)
Emitted when a profile's properties are modified.
QMapIterator::hasNext
bool hasNext() const
QStack
QMap::remove
int remove(const Key &key)
QList::replace
void replace(int i, const T &value)
Konsole::ProfileWriter
Interface for all classes which can write profile settings to a file.
Definition: ProfileWriter.h:32
profileIndexLessThan
static bool profileIndexLessThan(const Profile::Ptr &p1, const Profile::Ptr &p2)
Definition: ProfileManager.cpp:44
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