support transparent render background

It is useful for export.
This commit is contained in:
Le Tan 2018-03-02 22:36:11 +08:00
parent 935bb4d3b4
commit 22104ebde3
3 changed files with 16 additions and 1 deletions

View File

@ -370,6 +370,7 @@ void VExportDialog::initUIFields(MarkdownConverterType p_renderer)
// Markdown rendering background.
m_renderBgCB->addItem(tr("System"), "System");
m_renderBgCB->addItem(tr("Transparent"), "Transparent");
const QVector<VColor> &bgColors = g_config->getCustomColors();
for (int i = 0; i < bgColors.size(); ++i) {
m_renderBgCB->addItem(bgColors[i].m_name, bgColors[i].m_name);

View File

@ -1487,7 +1487,9 @@ void VConfigManager::clearGroupOfSettings(QSettings *p_settings, const QString &
QString VConfigManager::getRenderBackgroundColor(const QString &p_bgName) const
{
if (p_bgName != "System") {
if (p_bgName == "Transparent") {
return "transparent";
} else if (p_bgName != "System") {
for (int i = 0; i < m_customColors.size(); ++i) {
if (m_customColors[i].m_name == p_bgName) {
return m_customColors[i].m_color;

View File

@ -1528,6 +1528,17 @@ void VMainWindow::initRenderBackgroundMenu(QMenu *menu)
if (curBgColor == "System") {
tmpAct->setChecked(true);
}
renderBgMenu->addAction(tmpAct);
tmpAct = new QAction(tr("Transparent"), renderBackgroundAct);
tmpAct->setToolTip(tr("Use a transparent background for Markdown rendering"));
tmpAct->setCheckable(true);
tmpAct->setData("Transparent");
if (curBgColor == "Transparent") {
tmpAct->setChecked(true);
}
renderBgMenu->addAction(tmpAct);
const QVector<VColor> &bgColors = g_config->getCustomColors();
@ -1810,6 +1821,7 @@ void VMainWindow::setRenderBackgroundColor(QAction *action)
if (!action) {
return;
}
g_config->setCurRenderBackgroundColor(action->data().toString());
vnote->updateTemplate();
}