fontsettingspage.h 3.43 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2
3
4
**
** This file is part of Qt Creator
**
hjk's avatar
hjk committed
5
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
6
**
7
** Contact: Nokia Corporation (qt-info@nokia.com)
con's avatar
con committed
8
**
9
** Commercial Usage
10
**
11
12
13
14
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
15
**
16
** GNU Lesser General Public License Usage
17
**
18
19
20
21
22
23
** 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.
24
**
25
** If you are unsure which license is appropriate for your use, please
hjk's avatar
hjk committed
26
** contact the sales department at http://qt.nokia.com/contact.
con's avatar
con committed
27
**
28
**************************************************************************/
hjk's avatar
hjk committed
29

con's avatar
con committed
30
31
32
33
34
35
36
#ifndef FONTSETTINGSPAGE_H
#define FONTSETTINGSPAGE_H

#include "texteditor_global.h"

#include "fontsettings.h"

37
#include "texteditoroptionspage.h"
con's avatar
con committed
38
39
40
41
42

#include <QtCore/QString>

QT_BEGIN_NAMESPACE
class QWidget;
43
class QColor;
con's avatar
con committed
44
45
46
47
48
49
50
51
QT_END_NAMESPACE

namespace TextEditor {

namespace Internal {
class FontSettingsPagePrivate;
} // namespace Internal

52
53
// GUI description of a format consisting of id (settings key)
// and displayName to be displayed
con's avatar
con committed
54
55
56
class TEXTEDITOR_EXPORT FormatDescription
{
public:
57
    FormatDescription(const QString &id, const QString &displayName,
con's avatar
con committed
58
59
                      const QColor &foreground = Qt::black);

60
61
    QString id() const
    { return m_id; }
62

63
64
    QString displayName() const
    { return m_displayName; }
65

con's avatar
con committed
66
67
68
    QColor foreground() const;
    QColor background() const;

69
70
71
    const Format &format() const { return m_format; }
    Format &format() { return m_format; }

con's avatar
con committed
72
private:
73
74
    QString m_id;               // Name of the category
    QString m_displayName;      // Displayed name of the category
con's avatar
con committed
75
76
77
78
79
    Format m_format;            // Default format
};

typedef QList<FormatDescription> FormatDescriptions;

80
class TEXTEDITOR_EXPORT FontSettingsPage : public TextEditorOptionsPage
con's avatar
con committed
81
82
83
84
85
{
    Q_OBJECT

public:
    FontSettingsPage(const FormatDescriptions &fd,
86
                     const QString &id,
con's avatar
con committed
87
88
89
90
                     QObject *parent = 0);

    ~FontSettingsPage();

91
    QString id() const;
92
    QString displayName() const;
con's avatar
con committed
93
94

    QWidget *createPage(QWidget *parent);
95
96
    void apply();
    void finish();
97
    virtual bool matches(const QString &) const;
con's avatar
con committed
98

99
100
    void saveSettings();

con's avatar
con committed
101
102
103
104
105
106
107
    const FontSettings &fontSettings() const;

signals:
    void changed(const TextEditor::FontSettings&);

private slots:
    void delayedChange();
108
109
    void fontFamilySelected(const QString &family);
    void fontSizeSelected(const QString &sizeString);
mae's avatar
mae committed
110
    void fontZoomChanged();
111
    void colorSchemeSelected(int index);
112
    void copyColorScheme();
113
    void copyColorScheme(const QString &name);
114
    void confirmDeleteColorScheme();
115
    void deleteColorScheme();
con's avatar
con committed
116
117

private:
118
119
    void maybeSaveColorScheme();
    void updatePointSizes();
120
121
    void refreshColorSchemeList();

con's avatar
con committed
122
123
124
125
126
127
    Internal::FontSettingsPagePrivate *d_ptr;
};

} // namespace TextEditor

#endif // FONTSETTINGSPAGE_H