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

krdc

  • sources
  • kde-4.12
  • kdenetwork
  • krdc
  • konsole
konsoleview.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2009 Urs Wolfer <uwolfer @ kde.org>
4 **
5 ** This file is part of KDE.
6 **
7 ** This program is free software; you can redistribute it and/or modify
8 ** it under the terms of the GNU General Public License as published by
9 ** the Free Software Foundation; either version 2 of the License, or
10 ** (at your option) any later version.
11 **
12 ** This program is distributed in the hope that it will be useful,
13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ** GNU General Public License for more details.
16 **
17 ** You should have received a copy of the GNU General Public License
18 ** along with this program; see the file COPYING. If not, write to
19 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 ** Boston, MA 02110-1301, USA.
21 **
22 ****************************************************************************/
23 
24 #include "konsoleview.h"
25 
26 #include <KParts/Part>
27 #include <KPluginFactory>
28 #include <KPluginLoader>
29 #include <KService>
30 #include <kde_terminal_interface.h>
31 
32 #include <QDir>
33 #include <QEvent>
34 #include <QScrollArea>
35 #include <QVBoxLayout>
36 
37 KonsoleView::KonsoleView(QWidget *parent, const KUrl &url, KConfigGroup configGroup)
38  : RemoteView(parent)
39 {
40  m_url = url;
41  m_host = url.host();
42  m_port = url.port();
43 
44  m_hostPreferences = new KonsoleHostPreferences(configGroup, this);
45 
46 // QSize size = QSize(640, 480);
47  const QSize size = (qobject_cast<QWidget *>(parent))->size();
48  setStatus(Connected);
49  setFixedSize(size);
50  setFixedSize(size);
51  emit framebufferSizeChanged(size.width(), size.height());
52 
53  KPluginFactory* factory = 0;
54  KService::Ptr service = KService::serviceByDesktopName("konsolepart");
55  if (service) {
56  factory = KPluginLoader(service->library()).factory();
57  }
58  KParts::ReadOnlyPart* part = factory ? (factory->create<KParts::ReadOnlyPart>(this)) : 0;
59  if (part != 0) {
60 // connect(part, SIGNAL(destroyed(QObject*)), this, SLOT(terminalExited()));
61  QVBoxLayout *mainLayout = new QVBoxLayout(this);
62  mainLayout->setMargin(0);
63  mainLayout->setSpacing(0);
64  m_terminalWidget = part->widget();
65  mainLayout->addWidget(m_terminalWidget);
66  m_terminal = qobject_cast<TerminalInterface *>(part);
67  m_terminal->showShellInDir(QDir::homePath());
68  m_terminal->sendInput("echo " + url.user() + '@' + url.host()/* + ':' + url.port()*/ + '\n');
69 // m_terminal->sendInput("clear\n");
70  m_terminalWidget->resize(size);
71  }
72 }
73 
74 KonsoleView::~KonsoleView()
75 {
76  emit disconnected();
77  setStatus(Disconnected);
78 }
79 
80 bool KonsoleView::eventFilter(QObject *obj, QEvent *event)
81 {
82  if (m_viewOnly) {
83  if (event->type() == QEvent::KeyPress ||
84  event->type() == QEvent::KeyRelease ||
85  event->type() == QEvent::MouseButtonDblClick ||
86  event->type() == QEvent::MouseButtonPress ||
87  event->type() == QEvent::MouseButtonRelease ||
88  event->type() == QEvent::MouseMove)
89  return true;
90  }
91  return RemoteView::eventFilter(obj, event);
92 }
93 
94 QSize KonsoleView::framebufferSize()
95 {
96  return minimumSizeHint();
97 }
98 
99 QSize KonsoleView::sizeHint() const
100 {
101  return RemoteView::sizeHint();
102  return maximumSize();
103 }
104 
105 bool KonsoleView::isQuitting()
106 {
107  return false;
108 }
109 
110 bool KonsoleView::start()
111 {
112  setStatus(Connected);
113  emit connected();
114  m_terminalWidget->setFocus();
115  return true;
116 }
117 
118 HostPreferences* KonsoleView::hostPreferences()
119 {
120  return m_hostPreferences;
121 }
122 
123 void KonsoleView::switchFullscreen(bool on)
124 {
125  Q_UNUSED(on);
126 }
127 
128 #include "konsoleview.moc"
KonsoleView::sizeHint
QSize sizeHint() const
Definition: konsoleview.cpp:99
KonsoleView::hostPreferences
HostPreferences * hostPreferences()
Returns the current host preferences of this view.
Definition: konsoleview.cpp:118
QWidget
KonsoleHostPreferences
Definition: konsoleview.h:66
konsoleview.h
QObject
RemoteView::connected
void connected()
Emitted when the view connected successfully.
RemoteView::m_port
int m_port
Definition: remoteview.h:399
RemoteView::m_host
QString m_host
Definition: remoteview.h:398
RemoteView
Generic widget that displays a remote framebuffer.
Definition: remoteview.h:59
RemoteView::disconnected
void disconnected()
Emitted when the view disconnected without error.
RemoteView::framebufferSizeChanged
void framebufferSizeChanged(int w, int h)
Emitted when the size of the remote screen changes.
RemoteView::url
KUrl url()
Definition: remoteview.cpp:193
KonsoleView::~KonsoleView
virtual ~KonsoleView()
Definition: konsoleview.cpp:74
HostPreferences
Definition: hostpreferences.h:42
KonsoleView::switchFullscreen
virtual void switchFullscreen(bool on)
Definition: konsoleview.cpp:123
RemoteView::m_viewOnly
bool m_viewOnly
Definition: remoteview.h:400
KonsoleView::start
virtual bool start()
Initialize the view (for example by showing configuration dialogs to the user) and start connecting...
Definition: konsoleview.cpp:110
RemoteView::setStatus
virtual void setStatus(RemoteStatus s)
Set the status of the connection.
Definition: remoteview.cpp:62
RemoteView::m_url
KUrl m_url
Definition: remoteview.h:404
KonsoleView::framebufferSize
virtual QSize framebufferSize()
Returns the resolution of the remote framebuffer.
Definition: konsoleview.cpp:94
RemoteView::Disconnected
Definition: remoteview.h:114
KonsoleView::isQuitting
virtual bool isQuitting()
Checks whether the view is currently quitting.
Definition: konsoleview.cpp:105
KonsoleView::eventFilter
bool eventFilter(QObject *obj, QEvent *event)
Definition: konsoleview.cpp:80
RemoteView::Connected
Definition: remoteview.h:112
KonsoleView::KonsoleView
KonsoleView(QWidget *parent=0, const KUrl &url=KUrl(), KConfigGroup configGroup=KConfigGroup())
Definition: konsoleview.cpp:37
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:54:04 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

krdc

Skip menu "krdc"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

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