Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/3855

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/55/3855/1

Related fdo#35546: Simplyfy Code in Photo Album Dialog

Create a method for enabling/disabling the Up/Down/Remove buttons.
This also fixes some wrong behavior.

Change-Id: Ie40a4f3bb4402b988071b315617404c802b7e92a
---
M sd/source/ui/dlg/PhotoAlbumDialog.cxx
M sd/source/ui/dlg/PhotoAlbumDialog.hxx
2 files changed, 17 insertions(+), 71 deletions(-)



diff --git a/sd/source/ui/dlg/PhotoAlbumDialog.cxx b/sd/source/ui/dlg/PhotoAlbumDialog.cxx
index 2771166..351a9d8 100644
--- a/sd/source/ui/dlg/PhotoAlbumDialog.cxx
+++ b/sd/source/ui/dlg/PhotoAlbumDialog.cxx
@@ -597,19 +597,6 @@
                 OSL_FAIL("Could not find config for Create Photo Album function");
             }
 
-            if( aFilesArr.getLength() == 1)
-            {
-                pRemoveBtn->Enable();
-                pUpBtn->Disable();
-                pDownBtn->Disable();
-            }
-            else
-            {
-                pRemoveBtn->Enable();
-                pUpBtn->Enable();
-                pDownBtn->Enable();
-            }
-
             for ( sal_Int32 i = 0; i < aFilesArr.getLength(); i++ )
             {
                 // Store full path, show filename only. Use INetURLObject to display spaces in 
filename correctly
@@ -619,6 +606,7 @@
             }
         }
     }
+    EnableDisableButtons();
     return 0;
 }
 
@@ -634,12 +622,7 @@
     OUString sStr(SD_RESSTR(STR_PHOTO_ALBUM_TEXTBOX));
     pImagesLst->SetEntryData(nPos, (void*)new OUString(sStr));
 
-    if(pImagesLst->GetEntryCount() >= 1)
-    {
-        pRemoveBtn->Enable();
-        pUpBtn->Disable();
-        pDownBtn->Disable();
-    }
+    EnableDisableButtons();
     return 0;
 }
 
@@ -669,16 +652,9 @@
         pImagesLst->SetEntryData( nActPos, (void*) new OUString(sUpper));
 
         pImagesLst->SelectEntryPos(nActPos - 1);
-
-        pDownBtn->Enable();
-
     }
 
-    if(pImagesLst->GetSelectEntryPos() == 0)
-    {
-        pDownBtn->Enable();
-        pUpBtn->Disable();
-    }
+    EnableDisableButtons();
     return 0;
 }
 
@@ -707,16 +683,7 @@
         pImagesLst->SelectEntryPos(nActPos + 1);
 
     }
-
-    if(pImagesLst->GetEntry(pImagesLst->GetSelectEntryPos() + 1) != OUString(""))
-    {
-        pDownBtn->Enable();
-        pUpBtn->Enable();
-    }
-    else
-    {
-        pDownBtn->Disable();
-    }
+    EnableDisableButtons();
     return 0;
 }
 
@@ -725,18 +692,7 @@
     pImagesLst->RemoveEntry( pImagesLst->GetSelectEntryPos() );
     pImg->SetImage(Image());
 
-    if(pImagesLst->GetEntryCount() >= 1)
-    {
-        pRemoveBtn->Enable();
-        pUpBtn->Disable();
-        pDownBtn->Disable();
-    }
-    else
-    {
-        pRemoveBtn->Disable();
-        pUpBtn->Disable();
-        pDownBtn->Disable();
-    }
+    EnableDisableButtons();
     return 0;
 }
 
@@ -744,27 +700,6 @@
 {
     OUString* pData = (OUString*) pImagesLst->GetEntryData(pImagesLst->GetSelectEntryPos());
     OUString sImgUrl = pData ? OUString(*pData) : "";
-    // Some UI functionality: if you select the first/last item in the list,
-    // the Up/Down button gets enabled/diabled (meaning: you cannot move up/down the item)
-    // disable/enable moving up
-    if(pImagesLst->GetSelectEntryPos() == 0)
-    {
-        pUpBtn->Disable();
-    }
-    else
-    {
-        pUpBtn->Enable();
-    }
-
-    // disable/enable moving down
-    if(pImagesLst->GetEntry(pImagesLst->GetSelectEntryPos() + 1) == OUString(""))
-    {
-        pDownBtn->Disable();
-    }
-    else
-    {
-        pDownBtn->Enable();
-    }
 
     if (sImgUrl != SD_RESSTR(STR_PHOTO_ALBUM_TEXTBOX))
     {
@@ -817,7 +752,7 @@
     {
         pImg->SetImage(Image());
     }
-
+    EnableDisableButtons();
     return 0;
 }
 
@@ -893,6 +828,15 @@
     return ModalDialog::Execute();
 }
 
+void SdPhotoAlbumDialog::EnableDisableButtons()
+{
+    pRemoveBtn->Enable(pImagesLst->GetSelectEntryCount() > 0);
+    pUpBtn->Enable(pImagesLst->GetSelectEntryCount() > 0 &&
+                   pImagesLst->GetSelectEntryPos() != 0);
+    pDownBtn->Enable(pImagesLst->GetSelectEntryCount() > 0 &&
+                     pImagesLst->GetSelectEntryPos() < pImagesLst->GetEntryCount()-1);
+}
+
 
 } // end of namespace sd
 
diff --git a/sd/source/ui/dlg/PhotoAlbumDialog.hxx b/sd/source/ui/dlg/PhotoAlbumDialog.hxx
index 9a68ba9..3e75128 100644
--- a/sd/source/ui/dlg/PhotoAlbumDialog.hxx
+++ b/sd/source/ui/dlg/PhotoAlbumDialog.hxx
@@ -93,6 +93,8 @@
     Reference< graphic::XGraphic> createXGraphicFromUrl(const OUString& sUrl,
         Reference< graphic::XGraphicProvider> xProvider);
 
+    void EnableDisableButtons();
+
     enum SlideImageLayout
     {
         FIT_TO_SLIDE=0,

-- 
To view, visit https://gerrit.libreoffice.org/3855
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie40a4f3bb4402b988071b315617404c802b7e92a
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Samuel Mehrbrodt <s.mehrbrodt@gmail.com>


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.