]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/dialogs/vlm.cpp
Qt4 - track destroying of VLM dialog because vlm object is NOT destroyed on exit.
[vlc] / modules / gui / qt4 / dialogs / vlm.cpp
index 554130ffb72f64760e2884ab7400163c3f227753..56307333afb9ea2e332cb6355aff5092189a8906 100644 (file)
@@ -2,7 +2,7 @@
  * vlm.cpp : VLM Management
  ****************************************************************************
  * Copyright © 2008 the VideoLAN team
- * $Id: sout.cpp 21875 2007-09-08 16:01:33Z jb $
+ * $Id$
  *
  * Authors: Jean-Baptiste Kempf <jb@videolan.org>
  *          Jean-François Massol <jf.massol -at- gmail.com>
@@ -51,6 +51,7 @@
 #include <QSpinBox>
 #include <QHeaderView>
 #include <QScrollArea>
+#include <QFileDialog>
 
 static const char *psz_type[] = { "Broadcast", "Schedule", "VOD" };
 
@@ -129,9 +130,16 @@ VLMDialog::VLMDialog( QWidget *parent, intf_thread_t *_p_intf ) : QVLCDialog( pa
         new QSpacerItem( 10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding);
     vlmItemLayout->addItem( spacer );
 
+    QPushButton *importButton = new QPushButton( qtr(  "Import" ) );
+    ui.buttonBox->addButton( importButton, QDialogButtonBox::ActionRole );
+
+    QPushButton *exportButton = new QPushButton( qtr( "Export" ) );
+    ui.buttonBox->addButton( exportButton, QDialogButtonBox::ActionRole );
+
     QPushButton *closeButton = new QPushButton( qtr( "Close" ) );
     ui.buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
 
+
     showScheduleWidget( QVLM_Broadcast );
 
     /* Connect the comboBox to show the right Widgets */
@@ -143,6 +151,8 @@ VLMDialog::VLMDialog( QWidget *parent, intf_thread_t *_p_intf ) : QVLCDialog( pa
              this, selectVLMItem( int ) );
 
     BUTTONACT( closeButton, close() );
+    BUTTONACT( exportButton, exportVLMConf() );
+    BUTTONACT( importButton, importVLMConf() );
     BUTTONACT( ui.addButton, addVLMItem() );
     BUTTONACT( ui.clearButton, clearWidgets() );
     BUTTONACT( ui.saveButton, saveModifications() );
@@ -154,6 +164,7 @@ VLMDialog::~VLMDialog()
 {
    /* FIXME :you have to destroy vlm here to close
     * but we shouldn't destroy vlm here in case somebody else wants it */
+    msg_Dbg( p_intf, "Destroying VLM Dialog" );
     if( p_vlm )
         vlm_Delete( p_vlm );
 }
@@ -245,6 +256,44 @@ void VLMDialog::addVLMItem()
     clearWidgets();
 }
 
+// FIXME : VOD are not exported to the file
+bool VLMDialog::exportVLMConf()
+{
+    QString saveVLMConfFileName = QFileDialog::getSaveFileName(
+            this, qtr( "Choose a filename to save the VLM configuration..." ),
+            qfu( p_intf->p_libvlc->psz_homedir ),
+            qtr( "VLM conf (*.vlm) ;; All (*.*)" ) );
+
+    if( !saveVLMConfFileName.isEmpty() )
+    {
+        vlm_message_t *message;
+        QString command = "save \"" + saveVLMConfFileName + "\"";
+        vlm_ExecuteCommand( p_vlm , qtu( command ) , &message );
+        vlm_MessageDelete( message );
+        return true;
+    }
+    return false;
+}
+
+
+bool VLMDialog::importVLMConf()
+{
+    QString openVLMConfFileName = QFileDialog::getOpenFileName(
+            this, qtr( "Choose a VLM configuration file to open..." ),
+            qfu( p_intf->p_libvlc->psz_homedir ),
+            qtr( "VLM conf (*.vlm) ;; All (*.*)" ) );
+
+    if( !openVLMConfFileName.isEmpty() )
+    {
+        vlm_message_t *message;
+        QString command = "load \"" + openVLMConfFileName + "\"";
+        vlm_ExecuteCommand( p_vlm, qtu( command ) , &message );
+        vlm_MessageDelete( message );
+        return true;
+    }
+    return false;
+}
+
 void VLMDialog::clearWidgets()
 {
     ui.nameLedit->clear();
@@ -262,7 +311,7 @@ void VLMDialog::clearWidgets()
 
 void VLMDialog::selectInput()
 {
-    OpenDialog *o = OpenDialog::getInstance( this, p_intf, 0, true );
+    OpenDialog *o = OpenDialog::getInstance( this, p_intf, SELECT, true );
     o->exec();
     ui.inputLedit->setText( o->getMRL() );
 }