]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/simple_preferences.cpp
b048b8cbef2716aee0b50bc3c9c1b2ca5c646054
[vlc] / modules / gui / qt4 / components / simple_preferences.cpp
1 /*****************************************************************************
2  * simple_preferences.cpp : "Simple preferences"
3  ****************************************************************************
4  * Copyright (C) 2006 the VideoLAN team
5  * $Id: preferences.cpp 16348 2006-08-25 21:10:10Z zorglub $
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *          Antoine Cellerier <dionoea@videolan.org>
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 "components/simple_preferences.hpp"
26 #include "components/preferences_widgets.hpp"
27 #include "qt4.hpp"
28 #include <vlc_config_cat.h>
29 #include <assert.h>
30 #include <QListWidget>
31 #include <QListWidgetItem>
32 #include <QString>
33 #include <QFont>
34
35 #include "pixmaps/audio.xpm"
36 #include "ui/sprefs_trivial.h"
37
38 #define ITEM_HEIGHT 25
39
40 /*********************************************************************
41  * The List of categories
42  *********************************************************************/
43 SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent ) :
44                                   QListWidget( _parent ), p_intf( _p_intf )
45 {
46     setIconSize( QSize( ITEM_HEIGHT,ITEM_HEIGHT ) );
47     setAlternatingRowColors( true );
48
49 #ifndef WIN32
50     // Fixme - A bit UGLY
51     QFont f = font();
52     int pSize = f.pointSize();
53     if( pSize > 0 )
54         f.setPointSize( pSize + 1 );
55     else
56         f.setPixelSize( f.pixelSize() + 1 );
57     setFont( f );
58 #endif
59
60     addItem( "Very trivial" );
61     item(0)->setIcon( QIcon( QPixmap( audio_xpm ) ) );
62 }
63
64 void SPrefsCatList::ApplyAll()
65 {
66     DoAll( false );
67 }
68
69 void SPrefsCatList::CleanAll()
70 {
71     DoAll( true );
72 }
73
74 /// \todo When cleaning, we should remove the panel ?
75 void SPrefsCatList::DoAll( bool doclean )
76 {
77     /* Todo */
78 }
79
80 /*********************************************************************
81  * The Panels
82  *********************************************************************/
83 SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
84                           int number ) : QWidget( _parent ), p_intf( _p_intf )
85 {
86     if( number == 0 )
87     {
88         Ui::SPrefsTrivial ui;
89         ui.setupUi( this );
90         msg_Err( p_intf, "Intf there" );
91         module_config_t *p_config = config_FindConfig( VLC_OBJECT(p_intf),
92                                                         "memcpy" );
93         msg_Err( p_intf, "%p", p_config );
94         ConfigControl *control = new ModuleConfigControl( VLC_OBJECT(p_intf),
95                         p_config, ui.memcpyLabel, ui.memcpyCombo, false );
96         controls.append( control );
97     }
98     else
99     {
100         int *p = NULL;
101         fprintf( stderr, "Ha ha ca te fait bien la bite\n" );
102         *p=42;
103     }
104 }
105
106 void SPrefsPanel::Apply()
107 {
108     /* todo: factorize with PrefsPanel  */
109     QList<ConfigControl *>::Iterator i;
110     for( i = controls.begin() ; i != controls.end() ; i++ )
111     {
112         VIntConfigControl *vicc = qobject_cast<VIntConfigControl *>(*i);
113         if( !vicc )
114         {
115             VFloatConfigControl *vfcc = qobject_cast<VFloatConfigControl *>(*i);
116             if( !vfcc)
117             {
118                 VStringConfigControl *vscc =
119                                qobject_cast<VStringConfigControl *>(*i);
120                 assert( vscc );
121                 config_PutPsz( p_intf, vscc->getName().toAscii().data(),
122                                        vscc->getValue().toAscii().data() );
123                 continue;
124             }
125             config_PutFloat( p_intf, vfcc->getName().toAscii().data(),
126                                      vfcc->getValue() );
127             continue;
128         }
129         config_PutInt( p_intf, vicc->getName().toAscii().data(),
130                                vicc->getValue() );
131     }
132 }
133
134 void SPrefsPanel::Clean()
135 {}