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 restoreWidgetPosition( "Help", QSize( 500, 450 ) );
76 HelpDialog::~HelpDialog()
78 saveWidgetPosition( "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 Qt Interface.\n\n" )
118 + qtr( "Copyright (C) " ) + COPYRIGHT_YEARS
119 + qtr( " by the VideoLAN Team.\n" )
120 + "<a href=\"http://www.videolan.org\">http://www.videolan.org</a>" );
122 /* Be translators friendly: Convert to rich text */
123 ui.infoLabel->setText( ui.infoLabel->text().replace( "\n", "<br/>" ) );
126 ui.licenseEdit->setText( qfu( psz_license ) );
128 /* People who helped */
129 ui.thanksEdit->setText( qfu( psz_thanks ) );
131 /* People who wrote the software */
132 ui.authorsEdit->setText( qfu( psz_authors ) );
137 /*****************************************************************************
139 *****************************************************************************/
140 /* callback to get information from the core */
141 static void UpdateCallback( void *data, bool b_ret )
143 UpdateDialog* UDialog = (UpdateDialog *)data;
147 event = new QEvent( UpdateDialog::UDOkEvent );
149 event = new QEvent( UpdateDialog::UDErrorEvent );
151 QApplication::postEvent( UDialog, event );
154 const QEvent::Type UpdateDialog::UDOkEvent =
155 (QEvent::Type)QEvent::registerEventType();
156 const QEvent::Type UpdateDialog::UDErrorEvent =
157 (QEvent::Type)QEvent::registerEventType();
159 UpdateDialog::UpdateDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
163 ui.updateDialogButtonBox->addButton( new QPushButton( qtr("&Close"), this ),
164 QDialogButtonBox::RejectRole );
165 QPushButton *recheckButton = new QPushButton( qtr("&Recheck version"), this );
166 ui.updateDialogButtonBox->addButton( recheckButton, QDialogButtonBox::ActionRole );
168 ui.updateNotifyButtonBox->addButton( new QPushButton( qtr("&Yes"), this ),
169 QDialogButtonBox::AcceptRole );
170 ui.updateNotifyButtonBox->addButton( new QPushButton( qtr("&No"), this ),
171 QDialogButtonBox::RejectRole );
173 setWindowTitle( qtr( "VLC media player updates" ) );
174 setWindowRole( "vlc-update" );
176 BUTTONACT( recheckButton, UpdateOrDownload() );
177 CONNECT( ui.updateDialogButtonBox, rejected(), this, close() );
179 CONNECT( ui.updateNotifyButtonBox, accepted(), this, UpdateOrDownload() );
180 CONNECT( ui.updateNotifyButtonBox, rejected(), this, close() );
182 /* Create the update structure */
183 p_update = update_New( p_intf );
186 setMinimumSize( 300, 300 );
187 setMaximumSize( 500, 300 );
189 restoreWidgetPosition( "Update", maximumSize() );
191 /* Check for updates */
195 UpdateDialog::~UpdateDialog()
197 update_Delete( p_update );
198 saveWidgetPosition( "Update" );
201 /* Check for updates */
202 void UpdateDialog::UpdateOrDownload()
206 ui.stackedWidget->setCurrentWidget( ui.updateRequestPage );
207 update_Check( p_update, UpdateCallback, this );
211 QString dest_dir = QDir::tempPath();
212 if( !dest_dir.isEmpty() )
214 dest_dir = toNativeSepNoSlash( dest_dir ) + DIR_SEP;
215 msg_Dbg( p_intf, "Downloading to folder: %s", qtu( dest_dir ) );
217 update_Download( p_update, qtu( dest_dir ) );
218 /* FIXME: We should trigger a change to another dialog here ! */
223 /* Handle the events */
224 void UpdateDialog::customEvent( QEvent *event )
226 if( event->type() == UDOkEvent )
227 updateNotify( true );
229 updateNotify( false );
232 /* Notify the end of the update_Check */
233 void UpdateDialog::updateNotify( bool b_result )
235 /* The update finish without errors */
238 if( update_NeedUpgrade( p_update ) )
240 ui.stackedWidget->setCurrentWidget( ui.updateNotifyPage );
241 update_release_t *p_release = update_GetRelease( p_update );
244 QString message = QString(
245 qtr( "A new version of VLC (%1.%2.%3%4) is available." ) )
246 .arg( QString::number( p_release->i_major ) )
247 .arg( QString::number( p_release->i_minor ) )
248 .arg( QString::number( p_release->i_revision ) )
249 .arg( p_release->i_extra == 0 ? "" : "." + QString::number( p_release->i_extra ) );
251 ui.updateNotifyLabel->setText( message );
252 ui.updateNotifyTextEdit->setText( qfu( p_release->psz_desc ) );
254 /* Force the dialog to be shown */
259 ui.stackedWidget->setCurrentWidget( ui.updateDialogPage );
260 ui.updateDialogLabel->setText(
261 qtr( "You have the latest version of VLC media player." ) );
266 ui.stackedWidget->setCurrentWidget( ui.updateDialogPage );
267 ui.updateDialogLabel->setText(
268 qtr( "An error occurred while checking for updates..." ) );