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 *****************************************************************************/
27 #include "dialogs/help.hpp"
28 #include <vlc_about.h>
31 #include <vlc_update.h>
34 #include "dialogs_provider.hpp"
36 #include <vlc_intf_strings.h>
38 #include <QTextBrowser>
43 #include <QDialogButtonBox>
45 #include <QFileDialog>
49 HelpDialog *HelpDialog::instance = NULL;
51 HelpDialog::HelpDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
53 setWindowTitle( qtr( "Help" ) );
56 QGridLayout *layout = new QGridLayout( this );
57 QTextBrowser *helpBrowser = new QTextBrowser( this );
58 helpBrowser->setOpenExternalLinks( true );
59 helpBrowser->setHtml( I_LONGHELP );
60 QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
61 closeButton->setDefault( true );
63 layout->addWidget( helpBrowser, 0, 0, 1, 0 );
64 layout->addWidget( closeButton, 1, 3 );
66 BUTTONACT( closeButton, close() );
69 HelpDialog::~HelpDialog()
72 void HelpDialog::close()
74 this->toggleVisible();
77 AboutDialog *AboutDialog::instance = NULL;
79 AboutDialog::AboutDialog( intf_thread_t *_p_intf) : QVLCFrame( _p_intf )
81 setWindowTitle( qtr( "About" ) );
84 QGridLayout *layout = new QGridLayout( this );
85 QTabWidget *tab = new QTabWidget( this );
87 QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
88 closeButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
89 closeButton->setDefault( true );
91 QLabel *introduction = new QLabel(
92 qtr( "Information about VLC media player." ) );
93 QLabel *iconVLC = new QLabel;
94 if( QDate::currentDate().dayOfYear() >= 354 )
95 iconVLC->setPixmap( QPixmap( ":/vlc48-christmas.png" ) );
97 iconVLC->setPixmap( QPixmap( ":/vlc48.png" ) );
98 layout->addWidget( iconVLC, 0, 0, 1, 1 );
99 layout->addWidget( introduction, 0, 1, 1, 7 );
100 layout->addWidget( tab, 1, 0, 1, 8 );
101 layout->addWidget( closeButton, 2, 6, 1, 2 );
103 /* Main Introduction */
104 QWidget *infoWidget = new QWidget( this );
105 QHBoxLayout *infoLayout = new QHBoxLayout( infoWidget );
106 QLabel *infoLabel = new QLabel( "VLC media player " VERSION_MESSAGE "\n\n"
107 "(c) " COPYRIGHT_YEARS " - the VideoLAN Team\n\n" +
108 qtr( "VLC media player is a free media player, made by the "
109 "VideoLAN Team.\nIt is a standalone multimedia player, "
110 "encoder and streamer, that can read from many supports "
111 "(files, CDs, DVDs, networks, capture cards...) and that "
112 "works on many platforms.\n\n" )
113 + qtr( "You are using the new Qt4 Interface.\n" )
114 + qtr( "Compiled by " ) + qfu( VLC_CompileBy() )+ "@"
115 + qfu( VLC_CompileHost() ) + "."
116 + qfu( VLC_CompileDomain() ) + ".\n"
117 + "Compiler: " + qfu( VLC_Compiler() ) + ".\n"
118 + qtr( "Based on SVN revision: " ) + qfu( VLC_Changeset() )
120 + qtr( "This program comes with NO WARRANTY, to the extent "
121 "permitted by the law; read the distribution tab.\n\n" )
122 + "The VideoLAN team <videolan@videolan.org> \n"
123 "http://www.videolan.org/\n" );
124 infoLabel->setWordWrap( infoLabel );
126 QLabel *iconVLC2 = new QLabel;
127 if( QDate::currentDate().dayOfYear() >= 354 )
128 iconVLC2->setPixmap( QPixmap( ":/vlc128-christmas.png" ) );
130 iconVLC2->setPixmap( QPixmap( ":/vlc128.png" ) );
131 infoLayout->addWidget( iconVLC2 );
132 infoLayout->addWidget( infoLabel );
135 QTextEdit *licenseEdit = new QTextEdit( this );
136 licenseEdit->setFontFamily( "Monospace" );
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 "community, the testers, our users and the following people "
146 "(and the missing ones...) for their collaboration to "
147 "provide the best 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( "General Info" ) );
162 tab->addTab( authorsEdit, qtr( "Authors" ) );
163 tab->addTab( thanksWidget, qtr("Thanks") );
164 tab->addTab( licenseEdit, qtr("Distribution License") );
166 BUTTONACT( closeButton, close() );
169 AboutDialog::~AboutDialog()
172 void AboutDialog::close()
174 this->toggleVisible();
179 /*****************************************************************************
181 *****************************************************************************/
182 /* callback to get information from the core */
183 static void UpdateCallback( void *data, vlc_bool_t b_ret )
185 UpdateDialog* UDialog = (UpdateDialog *)data;
189 event = new QEvent( (QEvent::Type)UDOkEvent );
191 event = new QEvent( (QEvent::Type)UDErrorEvent );
193 QApplication::postEvent( UDialog, event );
196 UpdateDialog *UpdateDialog::instance = NULL;
198 UpdateDialog::UpdateDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
200 setWindowTitle( qtr( "Update" ) );
203 QGridLayout *layout = new QGridLayout( this );
205 QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
206 updateButton = new QPushButton( qtr( "&Update List" ) );
207 updateButton->setDefault( true );
208 QDialogButtonBox *buttonBox = new QDialogButtonBox( Qt::Horizontal );
209 buttonBox->addButton( updateButton, QDialogButtonBox::ActionRole );
210 buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
212 updateLabel = new QLabel( qtr( "Checking for the update..." ) );
213 updateLabel->setWordWrap( true );
215 layout->addWidget( updateLabel, 0, 0 );
216 layout->addWidget( buttonBox, 1, 0 );
218 BUTTONACT( updateButton, UpdateOrDownload() );
219 BUTTONACT( closeButton, close() );
221 /* create the update structure and the callback */
222 p_update = update_New( _p_intf );
226 UpdateDialog::~UpdateDialog()
228 update_Delete( p_update );
231 void UpdateDialog::close()
236 /* Check for updates */
237 void UpdateDialog::UpdateOrDownload()
241 updateButton->setEnabled( false );
242 update_Check( p_update, UpdateCallback, this );
246 updateButton->setEnabled( false );
247 QString dest_dir = QFileDialog::getExistingDirectory( this, qtr( "Select a directory ..." ),
248 qfu( p_update->p_libvlc->psz_homedir ) );
253 update_Download( p_update, qtu( dest_dir ) );
256 updateButton->setEnabled( true );
260 /* Handle the events */
261 void UpdateDialog::customEvent( QEvent *event )
263 if( event->type() == UDOkEvent )
264 updateNotify( true );
266 updateNotify( false );
269 /* Notify the end of the update_Check */
270 void UpdateDialog::updateNotify( bool b_result )
272 /* The update finish without errors */
275 if( update_CompareReleaseToCurrent( p_update ) == UpdateReleaseStatusNewer )
278 updateButton->setText( "Download" );
279 updateLabel->setText( qtr( "There is a new version of vlc :\n" ) + qfu( p_update->release.psz_desc ) );
282 updateLabel->setText( qtr( "You have the latest version of vlc" ) );
285 updateLabel->setText( qtr( "An error occure while checking for updates" ) );
288 updateButton->setEnabled( true );