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>
47 #include <QPushButton>
51 HelpDialog::HelpDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
54 setWindowTitle( qtr( "Help" ) );
55 setWindowRole( "vlc-help" );
56 setMinimumSize( 350, 300 );
58 QVBoxLayout *layout = new QVBoxLayout( this );
60 QTextBrowser *helpBrowser = new QTextBrowser( this );
61 helpBrowser->setOpenExternalLinks( true );
62 helpBrowser->setHtml( qtr(I_LONGHELP) );
64 QDialogButtonBox *closeButtonBox = new QDialogButtonBox( this );
65 closeButtonBox->addButton(
66 new QPushButton( qtr("&Close") ), QDialogButtonBox::RejectRole );
67 closeButtonBox->setFocus();
69 layout->addWidget( helpBrowser );
70 layout->addWidget( closeButtonBox );
72 CONNECT( closeButtonBox, rejected(), this, close() );
73 readSettings( "Help", QSize( 500, 450 ) );
76 HelpDialog::~HelpDialog()
78 writeSettings( "Help" );
81 AboutDialog::AboutDialog( intf_thread_t *_p_intf)
82 : QVLCDialog( (QWidget*)_p_intf->p_sys->p_mi, _p_intf )
86 ui.closeButtonBox->addButton(
87 new QPushButton( qtr("&Close"), this ), QDialogButtonBox::RejectRole );
89 setWindowTitle( qtr( "About" ) );
90 setWindowRole( "vlc-about" );
91 setMinimumSize( 600, 500 );
93 setWindowModality( Qt::WindowModal );
95 CONNECT( ui.closeButtonBox, rejected(), this, close() );
96 ui.closeButtonBox->setFocus();
98 ui.introduction->setText(
99 qtr( "VLC media player" ) + qfu( " " VERSION_MESSAGE ) );
101 if( QDate::currentDate().dayOfYear() >= QT_XMAS_JOKE_DAY && var_InheritBool( p_intf, "qt-icon-change" ) )
102 ui.iconVLC->setPixmap( QPixmap( ":/logo/vlc128-xmas.png" ) );
104 ui.iconVLC->setPixmap( QPixmap( ":/logo/vlc128.png" ) );
106 /* Main Introduction */
107 ui.infoLabel->setText(
108 qtr( "VLC media player is a free media player, "
109 "encoder and streamer that can read from files, "
110 "CDs, DVDs, network streams, capture cards and even more!\n"
111 "VLC uses its internal codecs and works on essentially every "
112 "popular platform.\n\n" )
113 + qtr( "This version of VLC was compiled by:\n " )
114 + qfu( VLC_CompileBy() )+ " on " + qfu( VLC_CompileHost() ) +
115 + " ("__DATE__" "__TIME__").\n"
116 + qtr( "Compiler: " ) + qfu( VLC_Compiler() ) + ".\n"
117 + qtr( "You are using the Qt4 Interface.\n\n" )
118 + qtr( "Copyright (C) " ) + COPYRIGHT_YEARS
119 + qtr( " by the VideoLAN Team.\n" )
120 + "vlc@videolan.org, http://www.videolan.org" );
123 ui.licenseEdit->setText( qfu( psz_license ) );
125 /* People who helped */
126 ui.thanksEdit->setText( qfu( psz_thanks ) );
128 /* People who wrote the software */
129 ui.authorsEdit->setText( qfu( psz_authors ) );
134 /*****************************************************************************
136 *****************************************************************************/
137 /* callback to get information from the core */
138 static void UpdateCallback( void *data, bool b_ret )
140 UpdateDialog* UDialog = (UpdateDialog *)data;
144 event = new QEvent( (QEvent::Type)UDOkEvent );
146 event = new QEvent( (QEvent::Type)UDErrorEvent );
148 QApplication::postEvent( UDialog, event );
151 UpdateDialog::UpdateDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
155 ui.updateDialogButtonBox->addButton( new QPushButton( qtr("&Close"), this ),
156 QDialogButtonBox::RejectRole );
157 QPushButton *recheckButton = new QPushButton( qtr("&Recheck version"), this );
158 ui.updateDialogButtonBox->addButton( recheckButton, QDialogButtonBox::ActionRole );
160 ui.updateNotifyButtonBox->addButton( new QPushButton( qtr("&Yes"), this ),
161 QDialogButtonBox::AcceptRole );
162 ui.updateNotifyButtonBox->addButton( new QPushButton( qtr("&No"), this ),
163 QDialogButtonBox::RejectRole );
165 setWindowTitle( qtr( "VLC media player updates" ) );
166 setWindowRole( "vlc-update" );
168 BUTTONACT( recheckButton, UpdateOrDownload() );
169 CONNECT( ui.updateDialogButtonBox, rejected(), this, close() );
171 CONNECT( ui.updateNotifyButtonBox, accepted(), this, UpdateOrDownload() );
172 CONNECT( ui.updateNotifyButtonBox, rejected(), this, close() );
174 /* Create the update structure */
175 p_update = update_New( p_intf );
178 setMinimumSize( 300, 300 );
179 setMaximumSize( 400, 300 );
181 readSettings( "Update", QSize( 300, 250 ) );
183 /* Check for updates */
187 UpdateDialog::~UpdateDialog()
189 update_Delete( p_update );
190 writeSettings( "Update" );
193 /* Check for updates */
194 void UpdateDialog::UpdateOrDownload()
198 ui.stackedWidget->setCurrentWidget( ui.updateRequestPage );
199 update_Check( p_update, UpdateCallback, this );
203 QString dest_dir = QDir::tempPath();
204 if( !dest_dir.isEmpty() )
206 dest_dir = toNativeSepNoSlash( dest_dir ) + DIR_SEP;
207 msg_Dbg( p_intf, "Downloading to folder: %s", qtu( dest_dir ) );
209 update_Download( p_update, qtu( dest_dir ) );
210 /* FIXME: We should trigger a change to another dialog here ! */
215 /* Handle the events */
216 void UpdateDialog::customEvent( QEvent *event )
218 if( event->type() == UDOkEvent )
219 updateNotify( true );
221 updateNotify( false );
224 /* Notify the end of the update_Check */
225 void UpdateDialog::updateNotify( bool b_result )
227 /* The update finish without errors */
230 if( update_NeedUpgrade( p_update ) )
232 ui.stackedWidget->setCurrentWidget( ui.updateNotifyPage );
233 update_release_t *p_release = update_GetRelease( p_update );
236 QString message = QString(
237 qtr( "A new version of VLC (%1.%2.%3%4) is available." ) )
238 .arg( QString::number( p_release->i_major ) )
239 .arg( QString::number( p_release->i_minor ) )
240 .arg( QString::number( p_release->i_revision ) )
241 .arg( p_release->i_extra == 0 ? "" : "." + QString::number( p_release->i_extra ) );
243 ui.updateNotifyLabel->setText( message );
244 ui.updateNotifyTextEdit->setText( qfu( p_release->psz_desc ) );
246 /* Force the dialog to be shown */
251 ui.stackedWidget->setCurrentWidget( ui.updateDialogPage );
252 ui.updateDialogLabel->setText(
253 qtr( "You have the latest version of VLC media player." ) );
258 ui.stackedWidget->setCurrentWidget( ui.updateDialogPage );
259 ui.updateDialogLabel->setText(
260 qtr( "An error occurred while checking for updates..." ) );