Qt: firstrun: use QDialogButtonsBox
[vlc/solaris.git] / modules / gui / qt4 / dialogs / firstrun.cpp
blob4e3487f3ef0726c65c353d040a5e96aee9f85c35
1 /*****************************************************************************
2 * firstrun : First Run dialogs
3 ****************************************************************************
4 * Copyright © 2009 VideoLAN
5 * $Id$
7 * Authors: Jean-Baptiste Kempf <jb (at) videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #include "dialogs/firstrun.hpp"
26 #include <QGridLayout>
27 #include <QGroupBox>
28 #include <QCheckBox>
29 #include <QLabel>
30 #include <QDialogButtonBox>
31 #include <QPushButton>
32 #include <QSettings>
34 FirstRun::FirstRun( QWidget *_p, intf_thread_t *_p_intf )
35 : QWidget( _p ), p_intf( _p_intf )
37 #ifndef HAVE_MAEMO
38 msg_Dbg( p_intf, "Boring first Run Wizard" );
39 buildPrivDialog();
40 setVisible( true );
41 #endif
44 #define ALBUM_ART_WHEN_ASKED 0
45 #define ALBUM_ART_ALL 2
47 void FirstRun::save()
49 config_PutInt( p_intf, "album-art", checkbox->isChecked() ? ALBUM_ART_ALL: ALBUM_ART_WHEN_ASKED );
50 #ifdef UPDATE_CHECK
51 config_PutInt( p_intf, "qt-updates-notif", checkbox2->isChecked() );
52 #endif
53 config_PutInt( p_intf, "qt-privacy-ask", 0 );
55 /* FIXME Should not save here. This will not work as expected if another
56 * plugin overwrote items of its own. */
57 #warning FIXME
58 /* We have to save here because the user may not launch Prefs */
59 config_SaveConfigFile( p_intf );
60 close();
63 void FirstRun::buildPrivDialog()
65 setWindowTitle( qtr( "Privacy and Network Access Policy" ) );
66 setWindowRole( "vlc-privacy" );
67 setWindowModality( Qt::ApplicationModal );
68 setWindowFlags( Qt::Dialog );
69 setAttribute( Qt::WA_DeleteOnClose );
71 QGridLayout *gLayout = new QGridLayout( this );
73 QGroupBox *blabla = new QGroupBox( qtr( "Privacy and Network Access Policy" ) );
74 QGridLayout *blablaLayout = new QGridLayout( blabla );
75 QLabel *text = new QLabel( qtr(
76 "<p><i>VLC media player</i> does <b>not</b> send or collect any "
77 "information, even anonymously, about your usage.</p>\n"
78 "<p>However, it can connect to the Internet "
79 "in order to display <b>medias information</b> "
80 #ifdef UPDATE_CHECK
81 "or to check for available <b>updates</b>"
82 #endif
83 ".</p>\n"
84 "<p><i>VideoLAN</i> (the authors) requires you to express your consent "
85 "before allowing this software to access the Internet.</p>\n"
86 "<p>According to your choices, please check or uncheck the following options:</p>\n"
87 ) );
88 text->setWordWrap( true );
89 text->setTextFormat( Qt::RichText );
91 blablaLayout->addWidget( text, 0, 0 ) ;
93 QGroupBox *options = new QGroupBox( qtr( "Network Access Policy" ) );
94 QGridLayout *optionsLayout = new QGridLayout( options );
96 gLayout->addWidget( blabla, 0, 0, 1, 3 );
97 gLayout->addWidget( options, 1, 0, 1, 3 );
98 int line = 0;
100 checkbox = new QCheckBox( qtr( "Allow downloading media information" ) );
101 checkbox->setChecked( true );
102 optionsLayout->addWidget( checkbox, line++, 0 );
104 #ifdef UPDATE_CHECK
105 checkbox2 = new QCheckBox( qtr( "Allow checking for VLC updates" ) );
106 checkbox2->setChecked( true );
107 optionsLayout->addWidget( checkbox2, line++, 0 );
108 #endif
110 QDialogButtonBox *buttonsBox = new QDialogButtonBox( this );
111 buttonsBox->addButton( qtr( "Save and Continue" ), QDialogButtonBox::AcceptRole );
113 gLayout->addWidget( buttonsBox, 2, 0, 2, 3 );
115 CONNECT( buttonsBox, accepted(), this, save() );
116 buttonsBox->setFocus();