author | zecke <zecke> | 2002-10-21 22:37:55 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-21 22:37:55 (UTC) |
commit | d7a4ad19a8493dbb226e7f8355c49dafd1fa9597 (patch) (unidiff) | |
tree | b9a77d8f25face1640a91b9030b93f61085fc2a4 | |
parent | d6a40efdb9d81d39972a1304bd62ac60bb45e996 (diff) | |
download | opie-d7a4ad19a8493dbb226e7f8355c49dafd1fa9597.zip opie-d7a4ad19a8493dbb226e7f8355c49dafd1fa9597.tar.gz opie-d7a4ad19a8493dbb226e7f8355c49dafd1fa9597.tar.bz2 |
one more mimetype for scripts
this makes play nirvana work ;)
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 7ffeca7..89f3516 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -204,207 +204,209 @@ void MainWindow::initUI() { | |||
204 | /* and the keyboard */ | 204 | /* and the keyboard */ |
205 | m_keyBar = new QToolBar(this); | 205 | m_keyBar = new QToolBar(this); |
206 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); | 206 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); |
207 | m_keyBar->setHorizontalStretchable( TRUE ); | 207 | m_keyBar->setHorizontalStretchable( TRUE ); |
208 | m_keyBar->hide(); | 208 | m_keyBar->hide(); |
209 | 209 | ||
210 | m_kb = new FunctionKeyboard(m_keyBar); | 210 | m_kb = new FunctionKeyboard(m_keyBar); |
211 | connect(m_kb, SIGNAL(keyPressed(ushort, ushort, bool, bool, bool)), | 211 | connect(m_kb, SIGNAL(keyPressed(ushort, ushort, bool, bool, bool)), |
212 | this, SLOT(slotKeyReceived(ushort, ushort, bool, bool, bool))); | 212 | this, SLOT(slotKeyReceived(ushort, ushort, bool, bool, bool))); |
213 | 213 | ||
214 | m_buttonBar = new QToolBar( this ); | 214 | m_buttonBar = new QToolBar( this ); |
215 | addToolBar( m_buttonBar, "Buttons", QMainWindow::Top, TRUE ); | 215 | addToolBar( m_buttonBar, "Buttons", QMainWindow::Top, TRUE ); |
216 | m_buttonBar->setHorizontalStretchable( TRUE ); | 216 | m_buttonBar->setHorizontalStretchable( TRUE ); |
217 | m_buttonBar->hide(); | 217 | m_buttonBar->hide(); |
218 | 218 | ||
219 | m_qb = new QuickButton( m_buttonBar ); | 219 | m_qb = new QuickButton( m_buttonBar ); |
220 | connect( m_qb, SIGNAL( keyPressed( ushort, ushort, bool, bool, bool) ), | 220 | connect( m_qb, SIGNAL( keyPressed( ushort, ushort, bool, bool, bool) ), |
221 | this, SLOT( slotKeyReceived( ushort, ushort, bool, bool, bool) ) ); | 221 | this, SLOT( slotKeyReceived( ushort, ushort, bool, bool, bool) ) ); |
222 | 222 | ||
223 | 223 | ||
224 | m_connect->setEnabled( false ); | 224 | m_connect->setEnabled( false ); |
225 | m_disconnect->setEnabled( false ); | 225 | m_disconnect->setEnabled( false ); |
226 | m_terminate->setEnabled( false ); | 226 | m_terminate->setEnabled( false ); |
227 | m_transfer->setEnabled( false ); | 227 | m_transfer->setEnabled( false ); |
228 | m_recordScript->setEnabled( false ); | 228 | m_recordScript->setEnabled( false ); |
229 | m_saveScript->setEnabled( false ); | 229 | m_saveScript->setEnabled( false ); |
230 | m_runScript->setEnabled( false ); | 230 | m_runScript->setEnabled( false ); |
231 | m_fullscreen->setEnabled( false ); | 231 | m_fullscreen->setEnabled( false ); |
232 | m_closewindow->setEnabled( false ); | 232 | m_closewindow->setEnabled( false ); |
233 | 233 | ||
234 | /* | 234 | /* |
235 | * connect to the menu activation | 235 | * connect to the menu activation |
236 | */ | 236 | */ |
237 | connect( m_sessionsPop, SIGNAL(activated( int ) ), | 237 | connect( m_sessionsPop, SIGNAL(activated( int ) ), |
238 | this, SLOT(slotProfile( int ) ) ); | 238 | this, SLOT(slotProfile( int ) ) ); |
239 | 239 | ||
240 | m_consoleWindow = new TabWidget( this, "blah"); | 240 | m_consoleWindow = new TabWidget( this, "blah"); |
241 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), | 241 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), |
242 | this, SLOT(slotSessionChanged(Session*) ) ); | 242 | this, SLOT(slotSessionChanged(Session*) ) ); |
243 | setCentralWidget( m_consoleWindow ); | 243 | setCentralWidget( m_consoleWindow ); |
244 | 244 | ||
245 | } | 245 | } |
246 | 246 | ||
247 | ProfileManager* MainWindow::manager() { | 247 | ProfileManager* MainWindow::manager() { |
248 | return m_manager; | 248 | return m_manager; |
249 | } | 249 | } |
250 | TabWidget* MainWindow::tabWidget() { | 250 | TabWidget* MainWindow::tabWidget() { |
251 | return m_consoleWindow; | 251 | return m_consoleWindow; |
252 | } | 252 | } |
253 | void MainWindow::populateProfiles() { | 253 | void MainWindow::populateProfiles() { |
254 | m_sessionsPop->clear(); | 254 | m_sessionsPop->clear(); |
255 | Profile::ValueList list = manager()->all(); | 255 | Profile::ValueList list = manager()->all(); |
256 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { | 256 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { |
257 | m_sessionsPop->insertItem( (*it).name() ); | 257 | m_sessionsPop->insertItem( (*it).name() ); |
258 | } | 258 | } |
259 | 259 | ||
260 | } | 260 | } |
261 | MainWindow::~MainWindow() { | 261 | MainWindow::~MainWindow() { |
262 | delete m_factory; | 262 | delete m_factory; |
263 | manager()->save(); | 263 | manager()->save(); |
264 | } | 264 | } |
265 | 265 | ||
266 | MetaFactory* MainWindow::factory() { | 266 | MetaFactory* MainWindow::factory() { |
267 | return m_factory; | 267 | return m_factory; |
268 | } | 268 | } |
269 | 269 | ||
270 | Session* MainWindow::currentSession() { | 270 | Session* MainWindow::currentSession() { |
271 | return m_curSession; | 271 | return m_curSession; |
272 | } | 272 | } |
273 | 273 | ||
274 | QList<Session> MainWindow::sessions() { | 274 | QList<Session> MainWindow::sessions() { |
275 | return m_sessions; | 275 | return m_sessions; |
276 | } | 276 | } |
277 | 277 | ||
278 | void MainWindow::slotNew() { | 278 | void MainWindow::slotNew() { |
279 | ProfileEditorDialog dlg(factory() ); | 279 | ProfileEditorDialog dlg(factory() ); |
280 | dlg.showMaximized(); | 280 | dlg.showMaximized(); |
281 | int ret = dlg.exec(); | 281 | int ret = dlg.exec(); |
282 | 282 | ||
283 | if ( ret == QDialog::Accepted ) { | 283 | if ( ret == QDialog::Accepted ) { |
284 | create( dlg.profile() ); | 284 | create( dlg.profile() ); |
285 | } | 285 | } |
286 | } | 286 | } |
287 | 287 | ||
288 | void MainWindow::slotRecordScript() { | 288 | void MainWindow::slotRecordScript() { |
289 | if (currentSession()) { | 289 | if (currentSession()) { |
290 | currentSession()->emulationHandler()->startRecording(); | 290 | currentSession()->emulationHandler()->startRecording(); |
291 | } | 291 | } |
292 | } | 292 | } |
293 | 293 | ||
294 | void MainWindow::slotSaveScript() { | 294 | void MainWindow::slotSaveScript() { |
295 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { | 295 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { |
296 | MimeTypes types; | 296 | MimeTypes types; |
297 | QStringList script; | 297 | QStringList script; |
298 | script << "text/plain"; | 298 | script << "text/plain"; |
299 | script << "text/all"; | 299 | script << "text/all"; |
300 | script << "application/octet-stream"; | ||
300 | types.insert("Script", script); | 301 | types.insert("Script", script); |
301 | QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); | 302 | QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); |
302 | if (!filename.isEmpty()) { | 303 | if (!filename.isEmpty()) { |
303 | currentSession()->emulationHandler()->script()->saveTo(filename); | 304 | currentSession()->emulationHandler()->script()->saveTo(filename); |
304 | currentSession()->emulationHandler()->clearScript(); | 305 | currentSession()->emulationHandler()->clearScript(); |
305 | } | 306 | } |
306 | } | 307 | } |
307 | } | 308 | } |
308 | 309 | ||
309 | void MainWindow::slotRunScript() { | 310 | void MainWindow::slotRunScript() { |
310 | if (currentSession()) { | 311 | if (currentSession()) { |
311 | MimeTypes types; | 312 | MimeTypes types; |
312 | QStringList script; | 313 | QStringList script; |
313 | script << "text/plain"; | 314 | script << "text/plain"; |
314 | script << "text/all"; | 315 | script << "text/all"; |
316 | script << "application/octet-stream"; | ||
315 | types.insert("Script", script); | 317 | types.insert("Script", script); |
316 | QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); | 318 | QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); |
317 | if (!filename.isEmpty()) { | 319 | if (!filename.isEmpty()) { |
318 | Script script(DocLnk(filename).file()); | 320 | Script script(DocLnk(filename).file()); |
319 | currentSession()->emulationHandler()->runScript(&script); | 321 | currentSession()->emulationHandler()->runScript(&script); |
320 | } | 322 | } |
321 | } | 323 | } |
322 | } | 324 | } |
323 | 325 | ||
324 | void MainWindow::slotConnect() { | 326 | void MainWindow::slotConnect() { |
325 | if ( currentSession() ) { | 327 | if ( currentSession() ) { |
326 | bool ret = currentSession()->layer()->open(); | 328 | bool ret = currentSession()->layer()->open(); |
327 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), | 329 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), |
328 | QObject::tr("Failed"), | 330 | QObject::tr("Failed"), |
329 | QObject::tr("Connecting failed for this session.")); | 331 | QObject::tr("Connecting failed for this session.")); |
330 | else { | 332 | else { |
331 | m_connect->setEnabled( false ); | 333 | m_connect->setEnabled( false ); |
332 | m_disconnect->setEnabled( true ); | 334 | m_disconnect->setEnabled( true ); |
333 | } | 335 | } |
334 | } | 336 | } |
335 | } | 337 | } |
336 | 338 | ||
337 | void MainWindow::slotDisconnect() { | 339 | void MainWindow::slotDisconnect() { |
338 | if ( currentSession() ) { | 340 | if ( currentSession() ) { |
339 | currentSession()->layer()->close(); | 341 | currentSession()->layer()->close(); |
340 | m_connect->setEnabled( true ); | 342 | m_connect->setEnabled( true ); |
341 | m_disconnect->setEnabled( false ); | 343 | m_disconnect->setEnabled( false ); |
342 | } | 344 | } |
343 | } | 345 | } |
344 | 346 | ||
345 | void MainWindow::slotTerminate() { | 347 | void MainWindow::slotTerminate() { |
346 | if ( currentSession() ) | 348 | if ( currentSession() ) |
347 | currentSession()->layer()->close(); | 349 | currentSession()->layer()->close(); |
348 | 350 | ||
349 | slotClose(); | 351 | slotClose(); |
350 | /* FIXME move to the next session */ | 352 | /* FIXME move to the next session */ |
351 | } | 353 | } |
352 | 354 | ||
353 | void MainWindow::slotConfigure() { | 355 | void MainWindow::slotConfigure() { |
354 | ConfigDialog conf( manager()->all(), factory() ); | 356 | ConfigDialog conf( manager()->all(), factory() ); |
355 | conf.showMaximized(); | 357 | conf.showMaximized(); |
356 | 358 | ||
357 | int ret = conf.exec(); | 359 | int ret = conf.exec(); |
358 | 360 | ||
359 | if ( QDialog::Accepted == ret ) { | 361 | if ( QDialog::Accepted == ret ) { |
360 | manager()->setProfiles( conf.list() ); | 362 | manager()->setProfiles( conf.list() ); |
361 | manager()->save(); | 363 | manager()->save(); |
362 | populateProfiles(); | 364 | populateProfiles(); |
363 | } | 365 | } |
364 | } | 366 | } |
365 | /* | 367 | /* |
366 | * we will remove | 368 | * we will remove |
367 | * this window from the tabwidget | 369 | * this window from the tabwidget |
368 | * remove it from the list | 370 | * remove it from the list |
369 | * delete it | 371 | * delete it |
370 | * and set the currentSession() | 372 | * and set the currentSession() |
371 | */ | 373 | */ |
372 | void MainWindow::slotClose() { | 374 | void MainWindow::slotClose() { |
373 | if (!currentSession() ) | 375 | if (!currentSession() ) |
374 | return; | 376 | return; |
375 | 377 | ||
376 | Session* ses = currentSession(); | 378 | Session* ses = currentSession(); |
377 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); | 379 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); |
378 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ | 380 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ |
379 | m_curSession = NULL; | 381 | m_curSession = NULL; |
380 | tabWidget()->remove( /*currentSession()*/ses ); | 382 | tabWidget()->remove( /*currentSession()*/ses ); |
381 | /*it's autodelete */ | 383 | /*it's autodelete */ |
382 | m_sessions.remove( ses ); | 384 | m_sessions.remove( ses ); |
383 | qWarning("after remove!!"); | 385 | qWarning("after remove!!"); |
384 | 386 | ||
385 | if (!currentSession() ) { | 387 | if (!currentSession() ) { |
386 | m_connect->setEnabled( false ); | 388 | m_connect->setEnabled( false ); |
387 | m_disconnect->setEnabled( false ); | 389 | m_disconnect->setEnabled( false ); |
388 | m_terminate->setEnabled( false ); | 390 | m_terminate->setEnabled( false ); |
389 | m_transfer->setEnabled( false ); | 391 | m_transfer->setEnabled( false ); |
390 | m_recordScript->setEnabled( false ); | 392 | m_recordScript->setEnabled( false ); |
391 | m_saveScript->setEnabled( false ); | 393 | m_saveScript->setEnabled( false ); |
392 | m_runScript->setEnabled( false ); | 394 | m_runScript->setEnabled( false ); |
393 | m_fullscreen->setEnabled( false ); | 395 | m_fullscreen->setEnabled( false ); |
394 | m_closewindow->setEnabled( false ); | 396 | m_closewindow->setEnabled( false ); |
395 | } | 397 | } |
396 | } | 398 | } |
397 | 399 | ||
398 | /* | 400 | /* |
399 | * We will get the name | 401 | * We will get the name |
400 | * Then the profile | 402 | * Then the profile |
401 | * and then we will make a profile | 403 | * and then we will make a profile |
402 | */ | 404 | */ |
403 | void MainWindow::slotProfile( int id) { | 405 | void MainWindow::slotProfile( int id) { |
404 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); | 406 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); |
405 | create( prof ); | 407 | create( prof ); |
406 | } | 408 | } |
407 | void MainWindow::create( const Profile& prof ) { | 409 | void MainWindow::create( const Profile& prof ) { |
408 | Session *ses = manager()->fromProfile( prof, tabWidget() ); | 410 | Session *ses = manager()->fromProfile( prof, tabWidget() ); |
409 | 411 | ||
410 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) | 412 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) |