1 /*****************************************************************************
2 * Help.cpp : Help and About dialogs
3 ****************************************************************************
4 * Copyright (C) 2007 the VideoLAN team
7 * Authors: Jean-Baptiste Kempf <jb (at) videolan.org>
8 * RĂ©mi Duraffort <ivoire (at) via.ecp.fr>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 #include "dialogs/help.hpp"
26 #include <vlc_about.h>
27 #include <vlc_update.h>
29 #include "dialogs_provider.hpp"
31 #include <vlc_intf_strings.h>
33 #include <QTextBrowser>
40 #include <QDialogButtonBox>
41 #include <QFileDialog>
44 HelpDialog *HelpDialog::instance = NULL;
46 HelpDialog::HelpDialog( intf_thread_t *_p_intf) : QVLCFrame( _p_intf )
48 setWindowTitle( qtr( "Help" ) );
51 QGridLayout *layout = new QGridLayout( this );
52 QTextBrowser *helpBrowser = new QTextBrowser( this );
53 helpBrowser->setOpenExternalLinks( true );
54 helpBrowser->setHtml( I_LONGHELP );
55 QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
56 closeButton->setDefault( true );
58 layout->addWidget( helpBrowser, 0, 0, 1, 0 );
59 layout->addWidget( closeButton, 1, 3 );
61 BUTTONACT( closeButton, close() );
64 HelpDialog::~HelpDialog()
67 void HelpDialog::close()
69 this->toggleVisible();
72 AboutDialog *AboutDialog::instance = NULL;
74 AboutDialog::AboutDialog( intf_thread_t *_p_intf) : QVLCFrame( _p_intf )
76 setWindowTitle( qtr( "About" ) );
79 QGridLayout *layout = new QGridLayout( this );
80 QTabWidget *tab = new QTabWidget( this );
82 QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
83 closeButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
84 closeButton->setDefault( true );
86 QLabel *introduction = new QLabel(
87 qtr( "Information about VLC media player." ) );
88 QLabel *iconVLC = new QLabel;
89 iconVLC->setPixmap( QPixmap( ":/vlc48.png" ) );
90 layout->addWidget( iconVLC, 0, 0, 1, 1 );
91 layout->addWidget( introduction, 0, 1, 1, 7 );
92 layout->addWidget( tab, 1, 0, 1, 8 );
93 layout->addWidget( closeButton, 2, 6, 1, 2 );
95 /* Main Introduction */
96 QWidget *infoWidget = new QWidget( this );
97 QHBoxLayout *infoLayout = new QHBoxLayout( infoWidget );
98 QLabel *infoLabel = new QLabel( "VLC media player " PACKAGE_VERSION "\n\n"
99 "(c) 1996-2007 - the VideoLAN Team\n\n" +
100 qtr( "VLC media player is a free media player, made by the "
101 "VideoLAN Team.\nIt is a standalone multimedia player, "
102 "encoder and streamer, that can read from many supports "
103 "(files, CDs, DVDs, networks, capture cards...) and that "
104 "works on many platforms.\n\n" )
105 + qtr( "You are using the new Qt4 Interface.\n" )
106 + qtr( "Compiled by " ) + qfu( VLC_CompileBy() )+ "@"
107 + qfu( VLC_CompileDomain() ) + ".\n"
108 + "Compiler: " + qfu( VLC_Compiler() ) +".\n"
109 + qtr( "Based on SVN revision: " ) + qfu( VLC_Changeset() )
111 + qtr( "This program comes with NO WARRANTY, to the extent "
112 "permitted by the law; read the distribution tab.\n\n" )
113 + "The VideoLAN team <videolan@videolan.org> \n"
114 "http://www.videolan.org/\n") ;
115 infoLabel->setWordWrap( infoLabel );
117 QLabel *iconVLC2 = new QLabel;
118 iconVLC2->setPixmap( QPixmap( ":/vlc128.png" ) );
119 infoLayout->addWidget( iconVLC2 );
120 infoLayout->addWidget( infoLabel );
123 QTextEdit *licenseEdit = new QTextEdit( this );
124 licenseEdit->setFontFamily( "Monospace" );
125 licenseEdit->setText( qfu( psz_license ) );
126 licenseEdit->setReadOnly( true );
128 /* People who helped */
129 QWidget *thanksWidget = new QWidget( this );
130 QVBoxLayout *thanksLayout = new QVBoxLayout( thanksWidget );
132 QLabel *thanksLabel = new QLabel( qtr("We would like to thank the whole "
133 "community, the testers, our users and the following people "
134 "(and the missing ones...) for their collaboration to "
135 "provide the best software." ) );
136 thanksLabel->setWordWrap( true );
137 thanksLayout->addWidget( thanksLabel );
138 QTextEdit *thanksEdit = new QTextEdit( this );
139 thanksEdit->setText( qfu( psz_thanks ) );
140 thanksEdit->setReadOnly( true );
141 thanksLayout->addWidget( thanksEdit );
143 /* People who wrote the software */
144 QTextEdit *authorsEdit = new QTextEdit( this );
145 authorsEdit->setText( qfu( psz_authors ) );
146 authorsEdit->setReadOnly( true );
148 /* add the tabs to the Tabwidget */
149 tab->addTab( infoWidget, qtr( "General Info" ) );
150 tab->addTab( authorsEdit, qtr( "Authors" ) );
151 tab->addTab( thanksWidget, qtr("Thanks") );
152 tab->addTab( licenseEdit, qtr("Distribution License") );
154 BUTTONACT( closeButton, close() );
157 AboutDialog::~AboutDialog()
160 void AboutDialog::close()
162 this->toggleVisible();
166 UpdateDialog *UpdateDialog::instance = NULL;
168 UpdateDialog::UpdateDialog( intf_thread_t *_p_intf) : QVLCFrame( _p_intf )
170 setWindowTitle( qtr( "Update" ) );
173 QGridLayout *layout = new QGridLayout( this );
175 QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
176 updateButton = new QPushButton( qtr( "&Update List" ) );
177 updateButton->setDefault( true );
178 QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Horizontal);
179 buttonBox->addButton( updateButton, QDialogButtonBox::ActionRole );
180 buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
182 QGroupBox *checkGroup = new QGroupBox( qtr( "Select Package" ) );
183 QGridLayout *checkLayout = new QGridLayout( checkGroup );
184 checkInfo = new QCheckBox( qtr( "Information" ) );
185 checkSource = new QCheckBox( qtr( "Sources" ) );
186 checkBinary = new QCheckBox( qtr( "Binary" ) );
187 checkPlugin = new QCheckBox( qtr( "Plugin" ) );
189 checkInfo->setDisabled( true );
190 checkSource->setDisabled( true );
191 checkBinary->setDisabled( true );
192 checkPlugin->setDisabled( true );
194 checkLayout->addWidget( checkInfo, 0, 0 );
195 checkLayout->addWidget( checkSource, 1, 0 );
196 checkLayout->addWidget( checkBinary, 2, 0 );
197 checkLayout->addWidget( checkPlugin, 3, 0 );
199 layout->addWidget( checkGroup, 0, 0 );
200 layout->addWidget( buttonBox, 1, 0 );
202 BUTTONACT( updateButton, updateOrUpload() );
203 BUTTONACT( closeButton, close() );
205 p_update = update_New( _p_intf );
209 UpdateDialog::~UpdateDialog()
211 update_Delete( p_update );
214 void UpdateDialog::close()
219 void UpdateDialog::updateOrUpload()
221 if( !p_update ) return;
224 update_Check( p_update, VLC_FALSE );
225 update_iterator_t *p_updateit = update_iterator_New( p_update );
226 bool b_download = false;
229 p_updateit->i_rs = UPDATE_RELEASE_STATUS_NEWER;
230 p_updateit->i_t = UPDATE_FILE_TYPE_ALL;
231 update_iterator_Action( p_updateit, UPDATE_MIRROR );
232 while( update_iterator_Action( p_updateit, UPDATE_FILE ) != UPDATE_FAIL )
234 switch( p_updateit->file.i_type )
236 case UPDATE_FILE_TYPE_INFO:
237 checkInfo->setText( qtr( "Information" ) + " (" + qfu( p_updateit->release.psz_version ) + ")" );
238 checkInfo->setDisabled( false );
239 checkInfo->setCheckState( Qt::Checked );
242 case UPDATE_FILE_TYPE_SOURCE:
243 checkSource->setText( qtr( "Source" ) + " (" + qfu( p_updateit->release.psz_version ) + ")" );
244 checkSource->setDisabled( false );
245 checkSource->setCheckState( Qt::Checked );
248 case UPDATE_FILE_TYPE_BINARY:
249 checkBinary->setText( qtr( "Binary" ) + " (" + qfu( p_updateit->release.psz_version ) + ")" );
250 checkBinary->setDisabled( false );
251 checkBinary->setCheckState( Qt::Checked );
254 case UPDATE_FILE_TYPE_PLUGIN:
255 checkPlugin->setText( qtr( "Plugin" ) + " (" + qfu( p_updateit->release.psz_version ) + ")");
256 checkPlugin->setDisabled( false );
257 checkPlugin->setCheckState( Qt::Checked );
267 updateButton->setText(qtr( "Download" ) );
270 update_iterator_Delete( p_updateit );
274 update_iterator_t *p_updateit = update_iterator_New( p_update );
275 bool b_download = false;
278 QString saveDir = QFileDialog::getExistingDirectory( this, qtr( "Choose a direcctory..." ),
279 qfu( p_intf->p_libvlc->psz_homedir ) );
281 p_updateit->i_rs = UPDATE_RELEASE_STATUS_NEWER;
282 p_updateit->i_t = UPDATE_FILE_TYPE_ALL;
283 update_iterator_Action( p_updateit, UPDATE_MIRROR );
285 while( update_iterator_Action( p_updateit, UPDATE_FILE ) != UPDATE_FAIL )
288 switch( p_updateit->file.i_type )
290 case UPDATE_FILE_TYPE_INFO:
291 if( checkInfo->isChecked() )
294 case UPDATE_FILE_TYPE_SOURCE:
295 if( checkSource->isChecked() )
298 case UPDATE_FILE_TYPE_BINARY:
299 if( checkBinary->isChecked() )
302 case UPDATE_FILE_TYPE_PLUGIN:
303 if( checkPlugin->isChecked() )
311 QString strFileName = p_updateit->file.psz_url;
312 strFileName.remove( 0, strFileName.lastIndexOf( "/" ) + 1 );
313 update_download( p_updateit, qtu( ( saveDir + strFileName ) ) );