]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs/help.cpp
modules/gui/qt4: add an update dialog box to the help menu. (Patch by Remi Duraffort...
[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 <QCheckBox>
39 #include <QGroupBox>
40 #include <QDialogButtonBox>
41
42 HelpDialog *HelpDialog::instance = NULL;
43
44 HelpDialog::HelpDialog( intf_thread_t *_p_intf) : QVLCFrame( _p_intf )
45 {
46     setWindowTitle( qtr( "Help" ) );
47     resize( 600, 560 );
48
49     QGridLayout *layout = new QGridLayout( this );
50     QTextBrowser *helpBrowser = new QTextBrowser( this );
51     helpBrowser->setOpenExternalLinks( true );
52     helpBrowser->setHtml( I_LONGHELP );
53     QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
54     closeButton->setDefault( true );
55
56     layout->addWidget( helpBrowser, 0, 0, 1, 0 );
57     layout->addWidget( closeButton, 1, 3 );
58
59     BUTTONACT( closeButton, close() );
60 }
61
62 HelpDialog::~HelpDialog()
63 {
64 }
65 void HelpDialog::close()
66 {
67     this->toggleVisible();
68 }
69
70 AboutDialog *AboutDialog::instance = NULL;
71
72 AboutDialog::AboutDialog( intf_thread_t *_p_intf) :  QVLCFrame( _p_intf )
73 {
74     setWindowTitle( qtr( "About" ) );
75     resize( 600, 500 );
76
77     QGridLayout *layout = new QGridLayout( this );
78     QTabWidget *tab = new QTabWidget( this );
79
80     QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
81     closeButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
82     closeButton->setDefault( true );
83
84     QLabel *introduction = new QLabel(
85             qtr( "Information about VLC media player." ) );
86     QLabel *iconVLC = new QLabel;
87     iconVLC->setPixmap( QPixmap( ":/vlc48.png" ) );
88     layout->addWidget( iconVLC, 0, 0, 1, 1 );
89     layout->addWidget( introduction, 0, 1, 1, 7 );
90     layout->addWidget( tab, 1, 0, 1, 8 );
91     layout->addWidget( closeButton, 2, 6, 1, 2 );
92
93     /* Main Introduction */
94     QWidget *infoWidget = new QWidget( this );
95     QHBoxLayout *infoLayout = new QHBoxLayout( infoWidget );
96     QLabel *infoLabel = new QLabel( "VLC media player " PACKAGE_VERSION "\n\n"
97             "(c) 1996-2007 - the VideoLAN Team\n\n" +
98             qtr( "VLC media player is a free media player, made by the "
99                 "VideoLAN Team.\nIt is a standalone multimedia player, "
100                 "encoder and streamer, that can read from many supports "
101                 "(files, CDs, DVDs, networks, capture cards...) and that "
102                 "works on many platforms.\n\n" )
103             + qtr( "You are using the new Qt4 Interface.\n" )
104             + qtr( "Compiled by " ) + qfu( VLC_CompileBy() )+ "@"
105             + qfu( VLC_CompileDomain() ) + ".\n"
106             + "Compiler: " + qfu( VLC_Compiler() ) +".\n"
107             + qtr( "Based on SVN revision: " ) + qfu( VLC_Changeset() )
108             + ".\n\n"
109             + qtr( "This program comes with NO WARRANTY, to the extent "
110                 "permitted by the law; read the distribution tab.\n\n" )
111             + "The VideoLAN team <videolan@videolan.org> \n"
112               "http://www.videolan.org/\n") ;
113     infoLabel->setWordWrap( infoLabel );
114
115     QLabel *iconVLC2 = new QLabel;
116     iconVLC2->setPixmap( QPixmap( ":/vlc128.png" ) );
117     infoLayout->addWidget( iconVLC2 );
118     infoLayout->addWidget( infoLabel );
119
120     /* GPL License */
121     QTextEdit *licenseEdit = new QTextEdit( this );
122     licenseEdit->setFontFamily( "Monospace" );
123     licenseEdit->setText( qfu( psz_license ) );
124     licenseEdit->setReadOnly( true );
125
126     /* People who helped */
127     QWidget *thanksWidget = new QWidget( this );
128     QVBoxLayout *thanksLayout = new QVBoxLayout( thanksWidget );
129
130     QLabel *thanksLabel = new QLabel( qtr("We would like to thank the whole "
131                 "community, the testers, our users and the following people "
132                 "(and the missing ones...) for their collaboration to "
133                 "provide the best software." ) );
134     thanksLabel->setWordWrap( true );
135     thanksLayout->addWidget( thanksLabel );
136     QTextEdit *thanksEdit = new QTextEdit( this );
137     thanksEdit->setText( qfu( psz_thanks ) );
138     thanksEdit->setReadOnly( true );
139     thanksLayout->addWidget( thanksEdit );
140
141     /* People who wrote the software */
142     QTextEdit *authorsEdit = new QTextEdit( this );
143     authorsEdit->setText( qfu( psz_authors ) );
144     authorsEdit->setReadOnly( true );
145
146     /* add the tabs to the Tabwidget */
147     tab->addTab( infoWidget, qtr( "General Info" ) );
148     tab->addTab( authorsEdit, qtr( "Authors" ) );
149     tab->addTab( thanksWidget, qtr("Thanks") );
150     tab->addTab( licenseEdit, qtr("Distribution License") );
151
152     BUTTONACT( closeButton, close() );
153 }
154
155 AboutDialog::~AboutDialog()
156 {
157 }
158 void AboutDialog::close()
159 {
160     this->toggleVisible();
161 }
162
163
164 UpdateDialog *UpdateDialog::instance = NULL;
165
166 UpdateDialog::UpdateDialog( intf_thread_t *_p_intf) : QVLCFrame( _p_intf )
167 {
168     setWindowTitle( qtr( "Update" ) );
169     resize( 230, 180 );
170
171     QGridLayout *layout = new QGridLayout( this );
172
173     QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
174     QPushButton *updateButton = new QPushButton( qtr( "&Update List" ) );
175     updateButton->setDefault( true );
176     QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Horizontal);
177     buttonBox->addButton( updateButton, QDialogButtonBox::ActionRole );
178     buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
179
180     QGroupBox *checkGroup = new QGroupBox( qtr( "Select Package" ) );
181     QGridLayout *checkLayout = new QGridLayout( checkGroup );
182     checkInfo = new QCheckBox( qtr( "Information" ) );
183     checkSource = new QCheckBox( qtr( "Sources" ) );
184     checkBinary = new QCheckBox( qtr( "Binary" ) );
185     checkPlugin = new QCheckBox( qtr( "Plugin" ) );
186
187     checkInfo->setDisabled( true );
188     checkSource->setDisabled( true );
189     checkBinary->setDisabled( true );
190     checkPlugin->setDisabled( true );
191
192     checkLayout->addWidget( checkInfo, 0, 0 );
193     checkLayout->addWidget( checkSource, 1, 0 );
194     checkLayout->addWidget( checkBinary, 2, 0 );
195     checkLayout->addWidget( checkPlugin, 3, 0 );
196
197     layout->addWidget( checkGroup, 0, 0 );
198     layout->addWidget( buttonBox, 1, 0 );
199
200     BUTTONACT( updateButton, update() );
201     BUTTONACT( closeButton, close() );
202
203     p_update = update_New( _p_intf );
204 }
205
206 UpdateDialog::~UpdateDialog()
207 {
208     update_Delete( p_update );
209 }
210
211 void UpdateDialog::close()
212 {
213     toggleVisible();
214 }
215
216 void UpdateDialog::update()
217 {
218     update_Check( p_update, VLC_FALSE );
219     update_iterator_t *p_uit = update_iterator_New( p_update );
220     if( p_uit )
221     {
222         p_uit->i_rs = UPDATE_RELEASE_STATUS_NEWER;
223         p_uit->i_t = UPDATE_FILE_TYPE_ALL;
224         update_iterator_Action( p_uit, UPDATE_MIRROR );
225         while( update_iterator_Action( p_uit, UPDATE_FILE ) != UPDATE_FAIL )
226         {
227             switch( p_uit->file.i_type )
228             {
229             case UPDATE_FILE_TYPE_INFO:
230                 checkInfo->setDisabled( false );
231                 checkInfo->setCheckState( Qt::Checked );
232                 break;
233             case UPDATE_FILE_TYPE_SOURCE:
234                 checkSource->setDisabled( false );
235                 checkSource->setCheckState( Qt::Checked );
236                 break;
237             case UPDATE_FILE_TYPE_BINARY:
238                 checkBinary->setDisabled( false );
239                 checkBinary->setCheckState( Qt::Checked );
240                 break;
241             case UPDATE_FILE_TYPE_PLUGIN:
242                 checkPlugin->setDisabled( false );
243                 checkPlugin->setCheckState( Qt::Checked );
244                 break;
245             default:
246                 break;
247             }
248         }
249     }
250     update_iterator_Delete( p_uit );
251 }