forked from len0rd/rockbox
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
This commit is contained in:
parent
fe0334394f
commit
42b065f04a
6 changed files with 58 additions and 4 deletions
|
@ -96,7 +96,7 @@ void EditorWindow::setupUI()
|
||||||
|
|
||||||
/* Setting up the parse status label */
|
/* Setting up the parse status label */
|
||||||
parseStatus = new QLabel(this);
|
parseStatus = new QLabel(this);
|
||||||
ui->statusbar->addWidget(parseStatus);
|
ui->statusbar->addPermanentWidget(parseStatus);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,9 @@ void PreferencesDialog::loadColors()
|
||||||
bgColor = settings.value("bgColor", Qt::white).value<QColor>();
|
bgColor = settings.value("bgColor", Qt::white).value<QColor>();
|
||||||
setButtonColor(ui->bgButton, bgColor);
|
setButtonColor(ui->bgButton, bgColor);
|
||||||
|
|
||||||
|
errorColor = settings.value("errorColor", Qt::red).value<QColor>();
|
||||||
|
setButtonColor(ui->errorButton, errorColor);
|
||||||
|
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,6 +117,7 @@ void PreferencesDialog::saveColors()
|
||||||
|
|
||||||
settings.setValue("fgColor", fgColor);
|
settings.setValue("fgColor", fgColor);
|
||||||
settings.setValue("bgColor", bgColor);
|
settings.setValue("bgColor", bgColor);
|
||||||
|
settings.setValue("errorColor", errorColor);
|
||||||
|
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
|
@ -149,6 +153,7 @@ void PreferencesDialog::setupUI()
|
||||||
buttons.append(ui->tagButton);
|
buttons.append(ui->tagButton);
|
||||||
buttons.append(ui->conditionalButton);
|
buttons.append(ui->conditionalButton);
|
||||||
buttons.append(ui->escapedButton);
|
buttons.append(ui->escapedButton);
|
||||||
|
buttons.append(ui->errorButton);
|
||||||
|
|
||||||
for(int i = 0; i < buttons.count(); i++)
|
for(int i = 0; i < buttons.count(); i++)
|
||||||
QObject::connect(buttons[i], SIGNAL(pressed()),
|
QObject::connect(buttons[i], SIGNAL(pressed()),
|
||||||
|
@ -171,6 +176,8 @@ void PreferencesDialog::colorClicked()
|
||||||
toEdit = &conditionalColor;
|
toEdit = &conditionalColor;
|
||||||
else if(QObject::sender() == ui->escapedButton)
|
else if(QObject::sender() == ui->escapedButton)
|
||||||
toEdit = &escapedColor;
|
toEdit = &escapedColor;
|
||||||
|
else if(QObject::sender() == ui->errorButton)
|
||||||
|
toEdit = &errorColor;
|
||||||
|
|
||||||
if(!toEdit)
|
if(!toEdit)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -62,6 +62,7 @@ private:
|
||||||
|
|
||||||
QColor fgColor;
|
QColor fgColor;
|
||||||
QColor bgColor;
|
QColor bgColor;
|
||||||
|
QColor errorColor;
|
||||||
QColor commentColor;
|
QColor commentColor;
|
||||||
QColor escapedColor;
|
QColor escapedColor;
|
||||||
QColor tagColor;
|
QColor tagColor;
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Editor</string>
|
<string>Editor</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||||
<item>
|
<item>
|
||||||
|
@ -113,9 +113,27 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_9">
|
||||||
|
<property name="text">
|
||||||
|
<string>Error Color</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="errorButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Click To Change</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="prefsGroupsPage1" native="true">
|
<widget class="QWidget" name="prefsGroupsPage1">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Highlighting</string>
|
<string>Highlighting</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
SkinDocument::SkinDocument(QLabel* statusLabel, QWidget *parent) :
|
SkinDocument::SkinDocument(QLabel* statusLabel, QWidget *parent) :
|
||||||
QWidget(parent), statusLabel(statusLabel)
|
QWidget(parent), statusLabel(statusLabel)
|
||||||
{
|
{
|
||||||
|
@ -141,9 +143,13 @@ void SkinDocument::settingsChanged()
|
||||||
QPalette palette;
|
QPalette palette;
|
||||||
palette.setColor(QPalette::All, QPalette::Base, bg);
|
palette.setColor(QPalette::All, QPalette::Base, bg);
|
||||||
palette.setColor(QPalette::All, QPalette::Text, fg);
|
palette.setColor(QPalette::All, QPalette::Text, fg);
|
||||||
|
|
||||||
editor->setPalette(palette);
|
editor->setPalette(palette);
|
||||||
|
|
||||||
|
errorColor = QTextCharFormat();
|
||||||
|
QColor highlight = settings.value("errorColor", Qt::red).value<QColor>();
|
||||||
|
errorColor.setBackground(highlight);
|
||||||
|
errorColor.setProperty(QTextFormat::FullWidthSelection, true);
|
||||||
|
|
||||||
/* Setting the font */
|
/* Setting the font */
|
||||||
QFont family = settings.value("fontFamily", QFont()).value<QFont>();
|
QFont family = settings.value("fontFamily", QFont()).value<QFont>();
|
||||||
family.setPointSize(settings.value("fontSize", 12).toInt());
|
family.setPointSize(settings.value("fontSize", 12).toInt());
|
||||||
|
@ -161,6 +167,26 @@ void SkinDocument::codeChanged()
|
||||||
toPlainText().toAscii());
|
toPlainText().toAscii());
|
||||||
statusLabel->setText(parseStatus);
|
statusLabel->setText(parseStatus);
|
||||||
|
|
||||||
|
/* Highlighting if an error was found */
|
||||||
|
if(skin_error_line() > 0)
|
||||||
|
{
|
||||||
|
QList<QTextEdit::ExtraSelection> 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<QTextEdit::ExtraSelection>());
|
||||||
|
}
|
||||||
|
|
||||||
if(editor->document()->toPlainText() != saved)
|
if(editor->document()->toPlainText() != saved)
|
||||||
emit titleChanged(title + QChar('*'));
|
emit titleChanged(title + QChar('*'));
|
||||||
else
|
else
|
||||||
|
|
|
@ -78,6 +78,8 @@ private:
|
||||||
QString saved;
|
QString saved;
|
||||||
QString parseStatus;
|
QString parseStatus;
|
||||||
|
|
||||||
|
QTextCharFormat errorColor;
|
||||||
|
|
||||||
QLayout* layout;
|
QLayout* layout;
|
||||||
QPlainTextEdit* editor;
|
QPlainTextEdit* editor;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue