2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
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"
|
|
|
|
|
|
2015-02-26 13:22:35 +01:00
|
|
|
#include "texteditorconstants.h"
|
|
|
|
|
#include "colorscheme.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2020-01-15 15:00:57 +01:00
|
|
|
#include <coreplugin/dialogs/ioptionspage.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-02-15 10:42:41 +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 {
|
|
|
|
|
|
2015-02-26 13:22:35 +01:00
|
|
|
class Format;
|
|
|
|
|
class FontSettings;
|
2014-02-11 21:55:42 +02:00
|
|
|
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:
|
2015-09-21 13:12:36 +02:00
|
|
|
enum ShowControls {
|
|
|
|
|
ShowForegroundControl = 0x1,
|
|
|
|
|
ShowBackgroundControl = 0x2,
|
2022-05-07 00:44:03 +03:00
|
|
|
ShowForeAndBackgroundControl = ShowForegroundControl | ShowBackgroundControl,
|
2015-09-21 13:12:36 +02:00
|
|
|
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
|
2015-09-21 13:12:36 +02:00
|
|
|
};
|
|
|
|
|
FormatDescription() = default;
|
|
|
|
|
|
|
|
|
|
FormatDescription(TextStyle id,
|
|
|
|
|
const QString &displayName,
|
|
|
|
|
const QString &tooltipText,
|
2018-09-24 14:51:06 +02:00
|
|
|
ShowControls showControls = ShowAllAbsoluteControls);
|
2015-09-21 13:12:36 +02:00
|
|
|
|
2015-09-10 14:18:37 +02:00
|
|
|
FormatDescription(TextStyle id,
|
|
|
|
|
const QString &displayName,
|
|
|
|
|
const QString &tooltipText,
|
2015-09-21 13:12:36 +02:00
|
|
|
const QColor &foreground,
|
2018-09-24 14:51:06 +02:00
|
|
|
ShowControls showControls = ShowAllAbsoluteControls);
|
2015-09-10 14:18:37 +02:00
|
|
|
FormatDescription(TextStyle id,
|
|
|
|
|
const QString &displayName,
|
|
|
|
|
const QString &tooltipText,
|
2015-09-21 13:12:36 +02:00
|
|
|
const Format &format,
|
2018-09-24 14:51:06 +02:00
|
|
|
ShowControls showControls = ShowAllAbsoluteControls);
|
2015-09-10 14:18:37 +02:00
|
|
|
FormatDescription(TextStyle id,
|
|
|
|
|
const QString &displayName,
|
|
|
|
|
const QString &tooltipText,
|
|
|
|
|
const QColor &underlineColor,
|
2015-09-21 13:12:36 +02:00
|
|
|
const QTextCharFormat::UnderlineStyle underlineStyle,
|
2018-09-24 14:51:06 +02:00
|
|
|
ShowControls showControls = ShowAllAbsoluteControls);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-04-26 14:17:42 +02:00
|
|
|
TextStyle id() const { return m_id; }
|
2009-06-18 12:28:40 +02:00
|
|
|
|
2010-01-07 18:17:24 +01:00
|
|
|
QString displayName() const
|
|
|
|
|
{ return m_displayName; }
|
2009-06-18 12:28:40 +02:00
|
|
|
|
2016-06-19 10:46:49 +03:00
|
|
|
static QColor defaultForeground(TextStyle id);
|
|
|
|
|
static QColor defaultBackground(TextStyle id);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-06-12 15:28:51 +02: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; }
|
|
|
|
|
|
2015-09-21 13:12:36 +02:00
|
|
|
bool showControl(ShowControls showControl) const;
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
private:
|
2012-04-26 14:17:42 +02:00
|
|
|
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
|
|
|
|
2020-01-27 13:52:32 +01:00
|
|
|
class TEXTEDITOR_EXPORT FontSettingsPage final : public Core::IOptionsPage
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2020-01-27 13:52:32 +01:00
|
|
|
FontSettingsPage(FontSettings *fontSettings, const FormatDescriptions &fd);
|
2009-06-18 16:12:24 +02:00
|
|
|
|
2020-01-27 13:52:32 +01:00
|
|
|
void setFontZoom(int zoom);
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace TextEditor
|