diff -r 11d3954df52a -r 627c4a0fd0e7 src/hbplugins/feedback/feedbackeffectplugin/hbfeedbackeffectutils.cpp --- a/src/hbplugins/feedback/feedbackeffectplugin/hbfeedbackeffectutils.cpp Thu May 27 13:10:59 2010 +0300 +++ b/src/hbplugins/feedback/feedbackeffectplugin/hbfeedbackeffectutils.cpp Fri Jun 11 13:58:22 2010 +0300 @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -239,9 +240,8 @@ } } - if (widget->type() == HbPrivate::ItemType_NavigationButton - // Commented out until use cases are clarified - /*|| widget->type() == HbPrivate::ItemType_IndicatorButton*/) { + if (widget->type() == HbPrivate::ItemType_NavigationButton || + widget->type() == Hb::ItemType_ToolButton) { effect = HbFeedback::BasicButton; } @@ -253,7 +253,7 @@ effect = HbFeedback::BasicKeypad; } else if (widget->type() == Hb::ItemType_CheckBox) { - effect = HbFeedback::None; // Checkbox deferred to release + effect = HbFeedback::BasicButton; } // title pane specific special case @@ -269,18 +269,25 @@ effect = HbFeedback::BasicItem; } else { + effect = HbFeedback::BasicItem; + } + if (widget->type() == Hb::ItemType_DataFormViewItem) { effect = HbFeedback::SensitiveItem; } + else if (widget->type() == HbPrivate::ItemType_DataGroup) { + effect = HbFeedback::None; + } + break; case HbFeedbackEffectUtils::Grid: - effect = HbFeedback::SensitiveItem; + effect = HbFeedback::BasicItem; break; case HbFeedbackEffectUtils::Slider: // slider track default - effect = HbFeedback::SensitiveSlider; + effect = HbFeedback::BasicSlider; // special cases if (const HbProgressSlider *progressSlider = qobject_cast(widget)) { @@ -293,12 +300,12 @@ // slider handle if (modifiers & Hb::ModifierSliderHandle) { - effect = HbFeedback::SensitiveSlider; + effect = HbFeedback::BasicSlider; } // slider elements if (modifiers & Hb::ModifierSliderElement) { - effect = HbFeedback::SensitiveButton; + effect = HbFeedback::BasicButton; } break; @@ -324,11 +331,11 @@ if ( const HbAbstractViewItem * viewItem = qobject_cast(widget)) { const HbAbstractItemView* itemView = viewItem->itemView(); if (itemView) { - // checkable item is checked with a press + // Different press feedbacks for single and multiselection list items switch (itemView->selectionMode()) { case HbAbstractItemView::SingleSelection: case HbAbstractItemView::MultiSelection: { - effect = HbFeedback::SensitiveItem; + effect = HbFeedback::BasicButton; break; } case HbAbstractItemView::NoSelection: @@ -343,9 +350,9 @@ break; } - // radio button list works like a normal list item + // radio button list behaves like an item view on press if (viewItem->type() == Hb::ItemType_RadioButtonListViewItem) { - effect = HbFeedback::SensitiveItem; + effect = HbFeedback::BasicItem; } else if(viewItem->type() == Hb::ItemType_TumbleViewItem ) { effect = HbFeedback::SensitiveItem; @@ -362,6 +369,11 @@ } } } + + if (widget->type() == Hb::ItemType_VirtualTrackPoint) { + effect = HbFeedback::BasicButton; + } + if (modifiers & Hb::ModifierScrolling) { effect = HbFeedback::StopFlick; } @@ -405,9 +417,8 @@ } } - if (widget->type() == HbPrivate::ItemType_NavigationButton - // Commented out until use cases are clarified - /*|| widget->type() == HbPrivate::ItemType_IndicatorButton*/) { + if (widget->type() == HbPrivate::ItemType_NavigationButton || + widget->type() == Hb::ItemType_ToolButton) { effect = HbFeedback::BasicButton; } @@ -416,14 +427,12 @@ || widget->type() == Hb::ItemType_InputFunctionButton) { effect = HbFeedback::SensitiveKeypad; } else if (widget->type() == Hb::ItemType_CheckBox) { - effect = HbFeedback::Checkbox; // deferred from press + effect = HbFeedback::Checkbox; } // title pane specific special case if (widget->type() == HbPrivate::ItemType_TitlePane) { - if (isOptionsMenuEmpty(widget)) { - effect = HbFeedback::None; - } + effect = HbFeedback::None; } if (widget->type() == Hb::ItemType_ComboBox) { @@ -437,31 +446,34 @@ effect = HbFeedback::BasicItem; } else { - effect = HbFeedback::SensitiveItem; + effect = HbFeedback::BasicItem; } - // menu items give popop closed feedback on release + // menu items give popup close feedback on release if (widget->type() == Hb::ItemType_MenuItem) { effect = HbFeedback::None; } + else if (widget->type() == Hb::ItemType_DataFormViewItem) { + effect = HbFeedback::None; + } break; case HbFeedbackEffectUtils::Grid: - effect = HbFeedback::SensitiveItem; + effect = HbFeedback::BasicItem; break; case HbFeedbackEffectUtils::Slider: // slider track default - effect = HbFeedback::SensitiveSlider; + effect = HbFeedback::BasicSlider; // slider handle if (modifiers & Hb::ModifierSliderHandle) { - effect = HbFeedback::SensitiveSlider; + effect = HbFeedback::BasicSlider; } // slider elements if (modifiers & Hb::ModifierSliderElement) { - effect = HbFeedback::SensitiveButton; + effect = HbFeedback::None; } break; @@ -479,7 +491,7 @@ if (itemView) { switch (itemView->selectionMode()) { case HbAbstractItemView::SingleSelection: - effect = HbFeedback::Checkbox; // deferred from press + effect = HbFeedback::Checkbox; break; case HbAbstractItemView::MultiSelection: { effect = HbFeedback::None; @@ -503,9 +515,9 @@ } } - // radio button list works like a normal list item + // radio button list has checkbox feedback behaviour on release if (viewItem->type() == Hb::ItemType_RadioButtonListViewItem) { - effect = HbFeedback::SensitiveItem; + effect = HbFeedback::Checkbox; } else if(viewItem->type() == Hb::ItemType_TumbleViewItem ) { effect = HbFeedback::SensitiveItem; @@ -600,9 +612,11 @@ if (widget->type() == Hb::ItemType_VirtualTrackPoint) { effect = HbFeedback::Editor; } + if (widget->type() == Hb::ItemType_Menu) { effect = HbFeedback::ItemScroll; } + return effect; } @@ -662,6 +676,49 @@ } } } + else if (const HbInputVirtualRocker *trackPoint = qobject_cast(widget)) { + + QGraphicsItem* graphicsItem = trackPoint->mainWindow()->scene()->focusItem(); + + if (graphicsItem->isWidget() && (static_cast(graphicsItem)->inherits("QGraphicsWebView"))) { + QVariant v; + v = graphicsItem->scene()->inputMethodQuery( Qt::ImCursorPosition ); + if ( v.isValid() && v.canConvert()) { + int index; + index = v.toInt(); + QVariant varSurrText; + varSurrText = graphicsItem->scene()->inputMethodQuery( Qt::ImSurroundingText ); + if ( varSurrText.isValid() ) { + QString text = varSurrText.toString(); + // Index (current cursor position) can be equal to the + // length of the string (for e.g. when the cursor is at the end) + // So we make sure we bring index within the bounds of the string + if (!text.isEmpty() && index <= text.count()) { + dist = abs(index - previousCursorPosition); + + if (previousCursorPosition < index || index == text.count()) { + index--; + } + QChar character = text.at(index); + emptyline = character.category() == QChar::Separator_Paragraph; + + if (emptyline) { + effect = HbFeedback::EmptyLineSelection; + } + else if (dist > 1) { + effect = HbFeedback::LineSelection; + } + else if (character.isSpace()) { + effect = HbFeedback::BlankSelection; + } + else { + effect = HbFeedback::TextSelection; + } + } + } + } + } + } return effect; } @@ -671,11 +728,11 @@ bool HbFeedbackEffectUtils::isFeedbackAllowedForPopup(const HbWidget *widget) { bool feedbackAllowed(false); + if (widgetFamily(widget) == HbFeedbackEffectUtils::Popup) { feedbackAllowed = true; if (widget->type() == HbPrivate::ItemType_ToolTipLabel - || widget->type() == Hb::ItemType_InputCharPreviewPane - || widget->type() == Hb::ItemType_InputVkbWidget) { + || widget->type() == Hb::ItemType_InputCharPreviewPane) { feedbackAllowed = false; } else if (QString(widget->metaObject()->className()) == "HbSelectionControl") { @@ -685,10 +742,44 @@ else if (QString(widget->metaObject()->className()) == "HbComboDropDown") { feedbackAllowed = true; } + return feedbackAllowed; } /*! + Returns the instant feedback effect for popup open event. +*/ +HbFeedback::InstantEffect HbFeedbackEffectUtils::instantOnPopupOpened(const HbWidget *widget) { + + HbFeedback::InstantEffect effect = HbFeedback::None; + + if (QString(widget->metaObject()->className()) == "HbDeviceNotificationDialogWidget") { + effect = HbFeedback::PopUp; + } + else { + effect = HbFeedback::PopupOpen; + } + return effect; +} + +/*! + Returns the instant feedback effect for popup close event. +*/ +HbFeedback::InstantEffect HbFeedbackEffectUtils::instantOnPopupClosed(const HbWidget *widget) { + + HbFeedback::InstantEffect effect = HbFeedback::None; + + if (QString(widget->metaObject()->className()) == "HbDeviceNotificationDialogWidget") { + effect = HbFeedback::None; + } + else { + effect = HbFeedback::PopupClose; + } + + return effect; +} + +/*! Returns the instant feedback effect on key press interaction. */ HbFeedback::InstantEffect HbFeedbackEffectUtils::instantOnKeyPress(const HbWidget *widget, Hb::InteractionModifiers modifiers) @@ -702,7 +793,6 @@ */ HbFeedback::InstantEffect HbFeedbackEffectUtils::instantOnSelectionChanged(const HbWidget *widget, Hb::InteractionModifiers modifiers) { - Q_UNUSED(modifiers); HbFeedback::InstantEffect effect = HbFeedback::None; if (const HbAbstractViewItem * viewItem = qobject_cast(widget)) { @@ -715,7 +805,7 @@ break; } case HbAbstractItemView::MultiSelection: { - effect = HbFeedback::MultipleCheckbox; + effect = HbFeedback::Checkbox; break; } default: @@ -723,6 +813,11 @@ } } } + else if (const HbAbstractItemView* itemView = qobject_cast(widget)) { + if (itemView->selectionMode() == HbAbstractItemView::MultiSelection && (modifiers & Hb::ModifierScrolling)) { + effect = HbFeedback::MultipleCheckbox; + } + } return effect; } @@ -854,6 +949,7 @@ HbFeedback::Modalities HbFeedbackEffectUtils::modalities(const HbWidget *widget, Hb::InstantInteraction interaction, Hb::InteractionModifiers modifiers ) { Q_UNUSED(modifiers) + Q_UNUSED(widget) HbFeedback::Modalities modalities = 0; @@ -869,9 +965,6 @@ case Hb::InstantClicked: modalities = HbFeedback::Tactile; - if(widget->type() == Hb::ItemType_CheckBox) { - modalities |= HbFeedback::Audio; - } break; case Hb::InstantKeyRepeated: