imported project
[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);
44     ~VncView();
45
46     QSize framebufferSize();
47     QSize sizeHint() const;
48     QSize minimumSizeHint() const;
49     void startQuitting();
50     bool isQuitting();
51     bool start();
52     bool supportsScaling() const;
53     bool supportsLocalCursor() const;
54     
55     void setQuality(int q);
56     void setViewOnly(bool viewOnly);
57     void showDotCursor(DotCursorState state);
58     
59     virtual void updateConfiguration();
60
61 public slots:
62     void enableScaling(bool scale);
63     void scaleResize(int w, int h);
64     void forceFullRepaint();
65
66 protected:
67     void paintEvent(QPaintEvent *event);
68     bool event(QEvent *event);
69     void resizeEvent(QResizeEvent *event);
70     bool eventFilter(QObject *obj, QEvent *event);
71
72 private:
73     VncClientThread vncThread;
74     QClipboard *m_clipboard;
75     bool m_initDone;
76     int m_buttonMask;
77     QMap<unsigned int, bool> m_mods;
78     int m_x, m_y, m_w, m_h;
79     int cursor_x, cursor_y;
80     bool m_repaint;
81     bool m_quitFlag;
82     bool m_firstPasswordTry;
83     bool m_authenticaionCanceled;
84     bool m_dontSendClipboard;
85     qreal m_horizontalFactor;
86     qreal m_verticalFactor;
87     QImage m_frame;
88     bool m_forceLocalCursor;
89     bool force_full_repaint;
90     RemoteView::Quality quality;
91
92     void keyEventHandler(QKeyEvent *e);
93     void unpressModifiers();
94     void wheelEventHandler(QWheelEvent *event);
95     
96 private slots:
97     void mouseEventHandler(QMouseEvent *event = 0);
98
99     void updateImage(int x, int y, int w, int h);
100     void setCut(const QString &text);
101     void requestPassword();
102     void outputErrorMessage(const QString &message);
103     void clipboardSelectionChanged();
104     void clipboardDataChanged();
105 };
106
107 #endif