Trolltech Home | Qtopia-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qtopia-interest Archive, February 2008
[PATCH] Keyboard navigation and the "grid" in the server


Message 1 in thread

Hey,

I had filed this bug, it has the issue number N199781 but it is sadly private 
so some sending the patches to the mailing list as well.

Situation: Touchscreen is preferred device but a keyboard is still available
Problem: The SelectedItem is 'flashing' (starting and immediately stopping) an 
animation when the keyboard is used to navigate. So touchscreen and keyboard
are not mutual exclusive (e.g. the Nokia tables have cursor keys and 
touchscreen)...

What is wrong: The flashing is not visually appealing

Proposed solution: Once the keyboard was used show the focus on the selected 
item, after launching an application make it go away

What is missing: Fading out after a time? UI decision?

comments?

	z.
From c55c3bcf9a499bbbedf3b4ee76ac87446c481937 Mon Sep 17 00:00:00 2001
From c55c3bcf9a499bbbedf3b4ee76ac87446c481937 Mon Sep 17 00:00:00 2001
From: Holger Freyther <zecke@xxxxxxxxxxx>
Date: Wed, 20 Feb 2008 23:25:19 +0100
Subject: [PATCH] If our InputDevice is Touchscreen but we still use a keyboard show the selected item
     Show the selected item to the user, avoid screen flickering by starting and
     stopping the animation after the first frame.

---
 src/server/phone/ui/selecteditem.cpp |    7 +++++--
 src/server/phone/ui/selecteditem.h   |    2 ++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/server/phone/ui/selecteditem.cpp b/src/server/phone/ui/selecteditem.cpp
index f0c9f44..be5e634 100644
--- a/src/server/phone/ui/selecteditem.cpp
+++ b/src/server/phone/ui/selecteditem.cpp
@@ -88,6 +88,7 @@ SelectedItem::SelectedItem(const QString &_backgroundFileName,
     , movie(0)
     , active(false)
     , pressed(false)
+    , sawMoveByKeyPress(false)
     , moveTimeLine(0)
     , playTimeLine(0)
     , slideTimeInterval(_slideTimeInterval)
@@ -333,7 +334,7 @@ void SelectedItem::paint(QPainter *painter,const QStyleOptionGraphicsItem *,QWid
         return;
     }
 
-    if (!Qtopia::mousePreferred() || active)
+    if (!Qtopia::mousePreferred() || active || sawMoveByKeyPress)
         drawBackground(painter);
 
     if ( animationState() == Animating ) {
@@ -367,7 +368,7 @@ void SelectedItem::paint(QPainter *painter,const QStyleOptionGraphicsItem *,QWid
             draw(painter,destItem->selectedPic(),destX,destY);
         } else {
             // We're not sliding, we're just drawing 'item' as the selected item.
-            if (!Qtopia::mousePreferred() || active)
+            if (!Qtopia::mousePreferred() || active || sawMoveByKeyPress)
                 draw(painter,currentItem->selectedPic(),static_cast<int>(rect().x()),static_cast<int>(rect().y()));
         }
     }
@@ -680,6 +681,8 @@ void SelectedItem::keyReleaseEvent(QKeyEvent *event)
 */
 void SelectedItem::moveRequested(Direction direction)
 {
+    sawMoveByKeyPress = true;
+
     int row;
     int col;
     if ( destItem ) {
diff --git a/src/server/phone/ui/selecteditem.h b/src/server/phone/ui/selecteditem.h
index bac16ba..cefe581 100644
--- a/src/server/phone/ui/selecteditem.h
+++ b/src/server/phone/ui/selecteditem.h
@@ -186,6 +186,8 @@ private:
     // Used by keyPressEvent(...) and keyReleaseEvent(...).
     bool pressed;
 
+    bool sawMoveByKeyPress;
+
     // Used to move the SelectedItem from the current GridItem object to a destination object.
     // The amount of time it takes to move an item is determine by the ctor's 'slideTimeInterval'
     // parameter. The timeline is connected to connector's moving(...) and movingStateChanged(...)
-- 
 [ signature omitted ] 
From 7fb20e375d90e4ac7bb341b66922a7bf42e06a9f Mon Sep 17 00:00:00 2001
From: Holger Freyther <zecke@xxxxxxxxxxx>
Date: Thu, 21 Feb 2008 00:00:53 +0100
Subject: [PATCH] Reset the keyboard status after launching an application
     Forget the highlighting if we have launched an application.

---
 src/server/phone/ui/phonelauncherview.cpp |    3 +++
 src/server/phone/ui/selecteditem.cpp      |    4 ++++
 src/server/phone/ui/selecteditem.h        |    2 ++
 3 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/src/server/phone/ui/phonelauncherview.cpp b/src/server/phone/ui/phonelauncherview.cpp
index 7a51b72..3aa3bef 100644
--- a/src/server/phone/ui/phonelauncherview.cpp
+++ b/src/server/phone/ui/phonelauncherview.cpp
@@ -513,6 +513,9 @@ void PhoneLauncherView::itemSelectedHandler(GridItem *item)
 void PhoneLauncherView::itemPressedHandler(GridItem *item)
 {
     if ( item && item->content() && !(item->content()->name().isEmpty()) ) {
+        if ( selectedItem )
+            selectedItem->resetMovedByKeyPress();
+
         emit pressed(*(item->content()));
     }
 }
diff --git a/src/server/phone/ui/selecteditem.cpp b/src/server/phone/ui/selecteditem.cpp
index be5e634..c8f44ca 100644
--- a/src/server/phone/ui/selecteditem.cpp
+++ b/src/server/phone/ui/selecteditem.cpp
@@ -1031,3 +1031,7 @@ void SelectedItem::paletteChanged()
     update(boundingRect());
 }
 
+void SelectedItem::resetMovedByKeyPress()
+{
+    sawMoveByKeyPress = false;
+}
diff --git a/src/server/phone/ui/selecteditem.h b/src/server/phone/ui/selecteditem.h
index cefe581..7eaac69 100644
--- a/src/server/phone/ui/selecteditem.h
+++ b/src/server/phone/ui/selecteditem.h
@@ -91,6 +91,8 @@ public:
 
     void paletteChanged();
 
+    void resetMovedByKeyPress();
+
 protected:
 
     void keyPressEvent(QKeyEvent *event);
-- 
 [ signature omitted ]