]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/simple_preferences.cpp
Don't use non existent file in Qt4 code
[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 <QListWidget>
26 #include <QListWidgetItem>
27 #include <QString>
28 #include <QFont>
29
30 #include "components/simple_preferences.hpp"
31 #include "components/preferences_widgets.hpp"
32 #include "qt4.hpp"
33
34 #include <vlc_config_cat.h>
35 #include <assert.h>
36
37 #include "pixmaps/advanced_50x50.xpm"
38 #include "pixmaps/audio_50x50.xpm"
39 #include "pixmaps/input_and_codecs_50x50.xpm"
40 #include "pixmaps/interface_50x50.xpm"
41 #include "pixmaps/playlist_50x50.xpm"
42 #include "pixmaps/subtitles_50x50.xpm"
43 #include "pixmaps/video_50x50.xpm"
44
45 #include "ui/sprefs_audio.h"
46 #include "ui/sprefs_video.h"
47 #include "ui/sprefs_subtitles.h"
48 #include "ui/sprefs_playlist.h"
49 #include "ui/sprefs_interface.h"
50
51 #define ITEM_HEIGHT 50
52
53 /*********************************************************************
54  * The List of categories
55  *********************************************************************/
56 SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent ) :
57                                   QListWidget( _parent ), p_intf( _p_intf )
58 {
59     setIconSize( QSize( ITEM_HEIGHT,ITEM_HEIGHT ) );
60     setAlternatingRowColors( true );
61
62 #define ADD_CATEGORY( id, label, icon )                             \
63     addItem( label );                                               \
64     item( id )->setIcon( QIcon( QPixmap( icon ) ) );                \
65     item( id )->setData( Qt::UserRole, qVariantFromValue( (int)id ) );
66
67     ADD_CATEGORY( SPrefsVideo, qtr("Video"), video_50x50_xpm );
68     ADD_CATEGORY( SPrefsAudio, qtr("Audio"), audio_50x50_xpm );
69     ADD_CATEGORY( SPrefsInputAndCodecs, qtr("Input and Codecs"),
70                   input_and_codecs_50x50_xpm );
71     ADD_CATEGORY( SPrefsPlaylist, qtr("Playlist"), playlist_50x50_xpm );
72     ADD_CATEGORY( SPrefsInterface, qtr("Interface"), interface_50x50_xpm );
73     ADD_CATEGORY( SPrefsSubtitles, qtr("Subtitles"), subtitles_50x50_xpm );
74     ADD_CATEGORY( SPrefsAdvanced, qtr("Advanced"), advanced_50x50_xpm );
75
76     setCurrentRow( SPrefsInterface );
77 }
78
79 /*********************************************************************
80  * The Panels
81  *********************************************************************/
82 SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
83                           int number ) : QWidget( _parent ), p_intf( _p_intf )
84 {
85     module_config_t *p_config;
86     ConfigControl *control;
87
88 #define CONFIG_GENERIC( option, type, label, qcontrol )                   \
89             p_config =  config_FindConfig( VLC_OBJECT(p_intf), option );  \
90             if( p_config )                                                \
91             {                                                             \
92                 control =  new type ## ConfigControl( VLC_OBJECT(p_intf), \
93                            p_config, label, ui.qcontrol, false );         \
94                 controls.append( control );                               \
95             }
96
97 #define START_SPREFS_CAT( name )    \
98         case SPrefs ## name:        \
99         {                           \
100             Ui::SPrefs ## name ui;  \
101             ui.setupUi( this );
102
103 #define END_SPREFS_CAT      \
104             break;          \
105         }
106
107
108     switch( number )
109     {
110         START_SPREFS_CAT( Video );
111
112             CONFIG_GENERIC( "video", Bool, NULL, enableVideo );
113
114             CONFIG_GENERIC( "fullscreen", Bool, NULL, fullscreen );
115             CONFIG_GENERIC( "overlay", Bool, NULL, overlay );
116             CONFIG_GENERIC( "video-on-top", Bool, NULL, alwaysOnTop );
117             CONFIG_GENERIC( "video-deco", Bool, NULL, windowDecorations );
118
119             CONFIG_GENERIC( "vout", Module, NULL, outputModule );
120
121             CONFIG_GENERIC( "snapshot-path", String, NULL,
122             snapshotsDirectory ); /* FIXME -> use file instead of string */
123             CONFIG_GENERIC( "snapshot-prefix", String, NULL, snapshotsPrefix );
124             CONFIG_GENERIC( "snapshot-sequential", Bool, NULL,
125                             snapshotsSequentialNumbering );
126             CONFIG_GENERIC( "snapshot-format", StringList, NULL,
127                             snapshotsFormat );
128
129         END_SPREFS_CAT;
130
131         START_SPREFS_CAT( Audio );
132
133             CONFIG_GENERIC( "audio", Bool, NULL, enableAudio );
134
135         END_SPREFS_CAT;
136
137         case SPrefsInputAndCodecs: break;
138
139         START_SPREFS_CAT( Playlist );
140         END_SPREFS_CAT;
141
142         START_SPREFS_CAT( Interface );
143
144             CONFIG_GENERIC( "language", StringList, NULL, language );
145
146         END_SPREFS_CAT;
147
148         START_SPREFS_CAT( Subtitles );
149
150             CONFIG_GENERIC( "subsdec-encoding", StringList, NULL, encoding );
151             CONFIG_GENERIC( "sub-language", String, NULL, preferredLanguage );
152             CONFIG_GENERIC( "freetype-font", String, NULL, font ); /* FIXME -> use file instead of string */
153             CONFIG_GENERIC( "freetype-color", IntegerList, NULL, fontColor );
154             CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList, NULL,
155                             fontSize );
156             CONFIG_GENERIC( "freetype-effect", IntegerList, NULL, effect );
157
158         END_SPREFS_CAT;
159
160         case SPrefsAdvanced: break;
161     }
162 }
163
164 void SPrefsPanel::apply()
165 {
166     QList<ConfigControl *>::Iterator i;
167     for( i = controls.begin() ; i != controls.end() ; i++ )
168     {
169         ConfigControl *c = qobject_cast<ConfigControl *>(*i);
170         c->doApply( p_intf );
171     }
172 }
173
174 void SPrefsPanel::clean()
175 {}