Bug 127614

Summary: [CameraUI] Focus steal when typing custom prefix in renaming options sidebar
Product: [Applications] digikam Reporter: sero4linux
Component: Import-Gphoto2Assignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In: 0.9.0
Sentry Crash Report:

Description sero4linux 2006-05-18 21:58:34 UTC
Version:           0.9 SVN (using KDE KDE 3.5.2)
Installed from:    Gentoo Packages

Since half a week or so I encouter the following problem when I want to download pictures from my Nikon D70 (PTP) with digikam SVN trunk: 

In the settings sidebar when I want to type in a custom prefix in the textbox I can only type 1-2 letters befor the textbox looses the focus. I have to activate the textbox again by left mouse click and can type 1-2 letters again, focus loss again and so on and so on.

Sorry I have no time to examine the code atm cause real life is very hard (yeah I know that sounds lame ...). The problem didn't go away in latest SVN. Maybe it's related to a Qt update I did recently (from 3.3.4 to 3.3.6) but otherwise I would say nothing changed in my system.

Regards,
Sebastian
Comment 1 caulier.gilles 2006-05-19 07:09:03 UTC
I cannot reproduce this problem in my system. Are you use a Gphoto2 camera or UMS camera ?

Gilles
Comment 2 sero4linux 2006-05-19 22:00:14 UTC
Hi Gilles,

> I cannot reproduce this problem in my system. Are you use a Gphoto2
> camera or UMS camera ?


Hmmm, I did a little further testing and the behaviour exists for both PTP 
Mode (gphoto2) and Mass Storage. I also tested whether the autorotation or 
photographer/copyright settings have an impact on that behaviour and the 
answer is "no" for both.

However the problem seems not to be so hard then yesterday - in most 
situations I have enough time to type in the name I want. This brings me to 
the question whether this is a "feature" and not a bug - do you want the 
cursor to jump to the last selected image after some seconds of no user input 
in the text box (that is what actually happens)? The focus stays intact in 
the textbox when a) the textbox is empty or b) the text in the box is 
selected.

I hope this information is usefull in some way. I notice a "refresh" of the 
cameraui window everytime this focus change appears (the whole 
window "blinks" once). It looks to me like some kind of polling is active?

What else can I test? Recompile with full debug? Recompile with Qt 3.3.4 
rather then 3.3.6? 
Comment 3 sero4linux 2006-06-18 20:36:12 UTC
I tested this problem again on latest SVN with diffrent cameras:

Nikon D70 both in PTP mode and in USB Mass Storage mode
Canon A75 in PTP mode

The problem is still there and I find it very annoying. Also the atempts to fix the problem by myself failed cause I didn't quite get the qtimer thingy yet.

Doesn't anybody else have this problem? Is this only me? Would be great if someone could reproduce the flicker and report back.
Comment 4 Marcel Wiesweg 2006-06-18 22:27:24 UTC
You could add debug statements to all the "d->changedTimer->start" lines in renamecustomizer.cpp and a statement to the "CameraIconView::slotDownloadNameChanged()" method in cameraiconview.cpp, which is called by the timer signal. Check if the latter method correlates with the flicker you are experiencing. Then, I still don't know why the focus would be lost.
Comment 5 caulier.gilles 2006-07-20 12:31:14 UTC
Seb,

The problem is fixed in my computer. Look in B.K.O #131034 : there is a patch to improve camera gui. I have include this fix in this patch. 

Apply the patch against current svn implementation and give me a report.

Gilles
Comment 6 caulier.gilles 2006-07-20 16:54:26 UTC
SVN commit 564596 by cgilles:

digikam from trunk : camera gui improvement and fix :

