From da0ff323860f23aba377a968ea21d9239fc2163b Mon Sep 17 00:00:00 2001 From: Nikita Sirgienko Date: Sun, 13 Oct 2019 15:35:05 +0300 Subject: [PATCH] Fix bug with unchangeable (from defaults settings) worksheet parameters (completion, embedded math, etc) --- src/markdownentry.cpp | 2 +- src/test/worksheet_test.cpp | 3 +-- src/worksheet.cpp | 17 +++++++++++------ src/worksheet.h | 13 ++++++++----- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/markdownentry.cpp b/src/markdownentry.cpp index 19cd018f..582db8e4 100644 --- a/src/markdownentry.cpp +++ b/src/markdownentry.cpp @@ -185,7 +185,7 @@ void MarkdownEntry::setContent(const QDomElement& content, const KZip& file) setRenderedMath(i+1, data.first, internal, data.second); } } - else + else if (worksheet()->embeddedMathEnabled()) renderMathExpression(i+1, mathCode); } } diff --git a/src/test/worksheet_test.cpp b/src/test/worksheet_test.cpp index b5c7ec3e..446572ac 100644 --- a/src/test/worksheet_test.cpp +++ b/src/test/worksheet_test.cpp @@ -58,9 +58,8 @@ void WorksheetTest::initTestCase() Worksheet* WorksheetTest::loadWorksheet(const QString& name) { - Worksheet* w = new Worksheet(Cantor::Backend::getBackend(QLatin1String("maxima")), nullptr); + Worksheet* w = new Worksheet(Cantor::Backend::getBackend(QLatin1String("maxima")), nullptr, false); WorksheetView v(w, nullptr); - w->enableEmbeddedMath(false); w->load(dataPath + name); return w; } diff --git a/src/worksheet.cpp b/src/worksheet.cpp index 95d5c5c7..ebe361fc 100644 --- a/src/worksheet.cpp +++ b/src/worksheet.cpp @@ -63,7 +63,7 @@ const double Worksheet::TopMargin = 12; const double Worksheet::EntryCursorLength = 30; const double Worksheet::EntryCursorWidth = 2; -Worksheet::Worksheet(Cantor::Backend* backend, QWidget* parent) +Worksheet::Worksheet(Cantor::Backend* backend, QWidget* parent, bool useDeafultWorksheetParameters) : QGraphicsScene(parent) { m_session = nullptr; @@ -80,6 +80,8 @@ Worksheet::Worksheet(Cantor::Backend* backend, QWidget* parent) m_choosenCursorEntry = nullptr; m_isCursorEntryAfterLastEntry = false; + m_useDefaultWorksheetParameters = useDeafultWorksheetParameters; + m_viewWidth = 0; m_maxWidth = 0; @@ -1280,11 +1282,14 @@ bool Worksheet::loadCantorWorksheet(const KZip& archive) void Worksheet::initSession(Cantor::Backend* backend) { m_session = backend->createSession(); - enableHighlighting(Settings::self()->highlightDefault()); - enableCompletion(Settings::self()->completionDefault()); - enableExpressionNumbering(Settings::self()->expressionNumberingDefault()); - enableAnimations(Settings::self()->animationDefault()); - enableEmbeddedMath(Settings::self()->embeddedMathDefault()); + if (m_useDefaultWorksheetParameters) + { + enableHighlighting(Settings::self()->highlightDefault()); + enableCompletion(Settings::self()->completionDefault()); + enableExpressionNumbering(Settings::self()->expressionNumberingDefault()); + enableAnimations(Settings::self()->animationDefault()); + enableEmbeddedMath(Settings::self()->embeddedMathDefault()); + } } bool Worksheet::loadJupyterNotebook(const QJsonDocument& doc) diff --git a/src/worksheet.h b/src/worksheet.h index a20acb95..444db3ef 100644 --- a/src/worksheet.h +++ b/src/worksheet.h @@ -63,7 +63,7 @@ class Worksheet : public QGraphicsScene JupyterNotebook }; - Worksheet(Cantor::Backend* backend, QWidget* parent); + Worksheet(Cantor::Backend* backend, QWidget* parent, bool useDeafultWorksheetParameters = true); ~Worksheet() override; Cantor::Session* session(); @@ -318,10 +318,13 @@ class Worksheet : public QGraphicsScene KToggleAction* m_alignRightAction; KToggleAction* m_alignJustifyAction; - bool m_completionEnabled; - bool m_embeddedMathEnabled; - bool m_showExpressionIds; - bool m_animationsEnabled; + bool m_useDefaultWorksheetParameters{true}; + + bool m_completionEnabled{false}; + bool m_embeddedMathEnabled{false}; + bool m_showExpressionIds{false}; + bool m_animationsEnabled{false}; + bool m_isPrinting; bool m_isLoadingFromFile; bool m_readOnly; -- GitLab