1 /*****************************************************************************
2 * prefs_dialog.cpp : Preferences
3 ****************************************************************************
4 * Copyright (C) 2000-2005 the VideoLAN team
5 * $Id: wxwidgets.cpp 15731 2006-05-25 14:43:53Z zorglub $
7 * Authors: Clément Stenac <zorglub@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/
23 #include "dialogs/prefs_dialog.hpp"
24 #include "dialogs_provider.hpp"
25 #include "util/qvlcframe.hpp"
27 #include "components/preferences.hpp"
30 #include <QHBoxLayout>
32 #include <QRadioButton>
33 #include <QVBoxLayout>
34 #include <QPushButton>
36 PrefsDialog *PrefsDialog::instance = NULL;
38 PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
40 layout = new QHBoxLayout();
41 QVBoxLayout * main_layout = new QVBoxLayout();
42 setWindowTitle( _("Preferences" ) );
48 advanced_panel = NULL;
50 vertical = new QVBoxLayout();
53 types = new QGroupBox( "Show settings" );
54 QHBoxLayout *tl = new QHBoxLayout();
56 small = new QRadioButton( "Common", types );
57 all = new QRadioButton( "All", types );
58 tl->addWidget( small );
60 types->setLayout(tl );
62 layout->addLayout( vertical, 1 );
65 all->setChecked( true );
67 main_layout->addLayout( layout );
68 adv_chk = new QCheckBox("Advanced options");
69 main_layout->addWidget( adv_chk );
71 QObject::connect( adv_chk, SIGNAL( toggled(bool) ), this,
72 SLOT( setAdvanced( bool ) ) );
73 setLayout( main_layout );
75 QObject::connect( small, SIGNAL( clicked() ), this, SLOT( setSmall()) );
76 QObject::connect( all, SIGNAL( clicked() ), this, SLOT( setAll()) );
79 void PrefsDialog::setAdvanced( bool advanced )
82 advanced_panel->setAdvanced( advanced );
85 void PrefsDialog::setAll()
87 while( (vertical->takeAt(0)) != 0 ) {}
93 advanced_tree = new PrefsTree( p_intf, this );
94 QObject::connect( advanced_tree,
95 SIGNAL( currentItemChanged( QTreeWidgetItem *,
96 QTreeWidgetItem *) ), this,
97 SLOT( changePanel( QTreeWidgetItem * ) ) );
99 advanced_tree->show();
100 setAdvanced( adv_chk->isChecked() );
101 vertical->addWidget( types );
102 vertical->addWidget( advanced_tree );
104 if( layout->count() == 2 )
107 if( !advanced_panel )
108 advanced_panel = new PrefsPanel( this );
109 layout->addWidget( advanced_panel, 3 ) ;
112 void PrefsDialog::setSmall()
114 while( (vertical->takeAt(0)) != 0 ) {}
116 advanced_tree->hide();
119 simple_tree = new QTreeWidget();
121 vertical->addWidget( types );
122 vertical->addWidget( simple_tree );
124 if( layout->count() == 2 )
128 simple_panel = new QWidget();
129 layout->addWidget( simple_panel, 3 ) ;
133 void PrefsDialog::init()
137 PrefsDialog::~PrefsDialog()
141 void PrefsDialog::changePanel( QTreeWidgetItem *item )
143 PrefsItemData *data = item->data( 0, Qt::UserRole ).value<PrefsItemData*>();
147 layout->removeWidget( advanced_panel );
148 advanced_panel->hide();
152 data->panel = new PrefsPanel( p_intf, this, data );
154 advanced_panel = data->panel;
155 advanced_panel->show();
156 setAdvanced( adv_chk->isChecked() );
157 layout->addWidget( advanced_panel, 3 );