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>
50 HelpDialog::HelpDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
53 setWindowTitle( qtr( "Help" ) );
54 setWindowRole( "vlc-help" );
55 setMinimumSize( 350, 300 );
57 QGridLayout *layout = new QGridLayout( this );
58 QTextBrowser *helpBrowser = new QTextBrowser( this );
59 helpBrowser->setOpenExternalLinks( true );
60 helpBrowser->setHtml( qtr(I_LONGHELP) );
61 QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
62 closeButton->setDefault( true );
64 layout->addWidget( helpBrowser, 0, 0, 1, 0 );
65 layout->addWidget( closeButton, 1, 3 );
67 BUTTONACT( closeButton, close() );
68 readSettings( "Help", QSize( 500, 450 ) );
71 HelpDialog::~HelpDialog()
73 writeSettings( "Help" );
76 void HelpDialog::close()
81 AboutDialog::AboutDialog( intf_thread_t *_p_intf)
82 : QVLCDialog( (QWidget*)_p_intf->p_sys->p_mi, _p_intf )
84 setWindowTitle( qtr( "About" ) );
85 setWindowRole( "vlc-about" );
87 setMinimumSize( 600, 500 );
89 QGridLayout *layout = new QGridLayout( this );
90 QTabWidget *tab = new QTabWidget( this );
92 QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
93 closeButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
94 closeButton->setDefault( true );
96 QLabel *introduction = new QLabel(
97 qtr( "VLC media player" ) + qfu( " " VERSION_MESSAGE ) );
98 QLabel *iconVLC = new QLabel;
99 if( QDate::currentDate().dayOfYear() >= 354 )
100 iconVLC->setPixmap( QPixmap( ":/logo/vlc48-christmas.png" ) );
102 iconVLC->setPixmap( QPixmap( ":/logo/vlc48.png" ) );
103 layout->addWidget( iconVLC, 0, 0, 1, 1 );
104 layout->addWidget( introduction, 0, 1, 1, 7 );
105 layout->addWidget( tab, 1, 0, 1, 8 );
106 layout->addWidget( closeButton, 2, 6, 1, 2 );
108 /* Main Introduction */
109 QWidget *infoWidget = new QWidget( this );
110 QHBoxLayout *infoLayout = new QHBoxLayout( infoWidget );
111 QLabel *infoLabel = new QLabel(
112 qtr( "VLC media player is a free media player, "
113 "encoder and streamer that can read from files, "
114 "CDs, DVDs, network streams, capture cards and even more!\n"
115 "VLC uses its internal codecs and works on essentially every "
116 "popular platform.\n\n" )
117 + qtr( "This version of VLC was compiled by:\n " )
118 + qfu( VLC_CompileBy() )+ "@" + qfu( VLC_CompileHost() ) + "."
119 + qfu( VLC_CompileDomain() ) + ".\n"
120 + qtr( "Compiler: " ) + qfu( VLC_Compiler() ) + ".\n"
121 + qtr( "You are using the Qt4 Interface.\n\n" )
122 + qtr( "Copyright (C) " ) + COPYRIGHT_YEARS
123 + qtr( " by the VideoLAN Team.\n" )
124 + "vlc@videolan.org, http://www.videolan.org" );
125 infoLabel->setWordWrap( infoLabel );
127 QLabel *iconVLC2 = new QLabel;
128 if( QDate::currentDate().dayOfYear() >= 354 )
129 iconVLC2->setPixmap( QPixmap( ":/logo/vlc128-christmas.png" ) );
131 iconVLC2->setPixmap( QPixmap( ":/logo/vlc128.png" ) );
132 infoLayout->addWidget( iconVLC2 );
133 infoLayout->addWidget( infoLabel );
136 QTextEdit *licenseEdit = new QTextEdit( this );
137 licenseEdit->setText( qfu( psz_license ) );
138 licenseEdit->setReadOnly( true );
140 /* People who helped */
141 QWidget *thanksWidget = new QWidget( this );
142 QVBoxLayout *thanksLayout = new QVBoxLayout( thanksWidget );
144 QLabel *thanksLabel = new QLabel( qtr( "We would like to thank the whole "
145 "VLC community, the testers, our users and the following people "
146 "(and the missing ones...) for their collaboration to "
147 "create the best free software." ) );
148 thanksLabel->setWordWrap( true );
149 thanksLayout->addWidget( thanksLabel );
150 QTextEdit *thanksEdit = new QTextEdit( this );
151 thanksEdit->setText( qfu( psz_thanks ) );
152 thanksEdit->setReadOnly( true );
153 thanksLayout->addWidget( thanksEdit );
155 /* People who wrote the software */
156 QTextEdit *authorsEdit = new QTextEdit( this );
157 authorsEdit->setText( qfu( psz_authors ) );
158 authorsEdit->setReadOnly( true );
160 /* add the tabs to the Tabwidget */
161 tab->addTab( infoWidget, qtr( "About" ) );
162 tab->addTab( authorsEdit, qtr( "Authors" ) );
163 tab->addTab( thanksWidget, qtr("Thanks") );
164 tab->addTab( licenseEdit, qtr("License") );
166 BUTTONACT( closeButton, close() );
169 AboutDialog::~AboutDialog()
173 void AboutDialog::close()
180 /*****************************************************************************
182 *****************************************************************************/
183 /* callback to get information from the core */
184 static void UpdateCallback( void *data, bool b_ret )
186 UpdateDialog* UDialog = (UpdateDialog *)data;
190 event = new QEvent( (QEvent::Type)UDOkEvent );
192 event = new QEvent( (QEvent::Type)UDErrorEvent );
194 QApplication::postEvent( UDialog, event );
197 UpdateDialog::UpdateDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
199 setWindowTitle( qtr( "VLC media player updates" ) );
200 setWindowRole( "vlc-update" );
202 QGridLayout *layout = new QGridLayout( this );
204 QPushButton *closeButton = new QPushButton( qtr( "&Cancel" ) );
205 updateButton = new QPushButton( qtr( "&Recheck version" ) );
206 updateButton->setDefault( true );
208 QDialogButtonBox *buttonBox = new QDialogButtonBox( Qt::Horizontal );
209 buttonBox->addButton( updateButton, QDialogButtonBox::ActionRole );
210 buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
212 updateLabelTop = new QLabel( qtr( "Checking for an update..." ) );
213 updateLabelTop->setWordWrap( true );
214 updateLabelTop->setMargin( 8 );
216 updateLabelDown = new QLabel( qtr( "\nDo you want to download it?\n" ) );
217 updateLabelDown->setWordWrap( true );
218 updateLabelDown->hide();
220 updateText = new QTextEdit( this );
221 updateText->setAcceptRichText(false);
222 updateText->setTextInteractionFlags( Qt::TextSelectableByKeyboard|
223 Qt::TextSelectableByMouse);
224 updateText->setEnabled( false );
226 layout->addWidget( updateLabelTop, 0, 0 );
227 layout->addWidget( updateText, 1, 0 );
228 layout->addWidget( updateLabelDown, 2, 0 );
229 layout->addWidget( buttonBox, 3, 0 );
231 BUTTONACT( updateButton, UpdateOrDownload() );
232 BUTTONACT( closeButton, close() );
234 /* Create the update structure */
235 p_update = update_New( p_intf );
238 setMinimumSize( 300, 300 );
239 setMaximumSize( 400, 300 );
241 readSettings( "Update", QSize( 300, 250 ) );
243 /* Check for updates */
247 UpdateDialog::~UpdateDialog()
249 update_Delete( p_update );
250 writeSettings( "Update" );
253 void UpdateDialog::close()
258 /* Check for updates */
259 void UpdateDialog::UpdateOrDownload()
263 updateButton->setEnabled( false );
264 updateLabelTop->setText( qtr( "Launching an update request..." ) );
265 update_Check( p_update, UpdateCallback, this );
269 QString dest_dir = QFileDialog::getExistingDirectory( this,
270 qtr( "Select a directory..." ),
271 QVLCUserDir( VLC_DOWNLOAD_DIR ) );
273 if( !dest_dir.isEmpty() )
275 dest_dir = toNativeSepNoSlash( dest_dir ) + DIR_SEP;
276 msg_Dbg( p_intf, "Downloading to folder: %s", qtu( dest_dir ) );
278 update_Download( p_update, qtu( dest_dir ) );
283 /* Handle the events */
284 void UpdateDialog::customEvent( QEvent *event )
286 if( event->type() == UDOkEvent )
287 updateNotify( true );
289 updateNotify( false );
292 /* Notify the end of the update_Check */
293 void UpdateDialog::updateNotify( bool b_result )
295 /* The update finish without errors */
298 if( update_NeedUpgrade( p_update ) )
300 update_release_t *p_release = update_GetRelease( p_update );
303 updateButton->setText( qtr( "&Yes" ) );
304 QString message = qtr( "A new version of VLC(" )
305 + QString::number( p_release->i_major ) + "."
306 + QString::number( p_release->i_minor ) + "."
307 + QString::number( p_release->i_revision );
308 if( p_release->extra )
309 message += p_release->extra;
310 message += qtr( ") is available.");
311 updateLabelTop->setText( message );
313 updateText->setText( qfu( p_release->psz_desc ) );
314 updateText->setEnabled( true );
316 updateLabelDown->show();
318 /* Force the dialog to be shown */
322 updateLabelTop->setText(
323 qtr( "You have the latest version of VLC media player." ) );
326 updateLabelTop->setText(
327 qtr( "An error occurred while checking for updates..." ) );
329 updateButton->setEnabled( true );