1
0
Fork 0
forked from len0rd/rockbox

Theme Editor: Made errors display in status bar when cursor is on error'd line

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26801 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Robert Bieber 2010-06-11 21:24:38 +00:00
parent 6c921f5e04
commit ce0d21437e
3 changed files with 30 additions and 1 deletions

View file

@ -62,6 +62,8 @@ public:
void addError(int line){ errors.append(line); }
void clearErrors(){ errors.clear(); }
void setErrorColor(QColor color){ errorColor = color; }
bool isError(int line){ return errors.contains(line); }
bool hasErrors(){ return !errors.isEmpty(); }
protected:
void resizeEvent(QResizeEvent *event);

View file

@ -138,6 +138,8 @@ void SkinDocument::setupUI()
/* Connecting the editor's signal */
QObject::connect(editor, SIGNAL(textChanged()),
this, SLOT(codeChanged()));
QObject::connect(editor, SIGNAL(cursorPositionChanged()),
this, SLOT(cursorChanged()));
settingsChanged();
}
@ -171,6 +173,28 @@ void SkinDocument::settingsChanged()
}
void SkinDocument::cursorChanged()
{
if(editor->isError(editor->textCursor().blockNumber() + 1))
{
QTextCursor line = editor->textCursor();
line.movePosition(QTextCursor::StartOfLine);
line.movePosition(QTextCursor::EndOfLine, QTextCursor::KeepAnchor);
skin_parse(line.selectedText().toAscii());
if(skin_error_line() > 0)
parseStatus = tr("Error on line ") +
QString::number(line.blockNumber() + 1) + tr(": ") +
skin_error_message();
statusLabel->setText(parseStatus);
}
else if(editor->hasErrors())
{
parseStatus = tr("Errors in document");
statusLabel->setText(parseStatus);
}
}
void SkinDocument::codeChanged()
{
if(blockUpdate)
@ -190,7 +214,6 @@ void SkinDocument::codeChanged()
parseStatus = tr("Errors in document");
statusLabel->setText(parseStatus);
/* Highlighting if an error was found */
if(skin_error_line() > 0)
{
@ -225,6 +248,9 @@ void SkinDocument::codeChanged()
emit titleChanged(title + QChar('*'));
else
emit titleChanged(title);
cursorChanged();
}
void SkinDocument::save()

View file

@ -67,6 +67,7 @@ signals:
public slots:
void settingsChanged();
void cursorChanged();
private slots:
void codeChanged();