1 /***************************************************************************
4 begin : Tue May 13 23:10:42 CET 2002
5 copyright : (C) 2002-2003 by Tim Jansen
7 ***************************************************************************/
9 /***************************************************************************
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. *
16 ***************************************************************************/
21 #include <kprogress.h>
22 #include <qscrollview.h>
27 #include <qdesktopwidget.h>
29 #include "vnc/kvncview.h"
30 #include "rdp/krdpview.h"
31 #include "kfullscreenpanel.h"
34 #include "keycapturedialog.h"
44 WINDOW_MODE_FULLSCREEN
54 // Overloaded QScrollView, to let mouse move events through to remote widget
55 class QScrollView2
: public QScrollView
{
57 QScrollView2(QWidget
*w
, const char *name
);
59 virtual void mouseMoveEvent(QMouseEvent
*e
);
63 class KRDC
: public QWidget
67 SmartPtr
<KProgressDialog
> m_progressDialog
; // dialog, displayed while connecting
68 QVBoxLayout
*m_layout
; // the layout for autosizing the scrollview
69 QScrollView
*m_scrollView
; // scrollview that contains the remote widget
70 KProgress
*m_progress
; // progress bar for the dialog
71 KRemoteView
*m_view
; // the remote widget (e.g. KVncView)
73 SmartPtr
<KeyCaptureDialog
> m_keyCaptureDialog
; // dialog for key capturing
74 KFullscreenPanel
*m_fsToolbar
; // toolbar for fullscreen (0 in normal mode)
75 QWidget
*m_fsToolbarWidget
; // qt designer widget for fs toolbar
76 // (invalid in normal mode)
77 QPixmap m_pinup
, m_pindown
; // fs toolbar imaged for autohide button
78 KToolBar
*m_toolbar
; // toolbar in normal mode (0 in fs mode)
79 QDockArea
*m_dockArea
; // dock area for toolbar in normal mode (0 in fs mode)
80 QPopupMenu
*m_popup
; // advanced options popup (0 in fs mode)
81 QDesktopWidget m_desktopWidget
;
83 static const int TOOLBAR_AUTOHIDE_TIMEOUT
;
84 bool m_ftAutoHide
; // if true auto hide in fs is activated
85 QTimer m_autoHideTimer
; // timer for autohide
87 QTimer m_bumpScrollTimer
; // timer for bump scrolling (in fs, when res too large)
89 bool m_showProgress
; // can disable showing the progress dialog temporary
90 QString m_host
; // host string as given from user
91 Protocol m_protocol
; // the used protocol
92 Quality m_quality
; // current quality setting
93 QString m_encodings
; // string containing the encodings, space separated,
94 // used for config before connection
95 QString m_password
; // if not null, contains the password to use
96 QString m_resolution
;// contains an alternative resolution
97 QString m_keymap
; // keymap on the terminal server
99 WindowMode m_isFullscreen
; // fs/normal state
100 Resolution m_oldResolution
; // conatins encoded res before fs
101 bool m_fullscreenMinimized
; // true if window is currently minimized from fs
102 QSize m_fullscreenResolution
; // xvidmode size (valid only in fs)
103 bool m_windowScaling
; // used in startup and fullscreen to determine
104 // whether scaling should be enabled in norm mode.
105 // The current state is m_view->scaled().
106 bool m_localCursor
; // show local cursor no matter what
107 QSize m_initialWindowSize
; // initial window size (windowed mode only),
108 // invalid after first use
109 static QString m_lastHost
; // remembers last value of host input
111 bool parseHost(QString
&s
, Protocol
&prot
, QString
&serverHost
, int &serverPort
,
112 QString
&userName
, QString
&password
);
114 void repositionView(bool fullscreen
);
116 void showProgressDialog();
117 void hideProgressDialog();
119 static const int TOOLBAR_FPS_1000
;
120 static const int TOOLBAR_SPEED_DOWN
;
121 static const int TOOLBAR_SPEED_UP
;
122 void fsToolbarScheduleHidden();
123 QPopupMenu
*createPopupMenu(QWidget
*parent
) const;
126 virtual void mouseMoveEvent(QMouseEvent
*e
);
127 virtual bool event(QEvent
*e
);
128 virtual bool eventFilter(QObject
*watched
, QEvent
*e
);
129 virtual QSize
sizeHint();
132 KRDC(WindowMode wm
= WINDOW_MODE_AUTO
,
133 const QString
&host
= QString::null
,
134 Quality q
= QUALITY_UNKNOWN
,
135 const QString
&encodings
= QString::null
,
136 const QString
&password
= QString::null
,
138 bool localCursor
= false,
139 QSize initialWindowSize
= QSize());
144 static void setLastHost(const QString
&host
);
147 void changeProgress(RemoteViewStatus s
);
148 void showingPasswordDialog(bool b
);
149 void showProgressTimeout();
151 void setSize(int w
, int h
);
153 void toolbarChanged();
156 void toggleFsToolbarAutoHide();
157 void setFsToolbarAutoHide(bool on
);
158 void showFullscreenToolbar();
159 void hideFullscreenToolbarDelayed();
160 void hideFullscreenToolbarNow();
164 void enableFullscreen(bool full
= false);
165 void switchToNormal(bool scaling
= false);
166 void switchToFullscreen(bool scaling
= false);
167 void viewOnlyToggled();
168 void showLocalCursorToggled();
172 void disconnectedError();