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 *****************************************************************************/
31 #include "dialogs/help.hpp"
32 #include <vlc_about.h>
35 #include <vlc_update.h>
38 #include "dialogs_provider.hpp"
40 #include <vlc_intf_strings.h>
42 #include <QTextBrowser>
47 #include <QDialogButtonBox>
49 #include <QFileDialog>
53 HelpDialog *HelpDialog::instance = NULL;
55 HelpDialog::HelpDialog( QWidget *parent, intf_thread_t *_p_intf )
56 : QVLCDialog( parent, _p_intf )
58 setWindowTitle( qtr( "Help" ) );
60 QGridLayout *layout = new QGridLayout( this );
61 QTextBrowser *helpBrowser = new QTextBrowser( this );
62 helpBrowser->setOpenExternalLinks( true );
63 helpBrowser->setHtml( I_LONGHELP );
64 QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
65 closeButton->setDefault( true );
67 layout->addWidget( helpBrowser, 0, 0, 1, 0 );
68 layout->addWidget( closeButton, 1, 3 );
70 BUTTONACT( closeButton, close() );
73 HelpDialog::~HelpDialog()
76 void HelpDialog::close()
78 this->toggleVisible();
81 AboutDialog *AboutDialog::instance = NULL;
83 AboutDialog::AboutDialog( intf_thread_t *_p_intf) : QVLCFrame( _p_intf )
85 setWindowTitle( qtr( "About" ) );
87 setMinimumSize( 600, 500 );
89 QGridLayout *layout = new QGridLayout( this );
90 QTabWidget *tab = new QTabWidget( this );
92 QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
93 closeButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
94 closeButton->setDefault( true );
96 QLabel *introduction = new QLabel(
97 qtr( "VLC media player " VERSION_MESSAGE ) );
98 QLabel *iconVLC = new QLabel;
99 if( QDate::currentDate().dayOfYear() >= 354 )
100 iconVLC->setPixmap( QPixmap( ":/vlc48-christmas.png" ) );
102 iconVLC->setPixmap( QPixmap( ":/vlc48.png" ) );
103 layout->addWidget( iconVLC, 0, 0, 1, 1 );
104 layout->addWidget( introduction, 0, 1, 1, 7 );
105 layout->addWidget( tab, 1, 0, 1, 8 );
106 layout->addWidget( closeButton, 2, 6, 1, 2 );
108 /* Main Introduction */
109 QWidget *infoWidget = new QWidget( this );
110 QHBoxLayout *infoLayout = new QHBoxLayout( infoWidget );
111 QLabel *infoLabel = new QLabel(
112 qtr( "VLC media player is a free media player, "
113 "encoder and streamer that can read from files, "
114 "CDs, DVDs, network streams, capture cards and even more!\n"
115 "Also, VLC works on essentially every popular platform.\n\n" )
116 + qtr( "This version of VLC was compiled by:\n " )
117 + qfu( VLC_CompileBy() )+ "@" + qfu( VLC_CompileHost() ) + "."
118 + qfu( VLC_CompileDomain() ) + ".\n"
119 + "Compiler: " + qfu( VLC_Compiler() ) + ".\n"
120 + qtr( "Based on SVN revision: " ) + qfu( VLC_Changeset() ) + ".\n"
121 + qtr( "You are using the Qt4 Interface.\n\n" )
122 + qtr( "Copyright (c) " COPYRIGHT_YEARS " by the VideoLAN Team.\n" )
123 + "vlc@videolan.org, http://www.videolan.org" );
124 infoLabel->setWordWrap( infoLabel );
126 QLabel *iconVLC2 = new QLabel;
127 if( QDate::currentDate().dayOfYear() >= 354 )
128 iconVLC2->setPixmap( QPixmap( ":/vlc128-christmas.png" ) );
130 iconVLC2->setPixmap( QPixmap( ":/vlc128.png" ) );
131 infoLayout->addWidget( iconVLC2 );
132 infoLayout->addWidget( infoLabel );
135 QTextEdit *licenseEdit = new QTextEdit( this );
136 licenseEdit->setText( qfu( psz_license ) );
137 licenseEdit->setReadOnly( true );
139 /* People who helped */
140 QWidget *thanksWidget = new QWidget( this );
141 QVBoxLayout *thanksLayout = new QVBoxLayout( thanksWidget );
143 QLabel *thanksLabel = new QLabel( qtr( "We would like to thank the whole "
144 "community, the testers, our users and the following people "
145 "(and the missing ones...) for their collaboration to "
146 "provide the best software." ) );
147 thanksLabel->setWordWrap( true );
148 thanksLayout->addWidget( thanksLabel );
149 QTextEdit *thanksEdit = new QTextEdit( this );
150 thanksEdit->setText( qfu( psz_thanks ) );
151 thanksEdit->setReadOnly( true );
152 thanksLayout->addWidget( thanksEdit );
154 /* People who wrote the software */
155 QTextEdit *authorsEdit = new QTextEdit( this );
156 authorsEdit->setText( qfu( psz_authors ) );
157 authorsEdit->setReadOnly( true );
159 /* add the tabs to the Tabwidget */
160 tab->addTab( infoWidget, qtr( "About" ) );
161 tab->addTab( authorsEdit, qtr( "Authors" ) );
162 tab->addTab( thanksWidget, qtr("Thanks") );
163 tab->addTab( licenseEdit, qtr("License") );
165 BUTTONACT( closeButton, close() );
168 AboutDialog::~AboutDialog()
171 void AboutDialog::close()
173 this->toggleVisible();
178 /*****************************************************************************
180 *****************************************************************************/
181 /* callback to get information from the core */
182 static void UpdateCallback( void *data, vlc_bool_t b_ret )
184 UpdateDialog* UDialog = (UpdateDialog *)data;
188 event = new QEvent( (QEvent::Type)UDOkEvent );
190 event = new QEvent( (QEvent::Type)UDErrorEvent );
192 QApplication::postEvent( UDialog, event );
195 UpdateDialog *UpdateDialog::instance = NULL;
197 UpdateDialog::UpdateDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
199 setWindowTitle( qtr( "Update" ) );
202 QGridLayout *layout = new QGridLayout( this );
204 QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
205 updateButton = new QPushButton( qtr( "&Update List" ) );
206 updateButton->setDefault( true );
207 QDialogButtonBox *buttonBox = new QDialogButtonBox( Qt::Horizontal );
208 buttonBox->addButton( updateButton, QDialogButtonBox::ActionRole );
209 buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
211 updateLabel = new QLabel( qtr( "Checking for the update..." ) );
212 updateLabel->setWordWrap( true );
214 layout->addWidget( updateLabel, 0, 0 );
215 layout->addWidget( buttonBox, 1, 0 );
217 BUTTONACT( updateButton, UpdateOrDownload() );
218 BUTTONACT( closeButton, close() );
220 /* Create the update structure */
224 /* Check for updates */
228 UpdateDialog::~UpdateDialog()
230 update_Delete( p_update );
233 void UpdateDialog::close()
238 /* Check for updates */
239 void UpdateDialog::UpdateOrDownload()
243 updateButton->setEnabled( false );
244 update_Check( p_update, UpdateCallback, this );
248 updateButton->setEnabled( false );
249 QString dest_dir = QFileDialog::getExistingDirectory( this, qtr( "Select a directory ..." ),
250 qfu( p_update->p_libvlc->psz_homedir ) );
255 update_Download( p_update, qtu( dest_dir ) );
258 updateButton->setEnabled( true );
262 /* Handle the events */
263 void UpdateDialog::customEvent( QEvent *event )
265 if( event->type() == UDOkEvent )
266 updateNotify( true );
268 updateNotify( false );
271 /* Notify the end of the update_Check */
272 void UpdateDialog::updateNotify( bool b_result )
274 /* The update finish without errors */
277 if( update_CompareReleaseToCurrent( p_update ) == UpdateReleaseStatusNewer )
280 updateButton->setText( "Download" );
281 updateLabel->setText( qtr( "There is a new version of vlc :\n" ) + qfu( p_update->release.psz_desc ) );
284 updateLabel->setText( qtr( "You have the latest version of vlc" ) );
287 updateLabel->setText( qtr( "An error occure while checking for updates" ) );
290 updateButton->setEnabled( true );
293 /* Initialise the p_update struct */
294 void UpdateDialog::initUpdate()
296 p_update = update_New( p_intf );