X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fqt4%2Fdialogs%2Finteraction.cpp;h=45e33516fff9020c2605fca84e4af9d101ee9381;hb=223419069363b3eab712cff2d0ac671a94d8fc65;hp=2859a56ab30095f70c078886b48cf943d7f8f26a;hpb=928454fad876fb8f5dc7b993dca4670460a008af;p=vlc diff --git a/modules/gui/qt4/dialogs/interaction.cpp b/modules/gui/qt4/dialogs/interaction.cpp index 2859a56ab3..45e33516ff 100644 --- a/modules/gui/qt4/dialogs/interaction.cpp +++ b/modules/gui/qt4/dialogs/interaction.cpp @@ -18,18 +18,22 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif -#include "qt4.hpp" #include "dialogs/errors.hpp" #include "dialogs/interaction.hpp" -#include "util/qvlcframe.hpp" +#include "main_interface.hpp" #include #include #include #include #include +#include #include @@ -50,7 +54,7 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf, } else if( p_dialog->i_flags & DIALOG_NONBLOCKING_ERROR ) { - if( config_GetInt( p_intf, "errors-dialog" ) != 0 ) + if( config_GetInt( p_intf, "qt-error-dialogs" ) != 0 ) ErrorsDialog::getInstance( p_intf )->addError( qfu( p_dialog->psz_title ), qfu( p_dialog->psz_description ) ); i_ret = 0; @@ -58,7 +62,7 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf, } else if( p_dialog->i_flags & DIALOG_WARNING ) { - if( config_GetInt( p_intf, "errors-dialog" ) != 0 ) + if( config_GetInt( p_intf, "qt-error-dialogs" ) != 0 ) ErrorsDialog::getInstance( p_intf )->addWarning( qfu( p_dialog->psz_title ),qfu( p_dialog->psz_description ) ); i_ret = 0; @@ -92,13 +96,13 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf, grid->addWidget( new QLabel( qtr("Password") ), 2, 0); passwordEdit = new QLineEdit; + passwordEdit->setEchoMode( QLineEdit::Password ); grid->addWidget( passwordEdit, 2, 1 ); panel->setLayout( grid ); layout->addWidget( panel ); } - else if( p_dialog->i_flags & DIALOG_USER_PROGRESS || - /* TEMPORARY ! */ p_dialog->i_flags & DIALOG_INTF_PROGRESS ) + else if( p_dialog->i_flags & DIALOG_USER_PROGRESS ) { dialog = new QWidget( 0 );layout = new QVBoxLayout( dialog ); layout->setMargin( 2 ); @@ -108,9 +112,14 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf, progressBar = new QProgressBar; progressBar->setMaximum( 1000 ); progressBar->setTextVisible( true ); - progressBar->setOrientation(Qt::Horizontal); + progressBar->setOrientation( Qt::Horizontal ); layout->addWidget( progressBar ); } + else if( p_dialog->i_flags & DIALOG_INTF_PROGRESS ) + { + progressBar = p_intf->p_sys->p_mi->pgBar; + progressBar->show(); + } else if( p_dialog->i_flags & DIALOG_PSZ_INPUT_OK_CANCEL ) { dialog = new QWidget( 0 );layout = new QVBoxLayout( dialog ); @@ -134,10 +143,28 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf, else /* Custom box, finish it */ { - QVLCFrame::doButtons( dialog, layout, - &defaultButton, p_dialog->psz_default_button, - &altButton, p_dialog->psz_alternate_button, - &otherButton, p_dialog->psz_other_button ); + QDialogButtonBox *buttonBox = new QDialogButtonBox; + + if( p_dialog->psz_default_button ) + { + defaultButton = new QPushButton; + defaultButton->setFocus(); + defaultButton->setText( qfu( p_dialog->psz_default_button ) ); + buttonBox->addButton( defaultButton, QDialogButtonBox::AcceptRole ); + } + if( p_dialog->psz_alternate_button ) + { + altButton = new QPushButton; + altButton->setText( qfu( p_dialog->psz_alternate_button ) ); + buttonBox->addButton( altButton, QDialogButtonBox::RejectRole ); + } + if( p_dialog->psz_other_button ) + { + otherButton = new QPushButton; + otherButton->setText( qfu( p_dialog->psz_other_button ) ); + buttonBox->addButton( otherButton, QDialogButtonBox::ActionRole ); + } + layout->addWidget( buttonBox ); if( p_dialog->psz_default_button ) BUTTONACT( defaultButton, defaultB() ); if( p_dialog->psz_alternate_button ) @@ -151,18 +178,26 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf, void InteractionDialog::update() { - if( p_dialog->i_flags & DIALOG_USER_PROGRESS ) + if( p_dialog->i_flags & DIALOG_USER_PROGRESS || + p_dialog->i_flags & DIALOG_INTF_PROGRESS ) { assert( progressBar ); - progressBar->setValue( (int)(p_dialog->val.f_float*1000) ); - fprintf (stderr, "Setting progress to %i\n", progressBar->value() ); + progressBar->setValue( (int)( p_dialog->val.f_float * 10 ) ); + description->setText( qfu( p_dialog->psz_description ) ); } + + if( ( p_dialog->i_flags & DIALOG_INTF_PROGRESS ) && + ( p_dialog->val.f_float >= 100.0 ) ) + progressBar->hide(); + if( ( p_dialog->i_flags & DIALOG_USER_PROGRESS ) && + ( p_dialog->val.f_float >= 100.0 ) ) + altButton->setText( qtr( "&Close" ) ); } InteractionDialog::~InteractionDialog() { -// if( panel ) delete panel; - if( dialog ) delete dialog; +// delete panel; + delete dialog; } void InteractionDialog::defaultB() @@ -180,7 +215,7 @@ void InteractionDialog::otherB() void InteractionDialog::Finish( int i_ret ) { - vlc_mutex_lock( &p_dialog->p_interaction->object_lock ); + vlc_object_lock( p_dialog->p_interaction ); if( p_dialog->i_flags & DIALOG_LOGIN_PW_OK_CANCEL ) { @@ -193,6 +228,14 @@ void InteractionDialog::Finish( int i_ret ) } p_dialog->i_status = ANSWERED_DIALOG; p_dialog->i_return = i_ret; + + /* Alert the Dialog_*_Progress that the user had clicked on "cancel" */ + if( p_dialog->i_flags & DIALOG_USER_PROGRESS || + p_dialog->i_flags & DIALOG_INTF_PROGRESS ) + p_dialog->b_cancelled = true; + hide(); - vlc_mutex_unlock( &p_dialog->p_interaction->object_lock ); + vlc_object_unlock( p_dialog->p_interaction ); + playlist_Signal( THEPL ); } +