summaryrefslogtreecommitdiffstats
path: root/src/declarative/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/util')
-rw-r--r--src/declarative/util/qfxview.cpp64
-rw-r--r--src/declarative/util/qfxview.h2
-rw-r--r--src/declarative/util/qmlpalette.cpp10
-rw-r--r--src/declarative/util/qmlpalette.h3
4 files changed, 31 insertions, 48 deletions
diff --git a/src/declarative/util/qfxview.cpp b/src/declarative/util/qfxview.cpp
index 41f7db2..821dc25 100644
--- a/src/declarative/util/qfxview.cpp
+++ b/src/declarative/util/qfxview.cpp
@@ -246,44 +246,6 @@ void QFxView::execute()
}
}
-/*!
- \internal
-*/
-void QFxView::printErrorLine(const QmlError &error)
-{
- QUrl url = error.url();
- if (error.line() > 0 && error.column() > 0 &&
- url.scheme() == QLatin1String("file")) {
- QString file = url.toLocalFile();
- QFile f(file);
- if (f.open(QIODevice::ReadOnly)) {
- QByteArray data = f.readAll();
- QTextStream stream(data, QIODevice::ReadOnly);
- const QString code = stream.readAll();
- const QStringList lines = code.split(QLatin1Char('\n'));
-
- if (lines.count() >= error.line()) {
- const QString &line = lines.at(error.line() - 1);
- qWarning() << qPrintable(line);
-
- int column = qMax(0, error.column() - 1);
- column = qMin(column, line.length());
-
- QByteArray ind;
- ind.reserve(column);
- for (int i = 0; i < column; ++i) {
- const QChar ch = line.at(i);
- if (ch.isSpace())
- ind.append(ch.unicode());
- else
- ind.append(' ');
- }
- ind.append('^');
- qWarning() << ind.constData();
- }
- }
- }
-}
/*!
\internal
@@ -292,14 +254,15 @@ void QFxView::continueExecute()
{
disconnect(d->component, SIGNAL(statusChanged(QmlComponent::Status)), this, SLOT(continueExecute()));
- if (!d->component){
+ if (!d->component) {
qWarning() << "Error in loading" << d->source;
return;
}
if(d->component->isError()) {
- QList<QmlError> errors = d->component->errors();
- foreach (const QmlError &error, errors) {
+ QList<QmlError> errorList = d->component->errors();
+ emit errors(errorList);
+ foreach (const QmlError &error, errorList) {
qWarning() << error;
}
@@ -309,8 +272,9 @@ void QFxView::continueExecute()
QObject *obj = d->component->create();
if(d->component->isError()) {
- QList<QmlError> errors = d->component->errors();
- foreach (const QmlError &error, errors) {
+ QList<QmlError> errorList = d->component->errors();
+ emit errors(errorList);
+ foreach (const QmlError &error, errorList) {
qWarning() << error;
}
@@ -362,6 +326,10 @@ void QFxView::continueExecute()
This signal is emitted when the view is resized to \a size.
*/
+/*! \fn void QFxView::error(const QList<QmlError> &errors)
+ This signal is emitted when the qml loaded contains errors.
+ */
+
/*!
\internal
*/
@@ -453,8 +421,9 @@ QFxItem* QFxView::addItem(const QString &qml, QFxItem* parent)
QmlComponent component(&d->engine, qml.toUtf8(), QUrl());
if(d->component->isError()) {
- QList<QmlError> errors = d->component->errors();
- foreach (const QmlError &error, errors) {
+ QList<QmlError> errorList = d->component->errors();
+ emit errors(errorList);
+ foreach (const QmlError &error, errorList) {
qWarning() << error;
}
@@ -463,8 +432,9 @@ QFxItem* QFxView::addItem(const QString &qml, QFxItem* parent)
QObject *obj = component.create();
if(d->component->isError()) {
- QList<QmlError> errors = d->component->errors();
- foreach (const QmlError &error, errors) {
+ QList<QmlError> errorList = d->component->errors();
+ emit errors(errorList);
+ foreach (const QmlError &error, errorList) {
qWarning() << error;
}
diff --git a/src/declarative/util/qfxview.h b/src/declarative/util/qfxview.h
index 05bf005..67de89b 100644
--- a/src/declarative/util/qfxview.h
+++ b/src/declarative/util/qfxview.h
@@ -88,9 +88,9 @@ public:
void dumpRoot();
- static void printErrorLine(const QmlError &);
Q_SIGNALS:
void sceneResized(QSize size);
+ void errors(const QList<QmlError> &error);
private Q_SLOTS:
void continueExecute();
diff --git a/src/declarative/util/qmlpalette.cpp b/src/declarative/util/qmlpalette.cpp
index eda0ded..40cfa71 100644
--- a/src/declarative/util/qmlpalette.cpp
+++ b/src/declarative/util/qmlpalette.cpp
@@ -151,6 +151,16 @@ QColor QmlPalette::highlightedText() const
return d->palette.color(d->group, QPalette::HighlightedText);
}
+QColor QmlPalette::lighter(const QColor& color) const
+{
+ return color.lighter();
+}
+
+QColor QmlPalette::darker(const QColor& color) const
+{
+ return color.darker();
+}
+
void QmlPalette::setColorGroup(QPalette::ColorGroup colorGroup)
{
Q_D(QmlPalette);
diff --git a/src/declarative/util/qmlpalette.h b/src/declarative/util/qmlpalette.h
index 1401ad1..7f26f9a 100644
--- a/src/declarative/util/qmlpalette.h
+++ b/src/declarative/util/qmlpalette.h
@@ -101,6 +101,9 @@ public:
bool virtual eventFilter(QObject *watched, QEvent *event);
bool virtual event(QEvent *event);
+ Q_INVOKABLE QColor lighter(const QColor&) const;
+ Q_INVOKABLE QColor darker(const QColor&) const;
+
Q_SIGNALS:
void paletteChanged();
};