[Libreoffice-commits] core.git: Branch 'feature/gsoc15-open-remote-files-dialog' - include/svtools svtools/source svtools/uiconfig
Szymon Kłos
eszkadev at gmail.com
Mon May 25 13:02:32 PDT 2015
include/svtools/RemoteFilesDialog.hxx | 4 +
svtools/source/dialogs/RemoteFilesDialog.cxx | 57 ++++++++++++++++++++++++++-
svtools/uiconfig/ui/remotefilesdialog.ui | 14 ++++++
3 files changed, 71 insertions(+), 4 deletions(-)
New commits:
commit 7f7675f740209caa28e5db1ecd39fc6b60dc9eb5
Author: Szymon Kłos <eszkadev at gmail.com>
Date: Mon May 25 21:59:01 2015 +0200
added services edit menu entry
Change-Id: Ic73e3d632296d61d1cdb5abdb54d9a74d841570d
diff --git a/include/svtools/RemoteFilesDialog.hxx b/include/svtools/RemoteFilesDialog.hxx
index 3ec915a..32c00aa 100644
--- a/include/svtools/RemoteFilesDialog.hxx
+++ b/include/svtools/RemoteFilesDialog.hxx
@@ -15,6 +15,7 @@
#include <svtools/PlaceEditDialog.hxx>
#include <vcl/button.hxx>
+#include <vcl/menubtn.hxx>
#include <vcl/lstbox.hxx>
#include <vcl/dialog.hxx>
#include <vcl/vclptr.hxx>
@@ -45,7 +46,7 @@ private:
VclPtr<PushButton> m_pOpen_btn;
VclPtr<PushButton> m_pSave_btn;
VclPtr<CancelButton> m_pCancel_btn;
- VclPtr<PushButton> m_pAddService_btn;
+ VclPtr<MenuButton> m_pAddService_btn;
VclPtr<ListBox> m_pServices_lb;
std::vector<ServicePtr> m_aServices;
@@ -53,6 +54,7 @@ private:
void fillServicesListbox();
DECL_LINK ( AddServiceHdl, void * );
+ DECL_LINK_TYPED ( EditServiceMenuHdl, MenuButton *, void );
};
#endif // INCLUDED_SVTOOLS_REMOTEFILESDIALOG_HXX
diff --git a/svtools/source/dialogs/RemoteFilesDialog.cxx b/svtools/source/dialogs/RemoteFilesDialog.cxx
index 28b153d..9b6a322 100644
--- a/svtools/source/dialogs/RemoteFilesDialog.cxx
+++ b/svtools/source/dialogs/RemoteFilesDialog.cxx
@@ -36,7 +36,9 @@ RemoteFilesDialog::RemoteFilesDialog(vcl::Window* pParent, WinBits nBits)
m_pOpen_btn->Hide();
}
- m_pAddService_btn->SetClickHdl( LINK( this, RemoteFilesDialog, AddServiceHdl) );
+ m_pAddService_btn->SetMenuMode(MENUBUTTON_MENUMODE_TIMED);
+ m_pAddService_btn->SetClickHdl( LINK( this, RemoteFilesDialog, AddServiceHdl ) );
+ m_pAddService_btn->SetSelectHdl( LINK( this, RemoteFilesDialog, EditServiceMenuHdl ) );
fillServicesListbox();
}
@@ -44,6 +46,7 @@ RemoteFilesDialog::RemoteFilesDialog(vcl::Window* pParent, WinBits nBits)
void RemoteFilesDialog::fillServicesListbox()
{
m_pServices_lb->Clear();
+ m_aServices.clear();
// Load from user settings
Sequence< OUString > placesUrlsList(officecfg::Office::Common::Misc::FilePickerPlacesUrls::get(m_context));
@@ -76,7 +79,8 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, AddServiceHdl )
ScopedVclPtrInstance< PlaceEditDialog > aDlg(this);
short aRetCode = aDlg->Execute();
- switch (aRetCode) {
+ switch(aRetCode)
+ {
case RET_OK :
{
ServicePtr newService = aDlg->GetPlace();
@@ -110,4 +114,53 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, AddServiceHdl )
return 1;
}
+IMPL_LINK_TYPED ( RemoteFilesDialog, EditServiceMenuHdl, MenuButton *, pButton, void )
+{
+ OString sIdent(pButton->GetCurItemIdent());
+ if(sIdent == "edit_service" && m_pServices_lb->GetEntryCount() > 0)
+ {
+ unsigned int nSelected = m_pServices_lb->GetSelectEntryPos();
+ ScopedVclPtrInstance< PlaceEditDialog > aDlg(this, m_aServices[nSelected]);
+ short aRetCode = aDlg->Execute();
+
+ switch(aRetCode)
+ {
+ case RET_OK :
+ {
+ // load all places (with local bookmarks), edit service and save all
+
+ ServicePtr pEditedService = aDlg->GetPlace();
+
+ Sequence< OUString > placesUrlsList(officecfg::Office::Common::Misc::FilePickerPlacesUrls::get(m_context));
+ Sequence< OUString > placesNamesList(officecfg::Office::Common::Misc::FilePickerPlacesNames::get(m_context));
+
+ for(int i = 0; i < placesUrlsList.getLength() && i < placesNamesList[i].getLength(); i++)
+ {
+ if(placesNamesList[i].compareTo(m_aServices[nSelected]->GetName()) == 0
+ && placesUrlsList[i].compareTo(m_aServices[nSelected]->GetUrl()) == 0)
+ {
+ placesUrlsList[i] = pEditedService->GetUrl();
+ placesNamesList[i] = pEditedService->GetName();
+ }
+ }
+
+ m_aServices[nSelected] = pEditedService;
+ m_pServices_lb->RemoveEntry(nSelected);
+ m_pServices_lb->InsertEntry(pEditedService->GetName(), nSelected);
+ m_pServices_lb->SelectEntryPos(nSelected);
+
+ std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(m_context));
+ officecfg::Office::Common::Misc::FilePickerPlacesUrls::set(placesUrlsList, batch);
+ officecfg::Office::Common::Misc::FilePickerPlacesNames::set(placesNamesList, batch);
+ batch->commit();
+ break;
+ }
+ case RET_CANCEL :
+ default :
+ // Do Nothing
+ break;
+ };
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/uiconfig/ui/remotefilesdialog.ui b/svtools/uiconfig/ui/remotefilesdialog.ui
index 5ada66d..c01ef56 100644
--- a/svtools/uiconfig/ui/remotefilesdialog.ui
+++ b/svtools/uiconfig/ui/remotefilesdialog.ui
@@ -103,7 +103,7 @@
</packing>
</child>
<child>
- <object class="GtkButton" id="add_service_btn">
+ <object class="GtkButton" id="add_service_btn:service_edit_menu">
<property name="label" translatable="yes">Add service</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -128,4 +128,16 @@
</object>
</child>
</object>
+ <object class="GtkMenu" id="service_edit_menu">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkMenuItem" id="edit_service">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_Edit service</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ </object>
</interface>
More information about the Libreoffice-commits
mailing list