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<QAbstractButton *> 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<QPushButton *>(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 );
{
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
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 ! */
}
}
}
{
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
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>updateWidget</class>
+ <widget class="QWidget" name="updateWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>VLC media player updates</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QStackedWidget" name="stackedWidget">
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="updateDialogPage">
+ <layout class="QVBoxLayout" name="verticalLayout_4">
+ <item>
+ <widget class="QLabel" name="updateDialogLabel">
+ <property name="text">
+ <string>Check for VLC updates</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="updateDialogButtonBox">
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Close|QDialogButtonBox::Retry</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="updateRequestPage">
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Launching an update request...</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QProgressBar" name="progressBar">
+ <property name="maximum">
+ <number>0</number>
+ </property>
+ <property name="value">
+ <number>-1</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="updateNotifyPage">
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QLabel" name="updateNotifyLabel">
+ <property name="text">
+ <string notr="true">updateNotifyLabel</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTextEdit" name="updateNotifyTextEdit">
+ <property name="textInteractionFlags">
+ <set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Do you want to download it ?</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="updateNotifyButtonBox">
+ <property name="standardButtons">
+ <set>QDialogButtonBox::No|QDialogButtonBox::Yes</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>