82de5931899bb0a375237341f6465d0f1dc38a37
[presencevnc] / src / vncview.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2007-2008 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 #ifndef VNCVIEW_H
25 #define VNCVIEW_H
26
27 #include "remoteview.h"
28 #include "vncclientthread.h"
29
30 class KConfigGroup {};
31
32 #include <QClipboard>
33
34 extern "C" {
35 #include <rfb/rfbclient.h>
36 }
37
38 class VncView: public RemoteView
39 {
40     Q_OBJECT
41
42 public:
43     explicit VncView(QWidget *parent = 0, const KUrl &url = KUrl(), RemoteView::Quality quality = RemoteView::Medium, int listen_port = 0);
44     ~VncView();
45
46     QSize framebufferSize() const;
47     QSize sizeHint() const;
48     QSize minimumSizeHint() const;
49     bool isQuitting() const;
50     qreal zoomFactor() const { return m_horizontalFactor;} //assumes fixed aspect ratio
51     void reloadSettings();
52     bool start();
53     bool supportsScaling() const;
54     bool supportsLocalCursor() const;
55
56     void setQuality(int q);
57     void setViewOnly(bool viewOnly);
58     void showDotCursor(DotCursorState state);
59     void useFastTransformations(bool enabled);
60     QPoint cursorPosition() const { return QPoint(cursor_x, cursor_y); }
61     void setDisplayOff(bool off) { display_off = off; }
62
63 public slots:
64     void setZoomLevel(int level = -1); //'level' doesn't correspond to actual magnification, though mapping is done here
65     void sendKey(Qt::Key key);
66     void sendKeySequence(QKeySequence keys);
67     void startQuitting();
68
69 protected:
70     void paintEvent(QPaintEvent *event);
71     bool event(QEvent *event);
72     void resizeEvent(QResizeEvent *event);
73     bool eventFilter(QObject *obj, QEvent *event);
74     void inputMethodEvent(QInputMethodEvent *event);
75
76 private:
77     VncClientThread vncThread;
78     QClipboard *m_clipboard;
79     bool m_initDone;
80     int m_buttonMask;
81     QMap<unsigned int, bool> m_mods;
82     int m_x, m_y, m_w, m_h;
83     int cursor_x, cursor_y;
84     bool m_quitFlag;
85     bool m_firstPasswordTry;
86     bool m_dontSendClipboard;
87     qreal m_horizontalFactor;
88     qreal m_verticalFactor;
89     QImage m_frame;
90     bool m_forceLocalCursor;
91     int left_zoom, right_zoom;
92     bool disable_tapping;
93     RemoteView::Quality quality;
94     int listen_port;
95     Qt::TransformationMode transformation_mode;
96     bool display_off;
97
98     void keyEventHandler(QKeyEvent *e);
99     void unpressModifiers();
100     void wheelEventHandler(QWheelEvent *event);
101
102 private slots:
103     void mouseEventHandler(QMouseEvent *event = 0);
104
105     void updateImage(int x, int y, int w, int h);
106     void setCut(const QString &text);
107     void requestPassword();
108     void outputErrorMessage(const QString &message);
109     void clipboardSelectionChanged();
110     void clipboardDataChanged();
111 };
112
113 #endif