[vlc-commits] qt: add load/save config to VLMWrapper

Rémi Denis-Courmont git at videolan.org
Sun Jul 23 18:58:08 CEST 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Jul 23 18:52:34 2017 +0300| [83e5a17fe3f879cae759940e9655ac6c8f667bfb] | committer: Rémi Denis-Courmont

qt: add load/save config to VLMWrapper

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=83e5a17fe3f879cae759940e9655ac6c8f667bfb
---

 modules/gui/qt/dialogs/vlm.cpp | 34 +++++++++++++++++++++++-----------
 modules/gui/qt/dialogs/vlm.hpp |  3 +++
 2 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/modules/gui/qt/dialogs/vlm.cpp b/modules/gui/qt/dialogs/vlm.cpp
index 205069445f..2484776433 100644
--- a/modules/gui/qt/dialogs/vlm.cpp
+++ b/modules/gui/qt/dialogs/vlm.cpp
@@ -273,10 +273,7 @@ bool VLMDialog::exportVLMConf()
 
     if( !saveVLMConfFileName.isEmpty() )
     {
-        vlm_message_t *message;
-        QString command = "save \"" + saveVLMConfFileName + "\"";
-        vlm_ExecuteCommand( p_vlm , qtu( command ) , &message );
-        vlm_MessageDelete( message );
+        VLMWrapper::SaveConfig( saveVLMConfFileName );
         return true;
     }
 
@@ -347,18 +344,13 @@ bool VLMDialog::importVLMConf()
 
     if( !openVLMConfFileName.isEmpty() )
     {
-        vlm_message_t *message;
-        int status;
-        QString command = "load \"" + openVLMConfFileName + "\"";
-        status = vlm_ExecuteCommand( p_vlm, qtu( command ) , &message );
-        vlm_MessageDelete( message );
-        if( status == 0 )
+        if( VLMWrapper::LoadConfig( openVLMConfFileName ) )
         {
             mediasPopulator();
         }
         else
         {
-            msg_Warn( p_intf, "Failed to import vlm configuration file : %s", qtu( command ) );
+            msg_Warn( p_intf, "Failed to import vlm configuration file : %s", qtu( openVLMConfFileName ) );
             return false;
         }
         return true;
@@ -894,6 +886,26 @@ void VLMWrapper::EditSchedule( const QString& name, const QString& input,
     }
 }
 
+void VLMWrapper::SaveConfig( const QString& filename )
+{
+    /* FIXME: escaping */
+    QString command = "save \"" + filename + "\"";
+    vlm_message_t *message;
+
+    vlm_ExecuteCommand( p_vlm , qtu( command ), &message );
+    vlm_MessageDelete( message );
+}
+
+bool VLMWrapper::LoadConfig( const QString& filename )
+{
+    /* FIXME: escaping */
+    QString command = "load \"" + filename + "\"";
+    vlm_message_t *message;
+    int status = vlm_ExecuteCommand( p_vlm, qtu( command ) , &message );
+    vlm_MessageDelete( message );
+    return status == 0;
+}
+
 void VLMDialog::toggleVisible()
 {
     qDeleteAll( vlmItems );
diff --git a/modules/gui/qt/dialogs/vlm.hpp b/modules/gui/qt/dialogs/vlm.hpp
index 351c52c84e..2f31de2a40 100644
--- a/modules/gui/qt/dialogs/vlm.hpp
+++ b/modules/gui/qt/dialogs/vlm.hpp
@@ -140,6 +140,9 @@ public:
     static void ControlBroadcast( const QString&, int, unsigned int seek = 0 );
     static void EnableItem( const QString&, bool );
 
+    static void SaveConfig( const QString& );
+    static bool LoadConfig( const QString& );
+
     /* We don't have yet the accessors in the core, so the following is commented */
     //unsigned int NbMedia() { if( p_vlm ) return p_vlm->i_media; return 0; }
    /* vlm_media_t *GetMedia( int i )



More information about the vlc-commits mailing list