[PATCH] Related fdo#35546: Simplyfy Code in Photo Album Dialog
Samuel Mehrbrodt (via Code Review)
gerrit at gerrit.libreoffice.org
Sat May 11 08:57:55 PDT 2013
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 at gmail.com>
More information about the LibreOffice
mailing list