Files
qt-creator/src/plugins/texteditor/fontsettingspage.h
T

161 lines
5.4 KiB
C++
Raw Normal View History

2012-10-02 09:12:39 +02:00
/****************************************************************************
2008-12-02 12:01:29 +01:00
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
2008-12-02 12:01:29 +01:00
**
2012-10-02 09:12:39 +02:00
** This file is part of Qt Creator.
2008-12-02 12:01:29 +01:00
**
2012-10-02 09:12:39 +02:00
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
2010-12-17 16:01:08 +01:00
**
2012-10-02 09:12:39 +02:00
****************************************************************************/
2008-12-02 16:19:05 +01:00
2016-03-18 07:55:01 +01:00
#pragma once
2008-12-02 12:01:29 +01:00
#include "texteditor_global.h"
#include "texteditorconstants.h"
#include "colorscheme.h"
2008-12-02 12:01:29 +01:00
#include <coreplugin/dialogs/ioptionspage.h>
2008-12-02 12:01:29 +01:00
#include <QList>
#include <QString>
2008-12-02 12:01:29 +01:00
QT_BEGIN_NAMESPACE
2009-10-01 16:38:08 +02:00
class QColor;
2008-12-02 12:01:29 +01:00
QT_END_NAMESPACE
namespace TextEditor {
class Format;
class FontSettings;
namespace Internal { class FontSettingsPagePrivate; }
2008-12-02 12:01:29 +01:00
2010-01-07 18:17:24 +01:00
// GUI description of a format consisting of id (settings key)
// and displayName to be displayed
2008-12-02 12:01:29 +01:00
class TEXTEDITOR_EXPORT FormatDescription
{
public:
enum ShowControls {
ShowForegroundControl = 0x1,
ShowBackgroundControl = 0x2,
ShowFontControls = 0x4,
ShowUnderlineControl = 0x8,
2016-09-27 11:52:18 +02:00
ShowRelativeForegroundControl = 0x10,
ShowRelativeBackgroundControl = 0x20,
2018-09-24 14:51:06 +02:00
ShowRelativeControls = ShowRelativeForegroundControl | ShowRelativeBackgroundControl,
2016-09-27 11:52:18 +02:00
ShowFontUnderlineAndRelativeControls = ShowFontControls
| ShowUnderlineControl
2018-09-24 14:51:06 +02:00
| ShowRelativeControls,
ShowAllAbsoluteControls = ShowForegroundControl
| ShowBackgroundControl
| ShowFontControls
| ShowUnderlineControl,
ShowAllAbsoluteControlsExceptUnderline = ShowAllAbsoluteControls & ~ShowUnderlineControl,
ShowAllControls = ShowAllAbsoluteControls | ShowRelativeControls
};
FormatDescription() = default;
FormatDescription(TextStyle id,
const QString &displayName,
const QString &tooltipText,
2018-09-24 14:51:06 +02:00
ShowControls showControls = ShowAllAbsoluteControls);
FormatDescription(TextStyle id,
const QString &displayName,
const QString &tooltipText,
const QColor &foreground,
2018-09-24 14:51:06 +02:00
ShowControls showControls = ShowAllAbsoluteControls);
FormatDescription(TextStyle id,
const QString &displayName,
const QString &tooltipText,
const Format &format,
2018-09-24 14:51:06 +02:00
ShowControls showControls = ShowAllAbsoluteControls);
FormatDescription(TextStyle id,
const QString &displayName,
const QString &tooltipText,
const QColor &underlineColor,
const QTextCharFormat::UnderlineStyle underlineStyle,
2018-09-24 14:51:06 +02:00
ShowControls showControls = ShowAllAbsoluteControls);
2008-12-02 12:01:29 +01:00
TextStyle id() const { return m_id; }
2010-01-07 18:17:24 +01:00
QString displayName() const
{ return m_displayName; }
static QColor defaultForeground(TextStyle id);
static QColor defaultBackground(TextStyle id);
2008-12-02 12:01:29 +01:00
const Format &format() const { return m_format; }
Format &format() { return m_format; }
2012-08-27 10:55:13 +02:00
QString tooltipText() const
{ return m_tooltipText; }
bool showControl(ShowControls showControl) const;
2008-12-02 12:01:29 +01:00
private:
TextStyle m_id; // Name of the category
2008-12-02 12:01:29 +01:00
Format m_format; // Default format
2013-02-18 18:47:54 +01:00
QString m_displayName; // Displayed name of the category
2012-08-27 10:55:13 +02:00
QString m_tooltipText; // Description text for category
2018-09-24 14:51:06 +02:00
ShowControls m_showControls = ShowAllAbsoluteControls;
2008-12-02 12:01:29 +01:00
};
2018-11-25 18:52:41 +01:00
using FormatDescriptions = std::vector<FormatDescription>;
2008-12-02 12:01:29 +01:00
class TEXTEDITOR_EXPORT FontSettingsPage : public Core::IOptionsPage
2008-12-02 12:01:29 +01:00
{
Q_OBJECT
public:
explicit FontSettingsPage(const FormatDescriptions &fd);
2018-05-07 15:02:41 +02:00
~FontSettingsPage() override;
2008-12-02 12:01:29 +01:00
2018-05-07 15:02:41 +02:00
QWidget *widget() override;
void apply() override;
void finish() override;
2008-12-02 12:01:29 +01:00
void saveSettings();
2008-12-02 12:01:29 +01:00
const FontSettings &fontSettings() const;
signals:
void changed(const TextEditor::FontSettings&);
2015-12-13 01:18:33 +02:00
private:
2008-12-02 12:01:29 +01:00
void delayedChange();
void fontSelected(const QFont &font);
void fontSizeSelected(const QString &sizeString);
2009-11-30 19:00:36 +01:00
void fontZoomChanged();
void antialiasChanged();
void colorSchemeSelected(int index);
void openCopyColorSchemeDialog();
void copyColorScheme(const QString &name);
void confirmDeleteColorScheme();
void deleteColorScheme();
2008-12-02 12:01:29 +01:00
void maybeSaveColorScheme();
void updatePointSizes();
QList<int> pointSizesForSelectedFont() const;
void refreshColorSchemeList();
2008-12-02 12:01:29 +01:00
Internal::FontSettingsPagePrivate *d_ptr;
};
} // namespace TextEditor