mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
Make font setting selection immediate.
This commit is contained in:
parent
7b4a9f1ea1
commit
081f3ed263
3 changed files with 26 additions and 14 deletions
|
@ -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();
|
||||
|
||||
mEditor->showLineNum(showLinenum == "true");
|
||||
mBottom->setVisible(showLinenum == "true");
|
||||
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…
Reference in a new issue