Settings.h 2.92 KB
Newer Older
1
/*****************************************************************************
2
 * Settings.h: generic preferences interface
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 *****************************************************************************
 * Copyright (C) 2008-2009 the VLMC team
 *
 * Authors: Clement CHAVANCE <kinder@vlmc.org>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

23
24
25
#ifndef SIMPLEPREFERENCES_H
#define SIMPLEPREFERENCES_H

Ludovic Fauvet's avatar
Ludovic Fauvet committed
26
#include <QDialog>
27
28
#include <QString>
#include <QHash>
29
#include <QLabel>
30
#include <QVBoxLayout>
31
#include <QDialogButtonBox>
32
#include <QButtonGroup>
33
#include <QStackedWidget>
34
#include <QAbstractButton>
35
#include <QVector>
36

37
#include "Panel.h"
38
#include "PreferenceWidget.h"
39

Ludovic Fauvet's avatar
Ludovic Fauvet committed
40
class   Settings : public QDialog
41
42
{
    Q_OBJECT
43
    Q_DISABLE_COPY( Settings )
44
45

    public:
Clement CHAVANCE's avatar
Clement CHAVANCE committed
46
47
48
49
        Settings( bool loadDefaults = false,
                  const QString& name = "default",
                  QWidget* parent = 0,
                  Qt::WindowFlags f = 0 );
Ludovic Fauvet's avatar
Ludovic Fauvet committed
50
        virtual ~Settings();
51
        void                addWidget( const QString& name,
52
                                        PreferenceWidget* pWidget,
53
                                        const QIcon& icon,
54
                                        const QString& label );
55
        void                build();
56
        void                show( const QString& part = "default" );
57
58

    private:
Clement CHAVANCE's avatar
Clement CHAVANCE committed
59
        void            connect( void );
60
        QVBoxLayout*    buildRightHLayout();
61
        void    save( void );
62
63

    private:
64
65
66
67
68
69
        QHash<int, QString>         m_widgets;
        QVector<PreferenceWidget*>  m_pWidgets;
        QWidget*                    m_currentWidget;
        Panel*                      m_panel;
        QLabel*                     m_title;
        QStackedWidget*             m_stackedWidgets;
70
        QDialogButtonBox*           m_buttons;
71
        bool                        m_defaults;
Clement CHAVANCE's avatar
Clement CHAVANCE committed
72
        QString                     m_name;
73

74
75

    public slots:
76
        void    switchWidget( int widget );
77
        void    load();
78

79
    private slots:
80
        void    buttonClicked( QAbstractButton* button );
81

82
83
    signals:
        void    widgetSwitched( int widget );
84
        void    loadSettings( const QString& part, bool defaults );
85
86
87
};

#endif /* !SIMPLEPREFERENCES_H */