Commit 53a1a697 authored by Filipe Saraiva's avatar Filipe Saraiva

Make Cantor’s LaTeX renderer friendlier with dark themes

When the user selects a dark theme,  the background of the windows (including Cantor’s ones) is dark whereas the text printed in them is white.
It works pretty well in Cantor, expect when the LaTeX renderer is enabled in which case the formulas rendered by LaTeX are still in black on white background. This creates unsightly frames as it can be seen of the following screenshot:

This patch makes Cantor pass the currently active background and foreground colors to LaTeX so that LaTeX rendered outputs are looking much more integrated. Please see the following screenshot showing the effect of this patch:

Reviewers: #cantor, asemke, filipesaraiva

Reviewed By: #cantor, asemke, filipesaraiva

Subscribers: filipesaraiva, asemke, #cantor

Tags: #cantor

Differential Revision:
parent 42478595
......@@ -26,6 +26,7 @@ using namespace Cantor;
#include <QFileInfo>
#include <QEventLoop>
#include <QTemporaryFile>
#include <KColorScheme>
#include <config-cantorlib.h>
#include "settings.h"
......@@ -47,12 +48,15 @@ static const QLatin1String tex("\\documentclass[12pt,fleqn]{article} \n
"\\usepackage{latexsym,amsfonts,amssymb,ulem} \n "\
"\\usepackage[dvips]{graphicx} \n "\
"\\usepackage[utf8]{inputenc} \n "\
"\\usepackage{xcolor} \n "\
"\\setlength\\textwidth{5in} \n "\
"\\setlength{\\parindent}{0pt} \n "\
"%1 \n "\
"\\pagecolor[rgb]{%2,%3,%4} \n "\
"\\pagestyle{empty} \n "\
"\\begin{document} \n "\
"%2 \n "\
"\\color[rgb]{%5,%6,%7} \n "\
"%8 \n "\
static const QLatin1String eqnHeader("\\begin{eqnarray*}%1\\end{eqnarray*} \n ");
......@@ -177,8 +181,13 @@ void LatexRenderer::renderWithLatex()
QTemporaryFile *texFile=new QTemporaryFile(dir + QLatin1String("/cantor_tex-XXXXXX.tex"));
KColorScheme scheme(QPalette::Active);
const QColor &backgroundColor=scheme.background().color();
const QColor &foregroundColor=scheme.foreground().color();
QString expressionTex=tex;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment