]> git.sesse.net Git - vlc/commitdiff
Implementation of login, input and progress dialogs in Qt
authorClément Stenac <zorglub@videolan.org>
Wed, 13 Sep 2006 09:03:27 +0000 (09:03 +0000)
committerClément Stenac <zorglub@videolan.org>
Wed, 13 Sep 2006 09:03:27 +0000 (09:03 +0000)
(untested)

modules/gui/qt4/Modules.am
modules/gui/qt4/dialogs/interaction.cpp
modules/gui/qt4/dialogs/interaction.hpp
modules/gui/qt4/ui/inputdialog.ui [deleted file]
modules/gui/qt4/ui/logindialog.ui [deleted file]
modules/gui/qt4/ui/progressdialog.ui [deleted file]

index 0e29c374ed5a256205480baaf0e9cea3f68b6c75..ec9e12a3d90e4e1384ac4416beb7eef6e4bba76b 100644 (file)
@@ -12,7 +12,7 @@
 AUTOMAKE_OPTIONS = subdir-objects
 
 TOUI = ui/input_stats ui/main_interface ui/file_open \
-       ui/logindialog ui/inputdialog ui/progressdialog ui/sprefs_trivial \
+       ui/sprefs_trivial \
        ui/sprefs_audio ui/sprefs_playlist ui/sprefs_subtitles \
        ui/sprefs_video ui/sprefs_interface
 UIH = $(TOUI:%=%.h)
@@ -137,9 +137,6 @@ EXTRA_DIST += \
        ui/input_stats.ui \
        ui/file_open.ui \
        ui/main_interface.ui \
-       ui/logindialog.ui \
-       ui/inputdialog.ui \
-       ui/progressdialog.ui \
        ui/sprefs_trivial.ui \
        ui/sprefs_audio.ui \
        ui/sprefs_video.ui \
index db257d7f62e53aebf79185a85d7db95d9c8aee39..7e59a052b08b8a511f969a3b89809dd03f916d08 100644 (file)
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/
 
-#include <QMessageBox>
+#include "qt4.hpp"
 #include "dialogs/errors.hpp"
 #include "dialogs/interaction.hpp"
 #include "util/qvlcframe.hpp"
-#include <vlc/intf.h>
-#include "qt4.hpp"
+
+#include <QLabel>
+#include <QLineEdit>
+#include <QPushButton>
+#include <QProgressBar>
+#include <QMessageBox>
+
+#include <assert.h>
 
 InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
                          interaction_dialog_t *_p_dialog ) : QWidget( 0 ),
