1 /****************************************************************************
3 ** Copyright (C) 2002-2003 Tim Jansen <tim@tjansen.de>
4 ** Copyright (C) 2007-2008 Urs Wolfer <uwolfer @ kde.org>
6 ** This file is part of KDE.
8 ** This program is free software; you can redistribute it and/or modify
9 ** it under the terms of the GNU General Public License as published by
10 ** the Free Software Foundation; either version 2 of the License, or
11 ** (at your option) any later version.
13 ** This program is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ** GNU General Public License for more details.
18 ** You should have received a copy of the GNU General Public License
19 ** along with this program; see the file COPYING. If not, write to
20 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 ** Boston, MA 02110-1301, USA.
23 ****************************************************************************/
25 #include "remoteview.h"
29 #include <KStandardDirs>
34 RemoteView::RemoteView(QWidget
*parent
)
36 m_status(Disconnected
),
42 m_keyboardIsGrabbed(false),
46 m_dotCursorState(CursorOff
)
50 RemoteView::RemoteStatus
RemoteView::status()
55 void RemoteView::setStatus(RemoteView::RemoteStatus s
)
60 if (((1+ m_status
) != s
) && (s
!= Disconnected
)) {
61 // follow state transition rules
63 if (s
== Disconnecting
) {
64 if (m_status
== Disconnected
)
67 Q_ASSERT(((int) s
) >= 0);
69 m_status
= Disconnected
;
70 emit
statusChanged(Disconnected
);
72 // smooth state transition
73 RemoteStatus origState
= m_status
;
74 for (int i
= origState
; i
< s
; i
++) {
75 m_status
= (RemoteStatus
) i
;
76 emit
statusChanged((RemoteStatus
) i
);
81 emit
statusChanged(m_status
);
84 RemoteView::~RemoteView()
88 bool RemoteView::supportsScaling() const
93 bool RemoteView::supportsLocalCursor() const
98 QString
RemoteView::host()
103 QSize
RemoteView::framebufferSize()
108 void RemoteView::startQuitting()
112 bool RemoteView::isQuitting()
117 int RemoteView::port()
122 void RemoteView::keyEvent(QKeyEvent
*)
126 bool RemoteView::viewOnly()
131 void RemoteView::setViewOnly(bool viewOnly
)
133 m_viewOnly
= viewOnly
;
136 bool RemoteView::grabAllKeys()
138 return m_grabAllKeys
;
141 void RemoteView::setGrabAllKeys(bool grabAllKeys
)
143 m_grabAllKeys
= grabAllKeys
;
146 m_keyboardIsGrabbed
= true;
148 } else if (m_keyboardIsGrabbed
) {
153 void RemoteView::showDotCursor(DotCursorState state
)
155 m_dotCursorState
= state
;
158 RemoteView::DotCursorState
RemoteView::dotCursorState() const
160 return m_dotCursorState
;
163 bool RemoteView::scaling() const
168 void RemoteView::enableScaling(bool scale
)
173 void RemoteView::switchFullscreen(bool)
177 KUrl
RemoteView::url()
183 QString
RemoteView::readWalletPassword()
185 QString krdc_folder
= "KRDC";
187 m_wallet
= KWallet::Wallet::openWallet(KWallet::Wallet::NetworkWallet(), window()->winId());
190 bool walletOK
= m_wallet
->hasFolder(krdc_folder
);
192 walletOK
= m_wallet
->createFolder(krdc_folder
);
193 kDebug(5010) << "Wallet folder created";
196 kDebug(5010) << "Wallet OK";
197 m_wallet
->setFolder(krdc_folder
);
200 if (m_wallet
->hasEntry(m_url
.prettyUrl(KUrl::RemoveTrailingSlash
)) &&
201 !m_wallet
->readPassword(m_url
.prettyUrl(KUrl::RemoveTrailingSlash
), password
)) {
202 kDebug(5010) << "Password read OK";
211 void RemoteView::saveWalletPassword(const QString
&password
)
213 if (m_wallet
&& m_wallet
->isOpen() && !m_wallet
->hasEntry(m_url
.prettyUrl(KUrl::RemoveTrailingSlash
))) {
214 kDebug(5010) << "Write wallet password";
215 m_wallet
->writePassword(m_url
.prettyUrl(KUrl::RemoveTrailingSlash
), password
);
220 QCursor
RemoteView::localDotCursor() const
223 return QCursor(); //TODO
225 QBitmap
cursorBitmap(KGlobal::dirs()->findResource("appdata",
226 "pics/pointcursor.png"));
227 QBitmap
cursorMask(KGlobal::dirs()->findResource("appdata",
228 "pics/pointcursormask.png"));
229 return QCursor(cursorBitmap
, cursorMask
);
233 void RemoteView::focusInEvent(QFocusEvent
*event
)
236 m_keyboardIsGrabbed
= true;
240 QWidget::focusInEvent(event
);
243 void RemoteView::focusOutEvent(QFocusEvent
*event
)
245 if (m_grabAllKeys
|| m_keyboardIsGrabbed
) {
246 m_keyboardIsGrabbed
= false;
250 QWidget::focusOutEvent(event
);
253 #include "moc_remoteview.cpp"