ioptionspage.h 3.77 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 IOPTIONSPAGE_H
#define IOPTIONSPAGE_H

hjk's avatar
hjk committed
33
#include <coreplugin/id.h>
con's avatar
con committed
34

35
#include <QIcon>
36
#include <QObject>
37

con's avatar
con committed
38
39
40
41
42
namespace Core {

class CORE_EXPORT IOptionsPage : public QObject
{
    Q_OBJECT
hjk's avatar
hjk committed
43

con's avatar
con committed
44
45
46
public:
    IOptionsPage(QObject *parent = 0) : QObject(parent) {}

hjk's avatar
hjk committed
47
    Id id() const { return m_id; }
48
    QString displayName() const { return m_displayName; }
hjk's avatar
hjk committed
49
    Id category() const { return m_category; }
50
51
    QString displayCategory() const { return m_displayCategory; }
    QIcon categoryIcon() const { return QIcon(m_categoryIcon); }
con's avatar
con committed
52

53
    virtual bool matches(const QString & /* searchKeyWord*/) const { return false; }
con's avatar
con committed
54
    virtual QWidget *createPage(QWidget *parent) = 0;
55
56
    virtual void apply() = 0;
    virtual void finish() = 0;
57
58

protected:
hjk's avatar
hjk committed
59
    void setId(Id id) { m_id = id; }
60
    void setDisplayName(const QString &displayName) { m_displayName = displayName; }
hjk's avatar
hjk committed
61
    void setCategory(Id category) { m_category = category; }
62
63
64
    void setDisplayCategory(const QString &displayCategory) { m_displayCategory = displayCategory; }
    void setCategoryIcon(const QString &categoryIcon) { m_categoryIcon = categoryIcon; }

hjk's avatar
hjk committed
65
    Id m_id;
66
    QString m_displayName;
hjk's avatar
hjk committed
67
    Id m_category;
68
69
    QString m_displayCategory;
    QString m_categoryIcon;
con's avatar
con committed
70
71
};

72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
    Alternative way for providing option pages instead of adding IOptionsPage
    objects into the plugin manager pool. Should only be used if creation of the
    actual option pages is not possible or too expensive at Qt Creator startup.
    (Like the designer integration, which needs to initialize designer plugins
    before the options pages get available.)
*/

class CORE_EXPORT IOptionsPageProvider : public QObject
{
    Q_OBJECT

public:
    IOptionsPageProvider(QObject *parent = 0) : QObject(parent) {}

hjk's avatar
hjk committed
87
    Core::Id category() const { return m_category; }
88
89
    QString displayCategory() const { return m_displayCategory; }
    QIcon categoryIcon() const { return QIcon(m_categoryIcon); }
90
91

    virtual QList<IOptionsPage *> pages() const = 0;
92
93

protected:
hjk's avatar
hjk committed
94
    void setCategory(Core::Id category) { m_category = category; }
95
96
97
    void setDisplayCategory(const QString &displayCategory) { m_displayCategory = displayCategory; }
    void setCategoryIcon(const QString &categoryIcon) { m_categoryIcon = categoryIcon; }

hjk's avatar
hjk committed
98
    Core::Id m_category;
99
100
    QString m_displayCategory;
    QString m_categoryIcon;
101
102
};

con's avatar
con committed
103
104
105
} // namespace Core

#endif // IOPTIONSPAGE_H