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 )
85 setWindowTitle( qtr( "About" ) );
86 setWindowRole( "vlc-about" );
88 setMinimumSize( 600, 500 );
89 setWindowModality( Qt::WindowModal );
91 QGridLayout *layout = new QGridLayout( this );
92 QTabWidget *tab = new QTabWidget( this );
94 QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
95 closeButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
96 closeButton->setDefault( true );
98 QLabel *introduction = new QLabel(
99 qtr( "VLC media player" ) + qfu( " " VERSION_MESSAGE ) );
100 QLabel *iconVLC = new QLabel;
101 if( QDate::currentDate().dayOfYear() >= 354 )
102 iconVLC->setPixmap( QPixmap( ":/logo/vlc48-christmas.png" ) );
104 iconVLC->setPixmap( QPixmap( ":/logo/vlc48.png" ) );
105 layout->addWidget( iconVLC, 0, 0, 1, 1 );
106 layout->addWidget( introduction, 0, 1, 1, 7 );
107 layout->addWidget( tab, 1, 0, 1, 8 );
108 layout->addWidget( closeButton, 2, 6, 1, 2 );
110 /* Main Introduction */
111 QWidget *infoWidget = new QWidget( this );
112 QHBoxLayout *infoLayout = new QHBoxLayout( infoWidget );
113 QLabel *infoLabel = new QLabel(
114 qtr( "VLC media player is a free media player, "
115 "encoder and streamer that can read from files, "
116 "CDs, DVDs, network streams, capture cards and even more!\n"
117 "VLC uses its internal codecs and works on essentially every "
118 "popular platform.\n\n" )
119 + qtr( "This version of VLC was compiled by:\n " )
120 + qfu( VLC_CompileBy() )+ " on " + qfu( VLC_CompileHost() ) +
121 + " ("__DATE__" "__TIME__").\n"
122 + qtr( "Compiler: " ) + qfu( VLC_Compiler() ) + ".\n"
123 + qtr( "You are using the Qt4 Interface.\n\n" )
124 + qtr( "Copyright (C) " ) + COPYRIGHT_YEARS
125 + qtr( " by the VideoLAN Team.\n" )
126 + "vlc@videolan.org, http://www.videolan.org" );
127 infoLabel->setWordWrap( infoLabel );
129 QLabel *iconVLC2 = new QLabel;
130 if( QDate::currentDate().dayOfYear() >= 354 )
131 iconVLC2->setPixmap( QPixmap( ":/logo/vlc128-christmas.png" ) );
133 iconVLC2->setPixmap( QPixmap( ":/logo/vlc128.png" ) );
134 infoLayout->addWidget( iconVLC2 );
135 infoLayout->addWidget( infoLabel );
138 QTextEdit *licenseEdit = new QTextEdit( this );
139 licenseEdit->setText( qfu( psz_license ) );
140 licenseEdit->setReadOnly( true );
142 /* People who helped */
143 QWidget *thanksWidget = new QWidget( this );
144 QVBoxLayout *thanksLayout = new QVBoxLayout( thanksWidget );
146 QLabel *thanksLabel = new QLabel( qtr( "We would like to thank the whole "
147 "VLC community, the testers, our users and the following people "
148 "(and the missing ones...) for their collaboration to "
149 "create the best free software." ) );
150 thanksLabel->setWordWrap( true );
151 thanksLayout->addWidget( thanksLabel );
152 QTextEdit *thanksEdit = new QTextEdit( this );
153 thanksEdit->setText( qfu( psz_thanks ) );
154 thanksEdit->setReadOnly( true );
155 thanksLayout->addWidget( thanksEdit );
157 /* People who wrote the software */
158 QTextEdit *authorsEdit = new QTextEdit( this );
159 authorsEdit->setText( qfu( psz_authors ) );
160 authorsEdit->setReadOnly( true );
162 /* add the tabs to the Tabwidget */
163 tab->addTab( infoWidget, qtr( "About" ) );
164 tab->addTab( authorsEdit, qtr( "Authors" ) );
165 tab->addTab( thanksWidget, qtr("Thanks") );
166 tab->addTab( licenseEdit, qtr("License") );
168 BUTTONACT( closeButton, close() );
171 AboutDialog::~AboutDialog()
175 void AboutDialog::close()
182 /*****************************************************************************
184 *****************************************************************************/
185 /* callback to get information from the core */
186 static void UpdateCallback( void *data, bool b_ret )
188 UpdateDialog* UDialog = (UpdateDialog *)data;
192 event = new QEvent( (QEvent::Type)UDOkEvent );
194 event = new QEvent( (QEvent::Type)UDErrorEvent );
196 QApplication::postEvent( UDialog, event );
199 UpdateDialog::UpdateDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
201 setWindowTitle( qtr( "VLC media player updates" ) );
202 setWindowRole( "vlc-update" );
204 QGridLayout *layout = new QGridLayout( this );
206 QPushButton *closeButton = new QPushButton( qtr( "&Cancel" ) );
207 updateButton = new QPushButton( qtr( "&Recheck version" ) );
208 updateButton->setDefault( true );
210 QDialogButtonBox *buttonBox = new QDialogButtonBox( Qt::Horizontal );
211 buttonBox->addButton( updateButton, QDialogButtonBox::ActionRole );
212 buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
214 updateLabelTop = new QLabel( qtr( "Checking for an update..." ) );
215 updateLabelTop->setWordWrap( true );
216 updateLabelTop->setMargin( 8 );
218 updateLabelDown = new QLabel( qtr( "\nDo you want to download it?\n" ) );
219 updateLabelDown->setWordWrap( true );
220 updateLabelDown->hide();
222 updateText = new QTextEdit( this );
223 updateText->setAcceptRichText(false);
224 updateText->setTextInteractionFlags( Qt::TextSelectableByKeyboard|
225 Qt::TextSelectableByMouse);
226 updateText->setEnabled( false );
228 layout->addWidget( updateLabelTop, 0, 0 );
229 layout->addWidget( updateText, 1, 0 );
230 layout->addWidget( updateLabelDown, 2, 0 );
231 layout->addWidget( buttonBox, 3, 0 );
233 BUTTONACT( updateButton, UpdateOrDownload() );
234 BUTTONACT( closeButton, close() );
236 /* Create the update structure */
237 p_update = update_New( p_intf );
240 setMinimumSize( 300, 300 );
241 setMaximumSize( 400, 300 );
243 readSettings( "Update", QSize( 300, 250 ) );
245 /* Check for updates */
249 UpdateDialog::~UpdateDialog()
251 update_Delete( p_update );
252 writeSettings( "Update" );
255 void UpdateDialog::close()
260 /* Check for updates */
261 void UpdateDialog::UpdateOrDownload()
265 updateButton->setEnabled( false );
266 updateLabelTop->setText( qtr( "Launching an update request..." ) );
267 update_Check( p_update, UpdateCallback, this );
271 QString dest_dir = QFileDialog::getExistingDirectory( this,
273 QVLCUserDir( VLC_DOWNLOAD_DIR ) );
275 if( !dest_dir.isEmpty() )
277 dest_dir = toNativeSepNoSlash( dest_dir ) + DIR_SEP;
278 msg_Dbg( p_intf, "Downloading to folder: %s", qtu( dest_dir ) );
280 update_Download( p_update, qtu( dest_dir ) );
285 /* Handle the events */
286 void UpdateDialog::customEvent( QEvent *event )
288 if( event->type() == UDOkEvent )
289 updateNotify( true );
291 updateNotify( false );
294 /* Notify the end of the update_Check */
295 void UpdateDialog::updateNotify( bool b_result )
297 /* The update finish without errors */
300 if( update_NeedUpgrade( p_update ) )
302 update_release_t *p_release = update_GetRelease( p_update );
305 updateButton->setText( qtr( "&Yes" ) );
306 QString message = qtr( "A new version of VLC(" )
307 + QString::number( p_release->i_major ) + "."
308 + QString::number( p_release->i_minor ) + "."
309 + QString::number( p_release->i_revision );
310 if( p_release->extra )
311 message += p_release->extra;
312 message += qtr( ") is available.");
313 updateLabelTop->setText( message );
315 updateText->setText( qfu( p_release->psz_desc ) );
316 updateText->setEnabled( true );
318 updateLabelDown->show();
320 /* Force the dialog to be shown */
324 updateLabelTop->setText(
325 qtr( "You have the latest version of VLC media player." ) );
328 updateLabelTop->setText(
329 qtr( "An error occurred while checking for updates..." ) );
331 updateButton->setEnabled( true );