]> git.sesse.net Git - vlc/commitdiff
Qt4: firstRun dialog is now separated
authorJean-Baptiste Kempf <jb@videolan.org>
Fri, 27 Nov 2009 17:28:29 +0000 (18:28 +0100)
committerJean-Baptiste Kempf <jb@videolan.org>
Fri, 4 Dec 2009 06:21:38 +0000 (07:21 +0100)
modules/gui/qt4/Modules.am
modules/gui/qt4/dialogs/firstrun.cpp [new file with mode: 0644]
modules/gui/qt4/dialogs/firstrun.hpp [new file with mode: 0644]
modules/gui/qt4/main_interface.cpp
modules/gui/qt4/main_interface.hpp

index 8b0edd91813e6adb824e487af26dae61b63091c1..d80f7b2cc18132ef20910da4252e4bc4c974d4b7 100644 (file)
@@ -40,6 +40,7 @@ nodist_SOURCES_qt4 = \
                dialogs/openurl.moc.cpp \
                dialogs/podcast_configuration.moc.cpp \
                dialogs/vlm.moc.cpp \
+               dialogs/firstrun.moc.cpp \
                components/extended_panels.moc.cpp \
                components/info_panels.moc.cpp \
                components/preferences_widgets.moc.cpp \
@@ -228,6 +229,7 @@ SOURCES_qt4 =       qt4.cpp \
                dialogs/open.cpp \
                dialogs/openurl.cpp \
                dialogs/vlm.cpp \
+               dialogs/firstrun.cpp \
                dialogs/podcast_configuration.cpp \
                components/extended_panels.cpp \
                components/info_panels.cpp \
@@ -275,6 +277,7 @@ noinst_HEADERS = \
        dialogs/open.hpp \
        dialogs/openurl.hpp \
        dialogs/vlm.hpp \
+       dialogs/firstrun.hpp \
        dialogs/podcast_configuration.hpp \
        components/extended_panels.hpp \
        components/info_panels.hpp \
