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),
mChangeLocked (0),
mLineNumberArea(0),
mShowLineNum(false)
mShowLineNum(false),
mDefaultFont(font()),
mMonoFont(QFont("Monospace"))
{
// setAcceptRichText (false);
setLineWrapMode (QPlainTextEdit::NoWrap);
@ -79,14 +81,11 @@ CSVWorld::ScriptEdit::ScriptEdit (const CSMDoc::Document& document, ScriptHighli
mUpdateTimer.setSingleShot (true);
// TODO: provide a font selector dialogue
mMonoFont.setStyleHint(QFont::TypeWriter);
std::string useMonoFont =
CSMSettings::UserSettings::instance().setting("script-editor/mono-font", "true").toStdString();
if (useMonoFont == "true")
{
QFont font("Monospace");
font.setStyleHint(QFont::TypeWriter);
setFont(font);
}
setFont(mMonoFont);
mLineNumberArea = new LineNumberArea(this);
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
{
return mChangeLocked!=0;

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

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

Loading…
Cancel
Save