From 3014b427aa8700890f9bd8ea2a0300fc152bf3d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 18 Aug 2010 17:06:19 +0200 Subject: Revert "Outline / fill inconsistency in X11 paint engine." This reverts commit ff405f5623d7ed18c881c097368e3e9afd2e9443. Reviewed-by: Trond --- src/gui/painting/qpaintengine_x11.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp index 5307142..e521e01 100644 --- a/src/gui/painting/qpaintengine_x11.cpp +++ b/src/gui/painting/qpaintengine_x11.cpp @@ -1516,8 +1516,8 @@ void QX11PaintEnginePrivate::fillPolygon_translated(const QPointF *polygonPoints for (int i = 0; i < pointCount; ++i) { translated_points[i] = polygonPoints[i] + offset; - translated_points[i].rx() = qFloor(translated_points[i].x()) + offs; - translated_points[i].ry() = qFloor(translated_points[i].y()) + offs; + translated_points[i].rx() = qRound(translated_points[i].x()) + offs; + translated_points[i].ry() = qRound(translated_points[i].y()) + offs; } fillPolygon_dev(translated_points.data(), pointCount, gcMode, mode); @@ -1754,8 +1754,8 @@ void QX11PaintEnginePrivate::fillPath(const QPainterPath &path, QX11PaintEngineP for (int j = 0; j < polys.at(i).size(); ++j) { translated_points[j] = polys.at(i).at(j); if (!X11->use_xrender || !(render_hints & QPainter::Antialiasing)) { - translated_points[j].rx() = qFloor(translated_points[j].rx() + aliasedCoordinateDelta) + offs; - translated_points[j].ry() = qFloor(translated_points[j].ry() + aliasedCoordinateDelta) + offs; + translated_points[j].rx() = qRound(translated_points[j].rx() + aliasedCoordinateDelta) + offs; + translated_points[j].ry() = qRound(translated_points[j].ry() + aliasedCoordinateDelta) + offs; } } -- cgit v0.12 From 041a68007413a20a9a9c97d0f2f04f9e03428f67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 18 Aug 2010 17:17:15 +0200 Subject: Revert "Fix the rendering of lines with the X11 paint engine" This reverts commit ebbab30af417dfbf3df47dec15c0e2f8d6a30fa6, which broke fill / outline consistency, and when trying to fix that by rounding the fill the same way that broke rendering in Creator. Unfortunately the X11 paint engine is too sensitive to changes, there have already been tons of patches to make it as consistent as possible. It's simply not possible to get the same rounding for both fill and outlines and at the same time have consistency between fill and outline (no holes or fill outside the outline), while using the integer based Xlib rendering API. Hopefully in 4.8 we'll switch to raster and the X11 paint engine will be a legacy. Reviewed-by: Trond --- src/gui/painting/qpaintengine_x11.cpp | 22 ++++++------ tests/auto/qpainter/tst_qpainter.cpp | 65 ----------------------------------- 2 files changed, 12 insertions(+), 75 deletions(-) diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp index e521e01..910b2df 100644 --- a/src/gui/painting/qpaintengine_x11.cpp +++ b/src/gui/painting/qpaintengine_x11.cpp @@ -696,10 +696,11 @@ void QX11PaintEngine::drawLines(const QLine *lines, int lineCount) linef = d->matrix.map(QLineF(lines[i])); } if (clipLine(&linef, d->polygonClipper.boundingRect())) { - int x1 = qFloor(linef.x1() + aliasedCoordinateDelta); - int y1 = qFloor(linef.y1() + aliasedCoordinateDelta); - int x2 = qFloor(linef.x2() + aliasedCoordinateDelta); - int y2 = qFloor(linef.y2() + aliasedCoordinateDelta); + int x1 = qRound(linef.x1() + aliasedCoordinateDelta); + int y1 = qRound(linef.y1() + aliasedCoordinateDelta); + int x2 = qRound(linef.x2() + aliasedCoordinateDelta); + int y2 = qRound(linef.y2() + aliasedCoordinateDelta); + XDrawLine(d->dpy, d->hd, d->gc, x1, y1, x2, y2); } } @@ -729,10 +730,11 @@ void QX11PaintEngine::drawLines(const QLineF *lines, int lineCount) for (int i = 0; i < lineCount; ++i) { QLineF linef = d->matrix.map(lines[i]); if (clipLine(&linef, d->polygonClipper.boundingRect())) { - int x1 = qFloor(linef.x1() + aliasedCoordinateDelta); - int y1 = qFloor(linef.y1() + aliasedCoordinateDelta); - int x2 = qFloor(linef.x2() + aliasedCoordinateDelta); - int y2 = qFloor(linef.y2() + aliasedCoordinateDelta); + int x1 = qRound(linef.x1() + aliasedCoordinateDelta); + int y1 = qRound(linef.y1() + aliasedCoordinateDelta); + int x2 = qRound(linef.x2() + aliasedCoordinateDelta); + int y2 = qRound(linef.y2() + aliasedCoordinateDelta); + XDrawLine(d->dpy, d->hd, d->gc, x1, y1, x2, y2); } } @@ -1688,8 +1690,8 @@ void QX11PaintEnginePrivate::strokePolygon_dev(const QPointF *polygonPoints, int if (clippedCount > 0) { QVarLengthArray xpoints(clippedCount); for (int i = 0; i < clippedCount; ++i) { - xpoints[i].x = qFloor(clippedPoints[i].x + aliasedCoordinateDelta); - xpoints[i].y = qFloor(clippedPoints[i].y + aliasedCoordinateDelta); + xpoints[i].x = qRound(clippedPoints[i].x + aliasedCoordinateDelta); + xpoints[i].y = qRound(clippedPoints[i].y + aliasedCoordinateDelta); } uint numberPoints = qMin(clippedCount, xlibMaxLinePoints); XPoint *pts = xpoints.data(); diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index 2cbb9b2..f358681 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -118,12 +118,10 @@ private slots: void drawLine_task190634(); void drawLine_task229459(); void drawLine_task234891(); - void drawHorizontalLineF(); void drawRect_data() { fillData(); } void drawRect(); void drawRect2(); - void drawRectFHorizontalLine(); void fillRect(); void fillRect2(); @@ -253,7 +251,6 @@ private slots: void setPenColorOnPixmap(); void QTBUG5939_attachPainterPrivate(); - void drawHorizontalLine(); private: void fillData(); @@ -1221,26 +1218,6 @@ void tst_QPainter::drawLine_task234891() QCOMPARE(expected, img); } -void tst_QPainter::drawHorizontalLineF() -{ - QPixmap pixmap(100, 3); - pixmap.fill(); - - { - QPainter painter(&pixmap); - painter.drawLine(QLineF(1.5f, 1.5f, 98.5f, 1.5f)); - } - - QImage refImage(100, 3, QImage::Format_ARGB32); - refImage.fill(0xFFFFFFFF); - { - QPainter painter(&refImage); - painter.drawLine(QLineF(1.5f, 1.5f, 98.5f, 1.5f)); - } - - QCOMPARE(pixmap.toImage().convertToFormat(QImage::Format_ARGB32), refImage); -} - void tst_QPainter::drawLine_task216948() { QImage img(1, 10, QImage::Format_ARGB32_Premultiplied); @@ -1325,26 +1302,6 @@ void tst_QPainter::drawRect2() } } -void tst_QPainter::drawRectFHorizontalLine() -{ - QPixmap pixmap(100, 3); - pixmap.fill(); - - { - QPainter painter(&pixmap); - painter.drawRect(QRectF(1.5f, 1.5f, 98.5f, 1.5f)); - } - - QImage refImage(100, 3, QImage::Format_ARGB32); - refImage.fill(0xFFFFFFFF); - { - QPainter painter(&refImage); - painter.drawRect(QRectF(1.5f, 1.5f, 98.5f, 1.5f)); - } - - QCOMPARE(pixmap.toImage().convertToFormat(QImage::Format_ARGB32), refImage); -} - void tst_QPainter::fillRect() { QImage image(100, 100, QImage::Format_ARGB32_Premultiplied); @@ -4565,28 +4522,6 @@ void tst_QPainter::QTBUG5939_attachPainterPrivate() QCOMPARE(widget->deviceTransform, proxy->deviceTransform); } -void tst_QPainter::drawHorizontalLine() -{ - QPixmap pixmap(100, 3); - pixmap.fill(); - - { - QPainter painter(&pixmap); - painter.translate(0.3, 0.3); - painter.drawLine(QLine(1, 1, 99, 1)); - } - - QImage refImage(100, 3, QImage::Format_ARGB32); - refImage.fill(0xFFFFFFFF); - { - QPainter painter(&refImage); - painter.translate(0.3, 0.3); - painter.drawLine(QLine(1, 1, 99, 1)); - } - - QCOMPARE(pixmap.toImage().convertToFormat(QImage::Format_ARGB32), refImage); -} - QTEST_MAIN(tst_QPainter) #include "tst_qpainter.moc" -- cgit v0.12 From 8e7fb343372acd0bc5fe04db7a5c5542541d4538 Mon Sep 17 00:00:00 2001 From: Carlos Manuel Duclos Vergara Date: Wed, 11 Aug 2010 15:47:40 +0200 Subject: Crash in QX11PaintEngine::drawPixmap We receive a pixmap as a const reference and then we convert it to an X11 pixmap. This conversion could fail for many reasons, however we were not looking at the result of this conversion. This patch was contributed by Christoph Feck from KDE. Task-number: QTBUG-12826 Reviewed-by: Samuel --- src/gui/painting/qpaintengine_x11.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp index 910b2df..fecf25f 100644 --- a/src/gui/painting/qpaintengine_x11.cpp +++ b/src/gui/painting/qpaintengine_x11.cpp @@ -1916,6 +1916,8 @@ void QX11PaintEngine::drawPixmap(const QRectF &r, const QPixmap &px, const QRect int sh = qRound(sr.height()); QPixmap pixmap = qt_toX11Pixmap(px); + if(pixmap.isNull()) + return; if ((d->xinfo && d->xinfo->screen() != pixmap.x11Info().screen()) || (pixmap.x11Info().screen() != DefaultScreen(X11->display))) { -- cgit v0.12 From 8dd8db250d92521fda619bdcf3e1c859b37b2da0 Mon Sep 17 00:00:00 2001 From: Carlos Manuel Duclos Vergara Date: Wed, 18 Aug 2010 17:59:04 +0200 Subject: Crash in QWidgetPrivate::init on QApplication::quit() using a modal dialog on Mac The problem was the order of deletion in the destructor. To autotest this I create an application, start a modal dialog and then quit the application. The fix was contributed by a customer. Task-number: QTBUG-12673 Reviewed-by: Olivier Goffart --- src/gui/kernel/qapplication.cpp | 24 ++++++++++++------------ tests/auto/qapplication/modal/base.cpp | 21 +++++++++++++++++++++ tests/auto/qapplication/modal/base.h | 23 +++++++++++++++++++++++ tests/auto/qapplication/modal/main.cpp | 11 +++++++++++ tests/auto/qapplication/modal/modal.pro | 8 ++++++++ tests/auto/qapplication/qapplication.pro | 1 + tests/auto/qapplication/tst_qapplication.cpp | 18 ++++++++++++++++++ 7 files changed, 94 insertions(+), 12 deletions(-) create mode 100644 tests/auto/qapplication/modal/base.cpp create mode 100644 tests/auto/qapplication/modal/base.h create mode 100644 tests/auto/qapplication/modal/main.cpp create mode 100644 tests/auto/qapplication/modal/modal.pro diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index e164baf..3d3a749 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -1055,6 +1055,18 @@ QApplication::~QApplication() QApplicationPrivate::is_app_closing = true; QApplicationPrivate::is_app_running = false; + // delete all widgets + if (QWidgetPrivate::allWidgets) { + QWidgetSet *mySet = QWidgetPrivate::allWidgets; + QWidgetPrivate::allWidgets = 0; + for (QWidgetSet::ConstIterator it = mySet->constBegin(); it != mySet->constEnd(); ++it) { + register QWidget *w = *it; + if (!w->parent()) // window + w->destroy(true, true); + } + delete mySet; + } + delete qt_desktopWidget; qt_desktopWidget = 0; @@ -1075,18 +1087,6 @@ QApplication::~QApplication() delete QWidgetPrivate::mapper; QWidgetPrivate::mapper = 0; - // delete all widgets - if (QWidgetPrivate::allWidgets) { - QWidgetSet *mySet = QWidgetPrivate::allWidgets; - QWidgetPrivate::allWidgets = 0; - for (QWidgetSet::ConstIterator it = mySet->constBegin(); it != mySet->constEnd(); ++it) { - register QWidget *w = *it; - if (!w->parent()) // window - w->destroy(true, true); - } - delete mySet; - } - delete QApplicationPrivate::app_pal; QApplicationPrivate::app_pal = 0; delete QApplicationPrivate::sys_pal; diff --git a/tests/auto/qapplication/modal/base.cpp b/tests/auto/qapplication/modal/base.cpp new file mode 100644 index 0000000..d3a7de6 --- /dev/null +++ b/tests/auto/qapplication/modal/base.cpp @@ -0,0 +1,21 @@ +#include "base.h" + +base::base(QWidget *parent) : + QWidget(parent) +{ + m_timer = new QTimer(this); + m_modalStarted = false; + m_timer->setSingleShot(false); + connect(m_timer, SIGNAL(timeout()), this, SLOT(periodicTimer())); + m_timer->start(5000); +} + +void base::periodicTimer() +{ + if(m_modalStarted) + exit(0); + m_modalDialog = new QDialog(this); + m_modalDialog->setModal(true); + m_modalDialog->show(); + m_modalStarted = true; +} diff --git a/tests/auto/qapplication/modal/base.h b/tests/auto/qapplication/modal/base.h new file mode 100644 index 0000000..ebf1198 --- /dev/null +++ b/tests/auto/qapplication/modal/base.h @@ -0,0 +1,23 @@ +#ifndef BASE_H +#define BASE_H + +#include +#include +#include + +class base : public QWidget +{ +Q_OBJECT + QTimer *m_timer; + bool m_modalStarted; + QDialog *m_modalDialog; +public: + explicit base(QWidget *parent = 0); + +signals: + +public slots: + void periodicTimer(); +}; + +#endif // BASE_H diff --git a/tests/auto/qapplication/modal/main.cpp b/tests/auto/qapplication/modal/main.cpp new file mode 100644 index 0000000..e1d39cf --- /dev/null +++ b/tests/auto/qapplication/modal/main.cpp @@ -0,0 +1,11 @@ +#include + +#include +#include "base.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + base *b = new base(); + return app.exec(); +} diff --git a/tests/auto/qapplication/modal/modal.pro b/tests/auto/qapplication/modal/modal.pro new file mode 100644 index 0000000..836f6ff --- /dev/null +++ b/tests/auto/qapplication/modal/modal.pro @@ -0,0 +1,8 @@ +TEMPLATE = app +TARGET = +DEPENDPATH += . +INCLUDEPATH += . +SOURCES += main.cpp \ + base.cpp +DESTDIR = ./ +HEADERS += base.h diff --git a/tests/auto/qapplication/qapplication.pro b/tests/auto/qapplication/qapplication.pro index 7814ad3..becc6c6 100644 --- a/tests/auto/qapplication/qapplication.pro +++ b/tests/auto/qapplication/qapplication.pro @@ -1,6 +1,7 @@ TEMPLATE = subdirs SUBDIRS = test \ desktopsettingsaware \ + modal \ wincmdline diff --git a/tests/auto/qapplication/tst_qapplication.cpp b/tests/auto/qapplication/tst_qapplication.cpp index 1a38070..91ae921 100644 --- a/tests/auto/qapplication/tst_qapplication.cpp +++ b/tests/auto/qapplication/tst_qapplication.cpp @@ -146,6 +146,7 @@ private slots: void symbianNeedForTraps(); void symbianLeaveThroughMain(); + void qtbug_12673(); }; class EventSpy : public QObject @@ -2239,6 +2240,23 @@ void tst_QApplication::symbianLeaveThroughMain() #endif } +void tst_QApplication::qtbug_12673() +{ +#ifdef Q_OS_SYMBIAN + QSKIP("This might not make sense in Symbian, but since I do not know how to test it I'll just skip it for now.", SkipAll); +#else + QProcess testProcess; + QStringList arguments; +#ifdef Q_OS_MAC + testProcess.start("modal/modal.app", arguments); +#else + testProcess.start("modal/modal", arguments); +#endif + QVERIFY(testProcess.waitForFinished(20000)); + QCOMPARE(testProcess.exitStatus(), QProcess::NormalExit); +#endif // Q_OS_SYMBIAN +} + //QTEST_APPLESS_MAIN(tst_QApplication) int main(int argc, char *argv[]) { -- cgit v0.12 From 0e443155c99a1ba9b990e7a2195132b2b8a1d36e Mon Sep 17 00:00:00 2001 From: Tuomas Suutari Date: Wed, 18 Aug 2010 12:41:24 +0200 Subject: QMake/Win32/MinGW: Fix ar script generating with absolute paths When QMake decides to use absolute path for some object file, this code used to leave the ADDMOD command out from the ar object script, which resulted in following errors from the issued "ar -M" command: Syntax error in archive script, line 2 Syntax error in archive script, line 3 etc... And the build failed in the linking phase, because the generated static library was empty. Fix this issue by prepending the file name with ADDMOD command even if the file path is absolute. Task-number: QTBUG-12959 Merge-request: 2451 Reviewed-by: Oswald Buddenhagen --- qmake/generators/win32/mingw_make.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp index 5685d6b..4717542 100644 --- a/qmake/generators/win32/mingw_make.cpp +++ b/qmake/generators/win32/mingw_make.cpp @@ -191,10 +191,7 @@ void createArObjectScriptFile(const QString &fileName, const QString &target, co QTextStream t(&file); t << "CREATE " << target << endl; for (QStringList::ConstIterator it = objList.constBegin(); it != objList.constEnd(); ++it) { - if (QDir::isRelativePath(*it)) - t << "ADDMOD " << *it << endl; - else - t << *it << endl; + t << "ADDMOD " << *it << endl; } t << "SAVE" << endl; t.flush(); -- cgit v0.12 From 4583ab15437c7744e8f08adafa1baccec238c1fa Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 18 Aug 2010 17:49:32 +0200 Subject: fix shadow builds with scratchbox seems it doesn't grok xargs -I. as some other unixes don't grok cp -s, we have two paths now ... Reviewed-by: joerg --- configure | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 7c3f9a3..bd69a0a 100755 --- a/configure +++ b/configure @@ -2414,10 +2414,15 @@ if [ "$OPT_SHADOW" = "yes" ]; then # Special case for mkspecs/features directory. # To be able to place .prf files into a shadow build directory, # we're creating links for files only. The directory structure is reproduced. - # A simple "cp -rs" doesn't work on Mac. :( rm -rf "$outpath/mkspecs/features" - find "$relpath/mkspecs/features" -type d | sed "s,^$relpath,$outpath," | xargs mkdir -p - find "$relpath/mkspecs/features" -type f | sed "s,^$relpath/,," | xargs -n 1 -I % ln -s "$relpath/%" "$outpath/%" + if [ "$UNAME_SYSTEM" = "Linux" ]; then + # This works with GNU coreutils, and is needed for ScratchBox + cp -rs "$relpath/mkspecs/features" "$outpath/mkspecs/features" + else + # A simple "cp -rs" doesn't work on Mac. :( + find "$relpath/mkspecs/features" -type d | sed "s,^$relpath,$outpath," | xargs mkdir -p + find "$relpath/mkspecs/features" -type f | sed "s,^$relpath/,," | xargs -n 1 -I % ln -s "$relpath/%" "$outpath/%" + fi # symlink the doc directory rm -rf "$outpath/doc" -- cgit v0.12 From 76d1c995e5bce542c5aa22e7bbf8a012fd5cb50e Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 18 Aug 2010 11:43:23 +0200 Subject: create missing output directories for substituted files it wasn't the fault of fileFixify() after all ... Reviewed-by: joerg --- qmake/generators/makefile.cpp | 1 + tests/auto/qmake/testdata/substitutes/test.pro | 3 +-- tests/auto/qmake/tst_qmake.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index 851e587..852471d 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -538,6 +538,7 @@ MakefileGenerator::init() continue; } } + mkdir(QFileInfo(out).absolutePath()); if(out.open(QFile::WriteOnly)) { v["QMAKE_INTERNAL_INCLUDED_FILES"].append(subs.at(i)); out.write(contents.toUtf8()); diff --git a/tests/auto/qmake/testdata/substitutes/test.pro b/tests/auto/qmake/testdata/substitutes/test.pro index 5bce312..ddad93f 100644 --- a/tests/auto/qmake/testdata/substitutes/test.pro +++ b/tests/auto/qmake/testdata/substitutes/test.pro @@ -1,2 +1 @@ -QMAKE_SUBSTITUTES += test.in -# doesn't work for the time being: sub/test2.in +QMAKE_SUBSTITUTES += test.in sub/test2.in diff --git a/tests/auto/qmake/tst_qmake.cpp b/tests/auto/qmake/tst_qmake.cpp index 1a3f843..060fa01 100644 --- a/tests/auto/qmake/tst_qmake.cpp +++ b/tests/auto/qmake/tst_qmake.cpp @@ -483,13 +483,13 @@ void tst_qmake::substitutes() QString workDir = base_path + "/testdata/substitutes"; QVERIFY( test_compiler.qmake( workDir, "test" )); QVERIFY( test_compiler.exists( workDir, "test", Plain, "" )); - //QVERIFY( test_compiler.exists( workDir, "sub/test2", Plain, "" )); + QVERIFY( test_compiler.exists( workDir, "sub/test2", Plain, "" )); QVERIFY( test_compiler.makeDistClean( workDir )); QString buildDir = base_path + "/testdata/substitutes_build"; QVERIFY( test_compiler.qmake( workDir, "test", buildDir )); QVERIFY( test_compiler.exists( buildDir, "test", Plain, "" )); - //QVERIFY( test_compiler.exists( buildDir, "sub/test2", Plain, "" )); + QVERIFY( test_compiler.exists( buildDir, "sub/test2", Plain, "" )); QVERIFY( test_compiler.makeDistClean( buildDir )); } -- cgit v0.12 From 2eba19cdaa859dc9b06eb12f2dea9da27b69ea74 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 18 Aug 2010 20:42:06 +0200 Subject: use intel linker and librarian with icc Reviewed-by: thiago Task-number: QTBUG-12937 --- mkspecs/win32-icc/qmake.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mkspecs/win32-icc/qmake.conf b/mkspecs/win32-icc/qmake.conf index 3ae18b6..2dd796d 100644 --- a/mkspecs/win32-icc/qmake.conf +++ b/mkspecs/win32-icc/qmake.conf @@ -50,7 +50,7 @@ QMAKE_RUN_CXX = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$obj $src QMAKE_RUN_CXX_IMP = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ $< QMAKE_RUN_CXX_IMP_BATCH = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ @<< -QMAKE_LINK = link +QMAKE_LINK = xilink QMAKE_LFLAGS = /NOLOGO QMAKE_LFLAGS_RELEASE = QMAKE_LFLAGS_DEBUG = /DEBUG @@ -72,7 +72,7 @@ QMAKE_UIC = $$[QT_INSTALL_BINS]\\uic.exe QMAKE_IDC = $$[QT_INSTALL_BINS]\\idc.exe QMAKE_IDL = midl -QMAKE_LIB = lib /NOLOGO +QMAKE_LIB = xilib /NOLOGO QMAKE_RC = rc QMAKE_ZIP = zip -r -9 -- cgit v0.12 From bf141a24864e48e997ea3b626ad25bf5b232c2fb Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Thu, 19 Aug 2010 08:19:41 +1000 Subject: Added license headers to new files. --- tests/auto/qapplication/modal/base.cpp | 41 ++++++++++++++++++++++++++++++++++ tests/auto/qapplication/modal/base.h | 41 ++++++++++++++++++++++++++++++++++ tests/auto/qapplication/modal/main.cpp | 41 ++++++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+) diff --git a/tests/auto/qapplication/modal/base.cpp b/tests/auto/qapplication/modal/base.cpp index d3a7de6..9022c36 100644 --- a/tests/auto/qapplication/modal/base.cpp +++ b/tests/auto/qapplication/modal/base.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "base.h" base::base(QWidget *parent) : diff --git a/tests/auto/qapplication/modal/base.h b/tests/auto/qapplication/modal/base.h index ebf1198..faa1765 100644 --- a/tests/auto/qapplication/modal/base.h +++ b/tests/auto/qapplication/modal/base.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #ifndef BASE_H #define BASE_H diff --git a/tests/auto/qapplication/modal/main.cpp b/tests/auto/qapplication/modal/main.cpp index e1d39cf..f9d8fb4 100644 --- a/tests/auto/qapplication/modal/main.cpp +++ b/tests/auto/qapplication/modal/main.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include #include -- cgit v0.12 From 4d1f74c9c8f26e978f4c3487f2bd8a9af219167f Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Thu, 19 Aug 2010 14:34:30 +1000 Subject: cleanup and remove __FUNCTION__, which breaks build on solaris Task-number: QTBUG-12904 --- src/plugins/bearer/connman/qconnmanengine.cpp | 4 ---- .../bearer/connman/qconnmanservice_linux.cpp | 23 ++-------------------- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/src/plugins/bearer/connman/qconnmanengine.cpp b/src/plugins/bearer/connman/qconnmanengine.cpp index 3b5ae86..341f7cd 100644 --- a/src/plugins/bearer/connman/qconnmanengine.cpp +++ b/src/plugins/bearer/connman/qconnmanengine.cpp @@ -328,7 +328,6 @@ QString QConnmanEngine::getServiceForNetwork(const QString &netPath) void QConnmanEngine::propertyChangedContext(const QString &path,const QString &item, const QDBusVariant &value) { Q_UNUSED(path); -// qDebug() << __FUNCTION__ << path << item << value.variant(); QMutexLocker locker(&mutex); if(item == "Services") { @@ -380,12 +379,10 @@ void QConnmanEngine::servicePropertyChangedContext(const QString &path,const QSt void QConnmanEngine::networkPropertyChangedContext(const QString &path,const QString &item, const QDBusVariant &value) { QMutexLocker locker(&mutex); -// qDebug() << __FUNCTION__ << path << item << value.variant(); } void QConnmanEngine::devicePropertyChangedContext(const QString &devpath,const QString &item,const QDBusVariant &value) { -// qDebug() << __FUNCTION__ << devpath << item << value.variant(); QMutexLocker locker(&mutex); if(item == "Networks") { @@ -429,7 +426,6 @@ void QConnmanEngine::devicePropertyChangedContext(const QString &devpath,const Q void QConnmanEngine::technologyPropertyChangedContext(const QString & path, const QString &item, const QDBusVariant &value) { -// qDebug() << __FUNCTION__ << path << item << value.variant(); if(item == "Devices") { QDBusArgument arg = qvariant_cast(value.variant()); QStringList list = qdbus_cast(arg); diff --git a/src/plugins/bearer/connman/qconnmanservice_linux.cpp b/src/plugins/bearer/connman/qconnmanservice_linux.cpp index b15589e..3722c43 100644 --- a/src/plugins/bearer/connman/qconnmanservice_linux.cpp +++ b/src/plugins/bearer/connman/qconnmanservice_linux.cpp @@ -481,9 +481,7 @@ QVariant QConnmanProfileInterface::getProperty(const QString &property) QVariantMap map = getProperties(); if (map.contains(property)) { var = map.value(property); - } else { - qDebug() <<__FUNCTION__<< "Could not find" << property; - } + } return var; } @@ -522,8 +520,6 @@ QConnmanServiceInterface::~QConnmanServiceInterface() void QConnmanServiceInterface::connectNotify(const char *signal) { -// qWarning() << __FUNCTION__ << signal << this->path(); - if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), this->path(), @@ -569,9 +565,7 @@ QVariant QConnmanServiceInterface::getProperty(const QString &property) QVariantMap map = getProperties(); if (map.contains(property)) { var = map.value(property); - } else { -// qDebug() <<__FUNCTION__<< "Could not find" << property; - } + } return var; } @@ -1051,17 +1045,7 @@ QVariantMap QConnmanDeviceInterface::getProperties() bool QConnmanDeviceInterface::setProperty(const QString &name, const QDBusVariant &value) { - -// QList args; -#ifndef QT_NO_TEXTSTREAM - qWarning() << __FUNCTION__ << name << value.variant(); -#endif -// args << qVariantFromValue(name); -// args << qVariantFromValue(value); - QDBusMessage reply = this->call(QLatin1String("SetProperty"),name, qVariantFromValue(value)); -qWarning() << reply.errorMessage(); - return true; } @@ -1150,7 +1134,6 @@ bool QConnmanDeviceInterface::setEnabled(bool powered) << qVariantFromValue(QDBusVariant(powered)); QDBusMessage reply = this->callWithArgumentList(QDBus::AutoDetect,QLatin1String("SetProperty"),args); - qWarning() << reply.errorMessage() << reply.errorName(); return true; } @@ -1166,8 +1149,6 @@ QConnmanDBusHelper::~QConnmanDBusHelper() void QConnmanDBusHelper::propertyChanged(const QString &item, const QDBusVariant &var) { QDBusMessage msg = this->message(); -// qWarning() << sender(); - // qWarning() << msg.interface() << msg.path() << item << var.variant() <<"\n"; Q_EMIT propertyChangedContext(msg.path() ,item, var); } -- cgit v0.12 From 015b726aa46e774155bc13359dcd68d15df73bbd Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 19 Aug 2010 16:35:40 +1000 Subject: Without Declarative, still build and run QtDemo If declarative is configured out then QtDemo will now still build, with all declarative demos disabled. Task-number: QTBUG-12983 --- demos/qtdemo/mainwindow.h | 1 - demos/qtdemo/menumanager.cpp | 32 ++++++++++++++++++++++---------- demos/qtdemo/menumanager.h | 7 ++++++- demos/qtdemo/qtdemo.pro | 6 +++++- 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/demos/qtdemo/mainwindow.h b/demos/qtdemo/mainwindow.h index e613268..b8cfda6 100644 --- a/demos/qtdemo/mainwindow.h +++ b/demos/qtdemo/mainwindow.h @@ -43,7 +43,6 @@ #define MAIN_WINDOW_H #include -#include #include class DemoTextItem; diff --git a/demos/qtdemo/menumanager.cpp b/demos/qtdemo/menumanager.cpp index 5b851b4..f98c2fc 100644 --- a/demos/qtdemo/menumanager.cpp +++ b/demos/qtdemo/menumanager.cpp @@ -356,6 +356,7 @@ void MenuManager::launchExample(const QString &name) void MenuManager::launchQmlExample(const QString &name) { +#ifndef QT_NO_DECLARATIVE if(!qmlRoot){ exampleError(QProcess::UnknownError); return; @@ -382,6 +383,11 @@ void MenuManager::launchQmlExample(const QString &name) qmlRoot->setProperty("qmlFile", QVariant(""));//unload component qmlRoot->setProperty("show", QVariant(true)); qmlRoot->setProperty("qmlFile", QUrl::fromLocalFile(file.fileName())); +#else + QMessageBox::critical(0, tr("Failed to launch the example"), + tr("This application was built without the QtDeclarative module, and therefore declarative examples have been disabled."), + QMessageBox::Cancel); +#endif } void MenuManager::exampleFinished() @@ -427,21 +433,26 @@ void MenuManager::init(MainWindow *window) level2MenuNode = level2MenuNode.nextSibling(); } + qmlRoot = 0; +#ifndef QT_NO_DECLARATIVE // Create QML Loader declarativeEngine = new QDeclarativeEngine(this); QDeclarativeComponent component(declarativeEngine, QUrl("qrc:qml/qmlShell.qml"), this); - qmlRoot = 0; - if(component.isReady()) - qmlRoot = qobject_cast(component.create()); - else + QDeclarativeItem* qmlRootItem = 0; + if(component.isReady()){ + qmlRoot = component.create(); + qmlRootItem = qobject_cast(qmlRoot); + }else{ qDebug() << component.status() << component.errorString(); - if(qmlRoot){ - qmlRoot->setHeight(this->window->scene->sceneRect().height()); - qmlRoot->setWidth(this->window->scene->sceneRect().width()); - qmlRoot->setZValue(101);//Above other items - qmlRoot->setCursor(Qt::ArrowCursor); - window->scene->addItem(qmlRoot); + } + + if(qmlRootItem){ + qmlRootItem->setHeight(this->window->scene->sceneRect().height()); + qmlRootItem->setWidth(this->window->scene->sceneRect().width()); + qmlRootItem->setZValue(101);//Above other items + qmlRootItem->setCursor(Qt::ArrowCursor); + window->scene->addItem(qmlRootItem); //Note that QML adds key handling to the app. window->viewport()->setFocusPolicy(Qt::NoFocus);//Correct keyboard focus handling @@ -451,6 +462,7 @@ void MenuManager::init(MainWindow *window) }else{ qDebug() << "Error initializing QML subsystem, Declarative examples will not work"; } +#endif } void MenuManager::readInfoAboutExample(const QDomElement &example) diff --git a/demos/qtdemo/menumanager.h b/demos/qtdemo/menumanager.h index 5e14204..e4303c8 100644 --- a/demos/qtdemo/menumanager.h +++ b/demos/qtdemo/menumanager.h @@ -45,6 +45,9 @@ #include #include #include +#ifndef QT_NO_DECLARATIVE +#include +#endif #include "score.h" #include "textbutton.h" @@ -83,8 +86,10 @@ public: Score *score; int currentMenuCode; + QObject *qmlRoot; +#ifndef QT_NO_DECLARATIVE QDeclarativeEngine* declarativeEngine; - QDeclarativeItem *qmlRoot; +#endif private slots: void exampleFinished(); diff --git a/demos/qtdemo/qtdemo.pro b/demos/qtdemo/qtdemo.pro index 61ea376..836178b 100644 --- a/demos/qtdemo/qtdemo.pro +++ b/demos/qtdemo/qtdemo.pro @@ -6,13 +6,17 @@ DESTDIR = $$DEMO_DESTDIR/bin INSTALLS += target sources -QT += xml network declarative +QT += xml network contains(QT_CONFIG, opengl) { DEFINES += QT_OPENGL_SUPPORT QT += opengl } +contains(QT_CONFIG, declarative) { + QT += declarative +} + build_all:!build_pass { CONFIG -= build_all CONFIG += release -- cgit v0.12 From 386b4900912d8d784860e60c17838a7b61d387a5 Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Thu, 19 Aug 2010 16:30:07 +1000 Subject: Fix Image element svg autotest Also, reduced some platform-specific test as the test case is not meant to test regression in the painting routines, but that Image's svg support works. Task-number: Reviewed-by: Martin Jones --- .../qdeclarativeimage/data/heart-arm.png | Bin 12596 -> 0 bytes .../qdeclarativeimage/data/heart-mac.png | Bin 12621 -> 0 bytes .../qdeclarativeimage/data/heart-win32.png | Bin 12621 -> 12457 bytes .../declarative/qdeclarativeimage/data/heart.png | Bin 12577 -> 12424 bytes .../qdeclarativeimage/data/heart200-arm.png | Bin 8063 -> 0 bytes .../qdeclarativeimage/data/heart200-mac.png | Bin 8062 -> 0 bytes .../qdeclarativeimage/data/heart200-win32.png | Bin 8062 -> 7939 bytes .../declarative/qdeclarativeimage/data/heart200.png | Bin 8063 -> 7943 bytes .../qdeclarativeimage/tst_qdeclarativeimage.cpp | 16 ++++------------ 9 files changed, 4 insertions(+), 12 deletions(-) delete mode 100644 tests/auto/declarative/qdeclarativeimage/data/heart-arm.png delete mode 100644 tests/auto/declarative/qdeclarativeimage/data/heart-mac.png delete mode 100644 tests/auto/declarative/qdeclarativeimage/data/heart200-arm.png delete mode 100644 tests/auto/declarative/qdeclarativeimage/data/heart200-mac.png diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart-arm.png b/tests/auto/declarative/qdeclarativeimage/data/heart-arm.png deleted file mode 100644 index 3245027..0000000 Binary files a/tests/auto/declarative/qdeclarativeimage/data/heart-arm.png and /dev/null differ diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart-mac.png b/tests/auto/declarative/qdeclarativeimage/data/heart-mac.png deleted file mode 100644 index d7df0e4..0000000 Binary files a/tests/auto/declarative/qdeclarativeimage/data/heart-mac.png and /dev/null differ diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart-win32.png b/tests/auto/declarative/qdeclarativeimage/data/heart-win32.png index 351da13..5992e79 100644 Binary files a/tests/auto/declarative/qdeclarativeimage/data/heart-win32.png and b/tests/auto/declarative/qdeclarativeimage/data/heart-win32.png differ diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart.png b/tests/auto/declarative/qdeclarativeimage/data/heart.png index 372b224..ff93f6c 100644 Binary files a/tests/auto/declarative/qdeclarativeimage/data/heart.png and b/tests/auto/declarative/qdeclarativeimage/data/heart.png differ diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart200-arm.png b/tests/auto/declarative/qdeclarativeimage/data/heart200-arm.png deleted file mode 100644 index b16db76..0000000 Binary files a/tests/auto/declarative/qdeclarativeimage/data/heart200-arm.png and /dev/null differ diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart200-mac.png b/tests/auto/declarative/qdeclarativeimage/data/heart200-mac.png deleted file mode 100644 index df22325..0000000 Binary files a/tests/auto/declarative/qdeclarativeimage/data/heart200-mac.png and /dev/null differ diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart200-win32.png b/tests/auto/declarative/qdeclarativeimage/data/heart200-win32.png index 4976ff9..19b20a8 100644 Binary files a/tests/auto/declarative/qdeclarativeimage/data/heart200-win32.png and b/tests/auto/declarative/qdeclarativeimage/data/heart200-win32.png differ diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart200.png b/tests/auto/declarative/qdeclarativeimage/data/heart200.png index 786e75d..5a31ae8 100644 Binary files a/tests/auto/declarative/qdeclarativeimage/data/heart200.png and b/tests/auto/declarative/qdeclarativeimage/data/heart200.png differ diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp index b8d2828..0f1050e 100644 --- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -274,14 +274,10 @@ void tst_qdeclarativeimage::svg() QCOMPARE(obj->pixmap().height(), 300); QCOMPARE(obj->width(), 550.0); QCOMPARE(obj->height(), 500.0); -#if defined(Q_OS_MAC) - QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart-mac.png")); +#if defined(Q_OS_LINUX) + QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart.png")); #elif defined(Q_OS_WIN32) QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart-win32.png")); -#elif defined(QT_ARCH_ARM) - QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart-arm.png")); -#else - QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart.png")); #endif obj->setSourceSize(QSize(200,200)); @@ -290,14 +286,10 @@ void tst_qdeclarativeimage::svg() QCOMPARE(obj->pixmap().height(), 200); QCOMPARE(obj->width(), 550.0); QCOMPARE(obj->height(), 500.0); -#if defined(Q_OS_MAC) - QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200-mac.png")); +#if defined(Q_OS_LINUX) + QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200.png")); #elif defined(Q_OS_WIN32) QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200-win32.png")); -#elif defined(QT_ARCH_ARM) - QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200-arm.png")); -#else - QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200.png")); #endif delete obj; } -- cgit v0.12 From 91f47532111927c7b8d5cd9981ded7bc0c203d88 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 19 Aug 2010 10:04:58 +0200 Subject: qdoc3: Added more pagewords & elements to the search index. Task-nr: QTBUG-11113 --- tools/qdoc3/htmlgenerator.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 8215ddc..6fbc2a9 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -4502,6 +4502,12 @@ bool HtmlGenerator::generatePageElement(QXmlStreamWriter& writer, pageWords << title; break; } + + Node* parent = node->parent(); + if (parent && ((parent->type() == Node::Class) || + (parent->type() == Node::Namespace))) { + pageWords << parent->name(); + } } writer.writeAttribute("id",t); -- cgit v0.12 From f894befedf669fb864a500b0aa395157ff0fb929 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 17 Aug 2010 15:38:33 +0200 Subject: QDeclarativeImageProvider: Do not keep the global declarative mutex locked when processing. The point is to be able to process images in a thread. If the mutex is locked, this is useless. Use case is a slow QDeclarativeImageProvider that generates thumbmails from large files. Even with the asynchronous attribute set to true, the gui thread would be blocked by the mutex. By using QSharedPointer, I also fix the leak of the providers (which were not deleted) Reviewed-by: Martin Jones --- src/declarative/qml/qdeclarativeengine.cpp | 15 +-- src/declarative/qml/qdeclarativeengine_p.h | 2 +- src/declarative/qml/qdeclarativeimageprovider.cpp | 4 +- .../tst_qdeclarativeimageprovider.cpp | 105 +++++++++++++++++++-- 4 files changed, 110 insertions(+), 16 deletions(-) diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 513fc65..bc7468f 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -674,7 +674,7 @@ void QDeclarativeEngine::addImageProvider(const QString &providerId, QDeclarativ { Q_D(QDeclarativeEngine); QMutexLocker locker(&d->mutex); - d->imageProviders.insert(providerId, provider); + d->imageProviders.insert(providerId, QSharedPointer(provider)); } /*! @@ -684,7 +684,7 @@ QDeclarativeImageProvider *QDeclarativeEngine::imageProvider(const QString &prov { Q_D(const QDeclarativeEngine); QMutexLocker locker(&d->mutex); - return d->imageProviders.value(providerId); + return d->imageProviders.value(providerId).data(); } /*! @@ -698,13 +698,14 @@ void QDeclarativeEngine::removeImageProvider(const QString &providerId) { Q_D(QDeclarativeEngine); QMutexLocker locker(&d->mutex); - delete d->imageProviders.take(providerId); + d->imageProviders.take(providerId); } QDeclarativeImageProvider::ImageType QDeclarativeEnginePrivate::getImageProviderType(const QUrl &url) { QMutexLocker locker(&mutex); - QDeclarativeImageProvider *provider = imageProviders.value(url.host()); + QSharedPointer provider = imageProviders.value(url.host()); + locker.unlock(); if (provider) return provider->imageType(); return static_cast(-1); @@ -714,7 +715,8 @@ QImage QDeclarativeEnginePrivate::getImageFromProvider(const QUrl &url, QSize *s { QMutexLocker locker(&mutex); QImage image; - QDeclarativeImageProvider *provider = imageProviders.value(url.host()); + QSharedPointer provider = imageProviders.value(url.host()); + locker.unlock(); if (provider) image = provider->requestImage(url.path().mid(1), size, req_size); return image; @@ -724,7 +726,8 @@ QPixmap QDeclarativeEnginePrivate::getPixmapFromProvider(const QUrl &url, QSize { QMutexLocker locker(&mutex); QPixmap pixmap; - QDeclarativeImageProvider *provider = imageProviders.value(url.host()); + QSharedPointer provider = imageProviders.value(url.host()); + locker.unlock(); if (provider) pixmap = provider->requestPixmap(url.path().mid(1), size, req_size); return pixmap; diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h index 3b5dd5a..db2db35 100644 --- a/src/declarative/qml/qdeclarativeengine_p.h +++ b/src/declarative/qml/qdeclarativeengine_p.h @@ -232,7 +232,7 @@ public: mutable QNetworkAccessManager *networkAccessManager; mutable QDeclarativeNetworkAccessManagerFactory *networkAccessManagerFactory; - QHash imageProviders; + QHash > imageProviders; QDeclarativeImageProvider::ImageType getImageProviderType(const QUrl &url); QImage getImageFromProvider(const QUrl &url, QSize *size, const QSize& req_size); QPixmap getPixmapFromProvider(const QUrl &url, QSize *size, const QSize& req_size); diff --git a/src/declarative/qml/qdeclarativeimageprovider.cpp b/src/declarative/qml/qdeclarativeimageprovider.cpp index ea68327..ef31be7 100644 --- a/src/declarative/qml/qdeclarativeimageprovider.cpp +++ b/src/declarative/qml/qdeclarativeimageprovider.cpp @@ -161,7 +161,9 @@ QDeclarativeImageProvider::QDeclarativeImageProvider(ImageType type) } /*! - \internal + Destroys the QDeclarativeImageProvider + + \note The destructor of your derived class need to be thread safe. */ QDeclarativeImageProvider::~QDeclarativeImageProvider() { diff --git a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp index e0b46f0..4a9224e 100644 --- a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp +++ b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir @@ -85,6 +86,8 @@ private slots: void removeProvider_data(); void removeProvider(); + void threadTest(); + private: QString newImageFileName() const; void fillRequestTestsData(const QString &id); @@ -95,9 +98,15 @@ private: class TestQImageProvider : public QDeclarativeImageProvider { public: - TestQImageProvider() - : QDeclarativeImageProvider(Image) + TestQImageProvider(bool *deleteWatch = 0) + : QDeclarativeImageProvider(Image), deleteWatch(deleteWatch) + { + } + + ~TestQImageProvider() { + if (deleteWatch) + *deleteWatch = true; } QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize) @@ -114,6 +123,8 @@ public: image = image.scaled(requestedSize); return image; } + + bool *deleteWatch; }; Q_DECLARE_METATYPE(TestQImageProvider*); @@ -121,11 +132,17 @@ Q_DECLARE_METATYPE(TestQImageProvider*); class TestQPixmapProvider : public QDeclarativeImageProvider { public: - TestQPixmapProvider() - : QDeclarativeImageProvider(Pixmap) + TestQPixmapProvider(bool *deleteWatch = 0) + : QDeclarativeImageProvider(Pixmap), deleteWatch(deleteWatch) { } + ~TestQPixmapProvider() + { + if (deleteWatch) + *deleteWatch = true; + } + QPixmap requestPixmap(const QString &id, QSize *size, const QSize& requestedSize) { if (id == QLatin1String("no-such-file.png")) @@ -140,6 +157,8 @@ public: image = image.scaled(requestedSize); return image; } + + bool *deleteWatch; }; Q_DECLARE_METATYPE(TestQPixmapProvider*); @@ -225,7 +244,9 @@ void tst_qdeclarativeimageprovider::requestImage_sync_data() void tst_qdeclarativeimageprovider::requestImage_sync() { - runTest(false, new TestQImageProvider); + bool deleteWatch = false; + runTest(false, new TestQImageProvider(&deleteWatch)); + QVERIFY(deleteWatch); } void tst_qdeclarativeimageprovider::requestImage_async_data() @@ -235,7 +256,9 @@ void tst_qdeclarativeimageprovider::requestImage_async_data() void tst_qdeclarativeimageprovider::requestImage_async() { - runTest(true, new TestQImageProvider); + bool deleteWatch = false; + runTest(true, new TestQImageProvider(&deleteWatch)); + QVERIFY(deleteWatch); } void tst_qdeclarativeimageprovider::requestPixmap_sync_data() @@ -245,13 +268,15 @@ void tst_qdeclarativeimageprovider::requestPixmap_sync_data() void tst_qdeclarativeimageprovider::requestPixmap_sync() { - runTest(false, new TestQPixmapProvider); + bool deleteWatch = false; + runTest(false, new TestQPixmapProvider(&deleteWatch)); + QVERIFY(deleteWatch); } void tst_qdeclarativeimageprovider::requestPixmap_async() { QDeclarativeEngine engine; - QDeclarativeImageProvider *provider = new TestQPixmapProvider; + QDeclarativeImageProvider *provider = new TestQPixmapProvider(); engine.addImageProvider("test", provider); QVERIFY(engine.imageProvider("test") != 0); @@ -305,6 +330,70 @@ void tst_qdeclarativeimageprovider::removeProvider() delete obj; } +class TestThreadProvider : public QDeclarativeImageProvider +{ + public: + TestThreadProvider() : QDeclarativeImageProvider(Image), ok(false) {} + + ~TestThreadProvider() {} + + QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize) + { + mutex.lock(); + if (!ok) + cond.wait(&mutex); + mutex.unlock(); + QVector v; + for (int i = 0; i < 10000; i++) + v.prepend(i); //do some computation + QImage image(50,50, QImage::Format_RGB32); + image.fill(QColor(id).rgb()); + if (size) + *size = image.size(); + if (requestedSize.isValid()) + image = image.scaled(requestedSize); + return image; + } + + QWaitCondition cond; + QMutex mutex; + bool ok; +}; + + +void tst_qdeclarativeimageprovider::threadTest() +{ + QDeclarativeEngine engine; + + TestThreadProvider *provider = new TestThreadProvider; + + engine.addImageProvider("test_thread", provider); + QVERIFY(engine.imageProvider("test_thread") != 0); + + QString componentStr = "import Qt 4.7\nItem { \n" + "Image { source: \"image://test_thread/blue\"; asynchronous: true; }\n" + "Image { source: \"image://test_thread/red\"; asynchronous: true; }\n" + "Image { source: \"image://test_thread/green\"; asynchronous: true; }\n" + "Image { source: \"image://test_thread/yellow\"; asynchronous: true; }\n" + " }"; + QDeclarativeComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QObject *obj = component.create(); + //MUST not deadlock + QVERIFY(obj != 0); + QList images = obj->findChildren(); + QCOMPARE(images.count(), 4); + QTest::qWait(100); + foreach(QDeclarativeImage *img, images) { + QCOMPARE(img->status(), QDeclarativeImage::Loading); + } + provider->ok = true; + provider->cond.wakeAll(); + foreach(QDeclarativeImage *img, images) { + TRY_WAIT(img->status() == QDeclarativeImage::Ready); + } +} + QTEST_MAIN(tst_qdeclarativeimageprovider) -- cgit v0.12 From acb18f598d96f4e193b85045a1e2d05272e4100b Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 18 Aug 2010 14:16:02 +0200 Subject: QTextCodec: fix wodring of a comment --- src/corelib/codecs/qtextcodec_symbian.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/corelib/codecs/qtextcodec_symbian.cpp b/src/corelib/codecs/qtextcodec_symbian.cpp index e4db9d7..20e0cfc 100644 --- a/src/corelib/codecs/qtextcodec_symbian.cpp +++ b/src/corelib/codecs/qtextcodec_symbian.cpp @@ -53,8 +53,10 @@ struct QSymbianCodecInitData { const char *aliases; }; -/* This table contains the known Symbian codecs aliases. It is ordered by charsetId. - It is required as symbian does not provide have aliases. +/* This table contains the known Symbian codecs aliases. + It is required because symbian does not provide aliases for codecs. + It is also faster to have a name here than asking the system. + It is ordered by charsetId to allow binary search lookup */ static const QSymbianCodecInitData codecsData[] = { { /*268439485*/ KCharacterSetIdentifierShiftJis, 17, "Shift_JIS\0MS_Kanji\0csShiftJIS\0MS_KANJI\0SJIS\0" }, -- cgit v0.12 From c0fa797ba33f0d15be1ba5d4b3587f47ccb02f0f Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 19 Aug 2010 12:47:03 +0200 Subject: qdoc3: Added more pagewords & elements to the search index. Task-nr: QTBUG-11113 --- doc/src/xml-processing/xquery-introduction.qdoc | 1 + tools/qdoc3/htmlgenerator.cpp | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/src/xml-processing/xquery-introduction.qdoc b/doc/src/xml-processing/xquery-introduction.qdoc index b79c205..b5356f7 100644 --- a/doc/src/xml-processing/xquery-introduction.qdoc +++ b/doc/src/xml-processing/xquery-introduction.qdoc @@ -29,6 +29,7 @@ \page xquery-introduction.html \title A Short Path to XQuery +\pagekeywords XPath XQuery \startpage XQuery \target XQuery-introduction diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 6fbc2a9..f3390de 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -4436,6 +4436,9 @@ bool HtmlGenerator::generatePageElement(QXmlStreamWriter& writer, if (node->isInnerNode()) { const InnerNode* inner = static_cast(node); + if (!inner->pageKeywords().isEmpty()) + pageWords << inner->pageKeywords(); + switch (node->type()) { case Node::Fake: { @@ -4463,9 +4466,6 @@ bool HtmlGenerator::generatePageElement(QXmlStreamWriter& writer, pageWords << title; break; } - - if (!inner->pageKeywords().isEmpty()) - pageWords << inner->pageKeywords(); } else { switch (node->type()) { -- cgit v0.12 From f30adf43b9331dbf0bb3768fb7694af5bce66c4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 19 Aug 2010 13:19:31 +0200 Subject: Made GL pixmap backend respect Qt::NoOpaqueDetection flag.. We don't want to do the opaque image scan when the Qt::NoOpaqueDetection flag is set. Reviewed-by: Trond --- src/opengl/qpixmapdata_gl.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp index 653e805..1efd398 100644 --- a/src/opengl/qpixmapdata_gl.cpp +++ b/src/opengl/qpixmapdata_gl.cpp @@ -367,7 +367,7 @@ void QGLPixmapData::ensureCreated() const } void QGLPixmapData::fromImage(const QImage &image, - Qt::ImageConversionFlags /*flags*/) + Qt::ImageConversionFlags flags) { if (image.size() == QSize(w, h)) setSerialNumber(++qt_gl_pixmap_serial); @@ -381,7 +381,9 @@ void QGLPixmapData::fromImage(const QImage &image, if (qApp->desktop()->depth() == 16) format = QImage::Format_RGB16; - if (image.hasAlphaChannel() && const_cast(image).data_ptr()->checkForAlphaPixels()) + if (image.hasAlphaChannel() + && ((flags & Qt::NoOpaqueDetection) + || const_cast(image).data_ptr()->checkForAlphaPixels())) format = QImage::Format_ARGB32_Premultiplied;; m_source = image.convertToFormat(format); -- cgit v0.12 From d0a25e466ea0234d03caff4ab0742484c37ae39f Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 19 Aug 2010 13:58:44 +0200 Subject: doc: Removed comment about automatic inclusion of 3rd party library. It must be copied into the appliv=cation bundle automatically. --- doc/src/deployment/deployment.qdoc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/doc/src/deployment/deployment.qdoc b/doc/src/deployment/deployment.qdoc index 00771ed..f2908bd 100644 --- a/doc/src/deployment/deployment.qdoc +++ b/doc/src/deployment/deployment.qdoc @@ -1442,10 +1442,8 @@ \endlist \note If you want a 3rd party library to be included in your - application bundle, then you must add an excplicit lib entry for - that library to your application's .pro file. Otherwise, the - \c macdeployqt tool will not copy the 3rd party .dylib into the - bundle. + application bundle, then you must copy the library into the + bundle manually, after the bundle is created. \c macdeployqt supports the following options: \list -- cgit v0.12 From da005580969b2501a246027f47f75ed3ee52670e Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 19 Aug 2010 14:46:10 +0200 Subject: Fixes a regression preventing loading images without extensions Task-number: QTBUG-12560 Reviewed-by: gabi --- src/gui/image/qpixmap.cpp | 3 --- tests/auto/qpixmap/tst_qpixmap.cpp | 18 +++++++++++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index ef9be8f..1c0ceff 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -830,9 +830,6 @@ bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConvers return false; QFileInfo info(fileName); - if (!info.exists()) - return false; - QString key = QLatin1Literal("qt_pixmap") % info.absoluteFilePath() % HexString(info.lastModified().toTime_t()) diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index f22edf6..e461b64 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -1673,31 +1673,39 @@ void tst_QPixmap::preserveDepth() void tst_QPixmap::loadAsBitmapOrPixmap() { QImage tmp(10, 10, QImage::Format_RGB32); - tmp.save("tmp.png"); + tmp.save("temp_image.png"); bool ok; // Check that we can load the pixmap as a pixmap and that it then turns into a pixmap - QPixmap pixmap("tmp.png"); + QPixmap pixmap("temp_image.png"); QVERIFY(!pixmap.isNull()); QVERIFY(pixmap.depth() > 1); QVERIFY(!pixmap.isQBitmap()); pixmap = QPixmap(); - ok = pixmap.load("tmp.png"); + ok = pixmap.load("temp_image.png"); + QVERIFY(ok); + QVERIFY(!pixmap.isNull()); + QVERIFY(pixmap.depth() > 1); + QVERIFY(!pixmap.isQBitmap()); + + //now we can try to load it without an extension + pixmap = QPixmap(); + ok = pixmap.load("temp_image"); QVERIFY(ok); QVERIFY(!pixmap.isNull()); QVERIFY(pixmap.depth() > 1); QVERIFY(!pixmap.isQBitmap()); // The do the same check for bitmaps.. - QBitmap bitmap("tmp.png"); + QBitmap bitmap("temp_image.png"); QVERIFY(!bitmap.isNull()); QVERIFY(bitmap.depth() == 1); QVERIFY(bitmap.isQBitmap()); bitmap = QBitmap(); - ok = bitmap.load("tmp.png"); + ok = bitmap.load("temp_image.png"); QVERIFY(ok); QVERIFY(!bitmap.isNull()); QVERIFY(bitmap.depth() == 1); -- cgit v0.12 From 1d991c8df38e0c5e75f99ad26ebcbe35ff674751 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 19 Aug 2010 15:00:22 +0200 Subject: qdoc: Added more elements to qt.pageindex Task-nr: QTBUG-11113 --- tools/qdoc3/htmlgenerator.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index f3390de..3e79a9f 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -4537,6 +4537,35 @@ bool HtmlGenerator::generatePageElement(QXmlStreamWriter& writer, } writer.writeEndElement(); writer.writeEndElement(); + + if (node->type() == Node::Fake && node->doc().hasTableOfContents()) { + QList toc = node->doc().tableOfContents(); + if (!toc.isEmpty()) { + for (int i = 0; i < toc.size(); ++i) { + Text headingText = Text::sectionHeading(toc.at(i)); + QString s = headingText.toString(); + writer.writeStartElement("page"); + t.setNum(id++); + QString internalUrl = url + "#" + Doc::canonicalTitle(s); + writer.writeAttribute("id",t); + writer.writeStartElement("pageWords"); + writer.writeCharacters(pageWords.join(" ")); + writer.writeCharacters(" "); + writer.writeCharacters(s); + writer.writeEndElement(); + writer.writeStartElement("pageTitle"); + writer.writeCharacters(s); + writer.writeEndElement(); + writer.writeStartElement("pageUrl"); + writer.writeCharacters(internalUrl); + writer.writeEndElement(); + writer.writeStartElement("pageType"); + writer.writeCharacters("Article"); + writer.writeEndElement(); + writer.writeEndElement(); + } + } + } return true; } -- cgit v0.12 From 76bce7b04ceaae174c8ef0db5223f2dd17d9b102 Mon Sep 17 00:00:00 2001 From: Carlos Manuel Duclos Vergara Date: Thu, 19 Aug 2010 15:03:05 +0200 Subject: Fatal crash on solaris 64 bit We use a dummy variable for a function call, and that variable is causing a data misalignment. Changing the type to long fixes the issue. According to Denis it is ok to change this for all cases. Task-number: QTBUG-12928 Reviewed-by: Denis Dzyubenko --- src/gui/kernel/qclipboard_x11.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qclipboard_x11.cpp b/src/gui/kernel/qclipboard_x11.cpp index 9fcc718..4b75f0a 100644 --- a/src/gui/kernel/qclipboard_x11.cpp +++ b/src/gui/kernel/qclipboard_x11.cpp @@ -456,7 +456,8 @@ QClipboard::QClipboard(QObject *parent) XCheckIfEvent(X11->display, &ev, &qt_init_timestamp_scanner, (XPointer)&data); if (data.timestamp == CurrentTime) { setupOwner(); - int dummy = 0; + // We need this value just for completeness, we don't use it. + long dummy = 0; Window ownerId = owner->internalWinId(); XChangeProperty(X11->display, ownerId, ATOM(CLIP_TEMPORARY), XA_INTEGER, 32, -- cgit v0.12 From a957ed92a61d9311ed163dba15f2b6f8d30bf03c Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 18 Aug 2010 15:36:09 +0100 Subject: Ensure geometry of top-level widget accounts for S60 screen furniture If the S60 screen furniture has already been constructed before QWidgetPrivate::show_sys() is called on a top-level widget which has Qt::WindowMaximized set (e.g. due to a showMaximized() call), its geometry is set to the full screen extent, including the regions covered by the status bar and CBA. This patch ensures that calculation of the widget geometry always takes into account the screen furniture. Task-number: QTBUG-12605 Reviewed-by: Jason Barron --- src/gui/kernel/qwidget_s60.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 319f330..7ab9fbc 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -482,14 +482,13 @@ void QWidgetPrivate::show_sys() activateSymbianWindow(); QSymbianControl *id = static_cast(q->internalWinId()); + const bool isFullscreen = q->windowState() & Qt::WindowFullScreen; #ifdef Q_WS_S60 // Lazily initialize the S60 screen furniture when the first window is shown. if (!QApplication::testAttribute(Qt::AA_S60DontConstructApplicationPanes) && !S60->buttonGroupContainer() && !S60->statusPane()) { - bool isFullscreen = q->windowState() & Qt::WindowFullScreen; - if (!q->testAttribute(Qt::WA_DontShowOnScreen)) { // Create the status pane and CBA here @@ -504,23 +503,24 @@ void QWidgetPrivate::show_sys() // Can't use AppUi directly because it privately inherits from MEikStatusPaneObserver. QSymbianControl *desktopControl = static_cast(QApplication::desktop()->winId()); S60->statusPane()->SetObserver(desktopControl); - - // Hide the status pane if fullscreen OR - // Fill client area if maximized OR - // Put window below status pane unless the window has an explicit position. - if (isFullscreen) { + if (isFullscreen) S60->statusPane()->MakeVisible(false); - } else if (q->windowState() & Qt::WindowMaximized) { - TRect r = static_cast(S60->appUi())->ClientRect(); - id->SetExtent(r.iTl, r.Size()); - } else if (!q->testAttribute(Qt::WA_Moved)) { - id->SetPosition(static_cast(S60->appUi())->ClientRect().iTl); - } } } } #endif + // Fill client area if maximized OR + // Put window below status pane unless the window has an explicit position. + if (!isFullscreen) { + if (q->windowState() & Qt::WindowMaximized) { + TRect r = static_cast(S60->appUi())->ClientRect(); + id->SetExtent(r.iTl, r.Size()); + } else if (!q->testAttribute(Qt::WA_Moved)) { + id->SetPosition(static_cast(S60->appUi())->ClientRect().iTl); + } + } + id->MakeVisible(true); if(q->isWindow()) -- cgit v0.12 From f0c1beda18d79097ab85f062e9125da175ad04b8 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 19 Aug 2010 18:03:16 +1000 Subject: Add info to Loader docs about receiving signals and key events --- doc/src/snippets/declarative/loader/KeyReader.qml | 53 ++++++++++ doc/src/snippets/declarative/loader/MyItem.qml | 55 +++++++++++ .../snippets/declarative/loader/connections.qml | 57 +++++++++++ doc/src/snippets/declarative/loader/focus.qml | 62 ++++++++++++ doc/src/snippets/declarative/loader/simple.qml | 54 +++++++++++ .../graphicsitems/qdeclarativeloader.cpp | 107 +++++++++++++-------- 6 files changed, 349 insertions(+), 39 deletions(-) create mode 100644 doc/src/snippets/declarative/loader/KeyReader.qml create mode 100644 doc/src/snippets/declarative/loader/MyItem.qml create mode 100644 doc/src/snippets/declarative/loader/connections.qml create mode 100644 doc/src/snippets/declarative/loader/focus.qml create mode 100644 doc/src/snippets/declarative/loader/simple.qml diff --git a/doc/src/snippets/declarative/loader/KeyReader.qml b/doc/src/snippets/declarative/loader/KeyReader.qml new file mode 100644 index 0000000..4423ac6 --- /dev/null +++ b/doc/src/snippets/declarative/loader/KeyReader.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import Qt 4.7 + +Item { + Item { + focus: true + Keys.onPressed: { + console.log("Loaded item captured:", event.text); + event.accepted = true; + } + } +} +//![0] diff --git a/doc/src/snippets/declarative/loader/MyItem.qml b/doc/src/snippets/declarative/loader/MyItem.qml new file mode 100644 index 0000000..cc69661 --- /dev/null +++ b/doc/src/snippets/declarative/loader/MyItem.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import Qt 4.7 + +Rectangle { + id: myItem + signal message(string msg) + + width: 100; height: 100 + + MouseArea { + anchors.fill: parent + onClicked: myItem.message("clicked!") + } +} +//![0] diff --git a/doc/src/snippets/declarative/loader/connections.qml b/doc/src/snippets/declarative/loader/connections.qml new file mode 100644 index 0000000..babac4e --- /dev/null +++ b/doc/src/snippets/declarative/loader/connections.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import Qt 4.7 + +Item { + width: 100; height: 100 + + Loader { + id: myLoader + source: "MyItem.qml" + } + + Connections { + target: myLoader.item + onMessage: console.log(msg) + } +} +//![0] diff --git a/doc/src/snippets/declarative/loader/focus.qml b/doc/src/snippets/declarative/loader/focus.qml new file mode 100644 index 0000000..464d986 --- /dev/null +++ b/doc/src/snippets/declarative/loader/focus.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import Qt 4.7 + +Rectangle { + width: 200; height: 200 + + Loader { + id: loader + focus: true + } + + MouseArea { + anchors.fill: parent + onClicked: loader.source = "KeyReader.qml" + } + + Keys.onPressed: { + console.log("Captured:", event.text); + } +} +//![0] + diff --git a/doc/src/snippets/declarative/loader/simple.qml b/doc/src/snippets/declarative/loader/simple.qml new file mode 100644 index 0000000..e0dc6b3 --- /dev/null +++ b/doc/src/snippets/declarative/loader/simple.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import Qt 4.7 + +Item { + width: 200; height: 200 + + Loader { id: pageLoader } + + MouseArea { + anchors.fill: parent + onClicked: pageLoader.source = "Page1.qml" + } +} +//![0] diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp index 4c6268f..2fde4c8 100644 --- a/src/declarative/graphicsitems/qdeclarativeloader.cpp +++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp @@ -115,53 +115,76 @@ void QDeclarativeLoaderPrivate::initResize() \brief The Loader item allows dynamically loading an Item-based subtree from a URL or Component. - The Loader element instantiates an item from a component. The component to - be instantiated may be specified directly by the \l sourceComponent - property, or loaded from a URL via the \l source property. + Loader is used to dynamically load visual QML components. It can load a + QML file (using the \l source property) or a \l Component object (using + the \l sourceComponent property). It is useful for delaying the creation + of a component until it is required: for example, when a component should + be created on demand, or when a component should not be created + unnecessarily for performance reasons. - Loader can be used to delay the creation of a component until it - is required. For example, this loads "Page1.qml" as a component - into the Loader element, when the \l MouseArea is clicked: + Here is a Loader that loads "Page1.qml" as a component when the + \l MouseArea is clicked: - \code - import Qt 4.7 + \snippet doc/src/snippets/declarative/loader/simple.qml 0 - Item { - width: 200; height: 200 + The loaded item can be accessed using the \l item property. - MouseArea { - anchors.fill: parent - onClicked: pageLoader.source = "Page1.qml" - } + Loader is like any other visual item and must be positioned and sized + accordingly to become visible. Once the component is loaded, the Loader + is automatically resized to the size of the component. - Loader { id: pageLoader } - } - \endcode + If the \l source or \l sourceComponent changes, any previously instantiated + items are destroyed. Setting \l source to an empty string or setting + \l sourceComponent to \c undefined destroys the currently loaded item, + freeing resources and leaving the Loader empty. + + + \section2 Receiving signals from loaded items - Note that Loader is like any other graphical Item and needs to be positioned - and sized accordingly to become visible. When a component is loaded, the - Loader is automatically resized to the size of the component. + Any signals emitted from the loaded item can be received using the + \l Connections element. For example, the following \c application.qml + loads \c MyItem.qml, and is able to receive the \c message signal from + the loaded item through a \l Connections object: - If the Loader source is changed, any previous items instantiated - will be destroyed. Setting \l source to an empty string, or setting - sourceComponent to \e undefined - will destroy the currently instantiated items, freeing resources - and leaving the Loader empty. For example: + \table + \row + \o application.qml + \o MyItem.qml + \row + \o \snippet doc/src/snippets/declarative/loader/connections.qml 0 + \o \snippet doc/src/snippets/declarative/loader/MyItem.qml 0 + \endtable - \code - pageLoader.source = "" - \endcode + Alternatively, since \c MyItem.qml is loaded within the scope of the + Loader, it could also directly call any function defined in the Loader or + its parent \l Item. - or - \code - pageLoader.sourceComponent = undefined - \endcode + \section2 Focus and key events - unloads "Page1.qml" and frees resources consumed by it. + Loader is a focus scope. Its \l {Item::}{focus} property must be set to + \c true for any of its children to get the \e {active focus}. (See + \l{qmlfocus#Acquiring Focus and Focus Scopes}{the focus documentation page} + for more details.) Any key events received in the loaded item should likely + also be \l {KeyEvent::}{accepted} so they are not propagated to the Loader. - Note that Loader is a focus scope. Its \c focus property must be set to \c true for any of its children - to get the \e {active focus} (see \l{qmlfocus#Acquiring Focus and Focus Scopes}{the focus documentation page} for more details). + For example, the following \c application.qml loads \c KeyReader.qml when + the \l MouseArea is clicked. Notice the \l {Item::}{focus} property is + set to \c true for the Loader as well as the \l Item in the dynamically + loaded object: + + \table + \row + \o application.qml + \o KeyReader.qml + \row + \o \snippet doc/src/snippets/declarative/loader/focus.qml 0 + \o \snippet doc/src/snippets/declarative/loader/KeyReader.qml 0 + \endtable + + Once \c KeyReader.qml is loaded, it accepts key events and sets + \c event.accepted to \c true so that the event is not propagated to the + parent \l Rectangle. \sa {dynamic-object-creation}{Dynamic Object Creation} */ @@ -198,8 +221,13 @@ QDeclarativeLoader::~QDeclarativeLoader() /*! \qmlproperty url Loader::source - This property holds the URL of the QML component to - instantiate. + This property holds the URL of the QML component to instantiate. + + Note the QML component must be an \l Item-based component. Loader cannot + load non-visual components. + + To unload the currently loaded item, set this property to an empty string, + or set \l sourceComponent to \c undefined. \sa sourceComponent, status, progress */ @@ -258,7 +286,8 @@ void QDeclarativeLoader::setSource(const QUrl &url) } \endqml - Note this value must hold a \l Component object; it cannot be a \l Item. + To unload the currently loaded item, set this property to an empty string, + or set \l sourceComponent to \c undefined. \sa source, progress */ @@ -477,7 +506,7 @@ void QDeclarativeLoaderPrivate::_q_updateSize(bool loaderGeometryChanged) /*! \qmlproperty Item Loader::item - This property holds the top-level item created from source. + This property holds the top-level item that is currently loaded. */ QGraphicsObject *QDeclarativeLoader::item() const { -- cgit v0.12 From 1f515224d52c9a33b46bbf926e82d5c2df1a84e4 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Fri, 20 Aug 2010 11:10:44 +1000 Subject: Doing "import foo.qml" doesn't work in QML anymore Task-number: QTBUG-13042 --- doc/src/getting-started/gettingstartedqml.qdoc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/doc/src/getting-started/gettingstartedqml.qdoc b/doc/src/getting-started/gettingstartedqml.qdoc index 885e6ce..a19d281 100644 --- a/doc/src/getting-started/gettingstartedqml.qdoc +++ b/doc/src/getting-started/gettingstartedqml.qdoc @@ -224,15 +224,13 @@ \code import Qt 4.7 \\import the main Qt QML module import "folderName" \\import the contents of the folder - import "Button.qml" \\import a QML file - import "NewButton.qml" as ButtonModule \\import a QML file and give it a name import "script.js" as Script \\import a Javascript file and name it as Script \endcode - To use the \c Button element in \c FileMenu.qml, we need to import \c Button.qml. - The syntax shown above, shows how to use the \c import keyword. However, the - \c {import Button.qml} is not necessary; qmlviewer will import all the contents - of the current directory. We can directly create a \c Button element by declaring + The syntax shown above shows how to use the \c import keyword. This is required to + use JavaScript files, or QML files that are not within the same directory. Since + \c Button.qml is in the same directory as \c FileMenu.qml, we do not need to import + the \c Button.qml file to use it. We can directly create a \c Button element by declaring \c Button{}, similar to a \c Rectangle{} declaration. \code -- cgit v0.12 From 43c2a627123d9f4a884dbe96e1ef6dbde02e50d5 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Fri, 20 Aug 2010 14:53:22 +1000 Subject: Add a quit button to declarative examples in QtDemo --- demos/qtdemo/qmlShell.qml | 58 ++++++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 33 deletions(-) diff --git a/demos/qtdemo/qmlShell.qml b/demos/qtdemo/qmlShell.qml index b5fdf39..b8a019e 100644 --- a/demos/qtdemo/qmlShell.qml +++ b/demos/qtdemo/qmlShell.qml @@ -100,6 +100,30 @@ Item { } } + Rectangle{ id: closeButton + width: 24 + height: 24 + z: 11 + border.color: "#aaaaaaaa" + gradient: Gradient{ + GradientStop{ position: 0.0; color: "#34FFFFFF" } + GradientStop{ position: 1.0; color: "#7AFFFFFF" } + } + anchors.left: frame.right + anchors.bottom: frame.top + anchors.margins: -(2*width/3) + Text{ + text: 'X' + font.bold: true + color: "white" + font.pixelSize: 12 + anchors.centerIn: parent + } + MouseArea{ + anchors.fill: parent + onClicked: main.show = false; + } + } Text{ id: errorTxt @@ -116,32 +140,6 @@ Item { onLinkActivated: Qt.openUrlExternally(link); } } - Rectangle{ - id: helpLabel - property bool timedOut: false - z: 9 - //Positioned in the top left corner - x: 8 - y: 8 - color: "white" - border.color: "black" - border.width: 1 - width: helpText.width + 16 - height: helpText.height + 8 - Text{ - id: helpText - color: "black" - anchors.centerIn: parent - text: "Click outside the example to exit it." - } - opacity: 0 - Behavior on opacity{ NumberAnimation{duration:500} } - Timer{ - id: helpTimer - interval: 5000 - onTriggered: {helpLabel.timedOut=true} - } - } Rectangle{ id: blackout //Maybe use a colorize effect instead? z: 8 anchors.fill: parent @@ -154,7 +152,6 @@ Item { hoverEnabled: main.show //To steal focus from the buttons acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton anchors.fill: parent - onClicked: main.show=false; } states: [ @@ -166,10 +163,6 @@ Item { opacity: 1 } PropertyChanges { - target: helpLabel - opacity: helpLabel.timedOut?0:1 - } - PropertyChanges { target: blackout opacity: 0.5 } @@ -178,8 +171,7 @@ Item { transitions: [//Should not be too long, because the component has already started running Transition { from: ''; to: "show"; reversible: true ParallelAnimation{ - ScriptAction{ script: {helpLabel.timedOut = false; helpTimer.restart();} } - NumberAnimation{ exclude: helpLabel; properties: "opacity"; easing.type: Easing.InQuad; duration: 500} + NumberAnimation{ properties: "opacity"; easing.type: Easing.InQuad; duration: 500} PropertyAction { target: loader; property: "focus"; value: true}//Might be needed to ensure the focus stays with us } } -- cgit v0.12 From e8141d3eff43e419f566449f42f9548ce54acf70 Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Fri, 20 Aug 2010 14:09:51 +1000 Subject: Fix minehunt demo for Symbian Task-number: QTBUG-8927 Reviewed-by: Alan Alpert --- demos/declarative/minehunt/MinehuntCore/qmldir | 1 - demos/declarative/minehunt/README | 7 +- demos/declarative/minehunt/main.cpp | 70 ++++++++++++++ demos/declarative/minehunt/minehunt.cpp | 117 +--------------------- demos/declarative/minehunt/minehunt.h | 129 +++++++++++++++++++++++++ demos/declarative/minehunt/minehunt.pro | 36 ++----- doc/src/examples/qml-minehunt.qdoc | 2 +- 7 files changed, 216 insertions(+), 146 deletions(-) create mode 100644 demos/declarative/minehunt/main.cpp create mode 100644 demos/declarative/minehunt/minehunt.h diff --git a/demos/declarative/minehunt/MinehuntCore/qmldir b/demos/declarative/minehunt/MinehuntCore/qmldir index 2beccf9..81980e0 100644 --- a/demos/declarative/minehunt/MinehuntCore/qmldir +++ b/demos/declarative/minehunt/MinehuntCore/qmldir @@ -1,3 +1,2 @@ -plugin qmlminehuntplugin Explosion 1.0 Explosion.qml Tile 1.0 Tile.qml diff --git a/demos/declarative/minehunt/README b/demos/declarative/minehunt/README index b9f1d2a..3849ca5 100644 --- a/demos/declarative/minehunt/README +++ b/demos/declarative/minehunt/README @@ -1,3 +1,6 @@ -To compile the C++ part, do 'qmake && make'. Minehunt will not run properly if the C++ plugin is not compiled. +Minehunt has to be compiled to run. + +To compile the C++ part, do 'qmake && make'. +To run, simply run the executable. +To deploy on a device, do 'make sis'. -To run, simply load the minehunt.qml file with the qml runtime. diff --git a/demos/declarative/minehunt/main.cpp b/demos/declarative/minehunt/main.cpp new file mode 100644 index 0000000..fc223dd --- /dev/null +++ b/demos/declarative/minehunt/main.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +#include "minehunt.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + QDeclarativeView canvas; + + qmlRegisterType(); + MinehuntGame* game = new MinehuntGame(); + +#ifdef Q_OS_SYMBIAN + canvas.setResizeMode(QDeclarativeView::SizeRootObjectToView); +#endif + canvas.engine()->rootContext()->setContextObject(game); + canvas.setSource(QString("minehunt.qml")); + +#ifdef Q_OS_SYMBIAN + canvas.showFullScreen(); +#else + canvas.setGeometry(QRect(100, 100, 450, 450)); + canvas.show(); +#endif + return app.exec(); +} diff --git a/demos/declarative/minehunt/minehunt.cpp b/demos/declarative/minehunt/minehunt.cpp index 2a4ed10..9c82f30 100644 --- a/demos/declarative/minehunt/minehunt.cpp +++ b/demos/declarative/minehunt/minehunt.cpp @@ -40,99 +40,10 @@ ****************************************************************************/ #include -#include -#include -#include -#include - #include #include -class TileData : public QObject -{ - Q_OBJECT -public: - TileData() : _hasFlag(false), _hasMine(false), _hint(-1), _flipped(false) {} - - Q_PROPERTY(bool hasFlag READ hasFlag WRITE setHasFlag NOTIFY hasFlagChanged) - bool hasFlag() const { return _hasFlag; } - - Q_PROPERTY(bool hasMine READ hasMine NOTIFY hasMineChanged) - bool hasMine() const { return _hasMine; } - - Q_PROPERTY(int hint READ hint NOTIFY hintChanged) - int hint() const { return _hint; } - - Q_PROPERTY(bool flipped READ flipped NOTIFY flippedChanged()) - bool flipped() const { return _flipped; } - - void setHasFlag(bool flag) {if(flag==_hasFlag) return; _hasFlag = flag; emit hasFlagChanged();} - void setHasMine(bool mine) {if(mine==_hasMine) return; _hasMine = mine; emit hasMineChanged();} - void setHint(int hint) { if(hint == _hint) return; _hint = hint; emit hintChanged(); } - void flip() { if (_flipped) return; _flipped = true; emit flippedChanged(); } - void unflip() { if(!_flipped) return; _flipped = false; emit flippedChanged(); } - -signals: - void flippedChanged(); - void hasFlagChanged(); - void hintChanged(); - void hasMineChanged(); - -private: - bool _hasFlag; - bool _hasMine; - int _hint; - bool _flipped; -}; - -class MinehuntGame : public QObject -{ - Q_OBJECT -public: - MinehuntGame(); - - Q_PROPERTY(QDeclarativeListProperty tiles READ tiles CONSTANT) - QDeclarativeListProperty tiles(); - - Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY isPlayingChanged) - bool isPlaying() {return playing;} - - Q_PROPERTY(bool hasWon READ hasWon NOTIFY hasWonChanged) - bool hasWon() {return won;} - - Q_PROPERTY(int numMines READ numMines NOTIFY numMinesChanged) - int numMines() const{return nMines;} - - Q_PROPERTY(int numFlags READ numFlags NOTIFY numFlagsChanged) - int numFlags() const{return nFlags;} - -public slots: - Q_INVOKABLE bool flip(int row, int col); - Q_INVOKABLE bool flag(int row, int col); - void setBoard(); - void reset(); - -signals: - void isPlayingChanged(); - void hasWonChanged(); - void numMinesChanged(); - void numFlagsChanged(); - -private: - bool onBoard( int r, int c ) const { return r >= 0 && r < numRows && c >= 0 && c < numCols; } - TileData *tile( int row, int col ) { return onBoard(row, col) ? _tiles[col+numRows*row] : 0; } - int getHint(int row, int col); - void setPlaying(bool b){if(b==playing) return; playing=b; emit isPlayingChanged();} - - QList _tiles; - int numCols; - int numRows; - bool playing; - bool won; - int remaining; - int nMines; - int nFlags; -}; +#include "minehunt.h" void tilesPropAppend(QDeclarativeListProperty* prop, TileData* value) { @@ -306,29 +217,3 @@ bool MinehuntGame::flag(int row, int col) emit numFlagsChanged(); return true; } - -class MinehuntExtensionPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT - - public: - void registerTypes(const char *uri) { - Q_UNUSED(uri); - qmlRegisterType(); - } - - void initializeEngine(QDeclarativeEngine *engine, const char *uri) { - Q_UNUSED(uri); - - srand(QTime(0,0,0).secsTo(QTime::currentTime())); - - MinehuntGame* game = new MinehuntGame(); - - engine->rootContext()->setContextObject(game); - } -}; - -#include "minehunt.moc" - -Q_EXPORT_PLUGIN(MinehuntExtensionPlugin); - diff --git a/demos/declarative/minehunt/minehunt.h b/demos/declarative/minehunt/minehunt.h new file mode 100644 index 0000000..962cf3d --- /dev/null +++ b/demos/declarative/minehunt/minehunt.h @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include + +class TileData : public QObject +{ + Q_OBJECT +public: + TileData() : _hasFlag(false), _hasMine(false), _hint(-1), _flipped(false) {} + + Q_PROPERTY(bool hasFlag READ hasFlag WRITE setHasFlag NOTIFY hasFlagChanged) + bool hasFlag() const { return _hasFlag; } + + Q_PROPERTY(bool hasMine READ hasMine NOTIFY hasMineChanged) + bool hasMine() const { return _hasMine; } + + Q_PROPERTY(int hint READ hint NOTIFY hintChanged) + int hint() const { return _hint; } + + Q_PROPERTY(bool flipped READ flipped NOTIFY flippedChanged()) + bool flipped() const { return _flipped; } + + void setHasFlag(bool flag) {if(flag==_hasFlag) return; _hasFlag = flag; emit hasFlagChanged();} + void setHasMine(bool mine) {if(mine==_hasMine) return; _hasMine = mine; emit hasMineChanged();} + void setHint(int hint) { if(hint == _hint) return; _hint = hint; emit hintChanged(); } + void flip() { if (_flipped) return; _flipped = true; emit flippedChanged(); } + void unflip() { if(!_flipped) return; _flipped = false; emit flippedChanged(); } + +signals: + void flippedChanged(); + void hasFlagChanged(); + void hintChanged(); + void hasMineChanged(); + +private: + bool _hasFlag; + bool _hasMine; + int _hint; + bool _flipped; +}; + +class MinehuntGame : public QObject +{ + Q_OBJECT +public: + MinehuntGame(); + + Q_PROPERTY(QDeclarativeListProperty tiles READ tiles CONSTANT) + QDeclarativeListProperty tiles(); + + Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY isPlayingChanged) + bool isPlaying() {return playing;} + + Q_PROPERTY(bool hasWon READ hasWon NOTIFY hasWonChanged) + bool hasWon() {return won;} + + Q_PROPERTY(int numMines READ numMines NOTIFY numMinesChanged) + int numMines() const{return nMines;} + + Q_PROPERTY(int numFlags READ numFlags NOTIFY numFlagsChanged) + int numFlags() const{return nFlags;} + +public slots: + Q_INVOKABLE bool flip(int row, int col); + Q_INVOKABLE bool flag(int row, int col); + void setBoard(); + void reset(); + +signals: + void isPlayingChanged(); + void hasWonChanged(); + void numMinesChanged(); + void numFlagsChanged(); + +private: + bool onBoard( int r, int c ) const { return r >= 0 && r < numRows && c >= 0 && c < numCols; } + TileData *tile( int row, int col ) { return onBoard(row, col) ? _tiles[col+numRows*row] : 0; } + int getHint(int row, int col); + void setPlaying(bool b){if(b==playing) return; playing=b; emit isPlayingChanged();} + + QList _tiles; + int numCols; + int numRows; + bool playing; + bool won; + int remaining; + int nMines; + int nFlags; +}; diff --git a/demos/declarative/minehunt/minehunt.pro b/demos/declarative/minehunt/minehunt.pro index f85afeb..1d56013 100644 --- a/demos/declarative/minehunt/minehunt.pro +++ b/demos/declarative/minehunt/minehunt.pro @@ -1,38 +1,22 @@ -TEMPLATE = lib -TARGET = qmlminehuntplugin +TEMPLATE = app +TARGET = minehunt QT += declarative CONFIG += qt plugin -TARGET = $$qtLibraryTarget($$TARGET) -DESTDIR = MinehuntCore - # Input -SOURCES += minehunt.cpp +HEADERS += minehunt.h +SOURCES += main.cpp minehunt.cpp -sources.files = minehunt.qml minehunt.pro +sources.files = minehunt.qml minehunt.pro MinehuntCore sources.path = $$[QT_INSTALL_DEMOS]/declarative/minehunt +target.path = $$[QT_INSTALL_DEMOS]/declarative/minehunt -target.path = $$[QT_INSTALL_DEMOS]/declarative/minehunt/MinehuntCore - -MinehuntCore_sources.files = \ - MinehuntCore/Explosion.qml \ - MinehuntCore/Tile.qml \ - MinehuntCore/pics \ - MinehuntCore/qmldir -MinehuntCore_sources.path = $$[QT_INSTALL_DEMOS]/declarative/minehunt/MinehuntCore - -INSTALLS = sources MinehuntCore_sources target +INSTALLS = sources target symbian:{ TARGET.EPOCALLOWDLLDATA = 1 include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) - TARGET.CAPABILITY = NetworkServices ReadUserData - importFiles.sources = MinehuntCore/qmlminehuntplugin.dll \ - MinehuntCore/Explosion.qml \ - MinehuntCore/pics \ - MinehuntCore/qmldir - importFiles.path = MinehuntCore - DEPLOYMENT = importFiles + qmlminehuntfiles.sources = MinehuntCore minehunt.qml + DEPLOYMENT = qmlminehuntfiles } - -INSTALLS = sources MinehuntCore_sources target + \ No newline at end of file diff --git a/doc/src/examples/qml-minehunt.qdoc b/doc/src/examples/qml-minehunt.qdoc index be82302..e1ff22f 100644 --- a/doc/src/examples/qml-minehunt.qdoc +++ b/doc/src/examples/qml-minehunt.qdoc @@ -30,7 +30,7 @@ \example demos/declarative/minehunt This demo shows how to create a simple Minehunt game, using QML for the - UI and a C++ plugin for the game logic. + UI and C++ for the game logic. \image qml-minehunt-demo.png */ -- cgit v0.12