From 30493545f172334fb9b11396edaf0a69bd31a44e Mon Sep 17 00:00:00 2001 From: Rob Cutmore Date: Sun, 17 Apr 2016 06:54:31 -0400 Subject: [PATCH] Update script editor tab width on font change --- apps/opencs/view/world/scriptedit.cpp | 13 ++++++++----- apps/opencs/view/world/scriptedit.hpp | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/apps/opencs/view/world/scriptedit.cpp b/apps/opencs/view/world/scriptedit.cpp index 39497ac1e..6dc0c2f0c 100644 --- a/apps/opencs/view/world/scriptedit.cpp +++ b/apps/opencs/view/world/scriptedit.cpp @@ -48,11 +48,12 @@ CSVWorld::ScriptEdit::ScriptEdit( mLineNumberArea(0), mDefaultFont(font()), mMonoFont(QFont("Monospace")), + mTabCharCount(4), mDocument(document), mWhiteListQoutes("^[a-z|_]{1}[a-z|0-9|_]{0,}$", Qt::CaseInsensitive) { wrapLines(false); - setTabWidth(4); + setTabWidth(); setUndoRedoEnabled (false); // we use OpenCS-wide undo/redo instead mAllowedTypes <isTrue() ? mMonoFont : mDefaultFont); + setTabWidth(); } else if (*setting == "Scripts/show-linenum") { @@ -233,7 +235,8 @@ void CSVWorld::ScriptEdit::settingChanged(const CSMPrefs::Setting *setting) } else if (*setting == "Scripts/tab-width") { - setTabWidth(setting->toInt()); + mTabCharCount = setting->toInt(); + setTabWidth(); } } diff --git a/apps/opencs/view/world/scriptedit.hpp b/apps/opencs/view/world/scriptedit.hpp index db2936a74..9d2062075 100644 --- a/apps/opencs/view/world/scriptedit.hpp +++ b/apps/opencs/view/world/scriptedit.hpp @@ -53,6 +53,7 @@ namespace CSVWorld LineNumberArea *mLineNumberArea; QFont mDefaultFont; QFont mMonoFont; + int mTabCharCount; protected: @@ -92,8 +93,7 @@ namespace CSVWorld bool stringNeedsQuote(const std::string& id) const; /// \brief Set tab width for script editor. - /// \param numCharacters Number of characters for tab width. - void setTabWidth(const int numCharacters); + void setTabWidth(); /// \brief Turn line wrapping in script editor on or off. /// \param wrap Whether or not to wrap lines.