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 $
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Antoine Cellerier <dionoea@videolan.org>
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.
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.
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 *****************************************************************************/
25 #include <QListWidget>
26 #include <QListWidgetItem>
30 #include "components/simple_preferences.hpp"
31 #include "components/preferences_widgets.hpp"
34 #include <vlc_config_cat.h>
37 //TODO Rename all advanced to hotkeys since they will be no advanced section
38 #include "pixmaps/advanced_50x50.xpm"
39 #include "pixmaps/audio_50x50.xpm"
40 #include "pixmaps/input_and_codecs_50x50.xpm"
41 #include "pixmaps/interface_50x50.xpm"
42 //#include "pixmaps/playlist_50x50.xpm"
43 #include "pixmaps/subtitles_50x50.xpm"
44 #include "pixmaps/video_50x50.xpm"
46 #include "ui/sprefs_audio.h"
47 #include "ui/sprefs_input.h"
48 #include "ui/sprefs_video.h"
49 #include "ui/sprefs_subtitles.h"
50 //#include "ui/sprefs_playlist.h"
51 #include "ui/sprefs_interface.h"
53 #define ITEM_HEIGHT 50
55 /*********************************************************************
56 * The List of categories
57 *********************************************************************/
58 SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent ) :
59 QListWidget( _parent ), p_intf( _p_intf )
61 setIconSize( QSize( ITEM_HEIGHT,ITEM_HEIGHT ) );
62 setAlternatingRowColors( true );
64 #define ADD_CATEGORY( id, label, icon ) \
66 item( id )->setIcon( QIcon( QPixmap( icon ) ) ); \
67 item( id )->setData( Qt::UserRole, qVariantFromValue( (int)id ) );
69 ADD_CATEGORY( SPrefsVideo, qtr("Video"), video_50x50_xpm );
70 ADD_CATEGORY( SPrefsAudio, qtr("Audio"), audio_50x50_xpm );
71 ADD_CATEGORY( SPrefsInputAndCodecs, qtr("Input and Codecs"),
72 input_and_codecs_50x50_xpm );
73 // ADD_CATEGORY( SPrefsPlaylist, qtr("Playlist"), playlist_50x50_xpm );
74 ADD_CATEGORY( SPrefsInterface, qtr("Interface"), interface_50x50_xpm );
75 ADD_CATEGORY( SPrefsSubtitles, qtr("Subtitles"), subtitles_50x50_xpm );
76 ADD_CATEGORY( SPrefsAdvanced, qtr("Hotkeys"), advanced_50x50_xpm );
78 setCurrentRow( SPrefsInterface );
81 /*********************************************************************
83 *********************************************************************/
84 SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
85 int number ) : QWidget( _parent ), p_intf( _p_intf )
87 module_config_t *p_config;
88 ConfigControl *control;
90 #define CONFIG_GENERIC( option, type, label, qcontrol ) \
91 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
94 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
95 p_config, label, ui.qcontrol, false ); \
96 controls.append( control ); \
99 #define START_SPREFS_CAT( name ) \
100 case SPrefs ## name: \
102 Ui::SPrefs ## name ui; \
105 #define END_SPREFS_CAT \
112 START_SPREFS_CAT( Video );
114 CONFIG_GENERIC( "video", Bool, NULL, enableVideo );
116 CONFIG_GENERIC( "fullscreen", Bool, NULL, fullscreen );
117 CONFIG_GENERIC( "overlay", Bool, NULL, overlay );
118 CONFIG_GENERIC( "video-on-top", Bool, NULL, alwaysOnTop );
119 CONFIG_GENERIC( "video-deco", Bool, NULL, windowDecorations );
121 CONFIG_GENERIC( "vout", Module, NULL, outputModule );
123 CONFIG_GENERIC( "snapshot-path", String, NULL,
124 snapshotsDirectory ); /* FIXME -> use file instead of string */
125 CONFIG_GENERIC( "snapshot-prefix", String, NULL, snapshotsPrefix );
126 CONFIG_GENERIC( "snapshot-sequential", Bool, NULL,
127 snapshotsSequentialNumbering );
128 CONFIG_GENERIC( "snapshot-format", StringList, NULL,
133 START_SPREFS_CAT( Audio );
135 CONFIG_GENERIC( "audio", Bool, NULL, enableAudio );
139 START_SPREFS_CAT( InputAndCodecs );
144 /* START_SPREFS_CAT( Playlist );
147 START_SPREFS_CAT( Interface );
149 CONFIG_GENERIC( "language", StringList, NULL, language );
153 START_SPREFS_CAT( Subtitles );
155 CONFIG_GENERIC( "subsdec-encoding", StringList, NULL, encoding );
156 CONFIG_GENERIC( "sub-language", String, NULL, preferredLanguage );
157 CONFIG_GENERIC( "freetype-font", String, NULL, font ); /* FIXME -> use file instead of string */
158 CONFIG_GENERIC( "freetype-color", IntegerList, NULL, fontColor );
159 CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList, NULL,
161 CONFIG_GENERIC( "freetype-effect", IntegerList, NULL, effect );
165 case SPrefsAdvanced: break;
169 void SPrefsPanel::apply()
171 QList<ConfigControl *>::Iterator i;
172 for( i = controls.begin() ; i != controls.end() ; i++ )
174 ConfigControl *c = qobject_cast<ConfigControl *>(*i);
175 c->doApply( p_intf );
179 void SPrefsPanel::clean()