forked from qt-creator/qt-creator
Help: Add option for disabling antialising of fonts
For the backends that we can do it for (litehtml, QTextBrowser). Fixes: QTCREATORBUG-12177 Change-Id: If64a279f74f878b6797bf43d8129058c6183919b Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Kai Köhne <kai.koehne@qt.io>
This commit is contained in:
Submodule src/libs/qlitehtml updated: 8e541a22b5...b8f6617f22
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
@@ -76,6 +77,7 @@ private:
|
||||
QFontComboBox *familyComboBox;
|
||||
QComboBox *styleComboBox;
|
||||
QComboBox *sizeComboBox;
|
||||
QCheckBox *antialiasCheckBox;
|
||||
QLineEdit *homePageLineEdit;
|
||||
QComboBox *helpStartComboBox;
|
||||
QComboBox *contextHelpComboBox;
|
||||
@@ -92,49 +94,31 @@ private:
|
||||
|
||||
GeneralSettingsPageWidget::GeneralSettingsPageWidget()
|
||||
{
|
||||
using namespace Layouting;
|
||||
|
||||
// font group box
|
||||
auto fontGroupBox = new QGroupBox(Tr::tr("Font"));
|
||||
auto familyLabel = new QLabel(Tr::tr("Family:"));
|
||||
|
||||
familyComboBox = new QFontComboBox;
|
||||
auto styleLabel = new QLabel(Tr::tr("Style:"));
|
||||
styleComboBox = new QComboBox;
|
||||
auto sizeLabel = new QLabel(Tr::tr("Size:"));
|
||||
sizeComboBox = new QComboBox;
|
||||
|
||||
auto fontLayout = new QHBoxLayout();
|
||||
fontLayout->addWidget(familyComboBox);
|
||||
fontLayout->addSpacing(20);
|
||||
fontLayout->addWidget(styleLabel);
|
||||
fontLayout->addWidget(styleComboBox);
|
||||
fontLayout->addSpacing(20);
|
||||
fontLayout->addWidget(sizeLabel);
|
||||
fontLayout->addWidget(sizeComboBox);
|
||||
fontLayout->addStretch();
|
||||
|
||||
auto noteLabel = new QLabel(Tr::tr(
|
||||
"Note: The above setting takes effect only if the HTML file does not use a style sheet."));
|
||||
noteLabel->setWordWrap(true);
|
||||
auto zoomLabel = new QLabel(Tr::tr("Zoom:"));
|
||||
|
||||
zoomSpinBox = new QSpinBox;
|
||||
zoomSpinBox->setMinimum(10);
|
||||
zoomSpinBox->setMaximum(3000);
|
||||
zoomSpinBox->setSingleStep(10);
|
||||
zoomSpinBox->setValue(100);
|
||||
zoomSpinBox->setSuffix(Tr::tr("%"));
|
||||
antialiasCheckBox = new QCheckBox(Tr::tr("Antialias"));
|
||||
|
||||
auto zoomLayout = new QHBoxLayout();
|
||||
zoomLayout->addWidget(zoomSpinBox);
|
||||
zoomLayout->addStretch();
|
||||
|
||||
auto fontGroupBoxLayout = new QGridLayout;
|
||||
fontGroupBox->setLayout(fontGroupBoxLayout);
|
||||
fontGroupBoxLayout->addWidget(familyLabel, 0, 0);
|
||||
fontGroupBoxLayout->addLayout(fontLayout, 0, 1);
|
||||
fontGroupBoxLayout->addWidget(noteLabel, 1, 0, 1, 2);
|
||||
fontGroupBoxLayout->addWidget(zoomLabel, 2, 0);
|
||||
fontGroupBoxLayout->addLayout(zoomLayout, 2, 1);
|
||||
auto fontGroupBox = new QGroupBox(Tr::tr("Font"));
|
||||
// clang-format off
|
||||
Column {
|
||||
Row { Tr::tr("Family:"), familyComboBox,
|
||||
Tr::tr("Style:"), styleComboBox,
|
||||
Tr::tr("Size:"), sizeComboBox, st },
|
||||
Row { Tr::tr("Note: The above setting takes effect only if the "
|
||||
"HTML file does not use a style sheet.") },
|
||||
Row { Tr::tr("Zoom:"), zoomSpinBox, antialiasCheckBox, st }
|
||||
}.attachTo(fontGroupBox);
|
||||
// clang-format on
|
||||
|
||||
// startup group box
|
||||
auto startupGroupBox = new QGroupBox(Tr::tr("Startup"));
|
||||
@@ -231,6 +215,7 @@ GeneralSettingsPageWidget::GeneralSettingsPageWidget()
|
||||
m_font = LocalHelpManager::fallbackFont();
|
||||
m_fontZoom = LocalHelpManager::fontZoom();
|
||||
zoomSpinBox->setValue(m_fontZoom);
|
||||
antialiasCheckBox->setChecked(LocalHelpManager::antialias());
|
||||
|
||||
updateFontSizeSelector();
|
||||
updateFontStyleSelector();
|
||||
@@ -309,6 +294,8 @@ void GeneralSettingsPageWidget::apply()
|
||||
if (m_fontZoom != LocalHelpManager::fontZoom())
|
||||
LocalHelpManager::setFontZoom(m_fontZoom);
|
||||
|
||||
LocalHelpManager::setAntialias(antialiasCheckBox->isChecked());
|
||||
|
||||
QString homePage = QUrl::fromUserInput(homePageLineEdit->text()).toString();
|
||||
if (homePage.isEmpty())
|
||||
homePage = Help::Constants::AboutBlank;
|
||||
|
||||
@@ -374,6 +374,13 @@ HelpViewer *HelpPlugin::createHelpViewer()
|
||||
connect(LocalHelpManager::instance(), &LocalHelpManager::fontZoomChanged,
|
||||
viewer, &HelpViewer::setFontZoom);
|
||||
|
||||
// initialize antialias
|
||||
viewer->setAntialias(LocalHelpManager::antialias());
|
||||
connect(LocalHelpManager::instance(),
|
||||
&LocalHelpManager::antialiasChanged,
|
||||
viewer,
|
||||
&HelpViewer::setAntialias);
|
||||
|
||||
viewer->setScrollWheelZoomingEnabled(LocalHelpManager::isScrollWheelZoomingEnabled());
|
||||
connect(LocalHelpManager::instance(), &LocalHelpManager::scrollWheelZoomingEnabledChanged,
|
||||
viewer, &HelpViewer::setScrollWheelZoomingEnabled);
|
||||
|
||||
@@ -71,6 +71,8 @@ HelpViewer::~HelpViewer()
|
||||
restoreOverrideCursor();
|
||||
}
|
||||
|
||||
void HelpViewer::setAntialias(bool) {}
|
||||
|
||||
void HelpViewer::setFontZoom(int percentage)
|
||||
{
|
||||
setScale(percentage / 100.0);
|
||||
|
||||
@@ -32,6 +32,7 @@ public:
|
||||
~HelpViewer() override;
|
||||
|
||||
virtual void setViewerFont(const QFont &font) = 0;
|
||||
virtual void setAntialias(bool on);
|
||||
|
||||
virtual void setScale(qreal scale) = 0;
|
||||
|
||||
|
||||
@@ -134,6 +134,11 @@ void LiteHtmlHelpViewer::setScale(qreal scale)
|
||||
m_viewer->setZoomFactor(scale == 0 ? qreal(1) : scale);
|
||||
}
|
||||
|
||||
void LiteHtmlHelpViewer::setAntialias(bool on)
|
||||
{
|
||||
m_viewer->setAntialias(on);
|
||||
}
|
||||
|
||||
QString LiteHtmlHelpViewer::title() const
|
||||
{
|
||||
return m_viewer->title();
|
||||
|
||||
@@ -24,8 +24,8 @@ public:
|
||||
~LiteHtmlHelpViewer() override;
|
||||
|
||||
void setViewerFont(const QFont &font) override;
|
||||
|
||||
void setScale(qreal scale) override;
|
||||
void setAntialias(bool on) final;
|
||||
|
||||
QString title() const override;
|
||||
|
||||
|
||||
@@ -52,21 +52,23 @@ QHelpEngine* LocalHelpManager::m_guiEngine = nullptr;
|
||||
QMutex LocalHelpManager::m_bkmarkMutex;
|
||||
BookmarkManager* LocalHelpManager::m_bookmarkManager = nullptr;
|
||||
|
||||
static const char kHelpHomePageKey[] = "Help/HomePage";
|
||||
static const char kFontFamilyKey[] = "Help/FallbackFontFamily";
|
||||
static const char kFontStyleNameKey[] = "Help/FallbackFontStyleName";
|
||||
static const char kFontSizeKey[] = "Help/FallbackFontSize";
|
||||
static const char kFontZoomKey[] = "Help/FontZoom";
|
||||
static const char kStartOptionKey[] = "Help/StartOption";
|
||||
static const char kContextHelpOptionKey[] = "Help/ContextHelpOption";
|
||||
static const char kReturnOnCloseKey[] = "Help/ReturnOnClose";
|
||||
static const char kUseScrollWheelZooming[] = "Help/UseScrollWheelZooming";
|
||||
static const char kLastShownPagesKey[] = "Help/LastShownPages";
|
||||
static const char kLastSelectedTabKey[] = "Help/LastSelectedTab";
|
||||
static const char kViewerBackend[] = "Help/ViewerBackend";
|
||||
const char kHelpHomePageKey[] = "Help/HomePage";
|
||||
const char kFontFamilyKey[] = "Help/FallbackFontFamily";
|
||||
const char kFontStyleNameKey[] = "Help/FallbackFontStyleName";
|
||||
const char kFontSizeKey[] = "Help/FallbackFontSize";
|
||||
const char kFontZoomKey[] = "Help/FontZoom";
|
||||
const char kAntialiasKey[] = "Help/FontAntialias";
|
||||
const char kStartOptionKey[] = "Help/StartOption";
|
||||
const char kContextHelpOptionKey[] = "Help/ContextHelpOption";
|
||||
const char kReturnOnCloseKey[] = "Help/ReturnOnClose";
|
||||
const char kUseScrollWheelZooming[] = "Help/UseScrollWheelZooming";
|
||||
const char kLastShownPagesKey[] = "Help/LastShownPages";
|
||||
const char kLastSelectedTabKey[] = "Help/LastSelectedTab";
|
||||
const char kViewerBackend[] = "Help/ViewerBackend";
|
||||
|
||||
static const int kDefaultFallbackFontSize = 14;
|
||||
static const int kDefaultFontZoom = 100;
|
||||
const int kDefaultFallbackFontSize = 14;
|
||||
const int kDefaultFontZoom = 100;
|
||||
const bool kDefaultAntialias = true;
|
||||
const int kDefaultStartOption = LocalHelpManager::ShowLastPages;
|
||||
const int kDefaultContextHelpOption = Core::HelpManager::SideBySideIfPossible;
|
||||
const bool kDefaultReturnOnClose = false;
|
||||
@@ -175,6 +177,19 @@ int LocalHelpManager::setFontZoom(int percentage)
|
||||
return newZoom;
|
||||
}
|
||||
|
||||
bool LocalHelpManager::antialias()
|
||||
{
|
||||
return Core::ICore::settings()->value(kAntialiasKey, kDefaultAntialias).toBool();
|
||||
}
|
||||
|
||||
void LocalHelpManager::setAntialias(bool on)
|
||||
{
|
||||
if (on != antialias()) {
|
||||
Core::ICore::settings()->setValueWithDefault(kAntialiasKey, on, kDefaultAntialias);
|
||||
emit m_instance->antialiasChanged(on);
|
||||
}
|
||||
}
|
||||
|
||||
LocalHelpManager::StartOption LocalHelpManager::startOption()
|
||||
{
|
||||
const QVariant value = Core::ICore::settings()->value(kStartOptionKey, kDefaultStartOption);
|
||||
|
||||
@@ -61,6 +61,9 @@ public:
|
||||
static int fontZoom();
|
||||
static int setFontZoom(int percentage);
|
||||
|
||||
static bool antialias();
|
||||
static void setAntialias(bool on);
|
||||
|
||||
static StartOption startOption();
|
||||
static void setStartOption(StartOption option);
|
||||
|
||||
@@ -104,6 +107,7 @@ public:
|
||||
signals:
|
||||
void fallbackFontChanged(const QFont &font);
|
||||
void fontZoomChanged(int percentage);
|
||||
void antialiasChanged(bool on);
|
||||
void returnOnCloseChanged();
|
||||
void scrollWheelZoomingEnabledChanged(bool enabled);
|
||||
void contextHelpOptionChanged(Core::HelpManager::HelpViewerLocation option);
|
||||
|
||||
@@ -55,22 +55,28 @@ TextBrowserHelpViewer::~TextBrowserHelpViewer() = default;
|
||||
|
||||
void TextBrowserHelpViewer::setViewerFont(const QFont &newFont)
|
||||
{
|
||||
setFontAndScale(newFont, LocalHelpManager::fontZoom() / 100.0);
|
||||
setFontAndScale(newFont, LocalHelpManager::fontZoom() / 100.0, LocalHelpManager::antialias());
|
||||
}
|
||||
|
||||
void TextBrowserHelpViewer::setFontAndScale(const QFont &font, qreal scale)
|
||||
void TextBrowserHelpViewer::setFontAndScale(const QFont &font, qreal scale, bool antialias)
|
||||
{
|
||||
m_textBrowser->withFixedTopPosition([this, &font, scale] {
|
||||
m_textBrowser->withFixedTopPosition([this, &font, scale, antialias] {
|
||||
QFont newFont = font;
|
||||
const float newSize = font.pointSizeF() * scale;
|
||||
newFont.setPointSizeF(newSize);
|
||||
newFont.setStyleStrategy(antialias ? QFont::PreferAntialias : QFont::NoAntialias);
|
||||
m_textBrowser->setFont(newFont);
|
||||
});
|
||||
}
|
||||
|
||||
void TextBrowserHelpViewer::setScale(qreal scale)
|
||||
{
|
||||
setFontAndScale(LocalHelpManager::fallbackFont(), scale);
|
||||
setFontAndScale(LocalHelpManager::fallbackFont(), scale, LocalHelpManager::antialias());
|
||||
}
|
||||
|
||||
void TextBrowserHelpViewer::setAntialias(bool on)
|
||||
{
|
||||
setFontAndScale(LocalHelpManager::fallbackFont(), LocalHelpManager::fontZoom() / 100.0, on);
|
||||
}
|
||||
|
||||
QString TextBrowserHelpViewer::title() const
|
||||
|
||||
@@ -22,8 +22,8 @@ public:
|
||||
~TextBrowserHelpViewer() override;
|
||||
|
||||
void setViewerFont(const QFont &font) override;
|
||||
|
||||
void setScale(qreal scale) override;
|
||||
void setAntialias(bool on) final;
|
||||
|
||||
QString title() const override;
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
void print(QPrinter *printer) override;
|
||||
|
||||
private:
|
||||
void setFontAndScale(const QFont &font, qreal scale);
|
||||
void setFontAndScale(const QFont &font, qreal scale, bool antialias);
|
||||
|
||||
TextBrowserHelpWidget *m_textBrowser;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user