1 /*****************************************************************************
2 * prefs_dialog.cpp : Preferences
3 ****************************************************************************
4 * Copyright (C) 2006 the VideoLAN team
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( qtr("Preferences" ) );
48 advanced_panel = NULL;
50 vertical = new QVBoxLayout();
53 types = new QGroupBox( "Show settings" );
54 QHBoxLayout *tl = new QHBoxLayout();
56 small = new QRadioButton( "Basic", types );
57 all = new QRadioButton( "All", types );
58 tl->addWidget( small );
60 types->setLayout(tl );
62 layout->addLayout( vertical, 1 );
64 all->setChecked( true );
66 main_layout->addLayout( layout );
67 adv_chk = new QCheckBox("Advanced options");
68 main_layout->addWidget( adv_chk );
72 connect( adv_chk, SIGNAL( toggled(bool) ),
73 this, SLOT( setAdvanced( bool ) ) );
74 setLayout( main_layout );
76 connect( small, SIGNAL( clicked() ), this, SLOT( setSmall()) );
77 connect( all, SIGNAL( clicked() ), this, SLOT( setAll()) );
80 void PrefsDialog::setAdvanced( bool advanced )
83 advanced_panel->setAdvanced( advanced );
86 void PrefsDialog::setAll()
88 while( (vertical->takeAt(0)) != 0 ) {}
94 advanced_tree = new PrefsTree( p_intf, this );
95 connect( advanced_tree,
96 SIGNAL( currentItemChanged( QTreeWidgetItem *, QTreeWidgetItem *) ),
97 this, 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 );