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 QGridLayout *main_layout = new QGridLayout(this);
41 setWindowTitle( qtr("Preferences" ) );
44 tree_panel = new QWidget(0);
45 tree_panel_l = new QHBoxLayout;
46 tree_panel->setLayout( tree_panel_l );
47 main_panel = new QWidget(0);
48 main_panel_l = new QHBoxLayout;
49 main_panel->setLayout( main_panel_l );
52 types = new QGroupBox( "Show settings" );
53 QHBoxLayout *tl = new QHBoxLayout(0);
54 tl->setSpacing( 3 ); tl->setMargin( 3 );
55 small = new QRadioButton( "Basic", types ); tl->addWidget( small );
56 all = new QRadioButton( "All", types ); tl->addWidget( all );
58 all->setChecked( true );
60 adv_chk = new QCheckBox("Advanced options");
65 advanced_panel = NULL;
67 main_layout->addWidget( types, 0,0,1,1 );
68 main_layout->addWidget( tree_panel, 1,0,1,1 );
69 main_layout->addWidget( adv_chk , 2,0,1,1 );
70 main_layout->addWidget( main_panel, 0, 1, 3, 1 );
72 main_layout->setColumnMinimumWidth( 0, 200 );
73 main_layout->setColumnStretch( 0, 1 );
74 main_layout->setColumnStretch( 1,3 );
78 connect( adv_chk, SIGNAL( toggled(bool) ),
79 this, SLOT( setAdvanced( bool ) ) );
80 setLayout( main_layout );
82 connect( small, SIGNAL( clicked() ), this, SLOT( setSmall()) );
83 connect( all, SIGNAL( clicked() ), this, SLOT( setAll()) );
86 void PrefsDialog::setAdvanced( bool advanced )
89 advanced_panel->setAdvanced( advanced );
92 void PrefsDialog::setAll()
96 tree_panel_l->removeWidget( simple_tree );
102 advanced_tree = new PrefsTree( p_intf, tree_panel );
103 connect( advanced_tree,
104 SIGNAL( currentItemChanged( QTreeWidgetItem *, QTreeWidgetItem *) ),
105 this, SLOT( changePanel( QTreeWidgetItem * ) ) );
107 tree_panel_l->addWidget( advanced_tree );
108 advanced_tree->show();
112 main_panel_l->removeWidget( simple_panel );
113 simple_panel->hide();
115 if( !advanced_panel )
116 advanced_panel = new PrefsPanel( main_panel );
117 main_panel_l->addWidget( advanced_panel );
118 advanced_panel->show();
121 void PrefsDialog::setSmall()
125 tree_panel_l->removeWidget( advanced_tree );
126 advanced_tree->hide();
129 simple_tree = new QTreeWidget();
130 tree_panel_l->addWidget( simple_tree );
135 main_panel_l->removeWidget( advanced_panel );
136 advanced_panel->hide();
139 simple_panel = new QWidget();
140 main_panel_l->addWidget( simple_panel );
141 simple_panel->show();
144 PrefsDialog::~PrefsDialog()
148 void PrefsDialog::changePanel( QTreeWidgetItem *item )
150 PrefsItemData *data = item->data( 0, Qt::UserRole ).value<PrefsItemData*>();
154 main_panel_l->removeWidget( advanced_panel );
155 advanced_panel->hide();
159 data->panel = new PrefsPanel( p_intf, main_panel , data,
160 adv_chk->isChecked() );
162 advanced_panel = data->panel;
163 main_panel_l->addWidget( advanced_panel );
164 advanced_panel->show();
165 setAdvanced( adv_chk->isChecked() );