Happy new year
[vlc.git] / modules / gui / qt4 / dialogs / help.cpp
blob8ca2dbe5986981aaab3b33638436392f897cc2c9
1 /*****************************************************************************
2 * Help.cpp : Help and About dialogs
3 ****************************************************************************
4 * Copyright (C) 2007 the VideoLAN team
5 * $Id$
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 *****************************************************************************/
25 #include <vlc/vlc.h>
27 #include "dialogs/help.hpp"
28 #include <vlc_about.h>
30 #ifdef UPDATE_CHECK
31 #include <vlc_update.h>
32 #endif
34 #include "dialogs_provider.hpp"
36 #include <vlc_intf_strings.h>
38 #include <QTextBrowser>
39 #include <QTabWidget>
40 #include <QFile>
41 #include <QLabel>
42 #include <QString>
43 #include <QDialogButtonBox>
44 #include <QEvent>
45 #include <QFileDialog>
46 #include <QDate>
49 HelpDialog *HelpDialog::instance = NULL;
51 HelpDialog::HelpDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
53 setWindowTitle( qtr( "Help" ) );
54 resize( 600, 560 );
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" ) );
82 resize( 600, 500 );
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" ) );
96 else
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_CompileDomain() ) + ".\n"
116 + "Compiler: " + qfu( VLC_Compiler() ) + ".\n"
117 + qtr( "Based on SVN revision: " ) + qfu( VLC_Changeset() )
118 + ".\n\n"
119 + qtr( "This program comes with NO WARRANTY, to the extent "
120 "permitted by the law; read the distribution tab.\n\n" )
121 + "The VideoLAN team <videolan@videolan.org> \n"
122 "http://www.videolan.org/\n" );
123 infoLabel->setWordWrap( infoLabel );
125 QLabel *iconVLC2 = new QLabel;
126 if( QDate::currentDate().dayOfYear() >= 354 )
127 iconVLC2->setPixmap( QPixmap( ":/vlc128-christmas.png" ) );
128 else
129 iconVLC2->setPixmap( QPixmap( ":/vlc128.png" ) );
130 infoLayout->addWidget( iconVLC2 );
131 infoLayout->addWidget( infoLabel );
133 /* GPL License */
134 QTextEdit *licenseEdit = new QTextEdit( this );
135 licenseEdit->setFontFamily( "Monospace" );
136 licenseEdit->setText( qfu( psz_license ) );
137 licenseEdit->setReadOnly( true );
139 /* People who helped */
140 QWidget *thanksWidget = new QWidget( this );
141 QVBoxLayout *thanksLayout = new QVBoxLayout( thanksWidget );
143 QLabel *thanksLabel = new QLabel( qtr( "We would like to thank the whole "
144 "community, the testers, our users and the following people "
145 "(and the missing ones...) for their collaboration to "
146 "provide the best software." ) );
147 thanksLabel->setWordWrap( true );
148 thanksLayout->addWidget( thanksLabel );
149 QTextEdit *thanksEdit = new QTextEdit( this );
150 thanksEdit->setText( qfu( psz_thanks ) );
151 thanksEdit->setReadOnly( true );
152 thanksLayout->addWidget( thanksEdit );
154 /* People who wrote the software */
155 QTextEdit *authorsEdit = new QTextEdit( this );
156 authorsEdit->setText( qfu( psz_authors ) );
157 authorsEdit->setReadOnly( true );
159 /* add the tabs to the Tabwidget */
160 tab->addTab( infoWidget, qtr( "General Info" ) );
161 tab->addTab( authorsEdit, qtr( "Authors" ) );
162 tab->addTab( thanksWidget, qtr("Thanks") );
163 tab->addTab( licenseEdit, qtr("Distribution License") );
165 BUTTONACT( closeButton, close() );
168 AboutDialog::~AboutDialog()
171 void AboutDialog::close()
173 this->toggleVisible();
176 #ifdef UPDATE_CHECK
178 /*****************************************************************************
179 * UpdateDialog
180 *****************************************************************************/
181 /* callback to get information from the core */
182 static void UpdateCallback( void *data )
184 UpdateDialog* UDialog = (UpdateDialog *)data;
185 QEvent *event = new QEvent( QEvent::User );
186 QApplication::postEvent( UDialog, event );
189 UpdateDialog *UpdateDialog::instance = NULL;
191 UpdateDialog::UpdateDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
193 setWindowTitle( qtr( "Update" ) );
194 resize( 120, 80 );
196 QGridLayout *layout = new QGridLayout( this );
198 QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
199 updateButton = new QPushButton( qtr( "&Update List" ) );
200 updateButton->setDefault( true );
201 QDialogButtonBox *buttonBox = new QDialogButtonBox( Qt::Horizontal );
202 buttonBox->addButton( updateButton, QDialogButtonBox::ActionRole );
203 buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
205 updateLabel = new QLabel( qtr( "Checking for the update..." ) );
206 updateLabel->setWordWrap( true );
208 layout->addWidget( updateLabel, 0, 0 );
209 layout->addWidget( buttonBox, 1, 0 );
211 BUTTONACT( updateButton, UpdateOrDownload() );
212 BUTTONACT( closeButton, close() );
214 /* create the update structure and the callback */
215 p_update = update_New( _p_intf );
216 b_checked = false;
219 UpdateDialog::~UpdateDialog()
221 update_Delete( p_update );
224 void UpdateDialog::close()
226 toggleVisible();
229 /* Check for updates */
230 void UpdateDialog::UpdateOrDownload()
232 if( !b_checked )
234 updateButton->setEnabled( false );
235 update_Check( p_update, UpdateCallback, this );
237 else
239 updateButton->setEnabled( false );
240 QString dest_dir = QFileDialog::getExistingDirectory( this, qtr( "Select a directory ..." ),
241 qfu( p_update->p_libvlc->psz_homedir ) );
243 if( dest_dir != "" )
245 toggleVisible();
246 update_Download( p_update, qtu( dest_dir ) );
248 else
249 updateButton->setEnabled( true );
253 /* Handle the events */
254 void UpdateDialog::customEvent( QEvent *event )
256 updateNotify();
259 /* Notify the end of the update_Check */
260 void UpdateDialog::updateNotify()
262 if( update_CompareReleaseToCurrent( p_update ) == UpdateReleaseStatusNewer )
264 b_checked = true;
265 updateButton->setText( "Download" );
266 updateLabel->setText( qtr( "There is a new version of vlc :\n" ) + qfu( p_update->release.psz_desc ) );
268 else
270 updateLabel->setText( qtr( "You have the latest version of vlc" ) );
272 adjustSize();
273 updateButton->setEnabled( true );
277 #endif