@@ -33,9 +39,6 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
 {
     QVBoxLayout *layout = new QVBoxLayout( this );
     int i_ret = -1;
-    uiLogin = NULL;
-    uiProgress = NULL;
-    uiInput = NULL;
     panel = NULL;
 
     if( p_dialog->i_flags & DIALOG_BLOCKING_ERROR )
@@ -46,7 +49,7 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
     }
     else if( p_dialog->i_flags & DIALOG_NONBLOCKING_ERROR )
     {
-        if( config_GetInt( p_intf, "qt-show-errors" ) != 0 )
+        if( config_GetInt( p_intf, "errors-dialog" ) != 0 )
             ErrorsDialog::getInstance( p_intf )->addError(
                  qfu( p_dialog->psz_title ), qfu( p_dialog->psz_description ) );
         i_ret = 0;
@@ -54,7 +57,7 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
     }
     else if( p_dialog->i_flags & DIALOG_WARNING )
     {
-        if( config_GetInt( p_intf, "qt-show-errors" ) != 0 )
+        if( config_GetInt( p_intf, "errors-dialog" ) != 0 )
             ErrorsDialog::getInstance( p_intf )->addWarning(
                 qfu( p_dialog->psz_title ),qfu( p_dialog->psz_description ) );
         i_ret = 0;
@@ -74,16 +77,40 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
     else if( p_dialog->i_flags & DIALOG_LOGIN_PW_OK_CANCEL )
     {
         panel = new QWidget( 0 );
-        uiLogin = new Ui::LoginDialog;
-        uiLogin->setupUi( panel );
-        uiLogin->description->setText( qfu(p_dialog->psz_description) );
+        QGridLayout *grid = new QGridLayout;
+
+        description = new QLabel( qfu( p_dialog->psz_description ) );
+        grid->addWidget( description, 0, 0, 1, 2 );
+
+        grid->addWidget( new QLabel( qtr( "Login") ), 1, 0 );
+        loginEdit = new QLineEdit;
+        grid->addWidget( loginEdit, 1, 1 );
+
+        grid->addWidget( new QLabel( qtr("Password") ), 2, 0);
+        passwordEdit = new QLineEdit;
+        grid->addWidget( passwordEdit, 2, 1 );
+
+        panel->setLayout( grid );
         layout->addWidget( panel );
     }
     else if( p_dialog->i_flags & DIALOG_USER_PROGRESS )
     {
+        description = new QLabel( qfu( p_dialog->psz_description ) );
+        layout->addWidget( description );
+
+        progressBar = new QProgressBar;
+        progressBar->setMaximum( 1000 );
+        progressBar->setTextVisible( true );
+        progressBar->setOrientation(Qt::Horizontal);
+        layout->addWidget( progressBar );
     }
     else if( p_dialog->i_flags & DIALOG_PSZ_INPUT_OK_CANCEL )
     {
+        description = new QLabel( qfu( p_dialog->psz_description ) );
+        layout->addWidget( description );
+
+        inputEdit = new QLineEdit;
+        layout->addWidget( inputEdit );
     }
     else
         msg_Err( p_intf, "unknown dialog type" );
@@ -116,14 +143,16 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
 
 void InteractionDialog::Update()
 {
+    if( p_dialog->i_flags & DIALOG_USER_PROGRESS )
+    {
+        assert( progressBar );
+        progressBar->setValue( (int)(p_dialog->val.f_float*1000) );
+    }
 }
 
 InteractionDialog::~InteractionDialog()
 {
     if( panel ) delete panel;
-    if( uiInput ) delete uiInput;
-    if( uiProgress) delete uiProgress;
-    if( uiLogin ) delete uiLogin;
 }
 
 void InteractionDialog::defaultB()
@@ -145,15 +174,12 @@ void InteractionDialog::Finish( int i_ret )
 
     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() );
+        p_dialog->psz_returned[0] = strdup( qtu( loginEdit->text() ) );
+        p_dialog->psz_returned[1] = strdup( qtu( passwordEdit->text() ) );
     }
     else if( p_dialog->i_flags & DIALOG_PSZ_INPUT_OK_CANCEL )
     {
-        p_dialog->psz_returned[0] = strdup(
-                               uiInput->inputEdit->text().toUtf8().data() );
+        p_dialog->psz_returned[0] = strdup( qtu( inputEdit->text() ) );
     }
     p_dialog->i_status = ANSWERED_DIALOG;
     p_dialog->i_return = i_ret;
index 727176797d4d0570e2dee529a7a2ab3e91424ef7..9cf828a8e199b2730264e1f507f52080c94ed859 100644 (file)
 
 #include <vlc/vlc.h>
 #include <vlc_interaction.h>
-#undef Q_
-#include <ui/inputdialog.h>
-#undef Q_
-#include <ui/logindialog.h>
-#undef Q_
-#include <ui/progressdialog.h>
-#undef Q_
 #include <QWidget>
 
+class QPushButton;
+class QLabel;
+class QProgressBar;
+class QLineEdit;
+
 class InteractionDialog : public QWidget
 {
     Q_OBJECT
@@ -47,12 +45,11 @@ private:
     QWidget *panel;
     intf_thread_t *p_intf;
     interaction_dialog_t *p_dialog;
-    Ui::LoginDialog *uiLogin;
-    Ui::InputDialog *uiInput;
-    Ui::ProgressDialog *uiProgress;
 
     QPushButton *defaultButton, *otherButton, *altButton;
     QLabel *description;
+    QProgressBar *progressBar;
+    QLineEdit *inputEdit, *loginEdit, *passwordEdit;
 
     void Finish( int );
 private slots:
diff --git a/modules/gui/qt4/ui/inputdialog.ui b/modules/gui/qt4/ui/inputdialog.ui
deleted file mode 100644 (file)
index 1fde899..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-<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
deleted file mode 100644 (file)
index 8e821cf..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-<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="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>
- </widget>
- <pixmapfunction></pixmapfunction>
- <resources/>
- <connections/>
-</ui>
diff --git a/modules/gui/qt4/ui/progressdialog.ui b/modules/gui/qt4/ui/progressdialog.ui
deleted file mode 100644 (file)
index 0a0f201..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-<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>