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 *****************************************************************************/
29 #include <vlc_common.h>
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( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
58 setWindowTitle( qtr( "Help" ) );
59 setMinimumSize( 250, 300 );
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() );
72 readSettings( "Help", QSize( 400, 450 ) );
75 HelpDialog::~HelpDialog()
77 writeSettings( "Help" );
80 void HelpDialog::close()
85 AboutDialog *AboutDialog::instance = NULL;
87 AboutDialog::AboutDialog( QWidget *parent, intf_thread_t *_p_intf)
88 : QVLCDialog( parent, _p_intf )
90 setWindowTitle( qtr( "About" ) );
92 setMinimumSize( 600, 500 );
94 QGridLayout *layout = new QGridLayout( this );
95 QTabWidget *tab = new QTabWidget( this );
97 QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
98 closeButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
99 closeButton->setDefault( true );
101 QLabel *introduction = new QLabel(
102 qtr( "VLC media player" " " VERSION_MESSAGE ) );
103 QLabel *iconVLC = new QLabel;
104 if( QDate::currentDate().dayOfYear() >= 354 )
105 iconVLC->setPixmap( QPixmap( ":/vlc48-christmas.png" ) );
107 iconVLC->setPixmap( QPixmap( ":/vlc48.png" ) );
108 layout->addWidget( iconVLC, 0, 0, 1, 1 );
109 layout->addWidget( introduction, 0, 1, 1, 7 );
110 layout->addWidget( tab, 1, 0, 1, 8 );
111 layout->addWidget( closeButton, 2, 6, 1, 2 );
113 /* Main Introduction */
114 QWidget *infoWidget = new QWidget( this );
115 QHBoxLayout *infoLayout = new QHBoxLayout( infoWidget );
116 QLabel *infoLabel = new QLabel(
117 qtr( "VLC media player is a free media player, "
118 "encoder and streamer that can read from files, "
119 "CDs, DVDs, network streams, capture cards and even more!\n"
120 "VLC uses its internal codecs and works on essentially every "
121 "popular platform.\n\n" )
122 + qtr( "This version of VLC was compiled by:\n " )
123 + qfu( VLC_CompileBy() )+ "@" + qfu( VLC_CompileHost() ) + "."
124 + qfu( VLC_CompileDomain() ) + ".\n"
125 + "Compiler: " + qfu( VLC_Compiler() ) + ".\n"
126 + qtr( "Based on Git commit: " ) + qfu( VLC_Changeset() ) + ".\n"
127 + qtr( "You are using the Qt4 Interface.\n\n" )
128 + qtr( "Copyright (C) " COPYRIGHT_YEARS " by the VideoLAN Team.\n" )
129 + "vlc@videolan.org, http://www.videolan.org" );
130 infoLabel->setWordWrap( infoLabel );
132 QLabel *iconVLC2 = new QLabel;
133 if( QDate::currentDate().dayOfYear() >= 354 )
134 iconVLC2->setPixmap( QPixmap( ":/vlc128-christmas.png" ) );
136 iconVLC2->setPixmap( QPixmap( ":/vlc128.png" ) );
137 infoLayout->addWidget( iconVLC2 );
138 infoLayout->addWidget( infoLabel );
141 QTextEdit *licenseEdit = new QTextEdit( this );
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 "VLC community, the testers, our users and the following people "
151 "(and the missing ones...) for their collaboration to "
152 "create the best free 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( "About" ) );
167 tab->addTab( authorsEdit, qtr( "Authors" ) );
168 tab->addTab( thanksWidget, qtr("Thanks") );
169 tab->addTab( licenseEdit, qtr("License") );
171 BUTTONACT( closeButton, close() );
174 AboutDialog::~AboutDialog()
178 void AboutDialog::close()
185 /*****************************************************************************
187 *****************************************************************************/
188 /* callback to get information from the core */
189 static void UpdateCallback( void *data, bool b_ret )
191 UpdateDialog* UDialog = (UpdateDialog *)data;
195 event = new QEvent( (QEvent::Type)UDOkEvent );
197 event = new QEvent( (QEvent::Type)UDErrorEvent );
199 QApplication::postEvent( UDialog, event );
202 UpdateDialog *UpdateDialog::instance = NULL;
204 UpdateDialog::UpdateDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
206 setWindowTitle( qtr( "Update" ) );
208 QGridLayout *layout = new QGridLayout( this );
210 QPushButton *closeButton = new QPushButton( qtr( "&Cancel" ) );
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 an 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 */
227 p_update = update_New( p_intf );
230 readSettings( "Update", QSize( 120, 80 ) );
232 /* Check for updates */
236 UpdateDialog::~UpdateDialog()
238 update_Delete( p_update );
239 writeSettings( "Update" );
242 void UpdateDialog::close()
247 /* Check for updates */
248 void UpdateDialog::UpdateOrDownload()
252 updateButton->setEnabled( false );
253 msg_Dbg( p_intf, "Launching an update request" );
254 update_Check( p_update, UpdateCallback, this );
258 QString dest_dir = QFileDialog::getExistingDirectory( this,
259 qtr( "Select a directory..." ),
260 qfu( config_GetHomeDir() ) );
264 /*HACK: Qt4 isn't able to change the way OS deals with directories
265 names. Windows doesn't add an ending separator so we might add it.
267 #if defined( WIN32 ) || defined( UNDER_CE )
270 msg_Dbg( p_intf, "Downloading to folder: %s", qtu( dest_dir ) );
272 update_Download( p_update, qtu( dest_dir ) );
277 /* Handle the events */
278 void UpdateDialog::customEvent( QEvent *event )
280 if( event->type() == UDOkEvent )
281 updateNotify( true );
283 updateNotify( false );
286 /* Notify the end of the update_Check */
287 void UpdateDialog::updateNotify( bool b_result )
289 /* The update finish without errors */
292 if( update_NeedUpgrade( p_update ) )
294 update_release_t *p_release = update_GetRelease( p_update );
297 updateButton->setText( "Ok" );
298 QString message = qtr( "A new version of VLC(" )
299 + QString::number( p_release->i_major ) + "."
300 + QString::number( p_release->i_minor ) + "."
301 + QString::number( p_release->i_revision );
302 if( p_release->extra )
303 message += p_release->extra;
304 message += qtr( ") is available.\nDo you want to download it?\n" ) + qfu( p_release->psz_desc );
306 updateLabel->setText( message );
308 /* Force the dialog to be shown */
312 updateLabel->setText( qtr( "You have the latest version of VLC" ) );
315 updateLabel->setText(
316 qtr( "An error occurred while checking for updates" ) );
319 updateButton->setEnabled( true );