]> git.sesse.net Git - vlc/commitdiff
Some more Qt interaction support
authorClément Stenac <zorglub@videolan.org>
Wed, 19 Jul 2006 15:17:23 +0000 (15:17 +0000)
committerClément Stenac <zorglub@videolan.org>
Wed, 19 Jul 2006 15:17:23 +0000 (15:17 +0000)
modules/gui/qt4/Modules.am
modules/gui/qt4/components/preferences.cpp
modules/gui/qt4/dialogs/interaction.cpp
modules/gui/qt4/dialogs/interaction.hpp
modules/gui/qt4/qt4.cpp
modules/gui/qt4/ui/inputdialog.ui [new file with mode: 0644]
modules/gui/qt4/ui/logindialog.ui [new file with mode: 0644]
modules/gui/qt4/ui/progressdialog.ui [new file with mode: 0644]
modules/gui/qt4/ui/yesnocanceldialog.ui [new file with mode: 0644]

index 753195d7973ad664a51ff28c5f8c3790e9a192d7..a9fe9d8eff0aea6bf370b43bc2f886811876f4b6 100644 (file)
@@ -12,7 +12,8 @@
 AUTOMAKE_OPTIONS = subdir-objects
 
 TOUI = ui/input_stats ui/main_interface ui/file_open \
-       ui/okcanceldialog
+       ui/okcanceldialog ui/yesnocanceldialog ui/logindialog ui/inputdialog \
+    ui/progressdialog
 UIH = $(TOUI:%=%.h)
 
 TOMOC = main_interface \
@@ -119,6 +120,10 @@ EXTRA_DIST += \
        ui/file_open.ui \
        ui/main_interface.ui \
        ui/okcanceldialog.ui \
+    ui/yesnocanceldialog.ui \
+    ui/logindialog.ui \
+    ui/inputdialog.ui \
+    ui/progressdialog.ui \
        pixmaps/advanced.xpm \
        pixmaps/audio.xpm \
        pixmaps/codec.xpm \
