• 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
ViewManager.h
Go to the documentation of this file.
1 /*
2  Copyright 2006-2008 by Robert Knight <robertknight@gmail.com>
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301 USA.
18 */
19 
20 #ifndef VIEWMANAGER_H
21 #define VIEWMANAGER_H
22 
23 // Qt
24 #include <QtCore/QHash>
25 #include <QtCore/QObject>
26 #include <QtCore/QPointer>
27 
28 // Konsole
29 #include "Profile.h"
30 #include "ViewContainer.h"
31 
32 class QSignalMapper;
33 class KActionCollection;
34 class KConfigGroup;
35 
36 namespace Konsole
37 {
38 class ColorScheme;
39 class IncrementalSearchBar;
40 class Session;
41 class TerminalDisplay;
42 
43 class SessionController;
44 class ViewProperties;
45 class ViewSplitter;
46 
66 class KONSOLEPRIVATE_EXPORT ViewManager : public QObject
67 {
68  Q_OBJECT
69  Q_CLASSINFO("D-Bus Interface", "org.kde.konsole.Window")
70 
71 public:
77  ViewManager(QObject* parent , KActionCollection* collection);
78  ~ViewManager();
79 
84  void createView(Session* session);
85 
90  void applyProfileToView(TerminalDisplay* view , const Profile::Ptr profile);
91 
96  QWidget* widget() const;
97 
101  QWidget* activeView() const;
102 
110  QList<ViewProperties*> viewProperties() const;
111 
117  enum NavigationMethod {
122  TabbedNavigation,
124  NoNavigation
125  };
126 
130  enum NewTabBehavior {
132  PutNewTabAtTheEnd = 0,
134  PutNewTabAfterCurrentTab = 1
135  };
136 
144  void setNavigationMethod(NavigationMethod method);
145 
150  NavigationMethod navigationMethod() const;
151 
156  SessionController* activeViewController() const;
157 
161  IncrementalSearchBar* searchBar() const;
162 
166  void saveSessions(KConfigGroup& group);
167  void restoreSessions(const KConfigGroup& group);
168 
169  void setNavigationVisibility(int visibility);
170  void setNavigationPosition(int position);
171  void setNavigationBehavior(int behavior);
172  void setNavigationStyleSheet(const QString& styleSheet);
173  void setShowQuickButtons(bool show);
174 
175  int managerId() const;
176 
178  QList<Session*> sessions() { return _sessionMap.values(); }
179 
180 signals:
182  void empty();
183 
185  void viewDetached(Session* session);
186 
191  void activeViewChanged(SessionController* controller);
192 
197  void unplugController(SessionController* controller);
198 
204  void viewPropertiesChanged(const QList<ViewProperties*>& propertiesList);
205 
214  void splitViewToggle(bool multipleViews);
215 
220  void setMenuBarVisibleRequest(bool);
221  void updateWindowIcon();
222 
224  void newViewRequest();
226  void newViewRequest(Profile::Ptr);
227 
228 public slots:
230  Q_SCRIPTABLE int sessionCount();
231 
233  Q_SCRIPTABLE int currentSession();
234 
240  Q_SCRIPTABLE int newSession(QString profile, QString directory);
241 
242  // TODO: its semantic is application-wide. Move it to more appropriate place
243  // DBus slot that returns the name of default profile
244  Q_SCRIPTABLE QString defaultProfile();
245 
246  // TODO: its semantic is application-wide. Move it to more appropriate place
247  // DBus slot that returns a string list of defined (known) profiles
248  Q_SCRIPTABLE QStringList profileList();
249 
253  Q_SCRIPTABLE int newSession();
254 
256  Q_SCRIPTABLE void nextSession();
257 
259  Q_SCRIPTABLE void prevSession();
260 
265  Q_SCRIPTABLE void moveSessionLeft();
266 
271  Q_SCRIPTABLE void moveSessionRight();
272 
274  Q_SCRIPTABLE void setTabWidthToText(bool);
275 
276 private slots:
277  // called when the "Split View Left/Right" menu item is selected
278  void splitLeftRight();
279  void splitTopBottom();
280  void closeActiveContainer();
281  void closeOtherContainers();
282  void expandActiveContainer();
283  void shrinkActiveContainer();
284 
285  // called when the "Detach View" menu item is selected
286  void detachActiveView();
287  void updateDetachViewState();
288 
289  // called when a session terminates - the view manager will delete any
290  // views associated with the session
291  void sessionFinished();
292  // called when one view has been destroyed
293  void viewDestroyed(QWidget* widget);
294 
295  // controller detects when an associated view is given the focus
296  // and emits a signal. ViewManager listens for that signal
297  // and then plugs the action into the UI
298  //void viewFocused( SessionController* controller );
299 
300  // called when the active view in a ViewContainer changes, so
301  // that we can plug the appropriate actions into the UI
302  void viewActivated(QWidget* view);
303 
304  // called when "Next View" shortcut is activated
305  void nextView();
306 
307  // called when "Previous View" shortcut is activated
308  void previousView();
309 
310  // called when "Switch to last tab" shortcut is activated
311  void lastView();
312 
313  // called when "Next View Container" shortcut is activated
314  void nextContainer();
315 
316  // called when the views in a container owned by this view manager
317  // changes
318  void containerViewsChanged(QObject* container);
319 
320  // called when a profile changes
321  void profileChanged(Profile::Ptr profile);
322 
323  void updateViewsForSession(Session* session);
324 
325  // moves active view to the left
326  void moveActiveViewLeft();
327  // moves active view to the right
328  void moveActiveViewRight();
329  // switches to the view at visual position 'index'
330  // in the current container
331  void switchToView(int index);
332 
333  // called when a SessionController gains focus
334  void controllerChanged(SessionController* controller);
335 
336  // called when a ViewContainer requests a view be
337  // moved
338  void containerMoveViewRequest(int index, int id, bool& success, TabbedViewContainer* sourceTabbedContainer);
339 
340  void detachView(ViewContainer* container, QWidget* view);
341 
342  void closeTabFromContainer(ViewContainer* container, QWidget* view);
343 
344 private:
345  void createView(Session* session, ViewContainer* container, int index);
346  static const ColorScheme* colorSchemeForProfile(const Profile::Ptr profile);
347 
348  void setupActions();
349  void focusActiveView();
350 
351  // takes a view from a view container owned by a different manager and places it in
352  // newContainer owned by this manager
353  void takeView(ViewManager* otherManager , ViewContainer* otherContainer, ViewContainer* newContainer, TerminalDisplay* view);
354  void splitView(Qt::Orientation orientation);
355 
356  // creates a new container which can hold terminal displays
357  ViewContainer* createContainer();
358  // removes a container and emits appropriate signals
359  void removeContainer(ViewContainer* container);
360 
361  // creates a new terminal display
362  // the 'session' is used so that the terminal display's random seed
363  // can be set to something which depends uniquely on that session
364  TerminalDisplay* createTerminalDisplay(Session* session = 0);
365 
366  // creates a new controller for a session/display pair which provides the menu
367  // actions associated with that view, and exposes basic information
368  // about the session ( such as title and associated icon ) to the display.
369  SessionController* createController(Session* session , TerminalDisplay* display);
370 
371 private:
372  QPointer<ViewSplitter> _viewSplitter;
373  QPointer<SessionController> _pluggedController;
374 
375  QHash<TerminalDisplay*, Session*> _sessionMap;
376 
377  KActionCollection* _actionCollection;
378  QSignalMapper* _containerSignalMapper;
379 
380  NavigationMethod _navigationMethod;
381 
382  ViewContainer::NavigationVisibility _navigationVisibility;
383  ViewContainer::NavigationPosition _navigationPosition;
384  bool _showQuickButtons;
385  NewTabBehavior _newTabBehavior;
386  QString _navigationStyleSheet;
387 
388  int _managerId;
389  static int lastManagerId;
390 };
391 }
392 
393 #endif
QWidget
Konsole::Session
Represents a terminal session consisting of a pseudo-teletype and a terminal emulation.
Definition: Session.h:78
Konsole::SessionController
Provides the menu actions to manipulate a single terminal session and view pair.
Definition: SessionController.h:85
Konsole::ViewManager::TabbedNavigation
Each container has a row of tabs (one per session) which the user can click on to navigate between op...
Definition: ViewManager.h:122
Konsole::ViewManager::NewTabBehavior
NewTabBehavior
This enum describes where newly created tab should be placed.
Definition: ViewManager.h:130
Konsole::TabbedViewContainer
An alternative tabbed view container which uses a QTabBar and QStackedWidget combination for navigati...
Definition: ViewContainer.h:361
QPointer
Konsole::ViewManager::sessions
QList< Session * > sessions()
Returns a list of sessions in this ViewManager.
Definition: ViewManager.h:178
Konsole::ViewManager
Manages the terminal display widgets in a Konsole window or part.
Definition: ViewManager.h:66
Konsole::ViewContainer
An interface for container widgets which can hold one or more views.
Definition: ViewContainer.h:64
QHash
QObject
QString
QList
QStringList
Konsole::IncrementalSearchBar
A widget which allows users to search incrementally through a document for a a text string or regular...
Definition: IncrementalSearchBar.h:56
Konsole::Profile::Ptr
KSharedPtr< Profile > Ptr
Definition: Profile.h:67
KONSOLEPRIVATE_EXPORT
#define KONSOLEPRIVATE_EXPORT
Definition: konsole_export.h:33
ViewContainer.h
Konsole::ViewContainer::NavigationVisibility
NavigationVisibility
This enum describes the options for showing or hiding the container's navigation widget.
Definition: ViewContainer.h:106
Konsole::TerminalDisplay
A widget which displays output from a terminal emulation and sends input keypresses and mouse activit...
Definition: TerminalDisplay.h:63
QSignalMapper
Konsole::ViewContainer::NavigationPosition
NavigationPosition
This enum describes the options for positioning the container's navigation widget.
Definition: ViewContainer.h:73
Konsole::ViewManager::NavigationMethod
NavigationMethod
This enum describes the available types of navigation widget which newly created containers can provi...
Definition: ViewManager.h:117
Profile.h
Konsole::ColorScheme
Represents a color scheme for a terminal display.
Definition: ColorScheme.h:72
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