-rw-r--r-- | noncore/apps/opie-console/function_keyboard.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/noncore/apps/opie-console/function_keyboard.cpp b/noncore/apps/opie-console/function_keyboard.cpp index fa11701..3da8d61 100644 --- a/noncore/apps/opie-console/function_keyboard.cpp +++ b/noncore/apps/opie-console/function_keyboard.cpp | |||
@@ -39,156 +39,156 @@ FunctionKeyboard::FunctionKeyboard(QWidget *parent) : | |||
39 | keys.insert( | 39 | keys.insert( |
40 | 40 | ||
41 | handle, | 41 | handle, |
42 | FKey (value_list[0], value_list[1], value_list[2].toUShort(), value_list[3].toUShort()) | 42 | FKey (value_list[0], value_list[1], value_list[2].toUShort(), value_list[3].toUShort()) |
43 | ); | 43 | ); |
44 | } | 44 | } |
45 | //qWarning("loaded %d keys", keys.count()); | 45 | //qWarning("loaded %d keys", keys.count()); |
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 | repaint(false); |
59 | } | 59 | } |
60 | void FunctionKeyboard::changeCols(int c) { | 60 | void FunctionKeyboard::changeCols(int c) { |
61 | 61 | ||
62 | numCols = c; | 62 | numCols = c; |
63 | keyWidth = (double)width()/numCols; // have to reset this thing too | 63 | keyWidth = (double)width()/numCols; // have to reset this thing too |
64 | repaint(false); | 64 | repaint(false); |
65 | } | 65 | } |
66 | 66 | ||
67 | void FunctionKeyboard::paintEvent(QPaintEvent *e) { | 67 | void FunctionKeyboard::paintEvent(QPaintEvent *e) { |
68 | 68 | ||
69 | QPainter p(this); | 69 | QPainter p(this); |
70 | p.setClipRect(e->rect()); | 70 | p.setClipRect(e->rect()); |
71 | p.fillRect(0, 0, width(), height(), QColor(255,255,255)); | 71 | p.fillRect(0, 0, width(), height(), QColor(255,255,255)); |
72 | 72 | ||
73 | p.setPen(QColor(0,0,0)); | 73 | p.setPen(QColor(0,0,0)); |
74 | 74 | ||
75 | /* those decimals do count! becomes short if use plain int */ | 75 | /* those decimals do count! becomes short if use plain int */ |
76 | for (double i = 0; i <= width(); i += keyWidth) { | 76 | for (double i = 0; i <= width(); i += keyWidth) { |
77 | 77 | ||
78 | p.drawLine((int)i, 0, (int)i, height()); | 78 | p.drawLine((int)i, 0, (int)i, height()); |
79 | } | 79 | } |
80 | 80 | ||
81 | // sometimes the last line doesnt get drawn | 81 | // sometimes the last line doesnt get drawn |
82 | p.drawLine(width() -1, 0, width() -1, height()); | 82 | p.drawLine(width() -1, 0, width() -1, height()); |
83 | 83 | ||
84 | for (int i = 0; i <= height(); i += keyHeight) { | 84 | for (int i = 0; i <= height(); i += keyHeight) { |
85 | 85 | ||
86 | p.drawLine(0, i, width(), i); | 86 | p.drawLine(0, i, width(), i); |
87 | } | 87 | } |
88 | 88 | ||
89 | for (uint r = 0; r < numRows; r++) { | 89 | for (uint r = 0; r < numRows; r++) { |
90 | for (uint c = 0; c < numCols; c++) { | 90 | for (uint c = 0; c < numCols; c++) { |
91 | 91 | ||
92 | QString handle = "r" + QString::number(r) + "c" + QString::number(c); | 92 | QString handle = "r" + QString::number(r) + "c" + QString::number(c); |
93 | if (keys.contains(handle)) { | 93 | if (keys.contains(handle)) { |
94 | 94 | ||
95 | if (keys[handle].pixFile.isEmpty()) | 95 | if (keys[handle].pixFile.isEmpty()) |
96 | p.drawText( c * keyWidth + 1, r * keyHeight + 1, | 96 | p.drawText( c * keyWidth + 1, r * keyHeight + 1, |
97 | keyWidth, keyHeight, | 97 | keyWidth, keyHeight, |
98 | Qt::AlignHCenter | Qt::AlignVCenter, | 98 | Qt::AlignHCenter | Qt::AlignVCenter, |
99 | keys[handle].label | 99 | keys[handle].label |
100 | ); | 100 | ); |
101 | else { | 101 | else { |
102 | 102 | ||
103 | ushort centerX = c *keyWidth + (keyWidth - keys[handle].pix->width()) / 2; | 103 | ushort centerX = (ushort)(c *keyWidth) + (ushort)(keyWidth - keys[handle].pix->width()) / 2; |
104 | ushort centerY = r * keyHeight + (keyHeight - keys[handle].pix->height()) / 2; | 104 | ushort centerY = r * keyHeight + (keyHeight - keys[handle].pix->height()) / 2; |
105 | p.drawPixmap(centerX, centerY, *keys[handle].pix); | 105 | p.drawPixmap(centerX, centerY, *keys[handle].pix); |
106 | } | 106 | } |
107 | } | 107 | } |
108 | } | 108 | } |
109 | } | 109 | } |
110 | } | 110 | } |
111 | 111 | ||
112 | void FunctionKeyboard::paintKey(uint row, uint col) { | 112 | void FunctionKeyboard::paintKey(uint row, uint col) { |
113 | 113 | ||
114 | QPainter p(this); | 114 | QPainter p(this); |
115 | 115 | ||
116 | p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1), | 116 | p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1), |
117 | QPoint((col + 1) * keyWidth - 1, row * keyHeight + keyHeight- 1)), | 117 | QPoint((col + 1) * keyWidth - 1, row * keyHeight + keyHeight- 1)), |
118 | (pressedRow != -1 && pressedCol != -1 ) ? QColor(97,119,155) : QColor(255,255,255)); | 118 | (pressedRow != -1 && pressedCol != -1 ) ? QColor(97,119,155) : QColor(255,255,255)); |
119 | 119 | ||
120 | QString handle ("r" + QString::number(row) + "c" + QString::number(col)); | 120 | QString handle ("r" + QString::number(row) + "c" + QString::number(col)); |
121 | if (keys[handle].pixFile.isEmpty()) | 121 | if (keys[handle].pixFile.isEmpty()) |
122 | p.drawText( | 122 | p.drawText( |
123 | col * keyWidth + 1, row * keyHeight + 1, | 123 | col * keyWidth + 1, row * keyHeight + 1, |
124 | keyWidth, keyHeight, | 124 | keyWidth, keyHeight, |
125 | Qt::AlignHCenter | Qt::AlignVCenter, | 125 | Qt::AlignHCenter | Qt::AlignVCenter, |
126 | keys[handle].label | 126 | keys[handle].label |
127 | ); | 127 | ); |
128 | else { | 128 | else { |
129 | 129 | ||
130 | ushort centerX = col *keyWidth + (keyWidth - keys[handle].pix->width()) / 2; | 130 | ushort centerX = (ushort)(col *keyWidth) + (ushort)(keyWidth - keys[handle].pix->width()) / 2; |
131 | ushort centerY = row * keyHeight + (keyHeight - keys[handle].pix->height()) / 2; | 131 | ushort centerY = row * keyHeight + (keyHeight - keys[handle].pix->height()) / 2; |
132 | p.drawPixmap(centerX, centerY, *keys[handle].pix); | 132 | p.drawPixmap(centerX, centerY, *keys[handle].pix); |
133 | } | 133 | } |
134 | 134 | ||
135 | if (col == numCols - 1) { | 135 | if (col == numCols - 1) { |
136 | 136 | ||
137 | // sometimes it doesnt draw the last line | 137 | // sometimes it doesnt draw the last line |
138 | 138 | ||
139 | p.drawLine((col+1) * keyWidth -1, row * keyHeight, | 139 | p.drawLine((col+1) * keyWidth -1, row * keyHeight, |
140 | (col+1) * keyWidth -1, (row + 1) * keyHeight | 140 | (col+1) * keyWidth -1, (row + 1) * keyHeight |
141 | ); | 141 | ); |
142 | } | 142 | } |
143 | 143 | ||
144 | } | 144 | } |
145 | 145 | ||
146 | void FunctionKeyboard::mousePressEvent(QMouseEvent *e) { | 146 | void FunctionKeyboard::mousePressEvent(QMouseEvent *e) { |
147 | 147 | ||
148 | pressedRow = e->y() / keyHeight; | 148 | pressedRow = e->y() / keyHeight; |
149 | pressedCol = (int) (e->x() / keyWidth); | 149 | pressedCol = (int) (e->x() / keyWidth); |
150 | 150 | ||
151 | paintKey(pressedRow, pressedCol); | 151 | paintKey(pressedRow, pressedCol); |
152 | 152 | ||
153 | // emit that sucker! | 153 | // emit that sucker! |
154 | FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)]; | 154 | FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)]; |
155 | emit keyPressed(k, pressedRow, pressedCol, 1); | 155 | emit keyPressed(k, pressedRow, pressedCol, 1); |
156 | 156 | ||
157 | } | 157 | } |
158 | 158 | ||
159 | void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) { | 159 | void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) { |
160 | 160 | ||
161 | if (pressedRow != -1 && pressedRow != -1) { | 161 | if (pressedRow != -1 && pressedRow != -1) { |
162 | 162 | ||
163 | int row = pressedRow; pressedRow = -1; | 163 | int row = pressedRow; pressedRow = -1; |
164 | int col = pressedCol; pressedCol = -1; | 164 | int col = pressedCol; pressedCol = -1; |
165 | paintKey(row, col); | 165 | paintKey(row, col); |
166 | 166 | ||
167 | FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)]; | 167 | FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)]; |
168 | emit keyPressed(k, row, col, 0); | 168 | emit keyPressed(k, row, col, 0); |
169 | } | 169 | } |
170 | 170 | ||
171 | } | 171 | } |
172 | 172 | ||
173 | 173 | ||
174 | void FunctionKeyboard::resizeEvent(QResizeEvent*) { | 174 | void FunctionKeyboard::resizeEvent(QResizeEvent*) { |
175 | 175 | ||
176 | /* set he default font height/width */ | 176 | /* set he default font height/width */ |
177 | QFontMetrics fm=fontMetrics(); | 177 | QFontMetrics fm=fontMetrics(); |
178 | keyHeight = fm.lineSpacing() + 2; | 178 | keyHeight = fm.lineSpacing() + 2; |
179 | keyWidth = (double)width()/numCols; | 179 | keyWidth = (double)width()/numCols; |
180 | 180 | ||
181 | } | 181 | } |
182 | 182 | ||
183 | QSize FunctionKeyboard::sizeHint() const { | 183 | QSize FunctionKeyboard::sizeHint() const { |
184 | 184 | ||
185 | return QSize(width(), keyHeight * numRows + 1); | 185 | return QSize(width(), keyHeight * numRows + 1); |
186 | } | 186 | } |
187 | 187 | ||
188 | void FunctionKeyboard::loadDefaults() { | 188 | void FunctionKeyboard::loadDefaults() { |
189 | 189 | ||
190 | keys.insert( "r0c0", FKey ("Enter", "enter", Qt::Key_Enter, 0)); | 190 | keys.insert( "r0c0", FKey ("Enter", "enter", Qt::Key_Enter, 0)); |
191 | keys.insert( "r0c1", FKey ("Space", "space", Qt::Key_Space, Qt::Key_Space)); | 191 | keys.insert( "r0c1", FKey ("Space", "space", Qt::Key_Space, Qt::Key_Space)); |
192 | keys.insert( "r0c2", FKey ("Tab", "tab", Qt::Key_Tab, 0)); | 192 | keys.insert( "r0c2", FKey ("Tab", "tab", Qt::Key_Tab, 0)); |
193 | keys.insert( "r0c3", FKey ("Up", "up", Qt::Key_Up, 0)); | 193 | keys.insert( "r0c3", FKey ("Up", "up", Qt::Key_Up, 0)); |
194 | keys.insert( "r0c4", FKey ("Down", "down", Qt::Key_Down, 0)); | 194 | keys.insert( "r0c4", FKey ("Down", "down", Qt::Key_Down, 0)); |
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 406586c..b177fa5 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -500,92 +500,92 @@ void MainWindow::slotSessionChanged( Session* ses ) { | |||
500 | m_saveScript->setEnabled( true ); | 500 | m_saveScript->setEnabled( true ); |
501 | m_runScript->setEnabled( true ); | 501 | m_runScript->setEnabled( true ); |
502 | } else { | 502 | } else { |
503 | m_connect->setEnabled( true ); | 503 | m_connect->setEnabled( true ); |
504 | m_disconnect->setEnabled( false ); | 504 | m_disconnect->setEnabled( false ); |
505 | m_recordScript->setEnabled( false ); | 505 | m_recordScript->setEnabled( false ); |
506 | m_saveScript->setEnabled( false ); | 506 | m_saveScript->setEnabled( false ); |
507 | m_runScript->setEnabled( false ); | 507 | m_runScript->setEnabled( false ); |
508 | } | 508 | } |
509 | 509 | ||
510 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { | 510 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { |
511 | m_transfer->setEnabled( false ); | 511 | m_transfer->setEnabled( false ); |
512 | } else { | 512 | } else { |
513 | m_transfer->setEnabled( true ); | 513 | m_transfer->setEnabled( true ); |
514 | } | 514 | } |
515 | 515 | ||
516 | 516 | ||
517 | 517 | ||
518 | 518 | ||
519 | 519 | ||
520 | QWidget *w = m_curSession->widget(); | 520 | QWidget *w = m_curSession->widget(); |
521 | if(w) w->setFocus(); | 521 | if(w) w->setFocus(); |
522 | } | 522 | } |
523 | } | 523 | } |
524 | 524 | ||
525 | void MainWindow::slotFullscreen() { | 525 | void MainWindow::slotFullscreen() { |
526 | 526 | ||
527 | 527 | ||
528 | 528 | ||
529 | if ( m_isFullscreen ) { | 529 | if ( m_isFullscreen ) { |
530 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); | 530 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); |
531 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); | 531 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); |
532 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); | 532 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); |
533 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 533 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
534 | 534 | ||
535 | } else { | 535 | } else { |
536 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); | 536 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); |
537 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); | 537 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); |
538 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop | 538 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop |
539 | , QPoint(0,0), false ); | 539 | , QPoint(0,0), false ); |
540 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); | 540 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); |
541 | ( m_curSession->widgetStack() )->setFocus(); | 541 | ( m_curSession->widgetStack() )->setFocus(); |
542 | ( m_curSession->widgetStack() )->show(); | 542 | ( m_curSession->widgetStack() )->show(); |
543 | 543 | ||
544 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); | 544 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); |
545 | 545 | ||
546 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 546 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
547 | } | 547 | } |
548 | 548 | ||
549 | m_isFullscreen = !m_isFullscreen; | 549 | m_isFullscreen = !m_isFullscreen; |
550 | } | 550 | } |
551 | 551 | ||
552 | 552 | ||
553 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { | 553 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { |
554 | 554 | ||
555 | if ( m_curSession ) { | 555 | if ( m_curSession ) { |
556 | 556 | ||
557 | QEvent::Type state; | 557 | QEvent::Type state; |
558 | 558 | ||
559 | if (pressed) state = QEvent::KeyPress; | 559 | if (pressed) state = QEvent::KeyPress; |
560 | else state = QEvent::KeyRelease; | 560 | else state = QEvent::KeyRelease; |
561 | 561 | ||
562 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); | 562 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); |
563 | 563 | ||
564 | // where should i send this event? doesnt work sending it here | 564 | // is this the best way to do this? cant figure out any other way to work |
565 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); | 565 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); |
566 | ke.ignore(); | 566 | ke.ignore(); |
567 | } | 567 | } |
568 | } | 568 | } |
569 | void MainWindow::slotCopy() { | 569 | void MainWindow::slotCopy() { |
570 | if (!currentSession() ) return; | 570 | if (!currentSession() ) return; |
571 | currentSession()->emulationHandler()->copy(); | 571 | currentSession()->emulationHandler()->copy(); |
572 | } | 572 | } |
573 | void MainWindow::slotPaste() { | 573 | void MainWindow::slotPaste() { |
574 | if (!currentSession() ) return; | 574 | if (!currentSession() ) return; |
575 | currentSession()->emulationHandler()->paste(); | 575 | currentSession()->emulationHandler()->paste(); |
576 | } | 576 | } |
577 | 577 | ||
578 | /* | 578 | /* |
579 | * Save the session | 579 | * Save the session |
580 | */ | 580 | */ |
581 | 581 | ||
582 | void MainWindow::slotSaveSession() { | 582 | void MainWindow::slotSaveSession() { |
583 | if (!currentSession() ) { | 583 | if (!currentSession() ) { |
584 | QMessageBox::information(this, tr("Save Connection"), | 584 | QMessageBox::information(this, tr("Save Connection"), |
585 | tr("<qt>There is no Connection.</qt>"), 1 ); | 585 | tr("<qt>There is no Connection.</qt>"), 1 ); |
586 | return; | 586 | return; |
587 | } | 587 | } |
588 | manager()->add( currentSession()->profile() ); | 588 | manager()->add( currentSession()->profile() ); |
589 | manager()->save(); | 589 | manager()->save(); |
590 | populateProfiles(); | 590 | populateProfiles(); |
591 | } | 591 | } |