1
0
Fork 0
forked from len0rd/rockbox

Theme Editor: Fixed status bar update bug

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26798 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Robert Bieber 2010-06-11 20:51:49 +00:00
parent 82ff776fbb
commit fa08c83e29
2 changed files with 30 additions and 6 deletions

View file

@ -37,13 +37,15 @@ SkinDocument::SkinDocument(QLabel* statusLabel, QWidget *parent) :
title = "Untitled"; title = "Untitled";
fileName = ""; fileName = "";
saved = ""; saved = "";
parseStatus = tr("Empty Document"); parseStatus = tr("Empty document");
blockUpdate = false;
} }
SkinDocument::SkinDocument(QLabel* statusLabel, QString file, QWidget *parent): SkinDocument::SkinDocument(QLabel* statusLabel, QString file, QWidget *parent):
QWidget(parent), fileName(file), statusLabel(statusLabel) QWidget(parent), fileName(file), statusLabel(statusLabel)
{ {
setupUI(); setupUI();
blockUpdate = false;
/* Loading the file */ /* Loading the file */
if(QFile::exists(fileName)) if(QFile::exists(fileName))
@ -77,6 +79,8 @@ void SkinDocument::connectPrefs(PreferencesDialog* prefs)
bool SkinDocument::requestClose() bool SkinDocument::requestClose()
{ {
/* Storing the response in blockUpdate will also block updates to the
status bar if the tab is being closed */
if(editor->document()->toPlainText() != saved) if(editor->document()->toPlainText() != saved)
{ {
/* Spawning the "Are you sure?" dialog */ /* Spawning the "Are you sure?" dialog */
@ -95,19 +99,24 @@ bool SkinDocument::requestClose()
save(); save();
/* After calling save, make sure the user actually went through */ /* After calling save, make sure the user actually went through */
if(editor->document()->toPlainText() != saved) if(editor->document()->toPlainText() != saved)
return false; blockUpdate = false;
else else
return true; blockUpdate = true;
break;
case QMessageBox::Discard: case QMessageBox::Discard:
return true; blockUpdate = true;
break;
case QMessageBox::Cancel: case QMessageBox::Cancel:
return false; blockUpdate = false;
break;
} }
} }
else
blockUpdate = true;
return true; return blockUpdate;
} }
void SkinDocument::setupUI() void SkinDocument::setupUI()
@ -164,11 +173,24 @@ void SkinDocument::settingsChanged()
void SkinDocument::codeChanged() void SkinDocument::codeChanged()
{ {
if(blockUpdate)
return;
if(editor->document()->isEmpty())
{
parseStatus = tr("Empty document");
statusLabel->setText(parseStatus);
return;
}
editor->clearErrors(); editor->clearErrors();
parseStatus = model->changeTree(editor->document()-> parseStatus = model->changeTree(editor->document()->
toPlainText().toAscii()); toPlainText().toAscii());
if(skin_error_line() > 0)
parseStatus = tr("Errors in document");
statusLabel->setText(parseStatus); statusLabel->setText(parseStatus);
/* Highlighting if an error was found */ /* Highlighting if an error was found */
if(skin_error_line() > 0) if(skin_error_line() > 0)
{ {

View file

@ -86,6 +86,8 @@ private:
ParseTreeModel* model; ParseTreeModel* model;
QLabel* statusLabel; QLabel* statusLabel;
bool blockUpdate;
}; };
#endif // SKINDOCUMENT_H #endif // SKINDOCUMENT_H