From: Francois Cartegnie Date: Thu, 23 Sep 2010 13:51:15 +0000 (+0200) Subject: Qt: rebase update dialog on QtCreator X-Git-Tag: 1.2.0-pre1~5230 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=2b1fabb28defb0599022f6142fd14ac5e06b4310;p=vlc Qt: rebase update dialog on QtCreator --- diff --git a/modules/gui/qt4/Modules.am b/modules/gui/qt4/Modules.am index 55ad347e14..0222e59c8b 100644 --- a/modules/gui/qt4/Modules.am +++ b/modules/gui/qt4/Modules.am @@ -87,6 +87,7 @@ nodist_SOURCES_qt4 = \ ui/streampanel.h \ ui/messages_panel.h \ ui/about.h \ + ui/update.h \ ui/sout.h DEPS_res = \ @@ -360,6 +361,7 @@ EXTRA_DIST += \ ui/streampanel.ui \ ui/messages_panel.ui \ ui/about.ui \ + ui/update.ui \ ui/sout.ui \ ui/vlm.ui \ $(DEPS_res) diff --git a/modules/gui/qt4/dialogs/help.cpp b/modules/gui/qt4/dialogs/help.cpp index 93989498d9..a5d77a9703 100644 --- a/modules/gui/qt4/dialogs/help.cpp +++ b/modules/gui/qt4/dialogs/help.cpp @@ -158,40 +158,29 @@ static void UpdateCallback( void *data, bool b_ret ) UpdateDialog::UpdateDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) { + /* build Ui */ + ui.setupUi( this ); setWindowTitle( qtr( "VLC media player updates" ) ); setWindowRole( "vlc-update" ); - QGridLayout *layout = new QGridLayout( this ); - - QPushButton *closeButton = new QPushButton( qtr( "&Cancel" ) ); - updateButton = new QPushButton( qtr( "&Recheck version" ) ); - updateButton->setDefault( true ); - - QDialogButtonBox *buttonBox = new QDialogButtonBox( Qt::Horizontal ); - buttonBox->addButton( updateButton, QDialogButtonBox::ActionRole ); - buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole ); - - updateLabelTop = new QLabel( qtr( "Checking for an update..." ) ); - updateLabelTop->setWordWrap( true ); - updateLabelTop->setMargin( 8 ); - - updateLabelDown = new QLabel( qtr( "\nDo you want to download it?\n" ) ); - updateLabelDown->setWordWrap( true ); - updateLabelDown->hide(); - - updateText = new QTextEdit( this ); - updateText->setAcceptRichText(false); - updateText->setTextInteractionFlags( Qt::TextSelectableByKeyboard| - Qt::TextSelectableByMouse); - updateText->setEnabled( false ); + QList buttonsList = ui.updateDialogButtonBox->buttons(); + QAbstractButton *currentButton; + for ( int i = 0; i < buttonsList.size() ; ++i ) + { + currentButton = buttonsList.at( i ); + if ( ui.updateDialogButtonBox->standardButton( currentButton ) + == QDialogButtonBox::Retry ) + { + currentButton->setText( qtr( "&Recheck version" ) ); + qobject_cast(currentButton)->setDefault( true ); + } + } - layout->addWidget( updateLabelTop, 0, 0 ); - layout->addWidget( updateText, 1, 0 ); - layout->addWidget( updateLabelDown, 2, 0 ); - layout->addWidget( buttonBox, 3, 0 ); + CONNECT( ui.updateDialogButtonBox, accepted(), this, UpdateOrDownload() ); + CONNECT( ui.updateDialogButtonBox, rejected(), this, close() ); - BUTTONACT( updateButton, UpdateOrDownload() ); - BUTTONACT( closeButton, close() ); + CONNECT( ui.updateNotifyButtonBox, accepted(), this, UpdateOrDownload() ); + CONNECT( ui.updateNotifyButtonBox, rejected(), this, close() ); /* Create the update structure */ p_update = update_New( p_intf ); @@ -222,8 +211,7 @@ void UpdateDialog::UpdateOrDownload() { if( !b_checked ) { - updateButton->setEnabled( false ); - updateLabelTop->setText( qtr( "Launching an update request..." ) ); + ui.stackedWidget->setCurrentWidget( ui.updateRequestPage ); update_Check( p_update, UpdateCallback, this ); } else @@ -238,6 +226,7 @@ void UpdateDialog::UpdateOrDownload() msg_Dbg( p_intf, "Downloading to folder: %s", qtu( dest_dir ) ); toggleVisible(); update_Download( p_update, qtu( dest_dir ) ); + /* FIXME: We should trigger a change to another dialog here ! */ } } } @@ -259,36 +248,36 @@ void UpdateDialog::updateNotify( bool b_result ) { if( update_NeedUpgrade( p_update ) ) { + ui.stackedWidget->setCurrentWidget( ui.updateNotifyPage ); update_release_t *p_release = update_GetRelease( p_update ); assert( p_release ); b_checked = true; - updateButton->setText( qtr( "&Yes" ) ); - QString message = qtr( "A new version of VLC(" ) - + QString::number( p_release->i_major ) + "." - + QString::number( p_release->i_minor ) + "." - + QString::number( p_release->i_revision ); - if( p_release->extra ) - message += p_release->extra; - message += qtr( ") is available."); - updateLabelTop->setText( message ); + QString message = QString( + qtr( "A new version of VLC (%1.%2.%3%4) is available." ) ) + .arg( QString::number( p_release->i_major ) ) + .arg( QString::number( p_release->i_minor ) ) + .arg( QString::number( p_release->i_revision ) ) + .arg( ( p_release->extra )?QString( p_release->extra ):"" ); - updateText->setText( qfu( p_release->psz_desc ) ); - updateText->setEnabled( true ); - - updateLabelDown->show(); + ui.updateNotifyLabel->setText( message ); + ui.updateNotifyTextEdit->setText( qfu( p_release->psz_desc ) ); /* Force the dialog to be shown */ this->show(); } else - updateLabelTop->setText( + { + ui.stackedWidget->setCurrentWidget( ui.updateDialogPage ); + ui.updateDialogLabel->setText( qtr( "You have the latest version of VLC media player." ) ); + } } else - updateLabelTop->setText( + { + ui.stackedWidget->setCurrentWidget( ui.updateDialogPage ); + ui.updateDialogLabel->setText( qtr( "An error occurred while checking for updates..." ) ); - - updateButton->setEnabled( true ); + } } #endif diff --git a/modules/gui/qt4/dialogs/help.hpp b/modules/gui/qt4/dialogs/help.hpp index 495747ae6a..117cadf5ef 100644 --- a/modules/gui/qt4/dialogs/help.hpp +++ b/modules/gui/qt4/dialogs/help.hpp @@ -33,6 +33,7 @@ #include "util/qvlcframe.hpp" #include "util/singleton.hpp" #include "ui/about.h" +#include "ui/update.h" class QPushButton; class QTextBrowser; @@ -85,11 +86,8 @@ private: UpdateDialog( intf_thread_t * ); virtual ~UpdateDialog(); + Ui::updateWidget ui; update_t *p_update; - QPushButton *updateButton; - QLabel *updateLabelTop; - QLabel *updateLabelDown; - QTextEdit *updateText; void customEvent( QEvent * ); bool b_checked; diff --git a/modules/gui/qt4/ui/update.ui b/modules/gui/qt4/ui/update.ui new file mode 100644 index 0000000000..2401173691 --- /dev/null +++ b/modules/gui/qt4/ui/update.ui @@ -0,0 +1,137 @@ + + + updateWidget + + + + 0 + 0 + 400 + 300 + + + + VLC media player updates + + + + + + 0 + + + + + + + Check for VLC updates + + + true + + + + + + + QDialogButtonBox::Close|QDialogButtonBox::Retry + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Launching an update request... + + + true + + + + + + + 0 + + + -1 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + updateNotifyLabel + + + true + + + + + + + Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Do you want to download it ? + + + true + + + + + + + QDialogButtonBox::No|QDialogButtonBox::Yes + + + + + + + + + + + +