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 *****************************************************************************/
30 #include "dialogs/help.hpp"
31 #include "util/qt_dirs.hpp"
33 #include <vlc_about.h>
34 #include <vlc_intf_strings.h>
37 # include <vlc_update.h>
40 #include <QTextBrowser>
44 #include <QDialogButtonBox>
46 #include <QFileDialog>
48 #include <QPushButton>
52 HelpDialog::HelpDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
55 setWindowTitle( qtr( "Help" ) );
56 setWindowRole( "vlc-help" );
57 setMinimumSize( 350, 300 );
59 QVBoxLayout *layout = new QVBoxLayout( this );
61 QTextBrowser *helpBrowser = new QTextBrowser( this );
62 helpBrowser->setOpenExternalLinks( true );
63 helpBrowser->setHtml( qtr(I_LONGHELP) );
65 QDialogButtonBox *closeButtonBox = new QDialogButtonBox( this );
66 closeButtonBox->addButton(
67 new QPushButton( qtr("&Close") ), QDialogButtonBox::RejectRole );
68 closeButtonBox->setFocus();
70 layout->addWidget( helpBrowser );
71 layout->addWidget( closeButtonBox );
73 CONNECT( closeButtonBox, rejected(), this, close() );
74 readSettings( "Help", QSize( 500, 450 ) );
77 HelpDialog::~HelpDialog()
79 writeSettings( "Help" );
82 AboutDialog::AboutDialog( intf_thread_t *_p_intf)
83 : QVLCDialog( (QWidget*)_p_intf->p_sys->p_mi, _p_intf )
87 ui.closeButtonBox->addButton(
88 new QPushButton( qtr("&Close"), this ), QDialogButtonBox::RejectRole );
90 setWindowTitle( qtr( "About" ) );
91 setWindowRole( "vlc-about" );
92 setMinimumSize( 600, 500 );
94 setWindowModality( Qt::WindowModal );
96 CONNECT( ui.closeButtonBox, rejected(), this, close() );
97 ui.closeButtonBox->setFocus();
99 ui.introduction->setText(
100 qtr( "VLC media player" ) + qfu( " " VERSION_MESSAGE ) );
102 if( QDate::currentDate().dayOfYear() >= QT_XMAS_JOKE_DAY && var_InheritBool( p_intf, "qt-icon-change" ) )
103 ui.iconVLC->setPixmap( QPixmap( ":/logo/vlc128-xmas.png" ) );
105 ui.iconVLC->setPixmap( QPixmap( ":/logo/vlc128.png" ) );
107 /* Main Introduction */
108 ui.infoLabel->setText(
109 qtr( "VLC media player is a free media player, "
110 "encoder and streamer that can read from files, "
111 "CDs, DVDs, network streams, capture cards and even more!\n"
112 "VLC uses its internal codecs and works on essentially every "
113 "popular platform.\n\n" )
114 + qtr( "This version of VLC was compiled by:\n " )
115 + qfu( VLC_CompileBy() )+ " on " + qfu( VLC_CompileHost() ) +
116 + " ("__DATE__" "__TIME__").\n"
117 + qtr( "Compiler: " ) + qfu( VLC_Compiler() ) + ".\n"
118 + qtr( "You are using the Qt4 Interface.\n\n" )
119 + qtr( "Copyright (C) " ) + COPYRIGHT_YEARS
120 + qtr( " by the VideoLAN Team.\n" )
121 + "vlc@videolan.org, http://www.videolan.org" );
124 ui.licenseEdit->setText( qfu( psz_license ) );
126 /* People who helped */
127 ui.thanksEdit->setText( qfu( psz_thanks ) );
129 /* People who wrote the software */
130 ui.authorsEdit->setText( qfu( psz_authors ) );
135 /*****************************************************************************
137 *****************************************************************************/
138 /* callback to get information from the core */
139 static void UpdateCallback( void *data, bool b_ret )
141 UpdateDialog* UDialog = (UpdateDialog *)data;
145 event = new QEvent( (QEvent::Type)UDOkEvent );
147 event = new QEvent( (QEvent::Type)UDErrorEvent );
149 QApplication::postEvent( UDialog, event );
152 UpdateDialog::UpdateDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
156 ui.updateDialogButtonBox->addButton( new QPushButton( qtr("&Close"), this ),
157 QDialogButtonBox::RejectRole );
158 QPushButton *recheckButton = new QPushButton( qtr("&Recheck version"), this );
159 ui.updateDialogButtonBox->addButton( recheckButton, QDialogButtonBox::ActionRole );
161 ui.updateNotifyButtonBox->addButton( new QPushButton( qtr("&Yes"), this ),
162 QDialogButtonBox::AcceptRole );
163 ui.updateNotifyButtonBox->addButton( new QPushButton( qtr("&No"), this ),
164 QDialogButtonBox::RejectRole );
166 setWindowTitle( qtr( "VLC media player updates" ) );
167 setWindowRole( "vlc-update" );
169 BUTTONACT( recheckButton, UpdateOrDownload() );
170 CONNECT( ui.updateDialogButtonBox, rejected(), this, close() );
172 CONNECT( ui.updateNotifyButtonBox, accepted(), this, UpdateOrDownload() );
173 CONNECT( ui.updateNotifyButtonBox, rejected(), this, close() );
175 /* Create the update structure */
176 p_update = update_New( p_intf );
179 setMinimumSize( 300, 300 );
180 setMaximumSize( 400, 300 );
182 readSettings( "Update", QSize( 300, 250 ) );
184 /* Check for updates */
188 UpdateDialog::~UpdateDialog()
190 update_Delete( p_update );
191 writeSettings( "Update" );
194 /* Check for updates */
195 void UpdateDialog::UpdateOrDownload()
199 ui.stackedWidget->setCurrentWidget( ui.updateRequestPage );
200 update_Check( p_update, UpdateCallback, this );
204 QString dest_dir = QFileDialog::getExistingDirectory( this,
206 QVLCUserDir( VLC_DOWNLOAD_DIR ) );
208 if( !dest_dir.isEmpty() )
210 dest_dir = toNativeSepNoSlash( dest_dir ) + DIR_SEP;
211 msg_Dbg( p_intf, "Downloading to folder: %s", qtu( dest_dir ) );
213 update_Download( p_update, qtu( dest_dir ) );
214 /* FIXME: We should trigger a change to another dialog here ! */
219 /* Handle the events */
220 void UpdateDialog::customEvent( QEvent *event )
222 if( event->type() == UDOkEvent )
223 updateNotify( true );
225 updateNotify( false );
228 /* Notify the end of the update_Check */
229 void UpdateDialog::updateNotify( bool b_result )
231 /* The update finish without errors */
234 if( update_NeedUpgrade( p_update ) )
236 ui.stackedWidget->setCurrentWidget( ui.updateNotifyPage );
237 update_release_t *p_release = update_GetRelease( p_update );
240 QString message = QString(
241 qtr( "A new version of VLC (%1.%2.%3%4) is available." ) )
242 .arg( QString::number( p_release->i_major ) )
243 .arg( QString::number( p_release->i_minor ) )
244 .arg( QString::number( p_release->i_revision ) )
245 .arg( p_release->i_extra == 0 ? "" : "." + QString::number( p_release->i_extra ) );
247 ui.updateNotifyLabel->setText( message );
248 ui.updateNotifyTextEdit->setText( qfu( p_release->psz_desc ) );
250 /* Force the dialog to be shown */
255 ui.stackedWidget->setCurrentWidget( ui.updateDialogPage );
256 ui.updateDialogLabel->setText(
257 qtr( "You have the latest version of VLC media player." ) );
262 ui.stackedWidget->setCurrentWidget( ui.updateDialogPage );
263 ui.updateDialogLabel->setText(
264 qtr( "An error occurred while checking for updates..." ) );