generate moc
[kdenetwork.git] / krdc / krdc.h
blobcf842120ef9be8b45522f63fa866220323ba78c4
1 /***************************************************************************
2 krdc.h - main window
3 -------------------
4 begin : Tue May 13 23:10:42 CET 2002
5 copyright : (C) 2002-2003 by Tim Jansen
6 email : tim@tjansen.de
7 ***************************************************************************/
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
18 #ifndef KRDC_H
19 #define KRDC_H
21 #include <kprogressdialog.h>
22 #include <QSize>
23 #include <QRect>
24 #include <QTimer>
25 #include <QDesktopWidget>
26 #include <QPixmap>
27 #include <QEvent>
28 #include <QVBoxLayout>
29 #include <QMouseEvent>
31 #include <Q3PopupMenu>
32 #include <Q3ScrollView>
34 #include "vnc/kvncview.h"
35 #include "rdp/krdpview.h"
36 #include "kfullscreenpanel.h"
37 #include "vidmode.h"
38 #include "smartptr.h"
39 #include "keycapturedialog.h"
41 class KActionCollection;
42 class KActionMenu;
43 class KToolBar;
44 class Q3PopupMenu;
45 class Q3DockArea;
48 enum WindowMode {
49 WINDOW_MODE_AUTO,
50 WINDOW_MODE_NORMAL,
51 WINDOW_MODE_FULLSCREEN
54 // known protocols
55 enum Protocol {
56 PROTOCOL_AUTO,
57 PROTOCOL_VNC,
58 PROTOCOL_RDP
61 // Overloaded QScrollView, to let mouse move events through to remote widget
62 class QScrollView2 : public Q3ScrollView {
63 public:
64 QScrollView2(QWidget *w, const char *name);
65 protected:
66 virtual void mouseMoveEvent(QMouseEvent *e);
70 class KRDC : public QWidget
72 Q_OBJECT
73 private:
74 SmartPtr<KProgressDialog> m_progressDialog; // dialog, displayed while connecting
75 QVBoxLayout *m_layout; // the layout for autosizing the scrollview
76 Q3ScrollView *m_scrollView; // scrollview that contains the remote widget
77 KRemoteView *m_view; // the remote widget (e.g. KVncView)
79 SmartPtr<KeyCaptureDialog> m_keyCaptureDialog; // dialog for key capturing
80 KFullscreenPanel *m_fsToolbar; // toolbar for fullscreen (0 in normal mode)
81 QWidget *m_fsToolbarWidget; // qt designer widget for fs toolbar
82 // (invalid in normal mode)
83 QPixmap m_pinup, m_pindown; // fs toolbar imaged for autohide button
84 KToolBar *m_toolbar; // toolbar in normal mode (0 in fs mode)
85 Q3DockArea *m_dockArea; // dock area for toolbar in normal mode (0 in fs mode)
86 KActionMenu *m_popup; // advanced options popup (0 in fs mode)
87 QDesktopWidget m_desktopWidget;
89 static const int TOOLBAR_AUTOHIDE_TIMEOUT;
90 bool m_ftAutoHide; // if true auto hide in fs is activated
91 QTimer m_autoHideTimer; // timer for autohide
93 QTimer m_bumpScrollTimer; // timer for bump scrolling (in fs, when res too large)
95 bool m_showProgress; // can disable showing the progress dialog temporary
96 QString m_host; // host string as given from user
97 Protocol m_protocol; // the used protocol
98 Quality m_quality; // current quality setting
99 QString m_encodings; // string containing the encodings, space separated,
100 // used for config before connection
101 QString m_password; // if not null, contains the password to use
102 QString m_resolution;// contains an alternative resolution
103 QString m_keymap; // keymap on the terminal server
105 WindowMode m_isFullscreen; // fs/normal state
106 Resolution m_oldResolution; // conatins encoded res before fs
107 bool m_fullscreenMinimized; // true if window is currently minimized from fs
108 QSize m_fullscreenResolution; // xvidmode size (valid only in fs)
109 bool m_windowScaling; // used in startup and fullscreen to determine
110 // whether scaling should be enabled in norm mode.
111 // The current state is m_view->scaled().
112 bool m_localCursor; // show local cursor no matter what
113 QSize m_initialWindowSize; // initial window size (windowed mode only),
114 // invalid after first use
115 static QString m_lastHost; // remembers last value of host input
116 KActionCollection* m_actionCollection; // used to hold all our KActions for toolbars and menus
117 QString m_caption; // window caption - normally a command line argument
119 bool parseHost(QString &s, Protocol &prot, QString &serverHost, int &serverPort,
120 QString &userName, QString &password);
122 void repositionView(bool fullscreen);
124 void showProgressDialog();
125 void hideProgressDialog();
127 static const int TOOLBAR_FPS_1000;
128 static const int TOOLBAR_SPEED_DOWN;
129 static const int TOOLBAR_SPEED_UP;
130 void fsToolbarScheduleHidden();
131 KActionMenu *createActionMenu(QWidget *parent) const;
133 protected:
134 virtual void mouseMoveEvent(QMouseEvent *e);
135 virtual bool event(QEvent *e);
136 virtual bool eventFilter(QObject *watched, QEvent *e);
137 virtual QSize sizeHint() const;
139 public:
140 KRDC(WindowMode wm = WINDOW_MODE_AUTO,
141 const QString &host = QString::null,
142 Quality q = QUALITY_UNKNOWN,
143 const QString &encodings = QString::null,
144 const QString &password = QString::null,
145 bool scale = false,
146 bool localCursor = false,
147 QSize initialWindowSize = QSize(),
148 const QString &caption = QString::null );
149 ~KRDC();
151 bool start();
153 static void setLastHost(const QString &host);
155 private slots:
156 void changeProgress(RemoteViewStatus s);
157 void showingPasswordDialog(bool b);
158 void showProgressTimeout();
160 void setSize(int w, int h);
161 void iconify();
162 void toolbarChanged();
163 void bumpScroll();
165 void toggleFsToolbarAutoHide();
166 void setFsToolbarAutoHide(bool on);
167 void showFullscreenToolbar();
168 void hideFullscreenToolbarDelayed();
169 void hideFullscreenToolbarNow();
171 public slots:
172 void quit();
173 void enableFullscreen(bool full = false);
174 void switchToNormal(bool scaling = false);
175 void switchToFullscreen(bool scaling = false);
176 void viewOnlyToggled();
177 void showLocalCursorToggled();
179 signals:
180 void disconnected();
181 void disconnectedError();
184 #endif