Commit b83bd217 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

modules/gui/qt4: add an update dialog box to the help menu. (Patch by Remi...

modules/gui/qt4: add an update dialog box to the help menu. (Patch by Remi Duraffort. Reviewed by jb).
parent 5c97509f
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* $Id$ * $Id$
* *
* Authors: Jean-Baptiste Kempf <jb (at) videolan.org> * Authors: Jean-Baptiste Kempf <jb (at) videolan.org>
* Rmi Duraffort <ivoire (at) via.ecp.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -23,6 +24,7 @@ ...@@ -23,6 +24,7 @@
#include "dialogs/help.hpp" #include "dialogs/help.hpp"
#include <vlc_about.h> #include <vlc_about.h>
#include <vlc_update.h>
#include "dialogs_provider.hpp" #include "dialogs_provider.hpp"
...@@ -33,6 +35,9 @@ ...@@ -33,6 +35,9 @@
#include <QFile> #include <QFile>
#include <QLabel> #include <QLabel>
#include <QString> #include <QString>
#include <QCheckBox>
#include <QGroupBox>
#include <QDialogButtonBox>
HelpDialog *HelpDialog::instance = NULL; HelpDialog *HelpDialog::instance = NULL;
...@@ -154,3 +159,93 @@ void AboutDialog::close() ...@@ -154,3 +159,93 @@ void AboutDialog::close()
{ {
this->toggleVisible(); this->toggleVisible();
} }
UpdateDialog *UpdateDialog::instance = NULL;
UpdateDialog::UpdateDialog( intf_thread_t *_p_intf) : QVLCFrame( _p_intf )
{
setWindowTitle( qtr( "Update" ) );
resize( 230, 180 );
QGridLayout *layout = new QGridLayout( this );
QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
QPushButton *updateButton = new QPushButton( qtr( "&Update List" ) );
updateButton->setDefault( true );
QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Horizontal);
buttonBox->addButton( updateButton, QDialogButtonBox::ActionRole );
buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
QGroupBox *checkGroup = new QGroupBox( qtr( "Select Package" ) );
QGridLayout *checkLayout = new QGridLayout( checkGroup );
checkInfo = new QCheckBox( qtr( "Information" ) );
checkSource = new QCheckBox( qtr( "Sources" ) );
checkBinary = new QCheckBox( qtr( "Binary" ) );
checkPlugin = new QCheckBox( qtr( "Plugin" ) );
checkInfo->setDisabled( true );
checkSource->setDisabled( true );
checkBinary->setDisabled( true );
checkPlugin->setDisabled( true );
checkLayout->addWidget( checkInfo, 0, 0 );
checkLayout->addWidget( checkSource, 1, 0 );
checkLayout->addWidget( checkBinary, 2, 0 );
checkLayout->addWidget( checkPlugin, 3, 0 );
layout->addWidget( checkGroup, 0, 0 );
layout->addWidget( buttonBox, 1, 0 );
BUTTONACT( updateButton, update() );
BUTTONACT( closeButton, close() );
p_update = update_New( _p_intf );
}
UpdateDialog::~UpdateDialog()
{
update_Delete( p_update );
}
void UpdateDialog::close()
{
toggleVisible();
}
void UpdateDialog::update()
{
update_Check( p_update, VLC_FALSE );
update_iterator_t *p_uit = update_iterator_New( p_update );
if( p_uit )
{
p_uit->i_rs = UPDATE_RELEASE_STATUS_NEWER;
p_uit->i_t = UPDATE_FILE_TYPE_ALL;
update_iterator_Action( p_uit, UPDATE_MIRROR );
while( update_iterator_Action( p_uit, UPDATE_FILE ) != UPDATE_FAIL )
{
switch( p_uit->file.i_type )
{
case UPDATE_FILE_TYPE_INFO:
checkInfo->setDisabled( false );
checkInfo->setCheckState( Qt::Checked );
break;
case UPDATE_FILE_TYPE_SOURCE:
checkSource->setDisabled( false );
checkSource->setCheckState( Qt::Checked );
break;
case UPDATE_FILE_TYPE_BINARY:
checkBinary->setDisabled( false );
checkBinary->setCheckState( Qt::Checked );
break;
case UPDATE_FILE_TYPE_PLUGIN:
checkPlugin->setDisabled( false );
checkPlugin->setCheckState( Qt::Checked );
break;
default:
break;
}
}
}
update_iterator_Delete( p_uit );
}
...@@ -24,8 +24,12 @@ ...@@ -24,8 +24,12 @@
#ifndef _HELP_DIALOG_H_ #ifndef _HELP_DIALOG_H_
#define _HELP_DIALOG_H_ #define _HELP_DIALOG_H_
#include <vlc_update.h>
#include "util/qvlcframe.hpp" #include "util/qvlcframe.hpp"
class QCheckBox;
class HelpDialog : public QVLCFrame class HelpDialog : public QVLCFrame
{ {
Q_OBJECT; Q_OBJECT;
...@@ -65,4 +69,31 @@ public slots: ...@@ -65,4 +69,31 @@ public slots:
void close(); void close();
}; };
class UpdateDialog : public QVLCFrame
{
Q_OBJECT;
public:
static UpdateDialog * getInstance( intf_thread_t *p_intf )
{
if( !instance)
instance = new UpdateDialog( p_intf);
return instance;
}
virtual ~UpdateDialog();
private:
UpdateDialog( intf_thread_t *);
static UpdateDialog *instance;
QCheckBox *checkInfo;
QCheckBox *checkSource;
QCheckBox *checkBinary;
QCheckBox *checkPlugin;
update_t *p_update;
private slots:
void close();
void update();
};
#endif #endif
...@@ -170,6 +170,11 @@ void DialogsProvider::helpDialog() ...@@ -170,6 +170,11 @@ void DialogsProvider::helpDialog()
HelpDialog::getInstance( p_intf )->toggleVisible(); HelpDialog::getInstance( p_intf )->toggleVisible();
} }
void DialogsProvider::updateDialog()
{
UpdateDialog::getInstance( p_intf )->toggleVisible();
}
void DialogsProvider::aboutDialog() void DialogsProvider::aboutDialog()
{ {
AboutDialog::getInstance( p_intf )->toggleVisible(); AboutDialog::getInstance( p_intf )->toggleVisible();
......
...@@ -144,6 +144,7 @@ public slots: ...@@ -144,6 +144,7 @@ public slots:
void messagesDialog(); void messagesDialog();
void vlmDialog(); void vlmDialog();
void helpDialog(); void helpDialog();
void updateDialog();
void aboutDialog(); void aboutDialog();
void gotoTimeDialog(); void gotoTimeDialog();
......
...@@ -448,6 +448,7 @@ QMenu *QVLCMenu::HelpMenu() ...@@ -448,6 +448,7 @@ QMenu *QVLCMenu::HelpMenu()
QMenu *menu = new QMenu(); QMenu *menu = new QMenu();
DP_SADD( menu, qtr( "Help..." ) , "", ":/pixmaps/menus_help_16px.png", DP_SADD( menu, qtr( "Help..." ) , "", ":/pixmaps/menus_help_16px.png",
helpDialog(), "F1" ); helpDialog(), "F1" );
DP_SADD( menu, qtr( "Update" ) , "", "", updateDialog(), "");
menu->addSeparator(); menu->addSeparator();
DP_SADD( menu, qtr( I_MENU_ABOUT ), "", "", aboutDialog(), "Ctrl+F1" ); DP_SADD( menu, qtr( I_MENU_ABOUT ), "", "", aboutDialog(), "Ctrl+F1" );
return menu; return menu;
......
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