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

Konsole

  • sources
  • kde-4.12
  • applications
  • konsole
  • src
ViewManager.cpp
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 // Own
21 #include "ViewManager.h"
22 
23 #include <config-konsole.h>
24 
25 // Qt
26 #include <QtCore/QSignalMapper>
27 #include <QtCore/QStringList>
28 #include <QMenu>
29 #include <QtDBus/QtDBus>
30 
31 // KDE
32 #include <KAcceleratorManager>
33 #include <KLocalizedString>
34 #include <KAction>
35 #include <KActionCollection>
36 #include <KConfigGroup>
37 
38 // Konsole
39 #include <windowadaptor.h>
40 
41 #include "ColorScheme.h"
42 #include "ColorSchemeManager.h"
43 #include "Session.h"
44 #include "TerminalDisplay.h"
45 #include "SessionController.h"
46 #include "SessionManager.h"
47 #include "ProfileManager.h"
48 #include "ViewContainer.h"
49 #include "ViewSplitter.h"
50 #include "Profile.h"
51 #include "Enumeration.h"
52 
53 using namespace Konsole;
54 
55 int ViewManager::lastManagerId = 0;
56 
57 ViewManager::ViewManager(QObject* parent , KActionCollection* collection)
58  : QObject(parent)
59  , _viewSplitter(0)
60  , _actionCollection(collection)
61  , _containerSignalMapper(new QSignalMapper(this))
62  , _navigationMethod(TabbedNavigation)
63  , _navigationVisibility(ViewContainer::AlwaysShowNavigation)
64  , _navigationPosition(ViewContainer::NavigationPositionTop)
65  , _showQuickButtons(false)
66  , _newTabBehavior(PutNewTabAtTheEnd)
67  , _navigationStyleSheet(QString())
68  , _managerId(0)
69 {
70  // create main view area
71  _viewSplitter = new ViewSplitter(0);
72  KAcceleratorManager::setNoAccel(_viewSplitter);
73 
74  // the ViewSplitter class supports both recursive and non-recursive splitting,
75  // in non-recursive mode, all containers are inserted into the same top-level splitter
76  // widget, and all the divider lines between the containers have the same orientation
77  //
78  // the ViewManager class is not currently able to handle a ViewSplitter in recursive-splitting
79  // mode
80  _viewSplitter->setRecursiveSplitting(false);
81  _viewSplitter->setFocusPolicy(Qt::NoFocus);
82 
83  // setup actions which are related to the views
84  setupActions();
85 
86  // emit a signal when all of the views held by this view manager are destroyed
87  connect(_viewSplitter , SIGNAL(allContainersEmpty()) , this , SIGNAL(empty()));
88  connect(_viewSplitter , SIGNAL(empty(ViewSplitter*)) , this , SIGNAL(empty()));
89 
90  // listen for addition or removal of views from associated containers
91  connect(_containerSignalMapper , SIGNAL(mapped(QObject*)) , this ,
92  SLOT(containerViewsChanged(QObject*)));
93 
94  // listen for profile changes
95  connect(ProfileManager::instance() , SIGNAL(profileChanged(Profile::Ptr)) , this,
96  SLOT(profileChanged(Profile::Ptr)));
97  connect(SessionManager::instance() , SIGNAL(sessionUpdated(Session*)) , this,
98  SLOT(updateViewsForSession(Session*)));
99 
100  //prepare DBus communication
101  new WindowAdaptor(this);
102  // TODO: remove this obsolete and bad name
103  QDBusConnection::sessionBus().registerObject(QLatin1String("/Konsole"), this);
104 
105  _managerId = ++lastManagerId;
106  QDBusConnection::sessionBus().registerObject(QLatin1String("/Windows/") + QString::number(_managerId), this);
107 }
108 
109 ViewManager::~ViewManager()
110 {
111 }
112 
113 int ViewManager::managerId() const
114 {
115  return _managerId;
116 }
117 
118 QWidget* ViewManager::activeView() const
119 {
120  ViewContainer* container = _viewSplitter->activeContainer();
121  if (container) {
122  return container->activeView();
123  } else {
124  return 0;
125  }
126 }
127 
128 QWidget* ViewManager::widget() const
129 {
130  return _viewSplitter;
131 }
132 
133 void ViewManager::setupActions()
134 {
135  KActionCollection* collection = _actionCollection;
136 
137  KAction* nextViewAction = new KAction(i18nc("@action Shortcut entry", "Next Tab") , this);
138  KAction* previousViewAction = new KAction(i18nc("@action Shortcut entry", "Previous Tab") , this);
139  KAction* lastViewAction = new KAction(i18nc("@action Shortcut entry", "Switch to Last Tab") , this);
140  KAction* nextContainerAction = new KAction(i18nc("@action Shortcut entry", "Next View Container") , this);
141 
142  KAction* moveViewLeftAction = new KAction(i18nc("@action Shortcut entry", "Move Tab Left") , this);
143  KAction* moveViewRightAction = new KAction(i18nc("@action Shortcut entry", "Move Tab Right") , this);
144 
145  // list of actions that should only be enabled when there are multiple view
146  // containers open
147  QList<QAction*> multiViewOnlyActions;
148  multiViewOnlyActions << nextContainerAction;
149 
150  if (collection) {
151  KAction* splitLeftRightAction = new KAction(KIcon("view-split-left-right"),
152  i18nc("@action:inmenu", "Split View Left/Right"),
153  this);
154  splitLeftRightAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_ParenLeft));
155  collection->addAction("split-view-left-right", splitLeftRightAction);
156  connect(splitLeftRightAction , SIGNAL(triggered()) , this , SLOT(splitLeftRight()));
157 
158  KAction* splitTopBottomAction = new KAction(KIcon("view-split-top-bottom") ,
159  i18nc("@action:inmenu", "Split View Top/Bottom"), this);
160  splitTopBottomAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_ParenRight));
161  collection->addAction("split-view-top-bottom", splitTopBottomAction);
162  connect(splitTopBottomAction , SIGNAL(triggered()) , this , SLOT(splitTopBottom()));
163 
164  KAction* closeActiveAction = new KAction(i18nc("@action:inmenu Close Active View", "Close Active") , this);
165  closeActiveAction->setIcon(KIcon("view-close"));
166  closeActiveAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_S));
167  closeActiveAction->setEnabled(false);
168  collection->addAction("close-active-view", closeActiveAction);
169  connect(closeActiveAction , SIGNAL(triggered()) , this , SLOT(closeActiveContainer()));
170 
171  multiViewOnlyActions << closeActiveAction;
172 
173  KAction* closeOtherAction = new KAction(i18nc("@action:inmenu Close Other Views", "Close Others") , this);
174  closeOtherAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_O));
175  closeOtherAction->setEnabled(false);
176  collection->addAction("close-other-views", closeOtherAction);
177  connect(closeOtherAction , SIGNAL(triggered()) , this , SLOT(closeOtherContainers()));
178 
179  multiViewOnlyActions << closeOtherAction;
180 
181  // Expand & Shrink Active View
182  KAction* expandActiveAction = new KAction(i18nc("@action:inmenu", "Expand View") , this);
183  expandActiveAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_BracketRight));
184  expandActiveAction->setEnabled(false);
185  collection->addAction("expand-active-view", expandActiveAction);
186  connect(expandActiveAction , SIGNAL(triggered()) , this , SLOT(expandActiveContainer()));
187 
188  multiViewOnlyActions << expandActiveAction;
189 
190  KAction* shrinkActiveAction = new KAction(i18nc("@action:inmenu", "Shrink View") , this);
191  shrinkActiveAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_BracketLeft));
192  shrinkActiveAction->setEnabled(false);
193  collection->addAction("shrink-active-view", shrinkActiveAction);
194  connect(shrinkActiveAction , SIGNAL(triggered()) , this , SLOT(shrinkActiveContainer()));
195 
196  multiViewOnlyActions << shrinkActiveAction;
197 
198 #if defined(ENABLE_DETACHING)
199  KAction* detachViewAction = collection->addAction("detach-view");
200  detachViewAction->setIcon(KIcon("tab-detach"));
201  detachViewAction->setText(i18nc("@action:inmenu", "D&etach Current Tab"));
202  // Ctrl+Shift+D is not used as a shortcut by default because it is too close
203  // to Ctrl+D - which will terminate the session in many cases
204  detachViewAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_H));
205 
206  connect(this , SIGNAL(splitViewToggle(bool)) , this , SLOT(updateDetachViewState()));
207  connect(detachViewAction , SIGNAL(triggered()) , this , SLOT(detachActiveView()));
208 #endif
209 
210  // Next / Previous View , Next Container
211  collection->addAction("next-view", nextViewAction);
212  collection->addAction("previous-view", previousViewAction);
213  collection->addAction("last-tab", lastViewAction);
214  collection->addAction("next-container", nextContainerAction);
215  collection->addAction("move-view-left", moveViewLeftAction);
216  collection->addAction("move-view-right", moveViewRightAction);
217 
218  // Switch to tab N shortcuts
219  const int SWITCH_TO_TAB_COUNT = 19;
220  QSignalMapper* switchToTabMapper = new QSignalMapper(this);
221  connect(switchToTabMapper, SIGNAL(mapped(int)), this, SLOT(switchToView(int)));
222  for (int i = 0; i < SWITCH_TO_TAB_COUNT; i++) {
223  KAction* switchToTabAction = new KAction(i18nc("@action Shortcut entry", "Switch to Tab %1", i + 1), this);
224  switchToTabMapper->setMapping(switchToTabAction, i);
225  connect(switchToTabAction, SIGNAL(triggered()), switchToTabMapper,
226  SLOT(map()));
227  collection->addAction(QString("switch-to-tab-%1").arg(i), switchToTabAction);
228  }
229  }
230 
231  foreach(QAction* action, multiViewOnlyActions) {
232  connect(this , SIGNAL(splitViewToggle(bool)) , action , SLOT(setEnabled(bool)));
233  }
234 
235  // keyboard shortcut only actions
236  nextViewAction->setShortcut(QKeySequence(Qt::SHIFT + Qt::Key_Right));
237  connect(nextViewAction, SIGNAL(triggered()) , this , SLOT(nextView()));
238  _viewSplitter->addAction(nextViewAction);
239 
240  previousViewAction->setShortcut(QKeySequence(Qt::SHIFT + Qt::Key_Left));
241  connect(previousViewAction, SIGNAL(triggered()) , this , SLOT(previousView()));
242  _viewSplitter->addAction(previousViewAction);
243 
244  nextContainerAction->setShortcut(QKeySequence(Qt::SHIFT + Qt::Key_Tab));
245  connect(nextContainerAction , SIGNAL(triggered()) , this , SLOT(nextContainer()));
246  _viewSplitter->addAction(nextContainerAction);
247 
248  moveViewLeftAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Left));
249  connect(moveViewLeftAction , SIGNAL(triggered()) , this , SLOT(moveActiveViewLeft()));
250  _viewSplitter->addAction(moveViewLeftAction);
251 
252  moveViewRightAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Right));
253  connect(moveViewRightAction , SIGNAL(triggered()) , this , SLOT(moveActiveViewRight()));
254  _viewSplitter->addAction(moveViewRightAction);
255 
256  connect(lastViewAction, SIGNAL(triggered()) , this , SLOT(lastView()));
257  _viewSplitter->addAction(lastViewAction);
258 }
259 void ViewManager::switchToView(int index)
260 {
261  Q_ASSERT(index >= 0);
262  ViewContainer* container = _viewSplitter->activeContainer();
263  Q_ASSERT(container);
264  QList<QWidget*> containerViews = container->views();
265  if (index >= containerViews.count())
266  return;
267  container->setActiveView(containerViews.at(index));
268 }
269 void ViewManager::updateDetachViewState()
270 {
271  if (!_actionCollection)
272  return;
273 
274  const bool splitView = _viewSplitter->containers().count() >= 2;
275  const bool shouldEnable = splitView ||
276  _viewSplitter->activeContainer()->views().count() >= 2;
277 
278  QAction* detachAction = _actionCollection->action("detach-view");
279 
280  if (detachAction && shouldEnable != detachAction->isEnabled())
281  detachAction->setEnabled(shouldEnable);
282 }
283 void ViewManager::moveActiveViewLeft()
284 {
285  ViewContainer* container = _viewSplitter->activeContainer();
286  Q_ASSERT(container);
287  container->moveActiveView(ViewContainer::MoveViewLeft);
288 }
289 void ViewManager::moveActiveViewRight()
290 {
291  ViewContainer* container = _viewSplitter->activeContainer();
292  Q_ASSERT(container);
293  container->moveActiveView(ViewContainer::MoveViewRight);
294 }
295 void ViewManager::nextContainer()
296 {
297  _viewSplitter->activateNextContainer();
298 }
299 
300 void ViewManager::nextView()
301 {
302  ViewContainer* container = _viewSplitter->activeContainer();
303 
304  Q_ASSERT(container);
305 
306  container->activateNextView();
307 }
308 
309 void ViewManager::previousView()
310 {
311  ViewContainer* container = _viewSplitter->activeContainer();
312 
313  Q_ASSERT(container);
314 
315  container->activatePreviousView();
316 }
317 
318 void ViewManager::lastView()
319 {
320  ViewContainer* container = _viewSplitter->activeContainer();
321 
322  Q_ASSERT(container);
323 
324  container->activateLastView();
325 }
326 
327 void ViewManager::detachActiveView()
328 {
329  // find the currently active view and remove it from its container
330  ViewContainer* container = _viewSplitter->activeContainer();
331 
332  detachView(container, container->activeView());
333 }
334 
335 void ViewManager::detachView(ViewContainer* container, QWidget* widgetView)
336 {
337 #if !defined(ENABLE_DETACHING)
338  return;
339 #endif
340 
341  TerminalDisplay * viewToDetach = qobject_cast<TerminalDisplay*>(widgetView);
342 
343  if (!viewToDetach)
344  return;
345 
346  emit viewDetached(_sessionMap[viewToDetach]);
347 
348  _sessionMap.remove(viewToDetach);
349 
350  // remove the view from this window
351  container->removeView(viewToDetach);
352  viewToDetach->deleteLater();
353 
354  // if the container from which the view was removed is now empty then it can be deleted,
355  // unless it is the only container in the window, in which case it is left empty
356  // so that there is always an active container
357  if (_viewSplitter->containers().count() > 1 &&
358  container->views().count() == 0) {
359  removeContainer(container);
360  }
361 }
362 
363 void ViewManager::sessionFinished()
364 {
365  // if this slot is called after the view manager's main widget
366  // has been destroyed, do nothing
367  if (!_viewSplitter)
368  return;
369 
370  Session* session = qobject_cast<Session*>(sender());
371  Q_ASSERT(session);
372 
373  // close attached views
374  QList<TerminalDisplay*> children = _viewSplitter->findChildren<TerminalDisplay*>();
375 
376  foreach(TerminalDisplay* view , children) {
377  if (_sessionMap[view] == session) {
378  _sessionMap.remove(view);
379  view->deleteLater();
380  }
381  }
382 
383  // This is needed to remove this controller from factory() in
384  // order to prevent BUG: 185466 - disappearing menu popup
385  if (_pluggedController)
386  emit unplugController(_pluggedController);
387 }
388 
389 void ViewManager::focusActiveView()
390 {
391  // give the active view in a container the focus. this ensures
392  // that controller associated with that view is activated and the session-specific
393  // menu items are replaced with the ones for the newly focused view
394 
395  // see the viewFocused() method
396 
397  ViewContainer* container = _viewSplitter->activeContainer();
398  if (container) {
399  QWidget* activeView = container->activeView();
400  if (activeView) {
401  activeView->setFocus(Qt::MouseFocusReason);
402  }
403  }
404 }
405 
406 void ViewManager::viewActivated(QWidget* view)
407 {
408  Q_ASSERT(view != 0);
409 
410  // focus the activated view, this will cause the SessionController
411  // to notify the world that the view has been focused and the appropriate UI
412  // actions will be plugged in.
413  view->setFocus(Qt::OtherFocusReason);
414 }
415 
416 void ViewManager::splitLeftRight()
417 {
418  splitView(Qt::Horizontal);
419 }
420 void ViewManager::splitTopBottom()
421 {
422  splitView(Qt::Vertical);
423 }
424 
425 void ViewManager::splitView(Qt::Orientation orientation)
426 {
427  ViewContainer* container = createContainer();
428 
429  // iterate over each session which has a view in the current active
430  // container and create a new view for that session in a new container
431  foreach(QWidget* view, _viewSplitter->activeContainer()->views()) {
432  Session* session = _sessionMap[qobject_cast<TerminalDisplay*>(view)];
433  TerminalDisplay* display = createTerminalDisplay(session);
434  const Profile::Ptr profile = SessionManager::instance()->sessionProfile(session);
435  applyProfileToView(display, profile);
436  ViewProperties* properties = createController(session, display);
437 
438  _sessionMap[display] = session;
439 
440  container->addView(display, properties);
441  session->addView(display);
442  }
443 
444  _viewSplitter->addContainer(container, orientation);
445  emit splitViewToggle(_viewSplitter->containers().count() > 0);
446 
447  // focus the new container
448  container->containerWidget()->setFocus();
449 
450  // ensure that the active view is focused after the split / unsplit
451  ViewContainer* activeContainer = _viewSplitter->activeContainer();
452  QWidget* activeView = activeContainer ? activeContainer->activeView() : 0;
453 
454  if (activeView)
455  activeView->setFocus(Qt::OtherFocusReason);
456 }
457 void ViewManager::removeContainer(ViewContainer* container)
458 {
459  // remove session map entries for views in this container
460  foreach(QWidget* view , container->views()) {
461  TerminalDisplay* display = qobject_cast<TerminalDisplay*>(view);
462  Q_ASSERT(display);
463  _sessionMap.remove(display);
464  }
465 
466  _viewSplitter->removeContainer(container);
467  container->deleteLater();
468 
469  emit splitViewToggle(_viewSplitter->containers().count() > 1);
470 }
471 void ViewManager::expandActiveContainer()
472 {
473  _viewSplitter->adjustContainerSize(_viewSplitter->activeContainer(), 10);
474 }
475 void ViewManager::shrinkActiveContainer()
476 {
477  _viewSplitter->adjustContainerSize(_viewSplitter->activeContainer(), -10);
478 }
479 void ViewManager::closeActiveContainer()
480 {
481  // only do something if there is more than one container active
482  if (_viewSplitter->containers().count() > 1) {
483  ViewContainer* container = _viewSplitter->activeContainer();
484 
485  removeContainer(container);
486 
487  // focus next container so that user can continue typing
488  // without having to manually focus it themselves
489  nextContainer();
490  }
491 }
492 void ViewManager::closeOtherContainers()
493 {
494  ViewContainer* active = _viewSplitter->activeContainer();
495 
496  foreach(ViewContainer* container, _viewSplitter->containers()) {
497  if (container != active)
498  removeContainer(container);
499  }
500 }
501 
502 SessionController* ViewManager::createController(Session* session , TerminalDisplay* view)
503 {
504  // create a new controller for the session, and ensure that this view manager
505  // is notified when the view gains the focus
506  SessionController* controller = new SessionController(session, view, this);
507  connect(controller , SIGNAL(focused(SessionController*)) , this , SLOT(controllerChanged(SessionController*)));
508  connect(session , SIGNAL(destroyed()) , controller , SLOT(deleteLater()));
509  connect(session , SIGNAL(primaryScreenInUse(bool)) ,
510  controller , SLOT(setupPrimaryScreenSpecificActions(bool)));
511  connect(session , SIGNAL(selectionChanged(QString)) ,
512  controller , SLOT(selectionChanged(QString)));
513  connect(view , SIGNAL(destroyed()) , controller , SLOT(deleteLater()));
514 
515  // if this is the first controller created then set it as the active controller
516  if (!_pluggedController)
517  controllerChanged(controller);
518 
519  return controller;
520 }
521 
522 void ViewManager::controllerChanged(SessionController* controller)
523 {
524  if (controller == _pluggedController)
525  return;
526 
527  _viewSplitter->setFocusProxy(controller->view());
528 
529  _pluggedController = controller;
530  emit activeViewChanged(controller);
531 }
532 
533 SessionController* ViewManager::activeViewController() const
534 {
535  return _pluggedController;
536 }
537 
538 IncrementalSearchBar* ViewManager::searchBar() const
539 {
540  return _viewSplitter->activeSplitter()->activeContainer()->searchBar();
541 }
542 
543 void ViewManager::createView(Session* session, ViewContainer* container, int index)
544 {
545  // notify this view manager when the session finishes so that its view
546  // can be deleted
547  //
548  // Use Qt::UniqueConnection to avoid duplicate connection
549  connect(session, SIGNAL(finished()), this, SLOT(sessionFinished()), Qt::UniqueConnection);
550 
551  TerminalDisplay* display = createTerminalDisplay(session);
552  const Profile::Ptr profile = SessionManager::instance()->sessionProfile(session);
553  applyProfileToView(display, profile);
554 
555  // set initial size
556  const QSize& preferredSize = session->preferredSize();
557  // FIXME: +1 is needed here for getting the expected rows
558  display->setSize(preferredSize.width(), preferredSize.height() + 1);
559 
560  ViewProperties* properties = createController(session, display);
561 
562  _sessionMap[display] = session;
563  container->addView(display, properties, index);
564  session->addView(display);
565 
566  // tell the session whether it has a light or dark background
567  session->setDarkBackground(colorSchemeForProfile(profile)->hasDarkBackground());
568 
569  if (container == _viewSplitter->activeContainer()) {
570  container->setActiveView(display);
571  display->setFocus(Qt::OtherFocusReason);
572  }
573 
574  updateDetachViewState();
575 }
576 
577 void ViewManager::createView(Session* session)
578 {
579  // create the default container
580  if (_viewSplitter->containers().count() == 0) {
581  ViewContainer* container = createContainer();
582  _viewSplitter->addContainer(container, Qt::Vertical);
583  emit splitViewToggle(false);
584  }
585 
586  // new tab will be put at the end by default.
587  int index = -1;
588 
589  if (_newTabBehavior == PutNewTabAfterCurrentTab) {
590  QWidget* view = activeView();
591  if (view) {
592  QList<QWidget*> views = _viewSplitter->activeContainer()->views();
593  index = views.indexOf(view) + 1;
594  }
595  }
596 
597  // iterate over the view containers owned by this view manager
598  // and create a new terminal display for the session in each of them, along with
599  // a controller for the session/display pair
600  foreach(ViewContainer* container, _viewSplitter->containers()) {
601  createView(session, container, index);
602  }
603 }
604 
605 ViewContainer* ViewManager::createContainer()
606 {
607  ViewContainer* container = 0;
608 
609  switch (_navigationMethod) {
610  case TabbedNavigation: {
611  container = new TabbedViewContainer(_navigationPosition, this, _viewSplitter);
612 
613  connect(container, SIGNAL(detachTab(ViewContainer*,QWidget*)),
614  this, SLOT(detachView(ViewContainer*,QWidget*))
615  );
616  connect(container, SIGNAL(closeTab(ViewContainer*,QWidget*)),
617  this, SLOT(closeTabFromContainer(ViewContainer*,QWidget*)));
618  }
619  break;
620  case NoNavigation:
621  default:
622  container = new StackedViewContainer(_viewSplitter);
623  }
624 
625  // FIXME: these code feels duplicated
626  container->setNavigationVisibility(_navigationVisibility);
627  container->setNavigationPosition(_navigationPosition);
628  container->setStyleSheet(_navigationStyleSheet);
629  if (_showQuickButtons) {
630  container->setFeatures(container->features()
631  | ViewContainer::QuickNewView
632  | ViewContainer::QuickCloseView);
633  } else {
634  container->setFeatures(container->features()
635  & ~ViewContainer::QuickNewView
636  & ~ViewContainer::QuickCloseView);
637  }
638 
639  // connect signals and slots
640  connect(container , SIGNAL(viewAdded(QWidget*,ViewProperties*)) , _containerSignalMapper ,
641  SLOT(map()));
642  connect(container , SIGNAL(viewRemoved(QWidget*)) , _containerSignalMapper ,
643  SLOT(map()));
644  _containerSignalMapper->setMapping(container, container);
645 
646  connect(container, SIGNAL(newViewRequest()), this, SIGNAL(newViewRequest()));
647  connect(container, SIGNAL(newViewRequest(Profile::Ptr)), this, SIGNAL(newViewRequest(Profile::Ptr)));
648  connect(container, SIGNAL(moveViewRequest(int,int,bool&,TabbedViewContainer*)),
649  this , SLOT(containerMoveViewRequest(int,int,bool&,TabbedViewContainer*)));
650  connect(container , SIGNAL(viewRemoved(QWidget*)) , this , SLOT(viewDestroyed(QWidget*)));
651  connect(container , SIGNAL(activeViewChanged(QWidget*)) , this , SLOT(viewActivated(QWidget*)));
652 
653  return container;
654 }
655 
656 void ViewManager::containerMoveViewRequest(int index, int id, bool& moved, TabbedViewContainer* sourceTabbedContainer)
657 {
658  ViewContainer* container = qobject_cast<ViewContainer*>(sender());
659  SessionController* controller = qobject_cast<SessionController*>(ViewProperties::propertiesById(id));
660 
661  if (!controller)
662  return;
663 
664  // do not move the last tab in a split view.
665  if (sourceTabbedContainer) {
666  QPointer<ViewContainer> sourceContainer = qobject_cast<ViewContainer*>(sourceTabbedContainer);
667 
668  if (_viewSplitter->containers().contains(sourceContainer)) {
669  return;
670  } else {
671  ViewManager* sourceViewManager = sourceTabbedContainer->connectedViewManager();
672 
673  // do not remove the last tab on the window
674  if (qobject_cast<ViewSplitter*>(sourceViewManager->widget())->containers().size() > 1) {
675  return;
676  }
677  }
678  }
679 
680  createView(controller->session(), container, index);
681  controller->session()->refresh();
682  moved = true;
683 }
684 
685 void ViewManager::setNavigationMethod(NavigationMethod method)
686 {
687  _navigationMethod = method;
688 
689  KActionCollection* collection = _actionCollection;
690 
691  if (collection) {
692  // FIXME: The following disables certain actions for the KPart that it
693  // doesn't actually have a use for, to avoid polluting the action/shortcut
694  // namespace of an application using the KPart (otherwise, a shortcut may
695  // be in use twice, and the user gets to see an "ambiguous shortcut over-
696  // load" error dialog). However, this approach sucks - it's the inverse of
697  // what it should be. Rather than disabling actions not used by the KPart,
698  // a method should be devised to only enable those that are used, perhaps
699  // by using a separate action collection.
700 
701  const bool enable = (_navigationMethod != NoNavigation);
702  QAction* action;
703 
704  action = collection->action("next-view");
705  if (action) action->setEnabled(enable);
706 
707  action = collection->action("previous-view");
708  if (action) action->setEnabled(enable);
709 
710  action = collection->action("last-tab");
711  if (action) action->setEnabled(enable);
712 
713  action = collection->action("split-view-left-right");
714  if (action) action->setEnabled(enable);
715 
716  action = collection->action("split-view-top-bottom");
717  if (action) action->setEnabled(enable);
718 
719  action = collection->action("rename-session");
720  if (action) action->setEnabled(enable);
721 
722  action = collection->action("move-view-left");
723  if (action) action->setEnabled(enable);
724 
725  action = collection->action("move-view-right");
726  if (action) action->setEnabled(enable);
727  }
728 }
729 
730 ViewManager::NavigationMethod ViewManager::navigationMethod() const
731 {
732  return _navigationMethod;
733 }
734 
735 void ViewManager::containerViewsChanged(QObject* container)
736 {
737  if (_viewSplitter && container == _viewSplitter->activeContainer()) {
738  emit viewPropertiesChanged(viewProperties());
739  }
740 }
741 
742 void ViewManager::viewDestroyed(QWidget* view)
743 {
744  // Note: the received QWidget has already been destroyed, so
745  // using dynamic_cast<> or qobject_cast<> does not work here
746  TerminalDisplay* display = static_cast<TerminalDisplay*>(view);
747  Q_ASSERT(display);
748 
749  // 1. detach view from session
750  // 2. if the session has no views left, close it
751  Session* session = _sessionMap[ display ];
752  _sessionMap.remove(display);
753  if (session) {
754  display->deleteLater();
755 
756  if (session->views().count() == 0)
757  session->close();
758  }
759  //we only update the focus if the splitter is still alive
760  if (_viewSplitter) {
761  focusActiveView();
762  updateDetachViewState();
763  }
764  // The below causes the menus to be messed up
765  // Only happens when using the tab bar close button
766 // if (_pluggedController)
767 // emit unplugController(_pluggedController);
768 }
769 
770 TerminalDisplay* ViewManager::createTerminalDisplay(Session* session)
771 {
772  TerminalDisplay* display = new TerminalDisplay(0);
773  display->setRandomSeed(session->sessionId() * 31);
774 
775  return display;
776 }
777 
778 const ColorScheme* ViewManager::colorSchemeForProfile(const Profile::Ptr profile)
779 {
780  const ColorScheme* colorScheme = ColorSchemeManager::instance()->
781  findColorScheme(profile->colorScheme());
782  if (!colorScheme)
783  colorScheme = ColorSchemeManager::instance()->defaultColorScheme();
784  Q_ASSERT(colorScheme);
785 
786  return colorScheme;
787 }
788 
789 void ViewManager::applyProfileToView(TerminalDisplay* view , const Profile::Ptr profile)
790 {
791  Q_ASSERT(profile);
792 
793  emit setSaveGeometryOnExitRequest(profile->saveGeometryOnExit());
794 
795  emit updateWindowIcon();
796 
797  // load color scheme
798  ColorEntry table[TABLE_COLORS];
799  const ColorScheme* colorScheme = colorSchemeForProfile(profile);
800  colorScheme->getColorTable(table , view->randomSeed());
801  view->setColorTable(table);
802  view->setOpacity(colorScheme->opacity());
803  view->setWallpaper(colorScheme->wallpaper());
804 
805  // load font
806  view->setAntialias(profile->antiAliasFonts());
807  view->setBoldIntense(profile->boldIntense());
808  view->setVTFont(profile->font());
809 
810  // set scroll-bar position
811  int scrollBarPosition = profile->property<int>(Profile::ScrollBarPosition);
812 
813  if (scrollBarPosition == Enum::ScrollBarLeft)
814  view->setScrollBarPosition(Enum::ScrollBarLeft);
815  else if (scrollBarPosition == Enum::ScrollBarRight)
816  view->setScrollBarPosition(Enum::ScrollBarRight);
817  else if (scrollBarPosition == Enum::ScrollBarHidden)
818  view->setScrollBarPosition(Enum::ScrollBarHidden);
819 
820  bool scrollFullPage = profile->property<bool>(Profile::ScrollFullPage);
821  view->setScrollFullPage(scrollFullPage);
822 
823  // show hint about terminal size after resizing
824  view->setShowTerminalSizeHint(profile->showTerminalSizeHint());
825 
826  // terminal features
827  view->setBlinkingCursorEnabled(profile->blinkingCursorEnabled());
828  view->setBlinkingTextEnabled(profile->blinkingTextEnabled());
829 
830  int tripleClickMode = profile->property<int>(Profile::TripleClickMode);
831  view->setTripleClickMode(Enum::TripleClickModeEnum(tripleClickMode));
832 
833  view->setAutoCopySelectedText(profile->autoCopySelectedText());
834  view->setUnderlineLinks(profile->underlineLinksEnabled());
835  view->setControlDrag(profile->property<bool>(Profile::CtrlRequiredForDrag));
836  view->setBidiEnabled(profile->bidiRenderingEnabled());
837  view->setLineSpacing(profile->lineSpacing());
838  view->setTrimTrailingSpaces(profile->property<bool>(Profile::TrimTrailingSpacesInSelectedText));
839 
840  view->setOpenLinksByDirectClick(profile->property<bool>(Profile::OpenLinksByDirectClickEnabled));
841 
842  int middleClickPasteMode = profile->property<int>(Profile::MiddleClickPasteMode);
843  if (middleClickPasteMode == Enum::PasteFromX11Selection)
844  view->setMiddleClickPasteMode(Enum::PasteFromX11Selection);
845  else if (middleClickPasteMode == Enum::PasteFromClipboard)
846  view->setMiddleClickPasteMode(Enum::PasteFromClipboard);
847 
848  // margin/center - these are hard-fixed ATM
849  view->setMargin(1);
850  view->setCenterContents(false);
851 
852  // cursor shape
853  int cursorShape = profile->property<int>(Profile::CursorShape);
854 
855  if (cursorShape == Enum::BlockCursor)
856  view->setKeyboardCursorShape(Enum::BlockCursor);
857  else if (cursorShape == Enum::IBeamCursor)
858  view->setKeyboardCursorShape(Enum::IBeamCursor);
859  else if (cursorShape == Enum::UnderlineCursor)
860  view->setKeyboardCursorShape(Enum::UnderlineCursor);
861 
862  // cursor color
863  if (profile->useCustomCursorColor()) {
864  const QColor& cursorColor = profile->customCursorColor();
865  view->setKeyboardCursorColor(cursorColor);
866  } else {
867  // an invalid QColor is used to inform the view widget to
868  // draw the cursor using the default color( matching the text)
869  view->setKeyboardCursorColor(QColor());
870  }
871 
872  // word characters
873  view->setWordCharacters(profile->wordCharacters());
874 
875  // bell mode
876  view->setBellMode(profile->property<int>(Profile::BellMode));
877 
878  // mouse wheel zoom
879  view->setMouseWheelZoom(profile->mouseWheelZoomEnabled());
880 }
881 
882 void ViewManager::updateViewsForSession(Session* session)
883 {
884  const Profile::Ptr profile = SessionManager::instance()->sessionProfile(session);
885 
886  foreach(TerminalDisplay* view, _sessionMap.keys(session)) {
887  applyProfileToView(view, profile);
888  }
889 }
890 
891 void ViewManager::profileChanged(Profile::Ptr profile)
892 {
893  // update all views associated with this profile
894  QHashIterator<TerminalDisplay*, Session*> iter(_sessionMap);
895  while (iter.hasNext()) {
896  iter.next();
897 
898  // if session uses this profile, update the display
899  if (iter.key() != 0 &&
900  iter.value() != 0 &&
901  SessionManager::instance()->sessionProfile(iter.value()) == profile) {
902  applyProfileToView(iter.key(), profile);
903  }
904  }
905 }
906 
907 QList<ViewProperties*> ViewManager::viewProperties() const
908 {
909  QList<ViewProperties*> list;
910 
911  ViewContainer* container = _viewSplitter->activeContainer();
912 
913  Q_ASSERT(container);
914 
915  foreach(QWidget* view, container->views()) {
916  ViewProperties* properties = container->viewProperties(view);
917  Q_ASSERT(properties);
918  list << properties;
919  }
920 
921  return list;
922 }
923 
924 void ViewManager::saveSessions(KConfigGroup& group)
925 {
926  // find all unique session restore IDs
927  QList<int> ids;
928  QHash<Session*, int> unique;
929 
930  // first: sessions in the active container, preserving the order
931  ViewContainer* container = _viewSplitter->activeContainer();
932  Q_ASSERT(container);
933  TerminalDisplay* activeview = qobject_cast<TerminalDisplay*>(container->activeView());
934 
935  QListIterator<QWidget*> viewIter(container->views());
936  int tab = 1;
937  while (viewIter.hasNext()) {
938  TerminalDisplay* view = qobject_cast<TerminalDisplay*>(viewIter.next());
939  Q_ASSERT(view);
940  Session* session = _sessionMap[view];
941  ids << SessionManager::instance()->getRestoreId(session);
942  if (view == activeview) group.writeEntry("Active", tab);
943  unique.insert(session, 1);
944  tab++;
945  }
946 
947  // second: all other sessions, in random order
948  // we don't want to have sessions restored that are not connected
949  foreach(Session * session, _sessionMap) {
950  if (!unique.contains(session)) {
951  ids << SessionManager::instance()->getRestoreId(session);
952  unique.insert(session, 1);
953  }
954  }
955 
956  group.writeEntry("Sessions", ids);
957 }
958 
959 void ViewManager::restoreSessions(const KConfigGroup& group)
960 {
961  QList<int> ids = group.readEntry("Sessions", QList<int>());
962  int activeTab = group.readEntry("Active", 0);
963  TerminalDisplay* display = 0;
964 
965  int tab = 1;
966  foreach(int id, ids) {
967  Session* session = SessionManager::instance()->idToSession(id);
968  createView(session);
969  if (!session->isRunning())
970  session->run();
971  if (tab++ == activeTab)
972  display = qobject_cast<TerminalDisplay*>(activeView());
973  }
974 
975  if (display) {
976  _viewSplitter->activeContainer()->setActiveView(display);
977  display->setFocus(Qt::OtherFocusReason);
978  }
979 
980  if (ids.isEmpty()) { // Session file is unusable, start default Profile
981  Profile::Ptr profile = ProfileManager::instance()->defaultProfile();
982  Session* session = SessionManager::instance()->createSession(profile);
983  createView(session);
984  if (!session->isRunning())
985  session->run();
986  }
987 }
988 
989 uint qHash(QPointer<TerminalDisplay> display)
990 {
991  return qHash((TerminalDisplay*)display);
992 }
993 
994 int ViewManager::sessionCount()
995 {
996  return this->_sessionMap.size();
997 }
998 
999 int ViewManager::currentSession()
1000 {
1001  QHash<TerminalDisplay*, Session*>::iterator i;
1002  for (i = this->_sessionMap.begin(); i != this->_sessionMap.end(); ++i)
1003  if (i.key()->isVisible())
1004  return i.value()->sessionId();
1005  return -1;
1006 }
1007 
1008 int ViewManager::newSession()
1009 {
1010  Profile::Ptr profile = ProfileManager::instance()->defaultProfile();
1011  Session* session = SessionManager::instance()->createSession(profile);
1012 
1013  this->createView(session);
1014  session->run();
1015 
1016  return session->sessionId();
1017 }
1018 
1019 int ViewManager::newSession(QString profile, QString directory)
1020 {
1021  const QList<Profile::Ptr> profilelist = ProfileManager::instance()->allProfiles();
1022  Profile::Ptr profileptr = ProfileManager::instance()->defaultProfile();
1023 
1024  for (int i = 0; i < profilelist.size(); ++i) {
1025  if (profilelist.at(i)->name() == profile) {
1026  profileptr = profilelist.at(i);
1027  break;
1028  }
1029  }
1030 
1031  Session* session = SessionManager::instance()->createSession(profileptr);
1032  session->setInitialWorkingDirectory(directory);
1033 
1034  this->createView(session);
1035  session->run();
1036 
1037  return session->sessionId();
1038 }
1039 
1040 QString ViewManager::defaultProfile()
1041 {
1042  return ProfileManager::instance()->defaultProfile()->name();
1043 }
1044 
1045 QStringList ViewManager::profileList()
1046 {
1047  return ProfileManager::instance()->availableProfileNames();
1048 }
1049 
1050 void ViewManager::nextSession()
1051 {
1052  this->nextView();
1053 }
1054 
1055 void ViewManager::prevSession()
1056 {
1057  this->previousView();
1058 }
1059 
1060 void ViewManager::moveSessionLeft()
1061 {
1062  this->moveActiveViewLeft();
1063 }
1064 
1065 void ViewManager::moveSessionRight()
1066 {
1067  this->moveActiveViewRight();
1068 }
1069 
1070 void ViewManager::setTabWidthToText(bool useTextWidth)
1071 {
1072  ViewContainer* container = _viewSplitter->activeContainer();
1073  Q_ASSERT(container);
1074  container->setNavigationTextMode(useTextWidth);
1075 }
1076 
1077 void ViewManager::closeTabFromContainer(ViewContainer* container, QWidget* tab)
1078 {
1079  SessionController* controller = qobject_cast<SessionController*>(container->viewProperties(tab));
1080  Q_ASSERT(controller);
1081  if (controller)
1082  controller->closeSession();
1083 }
1084 
1085 void ViewManager::setNavigationVisibility(int visibility)
1086 {
1087  _navigationVisibility =
1088  static_cast<ViewContainer::NavigationVisibility>(visibility);
1089 
1090  foreach(ViewContainer* container, _viewSplitter->containers()) {
1091  container->setNavigationVisibility(_navigationVisibility);
1092  }
1093 }
1094 
1095 void ViewManager::setNavigationPosition(int position)
1096 {
1097  _navigationPosition =
1098  static_cast<ViewContainer::NavigationPosition>(position);
1099 
1100  foreach(ViewContainer* container, _viewSplitter->containers()) {
1101  Q_ASSERT(container->supportedNavigationPositions().contains(_navigationPosition));
1102  container->setNavigationPosition(_navigationPosition);
1103  }
1104 }
1105 
1106 void ViewManager::setNavigationStyleSheet(const QString& styleSheet)
1107 {
1108  _navigationStyleSheet = styleSheet;
1109 
1110  foreach(ViewContainer* container, _viewSplitter->containers()) {
1111  container->setStyleSheet(_navigationStyleSheet);
1112  }
1113 }
1114 
1115 void ViewManager::setShowQuickButtons(bool show)
1116 {
1117  _showQuickButtons = show;
1118 
1119  foreach(ViewContainer* container, _viewSplitter->containers()) {
1120  if (_showQuickButtons) {
1121  container->setFeatures(container->features()
1122  | ViewContainer::QuickNewView
1123  | ViewContainer::QuickCloseView);
1124  } else {
1125  container->setFeatures(container->features()
1126  & ~ViewContainer::QuickNewView
1127  & ~ViewContainer::QuickCloseView);
1128  }
1129  }
1130 }
1131 
1132 
1133 void ViewManager::setNavigationBehavior(int behavior)
1134 {
1135  _newTabBehavior = static_cast<NewTabBehavior>(behavior);
1136 }
1137 
1138 #include "ViewManager.moc"
1139 
Konsole::TerminalDisplay::setWordCharacters
void setWordCharacters(const QString &wc)
Sets which characters, in addition to letters and numbers, are regarded as being part of a word for t...
Definition: TerminalDisplay.cpp:2658
Session.h
Konsole::Session::run
void run()
Starts the terminal session.
Definition: Session.cpp:422
TABLE_COLORS
#define TABLE_COLORS
Definition: CharacterColor.h:118
Konsole::SessionManager::instance
static SessionManager * instance()
Returns the session manager instance.
Definition: SessionManager.cpp:69
Konsole::TerminalDisplay::setMouseWheelZoom
void setMouseWheelZoom(bool value)
Specified whether zoom terminal on Ctrl+mousewheel is enabled or not.
Definition: TerminalDisplay.h:347
Konsole::Session
Represents a terminal session consisting of a pseudo-teletype and a terminal emulation.
Definition: Session.h:67
Konsole::SessionController
Provides the menu actions to manipulate a single terminal session and view pair.
Definition: SessionController.h:85
Konsole::ViewManager::PutNewTabAfterCurrentTab
Put newly created tab right after current tab.
Definition: ViewManager.h:134
Konsole::ViewManager::activeView
QWidget * activeView() const
Returns the view manager's active view.
Definition: ViewManager.cpp:118
Konsole::SessionManager::idToSession
Session * idToSession(int id)
Definition: SessionManager.cpp:321
Konsole::TerminalDisplay::setBlinkingCursorEnabled
void setBlinkingCursorEnabled(bool blink)
Specifies whether or not the cursor can blink.
Definition: TerminalDisplay.cpp:1510
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::TerminalDisplay::setWallpaper
void setWallpaper(ColorSchemeWallpaper::Ptr p)
Sets the background picture.
Definition: TerminalDisplay.cpp:594
Konsole::TerminalDisplay::setVTFont
void setVTFont(const QFont &font)
Sets the font used to draw the display.
Definition: TerminalDisplay.cpp:205
Konsole::TerminalDisplay::setTripleClickMode
void setTripleClickMode(Enum::TripleClickModeEnum mode)
Sets how the text is selected when the user triple clicks within the display.
Definition: TerminalDisplay.h:166
Konsole::ViewManager::NewTabBehavior
NewTabBehavior
This enum describes where newly created tab should be placed.
Definition: ViewManager.h:130
Konsole::ViewManager::saveSessions
void saveSessions(KConfigGroup &group)
Session management.
Definition: ViewManager.cpp:924
Konsole::ViewManager::sessionCount
Q_SCRIPTABLE int sessionCount()
DBus slot that returns the number of sessions in the current view.
Definition: ViewManager.cpp:994
Konsole::Enum::UnderlineCursor
Draw a line underneath the cursor's position.
Definition: Enumeration.h:88
Konsole::Session::sessionId
int sessionId() const
Returns the unique ID for this session.
Definition: Session.cpp:893
Konsole::TabbedViewContainer
An alternative tabbed view container which uses a QTabBar and QStackedWidget combination for navigati...
Definition: ViewContainer.h:361
Konsole::ViewManager::managerId
int managerId() const
Definition: ViewManager.cpp:113
Konsole::ViewContainer::activateNextView
void activateNextView()
Changes the active view to the next view.
Definition: ViewContainer.cpp:209
Konsole::ViewManager::empty
void empty()
Emitted when the last view is removed from the view manager.
Konsole::TerminalDisplay::setBellMode
void setBellMode(int mode)
Sets the type of effect used to alert the user when a 'bell' occurs in the terminal session...
Definition: TerminalDisplay.cpp:3013
Konsole::ViewContainer::addView
void addView(QWidget *view, ViewProperties *navigationItem, int index=-1)
Adds a new view to the container widget.
Definition: ViewContainer.cpp:138
QWidget
Konsole::ViewManager::moveSessionRight
Q_SCRIPTABLE void moveSessionRight()
DBus slot that Switches the current session (as returned by currentSession()) with the right (or next...
Definition: ViewManager.cpp:1065
Konsole::ViewManager::updateWindowIcon
void updateWindowIcon()
Konsole::SessionController::view
QPointer< TerminalDisplay > view()
Returns the view associated with this controller.
Definition: SessionController.h:112
Konsole::Profile::TrimTrailingSpacesInSelectedText
(bool) If true, trailing spaces are trimmed in selected text
Definition: Profile.h:213
Konsole::ViewManager::setShowQuickButtons
void setShowQuickButtons(bool show)
Definition: ViewManager.cpp:1115
Konsole::ColorScheme::getColorTable
void getColorTable(ColorEntry *table, uint randomSeed=0) const
Copies the color entries which form the palette for this color scheme into table. ...
Definition: ColorScheme.cpp:222
Konsole::ViewManager::defaultProfile
Q_SCRIPTABLE QString defaultProfile()
Definition: ViewManager.cpp:1040
Konsole::TerminalDisplay::setUnderlineLinks
void setUnderlineLinks(bool value)
Specifies whether links and email addresses should be underlined when hovered by the mouse...
Definition: TerminalDisplay.h:178
Konsole::ViewManager::nextSession
Q_SCRIPTABLE void nextSession()
DBus slot that changes the view port to the next session.
Definition: ViewManager.cpp:1050
Konsole::Enum::PasteFromX11Selection
Paste from X11 Selection.
Definition: Enumeration.h:102
Konsole::Profile::MiddleClickPasteMode
(MiddleClickPasteModeEnum) Specifies the source from which mouse middle click pastes data...
Definition: Profile.h:223
Konsole::ViewManager::currentSession
Q_SCRIPTABLE int currentSession()
DBus slot that returns the current (active) session window.
Definition: ViewManager.cpp:999
QObject
Konsole::ViewManager::setSaveGeometryOnExitRequest
void setSaveGeometryOnExitRequest(bool)
Konsole::Session::setDarkBackground
void setDarkBackground(bool darkBackground)
Sets whether the session has a dark background or not.
Definition: Session.cpp:235
Konsole::TerminalDisplay::setKeyboardCursorColor
void setKeyboardCursorColor(const QColor &color)
Sets the color used to draw the keyboard cursor.
Definition: TerminalDisplay.cpp:566
Konsole::Session::views
QList< TerminalDisplay * > views() const
Returns the views connected to this session.
Definition: Session.cpp:303
Konsole::ViewContainer::setFeatures
virtual void setFeatures(Features features)
Sets which additional features are enabled in this container.
Definition: ViewContainer.cpp:75
Konsole::SessionManager::sessionProfile
Profile::Ptr sessionProfile(Session *session) const
Returns the profile associated with a session.
Definition: SessionManager.cpp:141
Konsole::Enum::ScrollBarHidden
Do not show the scroll-bar.
Definition: Enumeration.h:64
Konsole::TerminalDisplay::setScrollFullPage
void setScrollFullPage(bool fullPage)
Definition: TerminalDisplay.cpp:1841
ColorSchemeManager.h
Konsole::ViewManager::profileList
Q_SCRIPTABLE QStringList profileList()
Definition: ViewManager.cpp:1045
Konsole::Enum::BlockCursor
Use a solid rectangular block to draw the cursor.
Definition: Enumeration.h:82
Konsole::ViewContainer::moveActiveView
void moveActiveView(MoveDirection direction)
Moves the active view within the container and updates the order in which the views are shown in the ...
Definition: ViewContainer.cpp:83
Konsole::TerminalDisplay::setAutoCopySelectedText
void setAutoCopySelectedText(bool enabled)
Definition: TerminalDisplay.cpp:2710
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
Konsole::ViewManager::setNavigationPosition
void setNavigationPosition(int position)
Definition: ViewManager.cpp:1095
Konsole::ProfileManager::defaultProfile
Profile::Ptr defaultProfile() const
Returns a Profile object describing the default profile.
Definition: ProfileManager.cpp:308
Konsole::TabbedViewContainer::connectedViewManager
ViewManager * connectedViewManager()
Definition: ViewContainer.cpp:714
Konsole::SessionManager::getRestoreId
int getRestoreId(Session *session)
Definition: SessionManager.cpp:295
Konsole::Session::isRunning
bool isRunning() const
Returns true if the session is currently running.
Definition: Session.cpp:240
Konsole::ViewContainer::containerWidget
virtual QWidget * containerWidget() const =0
Returns the widget which contains the view widgets.
Konsole::ViewSplitter
A splitter which holds a number of ViewContainer objects and allows the user to control the size of e...
Definition: ViewSplitter.h:47
Konsole::ColorScheme::opacity
qreal opacity() const
Returns the opacity level for this color scheme, see setOpacity() TODO: More documentation.
Definition: ColorScheme.cpp:284
Konsole::ProfileManager::allProfiles
QList< Profile::Ptr > allProfiles()
Returns a list of all available profiles.
Definition: ProfileManager.cpp:296
Konsole::ViewManager::setNavigationMethod
void setNavigationMethod(NavigationMethod method)
Sets the type of widget provided to navigate between open sessions in a container.
Definition: ViewManager.cpp:685
TerminalDisplay.h
Konsole::ProfileManager::instance
static ProfileManager * instance()
Returns the profile manager instance.
Definition: ProfileManager.cpp:114
Konsole::TerminalDisplay::setBidiEnabled
void setBidiEnabled(bool set)
Sets the status of the BiDi rendering inside the terminal display.
Definition: TerminalDisplay.h:431
Konsole::TerminalDisplay::setAntialias
void setAntialias(bool value)
Specified whether anti-aliasing of text in the terminal display is enabled or not.
Definition: TerminalDisplay.h:386
Konsole::ViewContainer::QuickNewView
Provides a button which can be clicked to create new views quickly.
Definition: ViewContainer.h:240
qHash
uint qHash(QPointer< TerminalDisplay > display)
Definition: ViewManager.cpp:989
Konsole::ViewManager::restoreSessions
void restoreSessions(const KConfigGroup &group)
Definition: ViewManager.cpp:959
Konsole::ColorEntry
An entry in a terminal display's color palette.
Definition: CharacterColor.h:40
Konsole::ViewManager::viewDetached
void viewDetached(Session *session)
Emitted when a session is detached from a view owned by this ViewManager.
Konsole::Profile::ScrollFullPage
(bool) Specifies whether the PageUp/Down will scroll the full height or half height.
Definition: Profile.h:157
Konsole::ViewContainer::setStyleSheet
virtual void setStyleSheet(const QString &styleSheet)
Sets the stylesheet for visual appearance.
Definition: ViewContainer.h:172
Konsole::ViewManager::setNavigationVisibility
void setNavigationVisibility(int visibility)
Definition: ViewManager.cpp:1085
Konsole::ViewManager::prevSession
Q_SCRIPTABLE void prevSession()
DBus slot that changes the view port to the previous session.
Definition: ViewManager.cpp:1055
Konsole::ViewManager::setNavigationStyleSheet
void setNavigationStyleSheet(const QString &styleSheet)
Definition: ViewManager.cpp:1106
Konsole::ViewManager::navigationMethod
NavigationMethod navigationMethod() const
Returns the type of navigation widget created in new containers.
Definition: ViewManager.cpp:730
Konsole::ViewContainer::setNavigationPosition
void setNavigationPosition(NavigationPosition position)
Sets the position of the navigation widget with respect to the main content area. ...
Definition: ViewContainer.cpp:115
Konsole::ViewContainer::activatePreviousView
void activatePreviousView()
Changes the active view to the previous view.
Definition: ViewContainer.cpp:231
Konsole::ViewManager::moveSessionLeft
Q_SCRIPTABLE void moveSessionLeft()
DBus slot that switches the current session (as returned by currentSession()) with the left (or previ...
Definition: ViewManager.cpp:1060
Konsole::TerminalDisplay::setColorTable
void setColorTable(const ColorEntry table[])
Sets the terminal color palette used by the display.
Definition: TerminalDisplay.cpp:152
Konsole::ViewContainer::activeView
virtual QWidget * activeView() const =0
Returns the view which currently has the focus or 0 if none of the child views have the focus...
Konsole::Session::setInitialWorkingDirectory
void setInitialWorkingDirectory(const QString &dir)
Sets the initial working directory for the session when it is run This has no effect once the session...
Definition: Session.cpp:277
Konsole::Session::addView
void addView(TerminalDisplay *widget)
Adds a new view for this session.
Definition: Session.cpp:308
Konsole::ViewManager::applyProfileToView
void applyProfileToView(TerminalDisplay *view, const Profile::Ptr profile)
Applies the view-specific settings associated with specified profile to the terminal display view...
Definition: ViewManager.cpp:789
Konsole::Profile::BellMode
(BellModeEnum) Specifies the behavior of bell.
Definition: Profile.h:241
Konsole::Profile::TripleClickMode
(TripleClickModeEnum) Specifies which part of current line should be selected with triple click actio...
Definition: Profile.h:201
Konsole::TerminalDisplay::setScrollBarPosition
void setScrollBarPosition(Enum::ScrollBarPositionEnum position)
Specifies whether the terminal display has a vertical scroll bar, and if so whether it is shown on th...
Definition: TerminalDisplay.cpp:1787
Enumeration.h
Konsole::TerminalDisplay::setCenterContents
void setCenterContents(bool enable)
Sets whether the contents are centered between the margins.
Definition: TerminalDisplay.cpp:1774
Konsole::TerminalDisplay::setMiddleClickPasteMode
void setMiddleClickPasteMode(Enum::MiddleClickPasteModeEnum mode)
Definition: TerminalDisplay.cpp:2715
Konsole::ViewManager::unplugController
void unplugController(SessionController *controller)
Emitted when the current session needs unplugged from factory().
Konsole::ViewContainer::QuickCloseView
Provides a button which can be clicked to close views quickly.
Definition: ViewContainer.h:242
Konsole::Enum::PasteFromClipboard
Paste from Clipboard.
Definition: Enumeration.h:104
Konsole::ViewProperties
Encapsulates user-visible information about the terminal session currently being displayed in a view...
Definition: ViewProperties.h:44
Konsole::TerminalDisplay::setOpacity
void setOpacity(qreal opacity)
Sets the opacity of the terminal display.
Definition: TerminalDisplay.cpp:575
Konsole::TerminalDisplay::setOpenLinksByDirectClick
void setOpenLinksByDirectClick(bool value)
Specifies whether links and email addresses should be opened when clicked with the mouse...
Definition: TerminalDisplay.h:193
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::ViewProperties::propertiesById
static ViewProperties * propertiesById(int id)
Finds a ViewProperties instance given its numeric identifier.
Definition: ViewProperties.cpp:38
Konsole::TerminalDisplay::setLineSpacing
void setLineSpacing(uint)
Definition: TerminalDisplay.cpp:260
Konsole::Session::close
void close()
Closes the terminal session.
Definition: Session.cpp:764
Konsole::ViewManager::setNavigationBehavior
void setNavigationBehavior(int behavior)
Definition: ViewManager.cpp:1133
Konsole::TerminalDisplay::setSize
void setSize(int columns, int lines)
Definition: TerminalDisplay.cpp:1716
ColorScheme.h
Konsole::ViewManager::activeViewChanged
void activeViewChanged(SessionController *controller)
Emitted when the active view changes.
Konsole::ViewManager::viewPropertiesChanged
void viewPropertiesChanged(const QList< ViewProperties * > &propertiesList)
Emitted when the list of view properties ( as returned by viewProperties() ) changes.
Konsole::ViewManager::splitViewToggle
void splitViewToggle(bool multipleViews)
Emitted when the number of views containers changes.
Konsole::Profile::Ptr
KSharedPtr< Profile > Ptr
Definition: Profile.h:67
Konsole::TerminalDisplay::setTrimTrailingSpaces
void setTrimTrailingSpaces(bool enabled)
Sets whether trailing spaces should be trimmed in selected text.
Definition: TerminalDisplay.h:207
Konsole::TerminalDisplay::setMargin
void setMargin(int margin)
Sets the display's contents margins.
Definition: TerminalDisplay.cpp:1768
Konsole::TerminalDisplay::setRandomSeed
void setRandomSeed(uint seed)
Sets the seed used to generate random colors for the display (in color schemes that support them)...
Definition: TerminalDisplay.cpp:800
Konsole::TerminalDisplay::setKeyboardCursorShape
void setKeyboardCursorShape(Enum::CursorShapeEnum shape)
Sets the shape of the keyboard cursor.
Definition: TerminalDisplay.cpp:558
Konsole::TerminalDisplay::setShowTerminalSizeHint
void setShowTerminalSizeHint(bool on)
Sets whether or not the current height and width of the terminal in lines and columns is displayed wh...
Definition: TerminalDisplay.h:415
Konsole::ViewContainer::supportedNavigationPositions
virtual QList< NavigationPosition > supportedNavigationPositions() const
Returns the list of supported navigation positions.
Definition: ViewContainer.cpp:124
Konsole::ViewContainer::setNavigationVisibility
void setNavigationVisibility(NavigationVisibility mode)
Definition: ViewContainer.cpp:106
Konsole::ViewManager::createView
void createView(Session *session)
Creates a new view to display the output from and deliver input to session.
Definition: ViewManager.cpp:577
Konsole::Enum::TripleClickModeEnum
TripleClickModeEnum
This enum describes the behavior of triple click action .
Definition: Enumeration.h:92
Konsole::Profile::CursorShape
(CursorShapeEnum) The shape used by terminal displays to represent the cursor.
Definition: Profile.h:187
Konsole::SessionController::closeSession
void closeSession()
close the associated session.
Definition: SessionController.cpp:900
ProfileManager.h
ViewManager.h
Konsole::TerminalDisplay::setBoldIntense
void setBoldIntense(bool value)
Specifies whether characters with intense colors should be rendered as bold.
Definition: TerminalDisplay.h:400
Konsole::ViewContainer::activateLastView
void activateLastView()
Changes the active view to the last view.
Definition: ViewContainer.cpp:226
Konsole::Profile::ScrollBarPosition
(ScrollBarPositionEnum) Specifies the position of the scroll bar in terminal displays using this prof...
Definition: Profile.h:153
Konsole::StackedViewContainer
A plain view container with no navigation display.
Definition: ViewContainer.h:434
Konsole::ViewManager::~ViewManager
~ViewManager()
Definition: ViewManager.cpp:109
Konsole::Enum::IBeamCursor
Use an 'I' shape, similar to that used in text editing applications, to draw the cursor.
Definition: Enumeration.h:86
Konsole::ViewContainer::MoveViewLeft
Moves the view to the left.
Definition: ViewContainer.h:221
Konsole::ViewManager::setTabWidthToText
Q_SCRIPTABLE void setTabWidthToText(bool)
DBus slot that sets ALL tabs' width to match their text.
Definition: ViewManager.cpp:1070
Konsole::ViewManager::activeViewController
SessionController * activeViewController() const
Returns the controller for the active view.
Definition: ViewManager.cpp:533
Konsole::ViewContainer::setActiveView
virtual void setActiveView(QWidget *widget)=0
Changes the focus to the specified view and updates navigation aids to reflect the change...
Konsole::ViewManager::newSession
Q_SCRIPTABLE int newSession()
DBus slot that creates a new session in the current view with the associated default profile and the ...
Definition: ViewManager.cpp:1008
Konsole::ViewManager::NoNavigation
The container has no navigation widget.
Definition: ViewManager.h:124
Konsole::ViewContainer::views
const QList< QWidget * > views() const
Returns a list of the contained views.
Definition: ViewContainer.cpp:189
Konsole::Session::preferredSize
QSize preferredSize() const
Definition: Session.cpp:1291
Konsole::ViewContainer::setNavigationTextMode
void setNavigationTextMode(bool mode)
Sets the navigation text mode If mode is true, use the width of the title; otherwise use the default ...
Definition: ViewContainer.cpp:133
Konsole::ViewContainer::viewProperties
ViewProperties * viewProperties(QWidget *view) const
Returns the ViewProperties instance associated with a particular view in the container.
Definition: ViewContainer.cpp:248
ViewContainer.h
SessionManager.h
Konsole::Enum::ScrollBarRight
Show the scroll-bar on the right of the terminal display.
Definition: Enumeration.h:62
Konsole::ViewManager::searchBar
IncrementalSearchBar * searchBar() const
Returns the search bar.
Definition: ViewManager.cpp:538
Konsole::ProfileManager::availableProfileNames
QStringList availableProfileNames() const
Returns a list of names of all available profiles.
Definition: ProfileManager.cpp:202
Konsole::SessionManager::createSession
Session * createSession(Profile::Ptr profile=Profile::Ptr())
Creates a new session using the settings specified by the specified profile.
Definition: SessionManager.cpp:88
Konsole::TerminalDisplay::randomSeed
uint randomSeed() const
Returns the seed used to generate random colors for the display (in color schemes that support them)...
Definition: TerminalDisplay.cpp:804
Konsole::ViewContainer::NavigationVisibility
NavigationVisibility
This enum describes the options for showing or hiding the container's navigation widget.
Definition: ViewContainer.h:106
Konsole::ViewContainer::features
Features features() const
Returns a bitwise-OR of enabled extra UI features.
Definition: ViewContainer.cpp:79
Konsole::TerminalDisplay::setControlDrag
void setControlDrag(bool enable)
Definition: TerminalDisplay.h:158
Konsole::ViewManager::widget
QWidget * widget() const
Return the main widget for the view manager which holds all of the views managed by this ViewManager ...
Definition: ViewManager.cpp:128
Konsole::TerminalDisplay::setBlinkingTextEnabled
void setBlinkingTextEnabled(bool blink)
Specifies whether or not text can blink.
Definition: TerminalDisplay.cpp:1527
Konsole::TerminalDisplay
A widget which displays output from a terminal emulation and sends input keypresses and mouse activit...
Definition: TerminalDisplay.h:63
ViewSplitter.h
Konsole::ViewManager::viewProperties
QList< ViewProperties * > viewProperties() const
Returns the list of view properties for views in the active container.
Definition: ViewManager.cpp:907
Konsole::Enum::ScrollBarLeft
Show the scroll-bar on the left of the terminal display.
Definition: Enumeration.h:60
SessionController.h
Konsole::Profile::OpenLinksByDirectClickEnabled
(bool) If true, links can be opened by direct mouse click.
Definition: Profile.h:207
Konsole::ViewContainer::NavigationPosition
NavigationPosition
This enum describes the options for positioning the container's navigation widget.
Definition: ViewContainer.h:73
Konsole::ViewManager::newViewRequest
void newViewRequest()
Requests creation of a new view with the default profile.
Konsole::ViewManager::ViewManager
ViewManager(QObject *parent, KActionCollection *collection)
Constructs a new view manager with the specified parent.
Definition: ViewManager.cpp:57
Konsole::ViewContainer::MoveViewRight
Moves the view to the right.
Definition: ViewContainer.h:223
Konsole::ColorSchemeManager::defaultColorScheme
const ColorScheme * defaultColorScheme() const
Returns the default color scheme for Konsole.
Definition: ColorSchemeManager.cpp:288
Konsole::ViewManager::NavigationMethod
NavigationMethod
This enum describes the available types of navigation widget which newly created containers can provi...
Definition: ViewManager.h:117
Konsole::ColorSchemeManager::instance
static ColorSchemeManager * instance()
Returns the global color scheme manager instance.
Definition: ColorSchemeManager.cpp:172
Profile.h
QList
Konsole::ViewContainer::removeView
void removeView(QWidget *view)
Removes a view from the container.
Definition: ViewContainer.cpp:174
Konsole::ColorScheme
Represents a color scheme for a terminal display.
Definition: ColorScheme.h:72
Konsole::Profile::CtrlRequiredForDrag
(bool) If true, control key must be pressed to click and drag selected text.
Definition: Profile.h:209
Konsole::ColorScheme::wallpaper
ColorSchemeWallpaper::Ptr wallpaper() const
Definition: ColorScheme.cpp:370
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:31:24 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
  • Applications
  •   Libraries
  •     libkonq
  • 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