Make font setting selection immediate.

test
cc9cii 10 years ago
parent 7b4a9f1ea1
commit 081f3ed263

@ -33,7 +33,9 @@ CSVWorld::ScriptEdit::ScriptEdit (const CSMDoc::Document& document, ScriptHighli
mWhiteListQoutes("^[a-z|_]{1}[a-z|0-9|_]{0,}$", Qt::CaseInsensitive), mWhiteListQoutes("^[a-z|_]{1}[a-z|0-9|_]{0,}$", Qt::CaseInsensitive),
mChangeLocked (0), mChangeLocked (0),
mLineNumberArea(0), mLineNumberArea(0),
mShowLineNum(false) mShowLineNum(false),
mDefaultFont(font()),
mMonoFont(QFont("Monospace"))
{ {
// setAcceptRichText (false); // setAcceptRichText (false);
setLineWrapMode (QPlainTextEdit::NoWrap); setLineWrapMode (QPlainTextEdit::NoWrap);
@ -79,14 +81,11 @@ CSVWorld::ScriptEdit::ScriptEdit (const CSMDoc::Document& document, ScriptHighli
mUpdateTimer.setSingleShot (true); mUpdateTimer.setSingleShot (true);
// TODO: provide a font selector dialogue // TODO: provide a font selector dialogue
mMonoFont.setStyleHint(QFont::TypeWriter);
std::string useMonoFont = std::string useMonoFont =
CSMSettings::UserSettings::instance().setting("script-editor/mono-font", "true").toStdString(); CSMSettings::UserSettings::instance().setting("script-editor/mono-font", "true").toStdString();
if (useMonoFont == "true") if (useMonoFont == "true")
{ setFont(mMonoFont);
QFont font("Monospace");
font.setStyleHint(QFont::TypeWriter);
setFont(font);
}
mLineNumberArea = new LineNumberArea(this); mLineNumberArea = new LineNumberArea(this);
updateLineNumberAreaWidth(0); updateLineNumberAreaWidth(0);
@ -109,6 +108,14 @@ void CSVWorld::ScriptEdit::showLineNum(bool show)
} }
} }
void CSVWorld::ScriptEdit::setMonoFont(bool show)
{
if(show)
setFont(mMonoFont);
else
setFont(mDefaultFont);
}
bool CSVWorld::ScriptEdit::isChangeLocked() const bool CSVWorld::ScriptEdit::isChangeLocked() const
{ {
return mChangeLocked!=0; return mChangeLocked!=0;

@ -50,6 +50,8 @@ namespace CSVWorld
QTimer mUpdateTimer; QTimer mUpdateTimer;
bool mShowLineNum; bool mShowLineNum;
LineNumberArea *mLineNumberArea; LineNumberArea *mLineNumberArea;
QFont mDefaultFont;
QFont mMonoFont;
public: public:
@ -64,6 +66,7 @@ namespace CSVWorld
void lineNumberAreaPaintEvent(QPaintEvent *event); void lineNumberAreaPaintEvent(QPaintEvent *event);
int lineNumberAreaWidth(); int lineNumberAreaWidth();
void showLineNum(bool show); void showLineNum(bool show);
void setMonoFont(bool show);
protected: protected:

@ -68,14 +68,16 @@ CSVWorld::ScriptSubView::ScriptSubView (const CSMWorld::UniversalId& id, CSMDoc:
void CSVWorld::ScriptSubView::updateUserSetting (const QString& name, const QStringList& value) void CSVWorld::ScriptSubView::updateUserSetting (const QString& name, const QStringList& value)
{ {
if (name != "script-editor/show-linenum") if (name == "script-editor/show-linenum")
return; {
std::string showLinenum = value.at(0).toStdString();
std::string showLinenum = mEditor->showLineNum(showLinenum == "true");
CSMSettings::UserSettings::instance().settingValue("script-editor/show-linenum").toStdString(); mBottom->setVisible(showLinenum == "true");
}
mEditor->showLineNum(showLinenum == "true"); else if (name == "script-editor/mono-font")
mBottom->setVisible(showLinenum == "true"); {
mEditor->setMonoFont(value.at(0).toStdString() == "true");
}
} }
void CSVWorld::ScriptSubView::updateStatusBar () void CSVWorld::ScriptSubView::updateStatusBar ()

Loading…
Cancel
Save