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" ) );
61 QGridLayout *layout = new QGridLayout( this );
62 QTextBrowser *helpBrowser = new QTextBrowser( this );
63 helpBrowser->setOpenExternalLinks( true );
64 helpBrowser->setHtml( I_LONGHELP );
65 QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
66 closeButton->setDefault( true );
68 layout->addWidget( helpBrowser, 0, 0, 1, 0 );
69 layout->addWidget( closeButton, 1, 3 );
71 BUTTONACT( closeButton, close() );
74 HelpDialog::~HelpDialog()
77 void HelpDialog::close()
79 this->toggleVisible();
82 AboutDialog *AboutDialog::instance = NULL;
84 AboutDialog::AboutDialog( intf_thread_t *_p_intf) : QVLCFrame( _p_intf )
86 setWindowTitle( qtr( "About" ) );
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( "Information about VLC media player." ) );
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( "VLC media player " VERSION_MESSAGE "\n\n"
112 "(c) " COPYRIGHT_YEARS " - the VideoLAN Team\n\n" +
113 qtr( "VLC media player is a free media player, made by the "
114 "VideoLAN Team.\nIt is a standalone multimedia player, "
115 "encoder and streamer, that can read from many supports "
116 "(files, CDs, DVDs, networks, capture cards...) and that "
117 "works on many platforms.\n\n" )
118 + qtr( "You are using the Qt4 Interface.\n" )
119 + qtr( "Compiled by " ) + qfu( VLC_CompileBy() )+ "@"
120 + qfu( VLC_CompileHost() ) + "."
121 + qfu( VLC_CompileDomain() ) + ".\n"
122 + "Compiler: " + qfu( VLC_Compiler() ) + ".\n"
123 + qtr( "Based on SVN revision: " ) + qfu( VLC_Changeset() )
125 + qtr( "This program comes with NO WARRANTY, to the extent "
126 "permitted by the law; read the distribution tab.\n\n" )
127 + "The VideoLAN team <videolan@videolan.org> \n"
128 "http://www.videolan.org/\n" );
129 infoLabel->setWordWrap( infoLabel );
131 QLabel *iconVLC2 = new QLabel;
132 if( QDate::currentDate().dayOfYear() >= 354 )
133 iconVLC2->setPixmap( QPixmap( ":/vlc128-christmas.png" ) );
135 iconVLC2->setPixmap( QPixmap( ":/vlc128.png" ) );
136 infoLayout->addWidget( iconVLC2 );
137 infoLayout->addWidget( infoLabel );
140 QTextEdit *licenseEdit = new QTextEdit( this );
141 licenseEdit->setFontFamily( "Monospace" );
142 licenseEdit->setText( qfu( psz_license ) );
143 licenseEdit->setReadOnly( true );
145 /* People who helped */
146 QWidget *thanksWidget = new QWidget( this );
147 QVBoxLayout *thanksLayout = new QVBoxLayout( thanksWidget );
149 QLabel *thanksLabel = new QLabel( qtr( "We would like to thank the whole "
150 "community, the testers, our users and the following people "
151 "(and the missing ones...) for their collaboration to "
152 "provide the best software." ) );
153 thanksLabel->setWordWrap( true );
154 thanksLayout->addWidget( thanksLabel );
155 QTextEdit *thanksEdit = new QTextEdit( this );
156 thanksEdit->setText( qfu( psz_thanks ) );
157 thanksEdit->setReadOnly( true );
158 thanksLayout->addWidget( thanksEdit );
160 /* People who wrote the software */
161 QTextEdit *authorsEdit = new QTextEdit( this );
162 authorsEdit->setText( qfu( psz_authors ) );
163 authorsEdit->setReadOnly( true );
165 /* add the tabs to the Tabwidget */
166 tab->addTab( infoWidget, qtr( "General Info" ) );
167 tab->addTab( authorsEdit, qtr( "Authors" ) );
168 tab->addTab( thanksWidget, qtr("Thanks") );
169 tab->addTab( licenseEdit, qtr("Distribution License") );
171 BUTTONACT( closeButton, close() );
174 AboutDialog::~AboutDialog()
177 void AboutDialog::close()
179 this->toggleVisible();
184 /*****************************************************************************
186 *****************************************************************************/
187 /* callback to get information from the core */
188 static void UpdateCallback( void *data, vlc_bool_t b_ret )
190 UpdateDialog* UDialog = (UpdateDialog *)data;
194 event = new QEvent( (QEvent::Type)UDOkEvent );
196 event = new QEvent( (QEvent::Type)UDErrorEvent );
198 QApplication::postEvent( UDialog, event );
201 UpdateDialog *UpdateDialog::instance = NULL;
203 UpdateDialog::UpdateDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
205 setWindowTitle( qtr( "Update" ) );
208 QGridLayout *layout = new QGridLayout( this );
210 QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
211 updateButton = new QPushButton( qtr( "&Update List" ) );
212 updateButton->setDefault( true );
213 QDialogButtonBox *buttonBox = new QDialogButtonBox( Qt::Horizontal );
214 buttonBox->addButton( updateButton, QDialogButtonBox::ActionRole );
215 buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
217 updateLabel = new QLabel( qtr( "Checking for the update..." ) );
218 updateLabel->setWordWrap( true );
220 layout->addWidget( updateLabel, 0, 0 );
221 layout->addWidget( buttonBox, 1, 0 );
223 BUTTONACT( updateButton, UpdateOrDownload() );
224 BUTTONACT( closeButton, close() );
226 /* create the update structure and the callback */
227 p_update = update_New( _p_intf );
230 /* Check for updates */
234 UpdateDialog::~UpdateDialog()
236 update_Delete( p_update );
239 void UpdateDialog::close()
244 /* Check for updates */
245 void UpdateDialog::UpdateOrDownload()
249 updateButton->setEnabled( false );
250 update_Check( p_update, UpdateCallback, this );
254 updateButton->setEnabled( false );
255 QString dest_dir = QFileDialog::getExistingDirectory( this, qtr( "Select a directory ..." ),
256 qfu( p_update->p_libvlc->psz_homedir ) );
261 update_Download( p_update, qtu( dest_dir ) );
264 updateButton->setEnabled( true );
268 /* Handle the events */
269 void UpdateDialog::customEvent( QEvent *event )
271 if( event->type() == UDOkEvent )
272 updateNotify( true );
274 updateNotify( false );
277 /* Notify the end of the update_Check */
278 void UpdateDialog::updateNotify( bool b_result )
280 /* The update finish without errors */
283 if( update_CompareReleaseToCurrent( p_update ) == UpdateReleaseStatusNewer )
286 updateButton->setText( "Download" );
287 updateLabel->setText( qtr( "There is a new version of vlc :\n" ) + qfu( p_update->release.psz_desc ) );
290 updateLabel->setText( qtr( "You have the latest version of vlc" ) );
293 updateLabel->setText( qtr( "An error occure while checking for updates" ) );
296 updateButton->setEnabled( true );