mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 07:53:53 +00:00
Merge remote-tracking branch 'rcutmore/bug-3286'
This commit is contained in:
commit
9d906a99a8
3 changed files with 21 additions and 10 deletions
|
@ -136,6 +136,9 @@ void CSMPrefs::State::declare()
|
||||||
declareBool ("wrap-lines", "Wrap Lines", false).
|
declareBool ("wrap-lines", "Wrap Lines", false).
|
||||||
setTooltip ("Wrap lines longer than width of script editor.");
|
setTooltip ("Wrap lines longer than width of script editor.");
|
||||||
declareBool ("mono-font", "Use monospace font", true);
|
declareBool ("mono-font", "Use monospace font", true);
|
||||||
|
declareInt ("tab-width", "Tab Width", 4).
|
||||||
|
setTooltip ("Number of characters for tab width").
|
||||||
|
setRange (1, 10);
|
||||||
EnumValue warningsNormal ("Normal", "Report warnings as warning");
|
EnumValue warningsNormal ("Normal", "Report warnings as warning");
|
||||||
declareEnum ("warnings", "Warning Mode", warningsNormal).
|
declareEnum ("warnings", "Warning Mode", warningsNormal).
|
||||||
addValue ("Ignore", "Do not report warning").
|
addValue ("Ignore", "Do not report warning").
|
||||||
|
|
|
@ -48,11 +48,12 @@ CSVWorld::ScriptEdit::ScriptEdit(
|
||||||
mLineNumberArea(0),
|
mLineNumberArea(0),
|
||||||
mDefaultFont(font()),
|
mDefaultFont(font()),
|
||||||
mMonoFont(QFont("Monospace")),
|
mMonoFont(QFont("Monospace")),
|
||||||
|
mTabCharCount(4),
|
||||||
mDocument(document),
|
mDocument(document),
|
||||||
mWhiteListQoutes("^[a-z|_]{1}[a-z|0-9|_]{0,}$", Qt::CaseInsensitive)
|
mWhiteListQoutes("^[a-z|_]{1}[a-z|0-9|_]{0,}$", Qt::CaseInsensitive)
|
||||||
{
|
{
|
||||||
wrapLines(false);
|
wrapLines(false);
|
||||||
setTabStopWidth (4);
|
setTabWidth();
|
||||||
setUndoRedoEnabled (false); // we use OpenCS-wide undo/redo instead
|
setUndoRedoEnabled (false); // we use OpenCS-wide undo/redo instead
|
||||||
|
|
||||||
mAllowedTypes <<CSMWorld::UniversalId::Type_Journal
|
mAllowedTypes <<CSMWorld::UniversalId::Type_Journal
|
||||||
|
@ -120,14 +121,6 @@ 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;
|
||||||
|
@ -194,6 +187,12 @@ bool CSVWorld::ScriptEdit::stringNeedsQuote (const std::string& id) const
|
||||||
return !(string.contains(mWhiteListQoutes));
|
return !(string.contains(mWhiteListQoutes));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVWorld::ScriptEdit::setTabWidth()
|
||||||
|
{
|
||||||
|
// Set tab width to specified number of characters using current font.
|
||||||
|
setTabStopWidth(mTabCharCount * fontMetrics().width(' '));
|
||||||
|
}
|
||||||
|
|
||||||
void CSVWorld::ScriptEdit::wrapLines(bool wrap)
|
void CSVWorld::ScriptEdit::wrapLines(bool wrap)
|
||||||
{
|
{
|
||||||
if (wrap)
|
if (wrap)
|
||||||
|
@ -216,6 +215,7 @@ void CSVWorld::ScriptEdit::settingChanged(const CSMPrefs::Setting *setting)
|
||||||
else if (*setting == "Scripts/mono-font")
|
else if (*setting == "Scripts/mono-font")
|
||||||
{
|
{
|
||||||
setFont(setting->isTrue() ? mMonoFont : mDefaultFont);
|
setFont(setting->isTrue() ? mMonoFont : mDefaultFont);
|
||||||
|
setTabWidth();
|
||||||
}
|
}
|
||||||
else if (*setting == "Scripts/show-linenum")
|
else if (*setting == "Scripts/show-linenum")
|
||||||
{
|
{
|
||||||
|
@ -225,6 +225,11 @@ void CSVWorld::ScriptEdit::settingChanged(const CSMPrefs::Setting *setting)
|
||||||
{
|
{
|
||||||
wrapLines(setting->isTrue());
|
wrapLines(setting->isTrue());
|
||||||
}
|
}
|
||||||
|
else if (*setting == "Scripts/tab-width")
|
||||||
|
{
|
||||||
|
mTabCharCount = setting->toInt();
|
||||||
|
setTabWidth();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::ScriptEdit::idListChanged()
|
void CSVWorld::ScriptEdit::idListChanged()
|
||||||
|
|
|
@ -53,6 +53,7 @@ namespace CSVWorld
|
||||||
LineNumberArea *mLineNumberArea;
|
LineNumberArea *mLineNumberArea;
|
||||||
QFont mDefaultFont;
|
QFont mDefaultFont;
|
||||||
QFont mMonoFont;
|
QFont mMonoFont;
|
||||||
|
int mTabCharCount;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -71,7 +72,6 @@ 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:
|
||||||
|
|
||||||
|
@ -91,6 +91,9 @@ namespace CSVWorld
|
||||||
|
|
||||||
bool stringNeedsQuote(const std::string& id) const;
|
bool stringNeedsQuote(const std::string& id) const;
|
||||||
|
|
||||||
|
/// \brief Set tab width for script editor.
|
||||||
|
void setTabWidth();
|
||||||
|
|
||||||
/// \brief Turn line wrapping in script editor on or off.
|
/// \brief Turn line wrapping in script editor on or off.
|
||||||
/// \param wrap Whether or not to wrap lines.
|
/// \param wrap Whether or not to wrap lines.
|
||||||
void wrapLines(bool wrap);
|
void wrapLines(bool wrap);
|
||||||
|
|
Loading…
Reference in a new issue