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>
9 * Jean-Baptiste Kempf <jb@videolan.org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 *****************************************************************************/
26 #include <QListWidget>
27 #include <QListWidgetItem>
31 #include "components/simple_preferences.hpp"
32 #include "components/preferences_widgets.hpp"
35 #include <vlc_config_cat.h>
38 #include "pixmaps/hotkeys_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/subtitles_50x50.xpm"
43 #include "pixmaps/video_50x50.xpm"
45 #include "ui/sprefs_audio.h"
46 #include "ui/sprefs_input.h"
47 #include "ui/sprefs_video.h"
48 #include "ui/sprefs_subtitles.h"
49 #include "ui/sprefs_hotkeys.h"
50 #include "ui/sprefs_interface.h"
52 #define ITEM_HEIGHT 50
54 /*********************************************************************
55 * The List of categories
56 *********************************************************************/
57 SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent ) :
58 QListWidget( _parent ), p_intf( _p_intf )
60 setIconSize( QSize( ITEM_HEIGHT,ITEM_HEIGHT ) );
61 setAlternatingRowColors( true );
62 setViewMode(QListView::IconMode);
65 #define ADD_CATEGORY( id, label, icon ) \
67 item( id )->setIcon( QIcon( QPixmap( icon ) ) ); \
68 item( id )->setData( Qt::UserRole, qVariantFromValue( (int)id ) ); \
69 item( id )->setTextAlignment(Qt::AlignHCenter); \
70 item( id )->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
72 ADD_CATEGORY( SPrefsVideo, qtr("Video"), video_50x50_xpm );
73 ADD_CATEGORY( SPrefsAudio, qtr("Audio"), audio_50x50_xpm );
74 ADD_CATEGORY( SPrefsInputAndCodecs, qtr("Input and Codecs"),
75 input_and_codecs_50x50_xpm );
76 ADD_CATEGORY( SPrefsInterface, qtr("Interface"), interface_50x50_xpm );
77 ADD_CATEGORY( SPrefsSubtitles, qtr("Subtitles"), subtitles_50x50_xpm );
78 ADD_CATEGORY( SPrefsHotkeys, qtr("Hotkeys"), hotkeys_50x50_xpm );
80 setCurrentRow( SPrefsInterface );
83 /*********************************************************************
85 *********************************************************************/
86 SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
87 int number ) : QWidget( _parent ), p_intf( _p_intf )
89 module_config_t *p_config;
90 ConfigControl *control;
92 #define CONFIG_GENERIC( option, type, label, qcontrol ) \
93 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
96 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
97 p_config, label, ui.qcontrol, false ); \
98 controls.append( control ); \
101 #define CONFIG_GENERIC_NO_BOOL( option, type, label, qcontrol ) \
102 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
105 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
106 p_config, label, ui.qcontrol ); \
107 controls.append( control ); \
112 #define START_SPREFS_CAT( name , label ) \
113 case SPrefs ## name: \
115 Ui::SPrefs ## name ui; \
116 ui.setupUi( panel ); \
117 panel_label->setText( qtr( label ) );
119 #define END_SPREFS_CAT \
123 QVBoxLayout *panel_layout = new QVBoxLayout();
124 QWidget *panel = new QWidget();
127 QLabel *panel_label = new QLabel;
128 QFont labelFont = QApplication::font( static_cast<QWidget*>(0) );
129 labelFont.setPointSize( labelFont.pointSize() + 4 );
130 labelFont.setBold( true );
131 panel_label->setFont( labelFont );
134 QFrame *title_line = new QFrame;
135 title_line->setFrameShape(QFrame::HLine);
136 title_line->setFrameShadow(QFrame::Sunken);
140 /* Video Panel Implementation */
141 START_SPREFS_CAT( Video , "General video settings" );
143 ui.directXBox->setVisible( false );
145 CONFIG_GENERIC( "video", Bool, NULL, enableVideo );
147 CONFIG_GENERIC( "fullscreen", Bool, NULL, fullscreen );
148 CONFIG_GENERIC( "overlay", Bool, NULL, overlay );
149 CONFIG_GENERIC( "video-on-top", Bool, NULL, alwaysOnTop );
150 CONFIG_GENERIC( "video-deco", Bool, NULL, windowDecorations );
151 CONFIG_GENERIC( "skip-frames" , Bool, NULL, skipFrames);
152 CONFIG_GENERIC( "vout", Module, NULL, outputModule );
155 CONFIG_GENERIC( "directx-wallpaper" , Bool , NULL, wallpaperMode );
156 CONFIG_GENERIC( "directx-device", StringList, NULL,
160 CONFIG_GENERIC( "snapshot-path", String, NULL,
161 snapshotsDirectory ); /* FIXME -> use file instead of string */
162 CONFIG_GENERIC( "snapshot-prefix", String, NULL, snapshotsPrefix );
163 CONFIG_GENERIC( "snapshot-sequential", Bool, NULL,
164 snapshotsSequentialNumbering );
165 CONFIG_GENERIC( "snapshot-format", StringList, NULL,
169 /* Audio Panel Implementation */
170 START_SPREFS_CAT( Audio, "General audio settings" );
172 ui.OSSBrowse->hide();
173 ui.OSSDevice->hide();
175 ui.alsaDevice->hide();
176 ui.alsaLabel->hide();
178 ui.DirectXLabel->setVisible( false );
179 ui.DirectXDevice->setVisible( false );
181 CONFIG_GENERIC( "audio", Bool, NULL, enableAudio );
183 CONFIG_GENERIC_NO_BOOL( "volume" , IntegerRangeSlider, NULL,
185 CONFIG_GENERIC( "audio-language" , StringList , NULL,
186 preferredAudioLanguage );
187 CONFIG_GENERIC( "spdif" , Bool , NULL, spdifBox );
188 CONFIG_GENERIC( "force-dolby-surround" , IntegerList , NULL,
191 CONFIG_GENERIC( "aout" , Module , NULL, outputModule );
193 CONFIG_GENERIC( "alsadev" , StringList , NULL, alsaDevice );
194 CONFIG_GENERIC( "dspdev" , String , NULL, OSSDevice );
197 CONFIG_GENERIC( "directx-audio-device" , IntegerList, NULL,
200 CONFIG_GENERIC( "audiofile-file" , String , NULL, FileName );
203 CONFIG_GENERIC( "headphone-dolby" , Bool , NULL, headphoneEffect );
204 // CONFIG_GENERIC( "" , Bool, NULL, ); activation of normalizer
205 CONFIG_GENERIC_NO_BOOL( "norm-max-level" , Float , NULL,
207 CONFIG_GENERIC( "audio-visual" , Module , NULL, visualisation);
210 /* Input and Codecs Panel Implementation */
211 START_SPREFS_CAT( InputAndCodecs, "Input & Codecs settings" );
213 /* CONFIG_GENERIC( );*/
215 CONFIG_GENERIC_NO_BOOL( "server-port", Integer, NULL, UDPPort );
216 CONFIG_GENERIC( "http-proxy", String , NULL, proxy );
219 /* CONFIG_GENERIC( );*/
221 CONFIG_GENERIC_NO_BOOL( "ffmpeg-pp-q", Integer, NULL, PostProcLevel );
222 CONFIG_GENERIC( "avi-index", IntegerList, NULL, AviRepair );
223 CONFIG_GENERIC( "rtsp-tcp", Bool, NULL, RTSP_TCPBox );
225 CONFIG_GENERIC( "timeshift-force", Bool, NULL, timeshiftBox );
226 CONFIG_GENERIC( "dump-force", Bool, NULL, DumpBox );
227 // CONFIG_GENERIC( "", Bool, NULL, RecordBox ); //FIXME activate record
230 /* Interface Panel */
231 START_SPREFS_CAT( Interface, "Interfaces settings" );
233 CONFIG_GENERIC( "language", StringList, NULL, language );
234 #if !defined( WIN32 ) && !defined( HAVE_DBUS_3 )
235 ui.OneInterfaceBox->hide();
238 /* p_config = config_FindConfig( VLC_OBJECT(p_intf), "intf" );
239 if( p_config->value.psz && strcmp( p_config->value.psz, "qt4" ))
240 ui.qt4->setChecked( true );
241 if( p_config->value.psz && strcmp( p_config->value.psz, "skins2" ))
242 ui.skins->setChecked( true );*/
243 /* CONFIG_GENERIC( "intf", Module, NULL, ??? ); */ //FIXME interface choice
244 CONFIG_GENERIC( "qt-always-video", Bool, NULL, qtAlwaysVideo );
245 CONFIG_GENERIC( "skins2-last", String, NULL, fileSkin);
247 #if defined( WIN32 ) || defined(HAVE_DBUS_3)
248 CONFIG_GENERIC( "one-instance", Bool, NULL, OneInterfaceMode );
249 CONFIG_GENERIC( "playlist-enqueue", Bool, NULL,
250 EnqueueOneInterfaceMode );
254 START_SPREFS_CAT( Subtitles, "Subtitles & OSD settings" );
255 CONFIG_GENERIC( "osd", Bool, NULL, OSDBox);
257 CONFIG_GENERIC( "subsdec-encoding", StringList, NULL, encoding );
258 CONFIG_GENERIC( "sub-language", String, NULL, preferredLanguage );
260 CONFIG_GENERIC( "freetype-font", String, NULL, font );
261 /* FIXME -> use file instead of string */
262 CONFIG_GENERIC( "freetype-color", IntegerList, NULL, fontColor );
263 CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList, NULL,
265 CONFIG_GENERIC( "freetype-effect", IntegerList, NULL, effect );
269 START_SPREFS_CAT( Hotkeys, "Configure Hotkeys" );
273 panel_layout->addWidget(panel_label);
274 panel_layout->addWidget(title_line);
275 panel_layout->addWidget( panel );
276 panel_layout->addStretch( 2 );
278 this->setLayout(panel_layout);
281 void SPrefsPanel::apply()
283 QList<ConfigControl *>::Iterator i;
284 for( i = controls.begin() ; i != controls.end() ; i++ )
286 ConfigControl *c = qobject_cast<ConfigControl *>(*i);
287 c->doApply( p_intf );
291 void SPrefsPanel::clean()