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()
{ {
update_Check( p_update, VLC_FALSE ); if( !b_updated )
update_iterator_t *p_uit = update_iterator_New( p_update );
if( p_uit )
{ {
p_uit->i_rs = UPDATE_RELEASE_STATUS_NEWER; update_Check( p_update, VLC_FALSE );
p_uit->i_t = UPDATE_FILE_TYPE_ALL; update_iterator_t *p_updateit = update_iterator_New( p_update );
update_iterator_Action( p_uit, UPDATE_MIRROR ); bool b_download = false;
while( update_iterator_Action( p_uit, UPDATE_FILE ) != UPDATE_FAIL ) if( p_updateit )
{
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 )
{
switch( p_updateit->file.i_type )
{
case UPDATE_FILE_TYPE_INFO:
checkInfo->setText( qtr( "Information" ) + " (" + qfu( p_updateit->release.psz_version ) + ")" );
checkInfo->setDisabled( false );
checkInfo->setCheckState( Qt::Checked );
b_download = true;
break;
case UPDATE_FILE_TYPE_SOURCE:
checkSource->setText( qtr( "Source" ) + " (" + qfu( p_updateit->release.psz_version ) + ")" );
checkSource->setDisabled( false );
checkSource->setCheckState( Qt::Checked );
b_download = true;
break;
case UPDATE_FILE_TYPE_BINARY:
checkBinary->setText( qtr( "Binary" ) + " (" + qfu( p_updateit->release.psz_version ) + ")" );
checkBinary->setDisabled( false );
checkBinary->setCheckState( Qt::Checked );
b_download = true;
break;
case UPDATE_FILE_TYPE_PLUGIN:
checkPlugin->setText( qtr( "Plugin" ) + " (" + qfu( p_updateit->release.psz_version ) + ")");
checkPlugin->setDisabled( false );
checkPlugin->setCheckState( Qt::Checked );
b_download = true;
break;
default:
break;
}
}
}
if( b_download )
{ {
switch( p_uit->file.i_type ) 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 )
{ {
case UPDATE_FILE_TYPE_INFO: b_download = false;
checkInfo->setDisabled( false ); switch( p_updateit->file.i_type )
checkInfo->setCheckState( Qt::Checked ); {
break; case UPDATE_FILE_TYPE_INFO:
case UPDATE_FILE_TYPE_SOURCE: if( checkInfo->isChecked() )
checkSource->setDisabled( false ); b_download = true;
checkSource->setCheckState( Qt::Checked ); break;
break; case UPDATE_FILE_TYPE_SOURCE:
case UPDATE_FILE_TYPE_BINARY: if( checkSource->isChecked() )
checkBinary->setDisabled( false ); b_download = true;
checkBinary->setCheckState( Qt::Checked ); break;
break; case UPDATE_FILE_TYPE_BINARY:
case UPDATE_FILE_TYPE_PLUGIN: if( checkBinary->isChecked() )
checkPlugin->setDisabled( false ); b_download = true;
checkPlugin->setCheckState( Qt::Checked ); break;
break; case UPDATE_FILE_TYPE_PLUGIN:
default: if( checkPlugin->isChecked() )
break; 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 ) ) );
}
} }
} }
} }
update_iterator_Delete( p_uit );
} }
...@@ -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