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 "dialogs/help.hpp"
30 #include "util/qt_dirs.hpp"
32 #include <vlc_about.h>
33 #include <vlc_intf_strings.h>
36 # include <vlc_update.h>
39 #include <QTextBrowser>
43 #include <QDialogButtonBox>
45 #include <QFileDialog>
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 QGridLayout
*layout
= new QGridLayout( this );
59 QTextBrowser
*helpBrowser
= new QTextBrowser( this );
60 helpBrowser
->setOpenExternalLinks( true );
61 helpBrowser
->setHtml( qtr(I_LONGHELP
) );
62 QPushButton
*closeButton
= new QPushButton( qtr( "&Close" ) );
63 closeButton
->setDefault( true );
65 layout
->addWidget( helpBrowser
, 0, 0, 1, 0 );
66 layout
->addWidget( closeButton
, 1, 3 );
68 BUTTONACT( closeButton
, close() );
69 readSettings( "Help", QSize( 500, 450 ) );
72 HelpDialog::~HelpDialog()
74 writeSettings( "Help" );
77 void HelpDialog::close()
82 AboutDialog::AboutDialog( intf_thread_t
*_p_intf
)
83 : QVLCDialog( (QWidget
*)_p_intf
->p_sys
->p_mi
, _p_intf
)
88 setWindowTitle( qtr( "About" ) );
89 setWindowRole( "vlc-about" );
91 setMinimumSize( 600, 500 );
92 setWindowModality( Qt::WindowModal
);
94 CONNECT( ui
.closeButtonBox
, rejected(), this, close() );
95 ui
.closeButtonBox
->setFocus();
97 ui
.introduction
->setText(
98 qtr( "VLC media player" ) + qfu( " " VERSION_MESSAGE
) );
100 if( QDate::currentDate().dayOfYear() >= 354 )
101 ui
.iconVLC
->setPixmap( QPixmap( ":/logo/vlc128-christmas.png" ) );
103 ui
.iconVLC
->setPixmap( QPixmap( ":/logo/vlc128.png" ) );
105 /* Main Introduction */
106 ui
.infoLabel
->setText(
107 qtr( "VLC media player is a free media player, "
108 "encoder and streamer that can read from files, "
109 "CDs, DVDs, network streams, capture cards and even more!\n"
110 "VLC uses its internal codecs and works on essentially every "
111 "popular platform.\n\n" )
112 + qtr( "This version of VLC was compiled by:\n " )
113 + qfu( VLC_CompileBy() )+ " on " + qfu( VLC_CompileHost() ) +
114 + " ("__DATE__
" "__TIME__
").\n"
115 + qtr( "Compiler: " ) + qfu( VLC_Compiler() ) + ".\n"
116 + qtr( "You are using the Qt4 Interface.\n\n" )
117 + qtr( "Copyright (C) " ) + COPYRIGHT_YEARS
118 + qtr( " by the VideoLAN Team.\n" )
119 + "vlc@videolan.org, http://www.videolan.org" );
122 ui
.licenseEdit
->setText( qfu( psz_license
) );
124 /* People who helped */
125 ui
.thanksEdit
->setText( qfu( psz_thanks
) );
127 /* People who wrote the software */
128 ui
.authorsEdit
->setText( qfu( psz_authors
) );
131 AboutDialog::~AboutDialog()
135 void AboutDialog::close()
142 /*****************************************************************************
144 *****************************************************************************/
145 /* callback to get information from the core */
146 static void UpdateCallback( void *data
, bool b_ret
)
148 UpdateDialog
* UDialog
= (UpdateDialog
*)data
;
152 event
= new QEvent( (QEvent::Type
)UDOkEvent
);
154 event
= new QEvent( (QEvent::Type
)UDErrorEvent
);
156 QApplication::postEvent( UDialog
, event
);
159 UpdateDialog::UpdateDialog( intf_thread_t
*_p_intf
) : QVLCFrame( _p_intf
)
163 setWindowTitle( qtr( "VLC media player updates" ) );
164 setWindowRole( "vlc-update" );
166 QList
<QAbstractButton
*> buttonsList
= ui
.updateDialogButtonBox
->buttons();
167 QAbstractButton
*currentButton
;
168 for ( int i
= 0; i
< buttonsList
.size() ; ++i
)
170 currentButton
= buttonsList
.at( i
);
171 if ( ui
.updateDialogButtonBox
->standardButton( currentButton
)
172 == QDialogButtonBox::Retry
)
174 currentButton
->setText( qtr( "&Recheck version" ) );
175 qobject_cast
<QPushButton
*>(currentButton
)->setDefault( true );
179 CONNECT( ui
.updateDialogButtonBox
, accepted(), this, UpdateOrDownload() );
180 CONNECT( ui
.updateDialogButtonBox
, rejected(), this, close() );
182 CONNECT( ui
.updateNotifyButtonBox
, accepted(), this, UpdateOrDownload() );
183 CONNECT( ui
.updateNotifyButtonBox
, rejected(), this, close() );
185 /* Create the update structure */
186 p_update
= update_New( p_intf
);
189 setMinimumSize( 300, 300 );
190 setMaximumSize( 400, 300 );
192 readSettings( "Update", QSize( 300, 250 ) );
194 /* Check for updates */
198 UpdateDialog::~UpdateDialog()
200 update_Delete( p_update
);
201 writeSettings( "Update" );
204 void UpdateDialog::close()
209 /* Check for updates */
210 void UpdateDialog::UpdateOrDownload()
214 ui
.stackedWidget
->setCurrentWidget( ui
.updateRequestPage
);
215 update_Check( p_update
, UpdateCallback
, this );
219 QString dest_dir
= QFileDialog::getExistingDirectory( this,
221 QVLCUserDir( VLC_DOWNLOAD_DIR
) );
223 if( !dest_dir
.isEmpty() )
225 dest_dir
= toNativeSepNoSlash( dest_dir
) + DIR_SEP
;
226 msg_Dbg( p_intf
, "Downloading to folder: %s", qtu( dest_dir
) );
228 update_Download( p_update
, qtu( dest_dir
) );
229 /* FIXME: We should trigger a change to another dialog here ! */
234 /* Handle the events */
235 void UpdateDialog::customEvent( QEvent
*event
)
237 if( event
->type() == UDOkEvent
)
238 updateNotify( true );
240 updateNotify( false );
243 /* Notify the end of the update_Check */
244 void UpdateDialog::updateNotify( bool b_result
)
246 /* The update finish without errors */
249 if( update_NeedUpgrade( p_update
) )
251 ui
.stackedWidget
->setCurrentWidget( ui
.updateNotifyPage
);
252 update_release_t
*p_release
= update_GetRelease( p_update
);
255 QString message
= QString(
256 qtr( "A new version of VLC (%1.%2.%3%4) is available." ) )
257 .arg( QString::number( p_release
->i_major
) )
258 .arg( QString::number( p_release
->i_minor
) )
259 .arg( QString::number( p_release
->i_revision
) )
260 .arg( ( p_release
->extra
)?QString( p_release
->extra
):"" );
262 ui
.updateNotifyLabel
->setText( message
);
263 ui
.updateNotifyTextEdit
->setText( qfu( p_release
->psz_desc
) );
265 /* Force the dialog to be shown */
270 ui
.stackedWidget
->setCurrentWidget( ui
.updateDialogPage
);
271 ui
.updateDialogLabel
->setText(
272 qtr( "You have the latest version of VLC media player." ) );
277 ui
.stackedWidget
->setCurrentWidget( ui
.updateDialogPage
);
278 ui
.updateDialogLabel
->setText(
279 qtr( "An error occurred while checking for updates..." ) );