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