Bug 263554

Summary: Saving a new contact group doesn't close dialog immediately
Product: [Applications] KAddressbook Mobile Reporter: Bjoern Ricks <bjoern.ricks>
Component: generalAssignee: Ludwig Reiter <ludwig.reiter>
Status: VERIFIED FIXED    
Severity: normal CC: aheinecke, andreas.holzammer
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Windows CE   
OS: Microsoft Windows CE   
Latest Commit: Version Fixed In:
Attachments: screenshots

Description Bjoern Ricks 2011-01-18 16:06:09 UTC
Steps to reproduce
1) Open kaddressbook mobile
2) Click on New Contact Group
3) Add a name for the contact group
4) Choose IMAP Folder as location to save the contact group
5) Click on save icon

The dialog isn't closed immediately and the user doesn't get any feedback if the new contact group was created. Therefore it's possible to click several times on the save icon which results in several contact groups are created. One for each click. After some time the dialog is closed automatically.
Comment 1 Andreas Holzammer 2011-01-19 16:34:55 UTC
Created attachment 56194 [details]
screenshots
Comment 2 Andreas Holzammer 2011-01-19 16:37:28 UTC
(In reply to comment #1)
> Created an attachment (id=56194) [details]
> screenshots

whoops wrong bug report.
Comment 3 Tobias Koenig 2011-01-19 17:09:02 UTC
commit 629f2adb85b881d46af3531f9a51d10fd167dae4
branch master
Author: Tobias Koenig <tokoe@kde.org>
Date:   Wed Jan 19 17:10:17 2011 +0100

    Disable 'Save' buttons after click
    
    Since the ContactEditor and ContactGroupEditor might need some
    time to finish saving, we should prevent the user from clicking
    save multiple times, otherwise the contact (group) is created multiple
    times as well.
    
    BUG: 263554

diff --git a/mobile/contacts/editorcontactgroup.cpp b/mobile/contacts/editorcontactgroup.cpp
index cac0f4a..0f38c5c 100644
--- a/mobile/contacts/editorcontactgroup.cpp
+++ b/mobile/contacts/editorcontactgroup.cpp
@@ -110,6 +110,11 @@ class EditorContactGroup::Private
       mUi.launchAccountWizardButton->setVisible( !available );
     }
 
+    void disableSaveButton()
+    {
+      mUi.saveButton->setEnabled( false );
+    }
+
   private:
     void addRows( int newRowCount );
 };
@@ -227,6 +232,7 @@ EditorContactGroup::EditorContactGroup( QWidget *parent )
   connect( d->mUi.addRecipientButton, SIGNAL( clicked() ), SLOT( addRecipientClicked() ) );
 
   connect( d->mUi.cancelButton, SIGNAL( clicked() ), SIGNAL( cancelClicked() ) );
+  connect( d->mUi.saveButton, SIGNAL( clicked() ), SLOT( disableSaveButton() ) ); // prevent double clicks
   connect( d->mUi.saveButton, SIGNAL( clicked() ), SIGNAL( saveClicked() ) );
   connect( d->mUi.collectionSelector, SIGNAL( currentChanged( Akonadi::Collection ) ),
            SIGNAL( collectionChanged( Akonadi::Collection ) ) );
diff --git a/mobile/contacts/editorcontactgroup.h b/mobile/contacts/editorcontactgroup.h
index 156d84f..b147ba3 100644
--- a/mobile/contacts/editorcontactgroup.h
+++ b/mobile/contacts/editorcontactgroup.h
@@ -67,6 +67,7 @@ class EditorContactGroup : public QWidget
     Q_PRIVATE_SLOT( d, void fetchResult( KJob* ) )
     Q_PRIVATE_SLOT( d, void clearRecipientClicked() )
     Q_PRIVATE_SLOT( d, void availableCollectionsChanged() )
+    Q_PRIVATE_SLOT( d, void disableSaveButton() )
 };
 
 #endif
diff --git a/mobile/contacts/editorgeneral.cpp b/mobile/contacts/editorgeneral.cpp
index 99ff880..bfe3677 100644
--- a/mobile/contacts/editorgeneral.cpp
+++ b/mobile/contacts/editorgeneral.cpp
@@ -125,6 +125,11 @@ class EditorGeneral::Private
       mUi.launchAccountWizardButton->setVisible( !available );
     }
 
+    void disableSaveButton()
+    {
+      mUi.saveButton->setEnabled( false );
+    }
+
   private:
     void addEmailRows( int newRowCount );
     void addPhoneRows( int newRowCount );
@@ -341,6 +346,7 @@ EditorGeneral::EditorGeneral( QWidget *parent )
 
   connect( d->mUi.addPhoneButton, SIGNAL( clicked() ), SLOT( addPhoneClicked() ) );
 
+  connect( d->mUi.saveButton, SIGNAL( clicked() ), SLOT( disableSaveButton() ) ); // prevent double clicks
   connect( d->mUi.saveButton, SIGNAL( clicked() ), SIGNAL( saveClicked() ) );
   connect( d->mUi.cancelButton, SIGNAL( clicked() ), SIGNAL( cancelClicked() ) );
   connect( d->mUi.collectionSelector, SIGNAL( currentChanged( Akonadi::Collection ) ),
diff --git a/mobile/contacts/editorgeneral.h b/mobile/contacts/editorgeneral.h
index 781c057..c01c8a9 100644
--- a/mobile/contacts/editorgeneral.h
+++ b/mobile/contacts/editorgeneral.h
@@ -66,6 +66,7 @@ class EditorGeneral : public EditorBase
     Q_PRIVATE_SLOT( d, void clearEmailClicked() )
     Q_PRIVATE_SLOT( d, void clearPhoneClicked() )
     Q_PRIVATE_SLOT( d, void availableCollectionsChanged() )
+    Q_PRIVATE_SLOT( d, void disableSaveButton() )
 };
 
 #endif