help.cpp 11.4 KB
Newer Older
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
1
2
3
/*****************************************************************************
 * Help.cpp : Help and About dialogs
 ****************************************************************************
4
 * Copyright (C) 2007 the VideoLAN team
5
 * $Id$
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
6
7
 *
 * Authors: Jean-Baptiste Kempf <jb (at) videolan.org>
8
 *          Rmi Duraffort <ivoire (at) via.ecp.fr>
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

#include "dialogs/help.hpp"
Christophe Mutricy's avatar
Christophe Mutricy committed
26
#include <vlc_about.h>
27
#include <vlc_update.h>
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
28
29
30

#include "dialogs_provider.hpp"

31
32
#include <vlc_intf_strings.h>

33
#include <QTextBrowser>
34
#include <QTabWidget>
35
36
#include <QFile>
#include <QLabel>
37
#include <QString>
38
39
40
#include <QCheckBox>
#include <QGroupBox>
#include <QDialogButtonBox>
41
42
#include <QFileDialog>

43

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
44
45
HelpDialog *HelpDialog::instance = NULL;

46
HelpDialog::HelpDialog( intf_thread_t *_p_intf) : QVLCFrame( _p_intf )
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
47
48
{
    setWindowTitle( qtr( "Help" ) );
49
    resize( 600, 560 );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
50

51
52
    QGridLayout *layout = new QGridLayout( this );
    QTextBrowser *helpBrowser = new QTextBrowser( this );
53
    helpBrowser->setOpenExternalLinks( true );
54
    helpBrowser->setHtml( I_LONGHELP );
55
    QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
56
    closeButton->setDefault( true );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
57

58
59
    layout->addWidget( helpBrowser, 0, 0, 1, 0 );
    layout->addWidget( closeButton, 1, 3 );
60

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
    BUTTONACT( closeButton, close() );
}

HelpDialog::~HelpDialog()
{
}
void HelpDialog::close()
{
    this->toggleVisible();
}

AboutDialog *AboutDialog::instance = NULL;

AboutDialog::AboutDialog( intf_thread_t *_p_intf) :  QVLCFrame( _p_intf )
{
    setWindowTitle( qtr( "About" ) );
77
    resize( 600, 500 );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
78

79
80
    QGridLayout *layout = new QGridLayout( this );
    QTabWidget *tab = new QTabWidget( this );
81

82
    QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
83
    closeButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
84
    closeButton->setDefault( true );
85

86
    QLabel *introduction = new QLabel(
87
88
89
90
91
92
93
94
95
96
97
98
            qtr( "Information about VLC media player." ) );
    QLabel *iconVLC = new QLabel;
    iconVLC->setPixmap( QPixmap( ":/vlc48.png" ) );
    layout->addWidget( iconVLC, 0, 0, 1, 1 );
    layout->addWidget( introduction, 0, 1, 1, 7 );
    layout->addWidget( tab, 1, 0, 1, 8 );
    layout->addWidget( closeButton, 2, 6, 1, 2 );

    /* Main Introduction */
    QWidget *infoWidget = new QWidget( this );
    QHBoxLayout *infoLayout = new QHBoxLayout( infoWidget );
    QLabel *infoLabel = new QLabel( "VLC media player " PACKAGE_VERSION "\n\n"
Christophe Mutricy's avatar
Oups    
Christophe Mutricy committed
99
            "(c) 1996-2007 - the VideoLAN Team\n\n" +
100
101
102
            qtr( "VLC media player is a free media player, made by the "
                "VideoLAN Team.\nIt is a standalone multimedia player, "
                "encoder and streamer, that can read from many supports "
103
                "(files, CDs, DVDs, networks, capture cards...) and that "
104
                "works on many platforms.\n\n" )
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
            + qtr( "You are using the new Qt4 Interface.\n" )
            + qtr( "Compiled by " ) + qfu( VLC_CompileBy() )+ "@"
            + qfu( VLC_CompileDomain() ) + ".\n"
            + "Compiler: " + qfu( VLC_Compiler() ) +".\n"
            + qtr( "Based on SVN revision: " ) + qfu( VLC_Changeset() )
            + ".\n\n"
            + qtr( "This program comes with NO WARRANTY, to the extent "
                "permitted by the law; read the distribution tab.\n\n" )
            + "The VideoLAN team <videolan@videolan.org> \n"
              "http://www.videolan.org/\n") ;
    infoLabel->setWordWrap( infoLabel );

    QLabel *iconVLC2 = new QLabel;
    iconVLC2->setPixmap( QPixmap( ":/vlc128.png" ) );
    infoLayout->addWidget( iconVLC2 );
    infoLayout->addWidget( infoLabel );
