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