File indexing completed on 2024-04-28 08:51:02
0001 /* 0002 SPDX-FileCopyrightText: 2007-2013 Urs Wolfer <uwolfer@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef VNCVIEW_H 0008 #define VNCVIEW_H 0009 0010 #include "remoteview.h" 0011 #include "vncclientthread.h" 0012 0013 #ifdef QTONLY 0014 class KConfigGroup{}; 0015 #else 0016 #include "vnchostpreferences.h" 0017 #endif 0018 0019 #ifdef LIBSSH_FOUND 0020 #include "vncsshtunnelthread.h" 0021 #endif 0022 0023 0024 #include <QClipboard> 0025 #include <QMap> 0026 0027 extern "C" { 0028 #include <rfb/rfbclient.h> 0029 } 0030 0031 class VncView: public RemoteView 0032 { 0033 Q_OBJECT 0034 0035 public: 0036 explicit VncView(QWidget *parent = nullptr, const QUrl &url = QUrl(), KConfigGroup configGroup = KConfigGroup()); 0037 ~VncView() override; 0038 0039 QSize framebufferSize() override; 0040 QSize sizeHint() const override; 0041 QSize minimumSizeHint() const override; 0042 void startQuitting() override; 0043 bool isQuitting() override; 0044 bool start() override; 0045 bool supportsScaling() const override; 0046 bool supportsLocalCursor() const override; 0047 bool supportsViewOnly() const override; 0048 0049 #ifndef QTONLY 0050 HostPreferences* hostPreferences() override; 0051 #endif 0052 0053 void setViewOnly(bool viewOnly) override; 0054 void showLocalCursor(LocalCursorState state) override; 0055 void enableScaling(bool scale) override; 0056 0057 void updateConfiguration() override; 0058 0059 public Q_SLOTS: 0060 void scaleResize(int w, int h) override; 0061 0062 protected: 0063 void paintEvent(QPaintEvent *event) override; 0064 bool event(QEvent *event) override; 0065 void resizeEvent(QResizeEvent *event) override; 0066 bool eventFilter(QObject *obj, QEvent *event) override; 0067 void focusOutEvent(QFocusEvent *event) override; 0068 0069 private: 0070 VncClientThread vncThread; 0071 QClipboard *m_clipboard; 0072 bool m_initDone; 0073 int m_buttonMask; 0074 QMap<unsigned int, bool> m_mods; 0075 bool m_quitFlag; 0076 bool m_firstPasswordTry; 0077 bool m_dontSendClipboard; 0078 qreal m_horizontalFactor; 0079 qreal m_verticalFactor; 0080 int m_wheelRemainderV; 0081 int m_wheelRemainderH; 0082 #ifndef QTONLY 0083 VncHostPreferences *m_hostPreferences; 0084 #endif 0085 QImage m_frame; 0086 bool m_forceLocalCursor; 0087 #ifdef LIBSSH_FOUND 0088 VncSshTunnelThread *m_sshTunnelThread; 0089 0090 QString readWalletSshPassword(); 0091 void saveWalletSshPassword(); 0092 #endif 0093 0094 void keyEventHandler(QKeyEvent *e); 0095 void unpressModifiers(); 0096 void wheelEventHandler(QWheelEvent *event); 0097 void mouseEventHandler(QMouseEvent *event); 0098 0099 private Q_SLOTS: 0100 void updateImage(int x, int y, int w, int h); 0101 void setCut(const QString &text); 0102 void requestPassword(bool includingUsername); 0103 #ifdef LIBSSH_FOUND 0104 void sshRequestPassword(VncSshTunnelThread::PasswordRequestFlags flags); 0105 #endif 0106 void outputErrorMessage(const QString &message); 0107 void sshErrorMessage(const QString &message); 0108 void clipboardDataChanged(); 0109 }; 0110 0111 #endif