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 <QMainWindow>
30 #include <QMouseEvent>
31 #include <QScrollArea>
33 #include "vnc/kvncview.h"
34 #include "rdp/krdpview.h"
35 #include "kfullscreenpanel.h"
38 #include "keycapturedialog.h"
40 class KActionCollection
;
48 WINDOW_MODE_FULLSCREEN
58 // Overloaded QScrollArea, to let mouse move events through to remote widget
59 class RemoteScrollArea
: public QScrollArea
{
61 RemoteScrollArea(QWidget
*parent
);
63 virtual void mouseMoveEvent(QMouseEvent
*e
);
67 class KRDC
: public QMainWindow
71 SmartPtr
<KProgressDialog
> m_progressDialog
; // dialog, displayed while connecting
72 QVBoxLayout
*m_layout
; // the layout for autosizing the scrollview
73 RemoteScrollArea
*m_scrollView
; // scrollview that contains the remote widget
74 KRemoteView
*m_view
; // the remote widget (e.g. KVncView)
76 SmartPtr
<KeyCaptureDialog
> m_keyCaptureDialog
; // dialog for key capturing
77 KFullscreenPanel
*m_fsToolbar
; // toolbar for fullscreen (0 in normal mode)
78 QWidget
*m_fsToolbarWidget
; // qt designer widget for fs toolbar
79 // (invalid in normal mode)
80 QPixmap m_pinup
, m_pindown
; // fs toolbar imaged for autohide button
81 QToolBar
*m_toolbar
; // toolbar in normal mode (0 in fs mode)
82 KActionMenu
*m_popup
; // advanced options popup (0 in fs mode)
83 QDesktopWidget m_desktopWidget
;
85 static const int TOOLBAR_AUTOHIDE_TIMEOUT
;
86 bool m_ftAutoHide
; // if true auto hide in fs is activated
87 QTimer m_autoHideTimer
; // timer for autohide
89 QTimer m_bumpScrollTimer
; // timer for bump scrolling (in fs, when res too large)
91 bool m_showProgress
; // can disable showing the progress dialog temporary
92 QString m_host
; // host string as given from user
93 Protocol m_protocol
; // the used protocol
94 Quality m_quality
; // current quality setting
95 QString m_encodings
; // string containing the encodings, space separated,
96 // used for config before connection
97 QString m_password
; // if not null, contains the password to use
98 QString m_resolution
;// contains an alternative resolution
99 QString m_keymap
; // keymap on the terminal server
101 WindowMode m_isFullscreen
; // fs/normal state
102 Resolution m_oldResolution
; // conatins encoded res before fs
103 bool m_fullscreenMinimized
; // true if window is currently minimized from fs
104 QSize m_fullscreenResolution
; // xvidmode size (valid only in fs)
105 bool m_windowScaling
; // used in startup and fullscreen to determine
106 // whether scaling should be enabled in norm mode.
107 // The current state is m_view->scaled().
108 bool m_localCursor
; // show local cursor no matter what
109 QSize m_initialWindowSize
; // initial window size (windowed mode only),
110 // invalid after first use
111 static QString m_lastHost
; // remembers last value of host input
112 KActionCollection
* m_actionCollection
; // used to hold all our KActions for toolbars and menus
113 QString m_caption
; // window caption - normally a command line argument
115 bool parseHost(QString
&s
, Protocol
&prot
, QString
&serverHost
, int &serverPort
,
116 QString
&userName
, QString
&password
);
118 void repositionView(bool fullscreen
);
120 void showProgressDialog();
121 void hideProgressDialog();
123 static const int TOOLBAR_FPS_1000
;
124 static const int TOOLBAR_SPEED_DOWN
;
125 static const int TOOLBAR_SPEED_UP
;
126 void fsToolbarScheduleHidden();
127 KActionMenu
*createActionMenu(QWidget
*parent
) const;
130 virtual void mouseMoveEvent(QMouseEvent
*e
);
131 virtual bool event(QEvent
*e
);
132 virtual bool eventFilter(QObject
*watched
, QEvent
*e
);
133 virtual QSize
sizeHint() const;
136 KRDC(WindowMode wm
= WINDOW_MODE_AUTO
,
137 const QString
&host
= QString::null
,
138 Quality q
= QUALITY_UNKNOWN
,
139 const QString
&encodings
= QString::null
,
140 const QString
&password
= QString::null
,
142 bool localCursor
= false,
143 QSize initialWindowSize
= QSize(),
144 const QString
&caption
= QString::null
);
149 static void setLastHost(const QString
&host
);
152 void changeProgress(RemoteViewStatus s
);
153 void showingPasswordDialog(bool b
);
154 void showProgressTimeout();
156 void setSize(int w
, int h
);
158 void toolbarChanged();
161 void toggleFsToolbarAutoHide();
162 void setFsToolbarAutoHide(bool on
);
163 void showFullscreenToolbar();
164 void hideFullscreenToolbarDelayed();
165 void hideFullscreenToolbarNow();
169 void enableFullscreen(bool full
= false);
170 void switchToNormal(bool scaling
= false);
171 void switchToFullscreen(bool scaling
= false);
172 void viewOnlyToggled();
173 void showLocalCursorToggled();
177 void disconnectedError();