• 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.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  // Note that the display shouldn't need to take into account the tabbar.
559  // However, it appears that taking into account the tabbar is needed.
560  // If tabbar is not visible, no +1 is needed here; however, depending on
561  // settings/tabbar style, +2 might be needed.
562  // 1st attempt at fixing the above:
563  // Guess if tabbar will NOT be visible; ignore ShowNavigationAsNeeded
564  int heightAdjustment = 0;
565  if (_navigationVisibility != ViewContainer::AlwaysHideNavigation) {
566  heightAdjustment = 2;
567  }
568 
569  display->setSize(preferredSize.width(), preferredSize.height() + heightAdjustment);
570  ViewProperties* properties = createController(session, display);
571 
572  _sessionMap[display] = session;
573  container->addView(display, properties, index);
574  session->addView(display);
575 
576  // tell the session whether it has a light or dark background
577  session->setDarkBackground(colorSchemeForProfile(profile)->hasDarkBackground());
578 
579  if (container == _viewSplitter->activeContainer()) {
580  container->setActiveView(display);
581  display->setFocus(Qt::OtherFocusReason);
582  }
583 
584  updateDetachViewState();
585 }
586 
587 void ViewManager::createView(Session* session)
588 {
589  // create the default container
590  if (_viewSplitter->containers().count() == 0) {
591  ViewContainer* container = createContainer();
592  _viewSplitter->addContainer(container, Qt::Vertical);
593  emit splitViewToggle(false);
594  }
595 
596  // new tab will be put at the end by default.
597  int index = -1;
598 
599  if (_newTabBehavior == PutNewTabAfterCurrentTab) {
600  QWidget* view = activeView();
601  if (view) {
602  QList<QWidget*> views = _viewSplitter->activeContainer()->views();
603  index = views.indexOf(view) + 1;
604  }
605  }
606 
607  // iterate over the view containers owned by this view manager
608  // and create a new terminal display for the session in each of them, along with
609  // a controller for the session/display pair
610  foreach(ViewContainer* container, _viewSplitter->containers()) {
611  createView(session, container, index);
612  }
613 }
614 
615 ViewContainer* ViewManager::createContainer()
616 {
617  ViewContainer* container = 0;
618 
619  switch (_navigationMethod) {
620  case TabbedNavigation: {
621  container = new TabbedViewContainer(_navigationPosition, this, _viewSplitter);
622 
623  connect(container, SIGNAL(detachTab(ViewContainer*,QWidget*)),
624  this, SLOT(detachView(ViewContainer*,QWidget*))
625  );
626  connect(container, SIGNAL(closeTab(ViewContainer*,QWidget*)),
627  this, SLOT(closeTabFromContainer(ViewContainer*,QWidget*)));
628  }
629  break;
630  case NoNavigation:
631  default:
632  container = new StackedViewContainer(_viewSplitter);
633  }
634 
635  // FIXME: these code feels duplicated
636  container->setNavigationVisibility(_navigationVisibility);
637  container->setNavigationPosition(_navigationPosition);
638  container->setStyleSheet(_navigationStyleSheet);
639  if (_showQuickButtons) {
640  container->setFeatures(container->features()
641  | ViewContainer::QuickNewView
642  | ViewContainer::QuickCloseView);
643  } else {
644  container->setFeatures(container->features()
645  & ~ViewContainer::QuickNewView
646  & ~ViewContainer::QuickCloseView);
647  }
648 
649  // connect signals and slots
650  connect(container , SIGNAL(viewAdded(QWidget*,ViewProperties*)) , _containerSignalMapper ,
651  SLOT(map()));
652  connect(container , SIGNAL(viewRemoved(QWidget*)) , _containerSignalMapper ,
653  SLOT(map()));
654  _containerSignalMapper->setMapping(container, container);
655 
656  connect(container, SIGNAL(newViewRequest()), this, SIGNAL(newViewRequest()));
657  connect(container, SIGNAL(newViewRequest(Profile::Ptr)), this, SIGNAL(newViewRequest(Profile::Ptr)));
658  connect(container, SIGNAL(moveViewRequest(int,int,bool&,TabbedViewContainer*)),
659  this , SLOT(containerMoveViewRequest(int,int,bool&,TabbedViewContainer*)));
660  connect(container , SIGNAL(viewRemoved(QWidget*)) , this , SLOT(viewDestroyed(QWidget*)));
661  connect(container , SIGNAL(activeViewChanged(QWidget*)) , this , SLOT(viewActivated(QWidget*)));
662 
663  return container;
664 }
665 
666 void ViewManager::containerMoveViewRequest(int index, int id, bool& moved, TabbedViewContainer* sourceTabbedContainer)
667 {
668  ViewContainer* container = qobject_cast<ViewContainer*>(sender());
669  SessionController* controller = qobject_cast<SessionController*>(ViewProperties::propertiesById(id));
670 
671  if (!controller)
672  return;
673 
674  // do not move the last tab in a split view.
675  if (sourceTabbedContainer) {
676  QPointer<ViewContainer> sourceContainer = qobject_cast<ViewContainer*>(sourceTabbedContainer);
677 
678  if (_viewSplitter->containers().contains(sourceContainer)) {
679  return;
680  } else {
681  ViewManager* sourceViewManager = sourceTabbedContainer->connectedViewManager();
682 
683  // do not remove the last tab on the window
684  if (qobject_cast<ViewSplitter*>(sourceViewManager->widget())->containers().size() > 1) {
685  return;
686  }
687  }
688  }
689 
690  createView(controller->session(), container, index);
691  controller->session()->refresh();
692  moved = true;
693 }
694 
695 void ViewManager::setNavigationMethod(NavigationMethod method)
696 {
697  _navigationMethod = method;
698 
699  KActionCollection* collection = _actionCollection;
700 
701  if (collection) {
702  // FIXME: The following disables certain actions for the KPart that it
703  // doesn't actually have a use for, to avoid polluting the action/shortcut
704  // namespace of an application using the KPart (otherwise, a shortcut may
705  // be in use twice, and the user gets to see an "ambiguous shortcut over-
706  // load" error dialog). However, this approach sucks - it's the inverse of
707  // what it should be. Rather than disabling actions not used by the KPart,
708  // a method should be devised to only enable those that are used, perhaps
709  // by using a separate action collection.
710 
711  const bool enable = (_navigationMethod != NoNavigation);
712  QAction* action;
713 
714  action = collection->action("next-view");
715  if (action) action->setEnabled(enable);
716 
717  action = collection->action("previous-view");
718  if (action) action->setEnabled(enable);
719 
720  action = collection->action("last-tab");
721  if (action) action->setEnabled(enable);
722 
723  action = collection->action("split-view-left-right");
724  if (action) action->setEnabled(enable);
725 
726  action = collection->action("split-view-top-bottom");
727  if (action) action->setEnabled(enable);
728 
729  action = collection->action("rename-session");
730  if (action) action->setEnabled(enable);
731 
732  action = collection->action("move-view-left");
733  if (action) action->setEnabled(enable);
734 
735  action = collection->action("move-view-right");
736  if (action) action->setEnabled(enable);
737  }
738 }
739 
740 ViewManager::NavigationMethod ViewManager::navigationMethod() const
741 {
742  return _navigationMethod;
743 }
744 
745 void ViewManager::containerViewsChanged(QObject* container)
746 {
747  if (_viewSplitter && container == _viewSplitter->activeContainer()) {
748  emit viewPropertiesChanged(viewProperties());
749  }
750 }
751 
752 void ViewManager::viewDestroyed(QWidget* view)
753 {
754  // Note: the received QWidget has already been destroyed, so
755  // using dynamic_cast<> or qobject_cast<> does not work here
756  TerminalDisplay* display = static_cast<TerminalDisplay*>(view);
757  Q_ASSERT(display);
758 
759  // 1. detach view from session
760  // 2. if the session has no views left, close it
761  Session* session = _sessionMap[ display ];
762  _sessionMap.remove(display);
763  if (session) {
764  display->deleteLater();
765 
766  if (session->views().count() == 0)
767  session->close();
768  }
769  //we only update the focus if the splitter is still alive
770  if (_viewSplitter) {
771  focusActiveView();
772  updateDetachViewState();
773  }
774  // The below causes the menus to be messed up
775  // Only happens when using the tab bar close button
776 // if (_pluggedController)
777 // emit unplugController(_pluggedController);
778 }
779 
780 TerminalDisplay* ViewManager::createTerminalDisplay(Session* session)
781 {
782  TerminalDisplay* display = new TerminalDisplay(0);
783  display->setRandomSeed(session->sessionId() * 31);
784 
785  return display;
786 }
787 
788 const ColorScheme* ViewManager::colorSchemeForProfile(const Profile::Ptr profile)
789 {
790  const ColorScheme* colorScheme = ColorSchemeManager::instance()->
791  findColorScheme(profile->colorScheme());
792  if (!colorScheme)
793  colorScheme = ColorSchemeManager::instance()->defaultColorScheme();
794  Q_ASSERT(colorScheme);
795 
796  return colorScheme;
797 }
798 
799 void ViewManager::applyProfileToView(TerminalDisplay* view , const Profile::Ptr profile)
800 {
801  Q_ASSERT(profile);
802 
803  emit updateWindowIcon();
804 
805  // load color scheme
806  ColorEntry table[TABLE_COLORS];
807  const ColorScheme* colorScheme = colorSchemeForProfile(profile);
808  colorScheme->getColorTable(table , view->randomSeed());
809  view->setColorTable(table);
810  view->setOpacity(colorScheme->opacity());
811  view->setWallpaper(colorScheme->wallpaper());
812 
813  // load font
814  view->setAntialias(profile->antiAliasFonts());
815  view->setBoldIntense(profile->boldIntense());
816  view->setVTFont(profile->font());
817 
818  // set scroll-bar position
819  int scrollBarPosition = profile->property<int>(Profile::ScrollBarPosition);
820 
821  if (scrollBarPosition == Enum::ScrollBarLeft)
822  view->setScrollBarPosition(Enum::ScrollBarLeft);
823  else if (scrollBarPosition == Enum::ScrollBarRight)
824  view->setScrollBarPosition(Enum::ScrollBarRight);
825  else if (scrollBarPosition == Enum::ScrollBarHidden)
826  view->setScrollBarPosition(Enum::ScrollBarHidden);
827 
828  bool scrollFullPage = profile->property<bool>(Profile::ScrollFullPage);
829  view->setScrollFullPage(scrollFullPage);
830 
831  // show hint about terminal size after resizing
832  view->setShowTerminalSizeHint(profile->showTerminalSizeHint());
833 
834  // terminal features
835  view->setBlinkingCursorEnabled(profile->blinkingCursorEnabled());
836  view->setBlinkingTextEnabled(profile->blinkingTextEnabled());
837 
838  int tripleClickMode = profile->property<int>(Profile::TripleClickMode);
839  view->setTripleClickMode(Enum::TripleClickModeEnum(tripleClickMode));
840 
841  view->setAutoCopySelectedText(profile->autoCopySelectedText());
842  view->setUnderlineLinks(profile->underlineLinksEnabled());
843  view->setControlDrag(profile->property<bool>(Profile::CtrlRequiredForDrag));
844  view->setBidiEnabled(profile->bidiRenderingEnabled());
845  view->setLineSpacing(profile->lineSpacing());
846  view->setTrimTrailingSpaces(profile->property<bool>(Profile::TrimTrailingSpacesInSelectedText));
847 
848  view->setOpenLinksByDirectClick(profile->property<bool>(Profile::OpenLinksByDirectClickEnabled));
849 
850  int middleClickPasteMode = profile->property<int>(Profile::MiddleClickPasteMode);
851  if (middleClickPasteMode == Enum::PasteFromX11Selection)
852  view->setMiddleClickPasteMode(Enum::PasteFromX11Selection);
853  else if (middleClickPasteMode == Enum::PasteFromClipboard)
854  view->setMiddleClickPasteMode(Enum::PasteFromClipboard);
855 
856  // margin/center - these are hard-fixed ATM
857  view->setMargin(1);
858  view->setCenterContents(false);
859 
860  // cursor shape
861  int cursorShape = profile->property<int>(Profile::CursorShape);
862 
863  if (cursorShape == Enum::BlockCursor)
864  view->setKeyboardCursorShape(Enum::BlockCursor);
865  else if (cursorShape == Enum::IBeamCursor)
866  view->setKeyboardCursorShape(Enum::IBeamCursor);
867  else if (cursorShape == Enum::UnderlineCursor)
868  view->setKeyboardCursorShape(Enum::UnderlineCursor);
869 
870  // cursor color
871  if (profile->useCustomCursorColor()) {
872  const QColor& cursorColor = profile->customCursorColor();
873  view->setKeyboardCursorColor(cursorColor);
874  } else {
875  // an invalid QColor is used to inform the view widget to
876  // draw the cursor using the default color( matching the text)
877  view->setKeyboardCursorColor(QColor());
878  }
879 
880  // word characters
881  view->setWordCharacters(profile->wordCharacters());
882 
883  // bell mode
884  view->setBellMode(profile->property<int>(Profile::BellMode));
885 
886  // mouse wheel zoom
887  view->setMouseWheelZoom(profile->mouseWheelZoomEnabled());
888 }
889 
890 void ViewManager::updateViewsForSession(Session* session)
891 {
892  const Profile::Ptr profile = SessionManager::instance()->sessionProfile(session);
893 
894  foreach(TerminalDisplay* view, _sessionMap.keys(session)) {
895  applyProfileToView(view, profile);
896  }
897 }
898 
899 void ViewManager::profileChanged(Profile::Ptr profile)
900 {
901  // update all views associated with this profile
902  QHashIterator<TerminalDisplay*, Session*> iter(_sessionMap);
903  while (iter.hasNext()) {
904  iter.next();
905 
906  // if session uses this profile, update the display
907  if (iter.key() != 0 &&
908  iter.value() != 0 &&
909  SessionManager::instance()->sessionProfile(iter.value()) == profile) {
910  applyProfileToView(iter.key(), profile);
911  }
912  }
913 }
914 
915 QList<ViewProperties*> ViewManager::viewProperties() const
916 {
917  QList<ViewProperties*> list;
918 
919  ViewContainer* container = _viewSplitter->activeContainer();
920 
921  Q_ASSERT(container);
922 
923  foreach(QWidget* view, container->views()) {
924  ViewProperties* properties = container->viewProperties(view);
925  Q_ASSERT(properties);
926  list << properties;
927  }
928 
929  return list;
930 }
931 
932 void ViewManager::saveSessions(KConfigGroup& group)
933 {
934  // find all unique session restore IDs
935  QList<int> ids;
936  QHash<Session*, int> unique;
937 
938  // first: sessions in the active container, preserving the order
939  ViewContainer* container = _viewSplitter->activeContainer();
940  Q_ASSERT(container);
941  TerminalDisplay* activeview = qobject_cast<TerminalDisplay*>(container->activeView());
942 
943  QListIterator<QWidget*> viewIter(container->views());
944  int tab = 1;
945  while (viewIter.hasNext()) {
946  TerminalDisplay* view = qobject_cast<TerminalDisplay*>(viewIter.next());
947  Q_ASSERT(view);
948  Session* session = _sessionMap[view];
949  ids << SessionManager::instance()->getRestoreId(session);
950  if (view == activeview) group.writeEntry("Active", tab);
951  unique.insert(session, 1);
952  tab++;
953  }
954 
955  // second: all other sessions, in random order
956  // we don't want to have sessions restored that are not connected
957  foreach(Session * session, _sessionMap) {
958  if (!unique.contains(session)) {
959  ids << SessionManager::instance()->getRestoreId(session);
960  unique.insert(session, 1);
961  }
962  }
963 
964  group.writeEntry("Sessions", ids);
965 }
966 
967 void ViewManager::restoreSessions(const KConfigGroup& group)
968 {
969  QList<int> ids = group.readEntry("Sessions", QList<int>());
970  int activeTab = group.readEntry("Active", 0);
971  TerminalDisplay* display = 0;
972 
973  int tab = 1;
974  foreach(int id, ids) {
975  Session* session = SessionManager::instance()->idToSession(id);
976  createView(session);
977  if (!session->isRunning())
978  session->run();
979  if (tab++ == activeTab)
980  display = qobject_cast<TerminalDisplay*>(activeView());
981  }
982 
983  if (display) {
984  _viewSplitter->activeContainer()->setActiveView(display);
985  display->setFocus(Qt::OtherFocusReason);
986  }
987 
988  if (ids.isEmpty()) { // Session file is unusable, start default Profile
989  Profile::Ptr profile = ProfileManager::instance()->defaultProfile();
990  Session* session = SessionManager::instance()->createSession(profile);
991  createView(session);
992  if (!session->isRunning())
993  session->run();
994  }
995 }
996 
997 uint qHash(QPointer<TerminalDisplay> display)
998 {
999  return qHash((TerminalDisplay*)display);
1000 }
1001 
1002 int ViewManager::sessionCount()
1003 {
1004  return this->_sessionMap.size();
1005 }
1006 
1007 int ViewManager::currentSession()
1008 {
1009  QHash<TerminalDisplay*, Session*>::iterator i;
1010  for (i = this->_sessionMap.begin(); i != this->_sessionMap.end(); ++i)
1011  if (i.key()->isVisible())
1012  return i.value()->sessionId();
1013  return -1;
1014 }
1015 
1016 int ViewManager::newSession()
1017 {
1018  Profile::Ptr profile = ProfileManager::instance()->defaultProfile();
1019  Session* session = SessionManager::instance()->createSession(profile);
1020 
1021  this->createView(session);
1022  session->run();
1023 
1024  return session->sessionId();
1025 }
1026 
1027 int ViewManager::newSession(QString profile, QString directory)
1028 {
1029  const QList<Profile::Ptr> profilelist = ProfileManager::instance()->allProfiles();
1030  Profile::Ptr profileptr = ProfileManager::instance()->defaultProfile();
1031 
1032  for (int i = 0; i < profilelist.size(); ++i) {
1033  if (profilelist.at(i)->name() == profile) {
1034  profileptr = profilelist.at(i);
1035  break;
1036  }
1037  }
1038 
1039  Session* session = SessionManager::instance()->createSession(profileptr);
1040  session->setInitialWorkingDirectory(directory);
1041 
1042  this->createView(session);
1043  session->run();
1044 
1045  return session->sessionId();
1046 }
1047 
1048 QString ViewManager::defaultProfile()
1049 {
1050  return ProfileManager::instance()->defaultProfile()->name();
1051 }
1052 
1053 QStringList ViewManager::profileList()
1054 {
1055  return ProfileManager::instance()->availableProfileNames();
1056 }
1057 
1058 void ViewManager::nextSession()
1059 {
1060  this->nextView();
1061 }
1062 
1063 void ViewManager::prevSession()
1064 {
1065  this->previousView();
1066 }
1067 
1068 void ViewManager::moveSessionLeft()
1069 {
1070  this->moveActiveViewLeft();
1071 }
1072 
1073 void ViewManager::moveSessionRight()
1074 {
1075  this->moveActiveViewRight();
1076 }
1077 
1078 void ViewManager::setTabWidthToText(bool useTextWidth)
1079 {
1080  ViewContainer* container = _viewSplitter->activeContainer();
1081  Q_ASSERT(container);
1082  container->setNavigationTextMode(useTextWidth);
1083 }
1084 
1085 void ViewManager::closeTabFromContainer(ViewContainer* container, QWidget* tab)
1086 {
1087  SessionController* controller = qobject_cast<SessionController*>(container->viewProperties(tab));
1088  Q_ASSERT(controller);
1089  if (controller)
1090  controller->closeSession();
1091 }
1092 
1093 void ViewManager::setNavigationVisibility(int visibility)
1094 {
1095  _navigationVisibility =
1096  static_cast<ViewContainer::NavigationVisibility>(visibility);
1097 
1098  foreach(ViewContainer* container, _viewSplitter->containers()) {
1099  container->setNavigationVisibility(_navigationVisibility);
1100  }
1101 }
1102 
1103 void ViewManager::setNavigationPosition(int position)
1104 {
1105  _navigationPosition =
1106  static_cast<ViewContainer::NavigationPosition>(position);
1107 
1108  foreach(ViewContainer* container, _viewSplitter->containers()) {
1109  Q_ASSERT(container->supportedNavigationPositions().contains(_navigationPosition));
1110  container->setNavigationPosition(_navigationPosition);
1111  }
1112 }
1113 
1114 void ViewManager::setNavigationStyleSheet(const QString& styleSheet)
1115 {
1116  _navigationStyleSheet = styleSheet;
1117 
1118  foreach(ViewContainer* container, _viewSplitter->containers()) {
1119  container->setStyleSheet(_navigationStyleSheet);
1120  }
1121 }
1122 
1123 void ViewManager::setShowQuickButtons(bool show)
1124 {
1125  _showQuickButtons = show;
1126 
1127  foreach(ViewContainer* container, _viewSplitter->containers()) {
1128  if (_showQuickButtons) {
1129  container->setFeatures(container->features()
1130  | ViewContainer::QuickNewView
1131  | ViewContainer::QuickCloseView);
1132  } else {
1133  container->setFeatures(container->features()
1134  & ~ViewContainer::QuickNewView
1135  & ~ViewContainer::QuickCloseView);
1136  }
1137  }
1138 }
1139 
1140 
1141 void ViewManager::setNavigationBehavior(int behavior)
1142 {
1143  _newTabBehavior = static_cast<NewTabBehavior>(behavior);
1144 }
1145 
1146 #include "ViewManager.moc"
1147 
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:2668
Session.h
Konsole::Session::run
void run()
Starts the terminal session.
Definition: Session.cpp:427
TABLE_COLORS
#define TABLE_COLORS
Definition: CharacterColor.h:117
Konsole::SessionManager::instance
static SessionManager * instance()
Returns the session manager instance.
Definition: SessionManager.cpp:69
QWidget
Konsole::TerminalDisplay::setMouseWheelZoom
void setMouseWheelZoom(bool value)
Specified whether zoom terminal on Ctrl+mousewheel is enabled or not.
Definition: TerminalDisplay.h:346
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::PutNewTabAfterCurrentTab
Put newly created tab right after current tab.
Definition: ViewManager.h:134
QHash::insert
iterator insert(const Key &key, const T &value)
Konsole::ViewManager::activeView
QWidget * activeView() const
Returns the view manager's active view.
Definition: ViewManager.cpp:118
QSize::width
int width() const
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:1515
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:596
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:932
Konsole::ViewManager::sessionCount
Q_SCRIPTABLE int sessionCount()
DBus slot that returns the number of sessions in the current view.
Definition: ViewManager.cpp:1002
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:899
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:3047
QObject::sender
QObject * sender() const
QList::at
const T & at(int i) const
Konsole::ViewContainer::addView
void addView(QWidget *view, ViewProperties *navigationItem, int index=-1)
Adds a new view to the container widget.
Definition: ViewContainer.cpp:138
QObject::children
const QObjectList & children() const
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:1073
Konsole::ViewManager::updateWindowIcon
void updateWindowIcon()
QPointer
QDBusConnection::registerObject
bool registerObject(const QString &path, QObject *object, QFlags< QDBusConnection::RegisterOption > options)
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:209
Konsole::ViewManager::setShowQuickButtons
void setShowQuickButtons(bool show)
Definition: ViewManager.cpp:1123
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:1048
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:1058
QDBusConnection::sessionBus
QDBusConnection sessionBus()
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:219
Konsole::ViewManager::currentSession
Q_SCRIPTABLE int currentSession()
DBus slot that returns the current (active) session window.
Definition: ViewManager.cpp:1007
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:567
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:1822
ColorSchemeManager.h
Konsole::ViewManager::profileList
Q_SCRIPTABLE QStringList profileList()
Definition: ViewManager.cpp:1053
QList::size
int size() const
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:2733
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
QList::indexOf
int indexOf(const T &value, int from) const
Konsole::ViewManager::setNavigationPosition
void setNavigationPosition(int position)
Definition: ViewManager.cpp:1103
Konsole::ProfileManager::defaultProfile
Profile::Ptr defaultProfile() const
Returns a Profile object describing the default profile.
Definition: ProfileManager.cpp:308
QHash::iterator
Konsole::TabbedViewContainer::connectedViewManager
ViewManager * connectedViewManager()
Definition: ViewContainer.cpp:714
Konsole::SessionManager::getRestoreId
int getRestoreId(Session *session)
Definition: SessionManager.cpp:295
QSignalMapper::setMapping
void setMapping(QObject *sender, int id)
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:695
QString::number
QString number(int n, int base)
QList::count
int count(const T &value) const
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:430
Konsole::TerminalDisplay::setAntialias
void setAntialias(bool value)
Specified whether anti-aliasing of text in the terminal display is enabled or not.
Definition: TerminalDisplay.h:385
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:997
Konsole::ViewManager::restoreSessions
void restoreSessions(const KConfigGroup &group)
Definition: ViewManager.cpp:967
QHash
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.
QObject
Konsole::Profile::ScrollFullPage
(bool) Specifies whether the PageUp/Down will scroll the full height or half height.
Definition: Profile.h:153
QWidget::setFocus
void setFocus()
Konsole::ViewContainer::setStyleSheet
virtual void setStyleSheet(const QString &styleSheet)
Sets the stylesheet for visual appearance.
Definition: ViewContainer.h:172
QList::isEmpty
bool isEmpty() const
Konsole::ViewManager::setNavigationVisibility
void setNavigationVisibility(int visibility)
Definition: ViewManager.cpp:1093
Konsole::ViewManager::prevSession
Q_SCRIPTABLE void prevSession()
DBus slot that changes the view port to the previous session.
Definition: ViewManager.cpp:1063
QHashIterator
Konsole::ViewManager::setNavigationStyleSheet
void setNavigationStyleSheet(const QString &styleSheet)
Definition: ViewManager.cpp:1114
Konsole::ViewManager::navigationMethod
NavigationMethod navigationMethod() const
Returns the type of navigation widget created in new containers.
Definition: ViewManager.cpp:740
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:1068
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:799
QObject::deleteLater
void deleteLater()
Konsole::Profile::BellMode
(BellModeEnum) Specifies the behavior of bell.
Definition: Profile.h:237
Konsole::Profile::TripleClickMode
(TripleClickModeEnum) Specifies which part of current line should be selected with triple click actio...
Definition: Profile.h:197
QString
QList
QtConcurrent::map
QFuture< void > map(Sequence &sequence, MapFunction function)
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:1768
Enumeration.h
QColor
Konsole::TerminalDisplay::setCenterContents
void setCenterContents(bool enable)
Sets whether the contents are centered between the margins.
Definition: TerminalDisplay.cpp:1755
Konsole::TerminalDisplay::setMiddleClickPasteMode
void setMiddleClickPasteMode(Enum::MiddleClickPasteModeEnum mode)
Definition: TerminalDisplay.cpp:2738
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
QStringList
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:576
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
QSize
Konsole::TerminalDisplay::setLineSpacing
void setLineSpacing(uint)
Definition: TerminalDisplay.cpp:260
Konsole::Session::close
void close()
Closes the terminal session.
Definition: Session.cpp:770
Konsole::ViewManager::setNavigationBehavior
void setNavigationBehavior(int behavior)
Definition: ViewManager.cpp:1141
Konsole::TerminalDisplay::setSize
void setSize(int columns, int lines)
Definition: TerminalDisplay.cpp:1715
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:1749
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:805
Konsole::TerminalDisplay::setKeyboardCursorShape
void setKeyboardCursorShape(Enum::CursorShapeEnum shape)
Sets the shape of the keyboard cursor.
Definition: TerminalDisplay.cpp:559
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:414
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:587
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:183
QLatin1String
Konsole::SessionController::closeSession
void closeSession()
close the associated session.
Definition: SessionController.cpp:905
QKeySequence
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:399
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:149
Konsole::StackedViewContainer
A plain view container with no navigation display.
Definition: ViewContainer.h:434
QAction
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
QSize::height
int height() const
Konsole::ViewManager::setTabWidthToText
Q_SCRIPTABLE void setTabWidthToText(bool)
DBus slot that sets ALL tabs' width to match their text.
Definition: ViewManager.cpp:1078
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:1016
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:1298
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
QHash::contains
bool contains(const Key &key) const
Konsole::ViewManager::searchBar
IncrementalSearchBar * searchBar() const
Returns the search bar.
Definition: ViewManager.cpp:538
QListIterator
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::ViewContainer::AlwaysHideNavigation
Always hide the navigation widget.
Definition: ViewContainer.h:112
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:809
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:1535
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
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:915
QSignalMapper
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:203
Konsole::ViewContainer::NavigationPosition
NavigationPosition
This enum describes the options for positioning the container's navigation widget.
Definition: ViewContainer.h:73
QObject::destroyed
void destroyed(QObject *obj)
Konsole::ViewManager::newViewRequest
void newViewRequest()
Requests creation of a new view with the default profile.
QAction::isEnabled
bool isEnabled() const
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
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:205
Konsole::ColorScheme::wallpaper
ColorSchemeWallpaper::Ptr wallpaper() const
Definition: ColorScheme.cpp:370
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