settingsdialog.h 3.45 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
con's avatar
con committed
2
**
hjk's avatar
hjk committed
3
4
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
con's avatar
con committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
con's avatar
con committed
7
**
hjk's avatar
hjk committed
8
9
10
11
12
13
14
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
15
**
16
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17
18
19
20
21
22
23
24
25
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
con's avatar
con committed
26
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
hjk's avatar
hjk committed
29

con's avatar
con committed
30
31
32
#ifndef SETTINGSDIALOG_H
#define SETTINGSDIALOG_H

33
#include "coreplugin/dialogs/ioptionspage.h"
hjk's avatar
hjk committed
34
#include "coreplugin/id.h"
35

36
37
38
39
#include <QList>
#include <QSet>
#include <QEventLoop>
#include <QDialog>
con's avatar
con committed
40

41
42
43
QT_BEGIN_NAMESPACE
class QModelIndex;
class QSortFilterProxyModel;
Friedemann Kleint's avatar
Friedemann Kleint committed
44
45
class QStackedLayout;
class QLabel;
46
class QListView;
47
48
QT_END_NAMESPACE

hjk's avatar
hjk committed
49
namespace Utils { class FilterLineEdit; }
Friedemann Kleint's avatar
Friedemann Kleint committed
50

con's avatar
con committed
51
52
53
namespace Core {
namespace Internal {

54
55
56
class Category;
class CategoryModel;

Friedemann Kleint's avatar
Friedemann Kleint committed
57
class SettingsDialog : public QDialog
con's avatar
con committed
58
59
60
61
{
    Q_OBJECT

public:
62
63
64
65
    // Returns a settings dialog. This makes sure that always only
    // a single settings dialog instance is running.
    // The dialog will be deleted automatically on close.
    static SettingsDialog *getSettingsDialog(QWidget *parent,
hjk's avatar
hjk committed
66
        Id initialCategory, Id initialPage);
67
68
    // Run the dialog and wait for it to finish.
    // Returns if the changes have been applied.
69
70
    bool execDialog();

71
72
    virtual QSize sizeHint() const;

73
74
75
public slots:
    void done(int);

con's avatar
con committed
76
77
78
private slots:
    void accept();
    void reject();
79
    void apply();
80
81
    void currentChanged(const QModelIndex &current);
    void currentTabChanged(int);
82
    void filter(const QString &text);
83
    void ensureAllCategoryWidgets();
con's avatar
con committed
84
85

private:
86
87
88
    SettingsDialog(QWidget *parent);
    ~SettingsDialog();

Friedemann Kleint's avatar
Friedemann Kleint committed
89
    void createGui();
90
    void showCategory(int index);
hjk's avatar
hjk committed
91
    void showPage(Id categoryId, Id pageId);
92
    void updateEnabledTabs(Category *category, const QString &searchText);
93
    void ensureCategoryWidget(Category *category);
94
    void disconnectTabWidgets();
95

hjk's avatar
hjk committed
96
    const QList<IOptionsPage *> m_pages;
97

hjk's avatar
hjk committed
98
    QSet<IOptionsPage *> m_visitedPages;
99
    QSortFilterProxyModel *m_proxyModel;
100
    CategoryModel *m_model;
hjk's avatar
hjk committed
101
102
    Id m_currentCategory;
    Id m_currentPage;
Friedemann Kleint's avatar
Friedemann Kleint committed
103
104
    QStackedLayout *m_stackedLayout;
    Utils::FilterLineEdit *m_filterLineEdit;
105
    QListView *m_categoryList;
Friedemann Kleint's avatar
Friedemann Kleint committed
106
    QLabel *m_headerLabel;
107
108
    bool m_running;
    bool m_applied;
109
    bool m_finished;
110
    QList<QEventLoop *> m_eventLoops;
con's avatar
con committed
111
112
113
114
115
116
};

} // namespace Internal
} // namespace Core

#endif // SETTINGSDIALOG_H