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