200 QGraphicsTextItem::mousePressEvent(event); |
200 QGraphicsTextItem::mousePressEvent(event); |
201 } |
201 } |
202 |
202 |
203 void GTextLineItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * event) |
203 void GTextLineItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * event) |
204 { |
204 { |
|
205 |
205 QGraphicsTextItem::mouseReleaseEvent(event); |
206 QGraphicsTextItem::mouseReleaseEvent(event); |
206 QPointF pos = event->pos(); |
207 QPointF pos = event->pos(); |
207 emit tapped(pos); |
208 emit tapped(pos); |
|
209 launchVKB(); |
|
210 } |
|
211 |
|
212 void GTextLineItem::keyPressEvent(QKeyEvent * event) |
|
213 { |
|
214 // Signal horizontal cursor movement so that an editor widget can |
|
215 // implement horizontal scrolling. |
|
216 qreal oldX = cursorX(); |
|
217 QGraphicsTextItem::keyPressEvent(event); |
|
218 qreal newX = cursorX(); |
|
219 if (newX != oldX) { |
|
220 emit cursorXChanged(newX); |
|
221 } |
|
222 } |
|
223 |
|
224 void GTextLineItem::keyReleaseEvent(QKeyEvent * event) |
|
225 { |
|
226 QGraphicsTextItem::keyReleaseEvent(event); |
|
227 emit textMayChanged(); |
|
228 } |
|
229 |
|
230 void GTextLineItem::focusInEvent(QFocusEvent * event) |
|
231 { |
|
232 Q_UNUSED(event); |
|
233 // disable the drag & drop to fix the auto-delete-all issue |
|
234 QApplication::setStartDragDistance(1000); |
|
235 QGraphicsTextItem::focusInEvent(event); |
|
236 |
|
237 #ifndef ORBIT_UI |
|
238 QWidget* fw = QApplication::focusWidget(); |
|
239 Qt::InputMethodHints hints = fw->inputMethodHints(); |
|
240 if (hints != m_hints) |
|
241 fw->setInputMethodHints(m_hints); |
|
242 #endif |
|
243 |
|
244 if (event->reason() != Qt::PopupFocusReason) // to fix the special char issue on VKB |
|
245 emit focusChanged(true); |
|
246 } |
|
247 |
|
248 void GTextLineItem::focusOutEvent(QFocusEvent * event) |
|
249 { |
|
250 Q_UNUSED(event); |
|
251 // restore the drag & drop for other components |
|
252 QApplication::setStartDragDistance(m_defaultStartDragDistance); |
|
253 QGraphicsTextItem::focusOutEvent(event); |
|
254 if (event->reason() != Qt::PopupFocusReason && event->reason() != Qt::ActiveWindowFocusReason) // to fix the special char issue on VKB |
|
255 emit focusChanged(false); |
|
256 } |
|
257 |
|
258 void GTextLineItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) |
|
259 { |
|
260 // ignore context menu event |
|
261 event->ignore(); |
|
262 } |
|
263 |
|
264 void GTextLineItem::setInputMethodHints(Qt::InputMethodHints hints) |
|
265 { |
|
266 m_hints = hints; |
|
267 m_hints |= Qt::ImhNoPredictiveText; // disable the predictive text |
|
268 } |
|
269 |
|
270 void GTextLineItem::launchVKB() { |
|
271 |
208 |
272 |
209 // add specific button |
273 // add specific button |
210 #ifdef ORBIT_UI |
274 #ifdef ORBIT_UI |
211 if (m_setSpecificBtn) { |
275 if (m_setSpecificBtn) { |
212 HbEditorInterface editorInterface(this); |
276 HbEditorInterface editorInterface(this); |
220 |
284 |
221 editorInterface.addAction(action); |
285 editorInterface.addAction(action); |
222 m_setSpecificBtn = false; |
286 m_setSpecificBtn = false; |
223 } |
287 } |
224 #endif |
288 #endif |
225 |
289 sendInputPanelEvent(QEvent::RequestSoftwareInputPanel); |
226 // open vkb by single tap |
290 |
227 QWidget * widget = event->widget(); |
|
228 QEvent vkbEvent(QEvent::RequestSoftwareInputPanel); |
|
229 QApplication::sendEvent(widget, &vkbEvent); |
|
230 |
291 |
231 // disable prediction |
292 // disable prediction |
232 #ifdef ORBIT_UI |
293 #ifdef ORBIT_UI |
233 HbInputSettingProxy* hbISProxy = HbInputSettingProxy::instance(); |
294 HbInputSettingProxy* hbISProxy = HbInputSettingProxy::instance(); |
234 if (hbISProxy->predictiveInputStatusForActiveKeyboard()) |
295 if (hbISProxy->predictiveInputStatusForActiveKeyboard()) |
235 hbISProxy->togglePrediction(); |
296 hbISProxy->togglePrediction(); |
236 #endif |
297 #endif |
237 } |
298 } |
238 |
299 |
239 void GTextLineItem::keyPressEvent(QKeyEvent * event) |
300 void GTextLineItem::sendInputPanelEvent(QEvent::Type type) { |
240 { |
301 QInputContext *ic = qApp->inputContext(); |
241 // Signal horizontal cursor movement so that an editor widget can |
302 if (ic) { QEvent *event = new QEvent(type); |
242 // implement horizontal scrolling. |
303 ic->filterEvent(event); |
243 qreal oldX = cursorX(); |
304 delete event; |
244 QGraphicsTextItem::keyPressEvent(event); |
305 } |
245 qreal newX = cursorX(); |
|
246 if (newX != oldX) { |
|
247 emit cursorXChanged(newX); |
|
248 } |
|
249 } |
|
250 |
|
251 void GTextLineItem::keyReleaseEvent(QKeyEvent * event) |
|
252 { |
|
253 QGraphicsTextItem::keyReleaseEvent(event); |
|
254 emit textMayChanged(); |
|
255 } |
|
256 |
|
257 void GTextLineItem::focusInEvent(QFocusEvent * event) |
|
258 { |
|
259 Q_UNUSED(event); |
|
260 // disable the drag & drop to fix the auto-delete-all issue |
|
261 QApplication::setStartDragDistance(1000); |
|
262 QGraphicsTextItem::focusInEvent(event); |
|
263 |
|
264 #ifndef ORBIT_UI |
|
265 QWidget* fw = QApplication::focusWidget(); |
|
266 Qt::InputMethodHints hints = fw->inputMethodHints(); |
|
267 if (hints != m_hints) |
|
268 fw->setInputMethodHints(m_hints); |
|
269 #endif |
|
270 |
|
271 if (event->reason() != Qt::PopupFocusReason) // to fix the special char issue on VKB |
|
272 emit focusChanged(true); |
|
273 } |
|
274 |
|
275 void GTextLineItem::focusOutEvent(QFocusEvent * event) |
|
276 { |
|
277 Q_UNUSED(event); |
|
278 // restore the drag & drop for other components |
|
279 QApplication::setStartDragDistance(m_defaultStartDragDistance); |
|
280 QGraphicsTextItem::focusOutEvent(event); |
|
281 if (event->reason() != Qt::PopupFocusReason && event->reason() != Qt::ActiveWindowFocusReason) // to fix the special char issue on VKB |
|
282 emit focusChanged(false); |
|
283 } |
|
284 |
|
285 void GTextLineItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) |
|
286 { |
|
287 // ignore context menu event |
|
288 event->ignore(); |
|
289 } |
|
290 |
|
291 void GTextLineItem::setInputMethodHints(Qt::InputMethodHints hints) |
|
292 { |
|
293 m_hints = hints; |
|
294 m_hints |= Qt::ImhNoPredictiveText; // disable the predictive text |
|
295 } |
306 } |
296 |
307 |
297 // Methods for class GLineEditor |
308 // Methods for class GLineEditor |
298 // GLineEditor is a QGraphicsWidget that wraps a GTextLineItem to implement scrolling, |
309 // GLineEditor is a QGraphicsWidget that wraps a GTextLineItem to implement scrolling, |
299 // draw a background and set padding |
310 // draw a background and set padding |
300 |
311 |
301 GLineEditor::GLineEditor(ChromeSnippet * snippet, ChromeWidget * chrome, QGraphicsItem * parent) |
312 GLineEditor::GLineEditor(ChromeSnippet * snippet, ChromeWidget * chrome, QGraphicsItem * parent) |
302 : QGraphicsWidget(parent) |
313 : QGraphicsWidget(parent) |
303 , m_chrome(chrome) |
314 , m_chrome(chrome) |
304 , m_viewPortWidth(0.0) |
315 , m_viewPortWidth(0.0) |
305 , m_viewPortHeight(0.0) |
316 #ifdef BROWSER_LAYOUT_TENONE |
|
317 , m_titleModeWidth(0.0) |
|
318 #endif |
306 , m_padding(0.0) |
319 , m_padding(0.0) |
307 , m_rightTextMargin(0.0) |
320 , m_rightTextMargin(0.0) |
308 { |
321 { |
309 Q_UNUSED(snippet); |
322 Q_UNUSED(snippet); |
310 |
323 |
312 // viewport size will be set in resize() |
325 // viewport size will be set in resize() |
313 m_viewPort = new QGraphicsWidget(this); |
326 m_viewPort = new QGraphicsWidget(this); |
314 m_viewPort->setFlags(QGraphicsItem::ItemClipsChildrenToShape); |
327 m_viewPort->setFlags(QGraphicsItem::ItemClipsChildrenToShape); |
315 |
328 |
316 // The actual text editor item |
329 // The actual text editor item |
|
330 //m_textColor = QColor(Qt::black); |
317 m_editor = new GTextLineItem(m_viewPort); |
331 m_editor = new GTextLineItem(m_viewPort); |
|
332 #ifndef BROWSER_LAYOUT_TENONE |
318 m_editor->setDefaultTextColor(m_textColor); |
333 m_editor->setDefaultTextColor(m_textColor); |
|
334 #endif |
319 m_editor->installEventFilter(this); |
335 m_editor->installEventFilter(this); |
|
336 |
|
337 #ifdef BROWSER_LAYOUT_TENONE |
|
338 m_titleColor = QColor(Qt::white); |
|
339 m_title = new GTitleItem(m_viewPort); |
|
340 m_title->setDefaultTextColor(m_titleColor); |
|
341 m_title->hide(); |
|
342 safe_connect(m_title, SIGNAL(tapped(QPointF& )), |
|
343 this, SIGNAL(titleMouseEvent(QPointF&))); |
|
344 #endif |
320 |
345 |
321 // Monitor editor cursor position changes for horizontal scrolling. |
346 // Monitor editor cursor position changes for horizontal scrolling. |
322 safe_connect(m_editor, SIGNAL(cursorXChanged(qreal)), |
347 safe_connect(m_editor, SIGNAL(cursorXChanged(qreal)), |
323 this, SLOT(makeVisible(qreal))); |
348 this, SLOT(makeVisible(qreal))); |
324 |
349 |
325 safe_connect(m_editor, SIGNAL(textMayChanged()), |
350 safe_connect(m_editor, SIGNAL(textMayChanged()), |
326 this, SIGNAL(textMayChanged())); |
351 this, SIGNAL(textMayChanged())); |
|
352 |
|
353 safe_connect(m_editor->document(), SIGNAL(contentsChange(int, int, int)), |
|
354 this, SIGNAL(contentsChange(int, int, int))); |
327 |
355 |
328 safe_connect(m_editor, SIGNAL(focusChanged(bool)), |
356 safe_connect(m_editor, SIGNAL(focusChanged(bool)), |
329 this, SIGNAL(focusChanged(bool))); |
357 this, SIGNAL(focusChanged(bool))); |
330 |
358 |
331 safe_connect(m_editor, SIGNAL(tapped(QPointF&)), |
359 safe_connect(m_editor, SIGNAL(tapped(QPointF&)), |
384 } |
425 } |
385 |
426 |
386 void GLineEditor::resizeEvent(QGraphicsSceneResizeEvent * event) |
427 void GLineEditor::resizeEvent(QGraphicsSceneResizeEvent * event) |
387 { |
428 { |
388 QSizeF size = event->newSize(); |
429 QSizeF size = event->newSize(); |
389 m_viewPortWidth = size.width() - m_rightTextMargin - m_padding * 2; |
430 qreal height = size.height() - m_padding * 2; |
390 m_viewPortHeight = size.height() - m_padding * 2; |
431 qreal width; |
|
432 |
|
433 width = m_viewPortWidth = size.width() - m_rightTextMargin - m_padding * 2; |
|
434 |
|
435 #ifdef BROWSER_LAYOUT_TENONE |
|
436 m_titleModeWidth = size.width() - m_padding * 2; |
|
437 if (m_title->isVisible() ) { |
|
438 width = m_titleModeWidth; |
|
439 } |
|
440 m_title->setTextWidth(m_titleModeWidth); |
|
441 |
|
442 #endif |
391 m_viewPort->setGeometry( |
443 m_viewPort->setGeometry( |
392 m_padding, |
444 m_padding, |
393 (size.height() - m_editor->boundingRect().height()) / 2, |
445 (size.height() - m_editor->boundingRect().height()) / 2, |
394 m_viewPortWidth, |
446 width, |
395 m_viewPortHeight); |
447 height); |
|
448 |
396 m_editor->setTextWidth(m_viewPortWidth); |
449 m_editor->setTextWidth(m_viewPortWidth); |
397 // move back the m_editor'x to 0 |
450 // move back the m_editor'x to 0 |
398 qreal editorShift = -1 * m_editor->pos().x(); |
451 qreal editorShift = -1 * m_editor->pos().x(); |
399 m_editor->moveBy(editorShift, 0); |
452 m_editor->moveBy(editorShift, 0); |
400 updateEditor(); |
453 updateEditor(); |
|
454 |
|
455 |
|
456 } |
|
457 |
|
458 #ifdef BROWSER_LAYOUT_TENONE |
|
459 |
|
460 void GLineEditor::changeEditorMode(bool edit) { |
|
461 QRectF rect = m_viewPort->geometry(); |
|
462 if (edit) { |
|
463 m_backgroundColor = QColor(Qt::white); |
|
464 |
|
465 // Update the width of viewPort |
|
466 if (m_title->isVisible() ) { |
|
467 m_viewPort->setGeometry(rect.x(), rect.y(), (rect.width() - m_rightTextMargin ), rect.height()); |
|
468 |
|
469 //move back the m_editor'x to 0 |
|
470 qreal editorShift = -1 * m_editor->pos().x(); |
|
471 m_editor->moveBy(editorShift, 0); |
|
472 updateEditor(); |
|
473 m_title->hide(); |
|
474 m_editor->show(); |
|
475 } |
|
476 } |
|
477 else { |
|
478 m_backgroundColor = QColor(Qt::transparent); |
|
479 |
|
480 // Update the width of viewPort |
|
481 if (m_editor->isVisible() ) { |
|
482 |
|
483 m_viewPort->setGeometry(rect.x(), rect.y(), (rect.width() + m_rightTextMargin ), rect.height()); |
|
484 m_editor->hide(); |
|
485 m_title->show(); |
|
486 } |
|
487 |
|
488 } |
|
489 } |
|
490 |
|
491 void GLineEditor::setTitle(const QString & text) |
|
492 { |
|
493 m_title->setText(text); |
|
494 } |
|
495 #endif |
|
496 |
|
497 void GLineEditor::closeVKB() |
|
498 { |
|
499 m_editor->sendInputPanelEvent(QEvent::CloseSoftwareInputPanel); |
|
500 |
|
501 } |
|
502 |
|
503 void GLineEditor::openVKB() |
|
504 { |
|
505 m_editor->launchVKB(); |
|
506 |
401 } |
507 } |
402 |
508 |
403 void GLineEditor::setText(const QString & text) |
509 void GLineEditor::setText(const QString & text) |
404 { |
510 { |
405 m_editor->setText(text); |
511 m_editor->setText(text); |
635 m_textEditor->setBackgroundColor(backgroundColor); |
741 m_textEditor->setBackgroundColor(backgroundColor); |
636 |
742 |
637 QColor borderColor; |
743 QColor borderColor; |
638 NativeChromeItem::CSSToQColor(we.styleProperty("border-top-color", QWebElement::ComputedStyle), |
744 NativeChromeItem::CSSToQColor(we.styleProperty("border-top-color", QWebElement::ComputedStyle), |
639 borderColor); |
745 borderColor); |
|
746 #ifndef BROWSER_LAYOUT_TENONE |
640 m_textEditor->setBorderColor(borderColor); |
747 m_textEditor->setBorderColor(borderColor); |
|
748 #endif |
641 |
749 |
642 //Padding sets the "border" width |
750 //Padding sets the "border" width |
643 QString cssPadding = we.styleProperty("padding-top", QWebElement::ComputedStyle); |
751 QString cssPadding = we.styleProperty("padding-top", QWebElement::ComputedStyle); |
644 m_textEditor->setPadding(cssPadding.remove("px").toInt()); |
752 m_textEditor->setPadding(cssPadding.remove("px").toInt()); |
645 |
753 |