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