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_CompileDomain() ) + ".\n"
116 + "Compiler: " + qfu( VLC_Compiler() ) + ".\n"
117 + qtr( "Based on SVN revision: " ) + qfu( VLC_Changeset() )
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" ) );
129 iconVLC2
->setPixmap( QPixmap( ":/vlc128.png" ) );
130 infoLayout
->addWidget( iconVLC2
);
131 infoLayout
->addWidget( infoLabel
);
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();
178 /*****************************************************************************
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" ) );
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
);
219 UpdateDialog::~UpdateDialog()
221 update_Delete( p_update
);
224 void UpdateDialog::close()
229 /* Check for updates */
230 void UpdateDialog::UpdateOrDownload()
234 updateButton
->setEnabled( false );
235 update_Check( p_update
, UpdateCallback
, this );
239 updateButton
->setEnabled( false );
240 QString dest_dir
= QFileDialog::getExistingDirectory( this, qtr( "Select a directory ..." ),
241 qfu( p_update
->p_libvlc
->psz_homedir
) );
246 update_Download( p_update
, qtu( dest_dir
) );
249 updateButton
->setEnabled( true );
253 /* Handle the events */
254 void UpdateDialog::customEvent( QEvent
*event
)
259 /* Notify the end of the update_Check */
260 void UpdateDialog::updateNotify()
262 if( update_CompareReleaseToCurrent( p_update
) == UpdateReleaseStatusNewer
)
265 updateButton
->setText( "Download" );
266 updateLabel
->setText( qtr( "There is a new version of vlc :\n" ) + qfu( p_update
->release
.psz_desc
) );
270 updateLabel
->setText( qtr( "You have the latest version of vlc" ) );
273 updateButton
->setEnabled( true );