121

122
    /* GPL License */
123
    QTextEdit *licenseEdit = new QTextEdit( this );
124
    licenseEdit->setFontFamily( "Monospace" );
125
    licenseEdit->setText( qfu( psz_license ) );
126
    licenseEdit->setReadOnly( true );
127
128

    /* People who helped */
129
130
131
    QWidget *thanksWidget = new QWidget( this );
    QVBoxLayout *thanksLayout = new QVBoxLayout( thanksWidget );

132
    QLabel *thanksLabel = new QLabel( qtr("We would like to thank the whole "
133
134
135
136
137
                "community, the testers, our users and the following people "
                "(and the missing ones...) for their collaboration to "
                "provide the best software." ) );
    thanksLabel->setWordWrap( true );
    thanksLayout->addWidget( thanksLabel );
138
    QTextEdit *thanksEdit = new QTextEdit( this );
139
    thanksEdit->setText( qfu( psz_thanks ) );
140
    thanksEdit->setReadOnly( true );
141
    thanksLayout->addWidget( thanksEdit );
142

143
    /* People who wrote the software */
144
145
146
147
    QTextEdit *authorsEdit = new QTextEdit( this );
    authorsEdit->setText( qfu( psz_authors ) );
    authorsEdit->setReadOnly( true );

148
    /* add the tabs to the Tabwidget */
149
    tab->addTab( infoWidget, qtr( "General Info" ) );
150
    tab->addTab( authorsEdit, qtr( "Authors" ) );
151
    tab->addTab( thanksWidget, qtr("Thanks") );
Christophe Mutricy's avatar
Christophe Mutricy committed
152
    tab->addTab( licenseEdit, qtr("Distribution License") );
153

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
154
155
156
157
158
159
160
161
162
163
    BUTTONACT( closeButton, close() );
}

AboutDialog::~AboutDialog()
{
}
void AboutDialog::close()
{
    this->toggleVisible();
}
164
165
166
167
168
169
170
171
172
173
174
175


UpdateDialog *UpdateDialog::instance = NULL;

UpdateDialog::UpdateDialog( intf_thread_t *_p_intf) : QVLCFrame( _p_intf )
{
    setWindowTitle( qtr( "Update" ) );
    resize( 230, 180 );

    QGridLayout *layout = new QGridLayout( this );

    QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
176
    updateButton = new QPushButton( qtr( "&Update List" ) );
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
    updateButton->setDefault( true );
    QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Horizontal);
    buttonBox->addButton( updateButton, QDialogButtonBox::ActionRole );
    buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );

    QGroupBox *checkGroup = new QGroupBox( qtr( "Select Package" ) );
    QGridLayout *checkLayout = new QGridLayout( checkGroup );
    checkInfo = new QCheckBox( qtr( "Information" ) );
    checkSource = new QCheckBox( qtr( "Sources" ) );
    checkBinary = new QCheckBox( qtr( "Binary" ) );
    checkPlugin = new QCheckBox( qtr( "Plugin" ) );

    checkInfo->setDisabled( true );
    checkSource->setDisabled( true );
    checkBinary->setDisabled( true );
    checkPlugin->setDisabled( true );

    checkLayout->addWidget( checkInfo, 0, 0 );
    checkLayout->addWidget( checkSource, 1, 0 );
    checkLayout->addWidget( checkBinary, 2, 0 );
    checkLayout->addWidget( checkPlugin, 3, 0 );

    layout->addWidget( checkGroup, 0, 0 );
    layout->addWidget( buttonBox, 1, 0 );

202
    BUTTONACT( updateButton, updateOrUpload() );
203
204
205
    BUTTONACT( closeButton, close() );

    p_update = update_New( _p_intf );
206
    b_updated = false;
207
208
209
210
211
212
213
214
215
216
217
218
}

UpdateDialog::~UpdateDialog()
{
    update_Delete( p_update );
}

void UpdateDialog::close()
{
    toggleVisible();
}

219
void UpdateDialog::updateOrUpload()
220
{
221
    if( !p_update ) return;
222
    if( !b_updated )
223
    {
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
        update_Check( p_update, VLC_FALSE );
        update_iterator_t *p_updateit = update_iterator_New( p_update );
        bool b_download = false;
        if( p_updateit )
        {
            p_updateit->i_rs = UPDATE_RELEASE_STATUS_NEWER;
            p_updateit->i_t = UPDATE_FILE_TYPE_ALL;
            update_iterator_Action( p_updateit, UPDATE_MIRROR );
            while( update_iterator_Action( p_updateit, UPDATE_FILE ) != UPDATE_FAIL )
            {
                switch( p_updateit->file.i_type )
                {
                    case UPDATE_FILE_TYPE_INFO:
                    checkInfo->setText( qtr( "Information" ) + " (" + qfu( p_updateit->release.psz_version ) + ")" );
                    checkInfo->setDisabled( false );
                    checkInfo->setCheckState( Qt::Checked );
                    b_download = true;
                    break;
                case UPDATE_FILE_TYPE_SOURCE:
                    checkSource->setText( qtr( "Source" ) + " (" + qfu( p_updateit->release.psz_version ) + ")" );
                    checkSource->setDisabled( false );
                    checkSource->setCheckState( Qt::Checked );
                    b_download = true;
                    break;
                case UPDATE_FILE_TYPE_BINARY:
                    checkBinary->setText( qtr( "Binary" ) + " (" + qfu( p_updateit->release.psz_version ) + ")" );
                    checkBinary->setDisabled( false );
                    checkBinary->setCheckState( Qt::Checked );
                    b_download = true;
                    break;
                case UPDATE_FILE_TYPE_PLUGIN:
                    checkPlugin->setText( qtr( "Plugin" ) + " (" + qfu( p_updateit->release.psz_version ) + ")");
                    checkPlugin->setDisabled( false );
                    checkPlugin->setCheckState( Qt::Checked );
                    b_download = true;
                    break;
                default:
                    break;
                }
            }
        }
        if( b_download )
266
        {
267
268
269
270
271
272
273
274
275
276
277
            updateButton->setText(qtr( "Download" ) );
            b_updated = true;
        }
        update_iterator_Delete( p_updateit );
    }
    else
    {
        update_iterator_t *p_updateit = update_iterator_New( p_update );
        bool b_download = false;
        if( p_updateit )
        {
Rafaël Carré's avatar
typo    
Rafaël Carré committed
278
279
            QString saveDir = QFileDialog::getExistingDirectory( this, qtr( "Choose a directory..." ),
                                                            qfu( p_intf->p_libvlc->psz_homedir ) );
280
281
282
283
284
285

            p_updateit->i_rs = UPDATE_RELEASE_STATUS_NEWER;
            p_updateit->i_t = UPDATE_FILE_TYPE_ALL;
            update_iterator_Action( p_updateit, UPDATE_MIRROR );

            while( update_iterator_Action( p_updateit, UPDATE_FILE ) != UPDATE_FAIL )
286
            {
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
                b_download = false;
                switch( p_updateit->file.i_type )
                {
                case UPDATE_FILE_TYPE_INFO:
                    if( checkInfo->isChecked() )
                        b_download = true;
                    break;
                case UPDATE_FILE_TYPE_SOURCE:
                    if( checkSource->isChecked() )
                        b_download = true;
                    break;
                case UPDATE_FILE_TYPE_BINARY:
                    if( checkBinary->isChecked() )
                        b_download = true;
                    break;
                case UPDATE_FILE_TYPE_PLUGIN:
                    if( checkPlugin->isChecked() )
                        b_download = true;
                    break;
                        default:
                        break;
                }
                if( b_download )
                {
                    QString strFileName = p_updateit->file.psz_url;
                    strFileName.remove( 0, strFileName.lastIndexOf( "/" ) + 1 );
                    update_download( p_updateit, qtu( ( saveDir + strFileName ) ) );
                }
315
316
317
318
            }
        }
    }
}