author | harlekin <harlekin> | 2003-03-08 21:22:55 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-03-08 21:22:55 (UTC) |
commit | e6bac45a35954b3d0161b6808fe9e60143aab79e (patch) (unidiff) | |
tree | 62a8496b548e3cf1a3fc2c934cd1445f6f049e9e | |
parent | e0ee59855dfd924d33b4fcd98d5fa74a95437e71 (diff) | |
download | opie-e6bac45a35954b3d0161b6808fe9e60143aab79e.zip opie-e6bac45a35954b3d0161b6808fe9e60143aab79e.tar.gz opie-e6bac45a35954b3d0161b6808fe9e60143aab79e.tar.bz2 |
use save from inline
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 100 |
1 files changed, 1 insertions, 99 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 01468ca..abcdb84 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -1,803 +1,705 @@ | |||
1 | #include <assert.h> | 1 | #include <assert.h> |
2 | 2 | ||
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qmenubar.h> | 4 | #include <qmenubar.h> |
5 | #include <qlabel.h> | 5 | #include <qlabel.h> |
6 | #include <qpopupmenu.h> | 6 | #include <qpopupmenu.h> |
7 | #include <qtoolbar.h> | 7 | #include <qtoolbar.h> |
8 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
9 | #include <qpushbutton.h> | 9 | #include <qpushbutton.h> |
10 | #include <qwhatsthis.h> | 10 | #include <qwhatsthis.h> |
11 | #include <qfileinfo.h> | 11 | #include <qfileinfo.h> |
12 | #include <qtextstream.h> | 12 | #include <qtextstream.h> |
13 | 13 | ||
14 | #include <qpe/resource.h> | 14 | #include <qpe/resource.h> |
15 | #include <qpe/qpeapplication.h> | 15 | #include <qpe/qpeapplication.h> |
16 | #include <qpe/filemanager.h> | 16 | #include <qpe/filemanager.h> |
17 | #include <qpe/mimetype.h> | 17 | #include <qpe/mimetype.h> |
18 | 18 | ||
19 | #include <opie/ofiledialog.h> | 19 | #include <opie/ofiledialog.h> |
20 | 20 | ||
21 | #include "TEmulation.h" | 21 | #include "TEmulation.h" |
22 | #include "keytrans.h" | 22 | #include "keytrans.h" |
23 | #include "profileeditordialog.h" | 23 | #include "profileeditordialog.h" |
24 | #include "configdialog.h" | 24 | #include "configdialog.h" |
25 | #include "default.h" | 25 | #include "default.h" |
26 | #include "metafactory.h" | 26 | #include "metafactory.h" |
27 | #include "profile.h" | 27 | #include "profile.h" |
28 | #include "profilemanager.h" | 28 | #include "profilemanager.h" |
29 | #include "mainwindow.h" | 29 | #include "mainwindow.h" |
30 | #include "tabwidget.h" | 30 | #include "tabwidget.h" |
31 | #include "transferdialog.h" | 31 | #include "transferdialog.h" |
32 | #include "function_keyboard.h" | 32 | #include "function_keyboard.h" |
33 | #include "emulation_handler.h" | 33 | #include "emulation_handler.h" |
34 | #include "script.h" | 34 | #include "script.h" |
35 | 35 | ||
36 | static char * filesave_xpm[] = { | ||
37 | "16 16 78 1", | ||
38 | " c None", | ||
39 | ". c #343434", | ||
40 | "+ c #A0A0A0", | ||
41 | "@ c #565656", | ||
42 | "# c #9E9E9E", | ||
43 | "$ c #525252", | ||
44 | "% c #929292", | ||
45 | "& c #676767", | ||
46 | "* c #848484", | ||
47 | "= c #666666", | ||
48 | "- c #D8D8D8", | ||
49 | "; c #FFFFFF", | ||
50 | "> c #DBDBDB", | ||
51 | ", c #636363", | ||
52 | "' c #989898", | ||
53 | ") c #2D2D2D", | ||
54 | "! c #909090", | ||
55 | "~ c #AEAEAE", | ||
56 | "{ c #EAEAEA", | ||
57 | "] c #575757", | ||
58 | "^ c #585858", | ||
59 | "/ c #8A8A8A", | ||
60 | "( c #828282", | ||
61 | "_ c #6F6F6F", | ||
62 | ": c #C9C9C9", | ||
63 | "< c #050505", | ||
64 | "[ c #292929", | ||
65 | "} c #777777", | ||
66 | "| c #616161", | ||
67 | "1 c #3A3A3A", | ||
68 | "2 c #BEBEBE", | ||
69 | "3 c #2C2C2C", | ||
70 | "4 c #7C7C7C", | ||
71 | "5 c #F6F6F6", | ||
72 | "6 c #FCFCFC", | ||
73 | "7 c #6B6B6B", | ||
74 | "8 c #959595", | ||
75 | "9 c #4F4F4F", | ||
76 | "0 c #808080", | ||
77 | "a c #767676", | ||
78 | "b c #818181", | ||
79 | "c c #B8B8B8", | ||
80 | "d c #FBFBFB", | ||
81 | "e c #F9F9F9", | ||
82 | "f c #CCCCCC", | ||
83 | "g c #030303", | ||
84 | "h c #737373", | ||
85 | "i c #7A7A7A", | ||
86 | "j c #7E7E7E", | ||
87 | "k c #6A6A6A", | ||
88 | "l c #FAFAFA", | ||
89 | "m c #505050", | ||
90 | "n c #9D9D9D", | ||
91 | "o c #333333", | ||
92 | "p c #7B7B7B", | ||
93 | "q c #787878", | ||
94 | "r c #696969", | ||
95 | "s c #494949", | ||
96 | "t c #555555", | ||
97 | "u c #949494", | ||
98 | "v c #E6E6E6", | ||
99 | "w c #424242", | ||
100 | "x c #515151", | ||
101 | "y c #535353", | ||
102 | "z c #3E3E3E", | ||
103 | "A c #D4D4D4", | ||
104 | "B c #0C0C0C", | ||
105 | "C c #353535", | ||
106 | "D c #474747", | ||
107 | "E c #ECECEC", | ||
108 | "F c #919191", | ||
109 | "G c #7D7D7D", | ||
110 | "H c #000000", | ||
111 | "I c #404040", | ||
112 | "J c #858585", | ||
113 | "K c #323232", | ||
114 | "L c #D0D0D0", | ||
115 | "M c #1C1C1C", | ||
116 | " ...+ ", | ||
117 | " @#$%&..+ ", | ||
118 | " .*=-;;>,..+ ", | ||
119 | " ')!~;;;;;;{]..", | ||
120 | " ^/(-;;;;;;;_:<", | ||
121 | " [}|;;;;;;;{12$", | ||
122 | " #34-55;;;;678$+", | ||
123 | " 90ab=c;dd;e1fg ", | ||
124 | " [ahij((kbl0mn$ ", | ||
125 | " op^q^^7r&]s/$+ ", | ||
126 | "@btu;vbwxy]zAB ", | ||
127 | "CzDEvEv;;DssF$ ", | ||
128 | "G.H{E{E{IxsJ$+ ", | ||
129 | " +...vEKxzLM ", | ||
130 | " +...z]n$ ", | ||
131 | " +... "}; | ||
132 | |||
133 | |||
134 | 36 | ||
135 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { | 37 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { |
136 | KeyTrans::loadAll(); | 38 | KeyTrans::loadAll(); |
137 | for (int i = 0; i < KeyTrans::count(); i++ ) { | 39 | for (int i = 0; i < KeyTrans::count(); i++ ) { |
138 | KeyTrans* s = KeyTrans::find(i ); | 40 | KeyTrans* s = KeyTrans::find(i ); |
139 | assert( s ); | 41 | assert( s ); |
140 | } | 42 | } |
141 | m_factory = new MetaFactory(); | 43 | m_factory = new MetaFactory(); |
142 | Default def(m_factory); | 44 | Default def(m_factory); |
143 | m_sessions.setAutoDelete( TRUE ); | 45 | m_sessions.setAutoDelete( TRUE ); |
144 | m_curSession = 0; | 46 | m_curSession = 0; |
145 | m_manager = new ProfileManager( m_factory ); | 47 | m_manager = new ProfileManager( m_factory ); |
146 | m_manager->load(); | 48 | m_manager->load(); |
147 | m_scriptsData.setAutoDelete(TRUE); | 49 | m_scriptsData.setAutoDelete(TRUE); |
148 | 50 | ||
149 | initUI(); | 51 | initUI(); |
150 | populateProfiles(); | 52 | populateProfiles(); |
151 | populateScripts(); | 53 | populateScripts(); |
152 | } | 54 | } |
153 | void MainWindow::initUI() { | 55 | void MainWindow::initUI() { |
154 | setToolBarsMovable( FALSE ); | 56 | setToolBarsMovable( FALSE ); |
155 | 57 | ||
156 | /* tool bar for the menu */ | 58 | /* tool bar for the menu */ |
157 | m_tool = new QToolBar( this ); | 59 | m_tool = new QToolBar( this ); |
158 | m_tool->setHorizontalStretchable( TRUE ); | 60 | m_tool->setHorizontalStretchable( TRUE ); |
159 | 61 | ||
160 | m_bar = new QMenuBar( m_tool ); | 62 | m_bar = new QMenuBar( m_tool ); |
161 | m_console = new QPopupMenu( this ); | 63 | m_console = new QPopupMenu( this ); |
162 | m_scripts = new QPopupMenu( this ); | 64 | m_scripts = new QPopupMenu( this ); |
163 | m_sessionsPop= new QPopupMenu( this ); | 65 | m_sessionsPop= new QPopupMenu( this ); |
164 | m_scriptsPop = new QPopupMenu( this ); | 66 | m_scriptsPop = new QPopupMenu( this ); |
165 | 67 | ||
166 | /* add a toolbar for icons */ | 68 | /* add a toolbar for icons */ |
167 | m_icons = new QToolBar(this); | 69 | m_icons = new QToolBar(this); |
168 | 70 | ||
169 | /* | 71 | /* |
170 | * the settings action | 72 | * the settings action |
171 | */ | 73 | */ |
172 | m_setProfiles = new QAction(tr("Configure Profiles"), | 74 | m_setProfiles = new QAction(tr("Configure Profiles"), |
173 | Resource::loadPixmap( "SettingsIcon" ), | 75 | Resource::loadPixmap( "SettingsIcon" ), |
174 | QString::null, 0, this, 0); | 76 | QString::null, 0, this, 0); |
175 | m_setProfiles->addTo( m_console ); | 77 | m_setProfiles->addTo( m_console ); |
176 | connect( m_setProfiles, SIGNAL(activated() ), | 78 | connect( m_setProfiles, SIGNAL(activated() ), |
177 | this, SLOT(slotConfigure() ) ); | 79 | this, SLOT(slotConfigure() ) ); |
178 | 80 | ||
179 | m_console->insertSeparator(); | 81 | m_console->insertSeparator(); |
180 | /* | 82 | /* |
181 | * new Action for new sessions | 83 | * new Action for new sessions |
182 | */ | 84 | */ |
183 | QAction* newCon = new QAction(tr("New Connection"), | 85 | QAction* newCon = new QAction(tr("New Connection"), |
184 | Resource::loadPixmap( "new" ), | 86 | Resource::loadPixmap( "new" ), |
185 | QString::null, 0, this, 0); | 87 | QString::null, 0, this, 0); |
186 | newCon->addTo( m_console ); | 88 | newCon->addTo( m_console ); |
187 | connect( newCon, SIGNAL(activated() ), | 89 | connect( newCon, SIGNAL(activated() ), |
188 | this, SLOT(slotNew() ) ); | 90 | this, SLOT(slotNew() ) ); |
189 | 91 | ||
190 | m_console->insertSeparator(); | 92 | m_console->insertSeparator(); |
191 | 93 | ||
192 | QAction *saveCon = new QAction(tr("Save Connection"), | 94 | QAction *saveCon = new QAction(tr("Save Connection"), |
193 | QPixmap( ( const char** ) filesave_xpm ) , QString::null, | 95 | Resource::loadPixmap( "save" ), QString::null, |
194 | 0, this, 0 ); | 96 | 0, this, 0 ); |
195 | saveCon->addTo( m_console ); | 97 | saveCon->addTo( m_console ); |
196 | connect( saveCon, SIGNAL(activated() ), | 98 | connect( saveCon, SIGNAL(activated() ), |
197 | this, SLOT(slotSaveSession() ) ); | 99 | this, SLOT(slotSaveSession() ) ); |
198 | m_console->insertSeparator(); | 100 | m_console->insertSeparator(); |
199 | 101 | ||
200 | /* | 102 | /* |
201 | * connect action | 103 | * connect action |
202 | */ | 104 | */ |
203 | m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), | 105 | m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), |
204 | QString::null, 0, this, 0 ); | 106 | QString::null, 0, this, 0 ); |
205 | m_connect->addTo( m_console ); | 107 | m_connect->addTo( m_console ); |
206 | connect(m_connect, SIGNAL(activated() ), | 108 | connect(m_connect, SIGNAL(activated() ), |
207 | this, SLOT(slotConnect() ) ); | 109 | this, SLOT(slotConnect() ) ); |
208 | 110 | ||
209 | /* | 111 | /* |
210 | * disconnect action | 112 | * disconnect action |
211 | */ | 113 | */ |
212 | m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), | 114 | m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), |
213 | QString::null, 0, this, 0 ); | 115 | QString::null, 0, this, 0 ); |
214 | m_disconnect->addTo( m_console ); | 116 | m_disconnect->addTo( m_console ); |
215 | connect(m_disconnect, SIGNAL(activated() ), | 117 | connect(m_disconnect, SIGNAL(activated() ), |
216 | this, SLOT(slotDisconnect() ) ); | 118 | this, SLOT(slotDisconnect() ) ); |
217 | 119 | ||
218 | m_console->insertSeparator(); | 120 | m_console->insertSeparator(); |
219 | 121 | ||
220 | m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, | 122 | m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, |
221 | 0, this, 0 ); | 123 | 0, this, 0 ); |
222 | m_transfer->addTo( m_console ); | 124 | m_transfer->addTo( m_console ); |
223 | connect(m_transfer, SIGNAL(activated() ), | 125 | connect(m_transfer, SIGNAL(activated() ), |
224 | this, SLOT(slotTransfer() ) ); | 126 | this, SLOT(slotTransfer() ) ); |
225 | 127 | ||
226 | /* | 128 | /* |
227 | * immediate change of line wrap policy | 129 | * immediate change of line wrap policy |
228 | */ | 130 | */ |
229 | m_isWrapped = false; | 131 | m_isWrapped = false; |
230 | m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0 ); | 132 | m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0 ); |
231 | m_wrap->addTo( m_console ); | 133 | m_wrap->addTo( m_console ); |
232 | connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); | 134 | connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); |
233 | 135 | ||
234 | /* | 136 | /* |
235 | * fullscreen | 137 | * fullscreen |
236 | */ | 138 | */ |
237 | m_isFullscreen = false; | 139 | m_isFullscreen = false; |
238 | 140 | ||
239 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) | 141 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) |
240 | , QString::null, 0, this, 0); | 142 | , QString::null, 0, this, 0); |
241 | m_fullscreen->addTo( m_console ); | 143 | m_fullscreen->addTo( m_console ); |
242 | connect( m_fullscreen, SIGNAL( activated() ), | 144 | connect( m_fullscreen, SIGNAL( activated() ), |
243 | this, SLOT( slotFullscreen() ) ); | 145 | this, SLOT( slotFullscreen() ) ); |
244 | 146 | ||
245 | m_console->insertSeparator(); | 147 | m_console->insertSeparator(); |
246 | 148 | ||
247 | QAction *a = new QAction(); | 149 | QAction *a = new QAction(); |
248 | a->setText( tr("Save history") ); | 150 | a->setText( tr("Save history") ); |
249 | a->addTo( m_console ); | 151 | a->addTo( m_console ); |
250 | connect(a, SIGNAL(activated() ), | 152 | connect(a, SIGNAL(activated() ), |
251 | this, SLOT(slotSaveHistory() ) ); | 153 | this, SLOT(slotSaveHistory() ) ); |
252 | /* | 154 | /* |
253 | * terminate action | 155 | * terminate action |
254 | */ | 156 | */ |
255 | m_terminate = new QAction(); | 157 | m_terminate = new QAction(); |
256 | m_terminate->setText( tr("Terminate") ); | 158 | m_terminate->setText( tr("Terminate") ); |
257 | m_terminate->addTo( m_console ); | 159 | m_terminate->addTo( m_console ); |
258 | connect(m_terminate, SIGNAL(activated() ), | 160 | connect(m_terminate, SIGNAL(activated() ), |
259 | this, SLOT(slotTerminate() ) ); | 161 | this, SLOT(slotTerminate() ) ); |
260 | 162 | ||
261 | m_closewindow = new QAction(); | 163 | m_closewindow = new QAction(); |
262 | m_closewindow->setText( tr("Close Window") ); | 164 | m_closewindow->setText( tr("Close Window") ); |
263 | m_closewindow->addTo( m_console ); | 165 | m_closewindow->addTo( m_console ); |
264 | connect( m_closewindow, SIGNAL(activated() ), | 166 | connect( m_closewindow, SIGNAL(activated() ), |
265 | this, SLOT(slotClose() ) ); | 167 | this, SLOT(slotClose() ) ); |
266 | 168 | ||
267 | 169 | ||
268 | /* | 170 | /* |
269 | * script actions | 171 | * script actions |
270 | */ | 172 | */ |
271 | m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); | 173 | m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); |
272 | connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); | 174 | connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); |
273 | 175 | ||
274 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); | 176 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); |
275 | m_recordScript->addTo(m_scripts); | 177 | m_recordScript->addTo(m_scripts); |
276 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); | 178 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); |
277 | 179 | ||
278 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); | 180 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); |
279 | m_saveScript->addTo(m_scripts); | 181 | m_saveScript->addTo(m_scripts); |
280 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); | 182 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); |
281 | 183 | ||
282 | 184 | ||
283 | /* | 185 | /* |
284 | * action that open/closes the keyboard | 186 | * action that open/closes the keyboard |
285 | */ | 187 | */ |
286 | m_openKeys = new QAction (tr("Open Keyboard..."), | 188 | m_openKeys = new QAction (tr("Open Keyboard..."), |
287 | Resource::loadPixmap( "console/keys/keyboard_icon" ), | 189 | Resource::loadPixmap( "console/keys/keyboard_icon" ), |
288 | QString::null, 0, this, 0); | 190 | QString::null, 0, this, 0); |
289 | m_openKeys->setToggleAction(true); | 191 | m_openKeys->setToggleAction(true); |
290 | connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); | 192 | connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); |
291 | 193 | ||
292 | /* insert the submenu */ | 194 | /* insert the submenu */ |
293 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, | 195 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, |
294 | -1, 0); | 196 | -1, 0); |
295 | 197 | ||
296 | /* insert the connection menu */ | 198 | /* insert the connection menu */ |
297 | m_bar->insertItem( tr("Connection"), m_console ); | 199 | m_bar->insertItem( tr("Connection"), m_console ); |
298 | 200 | ||
299 | /* the scripts menu */ | 201 | /* the scripts menu */ |
300 | m_bar->insertItem( tr("Scripts"), m_scripts ); | 202 | m_bar->insertItem( tr("Scripts"), m_scripts ); |
301 | 203 | ||
302 | /* and the keyboard */ | 204 | /* and the keyboard */ |
303 | m_keyBar = new QToolBar(this); | 205 | m_keyBar = new QToolBar(this); |
304 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); | 206 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); |
305 | m_keyBar->setHorizontalStretchable( TRUE ); | 207 | m_keyBar->setHorizontalStretchable( TRUE ); |
306 | m_keyBar->hide(); | 208 | m_keyBar->hide(); |
307 | 209 | ||
308 | m_kb = new FunctionKeyboard(m_keyBar); | 210 | m_kb = new FunctionKeyboard(m_keyBar); |
309 | connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), | 211 | connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), |
310 | this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); | 212 | this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); |
311 | 213 | ||
312 | 214 | ||
313 | a = new QAction(tr("Copy"), | 215 | a = new QAction(tr("Copy"), |
314 | Resource::loadPixmap("copy"), QString::null, | 216 | Resource::loadPixmap("copy"), QString::null, |
315 | 0, this, 0 ); | 217 | 0, this, 0 ); |
316 | //a->addTo( m_icons ); | 218 | //a->addTo( m_icons ); |
317 | connect( a, SIGNAL(activated() ), | 219 | connect( a, SIGNAL(activated() ), |
318 | this, SLOT(slotCopy() ) ); | 220 | this, SLOT(slotCopy() ) ); |
319 | 221 | ||
320 | QAction *paste = new QAction(tr("Paste"), | 222 | QAction *paste = new QAction(tr("Paste"), |
321 | Resource::loadPixmap("paste"), QString::null, | 223 | Resource::loadPixmap("paste"), QString::null, |
322 | 0, this, 0 ); | 224 | 0, this, 0 ); |
323 | connect( paste, SIGNAL(activated() ), | 225 | connect( paste, SIGNAL(activated() ), |
324 | this, SLOT(slotPaste() ) ); | 226 | this, SLOT(slotPaste() ) ); |
325 | 227 | ||
326 | 228 | ||
327 | newCon->addTo( m_icons ); | 229 | newCon->addTo( m_icons ); |
328 | m_setProfiles->addTo( m_icons ); | 230 | m_setProfiles->addTo( m_icons ); |
329 | paste->addTo( m_icons ); | 231 | paste->addTo( m_icons ); |
330 | m_openKeys->addTo(m_icons); | 232 | m_openKeys->addTo(m_icons); |
331 | m_fullscreen->addTo( m_icons ); | 233 | m_fullscreen->addTo( m_icons ); |
332 | 234 | ||
333 | m_connect->setEnabled( false ); | 235 | m_connect->setEnabled( false ); |
334 | m_disconnect->setEnabled( false ); | 236 | m_disconnect->setEnabled( false ); |
335 | m_terminate->setEnabled( false ); | 237 | m_terminate->setEnabled( false ); |
336 | m_transfer->setEnabled( false ); | 238 | m_transfer->setEnabled( false ); |
337 | m_scripts->setItemEnabled(m_runScript_id, false); | 239 | m_scripts->setItemEnabled(m_runScript_id, false); |
338 | m_recordScript->setEnabled( false ); | 240 | m_recordScript->setEnabled( false ); |
339 | m_saveScript->setEnabled( false ); | 241 | m_saveScript->setEnabled( false ); |
340 | m_fullscreen->setEnabled( false ); | 242 | m_fullscreen->setEnabled( false ); |
341 | m_closewindow->setEnabled( false ); | 243 | m_closewindow->setEnabled( false ); |
342 | m_wrap->setEnabled( false ); | 244 | m_wrap->setEnabled( false ); |
343 | 245 | ||
344 | /* | 246 | /* |
345 | * connect to the menu activation | 247 | * connect to the menu activation |
346 | */ | 248 | */ |
347 | connect( m_sessionsPop, SIGNAL(activated( int ) ), | 249 | connect( m_sessionsPop, SIGNAL(activated( int ) ), |
348 | this, SLOT(slotProfile( int ) ) ); | 250 | this, SLOT(slotProfile( int ) ) ); |
349 | 251 | ||
350 | m_consoleWindow = new TabWidget( this, "blah"); | 252 | m_consoleWindow = new TabWidget( this, "blah"); |
351 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), | 253 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), |
352 | this, SLOT(slotSessionChanged(Session*) ) ); | 254 | this, SLOT(slotSessionChanged(Session*) ) ); |
353 | setCentralWidget( m_consoleWindow ); | 255 | setCentralWidget( m_consoleWindow ); |
354 | 256 | ||
355 | } | 257 | } |
356 | 258 | ||
357 | ProfileManager* MainWindow::manager() { | 259 | ProfileManager* MainWindow::manager() { |
358 | return m_manager; | 260 | return m_manager; |
359 | } | 261 | } |
360 | TabWidget* MainWindow::tabWidget() { | 262 | TabWidget* MainWindow::tabWidget() { |
361 | return m_consoleWindow; | 263 | return m_consoleWindow; |
362 | } | 264 | } |
363 | void MainWindow::populateProfiles() { | 265 | void MainWindow::populateProfiles() { |
364 | m_sessionsPop->clear(); | 266 | m_sessionsPop->clear(); |
365 | Profile::ValueList list = manager()->all(); | 267 | Profile::ValueList list = manager()->all(); |
366 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { | 268 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { |
367 | m_sessionsPop->insertItem( (*it).name() ); | 269 | m_sessionsPop->insertItem( (*it).name() ); |
368 | } | 270 | } |
369 | 271 | ||
370 | } | 272 | } |
371 | 273 | ||
372 | void MainWindow::populateScripts() { | 274 | void MainWindow::populateScripts() { |
373 | m_scriptsPop->clear(); | 275 | m_scriptsPop->clear(); |
374 | m_scriptsData.clear(); | 276 | m_scriptsData.clear(); |
375 | DocLnkSet files(QPEApplication::documentDir(), "text/plain"); | 277 | DocLnkSet files(QPEApplication::documentDir(), "text/plain"); |
376 | QListIterator<DocLnk> dit(files.children()); | 278 | QListIterator<DocLnk> dit(files.children()); |
377 | for (; dit.current(); ++dit) { | 279 | for (; dit.current(); ++dit) { |
378 | if (*dit && (*dit)->name().length()>0) { | 280 | if (*dit && (*dit)->name().length()>0) { |
379 | QFileInfo info((*dit)->file()); | 281 | QFileInfo info((*dit)->file()); |
380 | if (info.extension(false) == "script") { | 282 | if (info.extension(false) == "script") { |
381 | m_scriptsData.append(new DocLnk(**dit)); | 283 | m_scriptsData.append(new DocLnk(**dit)); |
382 | m_scriptsPop->insertItem((*dit)->name()); | 284 | m_scriptsPop->insertItem((*dit)->name()); |
383 | } | 285 | } |
384 | } | 286 | } |
385 | } | 287 | } |
386 | 288 | ||
387 | } | 289 | } |
388 | 290 | ||
389 | MainWindow::~MainWindow() { | 291 | MainWindow::~MainWindow() { |
390 | delete m_factory; | 292 | delete m_factory; |
391 | manager()->save(); | 293 | manager()->save(); |
392 | } | 294 | } |
393 | 295 | ||
394 | MetaFactory* MainWindow::factory() { | 296 | MetaFactory* MainWindow::factory() { |
395 | return m_factory; | 297 | return m_factory; |
396 | } | 298 | } |
397 | 299 | ||
398 | Session* MainWindow::currentSession() { | 300 | Session* MainWindow::currentSession() { |
399 | return m_curSession; | 301 | return m_curSession; |
400 | } | 302 | } |
401 | 303 | ||
402 | QList<Session> MainWindow::sessions() { | 304 | QList<Session> MainWindow::sessions() { |
403 | return m_sessions; | 305 | return m_sessions; |
404 | } | 306 | } |
405 | 307 | ||
406 | void MainWindow::slotNew() { | 308 | void MainWindow::slotNew() { |
407 | ProfileEditorDialog dlg(factory() ); | 309 | ProfileEditorDialog dlg(factory() ); |
408 | dlg.showMaximized(); | 310 | dlg.showMaximized(); |
409 | dlg.setCaption( tr("New Connection") ); | 311 | dlg.setCaption( tr("New Connection") ); |
410 | int ret = dlg.exec(); | 312 | int ret = dlg.exec(); |
411 | 313 | ||
412 | if ( ret == QDialog::Accepted ) { | 314 | if ( ret == QDialog::Accepted ) { |
413 | create( dlg.profile() ); | 315 | create( dlg.profile() ); |
414 | } | 316 | } |
415 | } | 317 | } |
416 | 318 | ||
417 | void MainWindow::slotRecordScript() { | 319 | void MainWindow::slotRecordScript() { |
418 | if (currentSession()) { | 320 | if (currentSession()) { |
419 | currentSession()->emulationHandler()->startRecording(); | 321 | currentSession()->emulationHandler()->startRecording(); |
420 | m_saveScript->setEnabled(true); | 322 | m_saveScript->setEnabled(true); |
421 | m_recordScript->setEnabled(false); | 323 | m_recordScript->setEnabled(false); |
422 | } | 324 | } |
423 | } | 325 | } |
424 | 326 | ||
425 | void MainWindow::slotSaveScript() { | 327 | void MainWindow::slotSaveScript() { |
426 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { | 328 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { |
427 | QMap<QString, QStringList> map; | 329 | QMap<QString, QStringList> map; |
428 | QStringList text; | 330 | QStringList text; |
429 | text << "text/plain"; | 331 | text << "text/plain"; |
430 | map.insert(tr("Script"), text ); | 332 | map.insert(tr("Script"), text ); |
431 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); | 333 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); |
432 | if (!filename.isEmpty()) { | 334 | if (!filename.isEmpty()) { |
433 | QFileInfo info(filename); | 335 | QFileInfo info(filename); |
434 | if (info.extension(FALSE) != "script") | 336 | if (info.extension(FALSE) != "script") |
435 | filename += ".script"; | 337 | filename += ".script"; |
436 | DocLnk nf; | 338 | DocLnk nf; |
437 | nf.setType("text/plain"); | 339 | nf.setType("text/plain"); |
438 | nf.setFile(filename); | 340 | nf.setFile(filename); |
439 | nf.setName(info.fileName()); | 341 | nf.setName(info.fileName()); |
440 | FileManager fm; | 342 | FileManager fm; |
441 | fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); | 343 | fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); |
442 | currentSession()->emulationHandler()->clearScript(); | 344 | currentSession()->emulationHandler()->clearScript(); |
443 | m_saveScript->setEnabled(false); | 345 | m_saveScript->setEnabled(false); |
444 | m_recordScript->setEnabled(true); | 346 | m_recordScript->setEnabled(true); |
445 | populateScripts(); | 347 | populateScripts(); |
446 | } | 348 | } |
447 | } | 349 | } |
448 | } | 350 | } |
449 | 351 | ||
450 | void MainWindow::slotRunScript(int id) { | 352 | void MainWindow::slotRunScript(int id) { |
451 | if (currentSession()) { | 353 | if (currentSession()) { |
452 | int index = m_scriptsPop->indexOf(id); | 354 | int index = m_scriptsPop->indexOf(id); |
453 | DocLnk *lnk = m_scriptsData.at(index); | 355 | DocLnk *lnk = m_scriptsData.at(index); |
454 | QString filePath = lnk->file(); | 356 | QString filePath = lnk->file(); |
455 | Script script(filePath); | 357 | Script script(filePath); |
456 | currentSession()->emulationHandler()->runScript(&script); | 358 | currentSession()->emulationHandler()->runScript(&script); |
457 | } | 359 | } |
458 | } | 360 | } |
459 | 361 | ||
460 | void MainWindow::slotConnect() { | 362 | void MainWindow::slotConnect() { |
461 | if ( currentSession() ) { | 363 | if ( currentSession() ) { |
462 | bool ret = currentSession()->layer()->open(); | 364 | bool ret = currentSession()->layer()->open(); |
463 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), | 365 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), |
464 | QObject::tr("Failed"), | 366 | QObject::tr("Failed"), |
465 | QObject::tr("Connecting failed for this session.")); | 367 | QObject::tr("Connecting failed for this session.")); |
466 | else { | 368 | else { |
467 | m_connect->setEnabled( false ); | 369 | m_connect->setEnabled( false ); |
468 | m_disconnect->setEnabled( true ); | 370 | m_disconnect->setEnabled( true ); |
469 | 371 | ||
470 | // if it does not support file transfer, disable the menu entry | 372 | // if it does not support file transfer, disable the menu entry |
471 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { | 373 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { |
472 | m_transfer->setEnabled( false ); | 374 | m_transfer->setEnabled( false ); |
473 | } else { | 375 | } else { |
474 | m_transfer->setEnabled( true ); | 376 | m_transfer->setEnabled( true ); |
475 | } | 377 | } |
476 | 378 | ||
477 | m_recordScript->setEnabled( true ); | 379 | m_recordScript->setEnabled( true ); |
478 | m_scripts->setItemEnabled(m_runScript_id, true); | 380 | m_scripts->setItemEnabled(m_runScript_id, true); |
479 | } | 381 | } |
480 | } | 382 | } |
481 | } | 383 | } |
482 | 384 | ||
483 | void MainWindow::slotDisconnect() { | 385 | void MainWindow::slotDisconnect() { |
484 | if ( currentSession() ) { | 386 | if ( currentSession() ) { |
485 | currentSession()->layer()->close(); | 387 | currentSession()->layer()->close(); |
486 | m_connect->setEnabled( true ); | 388 | m_connect->setEnabled( true ); |
487 | m_disconnect->setEnabled( false ); | 389 | m_disconnect->setEnabled( false ); |
488 | m_transfer->setEnabled( false ); | 390 | m_transfer->setEnabled( false ); |
489 | m_recordScript->setEnabled( false); | 391 | m_recordScript->setEnabled( false); |
490 | m_saveScript->setEnabled( false ); | 392 | m_saveScript->setEnabled( false ); |
491 | m_scripts->setItemEnabled(m_runScript_id, false); | 393 | m_scripts->setItemEnabled(m_runScript_id, false); |
492 | } | 394 | } |
493 | } | 395 | } |
494 | 396 | ||
495 | void MainWindow::slotTerminate() { | 397 | void MainWindow::slotTerminate() { |
496 | if ( currentSession() ) | 398 | if ( currentSession() ) |
497 | currentSession()->layer()->close(); | 399 | currentSession()->layer()->close(); |
498 | 400 | ||
499 | slotClose(); | 401 | slotClose(); |
500 | /* FIXME move to the next session */ | 402 | /* FIXME move to the next session */ |
501 | } | 403 | } |
502 | 404 | ||
503 | void MainWindow::slotConfigure() { | 405 | void MainWindow::slotConfigure() { |
504 | ConfigDialog conf( manager()->all(), factory() ); | 406 | ConfigDialog conf( manager()->all(), factory() ); |
505 | conf.showMaximized(); | 407 | conf.showMaximized(); |
506 | 408 | ||
507 | int ret = conf.exec(); | 409 | int ret = conf.exec(); |
508 | 410 | ||
509 | if ( QDialog::Accepted == ret ) { | 411 | if ( QDialog::Accepted == ret ) { |
510 | manager()->setProfiles( conf.list() ); | 412 | manager()->setProfiles( conf.list() ); |
511 | manager()->save(); | 413 | manager()->save(); |
512 | populateProfiles(); | 414 | populateProfiles(); |
513 | } | 415 | } |
514 | } | 416 | } |
515 | /* | 417 | /* |
516 | * we will remove | 418 | * we will remove |
517 | * this window from the tabwidget | 419 | * this window from the tabwidget |
518 | * remove it from the list | 420 | * remove it from the list |
519 | * delete it | 421 | * delete it |
520 | * and set the currentSession() | 422 | * and set the currentSession() |
521 | */ | 423 | */ |
522 | void MainWindow::slotClose() { | 424 | void MainWindow::slotClose() { |
523 | if (!currentSession() ) | 425 | if (!currentSession() ) |
524 | return; | 426 | return; |
525 | 427 | ||
526 | Session* ses = currentSession(); | 428 | Session* ses = currentSession(); |
527 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); | 429 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); |
528 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ | 430 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ |
529 | m_curSession = NULL; | 431 | m_curSession = NULL; |
530 | tabWidget()->remove( /*currentSession()*/ses ); | 432 | tabWidget()->remove( /*currentSession()*/ses ); |
531 | /*it's autodelete */ | 433 | /*it's autodelete */ |
532 | m_sessions.remove( ses ); | 434 | m_sessions.remove( ses ); |
533 | qWarning("after remove!!"); | 435 | qWarning("after remove!!"); |
534 | 436 | ||
535 | if (!currentSession() ) { | 437 | if (!currentSession() ) { |
536 | m_connect->setEnabled( false ); | 438 | m_connect->setEnabled( false ); |
537 | m_disconnect->setEnabled( false ); | 439 | m_disconnect->setEnabled( false ); |
538 | m_terminate->setEnabled( false ); | 440 | m_terminate->setEnabled( false ); |
539 | m_transfer->setEnabled( false ); | 441 | m_transfer->setEnabled( false ); |
540 | m_recordScript->setEnabled( false ); | 442 | m_recordScript->setEnabled( false ); |
541 | m_saveScript->setEnabled( false ); | 443 | m_saveScript->setEnabled( false ); |
542 | m_scripts->setItemEnabled(m_runScript_id, false); | 444 | m_scripts->setItemEnabled(m_runScript_id, false); |
543 | m_fullscreen->setEnabled( false ); | 445 | m_fullscreen->setEnabled( false ); |
544 | m_wrap->setEnabled( false ); | 446 | m_wrap->setEnabled( false ); |
545 | m_closewindow->setEnabled( false ); | 447 | m_closewindow->setEnabled( false ); |
546 | } | 448 | } |
547 | 449 | ||
548 | m_kb->loadDefaults(); | 450 | m_kb->loadDefaults(); |
549 | } | 451 | } |
550 | 452 | ||
551 | /* | 453 | /* |
552 | * We will get the name | 454 | * We will get the name |
553 | * Then the profile | 455 | * Then the profile |
554 | * and then we will make a profile | 456 | * and then we will make a profile |
555 | */ | 457 | */ |
556 | void MainWindow::slotProfile( int id) { | 458 | void MainWindow::slotProfile( int id) { |
557 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); | 459 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); |
558 | create( prof ); | 460 | create( prof ); |
559 | } | 461 | } |
560 | void MainWindow::create( const Profile& prof ) { | 462 | void MainWindow::create( const Profile& prof ) { |
561 | if(m_curSession) | 463 | if(m_curSession) |
562 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); | 464 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); |
563 | 465 | ||
564 | Session *ses = manager()->fromProfile( prof, tabWidget() ); | 466 | Session *ses = manager()->fromProfile( prof, tabWidget() ); |
565 | 467 | ||
566 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) | 468 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) |
567 | { | 469 | { |
568 | QMessageBox::warning(this, | 470 | QMessageBox::warning(this, |
569 | QObject::tr("Session failed"), | 471 | QObject::tr("Session failed"), |
570 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); | 472 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); |
571 | //if(ses) delete ses; | 473 | //if(ses) delete ses; |
572 | return; | 474 | return; |
573 | } | 475 | } |
574 | 476 | ||
575 | m_sessions.append( ses ); | 477 | m_sessions.append( ses ); |
576 | tabWidget()->add( ses ); | 478 | tabWidget()->add( ses ); |
577 | tabWidget()->repaint(); | 479 | tabWidget()->repaint(); |
578 | m_curSession = ses; | 480 | m_curSession = ses; |
579 | 481 | ||
580 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it | 482 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it |
581 | m_connect->setEnabled( true ); | 483 | m_connect->setEnabled( true ); |
582 | m_disconnect->setEnabled( false ); | 484 | m_disconnect->setEnabled( false ); |
583 | m_terminate->setEnabled( true ); | 485 | m_terminate->setEnabled( true ); |
584 | m_fullscreen->setEnabled( true ); | 486 | m_fullscreen->setEnabled( true ); |
585 | m_wrap->setEnabled( true ); | 487 | m_wrap->setEnabled( true ); |
586 | m_closewindow->setEnabled( true ); | 488 | m_closewindow->setEnabled( true ); |
587 | m_transfer->setEnabled( false ); | 489 | m_transfer->setEnabled( false ); |
588 | m_recordScript->setEnabled( false ); | 490 | m_recordScript->setEnabled( false ); |
589 | m_saveScript->setEnabled( false ); | 491 | m_saveScript->setEnabled( false ); |
590 | m_scripts->setItemEnabled(m_runScript_id, false); | 492 | m_scripts->setItemEnabled(m_runScript_id, false); |
591 | 493 | ||
592 | // is io_layer wants direct connection, then autoconnect | 494 | // is io_layer wants direct connection, then autoconnect |
593 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { | 495 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { |
594 | if (prof.autoConnect()) { | 496 | if (prof.autoConnect()) { |
595 | slotConnect(); | 497 | slotConnect(); |
596 | } | 498 | } |
597 | 499 | ||
598 | 500 | ||
599 | QWidget *w = currentSession()->widget(); | 501 | QWidget *w = currentSession()->widget(); |
600 | if(w) w->setFocus(); | 502 | if(w) w->setFocus(); |
601 | 503 | ||
602 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ | 504 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ |
603 | m_isWrapped = true; | 505 | m_isWrapped = true; |
604 | } else { | 506 | } else { |
605 | m_isWrapped = false; | 507 | m_isWrapped = false; |
606 | } | 508 | } |
607 | 509 | ||
608 | m_kb->load(currentSession()->profile()); | 510 | m_kb->load(currentSession()->profile()); |
609 | } | 511 | } |
610 | 512 | ||
611 | void MainWindow::slotTransfer() | 513 | void MainWindow::slotTransfer() |
612 | { | 514 | { |
613 | if ( currentSession() ) { | 515 | if ( currentSession() ) { |
614 | Session *mysession = currentSession(); | 516 | Session *mysession = currentSession(); |
615 | TransferDialog dlg(/*mysession->widgetStack()*/this, this); | 517 | TransferDialog dlg(/*mysession->widgetStack()*/this, this); |
616 | mysession->setTransferDialog(&dlg); | 518 | mysession->setTransferDialog(&dlg); |
617 | //dlg.reparent(mysession->widgetStack(), QPoint(0, 0)); | 519 | //dlg.reparent(mysession->widgetStack(), QPoint(0, 0)); |
618 | //dlg.showMaximized(); | 520 | //dlg.showMaximized(); |
619 | currentSession()->widgetStack()->addWidget(&dlg, -1); | 521 | currentSession()->widgetStack()->addWidget(&dlg, -1); |
620 | dlg.show(); | 522 | dlg.show(); |
621 | //dlg.exec(); | 523 | //dlg.exec(); |
622 | while(dlg.isRunning()) qApp->processEvents(); | 524 | while(dlg.isRunning()) qApp->processEvents(); |
623 | mysession->setTransferDialog(0l); | 525 | mysession->setTransferDialog(0l); |
624 | } | 526 | } |
625 | } | 527 | } |
626 | 528 | ||
627 | 529 | ||
628 | void MainWindow::slotOpenKeb(bool state) { | 530 | void MainWindow::slotOpenKeb(bool state) { |
629 | 531 | ||
630 | if (state) m_keyBar->show(); | 532 | if (state) m_keyBar->show(); |
631 | else m_keyBar->hide(); | 533 | else m_keyBar->hide(); |
632 | 534 | ||
633 | } | 535 | } |
634 | 536 | ||
635 | 537 | ||
636 | void MainWindow::slotOpenButtons( bool state ) { | 538 | void MainWindow::slotOpenButtons( bool state ) { |
637 | 539 | ||
638 | if ( state ) { | 540 | if ( state ) { |
639 | m_buttonBar->show(); | 541 | m_buttonBar->show(); |
640 | } else { | 542 | } else { |
641 | m_buttonBar->hide(); | 543 | m_buttonBar->hide(); |
642 | } | 544 | } |
643 | } | 545 | } |
644 | 546 | ||
645 | 547 | ||
646 | 548 | ||
647 | void MainWindow::slotSessionChanged( Session* ses ) { | 549 | void MainWindow::slotSessionChanged( Session* ses ) { |
648 | qWarning("changed!"); | 550 | qWarning("changed!"); |
649 | 551 | ||
650 | if(m_curSession) | 552 | if(m_curSession) |
651 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); | 553 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); |
652 | if(ses) | 554 | if(ses) |
653 | if(ses->transferDialog()) ses->transferDialog()->show(); | 555 | if(ses->transferDialog()) ses->transferDialog()->show(); |
654 | 556 | ||
655 | if ( ses ) { | 557 | if ( ses ) { |
656 | m_curSession = ses; | 558 | m_curSession = ses; |
657 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); | 559 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); |
658 | if ( m_curSession->layer()->isConnected() ) { | 560 | if ( m_curSession->layer()->isConnected() ) { |
659 | m_connect->setEnabled( false ); | 561 | m_connect->setEnabled( false ); |
660 | m_disconnect->setEnabled( true ); | 562 | m_disconnect->setEnabled( true ); |
661 | m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); | 563 | m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); |
662 | m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); | 564 | m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); |
663 | m_scripts->setItemEnabled(m_runScript_id, true); | 565 | m_scripts->setItemEnabled(m_runScript_id, true); |
664 | } else { | 566 | } else { |
665 | m_connect->setEnabled( true ); | 567 | m_connect->setEnabled( true ); |
666 | m_disconnect->setEnabled( false ); | 568 | m_disconnect->setEnabled( false ); |
667 | m_recordScript->setEnabled( false ); | 569 | m_recordScript->setEnabled( false ); |
668 | m_saveScript->setEnabled( false ); | 570 | m_saveScript->setEnabled( false ); |
669 | m_scripts->setItemEnabled(m_runScript_id, false); | 571 | m_scripts->setItemEnabled(m_runScript_id, false); |
670 | } | 572 | } |
671 | 573 | ||
672 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { | 574 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { |
673 | m_transfer->setEnabled( false ); | 575 | m_transfer->setEnabled( false ); |
674 | } else { | 576 | } else { |
675 | m_transfer->setEnabled( true ); | 577 | m_transfer->setEnabled( true ); |
676 | } | 578 | } |
677 | 579 | ||
678 | QWidget *w = m_curSession->widget(); | 580 | QWidget *w = m_curSession->widget(); |
679 | if(w) w->setFocus(); | 581 | if(w) w->setFocus(); |
680 | 582 | ||
681 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ | 583 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ |
682 | m_isWrapped = true; | 584 | m_isWrapped = true; |
683 | } else { | 585 | } else { |
684 | m_isWrapped = false; | 586 | m_isWrapped = false; |
685 | } | 587 | } |
686 | 588 | ||
687 | m_kb->load(currentSession()->profile()); | 589 | m_kb->load(currentSession()->profile()); |
688 | } | 590 | } |
689 | } | 591 | } |
690 | 592 | ||
691 | void MainWindow::slotWrap() | 593 | void MainWindow::slotWrap() |
692 | { | 594 | { |
693 | if(m_curSession) | 595 | if(m_curSession) |
694 | { | 596 | { |
695 | EmulationHandler *e = m_curSession->emulationHandler(); | 597 | EmulationHandler *e = m_curSession->emulationHandler(); |
696 | if(e) | 598 | if(e) |
697 | { | 599 | { |
698 | if(m_isWrapped) | 600 | if(m_isWrapped) |
699 | { | 601 | { |
700 | e->setWrap(80); | 602 | e->setWrap(80); |
701 | m_isWrapped = false; | 603 | m_isWrapped = false; |
702 | } | 604 | } |
703 | else | 605 | else |
704 | { | 606 | { |
705 | e->setWrap(0); | 607 | e->setWrap(0); |
706 | m_isWrapped = true; | 608 | m_isWrapped = true; |
707 | } | 609 | } |
708 | } | 610 | } |
709 | } | 611 | } |
710 | } | 612 | } |
711 | 613 | ||
712 | void MainWindow::slotFullscreen() { | 614 | void MainWindow::slotFullscreen() { |
713 | 615 | ||
714 | 616 | ||
715 | 617 | ||
716 | if ( m_isFullscreen ) { | 618 | if ( m_isFullscreen ) { |
717 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); | 619 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); |
718 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); | 620 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); |
719 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); | 621 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); |
720 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 622 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
721 | 623 | ||
722 | } else { | 624 | } else { |
723 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); | 625 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); |
724 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); | 626 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); |
725 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop | 627 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop |
726 | , QPoint(0,0), false ); | 628 | , QPoint(0,0), false ); |
727 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); | 629 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); |
728 | ( m_curSession->widgetStack() )->setFocus(); | 630 | ( m_curSession->widgetStack() )->setFocus(); |
729 | ( m_curSession->widgetStack() )->show(); | 631 | ( m_curSession->widgetStack() )->show(); |
730 | 632 | ||
731 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); | 633 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); |
732 | 634 | ||
733 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 635 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
734 | } | 636 | } |
735 | 637 | ||
736 | m_isFullscreen = !m_isFullscreen; | 638 | m_isFullscreen = !m_isFullscreen; |
737 | } | 639 | } |
738 | 640 | ||
739 | 641 | ||
740 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { | 642 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { |
741 | 643 | ||
742 | if ( m_curSession ) { | 644 | if ( m_curSession ) { |
743 | 645 | ||
744 | QEvent::Type state; | 646 | QEvent::Type state; |
745 | 647 | ||
746 | if (pressed) state = QEvent::KeyPress; | 648 | if (pressed) state = QEvent::KeyPress; |
747 | else state = QEvent::KeyRelease; | 649 | else state = QEvent::KeyRelease; |
748 | 650 | ||
749 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); | 651 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); |
750 | 652 | ||
751 | // is this the best way to do this? cant figure out any other way to work | 653 | // is this the best way to do this? cant figure out any other way to work |
752 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); | 654 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); |
753 | ke.ignore(); | 655 | ke.ignore(); |
754 | } | 656 | } |
755 | } | 657 | } |
756 | void MainWindow::slotCopy() { | 658 | void MainWindow::slotCopy() { |
757 | if (!currentSession() ) return; | 659 | if (!currentSession() ) return; |
758 | currentSession()->emulationHandler()->copy(); | 660 | currentSession()->emulationHandler()->copy(); |
759 | } | 661 | } |
760 | void MainWindow::slotPaste() { | 662 | void MainWindow::slotPaste() { |
761 | if (!currentSession() ) return; | 663 | if (!currentSession() ) return; |
762 | currentSession()->emulationHandler()->paste(); | 664 | currentSession()->emulationHandler()->paste(); |
763 | } | 665 | } |
764 | 666 | ||
765 | /* | 667 | /* |
766 | * Save the session | 668 | * Save the session |
767 | */ | 669 | */ |
768 | 670 | ||
769 | void MainWindow::slotSaveSession() { | 671 | void MainWindow::slotSaveSession() { |
770 | if (!currentSession() ) { | 672 | if (!currentSession() ) { |
771 | QMessageBox::information(this, tr("Save Connection"), | 673 | QMessageBox::information(this, tr("Save Connection"), |
772 | tr("<qt>There is no Connection.</qt>"), 1 ); | 674 | tr("<qt>There is no Connection.</qt>"), 1 ); |
773 | return; | 675 | return; |
774 | } | 676 | } |
775 | manager()->add( currentSession()->profile() ); | 677 | manager()->add( currentSession()->profile() ); |
776 | manager()->save(); | 678 | manager()->save(); |
777 | populateProfiles(); | 679 | populateProfiles(); |
778 | } | 680 | } |
779 | void MainWindow::slotSaveHistory() { | 681 | void MainWindow::slotSaveHistory() { |
780 | QMap<QString, QStringList> map; | 682 | QMap<QString, QStringList> map; |
781 | QStringList text; | 683 | QStringList text; |
782 | text << "text/plain"; | 684 | text << "text/plain"; |
783 | map.insert(tr("History"), text ); | 685 | map.insert(tr("History"), text ); |
784 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); | 686 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); |
785 | if (filename.isEmpty() ) return; | 687 | if (filename.isEmpty() ) return; |
786 | 688 | ||
787 | QFileInfo info(filename); | 689 | QFileInfo info(filename); |
788 | 690 | ||
789 | DocLnk nf; | 691 | DocLnk nf; |
790 | nf.setType("text/plain"); | 692 | nf.setType("text/plain"); |
791 | nf.setFile(filename); | 693 | nf.setFile(filename); |
792 | nf.setName(info.fileName()); | 694 | nf.setName(info.fileName()); |
793 | 695 | ||
794 | 696 | ||
795 | QFile file(filename); | 697 | QFile file(filename); |
796 | file.open(IO_WriteOnly ); | 698 | file.open(IO_WriteOnly ); |
797 | QTextStream str(&file ); | 699 | QTextStream str(&file ); |
798 | if ( currentSession() ) | 700 | if ( currentSession() ) |
799 | currentSession()->emulationHandler()->emulation()->streamHistory(&str); | 701 | currentSession()->emulationHandler()->emulation()->streamHistory(&str); |
800 | 702 | ||
801 | file.close(); | 703 | file.close(); |
802 | nf.writeLink(); | 704 | nf.writeLink(); |
803 | } | 705 | } |