From 50b98b985858492cd54ff927e6531d85685c09e6 Mon Sep 17 00:00:00 2001 From: bieber Date: Mon, 7 Jun 2010 21:59:16 +0000 Subject: [PATCH] Theme Editor: Made status label a permanent widget and made editor highlight line that causes parse error git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26676 a1c6a512-1295-4272-9138-f99709370657 --- utils/themeeditor/editorwindow.cpp | 2 +- utils/themeeditor/preferencesdialog.cpp | 7 +++++++ utils/themeeditor/preferencesdialog.h | 1 + utils/themeeditor/preferencesdialog.ui | 22 ++++++++++++++++++++-- utils/themeeditor/skindocument.cpp | 28 +++++++++++++++++++++++++++- utils/themeeditor/skindocument.h | 2 ++ 6 files changed, 58 insertions(+), 4 deletions(-) diff --git a/utils/themeeditor/editorwindow.cpp b/utils/themeeditor/editorwindow.cpp index 23724ee1a..cc2a0fb35 100644 --- a/utils/themeeditor/editorwindow.cpp +++ b/utils/themeeditor/editorwindow.cpp @@ -96,7 +96,7 @@ void EditorWindow::setupUI() /* Setting up the parse status label */ parseStatus = new QLabel(this); - ui->statusbar->addWidget(parseStatus); + ui->statusbar->addPermanentWidget(parseStatus); } diff --git a/utils/themeeditor/preferencesdialog.cpp b/utils/themeeditor/preferencesdialog.cpp index 79f781c1c..9b28b275f 100644 --- a/utils/themeeditor/preferencesdialog.cpp +++ b/utils/themeeditor/preferencesdialog.cpp @@ -81,6 +81,9 @@ void PreferencesDialog::loadColors() bgColor = settings.value("bgColor", Qt::white).value(); setButtonColor(ui->bgButton, bgColor); + errorColor = settings.value("errorColor", Qt::red).value(); + setButtonColor(ui->errorButton, errorColor); + settings.endGroup(); } @@ -114,6 +117,7 @@ void PreferencesDialog::saveColors() settings.setValue("fgColor", fgColor); settings.setValue("bgColor", bgColor); + settings.setValue("errorColor", errorColor); settings.endGroup(); @@ -149,6 +153,7 @@ void PreferencesDialog::setupUI() buttons.append(ui->tagButton); buttons.append(ui->conditionalButton); buttons.append(ui->escapedButton); + buttons.append(ui->errorButton); for(int i = 0; i < buttons.count(); i++) QObject::connect(buttons[i], SIGNAL(pressed()), @@ -171,6 +176,8 @@ void PreferencesDialog::colorClicked() toEdit = &conditionalColor; else if(QObject::sender() == ui->escapedButton) toEdit = &escapedColor; + else if(QObject::sender() == ui->errorButton) + toEdit = &errorColor; if(!toEdit) return; diff --git a/utils/themeeditor/preferencesdialog.h b/utils/themeeditor/preferencesdialog.h index 7aadbade0..e28a83075 100644 --- a/utils/themeeditor/preferencesdialog.h +++ b/utils/themeeditor/preferencesdialog.h @@ -62,6 +62,7 @@ private: QColor fgColor; QColor bgColor; + QColor errorColor; QColor commentColor; QColor escapedColor; QColor tagColor; diff --git a/utils/themeeditor/preferencesdialog.ui b/utils/themeeditor/preferencesdialog.ui index 5364fb495..af1087572 100644 --- a/utils/themeeditor/preferencesdialog.ui +++ b/utils/themeeditor/preferencesdialog.ui @@ -26,7 +26,7 @@ Editor - + @@ -113,9 +113,27 @@ + + + + + + Error Color + + + + + + + Click To Change + + + + + - + Highlighting diff --git a/utils/themeeditor/skindocument.cpp b/utils/themeeditor/skindocument.cpp index 3ce70ad5b..aa8fc500d 100644 --- a/utils/themeeditor/skindocument.cpp +++ b/utils/themeeditor/skindocument.cpp @@ -27,6 +27,8 @@ #include #include +#include + SkinDocument::SkinDocument(QLabel* statusLabel, QWidget *parent) : QWidget(parent), statusLabel(statusLabel) { @@ -141,9 +143,13 @@ void SkinDocument::settingsChanged() QPalette palette; palette.setColor(QPalette::All, QPalette::Base, bg); palette.setColor(QPalette::All, QPalette::Text, fg); - editor->setPalette(palette); + errorColor = QTextCharFormat(); + QColor highlight = settings.value("errorColor", Qt::red).value(); + errorColor.setBackground(highlight); + errorColor.setProperty(QTextFormat::FullWidthSelection, true); + /* Setting the font */ QFont family = settings.value("fontFamily", QFont()).value(); family.setPointSize(settings.value("fontSize", 12).toInt()); @@ -161,6 +167,26 @@ void SkinDocument::codeChanged() toPlainText().toAscii()); statusLabel->setText(parseStatus); + /* Highlighting if an error was found */ + if(skin_error_line() > 0) + { + QList highlight; + QTextEdit::ExtraSelection error; + + /* Finding the apropriate line */ + error.cursor = QTextCursor(editor->document()-> + findBlockByNumber(skin_error_line() - 1)); + error.format = errorColor; + highlight.append(error); + + editor->setExtraSelections(highlight); + + } + else + { + editor->setExtraSelections(QList()); + } + if(editor->document()->toPlainText() != saved) emit titleChanged(title + QChar('*')); else diff --git a/utils/themeeditor/skindocument.h b/utils/themeeditor/skindocument.h index 4a6516f6d..b5eb60b2f 100644 --- a/utils/themeeditor/skindocument.h +++ b/utils/themeeditor/skindocument.h @@ -78,6 +78,8 @@ private: QString saved; QString parseStatus; + QTextCharFormat errorColor; + QLayout* layout; QPlainTextEdit* editor; -- 2.11.4.GIT