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 <kprogressdialog.h>
25 #include <QDesktopWidget>
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"
39 #include "keycapturedialog.h"
41 class KActionCollection
;
51 WINDOW_MODE_FULLSCREEN
61 // Overloaded QScrollView, to let mouse move events through to remote widget
62 class QScrollView2
: public Q3ScrollView
{
64 QScrollView2(QWidget
*w
, const char *name
);
66 virtual void mouseMoveEvent(QMouseEvent
*e
);
70 class KRDC
: public QWidget
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;
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;
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
,
146 bool localCursor
= false,
147 QSize initialWindowSize
= QSize(),
148 const QString
&caption
= QString::null
);
153 static void setLastHost(const QString
&host
);
156 void changeProgress(RemoteViewStatus s
);
157 void showingPasswordDialog(bool b
);
158 void showProgressTimeout();
160 void setSize(int w
, int h
);
162 void toolbarChanged();
165 void toggleFsToolbarAutoHide();
166 void setFsToolbarAutoHide(bool on
);
167 void showFullscreenToolbar();
168 void hideFullscreenToolbarDelayed();
169 void hideFullscreenToolbarNow();
173 void enableFullscreen(bool full
= false);
174 void switchToNormal(bool scaling
= false);
175 void switchToFullscreen(bool scaling
= false);
176 void viewOnlyToggled();
177 void showLocalCursorToggled();
181 void disconnectedError();