Commit 2b1fabb2 authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: rebase update dialog on QtCreator

parent 58b5d4a1
...@@ -87,6 +87,7 @@ nodist_SOURCES_qt4 = \ ...@@ -87,6 +87,7 @@ nodist_SOURCES_qt4 = \
ui/streampanel.h \ ui/streampanel.h \
ui/messages_panel.h \ ui/messages_panel.h \
ui/about.h \ ui/about.h \
ui/update.h \
ui/sout.h ui/sout.h
DEPS_res = \ DEPS_res = \
...@@ -360,6 +361,7 @@ EXTRA_DIST += \ ...@@ -360,6 +361,7 @@ EXTRA_DIST += \
ui/streampanel.ui \ ui/streampanel.ui \
ui/messages_panel.ui \ ui/messages_panel.ui \
ui/about.ui \ ui/about.ui \
ui/update.ui \
ui/sout.ui \ ui/sout.ui \
ui/vlm.ui \ ui/vlm.ui \
$(DEPS_res) $(DEPS_res)
......
...@@ -158,40 +158,29 @@ static void UpdateCallback( void *data, bool b_ret ) ...@@ -158,40 +158,29 @@ static void UpdateCallback( void *data, bool b_ret )
UpdateDialog::UpdateDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) UpdateDialog::UpdateDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
{ {
/* build Ui */
ui.setupUi( this );
setWindowTitle( qtr( "VLC media player updates" ) ); setWindowTitle( qtr( "VLC media player updates" ) );
setWindowRole( "vlc-update" ); setWindowRole( "vlc-update" );
QGridLayout *layout = new QGridLayout( this ); QList<QAbstractButton *> buttonsList = ui.updateDialogButtonBox->buttons();
QAbstractButton *currentButton;
QPushButton *closeButton = new QPushButton( qtr( "&Cancel" ) ); for ( int i = 0; i < buttonsList.size() ; ++i )
updateButton = new QPushButton( qtr( "&Recheck version" ) ); {
updateButton->setDefault( true ); currentButton = buttonsList.at( i );
if ( ui.updateDialogButtonBox->standardButton( currentButton )
QDialogButtonBox *buttonBox = new QDialogButtonBox( Qt::Horizontal ); == QDialogButtonBox::Retry )
buttonBox->addButton( updateButton, QDialogButtonBox::ActionRole ); {
buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole ); currentButton->setText( qtr( "&Recheck version" ) );
qobject_cast<QPushButton *>(currentButton)->setDefault( true );
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 );
layout->addWidget( updateLabelTop, 0, 0 ); CONNECT( ui.updateDialogButtonBox, accepted(), this, UpdateOrDownload() );
layout->addWidget( updateText, 1, 0 ); CONNECT( ui.updateDialogButtonBox, rejected(), this, close() );
layout->addWidget( updateLabelDown, 2, 0 );
layout->addWidget( buttonBox, 3, 0 );
BUTTONACT( updateButton, UpdateOrDownload() ); CONNECT( ui.updateNotifyButtonBox, accepted(), this, UpdateOrDownload() );
BUTTONACT( closeButton, close() ); CONNECT( ui.updateNotifyButtonBox, rejected(), this, close() );
/* Create the update structure */ /* Create the update structure */
p_update = update_New( p_intf ); p_update = update_New( p_intf );
...@@ -222,8 +211,7 @@ void UpdateDialog::UpdateOrDownload() ...@@ -222,8 +211,7 @@ void UpdateDialog::UpdateOrDownload()
{ {
if( !b_checked ) if( !b_checked )
{ {
updateButton->setEnabled( false ); ui.stackedWidget->setCurrentWidget( ui.updateRequestPage );
updateLabelTop->setText( qtr( "Launching an update request..." ) );
update_Check( p_update, UpdateCallback, this ); update_Check( p_update, UpdateCallback, this );
} }
else else
...@@ -238,6 +226,7 @@ void UpdateDialog::UpdateOrDownload() ...@@ -238,6 +226,7 @@ void UpdateDialog::UpdateOrDownload()
msg_Dbg( p_intf, "Downloading to folder: %s", qtu( dest_dir ) ); msg_Dbg( p_intf, "Downloading to folder: %s", qtu( dest_dir ) );
toggleVisible(); toggleVisible();
update_Download( p_update, qtu( dest_dir ) ); 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 ) ...@@ -259,36 +248,36 @@ void UpdateDialog::updateNotify( bool b_result )
{ {
if( update_NeedUpgrade( p_update ) ) if( update_NeedUpgrade( p_update ) )
{ {
ui.stackedWidget->setCurrentWidget( ui.updateNotifyPage );
update_release_t *p_release = update_GetRelease( p_update ); update_release_t *p_release = update_GetRelease( p_update );
assert( p_release ); assert( p_release );
b_checked = true; b_checked = true;
updateButton->setText( qtr( "&Yes" ) ); QString message = QString(
QString message = qtr( "A new version of VLC(" ) qtr( "A new version of VLC (%1.%2.%3%4) is available." ) )
+ QString::number( p_release->i_major ) + "." .arg( QString::number( p_release->i_major ) )
+ QString::number( p_release->i_minor ) + "." .arg( QString::number( p_release->i_minor ) )
+ QString::number( p_release->i_revision ); .arg( QString::number( p_release->i_revision ) )
if( p_release->extra ) .arg( ( p_release->extra )?QString( p_release->extra ):"" );
message += p_release->extra;
message += qtr( ") is available.");
updateLabelTop->setText( message );
updateText->setText( qfu( p_release->psz_desc ) ); ui.updateNotifyLabel->setText( message );
updateText->setEnabled( true ); ui.updateNotifyTextEdit->setText( qfu( p_release->psz_desc ) );
updateLabelDown->show();
/* Force the dialog to be shown */ /* Force the dialog to be shown */
this->show(); this->show();
} }
else else
updateLabelTop->setText( {
ui.stackedWidget->setCurrentWidget( ui.updateDialogPage );
ui.updateDialogLabel->setText(
qtr( "You have the latest version of VLC media player." ) ); qtr( "You have the latest version of VLC media player." ) );
}
} }
else else
updateLabelTop->setText( {
ui.stackedWidget->setCurrentWidget( ui.updateDialogPage );
ui.updateDialogLabel->setText(
qtr( "An error occurred while checking for updates..." ) ); qtr( "An error occurred while checking for updates..." ) );
}
updateButton->setEnabled( true );
} }
#endif #endif
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "util/qvlcframe.hpp" #include "util/qvlcframe.hpp"
#include "util/singleton.hpp" #include "util/singleton.hpp"
#include "ui/about.h" #include "ui/about.h"
#include "ui/update.h"
class QPushButton; class QPushButton;
class QTextBrowser; class QTextBrowser;
...@@ -85,11 +86,8 @@ private: ...@@ -85,11 +86,8 @@ private:
UpdateDialog( intf_thread_t * ); UpdateDialog( intf_thread_t * );
virtual ~UpdateDialog(); virtual ~UpdateDialog();
Ui::updateWidget ui;
update_t *p_update; update_t *p_update;
QPushButton *updateButton;
QLabel *updateLabelTop;
QLabel *updateLabelDown;
QTextEdit *updateText;
void customEvent( QEvent * ); void customEvent( QEvent * );
bool b_checked; bool b_checked;
......
<?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>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment