fontsettingspage.h 3.84 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
con's avatar
con committed
2
**
3
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** 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 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
#include <QList>
#include <QString>
con's avatar
con committed
41 42 43

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

namespace TextEditor {

namespace Internal {
class FontSettingsPagePrivate;
} // namespace Internal

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

63
    TextStyle id() const { return m_id; }
64

65 66
    QString displayName() const
    { return m_displayName; }
67

con's avatar
con committed
68 69 70
    QColor foreground() const;
    QColor background() const;

71 72 73
    const Format &format() const { return m_format; }
    Format &format() { return m_format; }

74 75 76
    QString tooltipText() const
    { return  m_tooltipText; }

con's avatar
con committed
77
private:
78
    TextStyle m_id;            // Name of the category
con's avatar
con committed
79
    Format m_format;            // Default format
80
    QString m_displayName;      // Displayed name of the category
81
    QString m_tooltipText;      // Description text for category
con's avatar
con committed
82 83 84 85
};

typedef QList<FormatDescription> FormatDescriptions;

86
class TEXTEDITOR_EXPORT FontSettingsPage : public TextEditorOptionsPage
con's avatar
con committed
87 88 89 90
{
    Q_OBJECT

public:
hjk's avatar
hjk committed
91
    FontSettingsPage(const FormatDescriptions &fd, Core::Id id, QObject *parent = 0);
con's avatar
con committed
92 93 94

    ~FontSettingsPage();

95
    QWidget *widget();
96 97
    void apply();
    void finish();
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 antialiasChanged();
112
    void colorSchemeSelected(int index);
113
    void copyColorScheme();
114
    void copyColorScheme(const QString &name);
115
    void confirmDeleteColorScheme();
116
    void deleteColorScheme();
con's avatar
con committed
117 118

private:
119 120
    void maybeSaveColorScheme();
    void updatePointSizes();
121
    QList<int> pointSizesForSelectedFont() const;
122 123
    void refreshColorSchemeList();

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

} // namespace TextEditor

#endif // FONTSETTINGSPAGE_H