index 6b9aa382cae473aae814d4983cd257a9ed54a1e4..4c438d5e9ea57967dedefe53201d3590c5725c61 100644 (file)
@@ -317,7 +317,7 @@ PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
                         QWidget( _parent ), p_intf( _p_intf )
 {
     module_config_t *p_item;
-    module_t *p_module;
+    module_t *p_module = NULL;
     vlc_list_t *p_list = NULL;
     global_layout = new QVBoxLayout();
 
index 6314ff68960e305cb972ffa91b0bfa0bbe3bf09c..36727c19041cb863bd37ce580bebac06ff7ce445 100644 (file)
 
 #include "dialogs/interaction.hpp"
 #include <vlc/intf.h>
+#include "qt4.hpp"
 
 InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
-                                      interaction_dialog_t *_p_dialog ) :
-                                        p_intf( _p_intf), p_dialog( _p_dialog )
+                         interaction_dialog_t *_p_dialog ) : QWidget( 0 ),
+                          p_intf( _p_intf), p_dialog( _p_dialog )
 {
+    uiOkCancel = NULL;
+    uiYesNoCancel = NULL;
+    uiLogin = NULL;
+    uiProgress = NULL;
+    uiInput = NULL;
+
     if( p_dialog->i_flags & DIALOG_YES_NO_CANCEL )
     {
         uiOkCancel = new Ui::OKCancelDialog;
         uiOkCancel->setupUi( this );
-        uiOkCancel->description->setText( p_dialog->psz_description );
+        uiOkCancel->description->setText( qfu(p_dialog->psz_description) );
         connect( uiOkCancel->okButton, SIGNAL( clicked() ),
                  this, SLOT( OK() ) );
         connect( uiOkCancel->cancelButton, SIGNAL( clicked() ),
@@ -39,11 +46,25 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
     }
     else if( p_dialog->i_flags & DIALOG_YES_NO_CANCEL )
     {
-      
+        uiYesNoCancel = new Ui::YesNoCancelDialog;      
+        uiYesNoCancel->setupUi( this );
+        uiYesNoCancel->description->setText( qfu(p_dialog->psz_description) );
+        connect( uiYesNoCancel->yesButton, SIGNAL( clicked() ),
+                 this, SLOT( yes() ) );
+        connect( uiYesNoCancel->noButton, SIGNAL( clicked() ),
+                 this, SLOT( no() ) );
+        connect( uiYesNoCancel->cancelButton, SIGNAL( clicked() ),
+                 this, SLOT( cancel() ) );
     }
     else if( p_dialog->i_flags & DIALOG_LOGIN_PW_OK_CANCEL )
     {
-
+        uiLogin = new Ui::LoginDialog;
+        uiLogin->setupUi( this );
+        uiLogin->description->setText( qfu(p_dialog->psz_description) );
+        connect( uiLogin->okButton, SIGNAL( clicked() ),
+                 this, SLOT( OK() ) );
+        connect( uiLogin->cancelButton, SIGNAL( clicked() ),
+                 this, SLOT( cancel() ) );
     }
     else if( p_dialog->i_flags & DIALOG_USER_PROGRESS )
     {
@@ -54,6 +75,7 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
     }
     else
         msg_Err( p_intf, "unknown dialog type" );
+    setWindowTitle( qfu( p_dialog->psz_title ) );
 }
 
 void InteractionDialog::Update()
@@ -62,24 +84,49 @@ void InteractionDialog::Update()
 
 InteractionDialog::~InteractionDialog()
 {
+    if( uiYesNoCancel ) delete uiYesNoCancel;
+    if( uiOkCancel ) delete uiOkCancel;
+    if( uiInput ) delete uiInput;
+    if( uiProgress) delete uiProgress;
+    if( uiLogin ) delete uiLogin;
 }
 
+void InteractionDialog::yes()
+{
+    Finish( DIALOG_OK_YES );
+}
+void InteractionDialog::no()
+{
+    Finish( DIALOG_NO );
+}
 void InteractionDialog::OK()
 {
-    Finish( DIALOG_OK_YES, NULL, NULL );
+    Finish( DIALOG_OK_YES );
 }
 
 void InteractionDialog::cancel()
 {
-    Finish( DIALOG_CANCELLED, NULL, NULL );
+    Finish( DIALOG_CANCELLED );
 }
 
-void InteractionDialog::Finish( int i_ret, QString *r1, QString *r2 )
+void InteractionDialog::Finish( int i_ret )
 {
-   vlc_mutex_lock( &p_dialog->p_interaction->object_lock ); 
+    vlc_mutex_lock( &p_dialog->p_interaction->object_lock ); 
 
-   p_dialog->i_status = ANSWERED_DIALOG;
-   p_dialog->i_return = i_ret;
-   hide();
-   vlc_mutex_unlock( &p_dialog->p_interaction->object_lock ); 
+    if( p_dialog->i_flags & DIALOG_LOGIN_PW_OK_CANCEL )
+    {
+        p_dialog->psz_returned[0] = strdup(
+                               uiLogin->loginEdit->text().toUtf8().data() );
+        p_dialog->psz_returned[1] = strdup(
+                               uiLogin->passwordEdit->text().toUtf8().data() );
+    }
+    else if( p_dialog->i_flags & DIALOG_PSZ_INPUT_OK_CANCEL )
+    {
+        p_dialog->psz_returned[0] = strdup(
+                               uiInput->inputEdit->text().toUtf8().data() );
+    }
+    p_dialog->i_status = ANSWERED_DIALOG;
+    p_dialog->i_return = i_ret;
+    hide();
+    vlc_mutex_unlock( &p_dialog->p_interaction->object_lock ); 
 }
index ca56e11883f93ac9473cd051fea6e6b9732b825e..ef658a97460bec443e9b33ae47d0873a880e5ad6 100644 (file)
 
 #include <vlc/vlc.h>
 #include <vlc_interaction.h>
+#undef Q_
 #include <ui/okcanceldialog.h>
+#undef Q_
+#include <ui/yesnocanceldialog.h>
+#undef Q_
+#include <ui/inputdialog.h>
+#undef Q_
+#include <ui/logindialog.h>
+#undef Q_
+#include <ui/progressdialog.h>
+#undef Q_
 
 class InteractionDialog : public QWidget
 {
@@ -40,10 +50,16 @@ private:
     intf_thread_t *p_intf;
     interaction_dialog_t *p_dialog;
     Ui::OKCancelDialog *uiOkCancel;
+    Ui::YesNoCancelDialog *uiYesNoCancel;
+    Ui::LoginDialog *uiLogin;
+    Ui::InputDialog *uiInput;
+    Ui::ProgressDialog *uiProgress;
 
-    void Finish( int, QString *, QString * );
+    void Finish( int );
 private slots:
     void OK();
+    void yes();
+    void no();
     void cancel();
 };
 
index 49e6c08736909ed532a12ff161dbe567f81388cb..1f97fe56743d4c5ea07676f703c07dc3d50fdac8 100644 (file)
@@ -154,3 +154,16 @@ static void ShowDialog( intf_thread_t *p_intf, int i_dialog_event, int i_arg,
     QApplication::postEvent( DialogsProvider::getInstance( p_intf ),
                              static_cast<QEvent*>(event) );
 }
+
+/*****************************************************************************
+ * PopupMenuCB: callback to show the popupmenu.
+ *  We don't show the menu directly here because we don't want the
+ *  caller to block for a too long time.
+ *****************************************************************************/
+static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
+                        vlc_value_t old_val, vlc_value_t new_val, void *param )
+{
+    intf_thread_t *p_intf = (intf_thread_t *)param;
+    ShowDialog( p_intf, INTF_DIALOG_POPUPMENU, new_val.b_bool, 0 );
+    return VLC_SUCCESS;
+}
diff --git a/modules/gui/qt4/ui/inputdialog.ui b/modules/gui/qt4/ui/inputdialog.ui
new file mode 100644 (file)
index 0000000..8508c53
--- /dev/null
@@ -0,0 +1,74 @@
+<ui version="4.0" >
+ <author></author>
+ <comment></comment>
+ <exportmacro></exportmacro>
+ <class>InputDialog</class>
+ <widget class="QWidget" name="InputDialog" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>409</width>
+    <height>89</height>
+   </rect>
+  </property>
+  <layout class="QVBoxLayout" >
+   <property name="margin" >
+    <number>9</number>
+   </property>
+   <property name="spacing" >
+    <number>6</number>
+   </property>
+   <item>
+    <widget class="QLabel" name="description" >
+     <property name="text" >
+      <string/>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QLineEdit" name="inputEdit" />
+   </item>
+   <item>
+    <layout class="QHBoxLayout" >
+     <property name="margin" >
+      <number>0</number>
+     </property>
+     <property name="spacing" >
+      <number>6</number>
+     </property>
+     <item>
+      <spacer>
+       <property name="orientation" >
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" >
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QPushButton" name="okButton" >
+       <property name="text" >
+        <string>OK</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="cancelButton" >
+       <property name="text" >
+        <string>Cancel</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <pixmapfunction></pixmapfunction>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/modules/gui/qt4/ui/logindialog.ui b/modules/gui/qt4/ui/logindialog.ui
new file mode 100644 (file)
index 0000000..a2e9586
--- /dev/null
@@ -0,0 +1,101 @@
+<ui version="4.0" >
+ <author></author>
+ <comment></comment>
+ <exportmacro></exportmacro>
+ <class>LoginDialog</class>
+ <widget class="QWidget" name="LoginDialog" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>409</width>
+    <height>129</height>
+   </rect>
+  </property>
+  <layout class="QVBoxLayout" >
+   <property name="margin" >
+    <number>9</number>
+   </property>
+   <property name="spacing" >
+    <number>6</number>
+   </property>
+   <item>
+    <layout class="QGridLayout" >
+     <property name="margin" >
+      <number>0</number>
+     </property>
+     <property name="spacing" >
+      <number>6</number>
+     </property>
+     <item row="1" column="0" >
+      <widget class="QLabel" name="label" >
+       <property name="text" >
+        <string>Login</string>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="1" >
+      <widget class="QLineEdit" name="loginEdit" />
+     </item>
+     <item row="2" column="0" >
+      <widget class="QLabel" name="label_2" >
+       <property name="text" >
+        <string>Password</string>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="1" >
+      <widget class="QLineEdit" name="passwordEdit" />
+     </item>
+     <item row="0" column="0" colspan="2" >
+      <widget class="QLabel" name="description" >
+       <property name="text" >
+        <string/>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" >
+     <property name="margin" >
+      <number>0</number>
+     </property>
+     <property name="spacing" >
+      <number>6</number>
+     </property>
+     <item>
+      <spacer>
+       <property name="orientation" >
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" >
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QPushButton" name="okButton" >
+       <property name="text" >
+        <string>OK</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="cancelButton" >
+       <property name="text" >
+        <string>Cancel</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <pixmapfunction></pixmapfunction>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/modules/gui/qt4/ui/progressdialog.ui b/modules/gui/qt4/ui/progressdialog.ui
new file mode 100644 (file)
index 0000000..3f582ff
--- /dev/null
@@ -0,0 +1,77 @@
+<ui version="4.0" >
+ <author></author>
+ <comment></comment>
+ <exportmacro></exportmacro>
+ <class>ProgressDialog</class>
+ <widget class="QWidget" name="ProgressDialog" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>407</width>
+    <height>91</height>
+   </rect>
+  </property>
+  <layout class="QVBoxLayout" >
+   <property name="margin" >
+    <number>9</number>
+   </property>
+   <property name="spacing" >
+    <number>6</number>
+   </property>
+   <item>
+    <widget class="QLabel" name="description" >
+     <property name="text" >
+      <string/>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QProgressBar" name="progressBar" >
+     <property name="value" >
+      <number>24</number>
+     </property>
+     <property name="textVisible" >
+      <bool>true</bool>
+     </property>
+     <property name="orientation" >
+      <enum>Qt::Horizontal</enum>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" >
+     <property name="margin" >
+      <number>0</number>
+     </property>
+     <property name="spacing" >
+      <number>6</number>
+     </property>
+     <item>
+      <spacer>
+       <property name="orientation" >
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" >
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QPushButton" name="cancelButton" >
+       <property name="text" >
+        <string>Cancel</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <pixmapfunction></pixmapfunction>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/modules/gui/qt4/ui/yesnocanceldialog.ui b/modules/gui/qt4/ui/yesnocanceldialog.ui
new file mode 100644 (file)
index 0000000..5dd1fba
--- /dev/null
@@ -0,0 +1,78 @@
+<ui version="4.0" >
+ <author></author>
+ <comment></comment>
+ <exportmacro></exportmacro>
+ <class>YesNoCancelDialog</class>
+ <widget class="QWidget" name="YesNoCancelDialog" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>122</height>
+   </rect>
+  </property>
+  <layout class="QVBoxLayout" >
+   <property name="margin" >
+    <number>9</number>
+   </property>
+   <property name="spacing" >
+    <number>6</number>
+   </property>
+   <item>
+    <widget class="QLabel" name="description" >
+     <property name="text" >
+      <string/>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" >
+     <property name="margin" >
+      <number>0</number>
+     </property>
+     <property name="spacing" >
+      <number>6</number>
+     </property>
+     <item>
+      <spacer>
+       <property name="orientation" >
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" >
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QPushButton" name="yesButton" >
+       <property name="text" >
+        <string>Yes</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="noButton" >
+       <property name="text" >
+        <string>No</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="cancelButton" >
+       <property name="text" >
+        <string>Cancel</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <pixmapfunction></pixmapfunction>
+ <resources/>
+ <connections/>
+</ui>