diff --git a/modules/gui/qt4/dialogs/firstrun.cpp b/modules/gui/qt4/dialogs/firstrun.cpp
new file mode 100644 (file)
index 0000000..67b403c
--- /dev/null
@@ -0,0 +1,128 @@
+/*****************************************************************************
+ * firstrun : First Run dialogs
+ ****************************************************************************
+ * Copyright © 2009 VideoLAN
+ * $Id$
+ *
+ * Authors: Jean-Baptiste Kempf <jb (at) videolan.org>
+ *
+ * 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/firstrun.hpp"
+
+#include "components/preferences_widgets.hpp"
+
+#include <QGridLayout>
+#include <QGroupBox>
+
+FirstRun::FirstRun( QWidget *_p, intf_thread_t *_p_intf )
+         : QWidget( _p ), p_intf( _p_intf )
+{
+#ifndef HAVE_MAEMO
+    /**
+     * Ask for the network policy on FIRST STARTUP
+     **/
+    if( config_GetInt( p_intf, "qt-privacy-ask") )
+    {
+        buildPrivDialog();
+        setVisible( true );
+    }
+    else
+        close();
+#endif
+}
+
+void FirstRun::save()
+{
+    QList<ConfigControl *>::Iterator i;
+    for( i = controlsList.begin() ; i != controlsList.end() ; i++ )
+    {
+        ConfigControl *c = qobject_cast<ConfigControl *>(*i);
+        c->doApply( p_intf );
+    }
+    config_PutInt( p_intf,  "qt-privacy-ask", 0 );
+    /* We have to save here because the user may not launch Prefs */
+    config_SaveConfigFile( p_intf, NULL );
+    close();
+}
+
+void FirstRun::buildPrivDialog()
+{
+    setWindowTitle( qtr( "Privacy and Network Policies" ) );
+    setWindowRole( "vlc-privacy" );
+    setWindowModality( Qt::ApplicationModal );
+    setWindowFlags( Qt::Dialog );
+    setAttribute( Qt::WA_DeleteOnClose );
+
+    QGridLayout *gLayout = new QGridLayout( this );
+
+    QGroupBox *blabla = new QGroupBox( qtr( "Privacy and Network Warning" ) );
+    QGridLayout *blablaLayout = new QGridLayout( blabla );
+    QLabel *text = new QLabel( qtr(
+        "<p>The <i>VideoLAN Team</i> doesn't like when an application goes "
+        "online without authorization.</p>\n "
+        "<p><i>VLC media player</i> can retreive limited information from "
+        "the Internet in order to get CD covers or to check "
+        "for available updates.</p>\n"
+        "<p><i>VLC media player</i> <b>DOES NOT</b> send or collect <b>ANY</b> "
+        "information, even anonymously, about your usage.</p>\n"
+        "<p>Therefore please select from the following options, the default being "
+        "almost no access to the web.</p>\n") );
+    text->setWordWrap( true );
+    text->setTextFormat( Qt::RichText );
+
+    blablaLayout->addWidget( text, 0, 0 ) ;
+
+    QGroupBox *options = new QGroupBox;
+    QGridLayout *optionsLayout = new QGridLayout( options );
+
+    gLayout->addWidget( blabla, 0, 0, 1, 3 );
+    gLayout->addWidget( options, 1, 0, 1, 3 );
+    module_config_t *p_config;
+    ConfigControl *control;
+    int line = 0;
+
+#define CONFIG_GENERIC( option, type )                            \
+    p_config =  config_FindConfig( VLC_OBJECT(p_intf), option );  \
+    if( p_config )                                                \
+    {                                                             \
+        control =  new type ## ConfigControl( VLC_OBJECT(p_intf), \
+                p_config, options, false, optionsLayout, line );  \
+        controlsList.append( control );                              \
+    }
+
+#define CONFIG_GENERIC_NOBOOL( option, type )                     \
+    p_config =  config_FindConfig( VLC_OBJECT(p_intf), option );  \
+    if( p_config )                                                \
+    {                                                             \
+        control =  new type ## ConfigControl( VLC_OBJECT(p_intf), \
+                p_config, options, optionsLayout, line );         \
+        controlsList.append( control );                              \
+    }
+
+    CONFIG_GENERIC( "album-art", IntegerList ); line++;
+#ifdef UPDATE_CHECK
+    CONFIG_GENERIC_NOBOOL( "qt-updates-notif", Bool ); line++;
+#endif
+
+    QPushButton *ok = new QPushButton( qtr( "OK" ) );
+
+    gLayout->addWidget( ok, 2, 2 );
+
+    CONNECT( ok, clicked(), this, save() );
+}
+
diff --git a/modules/gui/qt4/dialogs/firstrun.hpp b/modules/gui/qt4/dialogs/firstrun.hpp
new file mode 100644 (file)
index 0000000..357fed9
--- /dev/null
@@ -0,0 +1,40 @@
+/*****************************************************************************
+ * firstrun : First Run dialogs
+ ****************************************************************************
+ * Copyright © 2009 VideoLAN
+ * $Id$
+ *
+ * Authors: Jean-Baptiste Kempf <jb (at) videolan.org>
+ *
+ * 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 "qt4.hpp"
+
+#include <QWidget>
+class ConfigControl;
+class FirstRun : public QWidget
+{
+    Q_OBJECT
+    public:
+        FirstRun( QWidget *, intf_thread_t * );
+    private:
+        QList<ConfigControl *> controlsList;
+        intf_thread_t *p_intf;
+        void buildPrivDialog();
+    private slots:
+        void save();
+};
+
index d5d0d0d3227754ceddf44580d38e17d81cffbd81..982283c842be8905bcdf86903c638e34b21bc9b5 100644 (file)
@@ -40,6 +40,7 @@
 #include "components/controller.hpp"
 #include "components/playlist/playlist.hpp"
 #include "dialogs/external.hpp"
+#include "dialogs/firstrun.hpp"
 
 #include "menus.hpp"
 #include "recents.hpp"
@@ -98,8 +99,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     stackCentralOldState = HIDDEN_TAB;
     i_bg_height          = 0;
 
-    /* Ask for privacy */
-    askForPrivacy();
+    /* Ask for Privacy */
+    new FirstRun( this, p_intf );
 
     /**
      *  Configuration and settings
@@ -592,98 +593,6 @@ inline void MainInterface::initSystray()
 #endif
 }
 
-inline void MainInterface::askForPrivacy()
-{
-#ifndef HAVE_MAEMO
-    /**
-     * Ask for the network policy on FIRST STARTUP
-     **/
-    if( config_GetInt( p_intf, "qt-privacy-ask") )
-    {
-        QList<ConfigControl *> controls;
-        if( privacyDialog( &controls ) == QDialog::Accepted )
-        {
-            QList<ConfigControl *>::Iterator i;
-            for(  i = controls.begin() ; i != controls.end() ; i++ )
-            {
-                ConfigControl *c = qobject_cast<ConfigControl *>(*i);
-                c->doApply( p_intf );
-            }
-
-            config_PutInt( p_intf,  "qt-privacy-ask" , 0 );
-            /* We have to save here because the user may not launch Prefs */
-            config_SaveConfigFile( p_intf, NULL );
-        }
-    }
-#endif
-}
-
-int MainInterface::privacyDialog( QList<ConfigControl *> *controls )
-{
-    QDialog *privacy = new QDialog( this );
-
-    privacy->setWindowTitle( qtr( "Privacy and Network Policies" ) );
-    privacy->setWindowRole( "vlc-privacy" );
-
-    QGridLayout *gLayout = new QGridLayout( privacy );
-
-    QGroupBox *blabla = new QGroupBox( qtr( "Privacy and Network Warning" ) );
-    QGridLayout *blablaLayout = new QGridLayout( blabla );
-    QLabel *text = new QLabel( qtr(
-        "<p>The <i>VideoLAN Team</i> doesn't like when an application goes "
-        "online without authorization.</p>\n "
-        "<p><i>VLC media player</i> can retreive limited information from "
-        "the Internet in order to get CD covers or to check "
-        "for available updates.</p>\n"
-        "<p><i>VLC media player</i> <b>DOES NOT</b> send or collect <b>ANY</b> "
-        "information, even anonymously, about your usage.</p>\n"
-        "<p>Therefore please select from the following options, the default being "
-        "almost no access to the web.</p>\n") );
-    text->setWordWrap( true );
-    text->setTextFormat( Qt::RichText );
-
-    blablaLayout->addWidget( text, 0, 0 ) ;
-
-    QGroupBox *options = new QGroupBox;
-    QGridLayout *optionsLayout = new QGridLayout( options );
-
-    gLayout->addWidget( blabla, 0, 0, 1, 3 );
-    gLayout->addWidget( options, 1, 0, 1, 3 );
-    module_config_t *p_config;
-    ConfigControl *control;
-    int line = 0;
-
-#define CONFIG_GENERIC( option, type )                            \
-    p_config =  config_FindConfig( VLC_OBJECT(p_intf), option );  \
-    if( p_config )                                                \
-    {                                                             \
-        control =  new type ## ConfigControl( VLC_OBJECT(p_intf), \
-                p_config, options, false, optionsLayout, line );  \
-        controls->append( control );                              \
-    }
-
-#define CONFIG_GENERIC_NOBOOL( option, type )                     \
-    p_config =  config_FindConfig( VLC_OBJECT(p_intf), option );  \
-    if( p_config )                                                \
-    {                                                             \
-        control =  new type ## ConfigControl( VLC_OBJECT(p_intf), \
-                p_config, options, optionsLayout, line );         \
-        controls->append( control );                              \
-    }
-
-    CONFIG_GENERIC( "album-art", IntegerList ); line++;
-#ifdef UPDATE_CHECK
-    CONFIG_GENERIC_NOBOOL( "qt-updates-notif", Bool ); line++;
-#endif
-
-    QPushButton *ok = new QPushButton( qtr( "OK" ) );
-
-    gLayout->addWidget( ok, 2, 2 );
-
-    CONNECT( ok, clicked(), privacy, accept() );
-    return privacy->exec();
-}
-
 
 /**********************************************************************
  * Handling of sizing of the components
index 12d4303c6803d0cbeb79ca2490eaf56ad545cb61..22601d5452b5c4a72570299d8bbab234a607017b 100644 (file)
@@ -111,9 +111,6 @@ private:
     void createMainWidget( QSettings* );
     void createStatusBar();
 
-    void askForPrivacy();
-    int  privacyDialog( QList<ConfigControl *> *controls );
-
     /* Systray */
     void handleSystray();
     void createSystray();