diff --git a/src/dialog/vcopytextashtmldialog.cpp b/src/dialog/vcopytextashtmldialog.cpp
index 46ab0026..a4fd62bc 100644
--- a/src/dialog/vcopytextashtmldialog.cpp
+++ b/src/dialog/vcopytextashtmldialog.cpp
@@ -31,7 +31,7 @@ void VCopyTextAsHtmlDialog::setupUI()
m_textEdit->setProperty("LineEdit", true);
m_htmlLabel = new QLabel(tr("HTML:"));
- m_htmlViewer = VUtils::getWebEngineView();
+ m_htmlViewer = VUtils::getWebEngineView(g_config->getBaseBackground());
m_htmlViewer->setContextMenuPolicy(Qt::NoContextMenu);
m_htmlViewer->setMinimumSize(600, 400);
diff --git a/src/dialog/vtipsdialog.cpp b/src/dialog/vtipsdialog.cpp
index 9e19bbd2..9e093664 100644
--- a/src/dialog/vtipsdialog.cpp
+++ b/src/dialog/vtipsdialog.cpp
@@ -23,7 +23,7 @@ VTipsDialog::VTipsDialog(const QString &p_tipFile,
void VTipsDialog::setupUI(const QString &p_actionText)
{
- m_viewer = VUtils::getWebEngineView();
+ m_viewer = VUtils::getWebEngineView(g_config->getBaseBackground());
m_viewer->setContextMenuPolicy(Qt::NoContextMenu);
m_btnBox = new QDialogButtonBox(QDialogButtonBox::Ok);
diff --git a/src/dialog/vupdater.cpp b/src/dialog/vupdater.cpp
index 5460c206..90e6f1cb 100644
--- a/src/dialog/vupdater.cpp
+++ b/src/dialog/vupdater.cpp
@@ -35,7 +35,7 @@ void VUpdater::setupUI()
m_proBar = new QProgressBar();
m_proBar->setTextVisible(false);
- m_descriptionWV = VUtils::getWebEngineView();
+ m_descriptionWV = VUtils::getWebEngineView(g_config->getBaseBackground());
m_descriptionWV->setContextMenuPolicy(Qt::NoContextMenu);
m_descriptionWV->setHtml(VUtils::generateSimpleHtmlTemplate(VNote::s_sloganTemplate),
QUrl("qrc:/resources"));
diff --git a/src/main.cpp b/src/main.cpp
index 51408629..69eeebf8 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -234,6 +234,8 @@ int main(int argc, char *argv[])
w.show();
+ g_config->setBaseBackground(w.palette().color(QPalette::Window));
+
w.kickOffStartUpTimer(filePaths);
int ret = app.exec();
diff --git a/src/utils/vutils.cpp b/src/utils/vutils.cpp
index 7a190be4..43043988 100644
--- a/src/utils/vutils.cpp
+++ b/src/utils/vutils.cpp
@@ -1417,11 +1417,16 @@ void VUtils::setDynamicProperty(QWidget *p_widget, const char *p_prop, bool p_va
p_widget->style()->polish(p_widget);
}
-QWebEngineView *VUtils::getWebEngineView(QWidget *p_parent)
+QWebEngineView *VUtils::getWebEngineView(const QColor &p_background, QWidget *p_parent)
{
QWebEngineView *viewer = new QWebEngineView(p_parent);
VPreviewPage *page = new VPreviewPage(viewer);
- page->setBackgroundColor(Qt::transparent);
+
+ // Setting the background to Qt::transparent will force GrayScale antialiasing.
+ if (p_background.isValid() && p_background != Qt::transparent) {
+ page->setBackgroundColor(p_background);
+ }
+
viewer->setPage(page);
viewer->setZoomFactor(g_config->getWebZoomFactor());
diff --git a/src/utils/vutils.h b/src/utils/vutils.h
index 4c097b37..6b459dd6 100644
--- a/src/utils/vutils.h
+++ b/src/utils/vutils.h
@@ -314,7 +314,7 @@ public:
// Create and return a QComboBox.
static QComboBox *getComboBox(QWidget *p_parent = nullptr);
- static QWebEngineView *getWebEngineView(QWidget *p_parent = nullptr);
+ static QWebEngineView *getWebEngineView(const QColor &p_background, QWidget *p_parent = nullptr);
static void setDynamicProperty(QWidget *p_widget, const char *p_prop, bool p_val = true);
diff --git a/src/vconfigmanager.h b/src/vconfigmanager.h
index 627489a3..158b8173 100644
--- a/src/vconfigmanager.h
+++ b/src/vconfigmanager.h
@@ -584,6 +584,9 @@ public:
bool versionChanged() const;
+ const QColor &getBaseBackground() const;
+ void setBaseBackground(const QColor &p_bg);
+
private:
// Look up a config from user and default settings.
QVariant getConfigFromSettings(const QString §ion, const QString &key) const;
@@ -1044,6 +1047,9 @@ private:
// Whether the VNote instance has different version of vnote.ini.
bool m_versionChanged;
+ // Base background of MainWindow.
+ QColor m_baseBackground;
+
// The name of the config file in each directory.
static const QString c_dirConfigFile;
@@ -2714,4 +2720,14 @@ inline bool VConfigManager::versionChanged() const
{
return m_versionChanged;
}
+
+inline const QColor &VConfigManager::getBaseBackground() const
+{
+ return m_baseBackground;
+}
+
+inline void VConfigManager::setBaseBackground(const QColor &p_bg)
+{
+ m_baseBackground = p_bg;
+}
#endif // VCONFIGMANAGER_H
diff --git a/src/vmdtab.cpp b/src/vmdtab.cpp
index fe053de3..c7e7f657 100644
--- a/src/vmdtab.cpp
+++ b/src/vmdtab.cpp
@@ -450,7 +450,8 @@ void VMdTab::setupMarkdownViewer()
this, &VMdTab::statusMessage);
// Avoid white flash before loading content.
- page->setBackgroundColor(Qt::transparent);
+ // Setting Qt::transparent will force GrayScale antialias rendering.
+ page->setBackgroundColor(g_config->getBaseBackground());
m_document = new VDocument(m_file, m_webViewer);
m_documentID = m_document->registerIdentifier();