- fix rename customizer rule about custom prefix widget focus (#127614)
- Add small icon on top/roght of camera ites to indicate download status (#131034)
- Fix some minor internal bugs.
- Polish implementation.
- using d private class to speed up compilation
- camera gui support digiKam theme now. A screenshot :

http://digikam3rdparty.free.fr/Screenshots/camera_gui_with_theme_and_icon_download_status.png

BUG: 127614, 131034

CCMAIL: digikam-devel@kde.org



 M  +3 -1      NEWS  
 M  +0 -2      TODO  
 M  +14 -14    digikam/albumiconitem.cpp  
 M  +5 -0      digikam/albumiconitem.h  
 M  +166 -52   libs/imageproperties/cameraitempropertiestab.cpp  
 M  +1 -0      libs/imageproperties/cameraitempropertiestab.h  
 M  +13 -0     libs/imageproperties/imagepropertiessidebarcamgui.cpp  
 M  +1 -0      libs/imageproperties/imagepropertiessidebarcamgui.h  
 M  +1 -0      utilities/cameragui/Makefile.am  
 M  +158 -143  utilities/cameragui/cameracontroller.cpp  
 M  +1 -1      utilities/cameragui/cameracontroller.h  
 M  +245 -103  utilities/cameragui/cameraiconitem.cpp  
 M  +12 -22    utilities/cameragui/cameraiconitem.h  
 M  +99 -40    utilities/cameragui/cameraiconview.cpp  
 M  +10 -6     utilities/cameragui/cameraiconview.h  
 M  +28 -19    utilities/cameragui/cameraui.cpp  
 M  +1 -1      utilities/cameragui/cameraui.h  
 M  +5 -5      utilities/cameragui/dkcamera.cpp  
 M  +3 -3      utilities/cameragui/gpcamera.cpp  
 M  +13 -1     utilities/cameragui/gpiteminfo.h  
 M  +8 -2      utilities/cameragui/renamecustomizer.cpp  
 M  +7 -2      utilities/cameragui/renamecustomizer.h  
 M  +3 -3      utilities/cameragui/umscamera.cpp  
Comment 7 sero4linux 2006-07-25 11:15:52 UTC
Thx Gilles, the latest SVN works for me.
Comment 8 Marcel Wiesweg 2006-09-19 16:37:31 UTC
SVN commit 586413 by mwiesweg:

Cam GUI:
- Remove "flicker" of settings tab
- make keyboard navigation possible again

Flicker was caused from two sides:
- handling of signalChanged from RenameCustomizer
  and signalSelectionChanged from IconView was entangled in one method,
  slotDownloadNamesChanged. Splitting that up, no signalNewSelection is
  emitted any more in response to a signalChanged
- Fast dis/enabling will create the impression of flicker and lose focus (127614)
  Only disable now when downloading.
  Previously, signalSelected -> getExif -> slotBusy (disable tab),
    when Exif is ready -> slotBusy (enable tab)

CC'ing 127614 because this explains the reason for the reported bug, and
because I removed the restoreFocus again, which broke keyboard
navigation, but does not seem to be needed any more.

CCBUG: 127614



 M  +27 -21    cameraiconview.cpp  
 M  +1 -0      cameraiconview.h  
 M  +9 -2      cameraui.cpp  


--- trunk/extragear/graphics/digikam/utilities/cameragui/cameraiconview.cpp #586412:586413
@@ -106,14 +106,17 @@
     // ----------------------------------------------------------------
 
     connect(this, SIGNAL(signalSelectionChanged()),
-            this, SLOT(slotDownloadNameChanged()));
-            
+            this, SLOT(slotSelectionChanged()));
+
+    connect(this, SIGNAL(signalNewSelection(bool)),
+            this, SLOT(slotUpdateDownloadNames(bool)));
+
     connect(this, SIGNAL(signalRightButtonClicked(IconItem*, const QPoint&)),
             this, SLOT(slotContextMenu(IconItem*, const QPoint&)));
 
     connect(this, SIGNAL(signalRightButtonClicked(const QPoint &)),
             this, SLOT(slotRightButtonClicked(const QPoint &)));
-            
+
     connect(this, SIGNAL(signalDoubleClicked(IconItem*)),
             this, SLOT(slotDoubleClicked(IconItem*)));
 
@@ -242,6 +245,21 @@
 
 void CameraIconView::slotDownloadNameChanged()
 {
+    bool hasSelection = false;
+    for (IconItem* item = firstItem(); item; item = item->nextItem())
+    {
+        if (item->isSelected())
+        {
+            hasSelection = true;
+            break;
+        }
+    }
+
+    slotUpdateDownloadNames(hasSelection);
+}
+
+void CameraIconView::slotUpdateDownloadNames(bool hasSelection)
+{
     bool useDefault = true;
     int  startIndex = 0;
 
@@ -256,18 +274,6 @@
 
     viewport()->setUpdatesEnabled(false);
 
-    bool hasSelection = false;
-    for (IconItem* item = firstItem(); item; item = item->nextItem())
-    {
-        if (item->isSelected())
-        {
-            hasSelection = true;
-            break;
-        }
-    }
-
-    emit signalNewSelection(hasSelection);
-
     if (hasSelection)
     {
         // Camera items selection.
@@ -330,12 +336,10 @@
             startIndex++;
         }
     }
-    
+
     rearrangeItems();
     viewport()->setUpdatesEnabled(true);
     viewport()->update();
-
-    slotSelectionChanged();
 }
 
 QString CameraIconView::getTemplatedName(const GPItemInfo* itemInfo, int position)
@@ -384,9 +388,8 @@
 {
     bool selected               = false;
     CameraIconViewItem* camItem = 0;
-    
-    for (IconItem* item = firstItem(); item;
-         item = item->nextItem())
+
+    for (IconItem* item = firstItem(); item; item = item->nextItem())
     {
         if (item->isSelected())
         {
@@ -396,7 +399,10 @@
         }
     }
 
+    emit signalNewSelection(selected);
     emit signalSelected(camItem, selected);
+
+    viewport()->update();
 }
 
 void CameraIconView::slotContextMenu(IconItem * item, const QPoint&)
--- trunk/extragear/graphics/digikam/utilities/cameragui/cameraiconview.h #586412:586413
@@ -107,6 +107,7 @@
     void slotContextMenu(IconItem* item, const QPoint& pos);
     void slotDoubleClicked(IconItem* item);
     void slotThemeChanged();
+    void slotUpdateDownloadNames(bool hasSelection);
 
 protected:
 
--- trunk/extragear/graphics/digikam/utilities/cameragui/cameraui.cpp #586412:586413
@@ -711,7 +711,8 @@
 
         d->advBox->setEnabled(true);
         // B.K.O #127614: The Focus need to be restored in custom prefix widget.
-        d->renameCustomizer->restoreFocus();
+        //commenting this out again:  If we do not disable, no need to restore focus
+        //d->renameCustomizer->restoreFocus();
 
         enableButton(User3, true);
         enableButton(User2, true);
@@ -738,7 +739,9 @@
 
         d->busy = true;
         d->cancelBtn->setEnabled(true);
-        d->advBox->setEnabled(false);
+        // Settings tab is disabled in slotDownload, selectively when downloading
+        // Fast dis/enabling would create the impression of flicker, e.g. when retrieving EXIF from camera
+        //d->advBox->setEnabled(false);
 
         enableButton(User3, false);
         enableButton(User2, false);
@@ -1183,6 +1186,10 @@
     d->progress->setProgress(0);
     d->progress->setTotalSteps(total);
     d->progress->show();
+
+    // disable settings tab here instead of slotBusy:
+    // Only needs to be disabled while downloading
+    d->advBox->setEnabled(false);
 }
 
 void CameraUI::slotDownloaded(const QString& folder, const QString& file, int status)