• 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
SessionManager.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 SESSIONMANAGER_H
23 #define SESSIONMANAGER_H
24 
25 // Qt
26 #include <QtCore/QHash>
27 #include <QtCore/QList>
28 
29 // Konsole
30 #include "Profile.h"
31 
32 class QSignalMapper;
33 
34 class KConfig;
35 
36 namespace Konsole
37 {
38 class Session;
39 
43 class KONSOLEPRIVATE_EXPORT SessionManager : public QObject
44 {
45  Q_OBJECT
46 
47 public:
52  SessionManager();
53 
58  virtual ~SessionManager();
59 
63  static SessionManager* instance();
64 
66  void closeAllSessions();
67 
79  Session* createSession(Profile::Ptr profile = Profile::Ptr());
80 
82  void setSessionProfile(Session* session, Profile::Ptr profile);
83 
85  Profile::Ptr sessionProfile(Session* session) const;
86 
90  const QList<Session*> sessions() const;
91 
92  // System session management
93  void saveSessions(KConfig* config);
94  void restoreSessions(KConfig* config);
95  int getRestoreId(Session* session);
96  Session* idToSession(int id);
97 
98 signals:
103  void sessionUpdated(Session* session);
104 
105 protected slots:
111  void sessionTerminated(QObject* session);
112 
113 private slots:
114  void sessionProfileCommandReceived(const QString& text);
115 
116  void profileChanged(Profile::Ptr profile);
117 
118 private:
119  // applies updates to a profile
120  // to all sessions currently using that profile
121  // if modifiedPropertiesOnly is true, only properties which
122  // are set in the profile @p key are updated
123  void applyProfile(Profile::Ptr profile , bool modifiedPropertiesOnly);
124 
125  // applies updates to the profile @p profile to the session @p session
126  // if modifiedPropertiesOnly is true, only properties which
127  // are set in @p profile are update ( ie. properties for which profile->isPropertySet(<property>)
128  // returns true )
129  void applyProfile(Session* session , const Profile::Ptr profile , bool modifiedPropertiesOnly);
130 
131  QList<Session*> _sessions; // list of running sessions
132 
133  QHash<Session*, Profile::Ptr> _sessionProfiles;
134  QHash<Session*, Profile::Ptr> _sessionRuntimeProfiles;
135  QHash<Session*, int> _restoreMapping;
136 
137  QSignalMapper* _sessionMapper;
138 };
139 
141 class ShouldApplyProperty
142 {
143 public:
144  ShouldApplyProperty(const Profile::Ptr profile , bool modifiedOnly) :
145  _profile(profile) , _modifiedPropertiesOnly(modifiedOnly) {}
146 
147  bool shouldApply(Profile::Property property) const {
148  return !_modifiedPropertiesOnly || _profile->isPropertySet(property);
149  }
150 private:
151  const Profile::Ptr _profile;
152  bool _modifiedPropertiesOnly;
153 };
154 }
155 #endif //SESSIONMANAGER_H
Konsole::Session
Represents a terminal session consisting of a pseudo-teletype and a terminal emulation.
Definition: Session.h:78
Konsole::ShouldApplyProperty::shouldApply
bool shouldApply(Profile::Property property) const
Definition: SessionManager.h:147
Konsole::Profile::Property
Property
This enum describes the available properties which a Profile may consist of.
Definition: Profile.h:77
QHash
QObject
Konsole::ShouldApplyProperty
Utility class to simplify code in SessionManager::applyProfile().
Definition: SessionManager.h:141
QString
QList
Konsole::Profile::Ptr
KSharedPtr< Profile > Ptr
Definition: Profile.h:67
KONSOLEPRIVATE_EXPORT
#define KONSOLEPRIVATE_EXPORT
Definition: konsole_export.h:33
Konsole::ShouldApplyProperty::ShouldApplyProperty
ShouldApplyProperty(const Profile::Ptr profile, bool modifiedOnly)
Definition: SessionManager.h:144
Konsole::SessionManager
Manages running terminal sessions.
Definition: SessionManager.h:43
QSignalMapper
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