Commit f261c0d5 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Add fonctionality to the update dialog - Patches by Rémi Duraffort

parent 160ba82b
...@@ -38,6 +38,8 @@ ...@@ -38,6 +38,8 @@
#include <QCheckBox> #include <QCheckBox>
#include <QGroupBox> #include <QGroupBox>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QFileDialog>
HelpDialog *HelpDialog::instance = NULL; HelpDialog *HelpDialog::instance = NULL;
...@@ -171,7 +173,7 @@ UpdateDialog::UpdateDialog( intf_thread_t *_p_intf) : QVLCFrame( _p_intf ) ...@@ -171,7 +173,7 @@ UpdateDialog::UpdateDialog( intf_thread_t *_p_intf) : QVLCFrame( _p_intf )
QGridLayout *layout = new QGridLayout( this ); QGridLayout *layout = new QGridLayout( this );
QPushButton *closeButton = new QPushButton( qtr( "&Close" ) ); QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
QPushButton *updateButton = new QPushButton( qtr( "&Update List" ) ); updateButton = new QPushButton( qtr( "&Update List" ) );
updateButton->setDefault( true ); updateButton->setDefault( true );
QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Horizontal); QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Horizontal);
buttonBox->addButton( updateButton, QDialogButtonBox::ActionRole ); buttonBox->addButton( updateButton, QDialogButtonBox::ActionRole );
...@@ -197,10 +199,11 @@ UpdateDialog::UpdateDialog( intf_thread_t *_p_intf) : QVLCFrame( _p_intf ) ...@@ -197,10 +199,11 @@ UpdateDialog::UpdateDialog( intf_thread_t *_p_intf) : QVLCFrame( _p_intf )
layout->addWidget( checkGroup, 0, 0 ); layout->addWidget( checkGroup, 0, 0 );
layout->addWidget( buttonBox, 1, 0 ); layout->addWidget( buttonBox, 1, 0 );
BUTTONACT( updateButton, update() ); BUTTONACT( updateButton, updateOrUpload() );
BUTTONACT( closeButton, close() ); BUTTONACT( closeButton, close() );
p_update = update_New( _p_intf ); p_update = update_New( _p_intf );
b_updated = false;
} }
UpdateDialog::~UpdateDialog() UpdateDialog::~UpdateDialog()
...@@ -213,39 +216,102 @@ void UpdateDialog::close() ...@@ -213,39 +216,102 @@ void UpdateDialog::close()
toggleVisible(); toggleVisible();
} }
void UpdateDialog::update() void UpdateDialog::updateOrUpload()
{ {
if( !b_updated )
{
update_Check( p_update, VLC_FALSE ); update_Check( p_update, VLC_FALSE );
update_iterator_t *p_uit = update_iterator_New( p_update ); update_iterator_t *p_updateit = update_iterator_New( p_update );
if( p_uit ) bool b_download = false;
if( p_updateit )
{ {
p_uit->i_rs = UPDATE_RELEASE_STATUS_NEWER; p_updateit->i_rs = UPDATE_RELEASE_STATUS_NEWER;
p_uit->i_t = UPDATE_FILE_TYPE_ALL; p_updateit->i_t = UPDATE_FILE_TYPE_ALL;
update_iterator_Action( p_uit, UPDATE_MIRROR ); update_iterator_Action( p_updateit, UPDATE_MIRROR );
while( update_iterator_Action( p_uit, UPDATE_FILE ) != UPDATE_FAIL ) while( update_iterator_Action( p_updateit, UPDATE_FILE ) != UPDATE_FAIL )
{ {
switch( p_uit->file.i_type ) switch( p_updateit->file.i_type )
{ {
case UPDATE_FILE_TYPE_INFO: case UPDATE_FILE_TYPE_INFO:
checkInfo->setText( qtr( "Information" ) + " (" + qfu( p_updateit->release.psz_version ) + ")" );
checkInfo->setDisabled( false ); checkInfo->setDisabled( false );
checkInfo->setCheckState( Qt::Checked ); checkInfo->setCheckState( Qt::Checked );
b_download = true;
break; break;
case UPDATE_FILE_TYPE_SOURCE: case UPDATE_FILE_TYPE_SOURCE:
checkSource->setText( qtr( "Source" ) + " (" + qfu( p_updateit->release.psz_version ) + ")" );
checkSource->setDisabled( false ); checkSource->setDisabled( false );
checkSource->setCheckState( Qt::Checked ); checkSource->setCheckState( Qt::Checked );
b_download = true;
break; break;
case UPDATE_FILE_TYPE_BINARY: case UPDATE_FILE_TYPE_BINARY:
checkBinary->setText( qtr( "Binary" ) + " (" + qfu( p_updateit->release.psz_version ) + ")" );
checkBinary->setDisabled( false ); checkBinary->setDisabled( false );
checkBinary->setCheckState( Qt::Checked ); checkBinary->setCheckState( Qt::Checked );
b_download = true;
break; break;
case UPDATE_FILE_TYPE_PLUGIN: case UPDATE_FILE_TYPE_PLUGIN:
checkPlugin->setText( qtr( "Plugin" ) + " (" + qfu( p_updateit->release.psz_version ) + ")");
checkPlugin->setDisabled( false ); checkPlugin->setDisabled( false );
checkPlugin->setCheckState( Qt::Checked ); checkPlugin->setCheckState( Qt::Checked );
b_download = true;
break; break;
default: default:
break; break;
} }
} }
} }
update_iterator_Delete( p_uit ); if( b_download )
{
updateButton->setText(qtr( "Download" ) );
b_updated = true;
}
update_iterator_Delete( p_updateit );
}
else
{
update_iterator_t *p_updateit = update_iterator_New( p_update );
bool b_download = false;
if( p_updateit )
{
QString saveDir = QFileDialog::getExistingDirectory( this, qtr( "Choose a direcctory..." ),
qfu( p_intf->p_libvlc->psz_homedir ) );
p_updateit->i_rs = UPDATE_RELEASE_STATUS_NEWER;
p_updateit->i_t = UPDATE_FILE_TYPE_ALL;
update_iterator_Action( p_updateit, UPDATE_MIRROR );
while( update_iterator_Action( p_updateit, UPDATE_FILE ) != UPDATE_FAIL )
{
b_download = false;
switch( p_updateit->file.i_type )
{
case UPDATE_FILE_TYPE_INFO:
if( checkInfo->isChecked() )
b_download = true;
break;
case UPDATE_FILE_TYPE_SOURCE:
if( checkSource->isChecked() )
b_download = true;
break;
case UPDATE_FILE_TYPE_BINARY:
if( checkBinary->isChecked() )
b_download = true;
break;
case UPDATE_FILE_TYPE_PLUGIN:
if( checkPlugin->isChecked() )
b_download = true;
break;
default:
break;
}
if( b_download )
{
QString strFileName = p_updateit->file.psz_url;
strFileName.remove( 0, strFileName.lastIndexOf( "/" ) + 1 );
update_download( p_updateit, qtu( ( saveDir + strFileName ) ) );
}
}
}
}
} }
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "util/qvlcframe.hpp" #include "util/qvlcframe.hpp"
class QPushButton;
class QCheckBox; class QCheckBox;
class HelpDialog : public QVLCFrame class HelpDialog : public QVLCFrame
...@@ -85,14 +86,16 @@ public: ...@@ -85,14 +86,16 @@ public:
private: private:
UpdateDialog( intf_thread_t *); UpdateDialog( intf_thread_t *);
static UpdateDialog *instance; static UpdateDialog *instance;
QPushButton *updateButton;
QCheckBox *checkInfo; QCheckBox *checkInfo;
QCheckBox *checkSource; QCheckBox *checkSource;
QCheckBox *checkBinary; QCheckBox *checkBinary;
QCheckBox *checkPlugin; QCheckBox *checkPlugin;
update_t *p_update; update_t *p_update;
bool b_updated;
private slots: private slots:
void close(); void close();
void update(); void updateOrUpload();
}; };
......
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