[Libreoffice-commits] core.git: Branch 'feature/gsoc15-open-remote-files-dialog' - include/svtools svtools/source

Szymon Kłos eszkadev at gmail.com
Mon Jul 20 07:03:21 PDT 2015


 include/svtools/PlaceEditDialog.hxx        |    4 +++
 include/svtools/svtools.hrc                |    3 ++
 svtools/source/dialogs/PlaceEditDialog.cxx |   37 ++++++++++++++++++++++++++++-
 svtools/source/dialogs/filedlg2.src        |    6 ++++
 4 files changed, 49 insertions(+), 1 deletion(-)

New commits:
commit 109425e49ce257a9464ec49f5237f24c2b2c0c36
Author: Szymon Kłos <eszkadev at gmail.com>
Date:   Mon Jul 20 16:01:09 2015 +0200

    default label for service
    
    Change-Id: Iad4ad161765c943a035dcc15232c4dcbef1cc68c

diff --git a/include/svtools/PlaceEditDialog.hxx b/include/svtools/PlaceEditDialog.hxx
index 9cba4d5..0ba26b7 100644
--- a/include/svtools/PlaceEditDialog.hxx
+++ b/include/svtools/PlaceEditDialog.hxx
@@ -53,6 +53,8 @@ private :
 
     unsigned int m_nCurrentType;
 
+    bool bLabelChanged;
+
 public :
 
      PlaceEditDialog( vcl::Window* pParent);
@@ -69,11 +71,13 @@ public :
 private:
 
     void InitDetails( );
+    void UpdateLabel( );
 
     DECL_LINK ( OKHdl, Button * );
     DECL_LINK ( DelHdl, Button * );
     DECL_LINK ( EditHdl, void * );
     DECL_LINK ( SelectTypeHdl, void * );
+    DECL_LINK ( EditLabelHdl, void * );
     DECL_LINK ( EditUsernameHdl, void * );
 
 };
diff --git a/include/svtools/svtools.hrc b/include/svtools/svtools.hrc
index 23cf007..5ddb4dd 100644
--- a/include/svtools/svtools.hrc
+++ b/include/svtools/svtools.hrc
@@ -51,6 +51,9 @@
 #define STR_SVT_ESTIMATED_SIZE_VEC      (RID_SVTOOLS_START + 41)
 
 // FREE
+
+#define STR_SVT_DEFAULT_SERVICE_LABEL   (RID_SVTOOLS_START+57)
+
 #define STRARY_SVT_DOCINFO              (RID_SVTOOLS_START+58)
 
 #define STR_BASICKEY_FORMAT_ON          (RID_SVTOOLS_START+103)
diff --git a/svtools/source/dialogs/PlaceEditDialog.cxx b/svtools/source/dialogs/PlaceEditDialog.cxx
index 15034dd..cb90be7 100644
--- a/svtools/source/dialogs/PlaceEditDialog.cxx
+++ b/svtools/source/dialogs/PlaceEditDialog.cxx
@@ -13,6 +13,7 @@
 #include <com/sun/star/uno/Sequence.hxx>
 #include <officecfg/Office/Common.hxx>
 #include <svtools/svtresid.hxx>
+#include <svtools/svtools.hrc>
 #include <vcl/msgbox.hxx>
 
 using namespace com::sun::star::uno;
@@ -21,6 +22,7 @@ PlaceEditDialog::PlaceEditDialog(vcl::Window* pParent)
     : ModalDialog(pParent, "PlaceEditDialog", "svt/ui/placeedit.ui")
     , m_xCurrentDetails()
     , m_nCurrentType( 0 )
+    , bLabelChanged( false )
 {
     get( m_pEDServerName, "name" );
     get( m_pLBServerType, "type" );
@@ -33,7 +35,7 @@ PlaceEditDialog::PlaceEditDialog(vcl::Window* pParent)
     m_pBTOk->SetClickHdl( LINK( this, PlaceEditDialog, OKHdl) );
     m_pBTOk->Enable( false );
 
-    m_pEDServerName->SetModifyHdl( LINK( this, PlaceEditDialog, EditHdl) );
+    m_pEDServerName->SetModifyHdl( LINK( this, PlaceEditDialog, EditLabelHdl) );
 
     // This constructor is called when user request a place creation, so
     // delete button is hidden.
@@ -48,6 +50,7 @@ PlaceEditDialog::PlaceEditDialog(vcl::Window* pParent)
 PlaceEditDialog::PlaceEditDialog(vcl::Window* pParent, const std::shared_ptr<Place>& rPlace)
     : ModalDialog(pParent, "PlaceEditDialog", "svt/ui/placeedit.ui")
     , m_xCurrentDetails( )
+    , bLabelChanged( true )
 {
     get( m_pEDServerName, "name" );
     get( m_pLBServerType, "type" );
@@ -188,6 +191,26 @@ void PlaceEditDialog::InitDetails( )
     SelectTypeHdl( m_pLBServerType );
 }
 
+void PlaceEditDialog::UpdateLabel( )
+{
+    if( !bLabelChanged )
+    {
+        if( !m_pEDUsername->GetText().isEmpty( ) )
+        {
+            OUString sLabel = SvtResId( STR_SVT_DEFAULT_SERVICE_LABEL );
+            sLabel = sLabel.replaceFirst( "$user$", m_pEDUsername->GetText() );
+            sLabel = sLabel.replaceFirst( "$service$", m_pLBServerType->GetSelectEntry() );
+
+            m_pEDServerName->SetText( sLabel );
+            bLabelChanged = false;
+        }
+        else
+        {
+            m_pEDServerName->SetText( m_pLBServerType->GetSelectEntry( ) );
+        }
+    }
+}
+
 IMPL_LINK ( PlaceEditDialog,  OKHdl, Button *, )
 {
     if ( m_xCurrentDetails.get() )
@@ -234,12 +257,22 @@ IMPL_LINK ( PlaceEditDialog, DelHdl, Button *, )
 
 IMPL_LINK_NOARG( PlaceEditDialog, EditHdl )
 {
+    UpdateLabel( );
+
     OUString sUrl = GetServerUrl( );
     OUString sName = OUString( m_pEDServerName->GetText() ).trim( );
     m_pBTOk->Enable( !sName.isEmpty( ) && !sUrl.isEmpty( ) );
     return 1;
 }
 
+IMPL_LINK_NOARG( PlaceEditDialog, EditLabelHdl )
+{
+    bLabelChanged = true;
+    EditHdl(NULL);
+
+    return 1;
+}
+
 IMPL_LINK_NOARG( PlaceEditDialog, EditUsernameHdl )
 {
     for ( std::vector< std::shared_ptr< DetailsContainer > >::iterator it = m_aDetailsContainers.begin( );
@@ -247,7 +280,9 @@ IMPL_LINK_NOARG( PlaceEditDialog, EditUsernameHdl )
     {
         ( *it )->setUsername( OUString( m_pEDUsername->GetText() ) );
     }
+
     EditHdl(NULL);
+
     return 1;
 }
 
diff --git a/svtools/source/dialogs/filedlg2.src b/svtools/source/dialogs/filedlg2.src
index 6e68db0..795da0e 100644
--- a/svtools/source/dialogs/filedlg2.src
+++ b/svtools/source/dialogs/filedlg2.src
@@ -18,6 +18,7 @@
  */
 
 #include <svtools/filedlg2.hrc>
+#include <svtools/svtools.hrc>
 
 String STR_FILEDLG_OPEN
 {
@@ -32,4 +33,9 @@ String STR_FILEDLG_SAVE
     Text [ en-US ] = "Save" ;
 };
 
+String STR_SVT_DEFAULT_SERVICE_LABEL
+{
+    Text [ en-US ] = "$user$'s $service$" ;
+};
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list