author | hash <hash> | 2002-10-24 17:39:47 (UTC) |
---|---|---|
committer | hash <hash> | 2002-10-24 17:39:47 (UTC) |
commit | b01703c4b1de7006c88aa814ca00472b966b2464 (patch) (unidiff) | |
tree | 9d0f4e708646ddbf1a0198f1ac2dd4b67e2c45fa /noncore/apps | |
parent | 1364899f2b250d1605e1a49cb7c65ce950c57fda (diff) | |
download | opie-b01703c4b1de7006c88aa814ca00472b966b2464.zip opie-b01703c4b1de7006c88aa814ca00472b966b2464.tar.gz opie-b01703c4b1de7006c88aa814ca00472b966b2464.tar.bz2 |
i think it loads according to the session properly now
-rw-r--r-- | noncore/apps/opie-console/function_keyboard.cpp | 43 | ||||
-rw-r--r-- | noncore/apps/opie-console/function_keyboard.h | 7 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 6 |
3 files changed, 48 insertions, 8 deletions
diff --git a/noncore/apps/opie-console/function_keyboard.cpp b/noncore/apps/opie-console/function_keyboard.cpp index 3da8d61..ce65052 100644 --- a/noncore/apps/opie-console/function_keyboard.cpp +++ b/noncore/apps/opie-console/function_keyboard.cpp | |||
@@ -46,32 +46,68 @@ FunctionKeyboard::FunctionKeyboard(QWidget *parent) : | |||
46 | */ | 46 | */ |
47 | if (keys.isEmpty()) loadDefaults(); | 47 | if (keys.isEmpty()) loadDefaults(); |
48 | 48 | ||
49 | 49 | ||
50 | 50 | ||
51 | } | 51 | } |
52 | 52 | ||
53 | FunctionKeyboard::~FunctionKeyboard() {} | 53 | FunctionKeyboard::~FunctionKeyboard() {} |
54 | 54 | ||
55 | void FunctionKeyboard::changeRows(int r) { | 55 | void FunctionKeyboard::changeRows(int r) { |
56 | 56 | ||
57 | numRows = r; | 57 | numRows = r; |
58 | repaint(false); | 58 | |
59 | // have to do this so the whole thing gets redrawn | ||
60 | hide(); show(); | ||
59 | } | 61 | } |
60 | void FunctionKeyboard::changeCols(int c) { | 62 | void FunctionKeyboard::changeCols(int c) { |
61 | 63 | ||
62 | numCols = c; | 64 | numCols = c; |
63 | keyWidth = (double)width()/numCols; // have to reset this thing too | 65 | keyWidth = (double)width()/numCols; // have to reset this thing too |
64 | repaint(false); | 66 | repaint(false); |
65 | } | 67 | } |
68 | void FunctionKeyboard::load (const Profile& prof) { | ||
69 | |||
70 | keys.clear(); | ||
71 | |||
72 | numRows = prof.readNumEntry("keb_rows", 2); | ||
73 | numCols = prof.readNumEntry("keb_cols", 10); | ||
74 | keyWidth = (double)width()/numCols; // have to reset this thing too | ||
75 | |||
76 | /* load all the keys to the keyboard */ | ||
77 | for (ushort i = 0; i <= numRows - 1; i++) | ||
78 | for (ushort j = 0; j <= numCols - 1; j++) { | ||
79 | |||
80 | QString h = "r" + QString::number(i) + "c" + QString::number(j); | ||
81 | QString values = prof.readEntry("keb_" + h); | ||
82 | |||
83 | if (!values.isEmpty()) { | ||
84 | |||
85 | QStringList l = QStringList::split(QChar('|'), values, TRUE); | ||
86 | keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt()); | ||
87 | |||
88 | // load pixmap if used | ||
89 | if (!l[1].isEmpty()) { | ||
90 | |||
91 | keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) ); | ||
92 | } | ||
93 | } | ||
94 | } | ||
95 | |||
96 | if (keys.isEmpty()) loadDefaults(); | ||
97 | |||
98 | hide(); | ||
99 | show(); | ||
100 | |||
101 | } | ||
66 | 102 | ||
67 | void FunctionKeyboard::paintEvent(QPaintEvent *e) { | 103 | void FunctionKeyboard::paintEvent(QPaintEvent *e) { |
68 | 104 | ||
69 | QPainter p(this); | 105 | QPainter p(this); |
70 | p.setClipRect(e->rect()); | 106 | p.setClipRect(e->rect()); |
71 | p.fillRect(0, 0, width(), height(), QColor(255,255,255)); | 107 | p.fillRect(0, 0, width(), height(), QColor(255,255,255)); |
72 | 108 | ||
73 | p.setPen(QColor(0,0,0)); | 109 | p.setPen(QColor(0,0,0)); |
74 | 110 | ||
75 | /* those decimals do count! becomes short if use plain int */ | 111 | /* those decimals do count! becomes short if use plain int */ |
76 | for (double i = 0; i <= width(); i += keyWidth) { | 112 | for (double i = 0; i <= width(); i += keyWidth) { |
77 | 113 | ||
@@ -264,24 +300,27 @@ FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* par | |||
264 | connect (m_uniValues, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeUnicode(const QString&))); | 300 | connect (m_uniValues, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeUnicode(const QString&))); |
265 | 301 | ||
266 | QVBoxLayout *root = new QVBoxLayout(this, 2); | 302 | QVBoxLayout *root = new QVBoxLayout(this, 2); |
267 | root->addWidget(kb); | 303 | root->addWidget(kb); |
268 | root->addWidget(dimentions); | 304 | root->addWidget(dimentions); |
269 | root->addWidget(editKey); | 305 | root->addWidget(editKey); |
270 | } | 306 | } |
271 | FunctionKeyboardConfig::~FunctionKeyboardConfig() { | 307 | FunctionKeyboardConfig::~FunctionKeyboardConfig() { |
272 | 308 | ||
273 | } | 309 | } |
274 | void FunctionKeyboardConfig::load (const Profile& prof) { | 310 | void FunctionKeyboardConfig::load (const Profile& prof) { |
275 | 311 | ||
312 | kb->keys.clear(); | ||
313 | kb->loadDefaults(); | ||
314 | |||
276 | m_rowBox->setValue(prof.readNumEntry("keb_rows", 2)); | 315 | m_rowBox->setValue(prof.readNumEntry("keb_rows", 2)); |
277 | m_colBox->setValue(prof.readNumEntry("keb_cols", 10)); | 316 | m_colBox->setValue(prof.readNumEntry("keb_cols", 10)); |
278 | 317 | ||
279 | /* load all the keys to the keyboard */ | 318 | /* load all the keys to the keyboard */ |
280 | for (int i = 0; i <= m_rowBox->value() -1; i++) | 319 | for (int i = 0; i <= m_rowBox->value() -1; i++) |
281 | for (int j = 0; j <= m_colBox->value() -1; j++) { | 320 | for (int j = 0; j <= m_colBox->value() -1; j++) { |
282 | 321 | ||
283 | QString h = "r" + QString::number(i) + "c" + QString::number(j); | 322 | QString h = "r" + QString::number(i) + "c" + QString::number(j); |
284 | QString values = prof.readEntry("keb_" + h); | 323 | QString values = prof.readEntry("keb_" + h); |
285 | 324 | ||
286 | if (!values.isEmpty()) { | 325 | if (!values.isEmpty()) { |
287 | 326 | ||
@@ -311,26 +350,24 @@ void FunctionKeyboardConfig::save (Profile& prof) { | |||
311 | + QString::number(k.qcode) + "|" | 350 | + QString::number(k.qcode) + "|" |
312 | + QString::number(k.unicode); | 351 | + QString::number(k.unicode); |
313 | 352 | ||
314 | prof.writeEntry("keb_" + it.key(), entry); | 353 | prof.writeEntry("keb_" + it.key(), entry); |
315 | 354 | ||
316 | } | 355 | } |
317 | 356 | ||
318 | } | 357 | } |
319 | void FunctionKeyboardConfig::slotChangeRows(int r) { | 358 | void FunctionKeyboardConfig::slotChangeRows(int r) { |
320 | 359 | ||
321 | kb->changeRows(r); | 360 | kb->changeRows(r); |
322 | 361 | ||
323 | // have to do this so the whole thing gets redrawn | ||
324 | kb->hide(); kb->show(); | ||
325 | } | 362 | } |
326 | void FunctionKeyboardConfig::slotChangeCols(int c) { | 363 | void FunctionKeyboardConfig::slotChangeCols(int c) { |
327 | 364 | ||
328 | kb->changeCols(c); | 365 | kb->changeCols(c); |
329 | } | 366 | } |
330 | void FunctionKeyboardConfig::slotKeyPressed(FKey k, ushort r, ushort c, bool pressed) { | 367 | void FunctionKeyboardConfig::slotKeyPressed(FKey k, ushort r, ushort c, bool pressed) { |
331 | 368 | ||
332 | if (!pressed) return; | 369 | if (!pressed) return; |
333 | 370 | ||
334 | selectedHandle = "r" + QString::number(r) + | 371 | selectedHandle = "r" + QString::number(r) + |
335 | "c" + QString::number(c); | 372 | "c" + QString::number(c); |
336 | selectedRow = r; | 373 | selectedRow = r; |
diff --git a/noncore/apps/opie-console/function_keyboard.h b/noncore/apps/opie-console/function_keyboard.h index 80d9f29..a60ff4b 100644 --- a/noncore/apps/opie-console/function_keyboard.h +++ b/noncore/apps/opie-console/function_keyboard.h | |||
@@ -36,41 +36,38 @@ struct FKey { | |||
36 | class FunctionKeyboard : public QFrame { | 36 | class FunctionKeyboard : public QFrame { |
37 | Q_OBJECT | 37 | Q_OBJECT |
38 | 38 | ||
39 | public: | 39 | public: |
40 | FunctionKeyboard(QWidget *parent = 0); | 40 | FunctionKeyboard(QWidget *parent = 0); |
41 | ~FunctionKeyboard(); | 41 | ~FunctionKeyboard(); |
42 | 42 | ||
43 | friend class FunctionKeyboardConfig; | 43 | friend class FunctionKeyboardConfig; |
44 | 44 | ||
45 | void changeRows(int); | 45 | void changeRows(int); |
46 | void changeCols(int); | 46 | void changeCols(int); |
47 | 47 | ||
48 | //Key getKey(int, int); | 48 | void load(const Profile &); |
49 | void loadDefaults(); | ||
49 | 50 | ||
50 | void paintEvent(QPaintEvent *); | 51 | void paintEvent(QPaintEvent *); |
51 | void paintKey(uint, uint); | 52 | void paintKey(uint, uint); |
52 | void mousePressEvent(QMouseEvent*); | 53 | void mousePressEvent(QMouseEvent*); |
53 | void mouseReleaseEvent(QMouseEvent*); | 54 | void mouseReleaseEvent(QMouseEvent*); |
54 | void resizeEvent(QResizeEvent*); | 55 | void resizeEvent(QResizeEvent*); |
55 | QSize sizeHint() const; | 56 | QSize sizeHint() const; |
56 | 57 | ||
57 | signals: | 58 | signals: |
58 | 59 | ||
59 | void keyPressed(FKey, ushort, ushort, bool); | 60 | void keyPressed(FKey, ushort, ushort, bool); |
60 | 61 | ||
61 | private: | ||
62 | |||
63 | void loadDefaults(); | ||
64 | |||
65 | 62 | ||
66 | private: | 63 | private: |
67 | 64 | ||
68 | // thie key for the map is the row/col | 65 | // thie key for the map is the row/col |
69 | QMap<QString, FKey> keys; | 66 | QMap<QString, FKey> keys; |
70 | 67 | ||
71 | uint numRows; | 68 | uint numRows; |
72 | int test; | 69 | int test; |
73 | uint numCols; | 70 | uint numCols; |
74 | uint keyHeight; | 71 | uint keyHeight; |
75 | double keyWidth; // decimal point matters! | 72 | double keyWidth; // decimal point matters! |
76 | 73 | ||
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index b177fa5..745efaf 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -398,24 +398,26 @@ void MainWindow::slotClose() { | |||
398 | 398 | ||
399 | if (!currentSession() ) { | 399 | if (!currentSession() ) { |
400 | m_connect->setEnabled( false ); | 400 | m_connect->setEnabled( false ); |
401 | m_disconnect->setEnabled( false ); | 401 | m_disconnect->setEnabled( false ); |
402 | m_terminate->setEnabled( false ); | 402 | m_terminate->setEnabled( false ); |
403 | m_transfer->setEnabled( false ); | 403 | m_transfer->setEnabled( false ); |
404 | m_recordScript->setEnabled( false ); | 404 | m_recordScript->setEnabled( false ); |
405 | m_saveScript->setEnabled( false ); | 405 | m_saveScript->setEnabled( false ); |
406 | m_runScript->setEnabled( false ); | 406 | m_runScript->setEnabled( false ); |
407 | m_fullscreen->setEnabled( false ); | 407 | m_fullscreen->setEnabled( false ); |
408 | m_closewindow->setEnabled( false ); | 408 | m_closewindow->setEnabled( false ); |
409 | } | 409 | } |
410 | |||
411 | m_kb->loadDefaults(); | ||
410 | } | 412 | } |
411 | 413 | ||
412 | /* | 414 | /* |
413 | * We will get the name | 415 | * We will get the name |
414 | * Then the profile | 416 | * Then the profile |
415 | * and then we will make a profile | 417 | * and then we will make a profile |
416 | */ | 418 | */ |
417 | void MainWindow::slotProfile( int id) { | 419 | void MainWindow::slotProfile( int id) { |
418 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); | 420 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); |
419 | create( prof ); | 421 | create( prof ); |
420 | } | 422 | } |
421 | void MainWindow::create( const Profile& prof ) { | 423 | void MainWindow::create( const Profile& prof ) { |
@@ -447,24 +449,26 @@ void MainWindow::create( const Profile& prof ) { | |||
447 | m_runScript->setEnabled( false ); | 449 | m_runScript->setEnabled( false ); |
448 | 450 | ||
449 | // is io_layer wants direct connection, then autoconnect | 451 | // is io_layer wants direct connection, then autoconnect |
450 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { | 452 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { |
451 | if (prof.autoConnect()) { | 453 | if (prof.autoConnect()) { |
452 | slotConnect(); | 454 | slotConnect(); |
453 | } | 455 | } |
454 | 456 | ||
455 | 457 | ||
456 | 458 | ||
457 | QWidget *w = currentSession()->widget(); | 459 | QWidget *w = currentSession()->widget(); |
458 | if(w) w->setFocus(); | 460 | if(w) w->setFocus(); |
461 | |||
462 | m_kb->load(currentSession()->profile()); | ||
459 | } | 463 | } |
460 | 464 | ||
461 | void MainWindow::slotTransfer() | 465 | void MainWindow::slotTransfer() |
462 | { | 466 | { |
463 | if ( currentSession() ) { | 467 | if ( currentSession() ) { |
464 | TransferDialog dlg(currentSession()->widgetStack(), this); | 468 | TransferDialog dlg(currentSession()->widgetStack(), this); |
465 | dlg.showMaximized(); | 469 | dlg.showMaximized(); |
466 | //currentSession()->widgetStack()->add(dlg); | 470 | //currentSession()->widgetStack()->add(dlg); |
467 | dlg.exec(); | 471 | dlg.exec(); |
468 | } | 472 | } |
469 | } | 473 | } |
470 | 474 | ||
@@ -510,24 +514,26 @@ void MainWindow::slotSessionChanged( Session* ses ) { | |||
510 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { | 514 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { |
511 | m_transfer->setEnabled( false ); | 515 | m_transfer->setEnabled( false ); |
512 | } else { | 516 | } else { |
513 | m_transfer->setEnabled( true ); | 517 | m_transfer->setEnabled( true ); |
514 | } | 518 | } |
515 | 519 | ||
516 | 520 | ||
517 | 521 | ||
518 | 522 | ||
519 | 523 | ||
520 | QWidget *w = m_curSession->widget(); | 524 | QWidget *w = m_curSession->widget(); |
521 | if(w) w->setFocus(); | 525 | if(w) w->setFocus(); |
526 | |||
527 | m_kb->load(currentSession()->profile()); | ||
522 | } | 528 | } |
523 | } | 529 | } |
524 | 530 | ||
525 | void MainWindow::slotFullscreen() { | 531 | void MainWindow::slotFullscreen() { |
526 | 532 | ||
527 | 533 | ||
528 | 534 | ||
529 | if ( m_isFullscreen ) { | 535 | if ( m_isFullscreen ) { |
530 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); | 536 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); |
531 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); | 537 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); |
532 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); | 538 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); |
533 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 539 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |