]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs/firstrun.cpp
Qt: views behavior corrections
[vlc] / modules / gui / qt4 / dialogs / firstrun.cpp
1 /*****************************************************************************
2  * firstrun : First Run dialogs
3  ****************************************************************************
4  * Copyright © 2009 VideoLAN
5  * $Id$
6  *
7  * Authors: Jean-Baptiste Kempf <jb (at) videolan.org>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23
24 #include "dialogs/firstrun.hpp"
25
26 #include "components/preferences_widgets.hpp"
27
28 #include <QGridLayout>
29 #include <QGroupBox>
30 #include <QSettings>
31
32 FirstRun::FirstRun( QWidget *_p, intf_thread_t *_p_intf  )
33          : QWidget( _p ), p_intf( _p_intf )
34 {
35 #ifndef HAVE_MAEMO
36     msg_Dbg( p_intf, "Boring first Run Wizard" );
37     buildPrivDialog();
38     setVisible( true );
39 #endif
40 }
41
42 void FirstRun::save()
43 {
44     QList<ConfigControl *>::Iterator i;
45     for( i = controlsList.begin() ; i != controlsList.end() ; i++ )
46     {
47         ConfigControl *c = qobject_cast<ConfigControl *>(*i);
48         c->doApply( p_intf );
49     }
50     config_PutInt( p_intf,  "qt-privacy-ask", 0 );
51     /* We have to save here because the user may not launch Prefs */
52     config_SaveConfigFile( p_intf, NULL );
53     close();
54 }
55
56 void FirstRun::buildPrivDialog()
57 {
58     setWindowTitle( qtr( "Privacy and Network Policies" ) );
59     setWindowRole( "vlc-privacy" );
60     setWindowModality( Qt::ApplicationModal );
61     setWindowFlags( Qt::Dialog );
62     setAttribute( Qt::WA_DeleteOnClose );
63
64     QGridLayout *gLayout = new QGridLayout( this );
65
66     QGroupBox *blabla = new QGroupBox( qtr( "Privacy and Network Warning" ) );
67     QGridLayout *blablaLayout = new QGridLayout( blabla );
68     QLabel *text = new QLabel( qtr(
69         "<p>The <i>VideoLAN Team</i> doesn't like when an application goes "
70         "online without authorization.</p>\n "
71         "<p><i>VLC media player</i> can retreive limited information from "
72         "the Internet in order to get CD covers or to check "
73         "for available updates.</p>\n"
74         "<p><i>VLC media player</i> <b>DOES NOT</b> send or collect <b>ANY</b> "
75         "information, even anonymously, about your usage.</p>\n"
76         "<p>Therefore please select from the following options, the default being "
77         "almost no access to the web.</p>\n") );
78     text->setWordWrap( true );
79     text->setTextFormat( Qt::RichText );
80
81     blablaLayout->addWidget( text, 0, 0 ) ;
82
83     QGroupBox *options = new QGroupBox;
84     QGridLayout *optionsLayout = new QGridLayout( options );
85
86     gLayout->addWidget( blabla, 0, 0, 1, 3 );
87     gLayout->addWidget( options, 1, 0, 1, 3 );
88     module_config_t *p_config;
89     ConfigControl *control;
90     int line = 0;
91
92 #define CONFIG_GENERIC( option, type )                            \
93     p_config =  config_FindConfig( VLC_OBJECT(p_intf), option );  \
94     if( p_config )                                                \
95     {                                                             \
96         control =  new type ## ConfigControl( VLC_OBJECT(p_intf), \
97                 p_config, options, false, optionsLayout, line );  \
98         controlsList.append( control );                              \
99     }
100
101 #define CONFIG_GENERIC_NOBOOL( option, type )                     \
102     p_config =  config_FindConfig( VLC_OBJECT(p_intf), option );  \
103     if( p_config )                                                \
104     {                                                             \
105         control =  new type ## ConfigControl( VLC_OBJECT(p_intf), \
106                 p_config, options, optionsLayout, line );         \
107         controlsList.append( control );                              \
108     }
109
110     CONFIG_GENERIC( "album-art", IntegerList ); line++;
111 #ifdef UPDATE_CHECK
112     CONFIG_GENERIC_NOBOOL( "qt-updates-notif", Bool ); line++;
113 #endif
114
115     QPushButton *ok = new QPushButton( qtr( "OK" ) );
116
117     gLayout->addWidget( ok, 2, 2 );
118
119     CONNECT( ok, clicked(), this, save() );
120 }
121