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>
48 HelpDialog *HelpDialog::instance = NULL;
50 HelpDialog::HelpDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
52 setWindowTitle( qtr( "Help" ) );
55 QGridLayout *layout = new QGridLayout( this );
56 QTextBrowser *helpBrowser = new QTextBrowser( this );
57 helpBrowser->setOpenExternalLinks( true );
58 helpBrowser->setHtml( I_LONGHELP );
59 QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
60 closeButton->setDefault( true );
62 layout->addWidget( helpBrowser, 0, 0, 1, 0 );
63 layout->addWidget( closeButton, 1, 3 );
65 BUTTONACT( closeButton, close() );
68 HelpDialog::~HelpDialog()
71 void HelpDialog::close()
73 this->toggleVisible();
76 AboutDialog *AboutDialog::instance = NULL;
78 AboutDialog::AboutDialog( intf_thread_t *_p_intf) : QVLCFrame( _p_intf )
80 setWindowTitle( qtr( "About" ) );
83 QGridLayout *layout = new QGridLayout( this );
84 QTabWidget *tab = new QTabWidget( this );
86 QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
87 closeButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
88 closeButton->setDefault( true );
90 QLabel *introduction = new QLabel(
91 qtr( "Information about VLC media player." ) );
92 QLabel *iconVLC = new QLabel;
93 iconVLC->setPixmap( QPixmap( ":/vlc48.png" ) );
94 layout->addWidget( iconVLC, 0, 0, 1, 1 );
95 layout->addWidget( introduction, 0, 1, 1, 7 );
96 layout->addWidget( tab, 1, 0, 1, 8 );
97 layout->addWidget( closeButton, 2, 6, 1, 2 );
99 /* Main Introduction */
100 QWidget *infoWidget = new QWidget( this );
101 QHBoxLayout *infoLayout = new QHBoxLayout( infoWidget );
102 QLabel *infoLabel = new QLabel( "VLC media player " PACKAGE_VERSION "\n\n"
103 "(c) 1996-2007 - the VideoLAN Team\n\n" +
104 qtr( "VLC media player is a free media player, made by the "
105 "VideoLAN Team.\nIt is a standalone multimedia player, "
106 "encoder and streamer, that can read from many supports "
107 "(files, CDs, DVDs, networks, capture cards...) and that "
108 "works on many platforms.\n\n" )
109 + qtr( "You are using the new Qt4 Interface.\n" )
110 + qtr( "Compiled by " ) + qfu( VLC_CompileBy() )+ "@"
111 + qfu( VLC_CompileDomain() ) + ".\n"
112 + "Compiler: " + qfu( VLC_Compiler() ) + ".\n"
113 + qtr( "Based on SVN revision: " ) + qfu( VLC_Changeset() )
115 + qtr( "This program comes with NO WARRANTY, to the extent "
116 "permitted by the law; read the distribution tab.\n\n" )
117 + "The VideoLAN team <videolan@videolan.org> \n"
118 "http://www.videolan.org/\n" );
119 infoLabel->setWordWrap( infoLabel );
121 QLabel *iconVLC2 = new QLabel;
122 iconVLC2->setPixmap( QPixmap( ":/vlc128.png" ) );
123 infoLayout->addWidget( iconVLC2 );
124 infoLayout->addWidget( infoLabel );
127 QTextEdit *licenseEdit = new QTextEdit( this );
128 licenseEdit->setFontFamily( "Monospace" );
129 licenseEdit->setText( qfu( psz_license ) );
130 licenseEdit->setReadOnly( true );
132 /* People who helped */
133 QWidget *thanksWidget = new QWidget( this );
134 QVBoxLayout *thanksLayout = new QVBoxLayout( thanksWidget );
136 QLabel *thanksLabel = new QLabel( qtr( "We would like to thank the whole "
137 "community, the testers, our users and the following people "
138 "(and the missing ones...) for their collaboration to "
139 "provide the best software." ) );
140 thanksLabel->setWordWrap( true );
141 thanksLayout->addWidget( thanksLabel );
142 QTextEdit *thanksEdit = new QTextEdit( this );
143 thanksEdit->setText( qfu( psz_thanks ) );
144 thanksEdit->setReadOnly( true );
145 thanksLayout->addWidget( thanksEdit );
147 /* People who wrote the software */
148 QTextEdit *authorsEdit = new QTextEdit( this );
149 authorsEdit->setText( qfu( psz_authors ) );
150 authorsEdit->setReadOnly( true );
152 /* add the tabs to the Tabwidget */
153 tab->addTab( infoWidget, qtr( "General Info" ) );
154 tab->addTab( authorsEdit, qtr( "Authors" ) );
155 tab->addTab( thanksWidget, qtr("Thanks") );
156 tab->addTab( licenseEdit, qtr("Distribution License") );
158 BUTTONACT( closeButton, close() );
161 AboutDialog::~AboutDialog()
164 void AboutDialog::close()
166 this->toggleVisible();
171 /*****************************************************************************
173 *****************************************************************************/
174 /* callback to get information from the core */
175 static int updateCallback( vlc_object_t *p_this, char const *psz_cmd,
176 vlc_value_t oldval, vlc_value_t newval, void *data )
178 UpdateDialog* UDialog = (UpdateDialog *)data;
179 QEvent *event = new QEvent( QEvent::User );
180 QApplication::postEvent( UDialog, event );
184 UpdateDialog *UpdateDialog::instance = NULL;
186 UpdateDialog::UpdateDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
188 setWindowTitle( qtr( "Update" ) );
191 QGridLayout *layout = new QGridLayout( this );
193 QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
194 updateButton = new QPushButton( qtr( "&Update List" ) );
195 updateButton->setDefault( true );
196 QDialogButtonBox *buttonBox = new QDialogButtonBox( Qt::Horizontal );
197 buttonBox->addButton( updateButton, QDialogButtonBox::ActionRole );
198 buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
200 updateLabel = new QLabel( qtr( "Checking for the update..." ) );
201 updateLabel->setWordWrap( true );
203 layout->addWidget( updateLabel, 0, 0 );
204 layout->addWidget( buttonBox, 1, 0 );
206 BUTTONACT( updateButton, UpdateOrDownload() );
207 BUTTONACT( closeButton, close() );
209 /* create the update structure and the callback */
210 p_update = update_New( _p_intf );
211 var_AddCallback( _p_intf->p_libvlc, "update-notify", updateCallback, this );
215 UpdateDialog::~UpdateDialog()
217 var_DelCallback( p_update->p_libvlc, "update-notify", updateCallback, this );
218 update_Delete( p_update );
221 void UpdateDialog::close()
226 /* Check for updates */
227 void UpdateDialog::UpdateOrDownload()
231 updateButton->setEnabled( false );
232 update_Check( p_update );
236 updateButton->setEnabled( false );
237 QString dest_dir = QFileDialog::getExistingDirectory( this, qtr( "Select a directory ..." ),
238 qfu( p_update->p_libvlc->psz_homedir ) );
243 update_Download( p_update, qtu( dest_dir ) );
246 updateButton->setEnabled( true );
250 /* Handle the events */
251 void UpdateDialog::customEvent( QEvent *event )
256 /* Notify the end of the update_Check */
257 void UpdateDialog::updateNotify()
259 if( update_CompareReleaseToCurrent( p_update ) == UpdateReleaseStatusNewer )
262 updateButton->setText( "Download" );
263 updateLabel->setText( qtr( "There is a new version of vlc :\n" ) + qfu( p_update->release.psz_desc ) );
267 updateLabel->setText( qtr( "You have the latest version of vlc" ) );
270 updateButton->setEnabled( true );