merge in my changes from soc-krdc branch
[kdenetwork.git] / krdc / krdc.h
blob637cf9474c9dab70410f32d0e09b566273b38eff
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 <QMainWindow>
30 #include <QMouseEvent>
31 #include <QScrollArea>
33 #include "vnc/kvncview.h"
34 #include "rdp/krdpview.h"
35 #include "kfullscreenpanel.h"
36 #include "vidmode.h"
37 #include "smartptr.h"
38 #include "keycapturedialog.h"
40 class KActionCollection;
41 class KActionMenu;
44 enum WindowMode {
45 WINDOW_MODE_AUTO,
46 WINDOW_MODE_NORMAL,
47 WINDOW_MODE_FULLSCREEN
50 // known protocols
51 enum Protocol {
52 PROTOCOL_AUTO,
53 PROTOCOL_VNC,
54 PROTOCOL_RDP
57 // Overloaded QScrollArea, to let mouse move events through to remote widget
58 class RemoteScrollArea : public QScrollArea {
59 public:
60 RemoteScrollArea(QWidget *parent);
61 protected:
62 virtual void mouseMoveEvent(QMouseEvent *e);
66 class KRDC : public QMainWindow
68 Q_OBJECT
69 private:
70 SmartPtr<KProgressDialog> m_progressDialog; // dialog, displayed while connecting
71 QVBoxLayout *m_layout; // the layout for autosizing the scrollview
72 RemoteScrollArea *m_scrollView; // scrollview that contains the remote widget
73 KRemoteView *m_view; // the remote widget (e.g. KVncView)
75 SmartPtr<KeyCaptureDialog> m_keyCaptureDialog; // dialog for key capturing
76 KFullscreenPanel *m_fsToolbar; // toolbar for fullscreen (0 in normal mode)
77 QWidget *m_fsToolbarWidget; // qt designer widget for fs toolbar
78 // (invalid in normal mode)
79 QPixmap m_pinup, m_pindown; // fs toolbar imaged for autohide button
80 QToolBar *m_toolbar; // toolbar in normal mode (0 in fs mode)
81 KActionMenu *m_popup; // advanced options popup (0 in fs mode)
82 QDesktopWidget m_desktopWidget;
84 static const int TOOLBAR_AUTOHIDE_TIMEOUT;
85 bool m_ftAutoHide; // if true auto hide in fs is activated
86 QTimer m_autoHideTimer; // timer for autohide
88 QTimer m_bumpScrollTimer; // timer for bump scrolling (in fs, when res too large)
90 bool m_showProgress; // can disable showing the progress dialog temporary
91 QString m_host; // host string as given from user
92 Protocol m_protocol; // the used protocol
93 KRemoteView::Quality m_quality; // current quality setting
94 QString m_encodings; // string containing the encodings, space separated,
95 // used for config before connection
96 QString m_password; // if not null, contains the password to use
97 QString m_resolution;// contains an alternative resolution
98 QString m_keymap; // keymap on the terminal server
100 WindowMode m_isFullscreen; // fs/normal state
101 Resolution m_oldResolution; // conatins encoded res before fs
102 bool m_fullscreenMinimized; // true if window is currently minimized from fs
103 QSize m_fullscreenResolution; // xvidmode size (valid only in fs)
104 bool m_windowScaling; // used in startup and fullscreen to determine
105 // whether scaling should be enabled in norm mode.
106 // The current state is m_view->scaled().
107 bool m_localCursor; // show local cursor no matter what
108 QSize m_initialWindowSize; // initial window size (windowed mode only),
109 // invalid after first use
110 static QString m_lastHost; // remembers last value of host input
111 KActionCollection* m_actionCollection; // used to hold all our KActions for toolbars and menus
112 QString m_caption; // window caption - normally a command line argument
114 bool parseHost(QString &s, Protocol &prot, QString &serverHost, int &serverPort,
115 QString &userName, QString &password);
117 void repositionView(bool fullscreen);
119 void showProgressDialog();
120 void hideProgressDialog();
122 static const int TOOLBAR_FPS_1000;
123 static const int TOOLBAR_SPEED_DOWN;
124 static const int TOOLBAR_SPEED_UP;
125 void fsToolbarScheduleHidden();
126 KActionMenu *createActionMenu(QWidget *parent) const;
128 protected:
129 virtual void mouseMoveEvent(QMouseEvent *e);
130 virtual bool event(QEvent *e);
131 virtual bool eventFilter(QObject *watched, QEvent *e);
132 virtual QSize sizeHint() const;
134 public:
135 KRDC(WindowMode wm = WINDOW_MODE_AUTO,
136 const QString &host = QString(),
137 KRemoteView::Quality q = KRemoteView::Unknown,
138 const QString &encodings = QString(),
139 const QString &password = QString(),
140 bool scale = false,
141 bool localCursor = false,
142 QSize initialWindowSize = QSize(),
143 const QString &caption = QString() );
144 ~KRDC();
146 bool start();
148 static void setLastHost(const QString &host);
150 private slots:
151 void changeProgress(KRemoteView::RemoteStatus s);
152 void showingPasswordDialog(bool b);
153 void showProgressTimeout();
155 void setSize(int w, int h);
156 void iconify();
157 void toolbarChanged();
158 void bumpScroll();
160 void toggleFsToolbarAutoHide();
161 void setFsToolbarAutoHide(bool on);
162 void showFullscreenToolbar();
163 void hideFullscreenToolbarDelayed();
164 void hideFullscreenToolbarNow();
166 public slots:
167 void quit();
168 void enableFullscreen(bool full = false);
169 void switchToNormal(bool scaling = false);
170 void switchToFullscreen(bool scaling = false);
171 void viewOnlyToggled();
172 void showLocalCursorToggled();
174 signals:
175 void disconnected();
176 void disconnectedError();
179 #endif