]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs/help.cpp
409dbafce3911f0ab2b3376df971c1e86fc68ca8
[vlc] / modules / gui / qt4 / dialogs / help.cpp
1 /*****************************************************************************
2  * Help.cpp : Help and About dialogs
3  ****************************************************************************
4  * Copyright (C) 2007 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Jean-Baptiste Kempf <jb (at) videolan.org>
8  *          RĂ©mi Duraffort <ivoire (at) via.ecp.fr>
9  *
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.
14  *
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.
19  *
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  *****************************************************************************/
24
25 #include "dialogs/help.hpp"
26 #include <vlc_about.h>
27 #include <vlc_update.h>
28
29 #include "dialogs_provider.hpp"
30
31 #include <vlc_intf_strings.h>
32
33 #include <QTextBrowser>
34 #include <QTabWidget>
35 #include <QFile>
36 #include <QLabel>
37 #include <QString>
38 #include <QDialogButtonBox>
39
40
41 HelpDialog *HelpDialog::instance = NULL;
42
43 HelpDialog::HelpDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
44 {
45     setWindowTitle( qtr( "Help" ) );
46     resize( 600, 560 );
47
48     QGridLayout *layout = new QGridLayout( this );
49     QTextBrowser *helpBrowser = new QTextBrowser( this );
50     helpBrowser->setOpenExternalLinks( true );
51     helpBrowser->setHtml( I_LONGHELP );
52     QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
53     closeButton->setDefault( true );
54
55     layout->addWidget( helpBrowser, 0, 0, 1, 0 );
56     layout->addWidget( closeButton, 1, 3 );
57
58     BUTTONACT( closeButton, close() );
59 }
60
61 HelpDialog::~HelpDialog()
62 {
63 }
64 void HelpDialog::close()
65 {
66     this->toggleVisible();
67 }
68
69 AboutDialog *AboutDialog::instance = NULL;
70
71 AboutDialog::AboutDialog( intf_thread_t *_p_intf) :  QVLCFrame( _p_intf )
72 {
73     setWindowTitle( qtr( "About" ) );
74     resize( 600, 500 );
75
76     QGridLayout *layout = new QGridLayout( this );
77     QTabWidget *tab = new QTabWidget( this );
78
79     QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
80     closeButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
81     closeButton->setDefault( true );
82
83     QLabel *introduction = new QLabel(
84             qtr( "Information about VLC media player." ) );
85     QLabel *iconVLC = new QLabel;
86     iconVLC->setPixmap( QPixmap( ":/vlc48.png" ) );
87     layout->addWidget( iconVLC, 0, 0, 1, 1 );
88     layout->addWidget( introduction, 0, 1, 1, 7 );
89     layout->addWidget( tab, 1, 0, 1, 8 );
90     layout->addWidget( closeButton, 2, 6, 1, 2 );
91
92     /* Main Introduction */
93     QWidget *infoWidget = new QWidget( this );
94     QHBoxLayout *infoLayout = new QHBoxLayout( infoWidget );
95     QLabel *infoLabel = new QLabel( "VLC media player " PACKAGE_VERSION "\n\n"
96             "(c) 1996-2007 - the VideoLAN Team\n\n" +
97             qtr( "VLC media player is a free media player, made by the "
98                  "VideoLAN Team.\nIt is a standalone multimedia player, "
99                  "encoder and streamer, that can read from many supports "
100                  "(files, CDs, DVDs, networks, capture cards...) and that "
101                  "works on many platforms.\n\n" )
102             + qtr( "You are using the new Qt4 Interface.\n" )
103             + qtr( "Compiled by " ) + qfu( VLC_CompileBy() )+ "@"
104             + qfu( VLC_CompileDomain() ) + ".\n"
105             + "Compiler: " + qfu( VLC_Compiler() ) + ".\n"
106             + qtr( "Based on SVN revision: " ) + qfu( VLC_Changeset() )
107             + ".\n\n"
108             + qtr( "This program comes with NO WARRANTY, to the extent "
109                 "permitted by the law; read the distribution tab.\n\n" )
110             + "The VideoLAN team <videolan@videolan.org> \n"
111               "http://www.videolan.org/\n" );
112     infoLabel->setWordWrap( infoLabel );
113
114     QLabel *iconVLC2 = new QLabel;
115     iconVLC2->setPixmap( QPixmap( ":/vlc128.png" ) );
116     infoLayout->addWidget( iconVLC2 );
117     infoLayout->addWidget( infoLabel );
118
119     /* GPL License */
120     QTextEdit *licenseEdit = new QTextEdit( this );
121     licenseEdit->setFontFamily( "Monospace" );
122     licenseEdit->setText( qfu( psz_license ) );
123     licenseEdit->setReadOnly( true );
124
125     /* People who helped */
126     QWidget *thanksWidget = new QWidget( this );
127     QVBoxLayout *thanksLayout = new QVBoxLayout( thanksWidget );
128
129     QLabel *thanksLabel = new QLabel( qtr( "We would like to thank the whole "
130                 "community, the testers, our users and the following people "
131                 "(and the missing ones...) for their collaboration to "
132                 "provide the best software." ) );
133     thanksLabel->setWordWrap( true );
134     thanksLayout->addWidget( thanksLabel );
135     QTextEdit *thanksEdit = new QTextEdit( this );
136     thanksEdit->setText( qfu( psz_thanks ) );
137     thanksEdit->setReadOnly( true );
138     thanksLayout->addWidget( thanksEdit );
139
140     /* People who wrote the software */
141     QTextEdit *authorsEdit = new QTextEdit( this );
142     authorsEdit->setText( qfu( psz_authors ) );
143     authorsEdit->setReadOnly( true );
144
145     /* add the tabs to the Tabwidget */
146     tab->addTab( infoWidget, qtr( "General Info" ) );
147     tab->addTab( authorsEdit, qtr( "Authors" ) );
148     tab->addTab( thanksWidget, qtr("Thanks") );
149     tab->addTab( licenseEdit, qtr("Distribution License") );
150
151     BUTTONACT( closeButton, close() );
152 }
153
154 AboutDialog::~AboutDialog()
155 {
156 }
157 void AboutDialog::close()
158 {
159     this->toggleVisible();
160 }
161
162
163 UpdateDialog *UpdateDialog::instance = NULL;
164
165 UpdateDialog::UpdateDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
166 {
167     setWindowTitle( qtr( "Update" ) );
168     resize( 320, 120 );
169
170     QGridLayout *layout = new QGridLayout( this );
171
172     updateBrowser = new QTextBrowser( this );
173     updateBrowser->setOpenExternalLinks( true );
174     updateBrowser->setHtml( qtr( "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=\"utf-8\" /></head> \
175                                   <body><center>Push the update button to get the updates</center></body></html>" ) );
176     
177     QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
178     QPushButton *updateButton = new QPushButton( qtr( "&Update List" ) );
179     updateButton->setDefault( true );
180     QDialogButtonBox *buttonBox = new QDialogButtonBox( Qt::Horizontal );
181     buttonBox->addButton( updateButton, QDialogButtonBox::ActionRole );
182     buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
183
184     layout->addWidget( updateBrowser, 0, 0 );
185     layout->addWidget( buttonBox, 1, 0 );
186
187     BUTTONACT( updateButton, updateOrUpload() );
188     BUTTONACT( closeButton, close() );
189
190     p_update = update_New( _p_intf );
191 }
192
193 UpdateDialog::~UpdateDialog()
194 {
195     update_Delete( p_update );
196 }
197
198 void UpdateDialog::close()
199 {
200     toggleVisible();
201 }
202
203 void UpdateDialog::updateOrUpload()
204 {
205     update_Check( p_update );
206
207     if( update_CompareReleaseToCurrent( p_update ) == UpdateReleaseStatusNewer )
208     {
209         updateBrowser->setHtml( qtr( "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=\"utf-8\" /></head> \
210                                       <body><center><p>" ) + qtu( (QString)p_update->release.psz_desc ) +
211                                       qtr( "</p>You can download the latest version of VLC <a href=\"" ) +
212                                       qtu( (QString)p_update->release.psz_url ) + qtr( "\">here</a></center></body></html>" ) );
213     }
214     else
215     {
216         updateBrowser->setHtml( "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=\"utf-8\" /></head> \
217                                  <body><center>You have the latest version of VLC.</center></body></html>" );
218     }
219 }